43 public $errors = array();
79 public function create($user, $notrigger = 0)
86 if (isset($this->
id)) {
87 $this->
id = trim($this->
id);
89 if (isset($this->
code)) {
92 if (isset($this->libelle)) {
93 $this->libelle = trim($this->libelle);
95 if (isset($this->active)) {
96 $this->active = trim($this->active);
98 if (isset($this->module)) {
99 $this->module = trim($this->module);
106 $sql =
"INSERT INTO ".$this->db->prefix().
"c_typent(";
112 $sql .=
") VALUES (";
113 $sql .=
" ".(!isset($this->
id) ?
'NULL' :
"'".$this->db->escape($this->
id).
"'").
",";
114 $sql .=
" ".(!isset($this->
code) ?
'NULL' :
"'".$this->db->escape($this->
code).
"'").
",";
115 $sql .=
" ".(!isset($this->libelle) ?
'NULL' :
"'".$this->db->escape($this->libelle).
"'").
",";
116 $sql .=
" ".(!isset($this->active) ?
'NULL' :
"'".$this->db->escape($this->active).
"'").
",";
117 $sql .=
" ".(!isset($this->module) ?
'NULL' :
"'".$this->db->escape($this->module).
"'");
122 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
126 $this->errors[] =
"Error ".$this->db->lasterror();
130 $this->
id = $this->
db->last_insert_id($this->
db->prefix().
"c_typent");
135 foreach ($this->errors as $errmsg) {
136 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
137 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
139 $this->
db->rollback();
156 public function fetch($id, $code =
'', $label =
'')
161 $sql .=
" t.libelle as label,";
162 $sql .=
" t.fk_country as country_id,";
163 $sql .=
" t.active,";
165 $sql .=
" FROM ".$this->db->prefix().
"c_typent as t";
167 $sql .=
" WHERE t.id = ".((int) $id);
169 $sql .=
" WHERE t.code = '".$this->db->escape($code).
"'";
171 $sql .=
" WHERE t.libelle = '".$this->db->escape($label).
"'";
177 $obj = $this->
db->fetch_object(
$resql);
179 $this->
id = $obj->id;
180 $this->
code = $obj->code;
181 $this->libelle = $obj->label;
182 $this->country_id = $obj->country_id;
183 $this->active = $obj->active;
184 $this->module = $obj->module;
190 $this->error =
"Error ".$this->db->lasterror();
203 public function update($user =
null, $notrigger = 0)
205 global $conf, $langs;
209 if (isset($this->
code)) {
212 if (isset($this->libelle)) {
213 $this->libelle = trim($this->libelle);
215 if (isset($this->active)) {
216 $this->active = trim($this->active);
218 if (isset($this->module)) {
219 $this->module = trim($this->module);
227 $sql =
"UPDATE ".$this->db->prefix().
"c_typent SET";
228 $sql .=
" code=".(isset($this->
code) ?
"'".$this->db->escape($this->
code).
"'" :
"null").
",";
229 $sql .=
" libelle=".(isset($this->libelle) ?
"'".$this->db->escape($this->libelle).
"'" :
"null").
",";
230 $sql .=
" active=".(isset($this->active) ? ((int) $this->active) :
"null").
",";
231 $sql .=
" module=".(isset($this->module) ?
"'".$this->db->escape($this->module).
"'" :
"null");
232 $sql .=
" WHERE id=".$this->id;
236 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
240 $this->errors[] =
"Error ".$this->db->lasterror();
245 foreach ($this->errors as $errmsg) {
246 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
247 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
249 $this->
db->rollback();
265 public function delete($user, $notrigger = 0)
267 global $conf, $langs;
270 $sql =
"DELETE FROM ".$this->db->prefix().
"c_typent";
271 $sql .=
" WHERE id = ".$this->id;
275 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
279 $this->errors[] =
"Error ".$this->db->lasterror();
284 foreach ($this->errors as $errmsg) {
285 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
286 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
288 $this->
db->rollback();
Class of dictionary type of thirdparty (used by imports)
create($user, $notrigger=0)
Create object into database.
__construct($db)
Constructor.
update($user=null, $notrigger=0)
Update object into database.
fetch($id, $code='', $label='')
Load object in memory from database.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.
print *****$script_file(".$version.") pid code
! Closing after partial payment: discount_vat, badcustomer or badsupplier, bankcharge,...