diff --git a/html/stock.php b/html/stock.php index 0f14a76c2..b1733a16f 100644 --- a/html/stock.php +++ b/html/stock.php @@ -83,7 +83,7 @@ if ( isset ($_POST['sub_change'])) { echo_error($msg); } else { // Check if User Can change the stock - if ( CheckAction($g_dossier,$g_user,STOCK_WRITE) == 0 ) { + if ( CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],STOCK_WRITE) == 0 ) { NoAccess(); exit (-1); } @@ -106,7 +106,7 @@ if ( isset ($_POST['sub_change'])) { abs($change), '$type', to_date('$sg_date','DD.MM.YYYY'), - '$g_user'); + '".$_SESSION['g_user']."'); "); // to update the view $action="detail"; @@ -136,13 +136,16 @@ if ( $action == 'detail' ) { $sg_code=(isset ($_GET['sg_code'] ))?$_GET['sg_code']:$_POST['sg_code']; $year=(isset($_GET['year']))?$_GET['year']:$_POST['year']; $a=ViewDetailStock($cn,$sg_code,$year); + $b=ChangeStock($sg_code,$year); echo '
| Code | '; $result.='Noms | '; @@ -159,13 +159,11 @@ $sql="select sg_code, left outer join jrn on jr_grpt_id=j_grpt where sg_code='$p_sg_code' and ( - to_char(sg_date,'YYYY') = '$p_year' - or to_char(j_date,'YYYY') = '$p_year' + to_char(sg_date::timestamp,'YYYY') = '$p_year' + or to_char(j_date::timestamp,'YYYY') = '$p_year' ) order by stock_date " ; -// $r.=sprintf('', -// $row['jr_id'],$l_sessid,$row['jr_internal']); // name @@ -184,7 +182,7 @@ $sql="select sg_code, $Res=ExecSql($p_cn,$sql); if ( ($M=pg_NumRows($Res)) == 0 ) return "no rows"; - $r.="
|---|
| Date | "; $r.="Entrée / Sortie | "; @@ -233,7 +231,9 @@ $sql="select sg_code, // Unit Price $r.=""; - $up=$l['j_montant']/$l['sg_quantity']; + $up=""; + if ( $l['sg_quantity'] != 0 ) + $up=$l['j_montant']/$l['sg_quantity']; $r.=$up; $r.=" | "; @@ -276,11 +276,11 @@ $r=' function GetQuantity($p_cn,$p_sg_code,$p_year,$p_type) { $sql="select sum(sg_quantity) as result from stock_goods - join jrnx on (stock_goods.j_id=jrnx.j_id) - join parm_periode on (parm_periode.p_id=jrnx.j_tech_per) + left join jrnx on (stock_goods.j_id=jrnx.j_id) + left join parm_periode on (parm_periode.p_id=jrnx.j_tech_per) where sg_code='$p_sg_code' and - p_exercice = '$p_year' and + (p_exercice = '$p_year' or to_char(sg_date::timestamp,'YYYY')='$p_year') and sg_type='$p_type'"; $Res=ExecSql($p_cn,$sql); if ( pg_NumRows($Res)== 0) return null; diff --git a/include/user_form_ach.php b/include/user_form_ach.php index a13d4ed0c..6a23af4f0 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -800,7 +800,7 @@ function RecordSell($p_cn,$p_array,$p_user,$p_jrn) $j_id=InsertJrnx($p_cn,'d',$p_user->id,$p_jrn,$poste,$e_date,round($amount,2),$seq,$periode,$a_good[$i]); if ( $j_id == false) { Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");} // always save quantity but in withStock we can find what card need a stock management - if ( InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c') == false ) { + if ( InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'d') == false ) { $Rollback($p_cn);exit("error 'user_form_ach.php' __LINE__");} echo_debug('user_form_ach.php',__LINE__,"value non ded : ".$a_good[$i]."is");
|---|