Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

user_action_ach.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00020 /* $Revision$ */
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 // action = new
00039 if ( $action == 'new' ) {
00040 // We request a new form
00041   // Check privilege
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           // Submit button in the form
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());
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         // Add an item
00062         if ( isset ($_POST['add_item'])) {
00063           // Add a line
00064           $nb_number=$_POST["nb_item"];
00065           $nb_number++;
00066 
00067           // submit button in the form
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         // Correct it
00079         if ( isset ($_POST['correct'])) {
00080           // Get number of  lines
00081           $nb_number=$_POST["nb_item"];
00082 
00083           // submit button in the form
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         // View the charge and show a submit button to save it 
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           // Should use a read only view instead of FormAch
00104           // where we can check
00105           $r=FormAchView($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit,$nb_number);
00106         } else {
00107           // if something goes wrong, correct it
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         // Save the charge into database
00118         if ( isset($_POST['save'] )) {
00119           // Get number of  lines
00120           $nb_number=$_POST["nb_item"];
00121 
00122           // submit button in the form
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   // Check privilege
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     // Ask to update payment
00173     if ( isset ( $_POST['paid'])) 
00174       {
00175         // reset all the paid flag because the checkbox is post only
00176         // when checked
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         // set a paid flag for the checked box
00186         foreach ($_POST as $name=>$paid) 
00187           {
00188             list ($id) = sscanf ($name,"rd_paid%d");
00189 
00190             if ( $id == null ) continue;
00191 
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  // Show list of sell
00200   echo_debug ("user_action_ach.php");
00201  // Date - date of payment - Customer - amount
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   // Check privilege
00223   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 )    {
00224        NoAccess();
00225        exit -1;
00226   }
00227   // Ask to update payment
00228   if ( isset ( $_POST['paid'])) 
00229     {
00230       // reset all the paid flag because the checkbox is post only
00231       // when checked
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       // set a paid flag for the checked box
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 // Show list of unpaid sell
00255 // Date - date of payment - Customer - amount
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   //  $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
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   // Get the max line
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 //Search
00291 if ( $action == 'search' ) {
00292   // Check privilege
00293   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 )    {
00294        NoAccess();
00295        exit -1;
00296   }
00297 
00298   // PhpSessid
00299   $sessid=$_REQUEST['PHPSESSID'];
00300   // Search modules
00301   $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00302   $step=$_SESSION['g_pagesize'];
00303   $page=(isset($_GET['offset']))?$_GET['page']:1;
00304 
00305 // display a search box
00306   $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST);
00307   echo '<DIV class="u_redcontent">';
00308   echo $search_box; 
00309   // if nofirst is set then show result
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 ?>