dolibarr  7.0.0-beta
ecmfiles.class.php
1 <?php
2 /* Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2014-2016 Juanjo Menent <jmenent@2byte.es>
4  * Copyright (C) 2015 Florian Henry <florian.henry@open-concept.pro>
5  * Copyright (C) 2015 RaphaĆ«l Doursenaud <rdoursenaud@gpcsolutions.fr>
6  * Copyright (C) ---Put here your own copyright and developer email---
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
28 // Put here all includes required by your class file
29 require_once DOL_DOCUMENT_ROOT . '/core/class/commonobject.class.php';
30 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
31 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
32 
36 class EcmFiles //extends CommonObject
37 {
41  public $element = 'ecmfiles';
45  public $table_element = 'ecm_files';
46  public $picto = 'generic';
47 
50  public $ref; // hash of file path
51  public $label; // hash of file content (md5_file(dol_osencode($destfull))
52  public $share; // hash for file sharing, empty by default (example: getRandomPassword(true))
53  public $entity;
54  public $filename;
55  public $filepath;
56  public $fullpath_orig;
57  public $description;
58  public $keywords;
59  public $cover;
60  public $position;
61  public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown'
62  public $extraparams;
63  public $date_c = '';
64  public $date_m = '';
65  public $fk_user_c;
66  public $fk_user_m;
67  public $acl;
68 
78  public function __construct(DoliDB $db)
79  {
80  $this->db = $db;
81  }
82 
90  public function create(User $user, $notrigger = false)
91  {
92  global $conf;
93 
94  dol_syslog(__METHOD__, LOG_DEBUG);
95 
96  $error = 0;
97 
98  // Clean parameters
99  if (isset($this->ref)) {
100  $this->ref = trim($this->ref);
101  }
102  if (isset($this->label)) {
103  $this->label = trim($this->label);
104  }
105  if (isset($this->share)) {
106  $this->share = trim($this->share);
107  }
108  if (isset($this->entity)) {
109  $this->entity = trim($this->entity);
110  }
111  if (isset($this->filename)) {
112  $this->filename = trim($this->filename);
113  }
114  if (isset($this->filepath)) {
115  $this->filepath = trim($this->filepath);
116  $this->filepath = preg_replace('/[\\/]+$/', '', $this->filepath); // Remove last /
117  }
118  if (isset($this->fullpath_orig)) {
119  $this->fullpath_orig = trim($this->fullpath_orig);
120  }
121  if (isset($this->description)) {
122  $this->description = trim($this->description);
123  }
124  if (isset($this->keywords)) {
125  $this->keywords = trim($this->keywords);
126  }
127  if (isset($this->cover)) {
128  $this->cover = trim($this->cover);
129  }
130  if (isset($this->gen_or_uploaded)) {
131  $this->gen_or_uploaded = trim($this->gen_or_uploaded);
132  }
133  if (isset($this->extraparams)) {
134  $this->extraparams = trim($this->extraparams);
135  }
136  if (isset($this->fk_user_c)) {
137  $this->fk_user_c = trim($this->fk_user_c);
138  }
139  if (isset($this->fk_user_m)) {
140  $this->fk_user_m = trim($this->fk_user_m);
141  }
142  if (isset($this->acl)) {
143  $this->acl = trim($this->acl);
144  }
145  if (empty($this->date_c)) $this->date_c = dol_now();
146  if (empty($this->date_m)) $this->date_m = dol_now();
147 
148  // If ref not defined
149  $ref = dol_hash($this->filepath.'/'.$this->filename, 3);
150  if (! empty($this->ref)) $ref=$this->ref;
151 
152  $maxposition=0;
153  if (empty($this->position)) // Get max used
154  {
155  $sql = "SELECT MAX(position) as maxposition FROM " . MAIN_DB_PREFIX . $this->table_element;
156  $sql.= " WHERE filepath ='".$this->db->escape($this->filepath)."'";
157 
158  $resql = $this->db->query($sql);
159  if ($resql)
160  {
161  $obj = $this->db->fetch_object($resql);
162  $maxposition = (int) $obj->maxposition;
163  }
164  else dol_print_error($this->db);
165  }
166  $maxposition=$maxposition+1;
167 
168  // Check parameters
169  if (empty($this->filename) || empty($this->filepath))
170  {
171  $this->errors[] = 'Bad property filename or filepath';
172  return -1;
173  }
174  // Put here code to add control on parameters values
175 
176  // Insert request
177  $sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
178  $sql.= 'ref,';
179  $sql.= 'label,';
180  $sql.= 'share,';
181  $sql.= 'entity,';
182  $sql.= 'filename,';
183  $sql.= 'filepath,';
184  $sql.= 'fullpath_orig,';
185  $sql.= 'description,';
186  $sql.= 'keywords,';
187  $sql.= 'cover,';
188  $sql.= 'position,';
189  $sql.= 'gen_or_uploaded,';
190  $sql.= 'extraparams,';
191  $sql.= 'date_c,';
192  $sql.= 'date_m,';
193  $sql.= 'fk_user_c,';
194  $sql.= 'fk_user_m,';
195  $sql.= 'acl';
196  $sql .= ') VALUES (';
197  $sql .= " '".$ref."', ";
198  $sql .= ' '.(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").',';
199  $sql .= ' '.(! isset($this->share)?'NULL':"'".$this->db->escape($this->share)."'").',';
200  $sql .= ' '.(! isset($this->entity)?$conf->entity:$this->entity).',';
201  $sql .= ' '.(! isset($this->filename)?'NULL':"'".$this->db->escape($this->filename)."'").',';
202  $sql .= ' '.(! isset($this->filepath)?'NULL':"'".$this->db->escape($this->filepath)."'").',';
203  $sql .= ' '.(! isset($this->fullpath_orig)?'NULL':"'".$this->db->escape($this->fullpath_orig)."'").',';
204  $sql .= ' '.(! isset($this->description)?'NULL':"'".$this->db->escape($this->description)."'").',';
205  $sql .= ' '.(! isset($this->keywords)?'NULL':"'".$this->db->escape($this->keywords)."'").',';
206  $sql .= ' '.(! isset($this->cover)?'NULL':"'".$this->db->escape($this->cover)."'").',';
207  $sql .= ' '.$maxposition.',';
208  $sql .= ' '.(! isset($this->gen_or_uploaded)?'NULL':"'".$this->db->escape($this->gen_or_uploaded)."'").',';
209  $sql .= ' '.(! isset($this->extraparams)?'NULL':"'".$this->db->escape($this->extraparams)."'").',';
210  $sql .= ' '."'".$this->db->idate($this->date_c)."'".',';
211  $sql .= ' '.(! isset($this->date_m) || dol_strlen($this->date_m)==0?'NULL':"'".$this->db->idate($this->date_m)."'").',';
212  $sql .= ' '.(! isset($this->fk_user_c)?$user->id:$this->fk_user_c).',';
213  $sql .= ' '.(! isset($this->fk_user_m)?'NULL':$this->fk_user_m).',';
214  $sql .= ' '.(! isset($this->acl)?'NULL':"'".$this->db->escape($this->acl)."'");
215  $sql .= ')';
216 
217  $this->db->begin();
218 
219  $resql = $this->db->query($sql);
220  if (!$resql) {
221  $error ++;
222  $this->errors[] = 'Error ' . $this->db->lasterror();
223  dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
224  }
225 
226  if (!$error) {
227  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
228  $this->position = $maxposition;
229 
230  if (!$notrigger) {
231  // Uncomment this and change MYOBJECT to your own tag if you
232  // want this action to call a trigger.
233 
235  //$result=$this->call_trigger('MYOBJECT_CREATE',$user);
236  //if ($result < 0) $error++;
238  }
239  }
240 
241  // Commit or rollback
242  if ($error) {
243  $this->db->rollback();
244 
245  return - 1 * $error;
246  } else {
247  $this->db->commit();
248 
249  return $this->id;
250  }
251  }
252 
263  public function fetch($id, $ref = '', $relativepath = '', $hashoffile='', $hashforshare='')
264  {
265  dol_syslog(__METHOD__, LOG_DEBUG);
266 
267  $sql = 'SELECT';
268  $sql .= ' t.rowid,';
269  $sql .= " t.ref,";
270  $sql .= " t.label,";
271  $sql .= " t.share,";
272  $sql .= " t.entity,";
273  $sql .= " t.filename,";
274  $sql .= " t.filepath,";
275  $sql .= " t.fullpath_orig,";
276  $sql .= " t.description,";
277  $sql .= " t.keywords,";
278  $sql .= " t.cover,";
279  $sql .= " t.position,";
280  $sql .= " t.gen_or_uploaded,";
281  $sql .= " t.extraparams,";
282  $sql .= " t.date_c,";
283  $sql .= " t.date_m,";
284  $sql .= " t.fk_user_c,";
285  $sql .= " t.fk_user_m,";
286  $sql .= " t.acl";
287  $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element . ' as t';
288  $sql.= ' WHERE 1 = 1';
289  /* Fetching this table depends on filepath+filename, it must not depends on entity
290  if (! empty($conf->multicompany->enabled)) {
291  $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
292  }*/
293  if ($relativepath) {
294  $sql .= " AND t.filepath = '" . $this->db->escape(dirname($relativepath)) . "' AND t.filename = '".$this->db->escape(basename($relativepath))."'";
295  }
296  elseif (! empty($ref)) {
297  $sql .= " AND t.ref = '".$this->db->escape($ref)."'";
298  }
299  elseif (! empty($hashoffile)) {
300  $sql .= " AND t.label = '".$this->db->escape($hashoffile)."'";
301  }
302  elseif (! empty($hashforshare)) {
303  $sql .= " AND t.share = '".$this->db->escape($hashforshare)."'";
304  } else {
305  $sql .= ' AND t.rowid = ' . $id;
306  }
307  // When we search on hash of content, we take the first one. Solve also hash conflict.
308  $this->db->plimit(1);
309  $this->db->order('t.rowid', 'ASC');
310 
311  $resql = $this->db->query($sql);
312  if ($resql) {
313  $numrows = $this->db->num_rows($resql);
314  if ($numrows) {
315  $obj = $this->db->fetch_object($resql);
316 
317  $this->id = $obj->rowid;
318  $this->ref = $obj->ref;
319  $this->label = $obj->label;
320  $this->share = $obj->share;
321  $this->entity = $obj->entity;
322  $this->filename = $obj->filename;
323  $this->filepath = $obj->filepath;
324  $this->fullpath_orig = $obj->fullpath_orig;
325  $this->description = $obj->description;
326  $this->keywords = $obj->keywords;
327  $this->cover = $obj->cover;
328  $this->position = $obj->position;
329  $this->gen_or_uploaded = $obj->gen_or_uploaded;
330  $this->extraparams = $obj->extraparams;
331  $this->date_c = $this->db->jdate($obj->date_c);
332  $this->date_m = $this->db->jdate($obj->date_m);
333  $this->fk_user_c = $obj->fk_user_c;
334  $this->fk_user_m = $obj->fk_user_m;
335  $this->acl = $obj->acl;
336  }
337 
338  // Retrieve all extrafields for invoice
339  // fetch optionals attributes and labels
340  /*
341  require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
342  $extrafields=new ExtraFields($this->db);
343  $extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
344  $this->fetch_optionals($this->id,$extralabels);
345  */
346  // $this->fetch_lines();
347 
348  $this->db->free($resql);
349 
350  if ($numrows) {
351  return 1;
352  } else {
353  return 0;
354  }
355  } else {
356  $this->errors[] = 'Error ' . $this->db->lasterror();
357  dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
358 
359  return -1;
360  }
361  }
362 
375  public function fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter = array(), $filtermode='AND')
376  {
377  dol_syslog(__METHOD__, LOG_DEBUG);
378 
379  $sql = 'SELECT';
380  $sql .= ' t.rowid,';
381  $sql .= " t.label,";
382  $sql .= " t.share,";
383  $sql .= " t.entity,";
384  $sql .= " t.filename,";
385  $sql .= " t.filepath,";
386  $sql .= " t.fullpath_orig,";
387  $sql .= " t.description,";
388  $sql .= " t.keywords,";
389  $sql .= " t.cover,";
390  $sql .= " t.position,";
391  $sql .= " t.gen_or_uploaded,";
392  $sql .= " t.extraparams,";
393  $sql .= " t.date_c,";
394  $sql .= " t.date_m,";
395  $sql .= " t.fk_user_c,";
396  $sql .= " t.fk_user_m,";
397  $sql .= " t.acl";
398  $sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
399 
400  // Manage filter
401  $sqlwhere = array();
402  if (count($filter) > 0) {
403  foreach ($filter as $key => $value) {
404  $sqlwhere [] = $key . ' LIKE \'%' . $this->db->escape($value) . '%\'';
405  }
406  }
407  $sql.= ' WHERE 1 = 1';
408  /* Fetching this table depends on filepath+filename, it must not depends on entity
409  if (! empty($conf->multicompany->enabled)) {
410  $sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
411  }*/
412  if (count($sqlwhere) > 0) {
413  $sql .= ' AND ' . implode(' '.$filtermode.' ', $sqlwhere);
414  }
415  if (!empty($sortfield)) {
416  $sql .= $this->db->order($sortfield,$sortorder);
417  }
418  if (!empty($limit)) {
419  $sql .= ' ' . $this->db->plimit($limit, $offset);
420  }
421 
422  $this->lines = array();
423 
424  $resql = $this->db->query($sql);
425  if ($resql) {
426  $num = $this->db->num_rows($resql);
427 
428  while ($obj = $this->db->fetch_object($resql)) {
429  $line = new EcmfilesLine();
430 
431  $line->id = $obj->rowid;
432  $line->ref = $obj->ref;
433  $line->label = $obj->label;
434  $line->share = $obj->share;
435  $line->entity = $obj->entity;
436  $line->filename = $obj->filename;
437  $line->filepath = $obj->filepath;
438  $line->fullpath_orig = $obj->fullpath_orig;
439  $line->description = $obj->description;
440  $line->keywords = $obj->keywords;
441  $line->cover = $obj->cover;
442  $line->position = $obj->position;
443  $line->gen_or_uploaded = $obj->gen_or_uploaded;
444  $line->extraparams = $obj->extraparams;
445  $line->date_c = $this->db->jdate($obj->date_c);
446  $line->date_m = $this->db->jdate($obj->date_m);
447  $line->fk_user_c = $obj->fk_user_c;
448  $line->fk_user_m = $obj->fk_user_m;
449  $line->acl = $obj->acl;
450  }
451  $this->db->free($resql);
452 
453  return $num;
454  } else {
455  $this->errors[] = 'Error ' . $this->db->lasterror();
456  dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
457 
458  return - 1;
459  }
460  }
461 
470  public function update(User $user, $notrigger = false)
471  {
472  $error = 0;
473 
474  dol_syslog(__METHOD__, LOG_DEBUG);
475 
476  // Clean parameters
477 
478  if (isset($this->ref)) {
479  $this->ref = trim($this->ref);
480  }
481  if (isset($this->label)) {
482  $this->label = trim($this->label);
483  }
484  if (isset($this->share)) {
485  $this->share = trim($this->share);
486  }
487  if (isset($this->entity)) {
488  $this->entity = trim($this->entity);
489  }
490  if (isset($this->filename)) {
491  $this->filename = trim($this->filename);
492  }
493  if (isset($this->filepath)) {
494  $this->filepath = trim($this->filepath);
495  }
496  if (isset($this->fullpath_orig)) {
497  $this->fullpath_orig = trim($this->fullpath_orig);
498  }
499  if (isset($this->description)) {
500  $this->description = trim($this->description);
501  }
502  if (isset($this->keywords)) {
503  $this->keywords = trim($this->keywords);
504  }
505  if (isset($this->cover)) {
506  $this->cover = trim($this->cover);
507  }
508  if (isset($this->gen_or_uploaded)) {
509  $this->gen_or_uploaded = trim($this->gen_or_uploaded);
510  }
511  if (isset($this->extraparams)) {
512  $this->extraparams = trim($this->extraparams);
513  }
514  if (isset($this->fk_user_c)) {
515  $this->fk_user_c = trim($this->fk_user_c);
516  }
517  if (isset($this->fk_user_m)) {
518  $this->fk_user_m = trim($this->fk_user_m);
519  }
520  if (isset($this->acl)) {
521  $this->acl = trim($this->acl);
522  }
523 
524 
525  // Check parameters
526  // Put here code to add a control on parameters values
527 
528  // Update request
529  $sql = 'UPDATE ' . MAIN_DB_PREFIX . $this->table_element . ' SET';
530  $sql .= " ref = '".dol_hash($this->filepath.'/'.$this->filename, 3)."',";
531  $sql .= ' label = '.(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").',';
532  $sql .= ' share = '.(! empty($this->share)?"'".$this->db->escape($this->share)."'":"null").',';
533  $sql .= ' entity = '.(isset($this->entity)?$this->entity:$conf->entity).',';
534  $sql .= ' filename = '.(isset($this->filename)?"'".$this->db->escape($this->filename)."'":"null").',';
535  $sql .= ' filepath = '.(isset($this->filepath)?"'".$this->db->escape($this->filepath)."'":"null").',';
536  $sql .= ' fullpath_orig = '.(isset($this->fullpath_orig)?"'".$this->db->escape($this->fullpath_orig)."'":"null").',';
537  $sql .= ' description = '.(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").',';
538  $sql .= ' keywords = '.(isset($this->keywords)?"'".$this->db->escape($this->keywords)."'":"null").',';
539  $sql .= ' cover = '.(isset($this->cover)?"'".$this->db->escape($this->cover)."'":"null").',';
540  $sql .= ' position = '.(isset($this->position)?$this->db->escape($this->position):"0").',';
541  $sql .= ' gen_or_uploaded = '.(isset($this->gen_or_uploaded)?"'".$this->db->escape($this->gen_or_uploaded)."'":"null").',';
542  $sql .= ' extraparams = '.(isset($this->extraparams)?"'".$this->db->escape($this->extraparams)."'":"null").',';
543  $sql .= ' date_c = '.(! isset($this->date_c) || dol_strlen($this->date_c) != 0 ? "'".$this->db->idate($this->date_c)."'" : 'null').',';
544  //$sql .= ' date_m = '.(! isset($this->date_m) || dol_strlen($this->date_m) != 0 ? "'".$this->db->idate($this->date_m)."'" : 'null').','; // Field automatically updated
545  $sql .= ' fk_user_c = '.(isset($this->fk_user_c)?$this->fk_user_c:"null").',';
546  $sql .= ' fk_user_m = '.($this->fk_user_m > 0?$this->fk_user_m:$user->id).',';
547  $sql .= ' acl = '.(isset($this->acl)?"'".$this->db->escape($this->acl)."'":"null");
548  $sql .= ' WHERE rowid=' . $this->id;
549 
550  $this->db->begin();
551 
552  $resql = $this->db->query($sql);
553  if (!$resql) {
554  $error ++;
555  $this->errors[] = 'Error ' . $this->db->lasterror();
556  dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
557  }
558 
559  if (!$error && !$notrigger) {
560  // Uncomment this and change MYOBJECT to your own tag if you
561  // want this action calls a trigger.
562 
564  //$result=$this->call_trigger('MYOBJECT_MODIFY',$user);
565  //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
567  }
568 
569  // Commit or rollback
570  if ($error) {
571  $this->db->rollback();
572 
573  return - 1 * $error;
574  } else {
575  $this->db->commit();
576 
577  return 1;
578  }
579  }
580 
589  public function delete(User $user, $notrigger = false)
590  {
591  dol_syslog(__METHOD__, LOG_DEBUG);
592 
593  $error = 0;
594 
595  $this->db->begin();
596 
597  if (!$error) {
598  if (!$notrigger) {
599  // Uncomment this and change MYOBJECT to your own tag if you
600  // want this action calls a trigger.
601 
603  //$result=$this->call_trigger('MYOBJECT_DELETE',$user);
604  //if ($result < 0) { $error++; //Do also what you must do to rollback action if trigger fail}
606  }
607  }
608 
609  // If you need to delete child tables to, you can insert them here
610 
611  if (!$error) {
612  $sql = 'DELETE FROM ' . MAIN_DB_PREFIX . $this->table_element;
613  $sql .= ' WHERE rowid=' . $this->id;
614 
615  $resql = $this->db->query($sql);
616  if (!$resql) {
617  $error ++;
618  $this->errors[] = 'Error ' . $this->db->lasterror();
619  dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
620  }
621  }
622 
623  // Commit or rollback
624  if ($error) {
625  $this->db->rollback();
626 
627  return - 1 * $error;
628  } else {
629  $this->db->commit();
630 
631  return 1;
632  }
633  }
634 
642  public function createFromClone($fromid)
643  {
644  dol_syslog(__METHOD__, LOG_DEBUG);
645 
646  global $user;
647  $error = 0;
648  $object = new Ecmfiles($this->db);
649 
650  $this->db->begin();
651 
652  // Load source object
653  $object->fetch($fromid);
654  // Reset object
655  $object->id = 0;
656 
657  // Clear fields
658  // ...
659 
660  // Create clone
661  $result = $object->create($user);
662 
663  // Other options
664  if ($result < 0) {
665  $error ++;
666  $this->errors = $object->errors;
667  dol_syslog(__METHOD__ . ' ' . implode(',', $this->errors), LOG_ERR);
668  }
669 
670  // End
671  if (!$error) {
672  $this->db->commit();
673 
674  return $object->id;
675  } else {
676  $this->db->rollback();
677 
678  return - 1;
679  }
680  }
681 
692  function getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
693  {
694  global $db, $conf, $langs;
695  global $dolibarr_main_authentication, $dolibarr_main_demo;
696  global $menumanager;
697 
698  if (! empty($conf->dol_no_mouse_hover)) $notooltip=1; // Force disable tooltips
699 
700  $result = '';
701  $companylink = '';
702 
703  $label = '<u>' . $langs->trans("MyModule") . '</u>';
704  $label.= '<br>';
705  $label.= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
706 
707  $url = DOL_URL_ROOT.'/ecm/'.$this->table_name.'_card.php?id='.$this->id;
708 
709  $linkclose='';
710  if (empty($notooltip))
711  {
712  if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
713  {
714  $label=$langs->trans("ShowProject");
715  $linkclose.=' alt="'.dol_escape_htmltag($label, 1).'"';
716  }
717  $linkclose.=' title="'.dol_escape_htmltag($label, 1).'"';
718  $linkclose.=' class="classfortooltip'.($morecss?' '.$morecss:'').'"';
719  }
720  else $linkclose = ($morecss?' class="'.$morecss.'"':'');
721 
722  $linkstart = '<a href="'.$url.'"';
723  $linkstart.=$linkclose.'>';
724  $linkend='</a>';
725 
726  if ($withpicto)
727  {
728  $result.=($linkstart.img_object(($notooltip?'':$label), 'label', ($notooltip?'':'class="classfortooltip"')).$linkend);
729  if ($withpicto != 2) $result.=' ';
730  }
731  $result.= $linkstart . $this->ref . $linkend;
732  return $result;
733  }
734 
741  function getLibStatut($mode=0)
742  {
743  return $this->LibStatut($this->status,$mode);
744  }
745 
753  static function LibStatut($status,$mode=0)
754  {
755  global $langs;
756  return '';
757  }
758 
759 
766  public function initAsSpecimen()
767  {
768  global $conf,$user;
769 
770  $this->id = 0;
771 
772  $this->label = '0a1b2c3e4f59999999';
773  $this->entity = '1';
774  $this->filename = 'myspecimenfilefile.pdf';
775  $this->filepath = '/aaa/bbb';
776  $this->fullpath_orig = 'c:/file on my disk.pdf';
777  $this->description = 'This is a long description of file';
778  $this->keywords = 'key1,key2';
779  $this->cover = '1';
780  $this->position = '5';
781  $this->gen_or_uploaded = 'uploaded';
782  $this->extraparams = '';
783  $this->date_c = (dol_now() - 3600 * 24 * 10);
784  $this->date_m = '';
785  $this->fk_user_c = $user->id;
786  $this->fk_user_m = '';
787  $this->acl = '';
788  }
789 
790 }
791 
792 
794 {
795  public $label;
796  public $entity;
797  public $filename;
798  public $filepath;
799  public $fullpath_orig;
800  public $description;
801  public $keywords;
802  public $cover;
803  public $position;
804  public $gen_or_uploaded; // can be 'generated', 'uploaded', 'unknown'
805  public $extraparams;
806  public $date_c = '';
807  public $date_m = '';
808  public $fk_user_c;
809  public $fk_user_m;
810  public $acl;
811 }
getLibStatut($mode=0)
Retourne le libelle du status d'un user (actif, inactif)
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load object in memory from the database.
</td >< tdclass="liste_titre"align="right"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow img yes disabled img no img no< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="'.$i.'"'.$disabled.'></td >< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"></td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:554
static LibStatut($status, $mode=0)
Return the status.
Class to manage Dolibarr users.
Definition: user.class.php:39
Class to manage Dolibarr database access.
background position
Definition: style.css.php:368
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='')
Write log message into outputs.
create(User $user, $notrigger=false)
Create object into database.
createFromClone($fromid)
Load an object from its id and create a new one in database.
getNomUrl($withpicto=0, $option='', $notooltip=0, $maxlen=24, $morecss='')
Return a link to the object card (with optionaly the picto)
dol_now($mode='gmt')
Return date for now.
fetch($id, $ref= '', $relativepath= '', $hashoffile='', $hashforshare='')
Load object in memory from the database.
update(User $user, $notrigger=false)
Update object into database.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if(!empty($conf->fournisseur->enabled)&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->societe->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)&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1013
dol_hash($chain, $type='0')
Returns a hash of a string.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Class to manage ECM files.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
__construct(DoliDB $db)
Constructor.