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