Check(); if ( isset( $p_jrn )) { session_register("g_jrn"); $g_jrn=$p_jrn; } $cn=DbConnect($g_dossier); echo ''; echo JS_CONCERNED_OP; echo JS_VIEW_JRN_DETAIL; /* Get MaxLine */ include_once("poste.php"); include_once ("top_menu_compta.php"); ShowMenuCompta($g_dossier,$g_UserProperty); ShowMenuComptaRight($g_dossier,$g_UserProperty); if ( $g_UserProperty['use_admin'] == 0 ) { $r=CheckAction($g_dossier,$g_user,ENCJRN); if ($r == 0 ){ /* Cannot Access */ NoAccess(); } if ( isset ($g_jrn)) { $right=CheckJrn($g_dossier,$g_user,$g_jrn); if ($right == 0 ){ /* Cannot Access */ NoAccess(); exit -1; } } // if isset g_jrn } ShowMenuJrnUser($g_dossier,$g_UserProperty); if ( isset ( $_GET["action"] )) { if ( $_GET["action"] == "view" ) { // view all the journal's operation echo '
'; ShowMenuRecherche($g_dossier,$g_jrn); ViewJrn($g_dossier,$g_user,$g_jrn,"enc_jrn.php"); echo '
'; } if ( $_GET["action"] == "record" ) { if ( CheckJrn($g_dossier,$g_user,$g_jrn) < 2 ) { NoAccess(); exit -1; } echo_debug(__FILE__,__LINE__,"record"); $max_deb=$_GET["max_deb"]; $max_cred=$_GET["max_cred"]; RecordJrn($g_dossier,$g_user,$g_jrn,$max_deb,$max_cred); } if ($_GET["action"]=="update" ) { if ( CheckJrn($g_dossier,$g_user,$g_jrn) < 2 ) { NoAccess(); exit -1; } // p_id is jrn.jr_id $p_id=$_GET["line"]; echo_debug(__FILE__,__LINE__," action = update p_id = $p_id"); $r ='
'; $r.=UpdateJrn($cn,$p_id); $r.=''; $r.='
'; echo '
'; echo $r; echo '
'; } } ?> '; foreach ( $HTTP_POST_VARS as $key=>$element) { ${"p_$key"}=$element; } $p_MaxDeb+=2; echo ""; CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS); echo_debug(__FILE__,__LINE__,"CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);"); } if ( isset ($_POST['add_line_cred']) ) { echo '
'; foreach ( $HTTP_POST_VARS as $key=>$element) { ${"p_$key"}=$element; } $p_MaxCred+=2; echo "
"; CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS); echo_debug(__FILE__,__LINE__,"CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred+10,$HTTP_POST_VARS);"); } if ( isset ($_POST['viewsearch']) ) { reset($HTTP_POST_VARS); echo '
'; ShowMenuRecherche($g_dossier,$g_jrn,$HTTP_POST_VARS); ViewJrn($g_dossier,$g_user,$g_jrn,"enc_jrn.php",$HTTP_POST_VARS); echo '
'; } if ( isset($_POST['add_record']) ) { echo '
'; foreach ( $HTTP_POST_VARS as $name=>$element ) { echo_debug(__FILE__,__LINE__,"element $name -> $element "); // Sauve les données dans des variables ${"p_$name"}=$element; } $userPref=GetUserPeriode($cn,$g_user); list ($l_date_start,$l_date_end)=GetPeriode($cn,$userPref); $p_op_date=$p_op_date.substr($l_date_start,2,8); echo_debug(__FILE__,__LINE__,"p_op_date is $p_op_date"); $aHttp=$HTTP_POST_VARS; $aHttp['op_date']=$p_op_date; // Verifie data // $result=VerifData($cn,$HTTP_POST_VARS,$g_user); $result=VerifData($cn,$aHttp,$g_user); if ($result != NOERROR) { // Parse result AnalyzeError($result); echo "
"; CorrectRecord($g_dossier,$g_user,$g_jrn,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS); return; } $Res=StartSql($cn); $seq=GetNextId($cn,'j_grpt')+1; $s_op=GetNextId($cn,'j_id')+1; $tot_cred=0; $tot_deb=0; //debit for ( $i = 0; $i < $p_MaxDeb; $i++) { $montant=${"p_mont_deb$i"}; $l_class=${"p_class_deb$i"}; if ( strlen(trim($montant)) != 0 && $montant != 0) { ${"p_text_deb$i"}=FormatString(GetPosteLibelle($g_dossier,$l_class)); // $p_text=(FormatString(${"p_text_deb$i"})==null)?:FormatString(${"p_text_deb$i"}); $Sql="insert into jrnx(j_id,j_date,j_montant,j_poste,j_grpt, j_jrn_def,j_debit,j_tech_user,j_tech_per) values ( $s_op,to_date('$p_op_date','DD.MM.YYYY'), " .$montant.", $l_class,$seq, $g_jrn,true,'$g_user',$userPref)"; echo_debug(__FILE__,__LINE__,"sql $Sql"); $s_op++; $tot_deb+=$montant; $Res=ExecSql($cn,$Sql); if ( $Res == false ) { Rollback($cn); EndSql($cn); return;} // For the user profile we need the correct sequence id AlterSequence($cn,'s_jrn_op',$s_op); } } for ( $i = 0; $i < $p_MaxCred; $i++) { $montant=${"p_mont_cred$i"}; $l_class=${"p_class_cred$i"}; if ( strlen(trim($montant)) != 0 && $montant != 0) { //$p_text=(FormatString(${"p_text_cred$i"})==null)?FormatString(GetPosteLibelle($g_dossier,$l_class)):FormatString(${"p_text_cred$i"}); ${"p_text_cred$i"}=FormatString(GetPosteLibelle($g_dossier,$l_class)); $Sql="insert into jrnx(j_id,j_date,j_montant,j_poste,j_grpt, j_jrn_def,j_debit,j_tech_user,j_tech_per) values ( $s_op,to_date('$p_op_date','DD.MM.YYYY'), $montant, $l_class,$seq, $g_jrn,false,'$g_user',$userPref)"; echo_debug(__FILE__,__LINE__,"sql $Sql"); $s_op++; $tot_cred+=$montant; $Res=ExecSql($cn,$Sql); if ( $Res == false ) { Rollback($cn); EndSql($cn); break;} // For the user profile we need the correct sequence id AlterSequence($cn,'s_jrn_op',$s_op); } } $jrn_id=GetNextJrnId($cn,'jr_id')+1; if ( ! isset ($p_ech) ) $p_ech=""; $l_date=isDate($p_ech); if ( $l_date == null) { $p_ech='null'; } else { $p_ech="to_char('".$l_date."','DD.MM.YYYY')"; } $comment=FormatString($p_comment); $Sql=sprintf("insert into jrn(jr_id,jr_def_id,jr_comment,jr_date,jr_grpt_id, jr_montant,jr_tech_per) values(%s,%s,'%s',%s,%d,%f,%d)", $jrn_id, $g_jrn, $comment, $p_ech, $seq,$tot_deb,$userPref); echo_debug(__FILE__,__LINE__,"Sql $Sql"); $Res=ExecSql($cn,$Sql); if ($Res) SetInternalCode($cn,$seq,$g_jrn); if ( isset ($p_rapt)) InsertRapt($cn,$jrn_id,$p_rapt); if ( $Res) { Commit($cn); EndSql($cn); // For the user profile we need the correct sequence id AlterSequence($cn,'s_jrn',$jrn_id); // AlterSequence($cn,"s_grpt",$seq+1); //AlterSequence($cn,"s_jrn_op",$s_op); // Add the p_text to the array ViewRecord($g_dossier,$g_jrn,$seq,$p_MaxDeb,$p_MaxCred,$aHttp); // echo_debug(__FILE__,__LINE__,"ViewRecord($g_dossier,$g_jrn,$seq,$p_MaxDeb,$p_MaxCred,$HTTP_POST_VARS);"); echo_debug(__FILE__,__LINE__,"ViewRecord($g_dossier,$g_jrn,$seq,$p_MaxDeb,$p_MaxCred,$aHttp);"); } else { Rollback($cn); EndSql($cn); } } // _POST['add_record'] if ( isset($_POST['update_record']) ) { // NO UPDATE except rapt & comment UpdateComment($cn,$_POST['jr_id'],$_POST['comment']); InsertRapt($cn,$_POST['jr_id'],$_POST['rapt']); echo '
'; ViewJrn($g_dossier,$g_user,$g_jrn,"enc_jrn.php"); echo '
'; } // if update_record ?>