44 public $errors = array();
48 public $context =array();
59 public $libelle_facture;
92 if (isset($this->code)) $this->code=trim($this->code);
93 if (isset($this->sortorder)) $this->sortorder=trim($this->sortorder);
94 if (isset($this->active)) $this->active=trim($this->active);
95 if (isset($this->libelle)) $this->libelle=trim($this->libelle);
96 if (isset($this->libelle_facture)) $this->libelle_facture=trim($this->libelle_facture);
97 if (isset($this->type_cdr)) $this->type_cdr=trim($this->type_cdr);
98 if (isset($this->nbjour)) $this->nbjour=trim($this->nbjour);
99 if (isset($this->decalage)) $this->decalage=trim($this->decalage);
106 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"c_payment_term(";
112 $sql.=
"libelle_facture,";
117 $sql.=
" ".(! isset($this->entity)?
getEntity(
'c_payment_term'):
"'".$this->db->escape($this->entity).
"'").
",";
118 $sql.=
" ".(! isset($this->code)?
'NULL':
"'".$this->db->escape($this->code).
"'").
",";
119 $sql.=
" ".(! isset($this->sortorder)?
'NULL':
"'".$this->db->escape($this->sortorder).
"'").
",";
120 $sql.=
" ".(! isset($this->active)?
'NULL':
"'".$this->db->escape($this->active).
"'").
",";
121 $sql.=
" ".(! isset($this->libelle)?
'NULL':
"'".$this->db->escape($this->libelle).
"'").
",";
122 $sql.=
" ".(! isset($this->libelle_facture)?
'NULL':
"'".$this->db->escape($this->libelle_facture).
"'").
",";
123 $sql.=
" ".(! isset($this->type_cdr)?
'NULL':
"'".$this->db->escape($this->type_cdr).
"'").
",";
124 $sql.=
" ".(! isset($this->nbjour)?
'NULL':
"'".$this->db->escape($this->nbjour).
"'").
",";
125 $sql.=
" ".(! isset($this->decalage)?
'NULL':
"'".$this->db->escape($this->decalage).
"'").
"";
130 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
131 $resql=$this->db->query($sql);
132 if (!
$resql) { $error++; $this->errors[]=
"Error ".$this->db->lasterror(); }
136 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.
"c_payment_term");
154 foreach($this->errors as $errmsg)
156 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
157 $this->error.=($this->error?
', '.$errmsg:$errmsg);
159 $this->db->rollback();
184 $sql.=
" t.sortorder,";
186 $sql.=
" t.libelle,";
187 $sql.=
" t.libelle_facture,";
188 $sql.=
" t.type_cdr,";
190 $sql.=
" t.decalage";
193 $sql.=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
194 $sql.=
" WHERE t.rowid = ".$id;
196 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
197 $resql=$this->db->query($sql);
200 if ($this->db->num_rows(
$resql))
202 $obj = $this->db->fetch_object(
$resql);
204 $this->
id = $obj->rowid;
206 $this->code = $obj->code;
207 $this->sortorder = $obj->sortorder;
208 $this->active = $obj->active;
209 $this->libelle = $obj->libelle;
210 $this->libelle_facture = $obj->libelle_facture;
211 $this->type_cdr = $obj->type_cdr;
212 $this->nbjour = $obj->nbjour;
213 $this->decalage = $obj->decalage;
221 $this->error=
"Error ".$this->db->lasterror();
240 $sql.=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
241 $sql.=
" WHERE t.code = 'RECEP'";
242 $sql.=
" AND t.entity IN (".getEntity(
'c_payment_term').
")";
244 dol_syslog(get_class($this).
"::getDefaultId", LOG_DEBUG);
245 $resql=$this->db->query($sql);
248 if ($this->db->num_rows(
$resql))
250 $obj = $this->db->fetch_object(
$resql);
251 if ($obj) $ret=$obj->rowid;
258 $this->error=
"Error ".$this->db->lasterror();
271 function update($user=null, $notrigger=0)
273 global $conf, $langs;
279 if (isset($this->code)) $this->code=trim($this->code);
280 if (isset($this->sortorder)) $this->sortorder=trim($this->sortorder);
281 if (isset($this->active)) $this->active=trim($this->active);
282 if (isset($this->libelle)) $this->libelle=trim($this->libelle);
283 if (isset($this->libelle_facture)) $this->libelle_facture=trim($this->libelle_facture);
284 if (isset($this->type_cdr)) $this->type_cdr=trim($this->type_cdr);
285 if (isset($this->nbjour)) $this->nbjour=trim($this->nbjour);
286 if (isset($this->decalage)) $this->decalage=trim($this->decalage);
294 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"c_payment_term SET";
295 $sql.=
" code=".(isset($this->code)?
"'".$this->db->escape($this->code).
"'":
"null").
",";
296 $sql.=
" sortorder=".(isset($this->sortorder)?$this->sortorder:
"null").
",";
297 $sql.=
" active=".(isset($this->active)?$this->active:
"null").
",";
298 $sql.=
" libelle=".(isset($this->libelle)?
"'".$this->db->escape($this->libelle).
"'":
"null").
",";
299 $sql.=
" libelle_facture=".(isset($this->libelle_facture)?
"'".$this->db->escape($this->libelle_facture).
"'":
"null").
",";
300 $sql.=
" type_cdr=".(isset($this->type_cdr)?$this->type_cdr:
"null").
",";
301 $sql.=
" nbjour=".(isset($this->nbjour)?$this->nbjour:
"null").
",";
302 $sql.=
" decalage=".(isset($this->decalage)?$this->decalage:
"null").
"";
303 $sql.=
" WHERE rowid = " . $this->id;
307 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
308 $resql = $this->db->query($sql);
309 if (!
$resql) { $error++; $this->errors[]=
"Error ".$this->db->lasterror(); }
325 foreach($this->errors as $errmsg)
327 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
328 $this->error.=($this->error?
', '.$errmsg:$errmsg);
330 $this->db->rollback();
348 function delete($user, $notrigger=0)
350 global $conf, $langs;
353 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"c_payment_term";
354 $sql.=
" WHERE rowid = " . $this->id;
358 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
359 $resql = $this->db->query($sql);
360 if (!
$resql) { $error++; $this->errors[]=
"Error ".$this->db->lasterror(); }
376 foreach($this->errors as $errmsg)
378 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
379 $this->error.=($this->error?
', '.$errmsg:$errmsg);
381 $this->db->rollback();
410 $object->fetch($fromid);
418 $object->context[
'createfromclone'] =
'createfromclone';
419 $result=$object->create($user);
424 $this->error=$object->error;
432 unset($object->context[
'createfromclone']);
442 $this->db->rollback();
463 $this->libelle_facture=
'';
if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) if(! empty($conf->don->enabled) && $user->rights->societe->lire) if(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) if(! empty($conf->facture->enabled) &&! empty($conf->commande->enabled) && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(! empty($conf->facture->enabled) && $user->rights->facture->lire) if(! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
update($user=null, $notrigger=0)
Update database.
fetch($id)
Load object in memory from database.
create($user, $notrigger=0)
Create in database.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
initAsSpecimen()
Initialise an instance with random values.
getDefaultId()
Return id of default payment term.
Class to manage payment terms records in dictionary.
createFromClone($fromid)
Load an object from its id and create a new one in database.
__construct($db)
Constructor.