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