noalyss
Version-6.7.2
|
Public Member Functions | |
input ($p_array=null, $p_readonly=false) | |
if an array if receive the keys are p_date p_depot f_idX f_id sg_codeX sg_type0 | |
record_save ($p_array) | |
Static Public Member Functions | |
static | insert_goods (&$p_cn, $p_array) |
Insert into stock_goods from ACH and VEN. |
Definition at line 30 of file class_stock_goods.php.
Stock_Goods::input | ( | $ | p_array = null , |
$ | p_readonly = false |
||
) |
if an array if receive the keys are p_date p_depot f_idX f_id sg_codeX sg_type0
$cn database connx
$p_array | if an array if receive the keys are p_date p_depot f_idX f_id sg_codeX sg_type0 |
$p_readonly | true or false |
Definition at line 50 of file class_stock_goods.php.
References $cn, $date, $e, $fiche, $label, $nb, $p_array, $p_readonly, $row, cn, exit, extra, NoAccess(), HtmlInput\select_stock(), trim(), and value.
{ global $cn; if ($p_array != null) { extract($p_array); } else { $p_date = ''; $p_motif = ''; $p_depot = 0; } $date = new IDate('p_date', $p_date); $date->setReadOnly($p_readonly); $motif = new IText('p_motif', $p_motif); $motif->setReadOnly($p_readonly); $motif->size = 80; $idepo = HtmlInput::select_stock($cn, "p_depot", "W"); $idepo->setReadOnly($p_readonly); if (count($idepo->value) == 0) { NoAccess(); exit(); } $idepo->selected = $p_depot; if ($p_readonly ) { $nb=$row; } else { if (isset ($row ) ) { $nb=($row > MAX_ARTICLE_STOCK)?$row:MAX_ARTICLE_STOCK; }else { $nb=MAX_ARTICLE_STOCK; } } for ($e = 0; $e < $nb; $e++) {//ATTR_DEF_STOCKfiche_ $sg_code[$e] = new ICard('sg_code' . $e); $sg_code[$e]->extra = "[sql] fd_id = 500000"; $sg_code[$e]->set_attribute("typecard", $sg_code[$e]->extra); $sg_code[$e]->set_attribute("label", "label" . $e); $sg_code[$e]->value = (isset(${'sg_code' . $e})) ? ${'sg_code' . $e} : ''; $sg_quantity[$e] = new INum('sg_quantity' . $e); $sg_quantity[$e]->value = (isset(${'sg_quantity' . $e})) ? ${'sg_quantity' . $e} : ''; $label[$e] = new ISpan("label$e"); if (trim($sg_code[$e]->value) != '') { $label[$e]->value = $cn->get_value("select vw_name from vw_fiche_attr where quick_code=$1", array($sg_code[$e]->value)); } $sg_code[$e]->setReadOnly($p_readonly); $sg_quantity[$e]->setReadOnly($p_readonly); if ( isset (${'sg_type'.$e})) { $sg_type[$e]=(${'sg_type'.$e}=='c')?'OUT':'IN'; } if ( isset (${'f_id'.$e})) { $fiche[$e]=new Fiche($this->cn,${'f_id'.$e}); } } require_once 'template/stock_inv.php'; }
static Stock_Goods::insert_goods | ( | &$ | p_cn, |
$ | p_array | ||
) | [static] |
Insert into stock_goods from ACH and VEN.
type | $p_array | KEY : db => database conx, j_id => jrnx.j_id,goods=> f_id of the goods 'quant' => quantity ,'dir'=> d or c (c for sales OUT and d for purchase IN),'repo'=>r_id of the repository (stock_repository.r_id |
Definition at line 175 of file class_stock_goods.php.
References $code, $exercice, $g_user, $p_array, $repo, and $Res.
Referenced by Acc_Ledger_Sold\insert(), and Acc_Ledger_Purchase\insert().
{ global $g_user; extract ($p_array); if ($g_user->can_write_repo($repo) == false) return false; // Retrieve the good account for stock $code = new Fiche($p_cn); $code->get_by_qcode($goods); $code_marchandise = $code->strAttribut(ATTR_DEF_STOCK); if ($code_marchandise == NOTFOUND || $code_marchandise=='') return false; $exercice = $g_user->get_exercice(); if ($exercice == 0) throw new Exception('Annee invalide erreur'); $Res = $p_cn->exec_sql("insert into stock_goods ( j_id, f_id, sg_code, sg_quantity, sg_type,sg_exercice,r_id ) values ($1,$2,$3,$4,$5,$6,$7)", array( $p_array['j_id'], $code->id, $code_marchandise, $p_array['quant'], $p_array['dir'], $exercice, $p_array['repo'] ) ); return $Res; }
Stock_Goods::record_save | ( | $ | p_array | ) |
Definition at line 113 of file class_stock_goods.php.
References $a, $cn, $count, $exercice, $fiche, $nb, $p_array, $per, $periode, $stock, echo, isDate(), and trim().
{ global $cn; try { if (isDate($p_array['p_date']) == null) throw new Exception('Date invalide'); $cn->start(); $ch = new Stock_Change_Sql($cn); $ch->setp("c_comment", $p_array['p_motif']); $ch->setp("r_id", $p_array['p_depot']); $ch->setp("c_date", $p_array['p_date']); $ch->setp('tech_user', $_SESSION['g_user']); $ch->insert(); $per = new Periode($cn); $periode = $per->find_periode($p_array['p_date']); $exercice = $per->get_exercice($periode); $nb=$p_array['row']; for ($i = 0; $i < $nb; $i++) { $a = new Stock_Goods_Sql($cn); if ($p_array['sg_quantity' . $i] != 0 && trim($p_array['sg_code' . $i]) != '') { $stock= strtoupper(trim($p_array['sg_code' . $i])); $fiche=new Fiche($cn); $fiche->get_by_qcode($p_array['sg_code' . $i]); /* * check if code stock does exist */ $count=$cn->get_value('select count(*) from fiche_detail where ad_id=$1 and ad_value=$2', array(ATTR_DEF_STOCK,$stock)); if ( $count==0) { throw new Exception("Code stock inexistant"); } $a->f_id=$fiche->id; $a->sg_code = $stock; $a->sg_quantity = abs($p_array['sg_quantity' . $i]); $a->sg_type = ($p_array['sg_quantity' . $i] > 0) ? 'd' : 'c'; $a->sg_comment = $p_array['p_motif']; $a->tech_user = $_SESSION['g_user']; $a->r_id = $p_array['p_depot']; $a->sg_exercice = $exercice; $a->c_id = $ch->c_id; $a->sg_date=$p_array['p_date']; $a->insert(); } } $cn->commit(); } catch (Exception $exc) { echo $exc->getTraceAsString(); throw $exc; } }