dolibarr  18.0.0-beta
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, 'csslist'=>'tdoverflowmax100'),
108  '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'=>'tdoverflowmax125',),
109  'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
110  'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
111  'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
112  'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
113  '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',),
114  'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
115  'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
116  'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
117  'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
118  'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
119  'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
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  'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
125  'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),),
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  public $fk_member;
149  // END MODULEBUILDER PROPERTIES
150 
151 
152  // If this object has a subtable with lines
153 
154  // /**
155  // * @var string Name of subtable line
156  // */
157  // public $table_element_line = 'partnershipline';
158 
159  // /**
160  // * @var string Field with ID of parent key if this object has a parent
161  // */
162  // public $fk_element = 'fk_partnership';
163 
164  // /**
165  // * @var string Name of subtable class that manage subtable lines
166  // */
167  // public $class_element_line = 'Partnershipline';
168 
169  // /**
170  // * @var array List of child tables. To test if we can delete object.
171  // */
172  // protected $childtables = array();
173 
174  // /**
175  // * @var array List of child tables. To know object to delete on cascade.
176  // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
177  // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
178  // */
179  // protected $childtablesoncascade = array('partnershipdet');
180 
181  // /**
182  // * @var PartnershipLine[] Array of subtable lines
183  // */
184  // public $lines = array();
185 
186 
192  public function __construct(DoliDB $db)
193  {
194  global $conf, $langs;
195 
196  $this->db = $db;
197 
198  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
199  $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');
200  } else {
201  $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');
202  }
203 
204  if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
205  $this->fields['rowid']['visible'] = 0;
206  }
207  // if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
208  // $this->fields['entity']['enabled'] = 0;
209  // }
210 
211  // Example to show how to set values of fields definition dynamically
212  /*if ($user->rights->partnership->read) {
213  $this->fields['myfield']['visible'] = 1;
214  $this->fields['myfield']['noteditable'] = 0;
215  }*/
216 
217  // Unset fields that are disabled
218  foreach ($this->fields as $key => $val) {
219  if (isset($val['enabled']) && empty($val['enabled'])) {
220  unset($this->fields[$key]);
221  }
222  }
223 
224  // Translate some data of arrayofkeyval
225  if (is_object($langs)) {
226  foreach ($this->fields as $key => $val) {
227  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
228  foreach ($val['arrayofkeyval'] as $key2 => $val2) {
229  $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
230  }
231  }
232  }
233  }
234  }
235 
243  public function create(User $user, $notrigger = false)
244  {
245  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
246  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
247  return -1;
248  }
249 
250  $this->status = 0;
251  return $this->createCommon($user, $notrigger);
252  }
253 
261  public function createFromClone(User $user, $fromid)
262  {
263  global $langs, $extrafields;
264  $error = 0;
265 
266  dol_syslog(__METHOD__, LOG_DEBUG);
267 
268  $object = new self($this->db);
269 
270  $this->db->begin();
271 
272  // Load source object
273  $result = $object->fetchCommon($fromid);
274  if ($result > 0 && !empty($object->table_element_line)) {
275  $object->fetchLines();
276  }
277 
278  // get lines so they will be clone
279  //foreach($this->lines as $line)
280  // $line->fetch_optionals();
281 
282  // Reset some properties
283  unset($object->id);
284  unset($object->fk_user_creat);
285  unset($object->import_key);
286 
287  // Clear fields
288  if (property_exists($object, 'ref')) {
289  $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
290  }
291  if (property_exists($object, 'label')) {
292  $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
293  }
294  if (property_exists($object, 'status')) {
295  $object->status = self::STATUS_DRAFT;
296  }
297  if (property_exists($object, 'date_creation')) {
298  $object->date_creation = dol_now();
299  }
300  if (property_exists($object, 'date_modification')) {
301  $object->date_modification = null;
302  }
303  // ...
304  // Clear extrafields that are unique
305  if (is_array($object->array_options) && count($object->array_options) > 0) {
306  $extrafields->fetch_name_optionals_label($this->table_element);
307  foreach ($object->array_options as $key => $option) {
308  $shortkey = preg_replace('/options_/', '', $key);
309  if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
310  //var_dump($key);
311  //var_dump($clonedObj->array_options[$key]); exit;
312  unset($object->array_options[$key]);
313  }
314  }
315  }
316 
317  // Create clone
318  $object->context['createfromclone'] = 'createfromclone';
319  $result = $object->createCommon($user);
320  if ($result < 0) {
321  $error++;
322  $this->error = $object->error;
323  $this->errors = $object->errors;
324  }
325 
326  if (!$error) {
327  // copy internal contacts
328  if ($this->copy_linked_contact($object, 'internal') < 0) {
329  $error++;
330  }
331  }
332 
333  if (!$error) {
334  // copy external contacts if same company
335  if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
336  if ($this->copy_linked_contact($object, 'external') < 0) {
337  $error++;
338  }
339  }
340  }
341 
342  unset($object->context['createfromclone']);
343 
344  // End
345  if (!$error) {
346  $this->db->commit();
347  return $object;
348  } else {
349  $this->db->rollback();
350  return -1;
351  }
352  }
353 
364  public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
365  {
366  global $conf;
367 
368  // Check parameters
369  if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
370  return -1;
371  }
372 
373  $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
374  $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
375  $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
376  $sql .= ', p.note_private, p.note_public, p.url_to_check';
377  $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
378  $sql .= ', p.import_key, p.model_pdf';
379  $sql .= ', pt.code as type_code, pt.label as type_label';
380  $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
381  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
382 
383  if ($id) {
384  $sql .= " WHERE p.rowid = ".((int) $id);
385  } else {
386  $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid
387  }
388 
389  if ($ref) {
390  $sql .= " AND p.ref='".$this->db->escape($ref)."'";
391  }
392 
393  if ($fk_member > 0) {
394  $sql .= ' AND p.fk_member = '.((int) $fk_member);
395  }
396  if ($fk_soc > 0) {
397  $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
398  }
399  $sql .= ' ORDER BY p.date_partnership_end DESC';
400 
401  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
402  $result = $this->db->query($sql);
403  if ($result) {
404  $obj = $this->db->fetch_object($result);
405  if ($obj) {
406  $this->id = $obj->rowid;
407  $this->entity = $obj->entity;
408  $this->ref = $obj->ref;
409 
410  $this->fk_type = $obj->fk_type;
411  $this->type_code = $obj->type_code;
412  $this->type_label = $obj->type_label;
413 
414  $this->fk_soc = $obj->fk_soc;
415  $this->fk_member = $obj->fk_member;
416  $this->status = $obj->status;
417  $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
418  $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
419  $this->date_creation = $this->db->jdate($obj->date_creation);
420  $this->fk_user_creat = $obj->fk_user_creat;
421  $this->tms = $obj->tms;
422  $this->fk_user_modif = $obj->fk_user_modif;
423  $this->note_private = $obj->note_private;
424  $this->note_public = $obj->note_public;
425  $this->last_main_doc = $obj->last_main_doc;
426  $this->count_last_url_check_error = $obj->count_last_url_check_error;
427  $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
428  $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
429  $this->import_key = $obj->import_key;
430  $this->model_pdf = $obj->model_pdf;
431  $this->url_to_check = $obj->url_to_check;
432 
433  // Retrieve all extrafield
434  // fetch optionals attributes and labels
435  $this->fetch_optionals();
436 
437  $this->db->free($result);
438 
439  return 1;
440  } else {
441  // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
442  return 0;
443  }
444  } else {
445  $this->error = $this->db->error();
446  return -1;
447  }
448  }
449 
450 
456  public function fetchLines()
457  {
458  $this->lines = array();
459 
460  $result = $this->fetchLinesCommon();
461  return $result;
462  }
463 
464 
476  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
477  {
478  global $conf;
479 
480  dol_syslog(__METHOD__, LOG_DEBUG);
481 
482  $records = array();
483 
484  $sql = 'SELECT ';
485  $sql .= $this->getFieldList('t');
486  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
487  if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
488  $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
489  } else {
490  $sql .= ' WHERE 1 = 1';
491  }
492  // Manage filter
493  $sqlwhere = array();
494  if (count($filter) > 0) {
495  foreach ($filter as $key => $value) {
496  if ($key == 't.rowid') {
497  $sqlwhere[] = $key." = ".((int) $value);
498  } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
499  $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
500  } elseif ($key == 'customsql') {
501  $sqlwhere[] = $value;
502  } elseif (strpos($value, '%') === false) {
503  $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
504  } else {
505  $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
506  }
507  }
508  }
509  if (count($sqlwhere) > 0) {
510  $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
511  }
512 
513  if (!empty($sortfield)) {
514  $sql .= $this->db->order($sortfield, $sortorder);
515  }
516  if (!empty($limit)) {
517  $sql .= $this->db->plimit($limit, $offset);
518  }
519  print $sql;
520  $resql = $this->db->query($sql);
521  if ($resql) {
522  $num = $this->db->num_rows($resql);
523  $i = 0;
524  while ($i < ($limit ? min($limit, $num) : $num)) {
525  $obj = $this->db->fetch_object($resql);
526 
527  $record = new self($this->db);
528  $record->setVarsFromFetchObj($obj);
529 
530  $records[$record->id] = $record;
531 
532  $i++;
533  }
534  $this->db->free($resql);
535 
536  return $records;
537  } else {
538  $this->errors[] = 'Error '.$this->db->lasterror();
539  dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
540 
541  return -1;
542  }
543  }
544 
552  public function update(User $user, $notrigger = false)
553  {
554  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
555  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
556  return -1;
557  }
558  if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
559  $this->fk_user_creat = $user->id;
560  }
561 
562  return $this->updateCommon($user, $notrigger);
563  }
564 
572  public function delete(User $user, $notrigger = false)
573  {
574  return $this->deleteCommon($user, $notrigger);
575  //return $this->deleteCommon($user, $notrigger, 1);
576  }
577 
586  public function deleteLine(User $user, $idline, $notrigger = false)
587  {
588  if ($this->status < 0) {
589  $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
590  return -2;
591  }
592 
593  return $this->deleteLineCommon($user, $idline, $notrigger);
594  }
595 
596 
604  public function validate($user, $notrigger = 0)
605  {
606  global $conf, $langs;
607 
608  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
609 
610  $error = 0;
611 
612  // Protection
613  if ($this->status == self::STATUS_VALIDATED) {
614  dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
615  return 0;
616  }
617 
618  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
619  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->validate))))
620  {
621  $this->error='NotEnoughPermissions';
622  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
623  return -1;
624  }*/
625 
626  $now = dol_now();
627 
628  $this->db->begin();
629 
630  // Define new ref
631  if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
632  $num = $this->getNextNumRef();
633  } else {
634  $num = $this->ref;
635  }
636  $this->newref = $num;
637 
638  if (!empty($num)) {
639  // Validate
640  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
641  $sql .= " SET ref = '".$this->db->escape($num)."',";
642  $sql .= " status = ".self::STATUS_VALIDATED;
643  if (!empty($this->fields['date_validation'])) {
644  $sql .= ", date_validation = '".$this->db->idate($now)."'";
645  }
646  if (!empty($this->fields['fk_user_valid'])) {
647  $sql .= ", fk_user_valid = ".$user->id;
648  }
649  $sql .= " WHERE rowid = ".((int) $this->id);
650 
651  dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
652  $resql = $this->db->query($sql);
653  if (!$resql) {
654  dol_print_error($this->db);
655  $this->error = $this->db->lasterror();
656  $error++;
657  }
658 
659  if (!$error && !$notrigger) {
660  // Call trigger
661  $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
662  if ($result < 0) {
663  $error++;
664  }
665  // End call triggers
666  }
667  }
668 
669  if (!$error) {
670  $this->oldref = $this->ref;
671 
672  // Rename directory if dir was a temporary ref
673  if (preg_match('/^[\(]?PROV/i', $this->ref)) {
674  // Now we rename also files into index
675  $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)."'";
676  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
677  $resql = $this->db->query($sql);
678  if (!$resql) {
679  $error++; $this->error = $this->db->lasterror();
680  }
681 
682  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
683  $oldref = dol_sanitizeFileName($this->ref);
684  $newref = dol_sanitizeFileName($num);
685  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
686  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
687  if (!$error && file_exists($dirsource)) {
688  dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
689 
690  if (@rename($dirsource, $dirdest)) {
691  dol_syslog("Rename ok");
692  // Rename docs starting with $oldref with $newref
693  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
694  foreach ($listoffiles as $fileentry) {
695  $dirsource = $fileentry['name'];
696  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
697  $dirsource = $fileentry['path'].'/'.$dirsource;
698  $dirdest = $fileentry['path'].'/'.$dirdest;
699  @rename($dirsource, $dirdest);
700  }
701  }
702  }
703  }
704  }
705 
706  // Set new ref and current status
707  if (!$error) {
708  $this->ref = $num;
709  $this->status = self::STATUS_VALIDATED;
710  }
711 
712  if (!$error) {
713  $this->db->commit();
714  return 1;
715  } else {
716  $this->db->rollback();
717  return -1;
718  }
719  }
720 
728  public function approve($user, $notrigger = 0)
729  {
730  global $conf, $langs;
731 
732  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
733 
734  $error = 0;
735 
736  // Protection
737  if ($this->status == self::STATUS_APPROVED) {
738  dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING);
739  return 0;
740  }
741 
742  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
743  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
744  {
745  $this->error='NotEnoughPermissions';
746  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
747  return -1;
748  }*/
749 
750  $now = dol_now();
751 
752  $this->db->begin();
753 
754  // Define new ref
755  if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
756  $num = $this->getNextNumRef();
757  } else {
758  $num = $this->ref;
759  }
760  $this->newref = $num;
761 
762  if (!empty($num)) {
763  // Accept
764  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
765  $sql .= " SET ref = '".$this->db->escape($num)."',";
766  $sql .= " status = ".self::STATUS_APPROVED;
767  // if (!empty($this->fields['date_validation'])) {
768  // $sql .= ", date_validation = '".$this->db->idate($now)."'";
769  // }
770  // if (!empty($this->fields['fk_user_valid'])) {
771  // $sql .= ", fk_user_valid = ".$user->id;
772  // }
773  $sql .= " WHERE rowid = ".((int) $this->id);
774 
775  dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
776  $resql = $this->db->query($sql);
777  if (!$resql) {
778  dol_print_error($this->db);
779  $this->error = $this->db->lasterror();
780  $error++;
781  }
782 
783  if (!$error && !$notrigger) {
784  // Call trigger
785  $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
786  if ($result < 0) {
787  $error++;
788  }
789  // End call triggers
790  }
791  }
792 
793  if (!$error) {
794  $this->oldref = $this->ref;
795 
796  // Rename directory if dir was a temporary ref
797  if (preg_match('/^[\(]?PROV/i', $this->ref)) {
798  // Now we rename also files into index
799  $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)."'";
800  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
801  $resql = $this->db->query($sql);
802  if (!$resql) {
803  $error++; $this->error = $this->db->lasterror();
804  }
805 
806  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
807  $oldref = dol_sanitizeFileName($this->ref);
808  $newref = dol_sanitizeFileName($num);
809  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
810  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
811  if (!$error && file_exists($dirsource)) {
812  dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
813 
814  if (@rename($dirsource, $dirdest)) {
815  dol_syslog("Rename ok");
816  // Rename docs starting with $oldref with $newref
817  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
818  foreach ($listoffiles as $fileentry) {
819  $dirsource = $fileentry['name'];
820  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
821  $dirsource = $fileentry['path'].'/'.$dirsource;
822  $dirdest = $fileentry['path'].'/'.$dirdest;
823  @rename($dirsource, $dirdest);
824  }
825  }
826  }
827  }
828  }
829 
830  // Set new ref and current status
831  if (!$error) {
832  $this->ref = $num;
833  $this->status = self::STATUS_APPROVED;
834  }
835 
836  if (!$error) {
837  $this->db->commit();
838  return 1;
839  } else {
840  $this->db->rollback();
841  return -1;
842  }
843  }
844 
845 
853  public function setDraft($user, $notrigger = 0)
854  {
855  // Protection
856  if ($this->status <= self::STATUS_DRAFT) {
857  return 0;
858  }
859 
860  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
861  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
862  {
863  $this->error='Permission denied';
864  return -1;
865  }*/
866 
867  return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
868  }
869 
878  public function refused($user, $reasondeclinenote = '', $notrigger = 0)
879  {
880  // Protection
881  if ($this->status == self::STATUS_REFUSED) {
882  return 0;
883  }
884 
885  $this->status = self::STATUS_REFUSED;
886  $this->reason_decline_or_cancel = $reasondeclinenote;
887 
888  $result = $this->update($user);
889 
890  if ($result) {
891  $this->reason_decline_or_cancel = $reasondeclinenote;
892  return 1;
893  }
894 
895  return -1;
896  }
897 
905  public function cancel($user, $notrigger = 0)
906  {
907  // Protection
908  if ($this->status != self::STATUS_APPROVED) {
909  return 0;
910  }
911 
912  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
913  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
914  {
915  $this->error='Permission denied';
916  return -1;
917  }*/
918 
919  return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
920  }
921 
929  public function reopen($user, $notrigger = 0)
930  {
931  // Protection
932  if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
933  return 0;
934  }
935 
936  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
937  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
938  {
939  $this->error='Permission denied';
940  return -1;
941  }*/
942 
943  return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
944  }
945 
953  public function getTooltipContentArray($params)
954  {
955  global $langs;
956 
957  $langs->load('partnership');
958 
959  $datas = [];
960  $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
961  if (isset($this->status)) {
962  $datas['picto'] .= ' '.$this->getLibStatut(5);
963  }
964  $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
965 
966  return $datas;
967  }
968 
979  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
980  {
981  global $conf, $langs, $hookmanager;
982 
983  if (!empty($conf->dol_no_mouse_hover)) {
984  $notooltip = 1; // Force disable tooltips
985  }
986 
987  $result = '';
988  $params = [
989  'id' => $this->id,
990  'objecttype' => $this->element,
991  'option' => $option,
992  ];
993  $classfortooltip = 'classfortooltip';
994  $dataparams = '';
995  if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
996  $classfortooltip = 'classforajaxtooltip';
997  $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
998  $label = '';
999  } else {
1000  $label = implode($this->getTooltipContentArray($params));
1001  }
1002 
1003  $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
1004 
1005  if ($option != 'nolink') {
1006  // Add param to save lastsearch_values or not
1007  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1008  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
1009  $add_save_lastsearch_values = 1;
1010  }
1011  if ($add_save_lastsearch_values) {
1012  $url .= '&save_lastsearch_values=1';
1013  }
1014  }
1015 
1016  $linkclose = '';
1017  if (empty($notooltip)) {
1018  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1019  $label = $langs->trans("ShowPartnership");
1020  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
1021  }
1022  $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
1023  $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
1024  } else {
1025  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
1026  }
1027 
1028  if ($option == 'nolink') {
1029  $linkstart = '<span';
1030  } else {
1031  $linkstart = '<a href="'.$url.'"';
1032  }
1033  $linkstart .= $linkclose.'>';
1034  if ($option == 'nolink') {
1035  $linkend = '</span>';
1036  } else {
1037  $linkend = '</a>';
1038  }
1039 
1040  $result .= $linkstart;
1041 
1042  if (empty($this->showphoto_on_popup)) {
1043  if ($withpicto) {
1044  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
1045  }
1046  } else {
1047  if ($withpicto) {
1048  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1049 
1050  list($class, $module) = explode('@', $this->picto);
1051  $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1052  $filearray = dol_dir_list($upload_dir, "files");
1053  $filename = $filearray[0]['name'];
1054  if (!empty($filename)) {
1055  $pospoint = strpos($filearray[0]['name'], '.');
1056 
1057  $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1058  if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
1059  $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>';
1060  } else {
1061  $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>';
1062  }
1063 
1064  $result .= '</div>';
1065  } else {
1066  $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);
1067  }
1068  }
1069  }
1070 
1071  if ($withpicto != 2) {
1072  $result .= $this->ref;
1073  }
1074 
1075  $result .= $linkend;
1076  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1077 
1078  global $action, $hookmanager;
1079  $hookmanager->initHooks(array('partnershipdao'));
1080  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1081  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1082  if ($reshook > 0) {
1083  $result = $hookmanager->resPrint;
1084  } else {
1085  $result .= $hookmanager->resPrint;
1086  }
1087 
1088  return $result;
1089  }
1090 
1097  public function getLibStatut($mode = 0)
1098  {
1099  return $this->LibStatut($this->status, $mode);
1100  }
1101 
1102  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1110  public function LibStatut($status, $mode = 0)
1111  {
1112  // phpcs:enable
1113  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1114  global $langs;
1115  //$langs->load("partnership");
1116  $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1117  $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1118  $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1119  $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1120  $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1121  $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1122  $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1123  $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1124  $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1125  $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1126  }
1127 
1128  $statusType = 'status'.$status;
1129  if ($status == self::STATUS_APPROVED) {
1130  $statusType = 'status4';
1131  }
1132  if ($status == self::STATUS_REFUSED) {
1133  $statusType = 'status9';
1134  }
1135  if ($status == self::STATUS_CANCELED) {
1136  $statusType = 'status6';
1137  }
1138 
1139  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1140  }
1141 
1148  public function info($id)
1149  {
1150  $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1151  $sql .= ' fk_user_creat, fk_user_modif';
1152  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1153  $sql .= ' WHERE t.rowid = '.((int) $id);
1154  $result = $this->db->query($sql);
1155  if ($result) {
1156  if ($this->db->num_rows($result)) {
1157  $obj = $this->db->fetch_object($result);
1158  $this->id = $obj->rowid;
1159 
1160  $this->user_creation_id = $obj->fk_user_creat;
1161  $this->user_modification_id = $obj->fk_user_modif;
1162  $this->date_creation = $this->db->jdate($obj->datec);
1163  $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1164  }
1165 
1166  $this->db->free($result);
1167  } else {
1168  dol_print_error($this->db);
1169  }
1170  }
1171 
1178  public function initAsSpecimen()
1179  {
1180  $this->initAsSpecimenCommon();
1181  }
1182 
1188  public function getLinesArray()
1189  {
1190  $this->lines = array();
1191 
1192  $objectline = new PartnershipLine($this->db);
1193  $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_partnership = '.((int) $this->id)));
1194 
1195  if (is_numeric($result)) {
1196  $this->error = $objectline->error;
1197  $this->errors = $objectline->errors;
1198  return $result;
1199  } else {
1200  $this->lines = $result;
1201  return $this->lines;
1202  }
1203  }
1204 
1210  public function getNextNumRef()
1211  {
1212  global $langs, $conf;
1213  $langs->load("partnership");
1214 
1215  if (empty($conf->global->PARTNERSHIP_ADDON)) {
1216  $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1217  }
1218 
1219  if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1220  $mybool = false;
1221 
1222  $file = $conf->global->PARTNERSHIP_ADDON.".php";
1223  $classname = $conf->global->PARTNERSHIP_ADDON;
1224 
1225  // Include file with class
1226  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1227  foreach ($dirmodels as $reldir) {
1228  $dir = dol_buildpath($reldir."core/modules/partnership/");
1229 
1230  // Load file with numbering class (if found)
1231  $mybool |= @include_once $dir.$file;
1232  }
1233 
1234  if ($mybool === false) {
1235  dol_print_error('', "Failed to include file ".$file);
1236  return '';
1237  }
1238 
1239  if (class_exists($classname)) {
1240  $obj = new $classname();
1241  $numref = $obj->getNextValue($this);
1242 
1243  if ($numref != '' && $numref != '-1') {
1244  return $numref;
1245  } else {
1246  $this->error = $obj->error;
1247  //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1248  return "";
1249  }
1250  } else {
1251  print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1252  return "";
1253  }
1254  } else {
1255  print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1256  return "";
1257  }
1258  }
1259 
1271  public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1272  {
1273  global $conf, $langs;
1274 
1275  $result = 0;
1276  $includedocgeneration = 0;
1277 
1278  $langs->load("partnership");
1279 
1280  if (!dol_strlen($modele)) {
1281  $modele = 'standard_partnership';
1282 
1283  if (!empty($this->model_pdf)) {
1284  $modele = $this->model_pdf;
1285  } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1286  $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1287  }
1288  }
1289 
1290  $modelpath = "core/modules/partnership/doc/";
1291 
1292  if ($includedocgeneration && !empty($modele)) {
1293  $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1294  }
1295 
1296  return $result;
1297  }
1298 
1306  public function doScheduledJob()
1307  {
1308  global $conf, $langs;
1309 
1310  //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1311 
1312  $error = 0;
1313  $this->output = '';
1314  $this->error = '';
1315 
1316  dol_syslog(__METHOD__, LOG_DEBUG);
1317 
1318  $now = dol_now();
1319 
1320  $this->db->begin();
1321 
1322  // ...
1323 
1324  $this->db->commit();
1325 
1326  return $error;
1327  }
1328 
1336  public function getKanbanView($option = '', $arraydata = null)
1337  {
1338  $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1339 
1340  $return = '<div class="box-flex-item box-flex-grow-zero">';
1341  $return .= '<div class="info-box info-box-sm">';
1342  $return .= '<span class="info-box-icon bg-infobox-action">';
1343  $return .= img_picto('', $this->picto);
1344  $return .= '</span>';
1345  $return .= '<div class="info-box-content">';
1346  $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1347  $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1348  if (property_exists($this, 'label')) {
1349  $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
1350  }
1351  if (method_exists($this, 'getLibStatut')) {
1352  $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).'</div>';
1353  }
1354  $return .= '</div>';
1355  $return .= '</div>';
1356  $return .= '</div>';
1357 
1358  return $return;
1359  }
1360 }
1361 
1362 
1363 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1364 
1369 {
1370  // To complete with content of an object PartnershipLine
1371  // We should have a field rowid, fk_partnership and position
1372 
1376  public $isextrafieldmanaged = 0;
1377 
1383  public function __construct(DoliDB $db)
1384  {
1385  $this->db = $db;
1386  }
1387 }
CommonObject\deleteCommon
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
Definition: commonobject.class.php:9539
Partnership\getTooltipContentArray
getTooltipContentArray($params)
getTooltipContentArray
Definition: partnership.class.php:953
Partnership\__construct
__construct(DoliDB $db)
Constructor.
Definition: partnership.class.php:192
CommonObject\setStatusCommon
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
Definition: commonobject.class.php:9817
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1322
CommonObject\copy_linked_contact
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
Definition: commonobject.class.php:1099
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:5096
Partnership\getNomUrl
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
Definition: partnership.class.php:979
Partnership
Class for Partnership.
Definition: partnership.class.php:32
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1157
dol_dir_list
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:62
CommonObject\fetchLinesCommon
fetchLinesCommon($morewhere='')
Load object in memory from the database.
Definition: commonobject.class.php:9385
Partnership\setDraft
setDraft($user, $notrigger=0)
Set draft status.
Definition: partnership.class.php:853
CommonObjectLine
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Definition: commonobjectline.class.php:32
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:45
Partnership\refused
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
Definition: partnership.class.php:878
Partnership\approve
approve($user, $notrigger=0)
Approve object.
Definition: partnership.class.php:728
Partnership\getLibStatut
getLibStatut($mode=0)
Return the label of the status.
Definition: partnership.class.php:1097
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:4125
Partnership\info
info($id)
Load the info information in the object.
Definition: partnership.class.php:1148
CommonObject\createCommon
createCommon(User $user, $notrigger=false)
Create object into database.
Definition: commonobject.class.php:9162
Partnership\fetchLines
fetchLines()
Load object lines in memory from the database.
Definition: partnership.class.php:456
Partnership\initAsSpecimen
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Definition: partnership.class.php:1178
$sql
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') && $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.
Definition: index.php:746
Partnership\doScheduledJob
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
Definition: partnership.class.php:1306
Partnership\generateDocument
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
Definition: partnership.class.php:1271
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1732
Partnership\validate
validate($user, $notrigger=0)
Validate object.
Definition: partnership.class.php:604
Partnership\getNextNumRef
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
Definition: partnership.class.php:1210
PartnershipLine\__construct
__construct(DoliDB $db)
Constructor.
Definition: partnership.class.php:1383
Partnership\deleteLine
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
Definition: partnership.class.php:586
CommonObject\fetch_optionals
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...
Definition: commonobject.class.php:5959
CommonObject\updateCommon
updateCommon(User $user, $notrigger=false)
Update object into database.
Definition: commonobject.class.php:9435
Partnership\create
create(User $user, $notrigger=false)
Create object into database.
Definition: partnership.class.php:243
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3987
ref
$object ref
Definition: info.php:78
getDolGlobalString
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:142
User
Class to manage Dolibarr users.
Definition: user.class.php:47
Partnership\reopen
reopen($user, $notrigger=0)
Set back to validated status.
Definition: partnership.class.php:929
Partnership\fetchAll
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
Definition: partnership.class.php:476
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10932
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4462
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:3046
Partnership\update
update(User $user, $notrigger=false)
Update object into database.
Definition: partnership.class.php:552
Partnership\getLinesArray
getLinesArray()
Create an array of lines.
Definition: partnership.class.php:1188
CommonObject\deleteLineCommon
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
Definition: commonobject.class.php:9755
Partnership\getKanbanView
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
Definition: partnership.class.php:1336
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5743
Partnership\cancel
cancel($user, $notrigger=0)
Set cancel status.
Definition: partnership.class.php:905
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:156
Partnership\createFromClone
createFromClone(User $user, $fromid)
Clone an object into another one.
Definition: partnership.class.php:261
CommonObject\getFieldList
getFieldList($alias='')
Function to concat keys of fields.
Definition: commonobject.class.php:9114
Partnership\fetch
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
Definition: partnership.class.php:364
PartnershipLine
Class PartnershipLine.
Definition: partnership.class.php:1368
Partnership\LibStatut
LibStatut($status, $mode=0)
Return the status.
Definition: partnership.class.php:1110