45 public $errors = array();
58 public $table_element =
"c_price_expression";
78 public function create($user, $notrigger = 0)
83 if (isset($this->title)) {
84 $this->title = trim($this->title);
86 if (isset($this->expression)) {
87 $this->expression = trim($this->expression);
91 $sql =
"INSERT INTO ".$this->db->prefix().$this->table_element.
" (";
92 $sql .=
"title, expression";
94 $sql .=
" ".(isset($this->title) ?
"'".$this->db->escape($this->title).
"'" :
"''").
",";
95 $sql .=
" ".(isset($this->expression) ?
"'".$this->db->escape($this->expression).
"'" :
"''");
103 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
107 $this->
id = $this->
db->last_insert_id($this->
db->prefix().$this->table_element);
112 foreach ($this->errors as $errmsg) {
114 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
116 $this->
db->rollback();
135 $this->error =
'ErrorWrongParameters';
139 $sql =
"SELECT title, expression";
140 $sql .=
" FROM ".$this->db->prefix().$this->table_element;
141 $sql .=
" WHERE rowid = ".((int) $id);
146 $obj = $this->
db->fetch_object(
$resql);
149 $this->title = $obj->title;
150 $this->expression = $obj->expression;
156 $this->error =
"Error ".$this->db->lasterror();
170 $sql =
"SELECT rowid, title, expression";
171 $sql .=
" FROM ".$this->db->prefix().$this->table_element;
172 $sql .=
" ORDER BY title";
179 while ($record = $this->
db->fetch_array(
$resql)) {
181 $price_expression_obj->id = $record[
"rowid"];
182 $price_expression_obj->title = $record[
"title"];
183 $price_expression_obj->expression = $record[
"expression"];
184 $retarray[] = $price_expression_obj;
190 $this->error = $this->
db->error();
206 $sql =
"SELECT rowid";
207 $sql .=
" FROM ".$this->db->prefix().$this->table_element;
208 $sql .=
" WHERE title = '".$this->db->escape($title).
"'";
213 $obj = $this->
db->fetch_object(
$resql);
215 return (
int) $obj->rowid;
220 $this->error =
"Error ".$this->db->lasterror();
233 public function update($user = 0, $notrigger = 0)
238 if (isset($this->title)) {
239 $this->title = trim($this->title);
241 if (isset($this->expression)) {
242 $this->expression = trim($this->expression);
246 $sql =
"UPDATE ".$this->db->prefix().$this->table_element.
" SET";
247 $sql .=
" title = ".(isset($this->title) ?
"'".$this->db->escape($this->title).
"'" :
"''").
",";
248 $sql .=
" expression = ".(isset($this->expression) ?
"'".$this->db->escape($this->expression).
"'" :
"''");
249 $sql .=
" WHERE rowid = ".((int) $this->
id);
256 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
261 foreach ($this->errors as $errmsg) {
263 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
265 $this->
db->rollback();
281 public function delete(
User $user, $notrigger = 0)
290 $sql =
"DELETE FROM ".$this->db->prefix().$this->table_element;
291 $sql .=
" WHERE rowid = ".((int) $rowid);
296 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
302 foreach ($this->errors as $errmsg) {
304 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
306 $this->
db->rollback();
323 $this->expression =
'';
Class for accesing price expression table.
update($user=0, $notrigger=0)
Update object into database.
find_title($title)
Returns any existing rowid with specified title.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
fetch($id)
Load object in memory from the database.
create($user, $notrigger=0)
Create object into database.
list_price_expression()
List all price expressions.
__construct($db)
Constructor.
Class to manage Dolibarr users.
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.