/* * 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 */ /* $Revision$ */ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr require_once("class_widget.php"); require_once("constant.php"); require_once("preference.php"); require_once("fiche_inc.php"); require_once("user_common.php"); /*! \file * \brief Functions for the financial ledger */ /*! ************************************************** * \brief verify if the data to insert are valid * * * \param $p_cn database connection * \param $p_jrn concerned ledger * \param $p_periode User periode * \param $p_array array with the post data * \param $p_number number of items * gen : * - * return: */ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) { foreach ($p_array as $name=>$content) { ${"$name"}=$content; } // Verify the date if ( isDate($e_date) == null ) { echo_error("Invalid date $e_date"); echo_debug('user_form_fin.php',__LINE__,"Invalid date $e_date"); echo ""; return null; } // Check if the fiche is in the jrn if (IsFicheOfJrn($p_cn , $p_jrn, $e_bank_account,'deb') == 0 ) { $msg="Mauvais compte en banque"; echo_error($msg);echo_debug('user_form_fin.php',__LINE__,$msg); echo ""; return null; } // check if all e_march are in fiche for ($i=0;$i<$p_number;$i++) { if ( trim(${"e_other$i"}) == "" ) { // nothing to do continue; } // Check amount if ( isNumber(${"e_other".$i."_amount"}) == 0) { $msg="Montant invalide !!! "; echo_error($msg); echo_debug('user_form_fin.php',__LINE__,$msg); echo ""; return null; } // Check if ( isFicheOfJrn($p_cn,$p_jrn,${"e_other$i"},'cred') == 0 ) { $msg="Fiche inexistante !!! "; echo_error($msg);echo_debug('user_form_fin.php',__LINE__,$msg); echo ""; return null; } // check if the ATTR_DEF_ACCOUNT is set $poste=GetFicheAttribut($p_cn,${"e_other$i"},ATTR_DEF_ACCOUNT); if ( $poste == null ) { $msg="La fiche ".${"e_other$i"}." n\'a pas de poste comptable"; echo_error($msg); echo_debug('user_form_fin.php',__LINE__,$msg); echo ""; return null; } if ( strlen(trim($poste))==0 ) { $msg="La fiche ".${"e_other$i"}." n\'a pas de poste comptable"; echo_error($msg); echo_debug('user_form_fin.php',__LINE__,$msg); echo ""; } } // Verify the userperiode // p_periode contient la periode par default list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode); // Date dans la periode active echo_debug ('user_form_fin',__LINE__,"date start periode $l_date_start date fin periode $l_date_end date demande $e_date"); if ( cmpDate($e_date,$l_date_start)<0 || cmpDate($e_date,$l_date_end)>0 ) { $msg="Not in the active periode please change your preference"; echo_error($msg); echo_error($msg); echo ""; return null; } // Periode ferm� if ( PeriodeClosed ($p_cn,$p_periode)=='t' ) { $msg="This periode is closed please change your preference"; echo_error($msg); echo_error($msg); echo ""; return null; } return true; } /*! * \brief Display the form for financial * Used to show detail, encode a new fin op * or update one * * parm : * - p_array which can be empty * - the "journal" * - $p_user = $g_user * - $p_submit contains the submit string * - view_only if we cannot change it (no right or centralized op) * - $p_item number of article * gen : * - * return: string with the form */ function FormFin($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=true,$p_item=4,$p_save=false) { include_once("poste.php"); if ( $p_array != null ) { // array contains old value foreach ( $p_array as $a=>$v) { ${"$a"}=$v; } } // The date list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode); $flag=(isset($e_date))?1:0; $e_date=( ! isset($e_date) ) ? substr($l_date_start,2,8):$e_date; // Verify if valid date if ($flag ==1 and VerifyOperationDate($p_cn,$p_periode,$e_date) == null) { $e_date=substr($l_date_start,2,8); } $e_comment=(isset($e_comment))?$e_comment:""; $r=""; if ( $pview_only == false) { $r.=JS_SEARCH_CARD; $r.=JS_CONCERNED_OP; } $r.="
"; // if view_only is true //Put the new saldo here (old saldo - operation) if ( $pview_only==true) { // if not recorded the new amount must be recalculate if ( $p_save == false) { $r.=" Ancien Solde = ".$solde."