diff --git a/html/annulation.php b/html/annulation.php index a1bc92bff..529746450 100644 --- a/html/annulation.php +++ b/html/annulation.php @@ -31,6 +31,7 @@ include_once ("postgres.php"); include_once("jrn.php"); require_once("class_widget.php"); require_once("class_acc_ledger.php"); +require_once("class_acc_operation.php"); /* Admin. Dossier */ include_once ("class_user.php"); require_once('class_dossier.php'); @@ -402,12 +403,11 @@ if ( $a != null ) { foreach ($a as $key => $element) { echo "operation concernée
"; +$operation=new Acc_Operation($cn); +$operation->jr_id=$element; - // echo " - // ".GetInternal($cn,$element)."
"; $w=new widget("button"); - $w->label=GetInternal($cn,$element); + $w->label=$operation->get_internal(); $w->javascript="modifyOperation('".$element."','".$_REQUEST['PHPSESSID']."',".dossier::id(). ','.$_REQUEST['p_jrn'].",'S')"; echo $w->IOValue().'
'; diff --git a/include/class_acc_operation.php b/include/class_acc_operation.php index 44d84c460..bb2ba1b1a 100644 --- a/include/class_acc_operation.php +++ b/include/class_acc_operation.php @@ -26,12 +26,13 @@ */ require_once ('class_user.php'); /*! \brief this file match the tables jrn & jrnx the purpose is to - remove or save accountant writing to these table. + * remove or save accountant writing to these table. * */ class Acc_Operation { var $db; /*!< database connx */ +var $jr_id; /*!< pk of jrn */ var $jrn_id; /*!< jrn_def_id */ var $debit; /*!< debit or credit */ var $user; /*!< current user */ @@ -45,7 +46,7 @@ class Acc_Operation * \brief constructor set automatically the attributes user and periode * \param $p_cn the databse connection */ - function Acc_operation($p_cn) { + function __construct($p_cn) { $this->db=$p_cn; $this->qcode=""; $this->user=$_SESSION['g_user']; @@ -83,7 +84,7 @@ class Acc_Operation *\brief Insert into the table Jrn, the amount is computed from jrnx thanks the * group id ($p_grpt) * - * \return nothing + * \return sequence * */ @@ -114,7 +115,23 @@ class Acc_Operation $Res=ExecSql($this->db,$sql); if ( $Res == false) return false; - return GetSequence($this->db,'s_jrn'); + $this->jr_id=GetSequence($this->db,'s_jrn'); + return $this->jr_id; +} +/*! + * \brief Return the internal value, the property jr_id must be set before + * + * \return null si aucune valeur de trouv + * + */ +function get_internal() { + if ( ! isset($this->jr_id) ) + throw new Exception('jr_id is not set',1); + $Res=ExecSql($this->db,"select jr_internal from jrn where jr_id=".$this->jr_id); + if ( pg_NumRows($Res) == 0 ) return null; + $l_line=pg_fetch_array($Res); + $this->jr_internal= $l_line['jr_internal']; + return $this->jr_internal; } } diff --git a/include/jrn.php b/include/jrn.php index 6fd6e6157..fd89ae463 100644 --- a/include/jrn.php +++ b/include/jrn.php @@ -29,6 +29,7 @@ require_once ('class_gestion_purchase.php'); require_once ('class_plananalytic.php'); require_once ('class_anc_operation.php'); require_once ('class_acc_ledger.php'); +require_once ('class_acc_operation.php'); /*! * \brief Display the form to UPDATE account operation in the expert view * @@ -168,8 +169,10 @@ function ShowOperationExpert($p_cn,$p_jr_id,$p_mode=1) $r.= '
'; foreach ($a as $key => $element) { + $operation=new Acc_operation($p_cn); + $operation->jr_id=$element; $r.=sprintf ('%s ', - GetInternal($p_cn,$element), + $operation->get_internal($p_cn,$element), $element, $sessid, $gDossier); @@ -485,8 +488,10 @@ function ShowOperationUser($p_cn,$p_jr_id,$p_mode=1) $r.= '
'; foreach ($a as $key => $element) { + $operation=new Acc_operation($p_cn); + $operation->jr_id=$element; $r.=sprintf ('%s ', - GetInternal($p_cn,$element), + $operation->get_internal(), $element, $sessid, $gDossier); @@ -732,7 +737,7 @@ function GetData ($p_cn,$p_grpt) { * - null si aucune valeur de trouvée * */ -function GetInternal($p_cn,$p_id) { +function get_internal($p_cn,$p_id) { $Res=ExecSql($p_cn,"select jr_internal from jrn where jr_id=$p_id"); if ( pg_NumRows($Res) == 0 ) return null; diff --git a/include/user_common.php b/include/user_common.php index 0aa801a06..1351a93a0 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -27,6 +27,7 @@ include_once("postgres.php"); require_once("class_document.php"); +require_once("class_acc_operation.php"); /*! \file * \brief Common functions */ @@ -704,9 +705,11 @@ $sort_echeance=" $image_ascEch foreach ($a as $key => $element) { - $l_amount=getDbValue($p_cn,"select jr_montant from jrn ". - " where jr_id=$element"); - $r.= " ".GetInternal($p_cn,$element)." [ $l_amount € ]"; + $operation=new Acc_Operation($p_cn); + $operation->jr_id=$element; + $l_amount=getDbValue($p_cn,"select jr_montant from jrn ". + " where jr_id=$element"); + $r.= " ".$operation->get_internal()." [ $l_amount € ]"; }//for }// if ( $a != null ) { $r.="";