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

user_action_ods.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.27 $ */
00025 echo_debug('user_action_ods.php',__LINE__,"include user_action_ods.php");
00026 include_once("user_form_ods.php");
00027 include_once("class_widget.php");
00028 
00029 $cn=DbConnect($_SESSION['g_dossier']);
00030 
00031 if ( ! isset ($_GET['action']) && ! isset ($_POST["action"]) ) {
00032   exit;
00033 
00034 }
00035 include_once ("preference.php");
00036 include_once ("user_common.php");
00037 
00038 
00039 $action=(isset($_GET['action']))?$_GET['action']:$_POST['action'];
00040 
00041 // action = new
00042 if ( $action == 'new' ) {
00043 
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 poste">
00054                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Confirmer">';
00055     // add a one-line calculator
00056 
00057     
00058     $r=FormODS($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     echo "</div>";
00063           
00064     
00065   }
00066 
00067         // Add an item
00068         if ( isset ($_POST['add_item'])) {
00069           // Add a line
00070           $nb_number=$_POST["nb_item"];
00071           $nb_number++;
00072 
00073           // submit button in the form
00074           $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
00075                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00076 
00077           $r=FormODS($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,false,  $nb_number);
00078           echo '<div class="u_redcontent">';
00079           echo $r;
00080           echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00081           echo "</div>";
00082         }
00083         // Correct it
00084         if ( isset ($_POST['correct'])) {
00085           // Get number of  lines
00086           $nb_number=$_POST["nb_item"];
00087 
00088           // submit button in the form
00089           $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
00090                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00091 
00092           $r=FormODS($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,false,  $nb_number);
00093           echo '<div class="u_redcontent">';
00094           echo $r;
00095           echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00096           echo "</div>";
00097         }
00098 
00099 
00100         // View the charge and show a submit button to save it 
00101   // TODO: the name 'view_invoice' should be changed to something more self-explaining, like
00102   // 'submit_od', no? 
00103         if ( isset ($_POST['view_invoice']) ) {
00104           $nb_number=$_POST["nb_item"];
00105           $submit='<INPUT TYPE="SUBMIT" name="save" value="Confirmer">';
00106           $submit.='<INPUT TYPE="SUBMIT" name="correct" value="Corriger">';
00107 
00108           $r=FormODS($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,true,$nb_number);
00109 
00110         // if something goes wrong, correct it
00111           if ( $r == null ) {
00112             // submit button in the form
00113             $submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout Poste">
00114                     <INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
00115             
00116             $r=FormODS($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,false,  $nb_number);
00117           }
00118           echo '<div class="u_redcontent">';
00119           echo $r;
00120           echo "<div><h4>On-line calculator</h4>".JS_CALC_LINE."<div>";
00121           echo "</div>";
00122         }
00123         // Save the change into database
00124         if ( isset($_POST['save'] )) {
00125           $r=RecordODS($cn,$HTTP_POST_VARS,$User,$_GET['p_jrn']);
00126           // Get number of  lines
00127           $nb_number=$_POST["nb_item"];
00128 
00129           // submit button in the form
00130           $submit='<h2 class="info">Recorded</h2>';
00131 
00132           $r.=FormODS($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS,true,  $nb_number,true);
00133           echo '<div class="u_redcontent">';
00134           echo $r;
00135           echo "</div>";
00136           
00137         }
00138         
00139 
00140 }
00141 if ( $action == 'voir_jrn' ) {
00142   // Check privilege
00143   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) < 1 )    {
00144        NoAccess();
00145        exit -1;
00146   }
00147 
00148  // Show list of cells
00149   echo_debug ("user_action_ods.php");
00150  // Date - date of payment - Customer - amount
00151 ?>
00152 <div class="u_redcontent">
00153 
00154 <form method= "get" action="user_jrn.php">
00155 
00156 <?
00157 $hid=new widget("hidden");
00158 
00159 $hid->name="p_jrn";
00160 $hid->value=$p_jrn;
00161 echo $hid->IOValue();
00162 
00163 $hid->name="action";
00164 $hid->value="voir_jrn";
00165 echo $hid->IOValue();
00166 
00167 
00168 $hid->name="jrn_type";
00169 $hid->value=$jrn_type;
00170 echo $hid->IOValue();
00171 
00172 
00173 
00174 $w=new widget("select");
00175 // filter on the current year
00176 $filter_year=" where p_exercice='".$User->getExercice()."'";
00177 
00178 $periode_start=make_array($cn,"select p_id,to_char(p_start,'DD-MM-YYYY') from parm_periode $filter_year order by p_id");
00179 $User=new cl_user($cn);
00180 $current=(isset($_GET['p_periode']))?$_GET['p_periode']:$User->GetPeriode();
00181 $w->selected=$current;
00182 
00183 echo 'Période  '.$w->IOValue("p_periode",$periode_start).$w->Submit('gl_submit','Valider');
00184 ?>
00185 </form>
00186 <?
00187         $sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_id=".$_GET['p_jrn'] ;
00188         $step=$_SESSION['g_pagesize'];
00189         $page=(isset($_GET['offset']))?$_GET['page']:1;
00190         $offset=(isset($_GET['offset']))?$_GET['offset']:0;
00191         list ($max_line,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset);
00192         $bar=jrn_navigation_bar($offset,$max_line,$step,$page);
00193         echo $bar;
00194         echo $list;
00195         echo $bar;
00196         echo '</div>';
00197 }
00198 
00199 //Search
00200 if ( $action == 'search' ) {
00201   // Check privilege
00202   if ( CheckJrn($_SESSION['g_dossier'],$_SESSION['g_user'],$_GET['p_jrn']) <1 )    {
00203        NoAccess();
00204        exit -1;
00205   }
00206 
00207   // PhpSessid
00208   $sessid=(isset ($_POST['PHPSESSID']))?$_POST['PHPSESSID']:$_GET['PHPSESSID'];
00209 
00210 // display a search box
00211   $search_box=u_ShowMenuRecherche($cn,$_GET['p_jrn'],$sessid,$HTTP_POST_VARS);
00212   echo '<DIV class="u_redcontent">';
00213   echo $search_box; 
00214   // if nofirst is set then show result
00215   if ( isset ($_GET['nofirst'] ) )     {
00216     list ($max_line,$a)=ListJrn($cn,$_GET['p_jrn'],"",$HTTP_POST_VARS);
00217     echo $a;
00218   }
00219   echo '</DIV>'; 
00220 }
00221 include("user_update.php");
00222 ?>