diff --git a/html/stock.php b/html/stock.php index 825dbe80a..65f14cab1 100644 --- a/html/stock.php +++ b/html/stock.php @@ -64,20 +64,76 @@ $left_menu=ShowMenuAdvanced(); echo ''; +$action= ( isset ($_GET['action']))? $_GET['action']:""; include_once("stock_inc.php"); +// Adjust the stock +if ( isset ($_POST['sub_change'])) { + $change=$_POST['stock_change']; + $sg_code=$_POST['sg_code']; + $sg_date=$_POST['sg_date']; + if ( isDate($sg_date) == null + or isNumber($change) == 0 ) { + $msg="Stock données non conformes"; + echo ""; + echo_error($msg); + } else { + // if neg the stock decrease => credit + $type=( $change < 0 )?'c':'d'; + if ( $change != 0) + $Res=ExecSql($cn,"insert into stock_goods + ( j_id, + f_id, + sg_code, + sg_quantity, + sg_type, + sg_date, + sg_tech_user) + values ( + null, + 0, + '$sg_code', + abs($change), + '$type', + to_date('$sg_date','DD.MM.YYYY'), + '$g_user'); + "); + // to update the view + $action="detail"; + } +} + +// View the summary // if year is not set then use the year of the user's periode -if ( ! isset ($_GET['p_year']) ) { +if ( ! isset ($_GET['year']) ) { // get defaut periode $a=GetUserPeriode($cn,$g_user); // get exercice of periode - $p_year=GetExercice($cn,$a); + $year=GetExercice($cn,$a); } else { - $p_year=$_GET['p_year']; + $year=$_GET['year']; } +// View details +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 '
' ; + echo $a; + echo 'Entrer la valeur qui doit augmenter ou diminuer le stock'; + echo '
'; + echo $b; + echo ''; + echo '
'; + echo '
'; + exit(); +} + // Show the possible years $sql="select distinct (p_exercice) as exercice from parm_periode "; $Res=ExecSql($cn,$sql); @@ -94,12 +150,10 @@ for ( $i = 0; $i < pg_NumRows($Res);$i++) { // Show the current stock echo '
'; echo $r; -echo '
'; -$a=ViewStock($cn,$p_year); +$a=ViewStock($cn,$year); if ( $a != null ) { - echo ''; echo $a; } echo '
'; - +html_page_stop(); ?> \ No newline at end of file diff --git a/include/jrn.php b/include/jrn.php index 68ca0c0ff..1d817ffd3 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -1,5 +1,4 @@ "; @@ -98,22 +118,6 @@ group by c.sg_code"; $result.=""; return $result; -} -/* function ViewDetailStock ($p_cn,$p_f_id,$p_year) - ************************************************************ - * Purpose : return all the stock movement - * - * parm : - * - p_cn database connection - * - p_f_id f_id concerned card - * - year - * gen : - * - none - * return: table with the html code (string) - */ -function ViewDetailStock($p_cn,$p_f_id,$p_year) { - - } /* function getFicheNameCode ($p_cn,$p_sg_code) ************************************************************ @@ -136,7 +140,7 @@ $sql="select f_id,av_text where ad_id=".ATTR_DEF_NAME." and sg_code='$p_sg_code' - and sg_code != null "; + "; // Execute $Res=ExecSql($p_cn,$sql); if ( ( $M=pg_NumRows($Res)) == 0 ) return null; @@ -152,4 +156,141 @@ $sql="select f_id,av_text return $result; -} \ No newline at end of file +} +/* function ViewDetailStock($cn,$sg_code,$year) + ************************************************** + * Purpose : + * + * parm : + * - cn database connection + * - sg_code + * - year + * gen : + * - + * return: HTML code + */ +function ViewDetailStock($p_cn,$p_sg_code,$p_year) { +$sql="select sg_code, + j_montant, + j_date, + sg_quantity, + sg_type, + jr_comment, + jr_internal, + jr_id, + case when sg_date is not null then sg_date else j_date end as stock_date + from stock_goods + left outer join jrnx using (j_id) + 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' + ) + order by stock_date + " ; +// $r.=sprintf('', +// $row['jr_id'],$l_sessid,$row['jr_internal']); + // name + + + $r=""; + $a_name=getFicheNameCode($p_cn,$p_sg_code); + $name=""; + if ( $a_name != null ) { + foreach ($a_name as $key=>$element) { + $name.=$element['av_text'].","; + } + }// if ( $a_name + // Add java script for detail + $r.=JS_VIEW_JRN_DETAIL; + + $r.='

'.$p_sg_code." Noms : ".$name.'

'; + + $Res=ExecSql($p_cn,$sql); + if ( ($M=pg_NumRows($Res)) == 0 ) return "no rows"; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + $r.=""; + // compute sessid + $l_sessid=(isset($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID']; + + + for ( $i=0; $i < $M;$i++) { + $l=pg_fetch_array($Res,$i); + $r.=""; + + // date + $r.=""; + + //type (deb = out cred=in) + $r.=""; + + // jr_internal + $r.=""; + + + // comment + $r.=""; + + //amount + $r.=""; + + //quantity + $r.=""; + + // Unit Price + $r.=""; + + $r.=""; + }// for ($i + $r.="
Date Entrée / Sortie DescriptionMontantQuantitéPrix/Cout Unitaire
"; + $r.=$l['j_date']; + $r.=""; + $r.=($l['sg_type']=='c')?'OUT':'IN'; + $r.=""; + $r.=""; + $r.=$l['jr_comment']; + $r.=""; + $r.=$l['j_montant']; + $r.=""; + $r.=$l['sg_quantity']; + $r.=""; + $up=$l['j_montant']/$l['sg_quantity']; + $r.=$up; + $r.="
"; + + + + return $r; + +} +/* function ChangeStock($cn,$sg_code,$sg_date) + ************************************************** + * Purpose : + * + * parm : + * - + * gen : + * - + * return: + */ +function ChangeStock($p_sg_code,$p_year){ +$sg_date=date("d.m.Y"); +$r=' + + + + +
+ '; + return $r; + +} diff --git a/include/user_common.php b/include/user_common.php index 5ff3562c4..d3ea1837b 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -155,6 +155,7 @@ function InsertJrnx($p_cn,$p_type,$p_user,$p_jrn,$p_poste,$p_date,$p_amount,$p_g $p_date,round($p_amount,2),$p_poste,$p_grpt,$p_jrn,$debit,$p_user,$p_periode); echo_debug("InsertJrnx $sql"); $Res=ExecSql($p_cn,$sql); + if ( $Res==false) return $Res; return GetSequence($p_cn,'s_jrn_op'); } @@ -189,6 +190,7 @@ function InsertJrn($p_cn,$p_date,$p_echeance,$p_jrn,$p_comment,$p_amount,$p_grpt $p_jrn, round($p_amount,2),$p_comment,$p_date,$p_echeance,$p_grpt,$p_periode); echo_debug("InsertJrn $sql"); $Res=ExecSql($p_cn,$sql); + if ( $Res == false) return false; return GetSequence($p_cn,'s_jrn'); } /* function ListJrn($p_cn,$p_jrn,$p_wherel) @@ -395,6 +397,7 @@ function InsertStockGoods($p_cn,$p_j_id,$p_good,$p_quant,$p_type) '$l_code', $p_quant, '$p_type') "); + return $Res; } /* function withStock($p_cn,$p_f_id) ************************************************** diff --git a/style.css b/style.css index 6c90e6e16..1f291ef46 100644 --- a/style.css +++ b/style.css @@ -219,7 +219,7 @@ div.u_redcontent{ top:100px; left:150px; width:700px; - font-size:9pt; + font-size:9px; } span.odd {