diff --git a/include/poste.php b/include/poste.php index e859b312b..50d40cbe7 100644 --- a/include/poste.php +++ b/include/poste.php @@ -126,5 +126,4 @@ function GetSolde($p_cn,$p_account,$p_cond="") { return $r['sum_deb']-$r['sum_cred']; } - ?> diff --git a/include/user_common.php b/include/user_common.php index 854d1f158..9237aa933 100644 --- a/include/user_common.php +++ b/include/user_common.php @@ -938,3 +938,44 @@ function jrn_navigation_bar($p_offset,$p_line,$p_size=0,$p_page=1) return $r; } + +/*!\brief Verify that a fiche has a valid ledger. It must be verify before + * entering data into jrnx. Called from the form_verify_input + * \param $p_cn database connx + * \param $qcode the quick_code + * \return null if an error occurs + a alert message in javascript + * otherwise 1 + */ +function CheckPoste($p_cn,$qcode) +{ + // check if the ATTR_DEF_ACCOUNT is set + $poste=GetFicheAttribut($p_cn,$qcode,ATTR_DEF_ACCOUNT); + echo_debug('poste.php',__LINE__,"poste value = ".$poste."size = ".strlen(trim($poste))); + if ( $poste == null ) + { + $msg="La fiche ".$qcode." n\'a pas de poste comptable"; + echo_error($msg); echo_debug('poste.php',__LINE__,$msg); + echo ""; + return null; + + } + if ( strlen(trim($poste))==0 ) + { + $msg="La fiche ".$qcode." n\'a pas de poste comptable"; + echo_error($msg); echo_debug('poste.php',__LINE__,$msg); + echo ""; + return null; + } + // Check that the account exists + if ( CountSql($p_cn, + "select * from tmp_pcmn where pcm_val=$poste") == 0 ) + { + $msg=" Le poste comptable $poste de la fiche ".$qcode." n\'existe pas"; + echo_error($msg); echo_debug('poste.php',__LINE__,$msg); + echo ""; + return null; + + } + return 1; +} +?> \ No newline at end of file diff --git a/include/user_form_ach.php b/include/user_form_ach.php index 48b796457..6a8bf9e96 100644 --- a/include/user_form_ach.php +++ b/include/user_form_ach.php @@ -318,14 +318,6 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } - // Verify is a client is set -// if ( isNumber($e_client) == 0) -// { -// $msg="Client inexistant"; -// echo_error($msg); echo_error($msg); -// echo ""; -// return null; -// } // if ech is a number of days then compute date limit if ( strlen($e_ech) != 0 and isNumber($e_ech) == 1) @@ -337,7 +329,7 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) $e_ech=$p_ech; $wHidden=new widget("hidden"); $data.=$wHidden->IOValue("e_ech",$e_ech); -# $data.=InputType("","HIDDEN","e_ech",$e_ech); + } // Check if the fiche is in the jrn @@ -348,22 +340,18 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } + // Check if the customer card has a valid account + if ( CheckPoste($p_cn,$e_client) == null ) + return null; // check if all e_march are in fiche for ($i=0;$i<$p_number;$i++) { - if ( trim(${"e_march$i"}) == "" ) { + if ( trim(${"e_march$i"}) == "" ) { // no goods to sell continue; } -// // Check wether the f_id is a number -// if ( isNumber(${"e_march$i"}) == 0 ) { -// $msg="Fiche inexistante !!! "; -// echo_error($msg); echo_error($msg); -// echo ""; -// return null; -// } // Check if ( isFicheOfJrn($p_cn,$p_jrn,${"e_march$i"},'deb') == 0 ) { $msg="Fiche inexistante !!! "; @@ -371,25 +359,9 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } - // check if the ATTR_DEF_ACCOUNT is set - $poste=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_ACCOUNT); - echo_debug('user_form_ach.php',__LINE__,"poste value = ".$poste."size = ".strlen(trim($poste))); - if ( $poste == null ) - { - $msg="La fiche ".${"e_march$i"}." n\'a pas de poste comptable"; - echo_error($msg); echo_debug('user_form_ach.php',__LINE__,$msg); - echo ""; - return null; - - } - if ( strlen(trim($poste))==0 ) - { - $msg="La fiche ".${"e_march$i"}." n\'a pas de poste comptable"; - echo_error($msg); echo_debug('user_form_ach.php',__LINE__,$msg); - echo ""; - return null; - } - + if ( CheckPoste($p_cn,${"e_march".$i}) == null ) + return null; + // Check if the percentage indicated in this field is valid $non_dedu=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_DEPENSE_NON_DEDUCTIBLE); if ( $non_dedu != null && strlen(trim($non_dedu)) != 0 ) diff --git a/include/user_form_fin.php b/include/user_form_fin.php index 3acfe610f..becb6e82e 100644 --- a/include/user_form_fin.php +++ b/include/user_form_fin.php @@ -61,6 +61,9 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) echo ""; return null; } + // Check if the card has a valid account + if ( CheckPoste($p_cn,$e_bank_account) == null ) + return null; // check if all e_march are in fiche for ($i=0;$i<$p_number;$i++) { @@ -82,22 +85,9 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number) 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 ""; - } + // Check if the card has a valid account + if ( CheckPoste($p_cn,${"e_other".$i}) == null ) + return null; } // Verify the userperiode diff --git a/include/user_form_ven.php b/include/user_form_ven.php index 3fbd593f4..1d74011b1 100644 --- a/include/user_form_ven.php +++ b/include/user_form_ven.php @@ -348,6 +348,9 @@ for ($o = 0;$o < $p_number; $o++) { echo ""; return null; } + // Check if the card has a valid account + if ( CheckPoste($p_cn,$e_client) == null ) + return null; // check if all e_march are in fiche for ($i=0;$i<$p_number;$i++) { @@ -364,23 +367,9 @@ for ($o = 0;$o < $p_number; $o++) { echo ""; return null; } - // check if the ATTR_DEF_ACCOUNT is set - $poste=GetFicheAttribut($p_cn,${"e_march$i"},ATTR_DEF_ACCOUNT); - if ( $poste == null ) - { - $msg="La fiche ".${"e_march$i"}." n\'a pas de poste comptable"; - echo_error($msg); echo_debug('user_form_ven.php',__LINE__,$msg); - echo ""; + // Check if the card has a valid account + if ( CheckPoste($p_cn,${"e_march$i"}) == null ) return null; - - } - if ( strlen(trim($poste))==0 ) - { - $msg="La fiche ".$tiers." n\'a pas de poste comptable"; - echo_error($msg); echo_debug('user_form_ven.php',__LINE__,$msg); - echo ""; - } - } // Verify the userperiode