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