task 5025 : verify account

This commit is contained in:
sparkyx 2006-04-02 15:31:05 +00:00
parent b2e31b43b9
commit 63c83a625d
5 changed files with 89 additions and 27 deletions

View file

@ -1453,7 +1453,7 @@ function getFicheAttribut($p_cn,$p_id,$p_attr="") {
where
f_id=$p_id and
ad_id=$p_attr");
if ( pg_NumRows($Res) == 0 ) return "Unknown";
if ( pg_NumRows($Res) == 0 ) return NULL;
$st=pg_fetch_array($Res,0);
return $st['av_text'];
} else {

View file

@ -101,7 +101,7 @@ if ( $action == 'new' ) {
// if something goes wrong, correct it
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$submit,$HTTP_POST_VARS, $nb_number);
$r=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$HTTP_POST_VARS,$submit, false, $nb_number);
}
echo '<div class="u_redcontent">';
echo $r;

View file

@ -40,7 +40,7 @@ require_once("user_common.php");
*/
function FormAchInput($p_cn,$p_jrn,$p_periode,$p_array=null,$p_submit="",$pview_only=true,$p_article=1)
{
echo_debug(__FILE__,__LINE__,"Enter FormAchInput($p_cn,$p_jrn,$p_periode,$p_array,$p_submit,$pview_only,$p_article");
if ( $p_array != null) {
// array contains old value
extract($p_array);
@ -247,6 +247,7 @@ function FormAchInput($p_cn,$p_jrn,$p_periode,$p_array=null,$p_submit="",$pview_
*/
function form_verify_input($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
{
echo_debug(__FILE__,__LINE__,"Enter form_verify_input $p_cn,$p_jrn,$p_periode,".var_export($p_array,true).",$p_number");
foreach ($p_array as $name=>$content) {
${"$name"}=$content;
}
@ -341,6 +342,24 @@ 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);
echo_debug(__FILE__,__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(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
if ( strlen(trim($poste))==0 )
{
$msg="La fiche ".$tiers." n\'a pas de poste comptable";
echo_error($msg); echo_debug(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
}
// Verify the userperiode
@ -348,7 +367,7 @@ for ($o = 0;$o < $p_number; $o++) {
list ($l_date_start,$l_date_end)=GetPeriode($p_cn,$p_periode);
// Date dans la periode active
echo_debug ("date start periode $l_date_start date fin periode $l_date_end date demand<EFBFBD> $e_date");
echo_debug ("date start periode $l_date_start date fin periode $l_date_end date demande $e_date");
if ( cmpDate($e_date,$l_date_start)<0 ||
cmpDate($e_date,$l_date_end)>0 )
{

View file

@ -156,29 +156,55 @@ function FormFin($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=tru
$tiers_label="";
$tiers_amount=(isset(${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0;
if ( isNumber($tiers_amount) == 0) {
if ( $pview_only==true ){
$msg="Montant invalide !!! ";
echo_error($msg); echo_error($msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
$tiers_amount=0;
if ( $pview_only==true )
{
$msg="Montant invalide !!! ";
echo_error($msg); echo_error($msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
$tiers_amount=0;
}
$tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:"";
// If $tiers has a value
if ( isNumber($tiers) == 1 ) {
if ( isFicheOfJrn($p_cn,$p_jrn,$tiers,'cred') == 0 ) {
$msg="Fiche inexistante !!! ";
echo_error($msg); echo_error($msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
$tiers="";
} else {
// retrieve the tva label and name
$a_fiche=GetFicheAttribut($p_cn, $tiers);
if ( $a_fiche != null ) {
$tiers_label=$a_fiche['vw_name'];
}
}
if ( isNumber($tiers) == 1 )
{
if ( $pview_only && isFicheOfJrn($p_cn,$p_jrn,$tiers,'cred') == 0 )
{
$msg="Fiche inexistante !!! ";
echo_error($msg); echo_debug(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
$tiers="";
return null;
}
else
{
// retrieve the tva label and name
$a_fiche=GetFicheAttribut($p_cn, $tiers);
if ( $a_fiche != null ) {
$tiers_label=$a_fiche['vw_name'];
}
}
// if the parameter is set to view only we do not check
if ( $pview_only )
{
// check if the ATTR_DEF_ACCOUNT is set
$poste=GetFicheAttribut($p_cn,$tiers,ATTR_DEF_ACCOUNT);
if ( $poste == null )
{
$msg="La fiche ".$tiers." n\'a pas poste comptable";
echo_error($msg);echo_debug(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
if ( strlen(trim($poste))==0 )
{
$msg="La fiche ".$tiers." n\'a pas poste comptable";
echo_error($msg); echo_debug(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
}
}
${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0;

View file

@ -354,6 +354,23 @@ 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(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
return null;
}
if ( strlen(trim($poste))==0 )
{
$msg="La fiche ".$tiers." n\'a pas de poste comptable";
echo_error($msg); echo_debug(__FILE__,__LINE__,$msg);
echo "<SCRIPT>alert('$msg');</SCRIPT>";
}
}
// Verify the userperiode
@ -683,10 +700,10 @@ function RecordInvoice($p_cn,$p_array,$p_user,$p_jrn)
$vat_code=$a_vat[$i];
}
$r=ExecSql($p_cn,"insert into quant_sold".
"(qs_internal,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code) values".
"('".$internal."',".$a_good[$i].",".$a_quant[$i].",".$a_price[$i].
"(qs_internal,qs_fiche,qs_quantite,qs_price,qs_vat,qs_vat_code,qs_client) values".
"('".$internal."',".$a_good[$i].",".$a_quant[$i].",".$a_price[$i]*$a_quant[$i].
",".$computed_vat.
",".$vat_code.")");
",".$vat_code.",".$e_client.")");
if ( $r == false ) { Rollback($p_cn); exit(" Error __FILE__ __LINE__"); };
}
Commit($p_cn);