43 public $errors = array();
47 public $context = array();
58 public $libelle_facture;
84 public function create($user, $notrigger = 0)
92 if (isset($this->sortorder)) $this->sortorder = trim($this->sortorder);
93 if (isset($this->active)) $this->active = trim($this->active);
94 if (isset($this->libelle)) $this->libelle = trim($this->libelle);
95 if (isset($this->libelle_facture)) $this->libelle_facture = trim($this->libelle_facture);
96 if (isset($this->type_cdr)) $this->type_cdr = trim($this->type_cdr);
97 if (isset($this->nbjour)) $this->nbjour = trim($this->nbjour);
98 if (isset($this->decalage)) $this->decalage = trim($this->decalage);
105 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"c_payment_term(";
108 $sql .=
"sortorder,";
111 $sql .=
"libelle_facture,";
115 $sql .=
") VALUES (";
116 $sql .=
" ".(!isset($this->entity) ?
getEntity(
'c_payment_term') :
"'".$this->db->escape($this->entity).
"'").
",";
117 $sql .=
" ".(!isset($this->
code) ?
'NULL' :
"'".$this->db->escape($this->
code).
"'").
",";
118 $sql .=
" ".(!isset($this->sortorder) ?
'NULL' :
"'".$this->db->escape($this->sortorder).
"'").
",";
119 $sql .=
" ".(!isset($this->active) ?
'NULL' :
"'".$this->db->escape($this->active).
"'").
",";
120 $sql .=
" ".(!isset($this->libelle) ?
'NULL' :
"'".$this->db->escape($this->libelle).
"'").
",";
121 $sql .=
" ".(!isset($this->libelle_facture) ?
'NULL' :
"'".$this->db->escape($this->libelle_facture).
"'").
",";
122 $sql .=
" ".(!isset($this->type_cdr) ?
'NULL' :
"'".$this->db->escape($this->type_cdr).
"'").
",";
123 $sql .=
" ".(!isset($this->nbjour) ?
'NULL' :
"'".$this->db->escape($this->nbjour).
"'").
",";
124 $sql .=
" ".(!isset($this->decalage) ?
'NULL' :
"'".$this->db->escape($this->decalage).
"'").
"";
129 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
131 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
135 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"c_payment_term");
141 foreach ($this->errors as $errmsg)
143 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
144 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
146 $this->
db->rollback();
166 $sql .=
" t.entity,";
169 $sql .=
" t.sortorder,";
170 $sql .=
" t.active,";
171 $sql .=
" t.libelle,";
172 $sql .=
" t.libelle_facture,";
173 $sql .=
" t.type_cdr,";
174 $sql .=
" t.nbjour,";
175 $sql .=
" t.decalage";
178 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
179 $sql .=
" WHERE t.rowid = ".$id;
181 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
187 $obj = $this->
db->fetch_object(
$resql);
189 $this->
id = $obj->rowid;
191 $this->
code = $obj->code;
192 $this->sortorder = $obj->sortorder;
193 $this->active = $obj->active;
194 $this->libelle = $obj->libelle;
195 $this->libelle_facture = $obj->libelle_facture;
196 $this->type_cdr = $obj->type_cdr;
197 $this->nbjour = $obj->nbjour;
198 $this->decalage = $obj->decalage;
204 $this->error =
"Error ".$this->db->lasterror();
223 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_payment_term as t";
224 $sql .=
" WHERE t.code = 'RECEP'";
225 $sql .=
" AND t.entity IN (".getEntity(
'c_payment_term').
")";
227 dol_syslog(get_class($this).
"::getDefaultId", LOG_DEBUG);
233 $obj = $this->
db->fetch_object(
$resql);
234 if ($obj) $ret = $obj->rowid;
239 $this->error =
"Error ".$this->db->lasterror();
252 public function update($user = null, $notrigger = 0)
254 global $conf, $langs;
260 if (isset($this->
code)) $this->
code = trim($this->
code);
261 if (isset($this->sortorder)) $this->sortorder = trim($this->sortorder);
262 if (isset($this->active)) $this->active = trim($this->active);
263 if (isset($this->libelle)) $this->libelle = trim($this->libelle);
264 if (isset($this->libelle_facture)) $this->libelle_facture = trim($this->libelle_facture);
265 if (isset($this->type_cdr)) $this->type_cdr = trim($this->type_cdr);
266 if (isset($this->nbjour)) $this->nbjour = trim($this->nbjour);
267 if (isset($this->decalage)) $this->decalage = trim($this->decalage);
275 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"c_payment_term SET";
276 $sql .=
" code=".(isset($this->
code) ?
"'".$this->db->escape($this->
code).
"'" :
"null").
",";
277 $sql .=
" sortorder=".(isset($this->sortorder) ? $this->sortorder :
"null").
",";
278 $sql .=
" active=".(isset($this->active) ? $this->active :
"null").
",";
279 $sql .=
" libelle=".(isset($this->libelle) ?
"'".$this->db->escape($this->libelle).
"'" :
"null").
",";
280 $sql .=
" libelle_facture=".(isset($this->libelle_facture) ?
"'".$this->db->escape($this->libelle_facture).
"'" :
"null").
",";
281 $sql .=
" type_cdr=".(isset($this->type_cdr) ? $this->type_cdr :
"null").
",";
282 $sql .=
" nbjour=".(isset($this->nbjour) ? $this->nbjour :
"null").
",";
283 $sql .=
" decalage=".(isset($this->decalage) ? $this->decalage :
"null").
"";
284 $sql .=
" WHERE rowid = ".$this->id;
288 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
290 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
295 foreach ($this->errors as $errmsg)
297 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
298 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
300 $this->
db->rollback();
316 public function delete($user, $notrigger = 0)
318 global $conf, $langs;
321 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"c_payment_term";
322 $sql .=
" WHERE rowid = ".$this->id;
326 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
328 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
333 foreach ($this->errors as $errmsg)
335 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
336 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
338 $this->
db->rollback();
364 $object->fetch($fromid);
372 $object->context[
'createfromclone'] =
'createfromclone';
373 $result = $object->create($user);
378 $this->error = $object->error;
382 unset($object->context[
'createfromclone']);
390 $this->
db->rollback();
408 $this->sortorder =
'';
411 $this->libelle_facture =
'';
412 $this->type_cdr =
'';
414 $this->decalage =
'';
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
update($user=null, $notrigger=0)
Update database.
if(!empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'] country if(!empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'] typent code
fetch($id)
Load object in memory from database.
Class to manage Dolibarr users.
create($user, $notrigger=0)
Create in database.
$conf db
API class for accounts.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
initAsSpecimen()
Initialise an instance with random values.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
getDefaultId()
Return id of default payment term.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->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)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Class to manage payment terms records in dictionary.
__construct($db)
Constructor.