Correct the stock

This commit is contained in:
sparkyx 2007-04-14 21:07:19 +00:00
parent 397cb24b15
commit 2cd6388428
3 changed files with 20 additions and 17 deletions

View file

@ -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 '<div class="u_redcontent">' ;
echo $a;
echo 'Entrer la valeur qui doit augmenter ou diminuer le stock';
echo 'Entrer la valeur qui doit augmenter ou diminuer le stock, attention ne pas utiliser de d&eacute;cimales';
echo '<form action="stock.php" method="POST">';
echo $b;
echo '<input type="submit" name="sub_change" value="Ok">';
echo '<A class="mtitle" HREF="?"><INPUT TYPE="BUTTON" value="Retour"</A>';
echo '</form>';
echo '</div>';
exit();
@ -154,7 +157,7 @@ $Res=ExecSql($cn,$sql);
$r="";
for ( $i = 0; $i < pg_NumRows($Res);$i++) {
$l=pg_fetch_array($Res,$i);
$r.=sprintf('<A class="one" HREF="stock.php?year=%d">%d</a> - ',
$r.=sprintf('<A class="mtitle" HREF="stock.php?year=%d">%d</a> - ',
$l['exercice'],
$l['exercice']);

View file

@ -37,8 +37,8 @@ function ViewStock($p_cn,$p_year) {
// during the p_year
$sql=" select distinct sg_code
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 outer join jrnx on (stock_goods.j_id=jrnx.j_id)
right outer join parm_periode on (parm_periode.p_id=jrnx.j_tech_per)
where
p_exercice= '$p_year'
and sg_code is not null and sg_code != '' and sg_code!='null'";
@ -50,7 +50,7 @@ $sql=" select distinct sg_code
if ( ( $M = pg_NumRows($Res)) == 0 ) return null;
// store it in a HTLM table
$result="<table>";
$result='<table style="width:100%;border:solid blue 2px ;border-style:outset;">';
$result.="<tr>";
$result.='<th>Code</th>';
$result.='<th>Noms</th>';
@ -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('<input TYPE="button" onClick="modifyOperation(\'%s\',\'%s\')" value="%s">',
// $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.="<table>";
$r.='<table style="width:100%;border:solid blue 2px ;border-style:outset;">';
$r.="<TR>";
$r.="<th>Date </th>";
$r.="<th>Entrée / Sortie </th>";
@ -233,7 +231,9 @@ $sql="select sg_code,
// Unit Price
$r.="<TD>";
$up=$l['j_montant']/$l['sg_quantity'];
$up="";
if ( $l['sg_quantity'] != 0 )
$up=$l['j_montant']/$l['sg_quantity'];
$r.=$up;
$r.="</TD>";
@ -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;

View file

@ -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");