dolibarr  x.y.z
partnership.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
26 // Put here all includes required by your class file
27 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28 
33 {
37  public $module = 'partnership';
38 
42  public $element = 'partnership';
43 
47  public $table_element = 'partnership';
48 
53  public $ismultientitymanaged = 0;
54 
58  public $isextrafieldmanaged = 1;
59 
63  public $picto = 'partnership';
64 
65 
66  const STATUS_DRAFT = 0;
67  const STATUS_VALIDATED = 1; // Validate (no more draft)
68  const STATUS_APPROVED = 2; // Approved
69  const STATUS_REFUSED = 3; // Refused
70  const STATUS_CANCELED = 9;
71 
72 
99  // BEGIN MODULEBUILDER PROPERTIES
103  public $fields=array(
104  'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
105  'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
106  'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
107  'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1,),
108  'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
109  'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
110  'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
111  'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
112  'fk_user_creat' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserAuthor', 'enabled'=>'1', 'position'=>510, 'notnull'=>1, 'visible'=>-2, 'foreignkey'=>'user.rowid',),
113  'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
114  'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
115  'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
116  'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
117  'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
118  'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
119  'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('-1'=>'', '0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),),
120  'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1,),
121  'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
122  'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,),
123  'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
124  'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150',),
125  'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
126  );
127  public $rowid;
128  public $ref;
129  public $entity;
130  public $fk_type;
131  public $note_public;
132  public $note_private;
133  public $date_creation;
134  public $tms;
135  public $fk_user_creat;
136  public $fk_user_modif;
137  public $last_main_doc;
138  public $import_key;
139  public $model_pdf;
140  public $date_partnership_start;
141  public $date_partnership_end;
142  public $status;
143  public $url_to_check;
144  public $count_last_url_check_error;
145  public $last_check_backlink;
146  public $reason_decline_or_cancel;
147  public $fk_soc;
148  // END MODULEBUILDER PROPERTIES
149 
150 
151  // If this object has a subtable with lines
152 
153  // /**
154  // * @var string Name of subtable line
155  // */
156  // public $table_element_line = 'partnershipline';
157 
158  // /**
159  // * @var string Field with ID of parent key if this object has a parent
160  // */
161  // public $fk_element = 'fk_partnership';
162 
163  // /**
164  // * @var string Name of subtable class that manage subtable lines
165  // */
166  // public $class_element_line = 'Partnershipline';
167 
168  // /**
169  // * @var array List of child tables. To test if we can delete object.
170  // */
171  // protected $childtables = array();
172 
173  // /**
174  // * @var array List of child tables. To know object to delete on cascade.
175  // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
176  // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
177  // */
178  // protected $childtablesoncascade = array('partnershipdet');
179 
180  // /**
181  // * @var PartnershipLine[] Array of subtable lines
182  // */
183  // public $lines = array();
184 
185 
191  public function __construct(DoliDB $db)
192  {
193  global $conf, $langs;
194 
195  $this->db = $db;
196 
197  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
198  $this->fields['fk_member'] = array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'member', 'csslist'=>'tdoverflowmax150');
199  } else {
200  $this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'picto'=>'company', 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax150');
201  }
202 
203  if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
204  $this->fields['rowid']['visible'] = 0;
205  }
206  // if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
207  // $this->fields['entity']['enabled'] = 0;
208  // }
209 
210  // Example to show how to set values of fields definition dynamically
211  /*if ($user->rights->partnership->read) {
212  $this->fields['myfield']['visible'] = 1;
213  $this->fields['myfield']['noteditable'] = 0;
214  }*/
215 
216  // Unset fields that are disabled
217  foreach ($this->fields as $key => $val) {
218  if (isset($val['enabled']) && empty($val['enabled'])) {
219  unset($this->fields[$key]);
220  }
221  }
222 
223  // Translate some data of arrayofkeyval
224  if (is_object($langs)) {
225  foreach ($this->fields as $key => $val) {
226  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
227  foreach ($val['arrayofkeyval'] as $key2 => $val2) {
228  $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
229  }
230  }
231  }
232  }
233  }
234 
242  public function create(User $user, $notrigger = false)
243  {
244  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
245  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
246  return -1;
247  }
248 
249  $this->status = 0;
250  return $this->createCommon($user, $notrigger);
251  }
252 
260  public function createFromClone(User $user, $fromid)
261  {
262  global $langs, $extrafields;
263  $error = 0;
264 
265  dol_syslog(__METHOD__, LOG_DEBUG);
266 
267  $object = new self($this->db);
268 
269  $this->db->begin();
270 
271  // Load source object
272  $result = $object->fetchCommon($fromid);
273  if ($result > 0 && !empty($object->table_element_line)) {
274  $object->fetchLines();
275  }
276 
277  // get lines so they will be clone
278  //foreach($this->lines as $line)
279  // $line->fetch_optionals();
280 
281  // Reset some properties
282  unset($object->id);
283  unset($object->fk_user_creat);
284  unset($object->import_key);
285 
286  // Clear fields
287  if (property_exists($object, 'ref')) {
288  $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
289  }
290  if (property_exists($object, 'label')) {
291  $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
292  }
293  if (property_exists($object, 'status')) {
294  $object->status = self::STATUS_DRAFT;
295  }
296  if (property_exists($object, 'date_creation')) {
297  $object->date_creation = dol_now();
298  }
299  if (property_exists($object, 'date_modification')) {
300  $object->date_modification = null;
301  }
302  // ...
303  // Clear extrafields that are unique
304  if (is_array($object->array_options) && count($object->array_options) > 0) {
305  $extrafields->fetch_name_optionals_label($this->table_element);
306  foreach ($object->array_options as $key => $option) {
307  $shortkey = preg_replace('/options_/', '', $key);
308  if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
309  //var_dump($key);
310  //var_dump($clonedObj->array_options[$key]); exit;
311  unset($object->array_options[$key]);
312  }
313  }
314  }
315 
316  // Create clone
317  $object->context['createfromclone'] = 'createfromclone';
318  $result = $object->createCommon($user);
319  if ($result < 0) {
320  $error++;
321  $this->error = $object->error;
322  $this->errors = $object->errors;
323  }
324 
325  if (!$error) {
326  // copy internal contacts
327  if ($this->copy_linked_contact($object, 'internal') < 0) {
328  $error++;
329  }
330  }
331 
332  if (!$error) {
333  // copy external contacts if same company
334  if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
335  if ($this->copy_linked_contact($object, 'external') < 0) {
336  $error++;
337  }
338  }
339  }
340 
341  unset($object->context['createfromclone']);
342 
343  // End
344  if (!$error) {
345  $this->db->commit();
346  return $object;
347  } else {
348  $this->db->rollback();
349  return -1;
350  }
351  }
352 
363  public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
364  {
365  global $conf;
366 
367  // Check parameters
368  if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
369  return -1;
370  }
371 
372  $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
373  $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
374  $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
375  $sql .= ', p.note_private, p.note_public';
376  $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
377  $sql .= ', p.import_key, p.model_pdf';
378  $sql .= ', pt.code as type_code, pt.label as type_label';
379  $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
380  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
381 
382  if ($id) {
383  $sql .= " WHERE p.rowid=".((int) $id);
384  } else {
385  $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid
386  }
387 
388  if ($ref) {
389  $sql .= " AND p.ref='".$this->db->escape($ref)."'";
390  }
391 
392  if ($fk_member > 0) {
393  $sql .= ' AND p.fk_member = '.((int) $fk_member);
394  }
395  if ($fk_soc > 0) {
396  $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
397  }
398  $sql .= ' ORDER BY p.date_partnership_end DESC';
399 
400  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
401  $result = $this->db->query($sql);
402  if ($result) {
403  $obj = $this->db->fetch_object($result);
404  if ($obj) {
405  $this->id = $obj->rowid;
406  $this->entity = $obj->entity;
407  $this->ref = $obj->ref;
408 
409  $this->fk_type = $obj->fk_type;
410  $this->type_code = $obj->type_code;
411  $this->type_label = $obj->type_label;
412 
413  $this->fk_soc = $obj->fk_soc;
414  $this->fk_member = $obj->fk_member;
415  $this->status = $obj->status;
416  $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
417  $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
418  $this->date_creation = $this->db->jdate($obj->date_creation);
419  $this->fk_user_creat = $obj->fk_user_creat;
420  $this->tms = $obj->tms;
421  $this->fk_user_modif = $obj->fk_user_modif;
422  $this->note_private = $obj->note_private;
423  $this->note_public = $obj->note_public;
424  $this->last_main_doc = $obj->last_main_doc;
425  $this->count_last_url_check_error = $obj->count_last_url_check_error;
426  $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
427  $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
428  $this->import_key = $obj->import_key;
429  $this->model_pdf = $obj->model_pdf;
430 
431  // Retrieve all extrafield
432  // fetch optionals attributes and labels
433  $this->fetch_optionals();
434 
435  $this->db->free($result);
436 
437  return 1;
438  } else {
439  // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
440  return 0;
441  }
442  } else {
443  $this->error = $this->db->error();
444  return -1;
445  }
446  }
447 
448 
454  public function fetchLines()
455  {
456  $this->lines = array();
457 
458  $result = $this->fetchLinesCommon();
459  return $result;
460  }
461 
462 
474  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
475  {
476  global $conf;
477 
478  dol_syslog(__METHOD__, LOG_DEBUG);
479 
480  $records = array();
481 
482  $sql = 'SELECT ';
483  $sql .= $this->getFieldList('t');
484  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
485  if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
486  $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
487  } else {
488  $sql .= ' WHERE 1 = 1';
489  }
490  // Manage filter
491  $sqlwhere = array();
492  if (count($filter) > 0) {
493  foreach ($filter as $key => $value) {
494  if ($key == 't.rowid') {
495  $sqlwhere[] = $key." = ".((int) $value);
496  } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
497  $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
498  } elseif ($key == 'customsql') {
499  $sqlwhere[] = $value;
500  } elseif (strpos($value, '%') === false) {
501  $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
502  } else {
503  $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
504  }
505  }
506  }
507  if (count($sqlwhere) > 0) {
508  $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
509  }
510 
511  if (!empty($sortfield)) {
512  $sql .= $this->db->order($sortfield, $sortorder);
513  }
514  if (!empty($limit)) {
515  $sql .= $this->db->plimit($limit, $offset);
516  }
517  print $sql;
518  $resql = $this->db->query($sql);
519  if ($resql) {
520  $num = $this->db->num_rows($resql);
521  $i = 0;
522  while ($i < ($limit ? min($limit, $num) : $num)) {
523  $obj = $this->db->fetch_object($resql);
524 
525  $record = new self($this->db);
526  $record->setVarsFromFetchObj($obj);
527 
528  $records[$record->id] = $record;
529 
530  $i++;
531  }
532  $this->db->free($resql);
533 
534  return $records;
535  } else {
536  $this->errors[] = 'Error '.$this->db->lasterror();
537  dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
538 
539  return -1;
540  }
541  }
542 
550  public function update(User $user, $notrigger = false)
551  {
552  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
553  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
554  return -1;
555  }
556 
557  return $this->updateCommon($user, $notrigger);
558  }
559 
567  public function delete(User $user, $notrigger = false)
568  {
569  return $this->deleteCommon($user, $notrigger);
570  //return $this->deleteCommon($user, $notrigger, 1);
571  }
572 
581  public function deleteLine(User $user, $idline, $notrigger = false)
582  {
583  if ($this->status < 0) {
584  $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
585  return -2;
586  }
587 
588  return $this->deleteLineCommon($user, $idline, $notrigger);
589  }
590 
591 
599  public function validate($user, $notrigger = 0)
600  {
601  global $conf, $langs;
602 
603  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
604 
605  $error = 0;
606 
607  // Protection
608  if ($this->status == self::STATUS_VALIDATED) {
609  dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
610  return 0;
611  }
612 
613  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
614  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->validate))))
615  {
616  $this->error='NotEnoughPermissions';
617  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
618  return -1;
619  }*/
620 
621  $now = dol_now();
622 
623  $this->db->begin();
624 
625  // Define new ref
626  if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
627  $num = $this->getNextNumRef();
628  } else {
629  $num = $this->ref;
630  }
631  $this->newref = $num;
632 
633  if (!empty($num)) {
634  // Validate
635  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
636  $sql .= " SET ref = '".$this->db->escape($num)."',";
637  $sql .= " status = ".self::STATUS_VALIDATED;
638  if (!empty($this->fields['date_validation'])) {
639  $sql .= ", date_validation = '".$this->db->idate($now)."'";
640  }
641  if (!empty($this->fields['fk_user_valid'])) {
642  $sql .= ", fk_user_valid = ".$user->id;
643  }
644  $sql .= " WHERE rowid = ".((int) $this->id);
645 
646  dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
647  $resql = $this->db->query($sql);
648  if (!$resql) {
649  dol_print_error($this->db);
650  $this->error = $this->db->lasterror();
651  $error++;
652  }
653 
654  if (!$error && !$notrigger) {
655  // Call trigger
656  $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
657  if ($result < 0) {
658  $error++;
659  }
660  // End call triggers
661  }
662  }
663 
664  if (!$error) {
665  $this->oldref = $this->ref;
666 
667  // Rename directory if dir was a temporary ref
668  if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
669  // Now we rename also files into index
670  $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'partnership/".$this->db->escape($this->newref)."'";
671  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
672  $resql = $this->db->query($sql);
673  if (!$resql) {
674  $error++; $this->error = $this->db->lasterror();
675  }
676 
677  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
678  $oldref = dol_sanitizeFileName($this->ref);
679  $newref = dol_sanitizeFileName($num);
680  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
681  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
682  if (!$error && file_exists($dirsource)) {
683  dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
684 
685  if (@rename($dirsource, $dirdest)) {
686  dol_syslog("Rename ok");
687  // Rename docs starting with $oldref with $newref
688  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
689  foreach ($listoffiles as $fileentry) {
690  $dirsource = $fileentry['name'];
691  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
692  $dirsource = $fileentry['path'].'/'.$dirsource;
693  $dirdest = $fileentry['path'].'/'.$dirdest;
694  @rename($dirsource, $dirdest);
695  }
696  }
697  }
698  }
699  }
700 
701  // Set new ref and current status
702  if (!$error) {
703  $this->ref = $num;
704  $this->status = self::STATUS_VALIDATED;
705  }
706 
707  if (!$error) {
708  $this->db->commit();
709  return 1;
710  } else {
711  $this->db->rollback();
712  return -1;
713  }
714  }
715 
723  public function approve($user, $notrigger = 0)
724  {
725  global $conf, $langs;
726 
727  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
728 
729  $error = 0;
730 
731  // Protection
732  if ($this->status == self::STATUS_APPROVED) {
733  dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING);
734  return 0;
735  }
736 
737  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
738  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
739  {
740  $this->error='NotEnoughPermissions';
741  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
742  return -1;
743  }*/
744 
745  $now = dol_now();
746 
747  $this->db->begin();
748 
749  // Define new ref
750  if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
751  $num = $this->getNextNumRef();
752  } else {
753  $num = $this->ref;
754  }
755  $this->newref = $num;
756 
757  if (!empty($num)) {
758  // Accept
759  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
760  $sql .= " SET ref = '".$this->db->escape($num)."',";
761  $sql .= " status = ".self::STATUS_APPROVED;
762  // if (!empty($this->fields['date_validation'])) {
763  // $sql .= ", date_validation = '".$this->db->idate($now)."'";
764  // }
765  // if (!empty($this->fields['fk_user_valid'])) {
766  // $sql .= ", fk_user_valid = ".$user->id;
767  // }
768  $sql .= " WHERE rowid = ".((int) $this->id);
769 
770  dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
771  $resql = $this->db->query($sql);
772  if (!$resql) {
773  dol_print_error($this->db);
774  $this->error = $this->db->lasterror();
775  $error++;
776  }
777 
778  if (!$error && !$notrigger) {
779  // Call trigger
780  $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
781  if ($result < 0) {
782  $error++;
783  }
784  // End call triggers
785  }
786  }
787 
788  if (!$error) {
789  $this->oldref = $this->ref;
790 
791  // Rename directory if dir was a temporary ref
792  if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
793  // Now we rename also files into index
794  $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'partnership/".$this->db->escape($this->newref)."'";
795  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
796  $resql = $this->db->query($sql);
797  if (!$resql) {
798  $error++; $this->error = $this->db->lasterror();
799  }
800 
801  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
802  $oldref = dol_sanitizeFileName($this->ref);
803  $newref = dol_sanitizeFileName($num);
804  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
805  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
806  if (!$error && file_exists($dirsource)) {
807  dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
808 
809  if (@rename($dirsource, $dirdest)) {
810  dol_syslog("Rename ok");
811  // Rename docs starting with $oldref with $newref
812  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
813  foreach ($listoffiles as $fileentry) {
814  $dirsource = $fileentry['name'];
815  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
816  $dirsource = $fileentry['path'].'/'.$dirsource;
817  $dirdest = $fileentry['path'].'/'.$dirdest;
818  @rename($dirsource, $dirdest);
819  }
820  }
821  }
822  }
823  }
824 
825  // Set new ref and current status
826  if (!$error) {
827  $this->ref = $num;
828  $this->status = self::STATUS_APPROVED;
829  }
830 
831  if (!$error) {
832  $this->db->commit();
833  return 1;
834  } else {
835  $this->db->rollback();
836  return -1;
837  }
838  }
839 
840 
848  public function setDraft($user, $notrigger = 0)
849  {
850  // Protection
851  if ($this->status <= self::STATUS_DRAFT) {
852  return 0;
853  }
854 
855  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
856  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
857  {
858  $this->error='Permission denied';
859  return -1;
860  }*/
861 
862  return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
863  }
864 
873  public function refused($user, $reasondeclinenote = '', $notrigger = 0)
874  {
875  // Protection
876  if ($this->status == self::STATUS_REFUSED) {
877  return 0;
878  }
879 
880  $this->status = self::STATUS_REFUSED;
881  $this->reason_decline_or_cancel = $reasondeclinenote;
882 
883  $result = $this->update($user);
884 
885  if ($result) {
886  $this->reason_decline_or_cancel = $reasondeclinenote;
887  return 1;
888  }
889 
890  return -1;
891  }
892 
900  public function cancel($user, $notrigger = 0)
901  {
902  // Protection
903  if ($this->status != self::STATUS_APPROVED) {
904  return 0;
905  }
906 
907  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
908  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
909  {
910  $this->error='Permission denied';
911  return -1;
912  }*/
913 
914  return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
915  }
916 
924  public function reopen($user, $notrigger = 0)
925  {
926  // Protection
927  if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
928  return 0;
929  }
930 
931  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
932  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
933  {
934  $this->error='Permission denied';
935  return -1;
936  }*/
937 
938  return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
939  }
940 
951  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
952  {
953  global $conf, $langs, $hookmanager;
954 
955  if (!empty($conf->dol_no_mouse_hover)) {
956  $notooltip = 1; // Force disable tooltips
957  }
958 
959  $result = '';
960 
961  $label = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
962  if (isset($this->status)) {
963  $label .= ' '.$this->getLibStatut(5);
964  }
965  $label .= '<br>';
966  $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
967 
968  $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
969 
970  if ($option != 'nolink') {
971  // Add param to save lastsearch_values or not
972  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
973  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
974  $add_save_lastsearch_values = 1;
975  }
976  if ($add_save_lastsearch_values) {
977  $url .= '&save_lastsearch_values=1';
978  }
979  }
980 
981  $linkclose = '';
982  if (empty($notooltip)) {
983  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
984  $label = $langs->trans("ShowPartnership");
985  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
986  }
987  $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
988  $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
989  } else {
990  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
991  }
992 
993  if ($option == 'nolink') {
994  $linkstart = '<span';
995  } else {
996  $linkstart = '<a href="'.$url.'"';
997  }
998  $linkstart .= $linkclose.'>';
999  if ($option == 'nolink') {
1000  $linkend = '</span>';
1001  } else {
1002  $linkend = '</a>';
1003  }
1004 
1005  $result .= $linkstart;
1006 
1007  if (empty($this->showphoto_on_popup)) {
1008  if ($withpicto) {
1009  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1010  }
1011  } else {
1012  if ($withpicto) {
1013  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1014 
1015  list($class, $module) = explode('@', $this->picto);
1016  $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1017  $filearray = dol_dir_list($upload_dir, "files");
1018  $filename = $filearray[0]['name'];
1019  if (!empty($filename)) {
1020  $pospoint = strpos($filearray[0]['name'], '.');
1021 
1022  $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1023  if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
1024  $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.'" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div></div>';
1025  } else {
1026  $result .= '<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$module.'&entity='.$conf->entity.'&file='.urlencode($pathtophoto).'"></div>';
1027  }
1028 
1029  $result .= '</div>';
1030  } else {
1031  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1032  }
1033  }
1034  }
1035 
1036  if ($withpicto != 2) {
1037  $result .= $this->ref;
1038  }
1039 
1040  $result .= $linkend;
1041  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1042 
1043  global $action, $hookmanager;
1044  $hookmanager->initHooks(array('partnershipdao'));
1045  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1046  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1047  if ($reshook > 0) {
1048  $result = $hookmanager->resPrint;
1049  } else {
1050  $result .= $hookmanager->resPrint;
1051  }
1052 
1053  return $result;
1054  }
1055 
1062  public function getLibStatut($mode = 0)
1063  {
1064  return $this->LibStatut($this->status, $mode);
1065  }
1066 
1067  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1075  public function LibStatut($status, $mode = 0)
1076  {
1077  // phpcs:enable
1078  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1079  global $langs;
1080  //$langs->load("partnership");
1081  $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1082  $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1083  $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1084  $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1085  $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1086  $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1087  $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1088  $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1089  $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1090  $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1091  }
1092 
1093  $statusType = 'status'.$status;
1094  if ($status == self::STATUS_APPROVED) {
1095  $statusType = 'status4';
1096  }
1097  if ($status == self::STATUS_REFUSED) {
1098  $statusType = 'status9';
1099  }
1100  if ($status == self::STATUS_CANCELED) {
1101  $statusType = 'status6';
1102  }
1103 
1104  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1105  }
1106 
1113  public function info($id)
1114  {
1115  $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1116  $sql .= ' fk_user_creat, fk_user_modif';
1117  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1118  $sql .= ' WHERE t.rowid = '.((int) $id);
1119  $result = $this->db->query($sql);
1120  if ($result) {
1121  if ($this->db->num_rows($result)) {
1122  $obj = $this->db->fetch_object($result);
1123  $this->id = $obj->rowid;
1124 
1125  $this->user_creation_id = $obj->fk_user_creat;
1126  $this->user_modification_id = $obj->fk_user_modif;
1127  $this->date_creation = $this->db->jdate($obj->datec);
1128  $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1129  }
1130 
1131  $this->db->free($result);
1132  } else {
1133  dol_print_error($this->db);
1134  }
1135  }
1136 
1143  public function initAsSpecimen()
1144  {
1145  $this->initAsSpecimenCommon();
1146  }
1147 
1153  public function getLinesArray()
1154  {
1155  $this->lines = array();
1156 
1157  $objectline = new PartnershipLine($this->db);
1158  $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_partnership = '.((int) $this->id)));
1159 
1160  if (is_numeric($result)) {
1161  $this->error = $objectline->error;
1162  $this->errors = $objectline->errors;
1163  return $result;
1164  } else {
1165  $this->lines = $result;
1166  return $this->lines;
1167  }
1168  }
1169 
1175  public function getNextNumRef()
1176  {
1177  global $langs, $conf;
1178  $langs->load("partnership");
1179 
1180  if (empty($conf->global->PARTNERSHIP_ADDON)) {
1181  $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1182  }
1183 
1184  if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1185  $mybool = false;
1186 
1187  $file = $conf->global->PARTNERSHIP_ADDON.".php";
1188  $classname = $conf->global->PARTNERSHIP_ADDON;
1189 
1190  // Include file with class
1191  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1192  foreach ($dirmodels as $reldir) {
1193  $dir = dol_buildpath($reldir."core/modules/partnership/");
1194 
1195  // Load file with numbering class (if found)
1196  $mybool |= @include_once $dir.$file;
1197  }
1198 
1199  if ($mybool === false) {
1200  dol_print_error('', "Failed to include file ".$file);
1201  return '';
1202  }
1203 
1204  if (class_exists($classname)) {
1205  $obj = new $classname();
1206  $numref = $obj->getNextValue($this);
1207 
1208  if ($numref != '' && $numref != '-1') {
1209  return $numref;
1210  } else {
1211  $this->error = $obj->error;
1212  //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1213  return "";
1214  }
1215  } else {
1216  print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1217  return "";
1218  }
1219  } else {
1220  print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1221  return "";
1222  }
1223  }
1224 
1236  public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1237  {
1238  global $conf, $langs;
1239 
1240  $result = 0;
1241  $includedocgeneration = 0;
1242 
1243  $langs->load("partnership");
1244 
1245  if (!dol_strlen($modele)) {
1246  $modele = 'standard_partnership';
1247 
1248  if (!empty($this->model_pdf)) {
1249  $modele = $this->model_pdf;
1250  } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1251  $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1252  }
1253  }
1254 
1255  $modelpath = "core/modules/partnership/doc/";
1256 
1257  if ($includedocgeneration && !empty($modele)) {
1258  $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1259  }
1260 
1261  return $result;
1262  }
1263 
1271  public function doScheduledJob()
1272  {
1273  global $conf, $langs;
1274 
1275  //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1276 
1277  $error = 0;
1278  $this->output = '';
1279  $this->error = '';
1280 
1281  dol_syslog(__METHOD__, LOG_DEBUG);
1282 
1283  $now = dol_now();
1284 
1285  $this->db->begin();
1286 
1287  // ...
1288 
1289  $this->db->commit();
1290 
1291  return $error;
1292  }
1293 }
1294 
1295 
1296 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1297 
1302 {
1303  // To complete with content of an object PartnershipLine
1304  // We should have a field rowid, fk_partnership and position
1305 
1309  public $isextrafieldmanaged = 0;
1310 
1316  public function __construct(DoliDB $db)
1317  {
1318  $this->db = $db;
1319  }
1320 }
$object ref
Definition: info.php:78
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...
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
getFieldList($alias='')
Function to concat keys of fields.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='')
Load object in memory from the database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class for Partnership.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
update(User $user, $notrigger=false)
Update object into database.
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
getLinesArray()
Create an array of lines.
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetchLines()
Load object lines in memory from the database.
create(User $user, $notrigger=false)
Create object into database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
Class PartnershipLine.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
Definition: user.class.php:45
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.
Definition: index.php:745
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:61
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.
Definition: inc.php:41