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: 1.16 $ */
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="where p_closed=true and p_central = false ";
00076     break;
00077   case OPEN:
00078     $sql_closed="where p_closed=false";
00079     break;
00080   case NOTCENTRALIZED:
00081     $sql_closed="where p_closed=true and p_central = false ";
00082     break;
00083   case ALL:
00084     $sql_closed="";
00085     break;
00086   default:
00087     error("invalide p_type in 'preference.php'#__LINE__");
00088   }
00089   $sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start_string,
00090                     to_char(p_end,'DD.MM.YYYY') as p_end_string 
00091         from parm_periode  
00092          $sql_closed 
00093           order by p_start";
00094           
00095   $Res=ExecSql($p_cn,$sql);
00096   $Max=pg_NumRows($Res);
00097   if ( $Max == 0 ) return null;
00098   $ret='<SELECT NAME="periode'.$p_suff.'">';
00099   for ( $i = 0; $i < $Max;$i++) {
00100     $l_line=pg_fetch_array($Res,$i);
00101     if ( $l_default == $l_line['p_id'] )
00102       $sel="SELECTED";
00103     else
00104       $sel="";
00105 
00106     $ret.=sprintf('<OPTION VALUE="%s" %s>%s - %s',$l_line['p_id']
00107                   ,$sel
00108                   ,$l_line['p_start_string']
00109                   ,$l_line['p_end_string']);
00110 
00111   }
00112   $ret.="</SELECT>";
00113   return $ret;
00114 }
00125 function GetPeriode($p_cn,$p_periode) 
00126 {
00127  $sql="select to_char(p_start,'DD.MM.YYYY') as p_start,
00128               to_char(p_end,'DD.MM.YYYY')   as p_end
00129        from parm_periode
00130          where p_id=".$p_periode;
00131  $Res=ExecSql($p_cn,$sql);
00132  if ( pg_NumRows($Res) == 0) return null;
00133  return pg_fetch_array($Res,0);
00134 
00135 }
00146 function PeriodeClosed($p_cn,$p_periode) 
00147 {
00148  $sql="select p_closed
00149        from parm_periode
00150          where p_id=".$p_periode;
00151  $Res=ExecSql($p_cn,$sql);
00152  if ( pg_NumRows($Res) == 0) return null;
00153  $l_line=pg_fetch_array($Res,0);
00154  return $l_line['p_closed'];
00155 
00156 }
00168 function GetExercice($p_cn,$p_periode)
00169 {
00170   $Res=ExecSql($p_cn,"select p_exercice from parm_periode".
00171                " where p_id=$p_periode");
00172   if ( pg_NumRows($Res) == 0 ) return "";
00173   $line=pg_fetch_array($Res,0);
00174   return $line['p_exercice'];
00175 }
00185 function ShowDevise($p_cn)
00186 {
00187  echo "<h2 class=\"info\"> Devises </H2>";
00188   echo '<TABLE ALIGN="CENTER">';
00189   echo "<TR>";
00190   echo '<TH> CODE </TH>';
00191   echo '<TH> Valeur <BR>(par rapport à l\'euro) </TH>';
00192   echo "</TR>";
00193 
00194   $Res=ExecSql($p_cn,"select pm_id,pm_code,pm_rate  from parm_money order by pm_code");
00195   $Max=pg_NumRows($Res);
00196   
00197   for ($i=0;$i<$Max;$i++) {
00198     $l_line=pg_fetch_array($Res,$i);
00199     echo '<TR>'; 
00200     echo '<TD>'.$l_line['pm_code'].'</TD>';
00201     $l_rate=sprintf("% 10.6f",$l_line['pm_rate']);
00202     echo '<TD ALIGN="RIGHT">'.$l_rate.'</TD>';
00203     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>";
00204     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>";
00205     echo '</TR>';
00206     
00207   }
00208   echo '<TR> <FORM ACTION="parametre.php" METHOD="POST">';
00209 echo '<TD> <INPUT TYPE="text" NAME="p_devise"></TD>';
00210  echo '<TD> <INPUT TYPE="text" NAME="p_rate"></TD>';
00211  echo '<TD> <INPUT TYPE="SUBMIT" NAME="action" Value="Ajout"</TD>';
00212  echo '</FORM></TR>';
00213  echo '</TABLE>';
00214 }
00224 function ShowPeriode($p_cn)
00225 {
00226   //  echo "<h2 class=\"info\"> Période </H2>";
00227   $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
00228   from parm_periode order by p_start");
00229   $Max=pg_NumRows($Res);
00230   echo '<TABLE ALIGN="CENTER">';
00231   echo "</TR>";
00232   echo '<TH> Date début </TH>';
00233   echo '<TH> Date fin </TH>';
00234   echo '<TH> Exercice </TH>';
00235   echo "</TR>";
00236   
00237   for ($i=0;$i<$Max;$i++) {
00238     $l_line=pg_fetch_array($Res,$i);
00239     echo '<TR>'; 
00240     echo '<TD ALIGN="CENTER"> '.$l_line['date_start'].'</TD>';
00241     echo '<TD  ALIGN="CENTER"> '.$l_line['date_end'].'</TD>';
00242     echo '<TD  ALIGN="CENTER"> '.$l_line['p_exercice'].'</TD>';
00243     echo_debug('preference.php',__LINE__," closed : $l_line[p_closed]");
00244     if ( $l_line['p_closed'] == 't' )     { 
00245       $closed=($l_line['p_central']=='t')?'<TD>Centralisée</TD>':'<TD>Fermée</TD>';
00246       $change='<TD></TD>';
00247       $remove='<TD></TD>';
00248     } else {
00249       $closed='<TD class="mtitle">'; 
00250       $closed.='<A class="mtitle" HREF="user_advanced.php?p_action=periode&action=closed&p_per='.$l_line['p_id'].'"> Cloturer</A>';
00251     $change='<TD class="mtitle">';
00252     $change.='<A class="mtitle" HREF="user_advanced.php?p_action=periode&action=change_per&p_per='.
00253       $l_line['p_id']."&p_date_start=".$l_line['date_start'].
00254       "&p_date_end=".$l_line['date_end']."&p_exercice=".
00255       $l_line['p_exercice']."\"> Changer</A>";
00256     $remove='<TD class="mtitle">';
00257     $remove.='<A class="mtitle" HREF="user_advanced.php?p_action=periode&action=delete_per&p_per='.
00258       $l_line['p_id']."\"> Efface</A>";
00259 
00260     }
00261     echo "$closed";
00262     echo $change;
00263 
00264     echo $remove;
00265 
00266     echo '</TR>';
00267     
00268   }
00269   echo '<TR> <FORM ACTION="user_advanced.php?p_action=periode" METHOD="POST">';
00270   echo '<TD> <INPUT TYPE="text" NAME="p_date_start" SIZE="10"></TD>';
00271   echo '<TD> <INPUT TYPE="text" NAME="p_date_end" SIZE="10"></TD>';
00272   echo '<TD> <INPUT TYPE="text" NAME="p_exercice" SIZE="10"></TD>';
00273   echo '<TD> <INPUT TYPE="SUBMIT" NAME="add_per" Value="Ajout"</TD>';
00274   echo '<TD></TD>';
00275   echo '<TD></TD>';
00276   echo '</FORM></TR>';
00277 
00278   echo '</TABLE>';
00279 }
00280 
00281 ?>