30 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $element =
'ecmfiles';
45 public $table_element =
'ecm_files';
50 public $picto =
'folder-open';
86 public $fullpath_orig;
111 public $gen_or_uploaded;
146 public $src_object_type;
151 public $src_object_id;
158 public $fields = array(
159 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
160 'ref' => array(
'type'=>
'varchar(128)',
'label'=>
'Ref',
'enabled'=>
'1',
'position'=>20,
'notnull'=>1,
'visible'=>-1,
'index'=>1,
'searchall'=>1,
'showoncombobox'=>
'1',
'validate'=>
'1',
'comment'=>
"contains hash from filename+filepath"),
161 'label' => array(
'type'=>
'varchar(128)',
'label'=>
'Label',
'enabled'=>
'1',
'position'=>30,
'notnull'=>0,
'visible'=>-1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"contains hash of file content"),
162 'share' => array(
'type'=>
'varchar(128)',
'label'=>
'Share',
'enabled'=>
'1',
'position'=>40,
'notnull'=>0,
'visible'=>-1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment' =>
"contains hash for file sharing"),
163 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => -1,
'position' => 50,
'index' => 1),
164 'filepath' => array(
'type'=>
'varchar(255)',
'label'=>
'FilePath',
'enabled'=>
'1',
'position'=>60,
'notnull'=>0,
'visible'=>0,
'searchall'=>0,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"relative to dolibarr document dir. Example module/def"),
165 'filename' => array(
'type'=>
'varchar(255)',
'label'=>
'FileName',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"file name only without any directory"),
166 'src_object_type' => array(
'type'=>
'varchar(64)',
'label'=>
'SourceType',
'enabled'=>
'1',
'position'=>80,
'notnull'=>0,
'visible'=>0,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"Source object type ('proposal', 'invoice', ...)"),
167 'src_object_id' => array(
'type' =>
'integer',
'label' =>
'SourceID',
'default' => 1,
'enabled' => 1,
'visible' => 0,
'notnull' => 1,
'position' => 90,
'index' => 1,
'comment' =>
"Source object id"),
168 'fullpath_orig' => array(
'type'=>
'varchar(750)',
'label'=>
'FullPathOrig',
'enabled'=>
'1',
'position'=>100,
'notnull'=>0,
'visible'=>0,
'searchall'=>0,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"full path of original filename, when file is uploaded from a local computer"),
169 'description' => array(
'type' =>
'text',
'label' =>
'Description',
'enabled' => 1,
'visible' => 0,
'position' => 110),
170 'keywords' => array(
'type'=>
'varchar(750)',
'label'=>
'Keywords',
'enabled'=>
'1',
'position'=>120,
'notnull'=>0,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"list of keywords, separated with comma. Must be limited to most important keywords."),
171 'cover' => array(
'type' =>
'text',
'label' =>
'Cover',
'enabled' => 1,
'visible' => 0,
'position' => 130,
'comment'=>
"is this file a file to use for a cover"),
172 'position' => array(
'type' =>
'integer',
'label' =>
'Position',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 140,
'index' => 1,
'comment' =>
"position of file among others"),
173 'gen_or_uploaded' => array(
'type'=>
'varchar(12)',
'label'=>
'GenOrUpload',
'enabled'=>
'1',
'position'=>150,
'notnull'=>0,
'visible'=>-1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment'=>
"'generated' or 'uploaded'"),
174 'extraparams' => array(
'type'=>
'varchar(255)',
'label'=>
'ExtraParams',
'enabled'=>
'1',
'position'=>160,
'notnull'=>0,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'cssview'=>
'wordbreak',
'help'=>
"Help text",
'showoncombobox'=>
'2',
'validate'=>
'1',
'comment' =>
"for stocking other parameters with json format"),
175 'date_c' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'visible' => -1,
'position' => 170),
176 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'visible' => -1,
'notnull' => 1,
'position' => 175),
177 'fk_user_c' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserAuthor',
'enabled'=>
'1',
'position'=>510,
'notnull'=>1,
'visible'=>-2,
'foreignkey'=>
'user.rowid',),
178 'fk_user_m' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
179 'note_public' => array(
'type' =>
'text',
'label' =>
'NotePublic',
'enabled' => 1,
'visible' => 0,
'position' => 155),
180 'note_private' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160),
181 'acl' => array(
'type' =>
'text',
'label' =>
'NotePrivate',
'enabled' => 1,
'visible' => 0,
'position' => 160,
'comment' =>
"for future permission 'per file'"),
211 if (isset($this->
ref)) {
212 $this->
ref = trim($this->
ref);
214 if (isset($this->label)) {
215 $this->label = trim($this->label);
217 if (isset($this->share)) {
218 $this->share = trim($this->share);
220 if (isset($this->entity)) {
221 $this->entity = (int) $this->entity;
223 if (isset($this->filename)) {
224 $this->filename = preg_replace(
'/\.noexe$/',
'', trim($this->filename));
226 if (isset($this->filepath)) {
227 $this->filepath = trim($this->filepath);
228 $this->filepath = preg_replace(
'/[\\/]+$/',
'', $this->filepath);
230 if (isset($this->fullpath_orig)) {
231 $this->fullpath_orig = trim($this->fullpath_orig);
236 if (isset($this->keywords)) {
237 $this->keywords = trim($this->keywords);
239 if (isset($this->cover)) {
240 $this->cover = trim($this->cover);
242 if (isset($this->gen_or_uploaded)) {
243 $this->gen_or_uploaded = trim($this->gen_or_uploaded);
245 if (isset($this->extraparams)) {
246 $this->extraparams = trim($this->extraparams);
248 if (isset($this->fk_user_c)) {
249 $this->fk_user_c = (int) $this->fk_user_c;
251 if (isset($this->fk_user_m)) {
252 $this->fk_user_m = (int) $this->fk_user_m;
254 if (isset($this->acl)) {
255 $this->acl = trim($this->acl);
257 if (isset($this->src_object_type)) {
258 $this->src_object_type = trim($this->src_object_type);
260 if (empty($this->date_c)) {
263 if (empty($this->date_m)) {
268 if (empty($this->
ref)) {
269 include_once DOL_DOCUMENT_ROOT.
'/core/lib/security.lib.php';
270 $this->
ref =
dol_hash($this->filepath.
'/'.$this->filename, 3);
276 $sql =
"SELECT MAX(position) as maxposition FROM ".MAIN_DB_PREFIX.$this->table_element;
277 $sql .=
" WHERE filepath ='".$this->db->escape($this->filepath).
"'";
279 $resql = $this->db->query(
$sql);
281 $obj = $this->db->fetch_object($resql);
282 $maxposition = (int) $obj->maxposition;
284 $this->errors[] =
'Error '.$this->db->lasterror();
287 $maxposition = $maxposition + 1;
289 $maxposition = $this->position;
293 if (empty($this->filename) || empty($this->filepath)) {
294 $this->errors[] =
'Bad property filename or filepath';
297 if (!isset($this->entity)) {
298 $this->entity = $conf->entity;
303 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.$this->table_element.
'(';
310 $sql .=
'fullpath_orig,';
311 $sql .=
'description,';
315 $sql .=
'gen_or_uploaded,';
316 $sql .=
'extraparams,';
319 $sql .=
'fk_user_c,';
320 $sql .=
'fk_user_m,';
322 $sql .=
'src_object_type,';
323 $sql .=
'src_object_id';
324 $sql .=
') VALUES (';
325 $sql .=
" '".$this->db->escape($this->
ref).
"', ";
326 $sql .=
' '.(!isset($this->label) ?
'NULL' :
"'".$this->db->escape($this->label).
"'").
',';
327 $sql .=
' '.(!isset($this->share) ?
'NULL' :
"'".$this->db->escape($this->share).
"'").
',';
328 $sql .=
' '.((int) $this->entity).
',';
329 $sql .=
' '.(!isset($this->filename) ?
'NULL' :
"'".$this->db->escape($this->filename).
"'").
',';
330 $sql .=
' '.(!isset($this->filepath) ?
'NULL' :
"'".$this->db->escape($this->filepath).
"'").
',';
331 $sql .=
' '.(!isset($this->fullpath_orig) ?
'NULL' :
"'".$this->db->escape($this->fullpath_orig).
"'").
',';
333 $sql .=
' '.(!isset($this->keywords) ?
'NULL' :
"'".$this->db->escape($this->keywords).
"'").
',';
334 $sql .=
' '.(!isset($this->cover) ?
'NULL' :
"'".$this->db->escape($this->cover).
"'").
',';
335 $sql .=
' '.((int) $maxposition).
',';
336 $sql .=
' '.(!isset($this->gen_or_uploaded) ?
'NULL' :
"'".$this->db->escape($this->gen_or_uploaded).
"'").
',';
337 $sql .=
' '.(!isset($this->extraparams) ?
'NULL' :
"'".$this->db->escape($this->extraparams).
"'").
',';
338 $sql .=
" '".$this->db->idate($this->date_c).
"',";
339 $sql .=
' '.(!isset($this->date_m) ||
dol_strlen($this->date_m) == 0 ?
'NULL' :
"'".$this->db->idate($this->date_m).
"'").
',';
340 $sql .=
' '.(!isset($this->fk_user_c) ? $user->id : $this->fk_user_c).
',';
341 $sql .=
' '.(!isset($this->fk_user_m) ?
'NULL' : $this->fk_user_m).
',';
342 $sql .=
' '.(!isset($this->acl) ?
'NULL' :
"'".$this->db->escape($this->acl).
"'").
',';
343 $sql .=
' '.(!isset($this->src_object_type) ?
'NULL' :
"'".$this->db->escape($this->src_object_type).
"'").
',';
344 $sql .=
' '.(!isset($this->src_object_id) ?
'NULL' : $this->src_object_id);
349 $resql = $this->db->query(
$sql);
352 if ($this->db->lasterrno() ==
'DB_ERROR_RECORD_ALREADY_EXISTS') {
353 $this->errors[] =
'Error DB_ERROR_RECORD_ALREADY_EXISTS : '.$this->db->lasterror();
355 $this->errors[] =
'Error '.$this->db->lasterror();
357 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
361 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX.$this->table_element);
367 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_CREATE', $user);
377 $this->db->rollback();
399 public function fetch($id, $ref =
'', $relativepath =
'', $hashoffile =
'', $hashforshare =
'', $src_object_type =
'', $src_object_id = 0)
410 $sql .=
" t.entity,";
411 $sql .=
" t.filename,";
412 $sql .=
" t.filepath,";
413 $sql .=
" t.fullpath_orig,";
414 $sql .=
" t.description,";
415 $sql .=
" t.keywords,";
417 $sql .=
" t.position,";
418 $sql .=
" t.gen_or_uploaded,";
419 $sql .=
" t.extraparams,";
420 $sql .=
" t.date_c,";
421 $sql .=
" t.tms as date_m,";
422 $sql .=
" t.fk_user_c,";
423 $sql .=
" t.fk_user_m,";
424 $sql .=
' t.note_private,';
425 $sql .=
' t.note_public,';
427 $sql .=
" t.src_object_type,";
428 $sql .=
" t.src_object_id";
429 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
430 $sql .=
' WHERE 1 = 1';
437 $relativepathwithnoexe = preg_replace(
'/\.noexe$/',
'', $relativepath);
438 $sql .=
" AND t.filepath = '".$this->db->escape(dirname($relativepath)).
"'";
439 $filename = basename($relativepathwithnoexe);
440 if ($filename !=
'*') {
441 $sql .=
" AND t.filename = '".$this->db->escape($filename).
"'";
443 $sql .=
" AND t.entity = ".$conf->entity;
447 $sql .=
" AND t.ref = '".$this->db->escape($ref).
"'";
448 $sql .=
" AND t.entity = ".$conf->entity;
451 if (!empty($hashoffile)) {
452 $sql .=
" AND t.label = '".$this->db->escape($hashoffile).
"'";
453 $sql .=
" AND t.entity = ".$conf->entity;
456 if (!empty($hashforshare)) {
457 if ($hashforshare !=
'shared') {
458 $sql .=
" AND t.share = '".$this->db->escape($hashforshare).
"'";
460 $sql .=
" AND t.share IS NOT NULL AND t.share <> ''";
465 if ($src_object_type && $src_object_id) {
466 $sql .=
" AND t.src_object_type = '".$this->db->escape($src_object_type).
"' AND t.src_object_id = ".((int) $src_object_id);
467 $sql .=
" AND t.entity = ".((int) $conf->entity);
470 if ($id > 0 || empty($filterfound)) {
471 $sql .=
' AND t.rowid = '.((int) $id);
475 $this->db->plimit(1);
476 $this->db->order(
't.rowid',
'ASC');
478 $resql = $this->db->query(
$sql);
480 $numrows = $this->db->num_rows($resql);
482 $obj = $this->db->fetch_object($resql);
484 $this->
id = $obj->rowid;
485 $this->
ref = $obj->ref;
486 $this->label = $obj->label;
487 $this->share = $obj->share;
488 $this->entity = $obj->entity;
489 $this->filename = $obj->filename;
490 $this->filepath = $obj->filepath;
491 $this->fullpath_orig = $obj->fullpath_orig;
493 $this->keywords = $obj->keywords;
494 $this->cover = $obj->cover;
496 $this->gen_or_uploaded = $obj->gen_or_uploaded;
497 $this->extraparams = $obj->extraparams;
498 $this->date_c = $this->db->jdate($obj->date_c);
499 $this->date_m = $this->db->jdate($obj->date_m);
500 $this->fk_user_c = $obj->fk_user_c;
501 $this->fk_user_m = $obj->fk_user_m;
502 $this->note_private = $obj->note_private;
503 $this->note_public = $obj->note_public;
504 $this->acl = $obj->acl;
505 $this->src_object_type = $obj->src_object_type;
506 $this->src_object_id = $obj->src_object_id;
515 $this->db->free($resql);
523 $this->errors[] =
'Error '.$this->db->lasterror();
524 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
542 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
550 $sql .=
" t.entity,";
551 $sql .=
" t.filename,";
552 $sql .=
" t.filepath,";
553 $sql .=
" t.fullpath_orig,";
554 $sql .=
" t.description,";
555 $sql .=
" t.keywords,";
557 $sql .=
" t.position,";
558 $sql .=
" t.gen_or_uploaded,";
559 $sql .=
" t.extraparams,";
560 $sql .=
" t.date_c,";
561 $sql .=
" t.tms as date_m,";
562 $sql .=
" t.fk_user_c,";
563 $sql .=
" t.fk_user_m,";
565 $sql .=
" t.src_object_type,";
566 $sql .=
" t.src_object_id";
567 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
571 if (count($filter) > 0) {
572 foreach ($filter as $key => $value) {
573 if ($key ==
't.src_object_id') {
574 $sqlwhere[] = $key.
" = ".((int) $value);
576 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
580 $sql .=
' WHERE 1 = 1';
585 if (count($sqlwhere) > 0) {
586 $sql .=
' AND '.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere);
588 if (!empty($sortfield)) {
589 $sql .= $this->db->order($sortfield, $sortorder);
591 if (!empty($limit)) {
592 $sql .= $this->db->plimit($limit, $offset);
595 $this->lines = array();
597 $resql = $this->db->query(
$sql);
599 $num = $this->db->num_rows($resql);
601 while ($obj = $this->db->fetch_object($resql)) {
604 $line->id = $obj->rowid;
605 $line->ref = $obj->rowid;
606 $line->label = $obj->label;
607 $line->share = $obj->share;
608 $line->entity = $obj->entity;
609 $line->filename = $obj->filename;
610 $line->filepath = $obj->filepath;
611 $line->fullpath_orig = $obj->fullpath_orig;
612 $line->description = $obj->description;
613 $line->keywords = $obj->keywords;
614 $line->cover = $obj->cover;
615 $line->position = $obj->position;
616 $line->gen_or_uploaded = $obj->gen_or_uploaded;
617 $line->extraparams = $obj->extraparams;
618 $line->date_c = $this->db->jdate($obj->date_c);
619 $line->date_m = $this->db->jdate($obj->date_m);
620 $line->fk_user_c = $obj->fk_user_c;
621 $line->fk_user_m = $obj->fk_user_m;
622 $line->acl = $obj->acl;
623 $line->src_object_type = $obj->src_object_type;
624 $line->src_object_id = $obj->src_object_id;
625 $this->lines[] = $line;
627 $this->db->free($resql);
631 $this->errors[] =
'Error '.$this->db->lasterror();
632 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
656 if (isset($this->
ref)) {
657 $this->
ref = trim($this->
ref);
659 if (isset($this->label)) {
660 $this->label = trim($this->label);
662 if (isset($this->share)) {
663 $this->share = trim($this->share);
665 if (isset($this->entity)) {
666 $this->entity = trim($this->entity);
668 if (isset($this->filename)) {
669 $this->filename = preg_replace(
'/\.noexe$/',
'', trim($this->filename));
671 if (isset($this->filepath)) {
672 $this->filepath = trim($this->filepath);
673 $this->filepath = preg_replace(
'/[\\/]+$/',
'', $this->filepath);
675 if (isset($this->fullpath_orig)) {
676 $this->fullpath_orig = trim($this->fullpath_orig);
681 if (isset($this->keywords)) {
682 $this->keywords = trim($this->keywords);
684 if (isset($this->cover)) {
685 $this->cover = trim($this->cover);
687 if (isset($this->gen_or_uploaded)) {
688 $this->gen_or_uploaded = trim($this->gen_or_uploaded);
690 if (isset($this->extraparams)) {
691 $this->extraparams = trim($this->extraparams);
693 if (isset($this->fk_user_m)) {
694 $this->fk_user_m = trim($this->fk_user_m);
696 if (isset($this->acl)) {
697 $this->acl = trim($this->acl);
699 if (isset($this->src_object_type)) {
700 $this->src_object_type = trim($this->src_object_type);
707 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET';
708 $sql .=
" ref = '".$this->db->escape(
dol_hash($this->filepath.
"/".$this->filename, 3)).
"',";
709 $sql .=
' label = '.(isset($this->label) ?
"'".$this->db->escape($this->label).
"'" :
"null").
',';
710 $sql .=
' share = '.(!empty($this->share) ?
"'".$this->db->escape($this->share).
"'" :
"null").
',';
711 $sql .=
' entity = '.(isset($this->entity) ? $this->entity : $conf->entity).
',';
712 $sql .=
' filename = '.(isset($this->filename) ?
"'".$this->db->escape($this->filename).
"'" :
"null").
',';
713 $sql .=
' filepath = '.(isset($this->filepath) ?
"'".$this->db->escape($this->filepath).
"'" :
"null").
',';
714 $sql .=
' fullpath_orig = '.(isset($this->fullpath_orig) ?
"'".$this->db->escape($this->fullpath_orig).
"'" :
"null").
',';
716 $sql .=
' keywords = '.(isset($this->keywords) ?
"'".$this->db->escape($this->keywords).
"'" :
"null").
',';
717 $sql .=
' cover = '.(isset($this->cover) ?
"'".$this->db->escape($this->cover).
"'" :
"null").
',';
719 $sql .=
' gen_or_uploaded = '.(isset($this->gen_or_uploaded) ?
"'".$this->db->escape($this->gen_or_uploaded).
"'" :
"null").
',';
720 $sql .=
' extraparams = '.(isset($this->extraparams) ?
"'".$this->db->escape($this->extraparams).
"'" :
"null").
',';
721 $sql .=
' date_c = '.(!isset($this->date_c) ||
dol_strlen($this->date_c) != 0 ?
"'".$this->db->idate($this->date_c).
"'" :
'null').
',';
723 $sql .=
' fk_user_m = '.($this->fk_user_m > 0 ? $this->fk_user_m : $user->id).
',';
724 $sql .=
' acl = '.(isset($this->acl) ?
"'".$this->db->escape($this->acl).
"'" :
"null").
',';
725 $sql .=
' src_object_id = '.($this->src_object_id > 0 ? $this->src_object_id :
"null").
',';
726 $sql .=
' src_object_type = '.(isset($this->src_object_type) ?
"'".$this->db->escape($this->src_object_type).
"'" :
"null");
727 $sql .=
' WHERE rowid='.((int) $this->
id);
731 $resql = $this->db->query(
$sql);
734 $this->errors[] =
'Error '.$this->db->lasterror();
735 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
739 if (!$error && !$notrigger) {
741 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_MODIFY', $user);
750 $this->db->rollback();
768 public function delete(
User $user, $notrigger =
false)
779 $result = $this->
call_trigger(strtoupper(get_class($this)).
'_DELETE', $user);
790 dol_syslog(get_class($this).
"::delete error ".$this->error, LOG_ERR);
795 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.$this->table_element;
796 $sql .=
' WHERE rowid='.((int) $this->
id);
798 $resql = $this->db->query(
$sql);
801 $this->errors[] =
'Error '.$this->db->lasterror();
802 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
808 $this->db->rollback();
835 $object->fetch($fromid);
843 $object->context[
'createfromclone'] =
'createfromclone';
844 $result = $object->create($user);
849 $this->errors = $object->errors;
850 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
853 unset($object->context[
'createfromclone']);
861 $this->db->rollback();
877 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $maxlen = 24, $morecss =
'')
879 global $db, $conf, $langs;
880 global $dolibarr_main_authentication, $dolibarr_main_demo;
881 global $menumanager, $hookmanager;
883 if (!empty($conf->dol_no_mouse_hover)) {
889 $label =
'<u>'.$langs->trans(
"MyModule").
'</u>';
891 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
893 $url = DOL_URL_ROOT.
'/ecm/'.$this->table_name.
'_card.php?id='.$this->id;
896 if (empty($notooltip)) {
897 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
898 $label = $langs->trans(
"ShowProject");
899 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
901 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
902 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
904 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
907 $linkstart =
'<a href="'.$url.
'"';
908 $linkstart .= $linkclose.
'>';
912 $result .= ($linkstart.img_object(($notooltip ?
'' : $label),
'label', ($notooltip ?
'' :
'class="classfortooltip"')).$linkend);
913 if ($withpicto != 2) {
917 $result .= $linkstart.$this->ref.$linkend;
920 $hookmanager->initHooks(array($this->element .
'dao'));
921 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
922 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
924 $result = $hookmanager->resPrint;
926 $result .= $hookmanager->resPrint;
939 return $this->
LibStatut($this->status, $mode);
970 $this->label =
'0a1b2c3e4f59999999';
972 $this->filename =
'myspecimenfilefile.pdf';
973 $this->filepath =
'/aaa/bbb';
974 $this->fullpath_orig =
'c:/file on my disk.pdf';
975 $this->
description =
'This is a long description of file';
976 $this->keywords =
'key1,key2';
979 $this->gen_or_uploaded =
'uploaded';
980 $this->extraparams =
'';
981 $this->date_c = (
dol_now() - 3600 * 24 * 10);
983 $this->fk_user_c = $user->id;
984 $this->fk_user_m =
'';
986 $this->src_object_type =
'product';
987 $this->src_object_id = 1;
1009 public $fullpath_orig;
1014 public $description;
1019 public $gen_or_uploaded;
1020 public $extraparams;
1021 public $date_c =
'';
1022 public $date_m =
'';
1035 public $src_object_type;
1036 public $src_object_id;
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteExtraFields()
Delete all extra fields values for the current object.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class to manage ECM files.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
getLibStatut($mode=0)
Return the label of the status.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
update(User $user, $notrigger=false)
Update object into database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
Return a link to the object card (with optionaly the picto)
fetch($id, $ref='', $relativepath='', $hashoffile='', $hashforshare='', $src_object_type='', $src_object_id=0)
Load object in memory from the database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load object in memory from the database.
__construct(DoliDB $db)
Constructor.
create(User $user, $notrigger=false)
Create object into database.
static LibStatut($status, $mode=0)
Return the status.
Class of an index line of a document.
Class to manage Dolibarr users.
if(isModEnabled('facture') && $user->hasRight('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') && $user->hasRight('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)) $sql
Social contributions to pay.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_hash($chain, $type='0')
Returns a hash (non reversible encryption) of a string.