26 $pk=$this->primary_key;
45 public function getp($p_string)
47 if (array_key_exists( $p_string,$this->
name))
49 $idx = $this->
name[$p_string];
53 throw new Exception(__FILE__ .
":" . __LINE__ . $p_string .
'Erreur attribut inexistant '.$p_string);
56 public function setp($p_string, $p_value)
58 if (array_key_exists( $p_string,$this->
name))
60 $idx = $this->
name[$p_string];
61 $this->$idx = $p_value;
64 throw new Exception(__FILE__ .
":" . __LINE__ . $p_string .
'Erreur attribut inexistant '.$p_string);
70 $sql =
"insert into " . $this->
table .
" ( ";
75 foreach ($this->
name as
$key=>$value)
77 if (isset($this->
default[$value]) && $this->
default[$value] ==
"auto" && $this->$value ==null )
79 if ( $value==$this->primary_key && $this->$value == -1 )
continue;
81 switch ($this->type[$value])
84 $par .=$sep.
'to_date($' . $idx .
",'" . $this->date_format .
"')" ;
87 $par .= $sep.
"$" . $idx ;
94 $sql.=
") values (" . $par .
") returning " . $this->primary_key;
95 $pk=$this->primary_key;
96 $this->$pk = $this->cn->get_value(
$sql,
$array);
99 public function delete()
101 $pk=$this->primary_key;
102 $sql =
" delete from " . $this->
table .
" where " . $this->primary_key .
"=" . sql_string($this->$pk);
103 $this->cn->exec_sql(
$sql);
109 $pk=$this->primary_key;
115 foreach ($this->
name as
$key=>$value)
117 if (isset($this->
default[$value]) && $this->
default[$value] ==
"auto" )
119 switch ($this->type[$value])
122 $par =$value.
'=to_date($' . $idx .
",'" . $this->date_format .
"')" ;
125 $par = $value.
"= $" . $idx ;
127 $sql.=$sep.
" $set " . $par ;
129 $sep =
",";$set=
"";$idx++;
131 $sql.=
" where " . $this->primary_key .
" =" . $this->$pk;
144 switch ($this->type[$key])
147 $sql .= $sep.
'to_char(' . $key .
",'" . $this->date_format .
"') as ".$key ;
154 $pk=$this->primary_key;
155 $sql.=
" from ".$this->table;
156 $sql.=
" where " . $this->primary_key .
" = " . $this->$pk;
157 $result = $this->cn->get_array(
$sql);
158 if ($this->cn->count() == 0 ) {
163 foreach ($result[0] as $key=>$value) {
170 return var_export($this,
true);
176 if ( trim($this->$key)==
'') $this->$key=null;
182 foreach ($this->
name as
$key=>$value)
184 if ( isset ($p_array[$value]))
186 $this->$value=$p_array[$value];
203 $this->
table =
"impdol.operation";
204 $this->primary_key =
"o_id";
208 "dolibarr"=>
"o_doli",
214 "amount_unit"=>
"amount_unit",
215 "amount_vat"=>
"amount_vat",
216 "number_unit"=>
"number_unit",
218 "amount_total"=>
"amount_total",
219 "jrn_def_id"=>
"jrn_def_id",
220 "o_message"=>
"o_message",
234 "amount_unit"=>
"numeric",
235 "amount_vat"=>
"numeric",
236 "number_unit"=>
"numeric",
237 "vat_rate"=>
"numeric",
238 "amount_total"=>
"numeric",
239 "jrn_def_id"=>
"numeric",
245 $this->
default = array(
248 $this->date_format =
"DD.MM.YYYY";
251 parent::__construct($cn,$p_id);
261 $this->
table =
"impdol.operation_tmp";
262 $this->primary_key =
"o_id";
266 "dolibarr"=>
"o_doli",
272 "amount_unit"=>
"amount_unit",
273 "amount_vat"=>
"amount_vat",
274 "number_unit"=>
"number_unit",
276 "amount_total"=>
"amount_total",
277 "jrn_def_id"=>
"jrn_def_id",
278 "message"=>
"o_message",
295 "amount_unit"=>
"text",
296 "amount_vat"=>
"text",
297 "number_unit"=>
"text",
299 "amount_total"=>
"text",
300 "jrn_def_id"=>
"text",
309 $this->
default = array(
312 $this->date_format =
"DD.MM.YYYY";
315 parent::__construct($cn,$p_id);
324 $this->
table =
"impdol.import";
325 $this->primary_key =
"i_id";
329 "send_file"=>
"send_file",
330 "temp_file"=>
"temp_file",
343 $this->
default = array(
347 $this->date_format =
"DD.MM.YYYY";
350 parent::__construct($cn,$p_id);
359 $this->
table =
"impdol.operation_transfer";
360 $this->primary_key =
"ot_id";
374 $this->
default = array(
377 $this->date_format =
"DD.MM.YYYY";
380 parent::__construct($cn,$p_id);
if(isset($_POST['remove'])) $array
__construct($p_cn, $p_id=-1)
setp($p_string, $p_value)