Add verify function + fix bug in budget detail
This commit is contained in:
parent
3f6ec9a500
commit
ed70806553
5 changed files with 38 additions and 5 deletions
|
|
@ -53,7 +53,7 @@ if ( $_POST['action'] == 'save' ) {
|
|||
|
||||
$obj=new Bud_Data($cn);
|
||||
$obj->get_from_array($a);
|
||||
|
||||
$obj->verify();
|
||||
if ( $bd_id == 0 ) {
|
||||
$obj->add();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -112,4 +112,21 @@ function bud_action(p_query,p_ctl) {
|
|||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
function bud_compute_sum(p_ctl) {
|
||||
var form=$('form_'+p_ctl);
|
||||
var elt=form.getElements();
|
||||
var sum=0;
|
||||
for (i=0; i<elt.length;i++) {
|
||||
if ( elt[i].name.search(/amount_/) != -1 ){
|
||||
if ( isNaN(elt[i].value)) {
|
||||
alert(elt[i].value+" n'est pas un nombre");
|
||||
elt[i].value=0;
|
||||
continue;
|
||||
}
|
||||
sum+=elt[i].value*1.0;
|
||||
}
|
||||
}
|
||||
$('form_total_'+p_ctl).innerHTML=sum;
|
||||
}
|
||||
|
|
@ -104,7 +104,12 @@ if ( $po_id !== -1 ) {
|
|||
echo $wPo_id->IOValue();
|
||||
}
|
||||
echo $button_other;
|
||||
|
||||
//echo http://localhost/phpcompta-dev/phpcompta/html/budget.php?gDossier=21&bh_id=3&recherche=recherche&p_action=detail//
|
||||
if ( isset ($_GET['po_id'] ) )
|
||||
$str_po_id="&po_id=".$_REQUEST['po_id'];
|
||||
else
|
||||
$str_po_id="";
|
||||
echo widget::button_href("Recharger","?".dossier::get()."&bh_id=".$_GET['bh_id']."&p_action=detail".$str_po_id);
|
||||
echo '<hr>';
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ class Bud_Data {
|
|||
$wAccount->table=0;
|
||||
$wAccount->disabled=true;
|
||||
$wAccount->value=$this->pcm_val.' - '.$this->pcm_lib;
|
||||
$wAccount->extra=$this->pcm_val;
|
||||
|
||||
$wBudCard=new widget('select');
|
||||
$wBudCard->value=$this->load_bud_card();
|
||||
$wBudCard->selected=$this->bc_id;
|
||||
|
|
@ -214,14 +216,15 @@ class Bud_Data {
|
|||
$r.="Compte d'exploitation ".$wAccount->IOValue('account_'.$p_number);
|
||||
// $r.=widget::hidden('account_'.$p_number.'_hidden',$this->pcm_val);
|
||||
$r.="Fiche Budget ".$wBudCard->IOValue('bc_id'.$p_number);
|
||||
$r.='Total : <span id="form_'.$p_number.'"> '.$tot.' </span>';
|
||||
$r.='Total : <span id="form_total_'.$p_number.'"> '.$tot.' </span>';
|
||||
$r.='<table WIDTH="100%">';
|
||||
$r.=$this->header_table();
|
||||
$r.="<tr> ";
|
||||
foreach ($this->amount as $p_id=>$amount){
|
||||
$wAmount->javascript="onChange='bud_compute_sum(".$p_number.");'";
|
||||
echo_debug(__FILE__.':'.__LINE__,' p_id '.$p_id.' - amount '.$amount);
|
||||
$tot+=$amount;
|
||||
$r.='<td >'.$wAmount->IOValue('amount_'.$p_id,sprintf("%08.2f",$amount))."</td>";
|
||||
$r.='<td >'.$wAmount->IOValue('amount_'.$p_id,sprintf("% 8.2f",$amount))."</td>";
|
||||
}
|
||||
$r.="</tr>";
|
||||
$r.="</table>";
|
||||
|
|
@ -344,6 +347,14 @@ class Bud_Data {
|
|||
}
|
||||
|
||||
}
|
||||
/*!\brief verify that all the amount are numeric */
|
||||
function verify() {
|
||||
foreach ($this->bud_detail_periode as $obj) {
|
||||
if ( isNumber($obj->bdp_amount) == 0 ) {
|
||||
$obj->bdp_amount=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*!\brief delete in bud_detail
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ class widget {
|
|||
$r.='<input type="text" readonly id="'.$this->name.'" name="'.
|
||||
$this->name.'" value ="'.$this->value.'" size="35">';
|
||||
|
||||
$r.='<input type="hidden" name="'.$this->name.'_hidden" id="'.$this->name.'_hidden" value="'.$this->value.'">';
|
||||
$r.='<input type="hidden" name="'.$this->name.'_hidden" id="'.$this->name.'_hidden" value="'.$this->extra.'">';
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue