48 public $errors = array();
68 public $fields = array(
69 'label' => array(
'type'=>
'varchar(250)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>1,
'position'=>15,
'notnull'=>-1,
'showoncombobox'=>
'1')
91 public function create($user, $notrigger = 0)
98 if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso);
99 if (isset($this->label)) $this->label = trim($this->label);
100 if (isset($this->active)) $this->active = trim($this->active);
106 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"c_country(";
112 $sql .=
") VALUES (";
113 $sql .=
" ".(!isset($this->
rowid) ?
'NULL' :
"'".$this->db->escape($this->
rowid).
"'").
",";
114 $sql .=
" ".(!isset($this->
code) ?
'NULL' :
"'".$this->db->escape($this->
code).
"'").
",";
115 $sql .=
" ".(!isset($this->code_iso) ?
'NULL' :
"'".$this->db->escape($this->code_iso).
"'").
",";
116 $sql .=
" ".(!isset($this->label) ?
'NULL' :
"'".$this->db->escape($this->label).
"'").
",";
117 $sql .=
" ".(!isset($this->active) ?
'NULL' :
"'".$this->db->escape($this->active).
"'").
"";
122 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
124 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
128 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
"c_country");
134 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 =
'', $code_iso =
'')
161 $sql .=
" t.code_iso,";
164 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_country as t";
165 if ($id) $sql .=
" WHERE t.rowid = ".((int) $id);
166 elseif ($code) $sql .=
" WHERE t.code = '".$this->db->escape(strtoupper($code)).
"'";
167 elseif ($code_iso) $sql .=
" WHERE t.code_iso = '".$this->db->escape(strtoupper($code_iso)).
"'";
169 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
175 $obj = $this->
db->fetch_object(
$resql);
178 $this->
id = $obj->rowid;
179 $this->
code = $obj->code;
180 $this->code_iso = $obj->code_iso;
181 $this->label = $obj->label;
182 $this->active = $obj->active;
191 $this->error =
"Error ".$this->db->lasterror();
204 public function update($user = null, $notrigger = 0)
206 global $conf, $langs;
210 if (isset($this->
code)) $this->
code = trim($this->
code);
211 if (isset($this->code_iso)) $this->code_iso = trim($this->code_iso);
212 if (isset($this->label)) $this->label = trim($this->label);
213 if (isset($this->active)) $this->active = trim($this->active);
220 $sql =
"UPDATE ".MAIN_DB_PREFIX.
"c_country SET";
221 $sql .=
" code=".(isset($this->
code) ?
"'".$this->db->escape($this->
code).
"'" :
"null").
",";
222 $sql .=
" code_iso=".(isset($this->code_iso) ?
"'".$this->db->escape($this->code_iso).
"'" :
"null").
",";
223 $sql .=
" label=".(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
",";
224 $sql .=
" active=".(isset($this->active) ? $this->active :
"null").
"";
225 $sql .=
" WHERE rowid=".$this->id;
229 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
231 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
236 foreach ($this->errors as $errmsg)
238 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
239 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
241 $this->
db->rollback();
257 public function delete($user, $notrigger = 0)
259 global $conf, $langs;
262 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.
"c_country";
263 $sql .=
" WHERE rowid=".$this->id;
267 dol_syslog(get_class($this).
"::delete", LOG_DEBUG);
269 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
274 foreach ($this->errors as $errmsg)
276 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
277 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
279 $this->
db->rollback();
297 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
300 return $langs->trans($this->label);
getNomUrl($withpicto=0, $option= '', $notooltip=0, $morecss= '', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
$element
Id that identify managed objects.
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
</td >< tdcolspan="3">< spanclass="opacitymedium"></span ></td ></tr >< trclass="liste_total"> CREANCES DETTES< tdcolspan="3"class="right"></td >< tdcolspan="3"class="right"></td ></tr > CREANCES DETTES RECETTES DEPENSES trips CREANCES DETTES Y m expensereport p date_valid Y m expensereport pe datep $db idate($date_start)."' AND $column < p rowid
update($user=null, $notrigger=0)
Update object into database.
$table_element
Name of table without prefix where object is stored.
__construct($db)
Constructor.
$conf db
API class for accounts.
Class to manage dictionary Countries (used by imports)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
fetch($id, $code= '', $code_iso= '')
Load object in memory from database.
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.
create($user, $notrigger=0)
Create object into database.