00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 echo_debug('user_action_ach.php',__LINE__,"include user_action_ach.php");
00025 require_once("user_form_ach.php");
00026 require_once ("preference.php");
00027 require_once ("user_common.php");
00028 require_once("class_widget.php");
00029 require_once("class_jrn.php");
00030 $cn=DbConnect($_SESSION['g_dossier']);
00031
00032 if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) {
00033 exit;
00034
00035 }
00036 $action=(isset($_GET['action']))?$_GET['action']:$_POST['action'];
00037
00038
00039 if ( $action == 'new' ) {
00040
00041
00042 if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) != 2 ) {
00043 NoAccess();
00044 exit -1;
00045 }
00046
00047 if ( isset($_GET['blank'] )) {
00048
00049 $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00050 <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver" ID="SubmitButton">';
00051 $jrn=new jrn($cn, $_GET['p_jrn']);
00052 $r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit,false,$jrn->getDefLine('deb'));
00053 echo '<div class="u_redcontent">';
00054 echo $r;
00055 echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00056 echo "</div>";
00057
00058
00059 }
00060
00061
00062 if ( isset ($_POST['add_item'])) {
00063
00064 $nb_number=$_POST["nb_item"];
00065 $nb_number++;
00066
00067
00068 $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00069 <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00070
00071 $r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit,false,
00072 $nb_number);
00073 echo '<div class="u_redcontent">';
00074 echo $r;
00075 echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00076 echo "</div>";
00077 }
00078
00079 if ( isset ($_POST['correct'])) {
00080
00081 $nb_number=$_POST["nb_item"];
00082
00083
00084 $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00085 <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00086
00087 $r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit,false, $nb_number);
00088 echo '<div class="u_redcontent">';
00089 echo $r;
00090 echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00091 echo "</div>";
00092 return;
00093 }
00094
00095
00096
00097 if ( isset ($_POST['view_invoice']) and
00098 ! isset ($_POST['save'])) {
00099 $nb_number=$_POST["nb_item"];
00100 $submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer">';
00101 $submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
00102 if ( form_verify_input ($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$nb_number) == true ) {
00103
00104
00105 $r=FormAchView($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit,$nb_number);
00106 } else {
00107
00108 $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00109 <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00110 $r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit, false, $nb_number);
00111 }
00112 echo '<div class="u_redcontent">';
00113 echo $r;
00114 echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00115 echo "</div>";
00116 }
00117
00118 if ( isset($_POST['save'] )) {
00119
00120 $nb_number=$_POST["nb_item"];
00121
00122
00123 $submit='<h2 class="info">Recorded</h2>';
00124 $r=RecordSell($cn,$HTTP_POST_VARS,$User,$_GET['p_jrn']);
00125 $r=FormAchView($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,"",$nb_number,false);
00126 echo '<div class="u_redcontent">';
00127 echo $submit;
00128 echo $r;
00129 echo "</div>";
00130
00131 }
00132
00133
00134 }
00135 if ( $action == 'voir_jrn' ) {
00136
00137 if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
00138 NoAccess();
00139 exit -1;
00140 }
00141 ?>
00142 <div class="u_redcontent">
00143 <form method= "get" action="user_jrn.php">
00144
00145 <?
00146 $hid=new widget("hidden");
00147
00148 $hid->name="p_jrn";
00149 $hid->value=$p_jrn;
00150 echo $hid->IOValue();
00151
00152 $hid->name="jrn_type";
00153 $hid->value=$jrn_type;
00154 echo $hid->IOValue();
00155
00156 $hid->name="action";
00157 $hid->value="voir_jrn";
00158 echo $hid->IOValue();
00159
00160
00161 $w=new widget("select");
00162 $w->name="p_periode";
00163 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id");
00164 $User=new cl_user($cn);
00165 $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->GetPeriode();
00166 $w->selected=$current;
00167
00168 echo 'Période '.$w->IOValue("p_periode",$periode_start).$w->Submit('gl_submit','Valider');
00169 ?>
00170 </form>
00171 <?
00172
00173 if ( isset ( $_POST['paid']))
00174 {
00175
00176
00177 foreach ($_POST as $name=>$paid)
00178 {
00179 list($ad) = sscanf($name,"set_jr_id%d");
00180 if ( $ad == null ) continue;
00181 $sql="update jrn set jr_rapt='' where jr_id=$ad";
00182 $Res=ExecSql($cn,$sql);
00183
00184 }
00185
00186 foreach ($_POST as $name=>$paid)
00187 {
00188 list ($id) = sscanf ($name,"rd_paid%d");
00189
00190 if ( $id == null ) continue;
00191 echo "Mise à jour $id";
00192 $paid=($paid=='on')?'paid':'';
00193 $sql="update jrn set jr_rapt='$paid' where jr_id=$id";
00194 $Res=ExecSql($cn,$sql);
00195 }
00196
00197 }
00198
00199
00200 echo_debug ("user_action_ach.php");
00201
00202 $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn'];
00203
00204 $step=$_SESSION['g_pagesize'];
00205 $page=(isset($_GET['offset']))?$_GET['page']:1;
00206 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00207
00208 list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
00209 $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
00210 echo '<form method="POST">';
00211
00212 echo "<hr> $bar";
00213 echo $list;
00214 echo "$bar <hr>";
00215 $hid=new widget();
00216 if ( $max_ligne != 0 )
00217 echo $hid->Submit('paid','Mise à jour paiement');
00218 echo '</form>';
00219 echo '</div>';
00220 }
00221 if ( $action == 'voir_jrn_non_paye' ) {
00222
00223 if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
00224 NoAccess();
00225 exit -1;
00226 }
00227
00228 if ( isset ( $_POST['paid']))
00229 {
00230
00231
00232 foreach ($_POST as $name=>$paid)
00233 {
00234 list($ad) = sscanf($name,"set_jr_id%d");
00235 if ( $ad == null ) continue;
00236 $sql="update jrn set jr_rapt='' where jr_id=$ad";
00237 $Res=ExecSql($cn,$sql);
00238
00239 }
00240
00241 foreach ($_POST as $name=>$paid)
00242 {
00243 list ($id) = sscanf ($name,"rd_paid%d");
00244
00245 if ( $id == null ) continue;
00246 echo "Mise à jour $id";
00247 $paid=($paid=='on')?'paid':'';
00248 $sql="update jrn set jr_rapt='$paid' where jr_id=$id";
00249 $Res=ExecSql($cn,$sql);
00250 }
00251
00252 }
00253
00254
00255
00256 $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn'] ;
00257 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00258 $step=$_SESSION['g_pagesize'];
00259 $page=(isset($_GET['offset']))?$_GET['page']:1;
00260
00261 list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
00262
00263
00264
00265 $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn'] ;
00266 list ($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
00267
00268
00269 $m=($max_line2>$max_line)?$max_line2:$max_line;
00270 $bar2=jrn_navigation_bar($offset,$m,$step,$page);
00271
00272 echo '<div class="u_redcontent">';
00273 echo '<h2 class="info"> Echeance dépassée </h2>';
00274 echo '<FORM METHOD="POST">';
00275 echo $bar2;
00276 echo $list;
00277
00278
00279 echo '<h2 class="info"> Non Payée </h2>';
00280 echo $list2;
00281 echo $bar2;
00282 $hid=new widget();
00283 if ( $m != 0 )
00284 echo $hid->Submit('paid','Mise à jour paiement');
00285 echo '</form>';
00286
00287 echo '</div>';
00288 }
00289
00290
00291 if ( $action == 'search' ) {
00292
00293 if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 ) {
00294 NoAccess();
00295 exit -1;
00296 }
00297
00298
00299 $sessid=$_REQUEST['PHPSESSID'];
00300
00301 $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00302 $step=$_SESSION['g_pagesize'];
00303 $page=(isset($_GET['offset']))?$_GET['page']:1;
00304
00305
00306 $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST);
00307 echo '<DIV class="u_redcontent">';
00308 echo $search_box;
00309
00310 if ( isset ($_GET['nofirst'] ) ) {
00311 list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST);
00312 echo $a;
00313 }
00314 echo '</DIV>';
00315 }
00316 include("user_update.php");
00317 ?>