27 public $element =
'comment';
32 public $table_element =
'comment';
66 public $fk_user_author;
71 public $fk_user_modif;
83 public $comments = array();
109 public function create($user, $notrigger = 0)
116 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.$this->table_element.
" (";
117 $sql .=
"description";
119 $sql .=
", fk_element";
120 $sql .=
", element_type";
121 $sql .=
", fk_user_author";
122 $sql .=
", fk_user_modif";
124 $sql .=
", import_key";
125 $sql .=
") VALUES (";
126 $sql .=
"'".$this->db->escape($this->
description).
"'";
127 $sql .=
", ".($this->datec !=
'' ?
"'".$this->db->idate($this->datec).
"'" :
'null');
128 $sql .=
", '".(isset($this->fk_element) ? $this->fk_element :
"null").
"'";
129 $sql .=
", '".$this->db->escape($this->element_type).
"'";
130 $sql .=
", '".(isset($this->fk_user_author) ? $this->fk_user_author :
"null").
"'";
131 $sql .=
", ".$user->id.
"";
132 $sql .=
", ".(!empty($this->entity) ? $this->entity :
'1');
133 $sql .=
", ".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
141 dol_syslog(get_class($this).
"::create", LOG_DEBUG);
144 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
148 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
152 $result = $this->
call_trigger(
'TASK_COMMENT_CREATE', $user);
162 foreach ($this->errors as $errmsg) {
163 dol_syslog(get_class($this).
"::create ".$errmsg, LOG_ERR);
164 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
166 $this->
db->rollback();
182 public function fetch($id, $ref =
'')
188 $sql .=
" c.description,";
191 $sql .=
" c.fk_element,";
192 $sql .=
" c.element_type,";
193 $sql .=
" c.fk_user_author,";
194 $sql .=
" c.fk_user_modif,";
195 $sql .=
" c.entity,";
196 $sql .=
" c.import_key";
197 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as c";
198 $sql .=
" WHERE c.rowid = ".((int) $id);
200 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
203 $num_rows = $this->
db->num_rows(
$resql);
206 $obj = $this->
db->fetch_object(
$resql);
208 $this->
id = $obj->rowid;
210 $this->element_type = $obj->element_type;
211 $this->datec = $this->
db->jdate($obj->datec);
212 $this->tms = $this->
db->jdate($obj->tms);
213 $this->fk_user_author = $obj->fk_user_author;
214 $this->fk_user_modif = $obj->fk_user_modif;
215 $this->fk_element = $obj->fk_element;
216 $this->entity = $obj->entity;
217 $this->import_key = $obj->import_key;
228 $this->error =
"Error ".$this->db->lasterror();
247 if (isset($this->fk_element)) {
248 $this->fk_project = (int) trim($this->fk_element);
256 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element.
" SET";
257 $sql .=
" description=".(isset($this->
description) ?
"'".$this->db->escape($this->
description).
"'" :
"null").
",";
258 $sql .=
" datec=".($this->datec !=
'' ?
"'".$this->db->idate($this->datec).
"'" :
'null').
",";
259 $sql .=
" fk_element=".(isset($this->fk_element) ? $this->fk_element :
"null").
",";
260 $sql .=
" element_type='".$this->db->escape($this->element_type).
"',";
261 $sql .=
" fk_user_modif=".$user->id.
",";
262 $sql .=
" entity=".(!empty($this->entity) ? $this->entity :
'1').
",";
263 $sql .=
" import_key=".(!empty($this->import_key) ?
"'".$this->db->escape($this->import_key).
"'" :
"null");
264 $sql .=
" WHERE rowid=".$this->id;
268 dol_syslog(get_class($this).
"::update", LOG_DEBUG);
271 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
277 $result = $this->
call_trigger(
'TASK_COMMENT_MODIFY', $user);
287 foreach ($this->errors as $errmsg) {
288 dol_syslog(get_class($this).
"::update ".$errmsg, LOG_ERR);
289 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
291 $this->
db->rollback();
307 public function delete($user, $notrigger = 0)
309 global $conf, $langs;
310 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
316 $sql =
"DELETE FROM ".MAIN_DB_PREFIX.$this->table_element;
317 $sql .=
" WHERE rowid=".$this->id;
321 $error++; $this->errors[] =
"Error ".$this->db->lasterror();
327 $result = $this->
call_trigger(
'TASK_COMMENT_DELETE', $user);
337 foreach ($this->errors as $errmsg) {
338 dol_syslog(get_class($this).
"::delete ".$errmsg, LOG_ERR);
339 $this->error .= ($this->error ?
', '.$errmsg : $errmsg);
341 $this->
db->rollback();
360 $this->comments = array();
361 if (!empty($element_type) && !empty($fk_element)) {
364 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as c";
365 $sql .=
" WHERE c.fk_element = ".$fk_element;
366 $sql .=
" AND c.element_type = '".$this->db->escape($element_type).
"'";
367 $sql .=
" AND c.entity = ".$conf->entity;
368 $sql .=
" ORDER BY c.tms DESC";
370 dol_syslog(get_class($this).
'::'.__METHOD__, LOG_DEBUG);
373 $num_rows = $this->
db->num_rows(
$resql);
375 while ($obj = $this->
db->fetch_object(
$resql)) {
376 $comment =
new self($db);
377 $comment->fetch($obj->rowid);
378 $this->comments[] = $comment;
383 $this->errors[] =
"Error ".$this->db->lasterror();
388 return count($this->comments);
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Class to manage Dolibarr users.
$conf db
API class for accounts.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
call_trigger($triggerName, $user)
Call trigger based on this instance.
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.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)