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

preference.php

Go to the documentation of this file.
00001 <?
00002 
00003 /*
00004  *   This file is part of PhpCompta.
00005  *
00006  *   PhpCompta is free software; you can redistribute it and/or modify
00007  *   it under the terms of the GNU General Public License as published by
00008  *   the Free Software Foundation; either version 2 of the License, or
00009  *   (at your option) any later version.
00010  *
00011  *   PhpCompta is distributed in the hope that it will be useful,
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *   GNU General Public License for more details.
00015  *
00016  *   You should have received a copy of the GNU General Public License
00017  *   along with PhpCompta; if not, write to the Free Software
00018  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 */
00020 
00021 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00022 /* $Revision$ */
00037 function FormPeriodeMult($p_cn)
00038 {
00039   $sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start,
00040                     to_char(p_end,'DD.MM.YYYY') as p_end 
00041         from parm_periode  
00042             order by p_exercice,p_start";
00043   $Res=ExecSql($p_cn,$sql);
00044   $Max=pg_NumRows($Res);
00045   $ret='<SELECT NAME="periode[]" SIZE="12" multiple>';
00046   for ( $i = 0; $i < $Max;$i++) {
00047     $l_line=pg_fetch_array($Res,$i);
00048     $ret.=sprintf('<OPTION VALUE="%s">%s - %s',$l_line['p_id']
00049                   ,$l_line['p_start']
00050                   ,$l_line['p_end']);
00051 
00052   }
00053   $ret.="</SELECT>";
00054   return $ret;
00055 }
00056 
00071 function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="")
00072 {
00073   switch ($p_type) {
00074   case CLOSED:
00075     $sql_closed="p_closed=true and p_central = false ";
00076     break;
00077   case OPEN:
00078     $sql_closed="p_closed=false";
00079     break;
00080   case NOTCENTRALIZED:
00081     $sql_closed="p_closed=true and p_central = false ";
00082     break;
00083   default:
00084     error("invalide p_type in 'preference.php'#__LINE__");
00085   }
00086   $sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start_string,
00087                     to_char(p_end,'DD.MM.YYYY') as p_end_string 
00088         from parm_periode where 
00089          $sql_closed 
00090           order by p_start";
00091           
00092   $Res=ExecSql($p_cn,$sql);
00093   $Max=pg_NumRows($Res);
00094   if ( $Max == 0 ) return null;
00095   $ret='<SELECT NAME="periode'.$p_suff.'">';
00096   for ( $i = 0; $i < $Max;$i++) {
00097     $l_line=pg_fetch_array($Res,$i);
00098     if ( $l_default == $l_line['p_id'] )
00099       $sel="SELECTED";
00100     else
00101       $sel="";
00102 
00103     $ret.=sprintf('<OPTION VALUE="%s" %s>%s - %s',$l_line['p_id']
00104                   ,$sel
00105                   ,$l_line['p_start_string']
00106                   ,$l_line['p_end_string']);
00107 
00108   }
00109   $ret.="</SELECT>";
00110   return $ret;
00111 }
00122 function GetPeriode($p_cn,$p_periode) 
00123 {
00124  $sql="select to_char(p_start,'DD.MM.YYYY') as p_start,
00125               to_char(p_end,'DD.MM.YYYY')   as p_end
00126        from parm_periode
00127          where p_id=".$p_periode;
00128  $Res=ExecSql($p_cn,$sql);
00129  if ( pg_NumRows($Res) == 0) return null;
00130  return pg_fetch_array($Res,0);
00131 
00132 }
00143 function PeriodeClosed($p_cn,$p_periode) 
00144 {
00145  $sql="select p_closed
00146        from parm_periode
00147          where p_id=".$p_periode;
00148  $Res=ExecSql($p_cn,$sql);
00149  if ( pg_NumRows($Res) == 0) return null;
00150  $l_line=pg_fetch_array($Res,0);
00151  return $l_line['p_closed'];
00152 
00153 }
00165 function GetExercice($p_cn,$p_periode)
00166 {
00167   $Res=ExecSql($p_cn,"select p_exercice from parm_periode".
00168                " where p_id=$p_periode");
00169   if ( pg_NumRows($Res) == 0 ) return "";
00170   $line=pg_fetch_array($Res,0);
00171   return $line['p_exercice'];
00172 }
00182 function ShowDevise($p_cn)
00183 {
00184  echo "<h2 class=\"info\"> Devises </H2>";
00185   echo '<TABLE ALIGN="CENTER">';
00186   echo "<TR>";
00187   echo '<TH> CODE </TH>';
00188   echo '<TH> Valeur <BR>(par rapport à l\'euro) </TH>';
00189   echo "</TR>";
00190 
00191   $Res=ExecSql($p_cn,"select pm_id,pm_code,pm_rate  from parm_money order by pm_code");
00192   $Max=pg_NumRows($Res);
00193   
00194   for ($i=0;$i<$Max;$i++) {
00195     $l_line=pg_fetch_array($Res,$i);
00196     echo '<TR>'; 
00197     echo '<TD>'.$l_line['pm_code'].'</TD>';
00198     $l_rate=sprintf("% 10.6f",$l_line['pm_rate']);
00199     echo '<TD ALIGN="RIGHT">'.$l_rate.'</TD>';
00200     echo "<TD class=\"mtitle\"> <A class=\"mtitle\" HREF=\"parametre.php?p_mid=$l_line[pm_id]&p_action=change&p_code=$l_line[pm_code]&p_rate=$l_line[pm_rate]\">Change</A></TD>";
00201     echo "<TD class=\"mtitle\"> <A class=\"mtitle\" HREF=\"parametre.php?p_mid=$l_line[pm_id]&p_action=delete&p_code=$l_line[pm_code]\">Efface</A></TD>";
00202     echo '</TR>';
00203     
00204   }
00205   echo '<TR> <FORM ACTION="parametre.php" METHOD="POST">';
00206 echo '<TD> <INPUT TYPE="text" NAME="p_devise"></TD>';
00207  echo '<TD> <INPUT TYPE="text" NAME="p_rate"></TD>';
00208  echo '<TD> <INPUT TYPE="SUBMIT" NAME="action" Value="Ajout"</TD>';
00209  echo '</FORM></TR>';
00210  echo '</TABLE>';
00211 }
00221 function ShowPeriode($p_cn)
00222 {
00223   //  echo "<h2 class=\"info\"> Période </H2>";
00224   $Res=ExecSql($p_cn,"select p_id,to_char(p_start,'DD.MM.YYYY') as date_start,to_char(p_end,'DD.MM.YYYY') as date_end,p_central,p_closed,p_exercice
00225   from parm_periode order by p_start");
00226   $Max=pg_NumRows($Res);
00227   echo '<TABLE ALIGN="CENTER">';
00228   echo "</TR>";
00229   echo '<TH> Date début </TH>';
00230   echo '<TH> Date fin </TH>';
00231   echo '<TH> Exercice </TH>';
00232   echo "</TR>";
00233   
00234   for ($i=0;$i<$Max;$i++) {
00235     $l_line=pg_fetch_array($Res,$i);
00236     echo '<TR>'; 
00237     echo '<TD ALIGN="CENTER"> '.$l_line['date_start'].'</TD>';
00238     echo '<TD  ALIGN="CENTER"> '.$l_line['date_end'].'</TD>';
00239     echo '<TD  ALIGN="CENTER"> '.$l_line['p_exercice'].'</TD>';
00240     echo_debug('preference.php',__LINE__," closed : $l_line[p_closed]");
00241     if ( $l_line['p_closed'] == 't' )     { 
00242       $closed=($l_line['p_central']=='t')?'<TD>Centralisée</TD>':'<TD>Fermée</TD>';
00243       $change='<TD></TD>';
00244       $remove='<TD></TD>';
00245     } else {
00246       $closed='<TD class="mtitle">'; 
00247       $closed.='<A class="mtitle" HREF="user_advanced.php?p_action=periode&action=closed&p_per='.$l_line['p_id'].'"> Cloturer</A>';
00248     $change='<TD class="mtitle">';
00249     $change.='<A class="mtitle" HREF="user_advanced.php?p_action=periode&action=change_per&p_per='.
00250       $l_line['p_id']."&p_date_start=".$l_line['date_start'].
00251       "&p_date_end=".$l_line['date_end']."&p_exercice=".
00252       $l_line['p_exercice']."\"> Changer</A>";
00253     $remove='<TD class="mtitle">';
00254     $remove.='<A class="mtitle" HREF="user_advanced.php?p_action=periode&action=delete_per&p_per='.
00255       $l_line['p_id']."\"> Efface</A>";
00256 
00257     }
00258     echo "$closed";
00259     echo $change;
00260 
00261     echo $remove;
00262 
00263     echo '</TR>';
00264     
00265   }
00266   echo '<TR> <FORM ACTION="user_advanced.php?p_action=periode" METHOD="POST">';
00267   echo '<TD> <INPUT TYPE="text" NAME="p_date_start" SIZE="10"></TD>';
00268   echo '<TD> <INPUT TYPE="text" NAME="p_date_end" SIZE="10"></TD>';
00269   echo '<TD> <INPUT TYPE="text" NAME="p_exercice" SIZE="10"></TD>';
00270   echo '<TD> <INPUT TYPE="SUBMIT" NAME="add_per" Value="Ajout"</TD>';
00271   echo '<TD></TD>';
00272   echo '<TD></TD>';
00273   echo '</FORM></TR>';
00274 
00275   echo '</TABLE>';
00276 }
00277 
00278 ?>

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