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: 1.31 $ */
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           list($internal,$comment)=RecordSell($cn,$HTTP_POST_VARS,$User,$_GET['p_jrn']);
00122 
00123           // submit button in the form
00124           $submit='<h2 class="info">Opération '.$internal.' </h2>';
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 // filter on the current year
00164 $filter_year=" where p_exercice='".$User->getExercice()."'";
00165 
00166 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00167 $User=new cl_user($cn);
00168 $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->GetPeriode();
00169 $w->selected=$current;
00170 
00171 echo 'Période  '.$w->IOValue("p_periode",$periode_start).$w->Submit('gl_submit','Valider');
00172 ?>
00173 </form>
00174 <?
00175     // Ask to update payment
00176     if ( isset ( $_POST['paid'])) 
00177       {
00178         // reset all the paid flag because the checkbox is post only
00179         // when checked
00180         foreach ($_POST as $name=>$paid) 
00181           {
00182             list($ad) = sscanf($name,"set_jr_id%d");
00183             if ( $ad == null ) continue;
00184             $sql="update jrn set jr_rapt='' where jr_id=$ad";
00185             $Res=ExecSql($cn,$sql);
00186 
00187           }
00188         // set a paid flag for the checked box
00189         foreach ($_POST as $name=>$paid) 
00190           {
00191             list ($id) = sscanf ($name,"rd_paid%d");
00192 
00193             if ( $id == null ) continue;
00194 
00195             $paid=($paid=='on')?'paid':'';
00196             $sql="update jrn set jr_rapt='$paid' where jr_id=$id";
00197             $Res=ExecSql($cn,$sql);
00198           }
00199 
00200       }
00201 
00202  // Show list of sell
00203   echo_debug ("user_action_ach.php");
00204  // Date - date of payment - Customer - amount
00205    $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn'];
00206 
00207    $step=$_SESSION['g_pagesize'];
00208    $page=(isset($_GET['offset']))?$_GET['page']:1;
00209    $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00210 
00211    list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
00212    $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
00213    echo '<form method="POST">';
00214 
00215    echo "<hr> $bar";
00216    echo $list;
00217    echo "$bar <hr>";
00218    $hid=new widget();
00219    if ( $max_ligne != 0 )
00220      echo $hid->Submit('paid','Mise à jour paiement');
00221    echo '</form>';
00222    echo '</div>';
00223 }
00224 if ( $action == 'voir_jrn_non_paye' ) {
00225   // Check privilege
00226   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 )    {
00227        NoAccess();
00228        exit -1;
00229   }
00230   // Ask to update payment
00231   if ( isset ( $_POST['paid'])) 
00232     {
00233       // reset all the paid flag because the checkbox is post only
00234       // when checked
00235       foreach ($_POST as $name=>$paid) 
00236         {
00237           list($ad) = sscanf($name,"set_jr_id%d");
00238           if ( $ad == null ) continue;
00239           $sql="update jrn set jr_rapt='' where jr_id=$ad";
00240           $Res=ExecSql($cn,$sql);
00241           
00242         }
00243       // set a paid flag for the checked box
00244       foreach ($_POST as $name=>$paid) 
00245           {
00246             list ($id) = sscanf ($name,"rd_paid%d");
00247             
00248             if ( $id == null ) continue;
00249             echo "Mise à jour $id";
00250             $paid=($paid=='on')?'paid':'';
00251             $sql="update jrn set jr_rapt='$paid' where jr_id=$id";
00252             $Res=ExecSql($cn,$sql);
00253           }
00254       
00255     }
00256 
00257 // Show list of unpaid sell
00258 // Date - date of payment - Customer - amount
00259   $sql=SQL_LIST_UNPAID_INVOICE_DATE_LIMIT." and jr_def_id=".$_GET['p_jrn']  ;
00260   $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00261   $step=$_SESSION['g_pagesize'];
00262   $page=(isset($_GET['offset']))?$_GET['page']:1;
00263 
00264   list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
00265   //  $bar=jrn_navigation_bar($offset,$max_ligne,$step,$page);
00266 
00267 
00268   $sql=SQL_LIST_UNPAID_INVOICE." and jr_def_id=".$_GET['p_jrn']  ;
00269   list ($max_line2,$list2)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
00270 
00271   // Get the max line
00272   $m=($max_line2>$max_line)?$max_line2:$max_line;
00273   $bar2=jrn_navigation_bar($offset,$m,$step,$page);
00274 
00275     echo '<div class="u_redcontent">';
00276     echo '<h2 class="info"> Echeance dépassée </h2>';
00277     echo '<FORM METHOD="POST">';
00278     echo $bar2;
00279     echo $list;
00280 
00281 
00282     echo  '<h2 class="info"> Non Payée </h2>';
00283     echo $list2;
00284     echo $bar2;
00285     $hid=new widget();
00286    if ( $m != 0 )
00287      echo $hid->Submit('paid','Mise à jour paiement');
00288     echo '</form>';
00289 
00290     echo '</div>';
00291 }
00292 
00293 //Search
00294 if ( $action == 'search' ) {
00295   // Check privilege
00296   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 )    {
00297        NoAccess();
00298        exit -1;
00299   }
00300 
00301   // PhpSessid
00302   $sessid=$_REQUEST['PHPSESSID'];
00303   // Search modules
00304   $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00305   $step=$_SESSION['g_pagesize'];
00306   $page=(isset($_GET['offset']))?$_GET['page']:1;
00307 
00308 // display a search box
00309   $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$_POST);
00310   echo '<DIV class="u_redcontent">';
00311   echo $search_box; 
00312   // if nofirst is set then show result
00313   if ( isset ($_GET['nofirst'] ) )     {
00314     list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$_POST);
00315     echo $a;
00316   }
00317   echo '</DIV>'; 
00318 }
00319 include("user_update.php");
00320 ?>