Add the quick / direct writing ability

This commit is contained in:
sparkyx 2007-10-15 13:25:35 +00:00
parent 15ce1362e9
commit 26afef570a
28 changed files with 656 additions and 122 deletions

View file

@ -29,17 +29,23 @@ require_once ('class_pre_operation.php');
/*---------------------------------------------------------------------- */
class Pre_Op_Advanced extends Pre_operation_detail {
var $op;
function Pre_Op_Advanced($cn) {
parent::__construct($cn);
$this->operation->od_direct='t';
}
function get_post() {
echo_debug(__FILE__.':'.__LINE__.'- ','get_post');
parent::get_post();
// For advanced we use +5000
$this->operation->p_jrn+=5000;
extract($_POST);
for ($i=0;$i<$this->operation->nb_item;$i++) {
if ( ! isset ($_POST['poste'.$i]) && ! isset ($_POST['qc_'.$i]))
continue;
$this->{'poste'.$i}=(isset($_POST['qc_'.$i]))?$_POST['qc_'.$i]:$_POST['poste'.$i];
$this->{'isqc'.$i}=(isset($_POST['qc_'.$i]))?'t':'f';
$this->{"amount".$i}=$_POST['amount'.$i];
$this->{"ck".$i}=($_POST['ck'.$i]=='c')?'t':'f';
$this->{"ck".$i}=(isset($_POST['ck'.$i]))?'t':'f';
}
}
@ -54,16 +60,22 @@ class Pre_Op_Advanced extends Pre_operation_detail {
return;
// save the selling
for ($i=0;$i<$this->operation->nb_item;$i++) {
$sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'.
'opd_debit,od_id)'.
' values '.
"('%s',%.2f,%d,%f,'%s',%d)",
$this->{"poste".$i},
$this->{"amount".$i},
$this->{"ck".$i},
$this->operation->od_id
);
ExecSql($this->db,$sql);
if ( ! isset ($this->{"poste".$i}))
continue;
$sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'.
'opd_debit,od_id,opd_qc)'.
' values '.
"('%s',%.2f,'%s',%d,'%s')",
$this->{"poste".$i},
$this->{"amount".$i},
$this->{"ck".$i},
$this->operation->od_id,
$this->{'isqc'.$i}
);
ExecSql($this->db,$sql);
}
} catch (Exception $e) {
echo ($e->getMessage());
@ -77,27 +89,37 @@ class Pre_Op_Advanced extends Pre_operation_detail {
$count=0;
$a_op=$this->operation->load();
$array=$this->operation->compute_array($a_op);
$array['desc']=$array['e_comm'];
$p_array=$this->load();
foreach ($p_array as $row) {
if ( $row['opd_debit']=='t') {
$array+=array('e_client'=>$row['opd_poste']);
} else {
$array+=array("e_march".$count=>$row['opd_poste'],
"e_march".$count."_sell"=>$row['opd_amount'],
"e_march".$count."_tva_id"=>$row['opd_tva_id'],
"e_quant".$count=>$row['opd_quantity']
);
$count++;
}
$tmp_array=array("qc_".$count=>'',
"poste".$count=>'',
"amount".$count=>$row['opd_amount'],
'ck'.$count=>$row['opd_debit']
);
if ( $row['opd_qc'] == 't' )
$tmp_array['qc_'.$count]=$row['opd_poste'];
else
$tmp_array['poste'.$count]=$row['opd_poste'];
if ( $row['opd_debit'] == 'f' )
unset ($tmp_array['ck'.$count]);
$array+=$tmp_array;
$count++;
}
return $array;
}
/*!\brief load the data from the database and return an array
* \return an array
*/
function load() {
$sql="select opd_id,opd_poste,opd_amount,opd_tva_id,opd_debit,".
" opd_quantity from op_predef_detail where od_id=".$this->operation->od_id.
$sql="select opd_id,opd_poste,opd_amount,opd_debit,".
" opd_qc from op_predef_detail where od_id=".$this->operation->od_id.
" order by opd_id";
$res=ExecSql($this->db,$sql);
$array=pg_fetch_all($res);