45 public $errors = array();
58 public $table_element =
"c_price_expression";
78 public function create($user, $notrigger = 0)
83 if (isset($this->title)) $this->title = trim($this->title);
84 if (isset($this->expression)) $this->expression = trim($this->expression);
87 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.$this->table_element.
" (";
88 $sql .=
"title, expression";
90 $sql .=
" ".(isset($this->title) ?
"'".$this->db->escape($this->title).
"'" :
"''").
",";
91 $sql .=
" ".(isset($this->expression) ?
"'".$this->db->escape($this->expression).
"'" :
"''");
98 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
102 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
119 foreach ($this->errors as $errmsg)
122 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
124 $this->
db->rollback();
144 $this->error =
'ErrorWrongParameters';
148 $sql =
"SELECT title, expression";
149 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element;
150 $sql .=
" WHERE rowid = ".$id;
156 $obj = $this->
db->fetch_object(
$resql);
160 $this->title = $obj->title;
161 $this->expression = $obj->expression;
167 $this->error =
"Error ".$this->db->lasterror();
181 $sql =
"SELECT rowid, title, expression";
182 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element;
183 $sql .=
" ORDER BY title";
191 while ($record = $this->
db->fetch_array(
$resql))
194 $price_expression_obj->id = $record[
"rowid"];
195 $price_expression_obj->title = $record[
"title"];
196 $price_expression_obj->expression = $record[
"expression"];
197 $retarray[] = $price_expression_obj;
203 $this->error = $this->
db->error();
219 $sql =
"SELECT rowid";
220 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element;
221 $sql .=
" WHERE title = '".$this->db->escape($title).
"'";
227 $obj = $this->
db->fetch_object(
$resql);
230 return (
int) $obj->rowid;
235 $this->error =
"Error ".$this->db->lasterror();
248 public function update($user = 0, $notrigger = 0)
253 if (isset($this->title)) $this->title = trim($this->title);
254 if (isset($this->expression)) $this->expression = trim($this->expression);
257 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element.
" SET";
258 $sql .=
" title = ".(isset($this->title) ?
"'".$this->db->escape($this->title).
"'" :
"''").
",";
259 $sql .=
" expression = ".(isset($this->expression) ?
"'".$this->db->escape($this->expression).
"'" :
"''").
"";
260 $sql .=
" WHERE rowid = ".$this->id;
266 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
285 foreach ($this->errors as $errmsg)
288 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
290 $this->
db->rollback();
306 public function delete(
User $user, $notrigger = 0)
330 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
331 $sql .=
" WHERE rowid = ".$rowid;
335 if (!
$resql) { $error++; $this->errors[] =
"Error ".$this->db->lasterror(); }
341 foreach ($this->errors as $errmsg)
344 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
346 $this->
db->rollback();
363 $this->expression =
'';
list_price_expression()
List all price expressions.
Class to manage Dolibarr users.
fetch($id)
Load object in memory from the database.
$conf db
API class for accounts.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Class for accesing price expression table.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
find_title($title)
Returns any existing rowid with specified title.
update($user=0, $notrigger=0)
Update object into database.
create($user, $notrigger=0)
Create object into database.
__construct($db)
Constructor.
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.