Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once ('class_pre_operation.php');
00026
00027
00028
00029
00030 class Pre_op_fin extends Pre_operation_detail
00031 {
00032 var $op;
00033 function __construct($cn)
00034 {
00035 parent::__construct($cn);
00036 $this->operation->od_direct='f';
00037 }
00038
00039 function get_post()
00040 {
00041 parent::get_post();
00042 $this->operation->od_direct='f';
00043 $this->e_bank_account=$_POST['e_bank_account'];
00044 for ($i=0;$i<$this->operation->nb_item;$i++)
00045 {
00046 $this->{"e_other".$i}=$_POST['e_other'.$i];
00047 $this->{"e_other".$i."_comment"}=$_POST['e_other'.$i.'_comment'];
00048 $this->{"e_other".$i."_amount"}=$_POST['e_other'.$i."_amount"];
00049 }
00050 }
00051
00052
00053
00054
00055 function save()
00056 {
00057 try
00058 {
00059 $this->db->start();
00060 if ($this->operation->save() == false )
00061 return;
00062
00063 $sql=sprintf('insert into op_predef_detail (od_id,opd_poste,opd_debit)'.
00064 ' values '.
00065 "(%d,'%s','%s')",
00066 $this->operation->od_id,
00067 $this->e_bank_account,
00068 "t");
00069 $this->db->exec_sql($sql);
00070
00071 for ($i=0;$i<$this->operation->nb_item;$i++)
00072 {
00073 $sql=sprintf('insert into op_predef_detail (opd_poste,'.
00074 'opd_amount,opd_comment,'.
00075 'opd_debit,od_id)'.
00076 ' values '.
00077 "('%s',%.2f,'%s','%s',%d)",
00078 $this->{"e_other".$i},
00079 $this->{"e_other".$i."_amount"},
00080 $this->{"e_other".$i."_comment"},
00081 'f',
00082 $this->operation->od_id
00083 );
00084 $this->db->exec_sql($sql);
00085 }
00086 }
00087 catch (Exception $e)
00088 {
00089 echo ($e->getMessage());
00090 $this->db->rollback();
00091 }
00092
00093 }
00094
00095
00096 function compute_array()
00097 {
00098 $count=0;
00099 $a_op=$this->operation->load();
00100 $array=$this->operation->compute_array($a_op);
00101 $p_array=$this->load();
00102 foreach ($p_array as $row)
00103 {
00104 if ( $row['opd_debit']=='t')
00105 {
00106 $array+=array('e_bank_account'=>$row['opd_poste']);
00107 }
00108 else
00109 {
00110 $array+=array("e_other".$count=>$row['opd_poste'],
00111 "e_other".$count."_amount"=>$row['opd_amount'],
00112 "e_other".$count."_comment"=>$row['opd_comment']
00113 );
00114 $count++;
00115 }
00116 }
00117 return $array;
00118 }
00119
00120
00121
00122 function load()
00123 {
00124 $sql="select opd_id,opd_poste,opd_amount,opd_comment,opd_debit".
00125 " from op_predef_detail where od_id=".$this->operation->od_id.
00126 " order by opd_id";
00127 $res=$this->db->exec_sql($sql);
00128 $array=Database::fetch_all($res);
00129 return $array;
00130 }
00131 function set_od_id($p_id)
00132 {
00133 $this->operation->od_id=$p_id;
00134 }
00135 }