/* * 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='"; 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='"; return $ret; } /*! GetPeriode * \brief Give the start & end date of a periode * * \param p_connection * \param p_periode * * \return array containing the start date & the end date * * */ function GetPeriode($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 GetExercice($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 "
| CODE | '; echo ' Valeur (par rapport à l\'euro) | ';
echo "||
|---|---|---|---|
| '.$l_line['pm_code'].' | '; $l_rate=sprintf("% 10.6f",$l_line['pm_rate']); echo ''.$l_rate.' | '; echo "Change | "; echo "Efface | "; echo '
| Date début | '; echo 'Date fin | '; echo 'Exercice | '; echo ""; for ($i=0;$i<$Max;$i++) { $l_line=pg_fetch_array($Res,$i); echo '|||||||
|---|---|---|---|---|---|---|---|---|---|
| '.$l_line['date_start'].' | '; echo ''.$l_line['date_end'].' | '; echo ''.$l_line['p_exercice'].' | '; echo_debug('preference.php',__LINE__," closed : $l_line[p_closed]"); if ( $l_line['p_closed'] == 't' ) { $closed=($l_line['p_central']=='t')?'Centralisée | ':'Fermée | '; $change=''; $remove=' | '; } else { $closed=' | '; $closed.=' Cloturer'; $change=' | '; $change.=' Changer"; $remove=' | '; $remove.=' Efface"; } echo "$closed"; echo $change; echo $remove; echo ' |