00001
00002 <?
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00026 include_once("preference.php");
00027 include_once ("ac_common.php");
00028 include_once("postgres.php");
00029 include_once("stock_inc.php");
00030 include_once("check_priv.php");
00031
00032 html_page_start($_SESSION['g_theme']);
00033
00034 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00035 echo "You must choose a Dossier ";
00036 exit -2;
00037 }
00038 include_once ("postgres.php");
00039
00040
00041 $cn=DbConnect($_SESSION['g_dossier']);
00042 include_once ("class_user.php");
00043 $User=new cl_user($cn);
00044 $User->Check();
00045
00046
00047 SyncRight($_SESSION['g_dossier'],$_SESSION['g_user']);
00048
00049
00050 if ( $User->admin == 0 ) {
00051
00052 $r=GetPriv($_SESSION['g_dossier'],$_SESSION['g_user']);
00053 if ($r == 0 ){
00054
00055 NoAccess();
00056 }
00057
00058 }
00059
00060
00061
00062 include_once ("user_menu.php");
00063
00064 echo ShowMenuCompta($_SESSION['g_dossier'],"user_advanced.php");
00065
00066
00067 $left_menu=ShowMenuAdvanced("stock.php");
00068
00069 echo $left_menu;
00070
00071 $action= ( isset ($_GET['action']))? $_GET['action']:"";
00072 include_once("stock_inc.php");
00073
00074
00075 if ( isset ($_POST['sub_change'])) {
00076 $change=$_POST['stock_change'];
00077 $sg_code=$_POST['sg_code'];
00078 $sg_date=$_POST['sg_date'];
00079 if ( isDate($sg_date) == null
00080 or isNumber($change) == 0 ) {
00081 $msg="Stock données non conformes";
00082 echo "<script> alert('$msg');</script>";
00083 echo_error($msg);
00084 } else {
00085
00086 if ( CheckAction($g_dossier,$g_user,STOCK_WRITE) == 0 ) {
00087 NoAccess();
00088 exit (-1);
00089 }
00090
00091
00092 $type=( $change < 0 )?'c':'d';
00093 if ( $change != 0)
00094 $Res=ExecSql($cn,"insert into stock_goods
00095 ( j_id,
00096 f_id,
00097 sg_code,
00098 sg_quantity,
00099 sg_type,
00100 sg_date,
00101 sg_tech_user)
00102 values (
00103 null,
00104 0,
00105 '$sg_code',
00106 abs($change),
00107 '$type',
00108 to_date('$sg_date','DD.MM.YYYY'),
00109 '$g_user');
00110 ");
00111
00112 $action="detail";
00113 }
00114 }
00115
00116
00117
00118
00119 if ( ! isset ($_GET['year']) ) {
00120
00121 $a=$User->GetPeriode();
00122
00123 $year=GetExercice($cn,$a);
00124 } else
00125 {
00126 $year=$_GET['year'];
00127 }
00128
00129
00130 if ( $action == 'detail' ) {
00131
00132 if ( CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],STOCK_READ) == 0 ) {
00133 NoAccess();
00134 exit (-1);
00135 }
00136 $sg_code=(isset ($_GET['sg_code'] ))?$_GET['sg_code']:$_POST['sg_code'];
00137 $year=(isset($_GET['year']))?$_GET['year']:$_POST['year'];
00138 $a=ViewDetailStock($cn,$sg_code,$year);
00139 $b=ChangeStock($sg_code,$year);
00140 echo '<div class="u_redcontent">' ;
00141 echo $a;
00142 echo 'Entrer la valeur qui doit augmenter ou diminuer le stock';
00143 echo '<form action="stock.php" method="POST">';
00144 echo $b;
00145 echo '<input type="submit" name="sub_change" value="Ok">';
00146 echo '</form>';
00147 echo '</div>';
00148 exit();
00149 }
00150
00151
00152 $sql="select distinct (p_exercice) as exercice from parm_periode ";
00153 $Res=ExecSql($cn,$sql);
00154 $r="";
00155 for ( $i = 0; $i < pg_NumRows($Res);$i++) {
00156 $l=pg_fetch_array($Res,$i);
00157 $r.=sprintf('<A class="one" HREF="stock.php?year=%d">%d</a> - ',
00158 $l['exercice'],
00159 $l['exercice']);
00160
00161 }
00162
00163 if ( CheckAction($_SESSION['g_dossier'],$_SESSION['g_user'],STOCK_READ) == 0 ) {
00164 NoAccess();
00165 exit (-1);
00166 }
00167
00168
00169 echo '<div class="u_redcontent">';
00170 echo $r;
00171 $a=ViewStock($cn,$year);
00172 if ( $a != null ) {
00173 echo $a;
00174 }
00175 echo '</div>';
00176 html_page_stop();
00177 ?>