dolibarr  18.0.6
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  public $type_code;
66  public $type_label;
67 
68 
69  const STATUS_DRAFT = 0;
70  const STATUS_VALIDATED = 1; // Validate (no more draft)
71  const STATUS_APPROVED = 2; // Approved
72  const STATUS_REFUSED = 3; // Refused
73  const STATUS_CANCELED = 9;
74 
75 
102  // BEGIN MODULEBUILDER PROPERTIES
106  public $fields=array(
107  'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
108  '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"),
109  'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
110  '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'),
111  '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',),
112  'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
113  'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
114  'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
115  'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
116  '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',),
117  'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
118  'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
119  'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
120  'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
121  'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
122  'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
123  'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'),
124  'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-4, 'default'=>'0',),
125  'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4, 'csslist'=>'nowraponall'),
126  'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
127  'ip' => array('type'=>'varchar(250)', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
128  'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),),
129  );
130  public $rowid;
131  public $ref;
132  public $entity;
133  public $fk_type;
134  public $note_public;
135  public $note_private;
136  public $date_creation;
137  public $tms;
138  public $fk_user_creat;
139  public $fk_user_modif;
140  public $last_main_doc;
141  public $import_key;
142  public $model_pdf;
143  public $date_partnership_start;
144  public $date_partnership_end;
145  public $url_to_check;
146  public $count_last_url_check_error;
147  public $last_check_backlink;
148  public $reason_decline_or_cancel;
149  public $fk_soc;
150  public $fk_member;
151  public $ip;
152  public $status;
153  // END MODULEBUILDER PROPERTIES
154 
155 
156  // If this object has a subtable with lines
157 
158  // /**
159  // * @var string Name of subtable line
160  // */
161  // public $table_element_line = 'partnershipline';
162 
163  // /**
164  // * @var string Field with ID of parent key if this object has a parent
165  // */
166  // public $fk_element = 'fk_partnership';
167 
168  // /**
169  // * @var string Name of subtable class that manage subtable lines
170  // */
171  // public $class_element_line = 'Partnershipline';
172 
173  // /**
174  // * @var array List of child tables. To test if we can delete object.
175  // */
176  // protected $childtables = array();
177 
178  // /**
179  // * @var array List of child tables. To know object to delete on cascade.
180  // * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
181  // * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
182  // */
183  // protected $childtablesoncascade = array('partnershipdet');
184 
185  // /**
186  // * @var PartnershipLine[] Array of subtable lines
187  // */
188  // public $lines = array();
189 
190 
196  public function __construct(DoliDB $db)
197  {
198  global $conf, $langs;
199 
200  $this->db = $db;
201 
202  if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
203  $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');
204  } else {
205  $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');
206  }
207 
208  if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
209  $this->fields['rowid']['visible'] = 0;
210  }
211  // if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
212  // $this->fields['entity']['enabled'] = 0;
213  // }
214 
215  // Example to show how to set values of fields definition dynamically
216  /*if ($user->rights->partnership->read) {
217  $this->fields['myfield']['visible'] = 1;
218  $this->fields['myfield']['noteditable'] = 0;
219  }*/
220 
221  // Unset fields that are disabled
222  foreach ($this->fields as $key => $val) {
223  if (isset($val['enabled']) && empty($val['enabled'])) {
224  unset($this->fields[$key]);
225  }
226  }
227 
228  // Translate some data of arrayofkeyval
229  if (is_object($langs)) {
230  foreach ($this->fields as $key => $val) {
231  if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
232  foreach ($val['arrayofkeyval'] as $key2 => $val2) {
233  $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
234  }
235  }
236  }
237  }
238  }
239 
247  public function create(User $user, $notrigger = false)
248  {
249  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
250  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
251  return -1;
252  }
253 
254  $this->status = 0;
255  return $this->createCommon($user, $notrigger);
256  }
257 
265  public function createFromClone(User $user, $fromid)
266  {
267  global $langs, $extrafields;
268  $error = 0;
269 
270  dol_syslog(__METHOD__, LOG_DEBUG);
271 
272  $object = new self($this->db);
273 
274  $this->db->begin();
275 
276  // Load source object
277  $result = $object->fetchCommon($fromid);
278  if ($result > 0 && !empty($object->table_element_line)) {
279  $object->fetchLines();
280  }
281 
282  // get lines so they will be clone
283  //foreach($this->lines as $line)
284  // $line->fetch_optionals();
285 
286  // Reset some properties
287  unset($object->id);
288  unset($object->fk_user_creat);
289  unset($object->import_key);
290 
291  // Clear fields
292  if (property_exists($object, 'ref')) {
293  $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
294  }
295  if (property_exists($object, 'label')) {
296  $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
297  }
298  if (property_exists($object, 'status')) {
299  $object->status = self::STATUS_DRAFT;
300  }
301  if (property_exists($object, 'date_creation')) {
302  $object->date_creation = dol_now();
303  }
304  if (property_exists($object, 'date_modification')) {
305  $object->date_modification = null;
306  }
307  // ...
308  // Clear extrafields that are unique
309  if (is_array($object->array_options) && count($object->array_options) > 0) {
310  $extrafields->fetch_name_optionals_label($this->table_element);
311  foreach ($object->array_options as $key => $option) {
312  $shortkey = preg_replace('/options_/', '', $key);
313  if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
314  //var_dump($key);
315  //var_dump($clonedObj->array_options[$key]); exit;
316  unset($object->array_options[$key]);
317  }
318  }
319  }
320 
321  // Create clone
322  $object->context['createfromclone'] = 'createfromclone';
323  $result = $object->createCommon($user);
324  if ($result < 0) {
325  $error++;
326  $this->error = $object->error;
327  $this->errors = $object->errors;
328  }
329 
330  if (!$error) {
331  // copy internal contacts
332  if ($this->copy_linked_contact($object, 'internal') < 0) {
333  $error++;
334  }
335  }
336 
337  if (!$error) {
338  // copy external contacts if same company
339  if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
340  if ($this->copy_linked_contact($object, 'external') < 0) {
341  $error++;
342  }
343  }
344  }
345 
346  unset($object->context['createfromclone']);
347 
348  // End
349  if (!$error) {
350  $this->db->commit();
351  return $object;
352  } else {
353  $this->db->rollback();
354  return -1;
355  }
356  }
357 
368  public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
369  {
370  global $conf;
371 
372  // Check parameters
373  if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
374  return -1;
375  }
376 
377  $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
378  $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
379  $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
380  $sql .= ', p.note_private, p.note_public, p.url_to_check';
381  $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
382  $sql .= ', p.import_key, p.model_pdf';
383  $sql .= ', pt.code as type_code, pt.label as type_label';
384  $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
385  $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
386 
387  if ($id) {
388  $sql .= " WHERE p.rowid = ".((int) $id);
389  } else {
390  $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid
391  }
392 
393  if ($ref) {
394  $sql .= " AND p.ref='".$this->db->escape($ref)."'";
395  }
396 
397  if ($fk_member > 0) {
398  $sql .= ' AND p.fk_member = '.((int) $fk_member);
399  }
400  if ($fk_soc > 0) {
401  $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
402  }
403  $sql .= ' ORDER BY p.date_partnership_end DESC';
404 
405  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
406  $result = $this->db->query($sql);
407  if ($result) {
408  $obj = $this->db->fetch_object($result);
409  if ($obj) {
410  $this->id = $obj->rowid;
411  $this->entity = $obj->entity;
412  $this->ref = $obj->ref;
413 
414  $this->fk_type = $obj->fk_type;
415  $this->type_code = $obj->type_code;
416  $this->type_label = $obj->type_label;
417 
418  $this->fk_soc = $obj->fk_soc;
419  $this->fk_member = $obj->fk_member;
420  $this->status = $obj->status;
421  $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
422  $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
423  $this->date_creation = $this->db->jdate($obj->date_creation);
424  $this->fk_user_creat = $obj->fk_user_creat;
425  $this->tms = $obj->tms;
426  $this->fk_user_modif = $obj->fk_user_modif;
427  $this->note_private = $obj->note_private;
428  $this->note_public = $obj->note_public;
429  $this->last_main_doc = $obj->last_main_doc;
430  $this->count_last_url_check_error = $obj->count_last_url_check_error;
431  $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
432  $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
433  $this->import_key = $obj->import_key;
434  $this->model_pdf = $obj->model_pdf;
435  $this->url_to_check = $obj->url_to_check;
436 
437  // Retrieve all extrafield
438  // fetch optionals attributes and labels
439  $this->fetch_optionals();
440 
441  $this->db->free($result);
442 
443  return 1;
444  } else {
445  // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
446  return 0;
447  }
448  } else {
449  $this->error = $this->db->error();
450  return -1;
451  }
452  }
453 
454 
460  public function fetchLines()
461  {
462  $this->lines = array();
463 
464  $result = $this->fetchLinesCommon();
465  return $result;
466  }
467 
468 
480  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
481  {
482  global $conf;
483 
484  dol_syslog(__METHOD__, LOG_DEBUG);
485 
486  $records = array();
487 
488  $sql = 'SELECT ';
489  $sql .= $this->getFieldList('t');
490  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
491  if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
492  $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
493  } else {
494  $sql .= ' WHERE 1 = 1';
495  }
496  // Manage filter
497  $sqlwhere = array();
498  if (count($filter) > 0) {
499  foreach ($filter as $key => $value) {
500  if ($key == 't.rowid') {
501  $sqlwhere[] = $key." = ".((int) $value);
502  } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
503  $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
504  } elseif ($key == 'customsql') {
505  $sqlwhere[] = $value;
506  } elseif (strpos($value, '%') === false) {
507  $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
508  } else {
509  $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
510  }
511  }
512  }
513  if (count($sqlwhere) > 0) {
514  $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
515  }
516 
517  if (!empty($sortfield)) {
518  $sql .= $this->db->order($sortfield, $sortorder);
519  }
520  if (!empty($limit)) {
521  $sql .= $this->db->plimit($limit, $offset);
522  }
523 
524  $resql = $this->db->query($sql);
525  if ($resql) {
526  $num = $this->db->num_rows($resql);
527  $i = 0;
528  while ($i < ($limit ? min($limit, $num) : $num)) {
529  $obj = $this->db->fetch_object($resql);
530 
531  $record = new self($this->db);
532  $record->setVarsFromFetchObj($obj);
533 
534  $records[$record->id] = $record;
535 
536  $i++;
537  }
538  $this->db->free($resql);
539 
540  return $records;
541  } else {
542  $this->errors[] = 'Error '.$this->db->lasterror();
543  dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
544 
545  return -1;
546  }
547  }
548 
556  public function update(User $user, $notrigger = false)
557  {
558  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
559  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
560  return -1;
561  }
562  if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
563  $this->fk_user_creat = $user->id;
564  }
565 
566  return $this->updateCommon($user, $notrigger);
567  }
568 
576  public function delete(User $user, $notrigger = false)
577  {
578  return $this->deleteCommon($user, $notrigger);
579  //return $this->deleteCommon($user, $notrigger, 1);
580  }
581 
590  public function deleteLine(User $user, $idline, $notrigger = false)
591  {
592  if ($this->status < 0) {
593  $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
594  return -2;
595  }
596 
597  return $this->deleteLineCommon($user, $idline, $notrigger);
598  }
599 
600 
608  public function validate($user, $notrigger = 0)
609  {
610  global $conf, $langs;
611 
612  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
613 
614  $error = 0;
615 
616  // Protection
617  if ($this->status == self::STATUS_VALIDATED) {
618  dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
619  return 0;
620  }
621 
622  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
623  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->validate))))
624  {
625  $this->error='NotEnoughPermissions';
626  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
627  return -1;
628  }*/
629 
630  $now = dol_now();
631 
632  $this->db->begin();
633 
634  // Define new ref
635  if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
636  $num = $this->getNextNumRef();
637  } else {
638  $num = $this->ref;
639  }
640  $this->newref = $num;
641 
642  if (!empty($num)) {
643  // Validate
644  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
645  $sql .= " SET ref = '".$this->db->escape($num)."',";
646  $sql .= " status = ".self::STATUS_VALIDATED;
647  if (!empty($this->fields['date_validation'])) {
648  $sql .= ", date_validation = '".$this->db->idate($now)."'";
649  }
650  if (!empty($this->fields['fk_user_valid'])) {
651  $sql .= ", fk_user_valid = ".$user->id;
652  }
653  $sql .= " WHERE rowid = ".((int) $this->id);
654 
655  dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
656  $resql = $this->db->query($sql);
657  if (!$resql) {
658  dol_print_error($this->db);
659  $this->error = $this->db->lasterror();
660  $error++;
661  }
662 
663  if (!$error && !$notrigger) {
664  // Call trigger
665  $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
666  if ($result < 0) {
667  $error++;
668  }
669  // End call triggers
670  }
671  }
672 
673  if (!$error) {
674  $this->oldref = $this->ref;
675 
676  // Rename directory if dir was a temporary ref
677  if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
678  // Now we rename also files into index
679  $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)."'";
680  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
681  $resql = $this->db->query($sql);
682  if (!$resql) {
683  $error++; $this->error = $this->db->lasterror();
684  }
685  $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
686  $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
687  $resql = $this->db->query($sql);
688  if (!$resql) {
689  $error++; $this->error = $this->db->lasterror();
690  }
691 
692  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
693  $oldref = dol_sanitizeFileName($this->ref);
694  $newref = dol_sanitizeFileName($num);
695  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
696  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
697  if (!$error && file_exists($dirsource)) {
698  dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
699 
700  if (@rename($dirsource, $dirdest)) {
701  dol_syslog("Rename ok");
702  // Rename docs starting with $oldref with $newref
703  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
704  foreach ($listoffiles as $fileentry) {
705  $dirsource = $fileentry['name'];
706  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
707  $dirsource = $fileentry['path'].'/'.$dirsource;
708  $dirdest = $fileentry['path'].'/'.$dirdest;
709  @rename($dirsource, $dirdest);
710  }
711  }
712  }
713  }
714  }
715 
716  // Set new ref and current status
717  if (!$error) {
718  $this->ref = $num;
719  $this->status = self::STATUS_VALIDATED;
720  }
721 
722  if (!$error) {
723  $this->db->commit();
724  return 1;
725  } else {
726  $this->db->rollback();
727  return -1;
728  }
729  }
730 
738  public function approve($user, $notrigger = 0)
739  {
740  global $conf, $langs;
741 
742  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
743 
744  $error = 0;
745 
746  // Protection
747  if ($this->status == self::STATUS_APPROVED) {
748  dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING);
749  return 0;
750  }
751 
752  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
753  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
754  {
755  $this->error='NotEnoughPermissions';
756  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
757  return -1;
758  }*/
759 
760  $now = dol_now();
761 
762  $this->db->begin();
763 
764  // Define new ref
765  if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
766  $num = $this->getNextNumRef();
767  } else {
768  $num = $this->ref;
769  }
770  $this->newref = $num;
771 
772  if (!empty($num)) {
773  // Accept
774  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
775  $sql .= " SET ref = '".$this->db->escape($num)."',";
776  $sql .= " status = ".self::STATUS_APPROVED;
777  // if (!empty($this->fields['date_validation'])) {
778  // $sql .= ", date_validation = '".$this->db->idate($now)."'";
779  // }
780  // if (!empty($this->fields['fk_user_valid'])) {
781  // $sql .= ", fk_user_valid = ".$user->id;
782  // }
783  $sql .= " WHERE rowid = ".((int) $this->id);
784 
785  dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
786  $resql = $this->db->query($sql);
787  if (!$resql) {
788  dol_print_error($this->db);
789  $this->error = $this->db->lasterror();
790  $error++;
791  }
792 
793  if (!$error && !$notrigger) {
794  // Call trigger
795  $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
796  if ($result < 0) {
797  $error++;
798  }
799  // End call triggers
800  }
801  }
802 
803  if (!$error) {
804  $this->oldref = $this->ref;
805 
806  // Rename directory if dir was a temporary ref
807  if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
808  // Now we rename also files into index
809  $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)."'";
810  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
811  $resql = $this->db->query($sql);
812  if (!$resql) {
813  $error++; $this->error = $this->db->lasterror();
814  }
815  $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
816  $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
817  $resql = $this->db->query($sql);
818  if (!$resql) {
819  $error++; $this->error = $this->db->lasterror();
820  }
821 
822  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
823  $oldref = dol_sanitizeFileName($this->ref);
824  $newref = dol_sanitizeFileName($num);
825  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
826  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
827  if (!$error && file_exists($dirsource)) {
828  dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
829 
830  if (@rename($dirsource, $dirdest)) {
831  dol_syslog("Rename ok");
832  // Rename docs starting with $oldref with $newref
833  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
834  foreach ($listoffiles as $fileentry) {
835  $dirsource = $fileentry['name'];
836  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
837  $dirsource = $fileentry['path'].'/'.$dirsource;
838  $dirdest = $fileentry['path'].'/'.$dirdest;
839  @rename($dirsource, $dirdest);
840  }
841  }
842  }
843  }
844  }
845 
846  // Set new ref and current status
847  if (!$error) {
848  $this->ref = $num;
849  $this->status = self::STATUS_APPROVED;
850  }
851 
852  if (!$error) {
853  $this->db->commit();
854  return 1;
855  } else {
856  $this->db->rollback();
857  return -1;
858  }
859  }
860 
861 
869  public function setDraft($user, $notrigger = 0)
870  {
871  // Protection
872  if ($this->status <= self::STATUS_DRAFT) {
873  return 0;
874  }
875 
876  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
877  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
878  {
879  $this->error='Permission denied';
880  return -1;
881  }*/
882 
883  return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
884  }
885 
894  public function refused($user, $reasondeclinenote = '', $notrigger = 0)
895  {
896  // Protection
897  if ($this->status == self::STATUS_REFUSED) {
898  return 0;
899  }
900 
901  $this->status = self::STATUS_REFUSED;
902  $this->reason_decline_or_cancel = $reasondeclinenote;
903 
904  $result = $this->update($user);
905 
906  if ($result) {
907  $this->reason_decline_or_cancel = $reasondeclinenote;
908  return 1;
909  }
910 
911  return -1;
912  }
913 
921  public function cancel($user, $notrigger = 0)
922  {
923  // Protection
924  if ($this->status != self::STATUS_APPROVED) {
925  return 0;
926  }
927 
928  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
929  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
930  {
931  $this->error='Permission denied';
932  return -1;
933  }*/
934 
935  return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
936  }
937 
945  public function reopen($user, $notrigger = 0)
946  {
947  // Protection
948  if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
949  return 0;
950  }
951 
952  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
953  || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
954  {
955  $this->error='Permission denied';
956  return -1;
957  }*/
958 
959  return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
960  }
961 
969  public function getTooltipContentArray($params)
970  {
971  global $langs;
972 
973  $langs->load('partnership');
974 
975  $datas = [];
976  $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
977  if (isset($this->status)) {
978  $datas['picto'] .= ' '.$this->getLibStatut(5);
979  }
980  $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
981 
982  return $datas;
983  }
984 
995  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
996  {
997  global $conf, $langs, $hookmanager;
998 
999  if (!empty($conf->dol_no_mouse_hover)) {
1000  $notooltip = 1; // Force disable tooltips
1001  }
1002 
1003  $result = '';
1004  $params = [
1005  'id' => $this->id,
1006  'objecttype' => $this->element,
1007  'option' => $option,
1008  ];
1009  $classfortooltip = 'classfortooltip';
1010  $dataparams = '';
1011  if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
1012  $classfortooltip = 'classforajaxtooltip';
1013  $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
1014  $label = '';
1015  } else {
1016  $label = implode($this->getTooltipContentArray($params));
1017  }
1018 
1019  $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
1020 
1021  if ($option != 'nolink') {
1022  // Add param to save lastsearch_values or not
1023  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1024  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
1025  $add_save_lastsearch_values = 1;
1026  }
1027  if ($add_save_lastsearch_values) {
1028  $url .= '&save_lastsearch_values=1';
1029  }
1030  }
1031 
1032  $linkclose = '';
1033  if (empty($notooltip)) {
1034  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1035  $label = $langs->trans("ShowPartnership");
1036  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
1037  }
1038  $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
1039  $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
1040  } else {
1041  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
1042  }
1043 
1044  if ($option == 'nolink') {
1045  $linkstart = '<span';
1046  } else {
1047  $linkstart = '<a href="'.$url.'"';
1048  }
1049  $linkstart .= $linkclose.'>';
1050  if ($option == 'nolink') {
1051  $linkend = '</span>';
1052  } else {
1053  $linkend = '</a>';
1054  }
1055 
1056  $result .= $linkstart;
1057 
1058  if (empty($this->showphoto_on_popup)) {
1059  if ($withpicto) {
1060  $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);
1061  }
1062  } else {
1063  if ($withpicto) {
1064  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1065 
1066  list($class, $module) = explode('@', $this->picto);
1067  $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1068  $filearray = dol_dir_list($upload_dir, "files");
1069  $filename = $filearray[0]['name'];
1070  if (!empty($filename)) {
1071  $pospoint = strpos($filearray[0]['name'], '.');
1072 
1073  $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1074  if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
1075  $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>';
1076  } else {
1077  $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>';
1078  }
1079 
1080  $result .= '</div>';
1081  } else {
1082  $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);
1083  }
1084  }
1085  }
1086 
1087  if ($withpicto != 2) {
1088  $result .= $this->ref;
1089  }
1090 
1091  $result .= $linkend;
1092  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1093 
1094  global $action, $hookmanager;
1095  $hookmanager->initHooks(array('partnershipdao'));
1096  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1097  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1098  if ($reshook > 0) {
1099  $result = $hookmanager->resPrint;
1100  } else {
1101  $result .= $hookmanager->resPrint;
1102  }
1103 
1104  return $result;
1105  }
1106 
1113  public function getLibStatut($mode = 0)
1114  {
1115  return $this->LibStatut($this->status, $mode);
1116  }
1117 
1118  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1126  public function LibStatut($status, $mode = 0)
1127  {
1128  // phpcs:enable
1129  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1130  global $langs;
1131  //$langs->load("partnership");
1132  $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1133  $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1134  $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1135  $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1136  $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1137  $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1138  $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1139  $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1140  $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1141  $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1142  }
1143 
1144  $statusType = 'status'.$status;
1145  if ($status == self::STATUS_APPROVED) {
1146  $statusType = 'status4';
1147  }
1148  if ($status == self::STATUS_REFUSED) {
1149  $statusType = 'status9';
1150  }
1151  if ($status == self::STATUS_CANCELED) {
1152  $statusType = 'status6';
1153  }
1154 
1155  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1156  }
1157 
1164  public function info($id)
1165  {
1166  $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1167  $sql .= ' fk_user_creat, fk_user_modif';
1168  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1169  $sql .= ' WHERE t.rowid = '.((int) $id);
1170  $result = $this->db->query($sql);
1171  if ($result) {
1172  if ($this->db->num_rows($result)) {
1173  $obj = $this->db->fetch_object($result);
1174  $this->id = $obj->rowid;
1175 
1176  $this->user_creation_id = $obj->fk_user_creat;
1177  $this->user_modification_id = $obj->fk_user_modif;
1178  $this->date_creation = $this->db->jdate($obj->datec);
1179  $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1180  }
1181 
1182  $this->db->free($result);
1183  } else {
1184  dol_print_error($this->db);
1185  }
1186  }
1187 
1194  public function initAsSpecimen()
1195  {
1196  $this->initAsSpecimenCommon();
1197  }
1198 
1204  public function getLinesArray()
1205  {
1206  $this->lines = array();
1207 
1208  $objectline = new PartnershipLine($this->db);
1209  $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_partnership = '.((int) $this->id)));
1210 
1211  if (is_numeric($result)) {
1212  $this->error = $objectline->error;
1213  $this->errors = $objectline->errors;
1214  return $result;
1215  } else {
1216  $this->lines = $result;
1217  return $this->lines;
1218  }
1219  }
1220 
1226  public function getNextNumRef()
1227  {
1228  global $langs, $conf;
1229  $langs->load("partnership");
1230 
1231  if (empty($conf->global->PARTNERSHIP_ADDON)) {
1232  $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1233  }
1234 
1235  if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1236  $mybool = false;
1237 
1238  $file = $conf->global->PARTNERSHIP_ADDON.".php";
1239  $classname = $conf->global->PARTNERSHIP_ADDON;
1240 
1241  // Include file with class
1242  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1243  foreach ($dirmodels as $reldir) {
1244  $dir = dol_buildpath($reldir."core/modules/partnership/");
1245 
1246  // Load file with numbering class (if found)
1247  $mybool |= @include_once $dir.$file;
1248  }
1249 
1250  if ($mybool === false) {
1251  dol_print_error('', "Failed to include file ".$file);
1252  return '';
1253  }
1254 
1255  if (class_exists($classname)) {
1256  $obj = new $classname();
1257  $numref = $obj->getNextValue($this);
1258 
1259  if ($numref != '' && $numref != '-1') {
1260  return $numref;
1261  } else {
1262  $this->error = $obj->error;
1263  //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1264  return "";
1265  }
1266  } else {
1267  print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1268  return "";
1269  }
1270  } else {
1271  print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1272  return "";
1273  }
1274  }
1275 
1287  public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1288  {
1289  global $conf, $langs;
1290 
1291  $result = 0;
1292  $includedocgeneration = 0;
1293 
1294  $langs->load("partnership");
1295 
1296  if (!dol_strlen($modele)) {
1297  $modele = 'standard_partnership';
1298 
1299  if (!empty($this->model_pdf)) {
1300  $modele = $this->model_pdf;
1301  } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1302  $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1303  }
1304  }
1305 
1306  $modelpath = "core/modules/partnership/doc/";
1307 
1308  if ($includedocgeneration && !empty($modele)) {
1309  $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1310  }
1311 
1312  return $result;
1313  }
1314 
1322  public function doScheduledJob()
1323  {
1324  //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1325 
1326  $error = 0;
1327  $this->output = '';
1328  $this->error = '';
1329 
1330  dol_syslog(__METHOD__, LOG_DEBUG);
1331 
1332  //$now = dol_now();
1333 
1334  $this->db->begin();
1335 
1336  // ...
1337 
1338  $this->db->commit();
1339 
1340  return $error;
1341  }
1342 
1350  public function getKanbanView($option = '', $arraydata = null)
1351  {
1352  $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1353 
1354  $return = '<div class="box-flex-item box-flex-grow-zero">';
1355  $return .= '<div class="info-box info-box-sm">';
1356  $return .= '<span class="info-box-icon bg-infobox-action">';
1357  $return .= img_picto('', $this->picto);
1358  $return .= '</span>';
1359  $return .= '<div class="info-box-content">';
1360  $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1361  $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1362  if (property_exists($this, 'label')) {
1363  $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
1364  }
1365  if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
1366  $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
1367  }
1368  if (method_exists($this, 'getLibStatut')) {
1369  $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).'</div>';
1370  }
1371  $return .= '</div>';
1372  $return .= '</div>';
1373  $return .= '</div>';
1374 
1375  return $return;
1376  }
1377 }
1378 
1379 
1380 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1381 
1386 {
1387  // To complete with content of an object PartnershipLine
1388  // We should have a field rowid, fk_partnership and position
1389 
1393  public $isextrafieldmanaged = 0;
1394 
1400  public function __construct(DoliDB $db)
1401  {
1402  $this->db = $db;
1403  }
1404 }
$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.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
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.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
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:48
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
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
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.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.