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