altocompta/include/preference.php
Dany De Bontridder 8e1db97b25 Merged revisions 2171,2173-2176,2178-2179,2181-2187,2189,2191-2194,2196-2230,2232,2234-2244 via svnmerge from
svn+ssh://danydb@svn/svn/phpcompta/branches/rel420

........
  r2174 | danydb | 2008-09-16 21:34:23 +0200 (Tue, 16 Sep 2008) | 3 lines
  
  Removed merge tracking for "svnmerge" for 
  svn+ssh://danydb@svn/svn/phpcompta/branches/rel410-exp
........
  r2178 | danydb | 2008-09-16 21:43:31 +0200 (Tue, 16 Sep 2008) | 1 line
  
  Update version
........
  r2191 | danydb | 2008-09-22 20:31:03 +0200 (Mon, 22 Sep 2008) | 1 line
  
  Add correct version
........
  r2196 | danydb | 2008-10-03 21:46:50 +0200 (Fri, 03 Oct 2008) | 1 line
  
  update index version
........
  r2234 | danydb | 2008-11-19 20:54:30 +0100 (Wed, 19 Nov 2008) | 1 line
  
  Add the payer, not yet finished
........
  r2235 | danydb | 2008-11-21 22:34:32 +0100 (Fri, 21 Nov 2008) | 1 line
  
  Add the form for setting the medium of payment
........
  r2236 | danydb | 2008-11-22 23:15:30 +0100 (Sat, 22 Nov 2008) | 1 line
  
  Improve add : payment (second operation) + generation of a note of fee
........
  r2237 | danydb | 2008-11-23 01:20:40 +0100 (Sun, 23 Nov 2008) | 1 line
  
  Improve Payment method
........
  r2238 | danydb | 2008-11-23 01:45:52 +0100 (Sun, 23 Nov 2008) | 1 line
  
  Get only the valid payment method
........
  r2239 | danydb | 2008-11-24 23:03:34 +0100 (Mon, 24 Nov 2008) | 1 line
  
  cosmetic remove debug info
........
  r2240 | danydb | 2008-11-24 23:04:07 +0100 (Mon, 24 Nov 2008) | 1 line
  
  Filter the search to the good frd_id
........
  r2241 | danydb | 2008-11-26 18:11:30 +0100 (Wed, 26 Nov 2008) | 2 lines
  
  BUG if no class base is given the flag create account is false
........
  r2242 | danydb | 2008-11-26 18:45:56 +0100 (Wed, 26 Nov 2008) | 1 line
  
  Create note of fee + database patch
........
2008-11-26 18:32:19 +00:00

221 lines
6 KiB
PHP

<?php
/*
* This file is part of PhpCompta.
*
* PhpCompta is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PhpCompta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpCompta; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
/* $Revision$ */
/*! \file
* \brief include file for the periode form, currency,...
*
*/
/*! FormPeriodeMult
* \brief Generate the form for the periode
*
*
* \param $p_cn connexion
*
* \return string containing html code for the
* form
*
*/
function FormPeriodeMult($p_cn)
{
$sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start,
to_char(p_end,'DD.MM.YYYY') as p_end
from parm_periode
order by p_exercice,p_start";
$Res=ExecSql($p_cn,$sql);
$Max=pg_NumRows($Res);
$ret='<SELECT NAME="periode[]" SIZE="12" multiple>';
for ( $i = 0; $i < $Max;$i++) {
$l_line=pg_fetch_array($Res,$i);
$ret.=sprintf('<OPTION VALUE="%s">%s - %s',$l_line['p_id']
,$l_line['p_start']
,$l_line['p_end']);
}
$ret.="</SELECT>";
return $ret;
}
/*!
* \brief Generate the form for the periode
*
*
* \param $p_cn connexion
* \param $p_default default periode
* \param $p_type the type of the periode OPEN CLOSE NOTCENTRALIZED or ALL
* \param $p_suff the suffix of the name
*
* \return string containing html code for the HTML
*
*
*
*/
function FormPeriode($p_cn,$l_default=0,$p_type=OPEN,$p_suff="")
{
switch ($p_type) {
case CLOSED:
$sql_closed="where p_closed=true and p_central = false ";
break;
case OPEN:
$sql_closed="where p_closed=false";
break;
case NOTCENTRALIZED:
$sql_closed="where p_closed=true and p_central = false ";
break;
case ALL:
$sql_closed="";
break;
default:
error("invalide p_type in 'preference.php'#__LINE__");
}
$sql="select p_id,to_char(p_start,'DD.MM.YYYY') as p_start_string,
to_char(p_end,'DD.MM.YYYY') as p_end_string
from parm_periode
$sql_closed
order by p_start,p_end";
$Res=ExecSql($p_cn,$sql);
$Max=pg_NumRows($Res);
if ( $Max == 0 ) return null;
$ret='<SELECT NAME="periode'.$p_suff.'">';
for ( $i = 0; $i < $Max;$i++) {
$l_line=pg_fetch_array($Res,$i);
if ( $l_default == $l_line['p_id'] )
$sel="SELECTED";
else
$sel="";
$ret.=sprintf('<OPTION VALUE="%s" %s>%s - %s',$l_line['p_id']
,$sel
,$l_line['p_start_string']
,$l_line['p_end_string']);
}
$ret.="</SELECT>";
return $ret;
}
/*! get_periode
* \brief Give the start & end date of a periode
*
* \param p_connection
* \param p_periode
*
* \return array containing the start date & the end date
* \todo the function get_periode@preference.php must be replaced
* by Periode::get_limit
*
*/
function get_periode($p_cn,$p_periode)
{
$sql="select to_char(p_start,'DD.MM.YYYY') as p_start,
to_char(p_end,'DD.MM.YYYY') as p_end
from parm_periode
where p_id=".$p_periode;
$Res=ExecSql($p_cn,$sql);
if ( pg_NumRows($Res) == 0) return null;
return pg_fetch_array($Res,0);
}
/*!
* \brief get the status of a periode
*
* \param $p_cn database connex
* \param periode id
*
* \return 't' if closed otherwise 'f'
*
*
*/
function PeriodeClosed($p_cn,$p_periode)
{
$sql="select p_closed
from parm_periode
where p_id=".$p_periode;
$Res=ExecSql($p_cn,$sql);
if ( pg_NumRows($Res) == 0) return null;
$l_line=pg_fetch_array($Res,0);
return $l_line['p_closed'];
}
/*!
* \brief get the exercice of a periode
*
*
* \param $p_cn connection
* \param $p_periode periode
*
* \return Exercice of the periode
*
*
*/
function get_exercice($p_cn,$p_periode)
{
$Res=ExecSql($p_cn,"select p_exercice from parm_periode".
" where p_id=$p_periode");
if ( pg_NumRows($Res) == 0 ) return "";
$line=pg_fetch_array($Res,0);
return $line['p_exercice'];
}
/*!
* \brief Show all the currency encoded
*
* \param $p_cn database connextion
*
* \return nothing
*
*
*/
function ShowDevise($p_cn)
{
echo "<h2 class=\"info\"> Devises </H2>";
echo '<TABLE ALIGN="CENTER">';
echo "<TR>";
echo '<TH> CODE </TH>';
echo '<TH> Valeur <BR>(par rapport à l\'euro) </TH>';
echo "</TR>";
$Res=ExecSql($p_cn,"select pm_id,pm_code,pm_rate from parm_money order by pm_code");
$Max=pg_NumRows($Res);
$link='parametre.php?p_action=divers&sa=devise&'.dossier::get();
for ($i=0;$i<$Max;$i++) {
$l_line=pg_fetch_array($Res,$i);
echo '<TR>';
echo '<TD>'.$l_line['pm_code'].'</TD>';
$l_rate=sprintf("% 10.6f",$l_line['pm_rate']);
echo '<TD ALIGN="RIGHT">'.$l_rate.'</TD>';
echo "<TD class=\"mtitle\"> <A class=\"mtitle\" HREF=\"$link&p_id=$l_line[pm_id]&sb=ch&p_code=$l_line[pm_code]&p_rate=$l_line[pm_rate]\">Change</A></TD>";
echo "<TD class=\"mtitle\"> <A class=\"mtitle\" HREF=\"$link&p_id=$l_line[pm_id]&sb=d&p_code=$l_line[pm_code]\">Efface</A></TD>";
echo '</TR>';
}
echo '<TR> <FORM ACTION="parametre.php" METHOD="POST">';
echo '<TD> <INPUT TYPE="text" NAME="p_devise"></TD>';
echo '<TD> <INPUT TYPE="text" NAME="p_rate"></TD>';
echo dossier::hidden();
echo '<input type="hidden" name="p_action" value="divers">';
echo '<input type="hidden" name="sa" value="devise">';
echo '<input type="hidden" name="sb" value="a">';
echo '<TD> <INPUT TYPE="SUBMIT" NAME="action" Value="Ajout"</TD>';
echo '</FORM></TR>';
echo '</TABLE>';
}
?>