task 5026 Add more check for the account

This commit is contained in:
sparkyx 2006-07-21 08:01:33 +00:00
parent cc3977bda3
commit 9346524d2f
5 changed files with 60 additions and 69 deletions

View file

@ -126,5 +126,4 @@ function GetSolde($p_cn,$p_account,$p_cond="") {
return $r['sum_deb']-$r['sum_cred'];
}
?>

View file

@ -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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
return 1;
}
?>

View file

@ -318,14 +318,6 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
// Verify is a client is set
// if ( isNumber($e_client) == 0)
// {
// $msg="Client inexistant";
// echo_error($msg); echo_error($msg);
// echo "<SCRIPT>alert('$msg');</SCRIPT>";
// 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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
// 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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 )

View file

@ -61,6 +61,9 @@ function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
echo "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
}
// Check if the card has a valid account
if ( CheckPoste($p_cn,${"e_other".$i}) == null )
return null;
}
// Verify the userperiode

View file

@ -348,6 +348,9 @@ for ($o = 0;$o < $p_number; $o++) {
echo "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
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 "<SCRIPT>alert('$msg');</SCRIPT>";
// 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 "<SCRIPT>alert('$msg');</SCRIPT>";
}
}
// Verify the userperiode