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

user_action_fin.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$ */
00025 echo_debug('user_action_fin.php',__LINE__,"include user_action_fin.php");
00026 // include_once("form_input.php");
00027 require_once("user_form_fin.php");
00028 include_once("class_widget.php");
00029 require_once("class_parm_code.php");
00030 
00031 $cn=DbConnect($_SESSION['g_dossier']);
00032 
00033 if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) {  
00034   return;
00035 }
00036 include_once ("preference.php");
00037 include_once ("user_common.php");
00038 
00039 $action=(isset($_GET['action']))?$_GET['action']:$_POST['action'];
00041 // action = new
00043 if ( $action == 'new' ) {
00044   // Check privilege
00045   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) != 2 )    {
00046        NoAccess();
00047        exit -1;
00048   }
00049 
00050 // We request a new form
00051         if ( isset($_GET['blank'] )) {
00052           // Submit button in the form
00053           $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00054                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00055           // add a one-line calculator
00056 
00057 
00058           $r=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,null,false);
00059           echo '<div class="u_redcontent">';
00060           echo $r;
00061           echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
00062         
00063           echo "</div>";
00064 
00065 
00066         }
00067 
00068         // Add an item
00069         if ( isset ($_POST['add_item'])) {
00070           // Add a line
00071           $nb_number=$_POST["nb_item"];
00072           $nb_number++;
00073 
00074           // submit button in the form
00075           $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00076                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00077 
00078           $r=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,false,  $nb_number);
00079           echo '<div class="u_redcontent">';
00080           echo $r;
00081           echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
00082 
00083           echo "</div>";
00084         }
00085         // Correct it
00086         if ( isset ($_POST['correct'])) {
00087           // Get number of  lines
00088           $nb_number=$_POST["nb_item"];
00089 
00090           // submit button in the form
00091           $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00092                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00093 
00094           $r=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,false,  $nb_number);
00095           echo '<div class="u_redcontent">';
00096           echo $r;
00097           echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
00098 
00099           echo "</div>";
00100         }
00101 
00102 
00103         // View the charge and show a submit button to save it 
00104         if ( isset ($_POST['view_invoice']) ) {
00105         $nb_number=$_POST["nb_item"];
00106         $submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer">';
00107         $submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
00108         $r=form_verify_input($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$nb_number);
00109         // if something goes wrong correct it
00110         if ( $r == null ) 
00111         {
00112           // submit button in the form
00113           $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
00114                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00115 
00116           $r=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,false,  $nb_number);
00117         }
00118         else 
00119         {
00120                 $r=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,true,$nb_number);
00121         }
00122 
00123         echo '<div class="u_redcontent">';
00124         echo $r;
00125         echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."</div>";
00126         echo "</div>";
00127         }
00128         // Save the charge into database
00129         if ( isset($_POST['save'] )) {
00130           $r=RecordFin($cn,$HTTP_POST_VARS,$User,$_GET['p_jrn']);
00131           // Get number of  lines
00132           $nb_number=$_POST["nb_item"];
00133 
00134           // submit button in the form
00135           $submit='<h2 class="info">Recorded</h2>';
00136 
00137           $r.=FormFin($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,true,  $nb_number,true);
00138           echo '<div class="u_redcontent">';
00139           echo $r;
00140           echo "</div>";
00141           
00142         }
00143         
00144 
00145 }
00147 // see jrn
00149 if ( $action == 'voir_jrn' ) {
00150   // Check privilege
00151   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 )    {
00152        NoAccess();
00153        exit -1;
00154   }
00155 ?>
00156 <div class="u_redcontent">
00157 
00158 <form method= "get" action="user_jrn.php">
00159 
00160 <?
00161 $hid=new widget("hidden");
00162 
00163 $hid->name="p_jrn";
00164 $hid->value=$p_jrn;
00165 echo $hid->IOValue();
00166 
00167 $hid->name="action";
00168 $hid->value="voir_jrn";
00169 echo $hid->IOValue();
00170 
00171 
00172 $hid->name="jrn_type";
00173 $hid->value=$jrn_type;
00174 echo $hid->IOValue();
00175 
00176 
00177 $w=new widget("select");
00178 
00179 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode order by p_id");
00180 $User=new cl_user($cn);
00181 $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->GetPeriode();
00182 $w->selected=$current;
00183 
00184 echo 'Période  '.$w->IOValue("p_periode",$periode_start).$w->Submit('gl_submit','Valider');
00185 ?>
00186 </form>
00187 <?
00188 
00189  // Show list of sell
00190   echo_debug ("user_action_jrn.php");
00191  // Date - date of payment - Customer - amount
00192    $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn'];
00193 
00194   // Nav. bar 
00195    $step=$_SESSION['g_pagesize'];
00196    $page=(isset($_GET['offset']))?$_GET['page']:1;
00197    $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00198    // SQL
00199    list($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset);
00200 
00201    $bar=jrn_navigation_bar($offset,$max_line,$step,$page);
00202         
00203         echo $bar;
00204         echo $list;
00205         echo $bar;
00206    echo '</div>';
00207 }
00209 // balance
00211 if ( $action == 'solde' ) {
00212   require_once("poste.php");
00213   // find the bank account
00214  // TODO : those values should be in a table because
00215  // they are _national_ parameters
00216   $banque=new parm_code($cn,'BANQUE');
00217   $caisse=new parm_code($cn,'CAISSE');
00218   $vir_interne=new parm_code($cn,'VIREMENT_INTERNE');
00219   $accountSql="select distinct pcm_val::text,pcm_lib from 
00220             tmp_pcmn 
00221             where pcm_val like '".$banque->p_value."%' or pcm_val like '".$vir_interne->p_value."%' 
00222             or pcm_val like '".$caisse->p_value."%'
00223             order by pcm_val::text";
00224   $ResAccount=ExecSql($cn,$accountSql);
00225   echo '<div class="u_redcontent">';
00226   echo "<table>";
00227   // for each account
00228   for ( $i = 0; $i < pg_NumRows($ResAccount);$i++) {
00229     // get the saldo
00230     $l=pg_fetch_array($ResAccount,$i);
00231     $m=GetSolde($cn,$l['pcm_val']);
00232     // print the result if the saldo is not equal to 0
00233     if ( $m != 0.0 ) {
00234       echo "<tr>";
00235       echo "<TD>".
00236         $l['pcm_val'].
00237         "</TD>".
00238         "<TD>".
00239         $l['pcm_lib'].
00240         "</TD>"."<TD>".
00241         $m.
00242         "</TD>"."</TR>";
00243     }
00244   }// for
00245   echo "</table>";
00246   echo "</div>";
00247  }
00249 include("user_update.php");
00250 
00251 
00252 ?>

Generated on Fri Jun 23 00:12:46 2006 for phpcompta by  doxygen 1.4.4