credit $type=( $change < 0 )?'c':'d'; if ( $change != 0) { $comment=sql_string($comment); $Res=$cn->exec_sql("insert into stock_goods ( j_id, f_id, sg_code, sg_quantity, sg_type, sg_date, sg_exercice, sg_comment, sg_tech_user) values ( null, null, '$sg_code', abs($change), '$type', to_date('$sg_date','DD.MM.YYYY'), '$year', '$comment', '".$_SESSION['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['year']) ) { // get defaut periode $a=$g_user->get_periode(); // get exercice of periode $periode=new Periode($cn,$a); $year=$periode->get_exercice(); } else { $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); $write=1; $b=""; echo '
' ; echo $a; echo '
'; if ( $write != 0) { echo '
'; echo 'Entrer la valeur qui doit augmenter ou diminuer le stock'; echo ''; echo '
'; echo ChangeStock($sg_code,$year); echo HtmlInput::submit("sub_change" ,"Valider"); echo dossier::hidden(); echo HtmlInput::button_anchor('Retour','?ac='.$_REQUEST['ac'].'&'.dossier::get()); echo '
'; echo '
'; } else echo HtmlInput::button_anchor('Retour','?ac='.$_REQUEST['ac'].'&'.dossier::get()); echo '
'; echo '
'; exit(); } // Show the possible years $sql="select distinct (p_exercice) as exercice from parm_periode "; $Res=$cn->exec_sql($sql); $r=""; for ( $i = 0; $i < Database::num_row($Res);$i++) { $l=Database::fetch_array($Res,$i); $url=sprintf("?ac=".$_REQUEST['ac']."&year=%d&".dossier::get(), $l['exercice']); $r.=HtmlInput::button_anchor($l['exercice'],$url); } // Check if User Can see the stock // Show the current stock echo '
'; echo $r; $a=ViewStock($cn,$year); if ( $a != null ) { echo $a; } echo '
'; html_page_stop(); ?>