diff --git a/include/jrn.php b/include/jrn.php
index fddd5fe30..b6d3789e4 100644
--- a/include/jrn.php
+++ b/include/jrn.php
@@ -222,7 +222,7 @@ if ( $p_update == 0 ) echo "
| $e) {
- ${"e_$n"}= $e;
- echo_debug("e_$n= $e");
+ echo_debug("function UpdateJrn");
+
+ $l_array=GetDataJrnJrId($p_cn,$p_jr_id);
+ if ( $l_array == null ) {
+ echo_error ("Not data found for UpdateJrn p_jr_id = $p_jr_id");
+ return ;
+ }
+ for ( $i =0 ; $i < sizeof($l_array); $i++) {
+ foreach ($l_array[$i] as $value) {
+ echo_debug("update key $i value $value content ".$value['j_id']);
}
- /* Get Jrn's properties */
- $l_line=GetJrnProp($p_dossier,$p_jrn);
- if ( $l_line == null ) return;
+ }
+ $r=JS_VIEW_JRN_MODIFY;
- $l_dossier=sprintf("dossier%d",$p_dossier);
- $cn=DbConnect($l_dossier);
+ // Build the form
+ $col_vide=" | | ";
+ for ( $i =0 ; $i < sizeof($l_array); $i++) {
+ $content=$l_array[$i] ;
- echo '';
- printf ('
%s (%s)
',$l_line['jrn_def_name'],$l_line['jrn_def_code']);
- echo '
";
- echo '
';
+ $search='";
+
+ $r.= 'rapprochement
+ '.$search;
+ $r.='';
+
+ // echo $r;
+ return $r;
}
+// function UpdateJrn($p_dossier,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array)
+// {
+// include_once("postgres.php");
+// echo_debug("function UpdateJrn($p_dossier,$p_jrn,$p_MaxDeb,$p_MaxCred,$p_array)");
+// foreach ( $p_array as $n=>$e) {
+// ${"e_$n"}= $e;
+// echo_debug("e_$n= $e");
+// }
+// /* Get Jrn's properties */
+// $l_line=GetJrnProp($p_dossier,$p_jrn);
+// if ( $l_line == null ) return;
+
+// $l_dossier=sprintf("dossier%d",$p_dossier);
+// $cn=DbConnect($l_dossier);
+
+// echo '';
+// printf ('
%s (%s)
',$l_line['jrn_def_name'],$l_line['jrn_def_code']);
+// echo '
";
+// echo '
';
+
+// }
+
/* function ViewRec
* Purpose : debug function to be dropped
*
@@ -675,6 +779,7 @@ function GetNextJrnId($p_cn,$p_name) {
* - p_dossier,
* - p_user,
* - p_jrn
+ * - p_url for modif
* - array
* gen :
* -
@@ -682,7 +787,7 @@ function GetNextJrnId($p_cn,$p_name) {
* -
*
*/
-function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
+function ViewJrn($p_dossier,$p_user,$p_jrn,$p_url,$p_array=null) {
echo_debug("function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) ");
echo JS_VIEW_JRN_DETAIL;
$db=sprintf("dossier%d",$p_dossier);
@@ -692,8 +797,8 @@ function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
if ( $p_array == null) {
include_once("preference.php");
$l_periode=GetUserPeriode($cn,$p_user);
- $Res=ExecSql($cn,"select j_id,jr_internal,to_char(j_date,'DD.MM.YYYY') as j_date,
- j_montant,j_poste,pcm_lib,j_grpt,j_rapt,j_debit,j_centralized,j_tech_per,
+ $Res=ExecSql($cn,"select jr_id,j_id,jr_internal,to_char(j_date,'DD.MM.YYYY') as j_date,
+ j_montant,j_poste,pcm_lib,j_grpt,j_debit,j_centralized,j_tech_per,
pcm_lib
from jrnx inner join tmp_pcmn on j_poste=pcm_val
inner join jrn on jr_grpt_id=j_grpt
@@ -707,7 +812,7 @@ function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
echo_debug ("l_$key $element");
}
$sql="select j_id,to_char(j_date,'DD.MM.YYYY') as j_date,j_montant,j_poste,
- pcm_lib,j_grpt,j_rapt,j_debit,j_centralized,j_tech_per,jr_internal
+ pcm_lib,j_grpt,jr_id,j_debit,j_centralized,j_tech_per,jr_internal
from jrnx inner join tmp_pcmn on j_poste=pcm_val
inner join jrn on jr_grpt_id=j_grpt
where
@@ -752,8 +857,8 @@ function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
echo "";
- if ( $l_line['j_centralized'] == 'f' && isClosed($cn,$l_line['j_tech_per']) == false )
- {
+// if ( $l_line['j_centralized'] == 'f' && isClosed($cn,$l_line['j_tech_per']) == false )
+// {
echo "";
if ( isset ($_GET["PHPSESSID"]) ) {
$sessid=$_GET["PHPSESSID"];
@@ -766,27 +871,30 @@ function ViewJrn($p_dossier,$p_user,$p_jrn,$p_array=null) {
$num_op,$l_line['j_grpt'],$sessid);
// echo $num_op;
echo " | ";
+
+
+ //TODO no modification only cancel of wrong op.
echo '';
- echo "";
+ echo "";
echo "M";
echo " | ";
- }else {
+// }else {
- if ( isset ($_GET["PHPSESSID"]) ) {
- $sessid=$_GET["PHPSESSID"];
- } else {
- $sessid=$_POST["PHPSESSID"];
- }
+// if ( isset ($_GET["PHPSESSID"]) ) {
+// $sessid=$_GET["PHPSESSID"];
+// } else {
+// $sessid=$_POST["PHPSESSID"];
+// }
- echo '';
- list($z_type,$z_num,$num_op)=split("-",$l_line['jr_internal']);
- printf ('',
- $num_op,$l_line['j_grpt'],$sessid);
+// echo ' | ';
+// list($z_type,$z_num,$num_op)=split("-",$l_line['jr_internal']);
+// printf ('',
+// $num_op,$l_line['j_grpt'],$sessid);
- echo " | ";
- echo $col_vide;
+// echo "";
+// echo $col_vide;
- }
+// }
$l_id=$l_line['j_grpt'];
}
if ($l_line['j_debit']=='f')
@@ -841,6 +949,7 @@ function isClosed($p_cn,$p_period) {
*
*/
function GetData ($p_cn,$p_grpt) {
+ echo_debug("GetData $p_cn $p_grpt");
$Res=ExecSql($p_cn,"select
to_char(j_date,'DD.MM.YYYY') as j_date,
j_text,
@@ -851,7 +960,7 @@ function GetData ($p_cn,$p_grpt) {
jr_comment,
to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
to_char(jr_date,'DD.MM.YYYY') as jr_date,
- jr_rapt, jr_id,jr_internal
+ jr_id,jr_internal
from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$p_grpt");
$MaxLine=pg_NumRows($Res);
if ( $MaxLine == 0 ) return null;
@@ -886,7 +995,6 @@ function GetData ($p_cn,$p_grpt) {
$l_array['jr_internal']=$l_line['jr_internal'];
$l_array['comment']=$l_line['jr_comment'];
$l_array['ech']=$l_line['jr_ech'];
- $l_array['rapt']=$l_line['jr_rapt'];
$l_array['jr_id']=$l_line['jr_id'];
}
return array($l_array,$deb,$cred);
@@ -902,20 +1010,21 @@ function GetData ($p_cn,$p_grpt) {
* - -1 si aucune valeur de trouvée
*
*/
-function GetRapt($p_cn,$p_rappt) {
+// function GetRapt($p_cn,$p_rappt) {
- $Res=ExecSql($p_cn,"select jr_id from jrn where jr_rapt='$p_rappt'");
- if ( pg_NumRows($Res) == 0 ) return -1;
- $l_line=pg_fetch_array($Res);
- return $l_line['jr_id'];
-}
-/* function
- * Purpose :
+// $Res=ExecSql($p_cn,"select jr_id from jrn where jr_rapt='$p_rappt'");
+// if ( pg_NumRows($Res) == 0 ) return -1;
+// $l_line=pg_fetch_array($Res);
+// return $l_line['jr_id'];
+// }
+/* function GetInternal($p_cn,$p_id)
+ * Purpose : Return the internal value
*
* parm :
- * -
+ * - p_cn database connection
+ * - p_id : jrn.jr_id
* gen :
- * -
+ * - none
* return:
* - null si aucune valeur de trouvée
*
@@ -928,7 +1037,7 @@ function GetInternal($p_cn,$p_id) {
return $l_line['jr_internal'];
}
-/* function
+/* function NOT USED
* Purpose :
*
* parm :
@@ -939,15 +1048,15 @@ function GetInternal($p_cn,$p_id) {
* - -1 si aucune valeur de trouvée
*
*/
-function GetRaptDest($p_cn,$p_rappt) {
+// function GetRaptDest($p_cn,$p_rappt) {
- $Res=ExecSql($p_cn,"select jr_rapt from jrn where jr_internal='$p_rappt'");
- echo_debug("select jr_rapt from jrn where jr_id=$p_rappt");
- if ( pg_NumRows($Res) == 0 ) return -1;
- $l_line=pg_fetch_array($Res);
- if ( strlen (trim ($l_line['jr_rapt'])) == 0 ) return -1;
- return $l_line['jr_rapt'];
-}
+// $Res=ExecSql($p_cn,"select jr_rapt from jrn where jr_internal='$p_rappt'");
+// echo_debug("select jr_rapt from jrn where jr_id=$p_rappt");
+// if ( pg_NumRows($Res) == 0 ) return -1;
+// $l_line=pg_fetch_array($Res);
+// if ( strlen (trim ($l_line['jr_rapt'])) == 0 ) return -1;
+// return $l_line['jr_rapt'];
+// }
/* function GetAmount
* Purpose : return the sum of jrn where
* the internal_code is the p_id
@@ -1039,25 +1148,6 @@ function VerifData($p_cn,$p_array,$p_user)
return DIFF_AMOUNT;
}
- $l_dest=-1;
- // Rapprochement demandé et vérif
- if ( strlen(trim($p_rapt)) != 0 ){
- $l_dest=GetRapt($p_cn,$p_rapt);
- if ( $l_dest != -1 && $l_dest != $p_jr_id ) {
- return RAPPT_ALREADY_USED;
- }
- // Get Amount
-
- $l_mont=GetAmount($p_cn,$p_rapt);
- echo_debug ("amount = $tot_deb $l_mont");
- if ( $l_mont == -1 ) {
- return RAPPT_NOT_EXIST;
- }
- if ( $tot_deb != $l_mont) {
- return RAPPT_NOMATCH_AMOUNT;
- }
-
- }
return NOERROR;
}
@@ -1125,6 +1215,59 @@ function SetInternalCode($p_cn,$p_grpt,$p_jrn)
" jr_grpt_id = ".$p_grpt);
return $internal_code;
}
+/* function GetDataJrnJrid
+ * Purpose : Get data from jrn and jrnx thanks the jr_id
+ *
+ * parm :
+ * - connection
+ * - p_jr_id (jrn.jr_id)
+ * gen :
+ * - none
+ * return:
+ * - return array
+ *
+ */
+function GetDataJrnJrId ($p_cn,$p_jr_id) {
+ echo_debug("GetDataJrn $p_cn $p_jr_id");
+ $Res=ExecSql($p_cn,"select
+ j_text,
+ j_debit,
+ j_poste,
+ pcm_lib as vw_name,
+ j_montant,
+ jr_montant,
+ j_id,
+ jr_comment,
+ to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
+ to_char(jr_date,'DD.MM.YYYY') as jr_date,
+ jr_id,jr_internal
+ from
+ jrnx
+ inner join jrn on j_grpt=jr_grpt_id
+ left outer join tmp_pcmn on j_poste=pcm_val
+ where
+ jr_id=$p_jr_id
+ order by j_debit desc");
+ $MaxLine=pg_NumRows($Res);
+ if ( $MaxLine == 0 ) return null;
+
+ for ( $i=0; $i < $MaxLine; $i++) {
+ $line=pg_fetch_array($Res,$i);
+ $array['j_debit']=$line['j_debit'];
+ $array['vw_name']=$line['vw_name'];
+ $array['jr_comment']=$line['jr_comment'];
+ $array['j_montant']=$line['j_montant'];
+ $array['jr_id']=$line['jr_id'];
+ $array['jr_date']=$line['jr_date'];
+ $array['jr_internal']=$line['jr_internal'];
+ $array['j_poste']=$line['j_poste'];
+ $array['jr_montant']=$line['jr_montant'];
+ // $array['']=$line[''];
+
+ $ret_array[$i]=$array;
+ }
+ return $ret_array;
+}
?>