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 " "; + $search='"; echo_debug("search $search"); // To avoid problem with unknown variable if ( ! isset ($e_rapt) ) { @@ -278,192 +278,296 @@ 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 ""; - echo ""; - echo ""; - echo 'Date : '; + // for the first line + if ( $i == 0 ) { + $r.=""; + $r.=""; + // Date + $r.=""; + // comment can be changed + $r.=""; - // Chargement comptes disponibles - if ( strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) { - $valid_deb=split(" ",$l_line['jrn_def_class_deb']); + // Internal + $r.=""; + // Amount + // Internal +// $r.=""; - // Creation query - $SqlDeb="select pcm_val,pcm_lib from tmp_pcmn where "; - foreach ( $valid_deb as $item_deb) { - if ( strlen (trim($item_deb))) { - echo_debug("l_line[jrn_def_class_deb] $l_line[jrn_def_class_deb] item_deb $item_deb"); - if ( strstr($item_deb,"*") == true ) { - $item_deb=strtr($item_deb,"*","%"); - $Sql=" pcm_val like '$item_deb' or"; - } else { - $Sql=" pcm_val = '$item_deb' or"; - } - $SqlDeb=$SqlDeb.$Sql; + $r.=""; + $r.="
"; + $r.=$content['jr_date']; + $r.=""; + $r.=''; + $r.=""; + $r.=$content['jr_internal']; + $r.=""; +// $r.="Montant ".$content['jr_montant']; +// $r.="
"; + $r.=""; } - } - $SqlDeb = substr($SqlDeb,0,strlen($SqlDeb)-2)." order by pcm_val::text"; - } else - { - $SqlDeb="select pcm_val,pcm_lib from tmp_pcmn order by pcm_val::text"; - } - echo_debug("SqlDeb $SqlDeb"); - $Res=ExecSql($cn,$SqlDeb); - $Count=pg_NumRows($Res); + $r.=""; + if ( $content['j_debit'] == 'f' ) $r.=$col_vide; + // $r.=""; + + $r.=""; + if ( $content['j_debit'] == 't' ) $r.=$col_vide; + $r.=""; + if ( $content['j_debit'] == 'f' ) $r.=$col_vide; + $r.=""; + $r.=""; - for ( $i=0;$i<$Count;$i++) { - $l2_line=pg_fetch_array($Res,$i); - $lib=substr($l2_line['pcm_lib'],0,35); - $poste [$l2_line['pcm_val']]= $lib; - } + // }// foreach ($l_array[$i] as $value=>$content) + }// for ( $i =0 ; $i < sizeof($l_array); $i++) - echo "
".$content['j_debit']."".$content['j_poste']."".$content['vw_name']."".$content['j_montant']."
"; - //echo ''; - for ( $i=0;$i < $p_MaxDeb;$i++) { - echo ""; - - echo ""; - /* printf('', - $i, - ${"e_text_deb$i"}); - */ - printf ('', - $i,$i,${"e_mont_deb$i"},$i); - echo ""; - - } - - echo ''; - // Chargement comptes disponibles - if ( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ) { - $valid_cred=split(" ",$l_line['jrn_def_class_cred']); - - // Creation query - $SqlCred="select pcm_val,pcm_lib from tmp_pcmn where "; - foreach ( $valid_cred as $item_cred) { - if ( strlen (trim($item_cred))) { - echo_debug("l_line[jrn_def_class_cred] $l_line[jrn_def_class_cred] item_cred $item_cred"); - if ( strstr($item_cred,"*") == true ) { - $item_cred=strtr($item_cred,"*","%"); - $Sql=" pcm_val like '$item_cred' or"; - } else { - $Sql=" pcm_val = '$item_cred' or"; - } - $SqlCred=$SqlCred.$Sql; + $r.="
Date : '; - echo '

débit

"; - printf('', - $i, - ${"e_op_deb$i"}); - - printf ('"; - echo " Montant :

crédit

"; + $r.="Total ".$content['jr_montant']."
"; + // show all the related operation + $a=GetConcerned($p_cn,$content['jr_id']); + + if ( $a != null ) { + $r.="Operation concernée "; + if ( isset ($_GET["PHPSESSID"]) ) { + $sessid=$_GET["PHPSESSID"]; + } + else { + $sessid=$_POST["PHPSESSID"]; } - } - $SqlCred = substr($SqlCred,0,strlen($SqlCred)-2)." order by pcm_val::text" ; - } else - { - $SqlCred="select pcm_val,pcm_lib from tmp_pcmn order by pcm_val::text"; - } - echo_debug("SqlCred $SqlCred"); - $Res=ExecSql($cn,$SqlCred); - $Count=pg_NumRows($Res); + foreach ($a as $key => $element) { + $r.=sprintf ('%s ', + GetInternal($p_cn,$element),GetGrpt($p_cn,$element),$sessid); + $r.=sprintf('
', + $content['jr_id'],$element,$sessid); + // $r.= " "..","; + }//for + }// if ( $a != null ) { - for ( $i=0;$i<$Count;$i++) { - $l2_line=pg_fetch_array($Res,$i); - $lib=substr($l2_line['pcm_lib'],0,35); - $poste_c[$l2_line['pcm_val']]=$lib; - } - for ( $i=0;$i < $p_MaxCred;$i++) { - echo ""; - echo ""; - printf('', - $i, - ${"e_op_cred$i"}); - - printf ('"; - echo ""; - - printf (' Montant :', - $i,$i,${"e_mont_cred$i"}); - echo ""; - - } if ( isset ($_GET["PHPSESSID"]) ) { $sessid=$_GET["PHPSESSID"]; } else { $sessid=$_POST["PHPSESSID"]; } - - $search='"; - - echo '

rapprochement

- '.$search.''; - echo ""; - echo "

Commentaire


"; - echo ''; - echo $e_comment; - echo ""; - - $e_sum_deb=0; - $e_sum_cred=0; - - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - 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 ""; +// echo ""; +// echo ""; +// echo 'Date : '; + + +// // Chargement comptes disponibles +// if ( strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) { +// $valid_deb=split(" ",$l_line['jrn_def_class_deb']); + +// // Creation query +// $SqlDeb="select pcm_val,pcm_lib from tmp_pcmn where "; +// foreach ( $valid_deb as $item_deb) { +// if ( strlen (trim($item_deb))) { +// echo_debug("l_line[jrn_def_class_deb] $l_line[jrn_def_class_deb] item_deb $item_deb"); +// if ( strstr($item_deb,"*") == true ) { +// $item_deb=strtr($item_deb,"*","%"); +// $Sql=" pcm_val like '$item_deb' or"; +// } else { +// $Sql=" pcm_val = '$item_deb' or"; +// } +// $SqlDeb=$SqlDeb.$Sql; +// } +// } +// $SqlDeb = substr($SqlDeb,0,strlen($SqlDeb)-2)." order by pcm_val::text"; +// } else +// { +// $SqlDeb="select pcm_val,pcm_lib from tmp_pcmn order by pcm_val::text"; +// } +// echo_debug("SqlDeb $SqlDeb"); +// $Res=ExecSql($cn,$SqlDeb); +// $Count=pg_NumRows($Res); + +// for ( $i=0;$i<$Count;$i++) { +// $l2_line=pg_fetch_array($Res,$i); +// $lib=substr($l2_line['pcm_lib'],0,35); +// $poste [$l2_line['pcm_val']]= $lib; +// } + +// echo ""; +// //echo ''; +// for ( $i=0;$i < $p_MaxDeb;$i++) { +// echo ""; + +// echo ""; +// /* printf('', +// $i, +// ${"e_text_deb$i"}); +// */ +// printf ('', +// $i,$i,${"e_mont_deb$i"},$i); +// echo ""; + +// } + +// echo ''; +// // Chargement comptes disponibles +// if ( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ) { +// $valid_cred=split(" ",$l_line['jrn_def_class_cred']); + +// // Creation query +// $SqlCred="select pcm_val,pcm_lib from tmp_pcmn where "; +// foreach ( $valid_cred as $item_cred) { +// if ( strlen (trim($item_cred))) { +// echo_debug("l_line[jrn_def_class_cred] $l_line[jrn_def_class_cred] item_cred $item_cred"); +// if ( strstr($item_cred,"*") == true ) { +// $item_cred=strtr($item_cred,"*","%"); +// $Sql=" pcm_val like '$item_cred' or"; +// } else { +// $Sql=" pcm_val = '$item_cred' or"; +// } +// $SqlCred=$SqlCred.$Sql; +// } +// } +// $SqlCred = substr($SqlCred,0,strlen($SqlCred)-2)." order by pcm_val::text" ; +// } else +// { +// $SqlCred="select pcm_val,pcm_lib from tmp_pcmn order by pcm_val::text"; +// } +// echo_debug("SqlCred $SqlCred"); +// $Res=ExecSql($cn,$SqlCred); +// $Count=pg_NumRows($Res); + + +// for ( $i=0;$i<$Count;$i++) { +// $l2_line=pg_fetch_array($Res,$i); +// $lib=substr($l2_line['pcm_lib'],0,35); +// $poste_c[$l2_line['pcm_val']]=$lib; +// } +// for ( $i=0;$i < $p_MaxCred;$i++) { +// echo ""; +// echo ""; + +// printf ('', +// $i,$i,${"e_mont_cred$i"}); +// echo ""; + +// } +// if ( isset ($_GET["PHPSESSID"]) ) { +// $sessid=$_GET["PHPSESSID"]; +// } +// else { +// $sessid=$_POST["PHPSESSID"]; +// } + +// $search='"; + +// echo ''; +// echo "
Date : '; +// echo '

débit

"; +// printf('', +// $i, +// ${"e_op_deb$i"}); + +// printf ('"; +// echo " Montant :

crédit

"; +// printf('', +// $i, +// ${"e_op_cred$i"}); + +// printf ('"; +// echo " Montant :

rapprochement

+// '.$search.'
"; +// echo "

Commentaire


"; +// echo ''; +// echo $e_comment; +// echo ""; + +// $e_sum_deb=0; +// $e_sum_cred=0; + +// echo ''; +// echo ''; +// echo ''; +// echo ''; +// echo ''; +// 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; +} ?>