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

dossier_prefs.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 /* $Revision$ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 /* $Revision$ */
00022 include_once ("ac_common.php");
00023 html_page_start($_SESSION['g_theme']);
00024 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00025   echo "You must choose a Dossier ";
00026   exit -2;
00027 }
00028 include_once ("postgres.php");
00029 /* Admin. Dossier */
00030 $rep=DbConnect();
00031 include_once ("class_user.php");
00032 $User=new cl_user($rep);
00033 $User->Check();
00034 
00035 include("preference.php");
00036 include_once("user_menu.php");
00037 
00038 ShowMenuCompta($_SESSION['g_dossier']);
00039 
00040 include_once ("check_priv.php");
00041 
00042 $cn=DbConnect($_SESSION['g_dossier']);
00043 
00044 if ( $User->CheckAction($cn,PARM) == 0 ) {
00045     /* Cannot Access */
00046     NoAccess();
00047   exit -1;                      
00048 
00049 }
00050 
00051 echo ShowMenuParam();
00052 $p_action="";
00053 if ( isset($_REQUEST["p_action"]) ) {
00054   $p_action=$_REQUEST["p_action"];
00055 }
00056 
00057 
00058 echo '<DIV CLASS="u_redcontent">';
00059 // Devise 
00060 
00061 $action="";
00062 if ( isset ($_POST['action']) ) {
00063   $action=$_POST['action'];
00064 }
00065 
00067 // Currency
00069 if ( $p_action == "change" ) {
00070   $p_mid=$_GET['p_mid'];
00071   $p_rate=$_GET['p_rate'];
00072   $p_code=$_GET['p_code'];
00073 
00074   echo '<TR> <FORM ACTION="dossier_prefs.php" METHOD="POST">';
00075   echo '<INPUT TYPE="HIDDEN" VALUE="'.$p_mid.'" NAME="p_id">';
00076   echo '<TD> <INPUT TYPE="text" NAME="p_devise" VALUE="'.$p_code.'"></TD>';
00077   echo '<TD> <INPUT TYPE="text" NAME="p_rate" VALUE="'.$p_rate.'"></TD>';
00078   echo '<TD> <INPUT TYPE="SUBMIT" NAME="action" Value="Change"</TD>';
00079   echo '</FORM></TR>';
00080 }
00081 if ( $action == "Change") {
00082   $p_devise=$_POST['p_devise'];
00083   $p_id=$_POST['p_id'];
00084   $p_rate=$_POST['p_rate'];
00085   $Res=ExecSql($cn,"update parm_money set pm_code='$p_devise',pm_rate=$p_rate where pm_id=$p_id");
00086   ShowDevise($cn);
00087 
00088 }
00089 if ( $action == "Ajout") {
00090   $p_devise=$_POST['p_devise'];
00091   $p_rate=$_POST['p_rate'];
00092   $Res=ExecSql($cn,"insert into parm_money ( pm_code,pm_rate) values ('$p_devise',$p_rate) ");
00093   ShowDevise($cn);
00094 
00095 }
00096 
00097 if ( $p_action == "delete") {
00098   $p_id=$_GET['p_mid'];
00099   $Res=ExecSql($cn,"delete from parm_money  where pm_id=$p_id");
00100   ShowDevise($cn);
00101 }
00102 
00103 
00104 if ( $p_action=="devise") {
00105   ShowDevise($cn);
00106 }
00107 
00109 // Periode
00111 if ( $p_action=="change_per") {
00112   foreach($HTTP_GET_VARS as $key=>$element) 
00113     ${"$key"}=$element;
00114   echo "<TABLE>";
00115   echo '<TR> <FORM ACTION="dossier_prefs.php" METHOD="POST">';
00116   echo ' <INPUT TYPE="HIDDEN" NAME="p_per" VALUE="'.$p_per.'">';
00117   echo '<TD> <INPUT TYPE="text" NAME="p_date_start" VALUE="'.$p_date_start.'"></TD>';
00118   echo '<TD> <INPUT TYPE="text" NAME="p_date_end" VALUE="'.$p_date_end.'"></TD>';
00119   echo '<TD> <INPUT TYPE="text" NAME="p_exercice" VALUE="'.$p_exercice.'"></TD>';
00120   echo '<TD> <INPUT TYPE="SUBMIT" NAME="chg_per" Value="Change"</TD>';
00121   echo '</FORM></TR>';
00122   echo "</TABLE>";
00123 
00124 }
00125 if ( isset ($_POST["chg_per"] ) ) {
00126   foreach($HTTP_POST_VARS as $key=>$element) 
00127     ${"$key"}=$element;
00128   if (isDate($p_date_start) == null ||
00129       isDate($p_date_end) == null ||
00130       strlen (trim($p_exercice)) == 0 ||
00131      (string) $p_exercice != (string)(int) $p_exercice)
00132     { 
00133       echo "<H2 class=\"error\"> Valeurs invalides</H2>";
00134       ShowPeriode($cn);
00135       return;
00136     }
00137   $Res=ExecSql($cn," update parm_periode ".
00138                "set p_start=to_date('". $p_date_start."','DD.MM.YYYY'),".
00139                " p_end=to_date('". $p_date_end."','DD.MM.YYYY'),".
00140                " p_exercice='".$p_exercice."'".
00141                " where p_id=".$p_per);
00142 
00143   ShowPeriode($cn);
00144 
00145 }
00146 if ( isset ($_POST["add_per"] )) {
00147   foreach($HTTP_POST_VARS as $key=>$element) 
00148     ${"$key"}=$element;
00149   if (isDate($p_date_start) == null ||
00150       isDate($p_date_end) == null ||
00151       strlen (trim($p_exercice)) == 0 ||
00152      (string) $p_exercice != (string)(int) $p_exercice)
00153     { 
00154       echo "<H2 class=\"error\"> Valeurs invalides</H2>";
00155       ShowPeriode($cn);
00156       return;
00157     }
00158   $Res=ExecSql($cn,sprintf(" insert into parm_periode(p_start,p_end,p_closed,p_exercice)".
00159                            "values (to_date('%s','DD.MM.YYYY'),to_date('%s','DD.MM.YYYY')".
00160                            ",'f','%s')",
00161                            $p_date_start,
00162                            $p_date_end,
00163                            $p_exercice));
00164 
00165   ShowPeriode($cn);
00166 
00167 }
00168 
00169 echo_debug('dossier_prefs.php',__LINE__,"Action $action");
00170 if ( $p_action=="closed") {
00171   $p_per=$_GET['p_per'];
00172   $Res=ExecSql($cn,"update parm_periode set p_closed=true where p_id=$p_per");
00173   ShowPeriode($cn);
00174 }
00175 
00176 if ( $p_action== "delete_per" ) {
00177   $p_per=$_GET["p_per"];
00178 // Check if the periode is not used
00179   if ( CountSql($cn,"select * from jrnx where j_tech_per=$p_per") != 0 ) {
00180   echo '<h2 class="error"> Désolé mais cette période est utilisée</h2>';
00181   } else
00182   {
00183   $Res=ExecSql($cn,"delete from parm_periode where p_id=$p_per");
00184   ShowPeriode($cn);
00185   }
00186 }
00187 
00188 if ( $p_action == "periode" ) {
00189   ShowPeriode($cn);
00190 }
00192 // Coord societe
00194 if ( $p_action=='company') { 
00195   require_once("class_own.php");
00196   require_once("class_widget.php");
00197   if ( isset ($_POST['record_company'] )) {
00198     $m=new Own($cn);
00199     extract($_POST);
00200     $m->MY_NAME=$p_name;
00201     $m->MY_TVA=$p_tva;
00202     $m->MY_STREET=$p_street;
00203     $m->MY_NUMBER=$p_no;
00204     $m->MY_CP=$p_cp;
00205     $m->MY_COMMUNE=$p_Commune;
00206     $m->Save();
00207   }
00208 
00209   $my=new Own($cn);
00210   $all=new widget("text");
00211   $all->table=1;
00212   echo '<form method="post" action="?p_action=company">';
00213   echo "<table class=\"result\">";
00214   echo "<tr>".$all->IOValue("p_name",$my->MY_NAME,"Nom société")."</tr>";
00215 
00216   echo "<tr>".$all->IOValue("p_tva",$my->MY_TVA,"Numéro de Tva")."</tr>";
00217   echo "<tr>".$all->IOValue("p_street",$my->MY_STREET,"Rue ")."</tr>";
00218   echo "<tr>".$all->IOValue("p_no",$my->MY_NUMBER,"Numéro")."</tr>";
00219   echo "<tr>".$all->IOValue("p_cp",$my->MY_CP,"Code Postal")."</tr>";
00220   echo "<tr>".$all->IOValue("p_Commune",$my->MY_COMMUNE,"Commune")."</tr>";
00221   echo "</table>";
00222   $submit=new widget("submit");
00223   echo $submit->Submit("record_company","Enregistre");
00224   echo "</form>";
00225  }
00227 // Invoice 
00229 
00230 if ( $p_action == 'invoice' ) {
00231         require_once("class_invoice.php");
00232         echo ShowMenuInvoice();
00233         $inv=new Invoice($cn);
00234         $inv->myList();
00235         $inv->FormAdd();
00236         
00237 } 
00238 
00240 // Invoice      add a template
00242 if ( $p_action=='add_template') {
00243         require_once("class_invoice.php");
00244         $inv=new Invoice($cn);
00245         //$inv->List();
00246 }
00248 // Invoice remove a template
00250 if ( $p_action=='rm_template') {
00251 require_once("class_invoice.php");
00252         $inv=new Invoice($cn);
00253         $inv->Delete();
00254 }
00255   
00256   
00257 
00258 echo "</DIV>";
00259 html_page_stop();
00260 ?>

Generated on Wed May 31 21:39:14 2006 for phpcompta by  doxygen 1.4.4