dolibarr  16.0.5
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 
25 // Put here all includes required by your class file
26 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
27 //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
28 //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
29 
30 
35 {
39  public $module = 'partnership';
40 
44  public $element = 'partnership';
45 
49  public $table_element = 'partnership';
50 
55  public $ismultientitymanaged = 0;
56 
60  public $isextrafieldmanaged = 1;
61 
65  public $picto = 'partnership';
66 
67 
68  const STATUS_DRAFT = 0;
69  const STATUS_VALIDATED = 1; // Validate (no more draft)
70  const STATUS_APPROVED = 2; // Approved
71  const STATUS_REFUSED = 3; // Refused
72  const STATUS_CANCELED = 9;
73 
74 
101  // BEGIN MODULEBUILDER PROPERTIES
105  public $fields=array(
106  'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
107  '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"),
108  'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
109  'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1', 'label' => 'Type', 'notnull'=>1, 'enabled' => 1, 'visible' => 1, 'position' => 20),
110  'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
111  'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
112  'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,),
113  'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2,),
114  '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',),
115  'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2,),
116  'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
117  'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
118  'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
119  'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
120  'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
121  'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),),
122  'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1),
123  'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
124  'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,),
125  'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
126  // fk_member and fk_soc are added into constructor
127  );
128 
134  public $rowid;
135 
136  public $fk_soc; // Link to thirdparty
137  public $fk_member; // Link to member
138 
139  public $tms;
140  public $fk_user_creat;
141  public $fk_user_modif;
142 
143  public $status;
144  public $date_partnership_start;
145  public $date_partnership_end;
146  public $count_last_url_check_error;
147  public $last_check_backlink;
148 
152  public $reason_decline_or_cancel;
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 (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) && 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 (empty($conf->multicompany->enabled) && 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';
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 
436  // Retrieve all extrafield
437  // fetch optionals attributes and labels
438  $this->fetch_optionals();
439 
440  $this->db->free($result);
441 
442  return 1;
443  } else {
444  // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
445  return 0;
446  }
447  } else {
448  $this->error = $this->db->error();
449  return -1;
450  }
451  }
452 
453 
459  public function fetchLines()
460  {
461  $this->lines = array();
462 
463  $result = $this->fetchLinesCommon();
464  return $result;
465  }
466 
467 
479  public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
480  {
481  global $conf;
482 
483  dol_syslog(__METHOD__, LOG_DEBUG);
484 
485  $records = array();
486 
487  $sql = 'SELECT ';
488  $sql .= $this->getFieldList('t');
489  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
490  if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
491  $sql .= ' WHERE t.entity IN ('.getEntity($this->table_element).')';
492  } else {
493  $sql .= ' WHERE 1 = 1';
494  }
495  // Manage filter
496  $sqlwhere = array();
497  if (count($filter) > 0) {
498  foreach ($filter as $key => $value) {
499  if ($key == 't.rowid') {
500  $sqlwhere[] = $key." = ".((int) $value);
501  } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
502  $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
503  } elseif ($key == 'customsql') {
504  $sqlwhere[] = $value;
505  } elseif (strpos($value, '%') === false) {
506  $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
507  } else {
508  $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
509  }
510  }
511  }
512  if (count($sqlwhere) > 0) {
513  $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
514  }
515 
516  if (!empty($sortfield)) {
517  $sql .= $this->db->order($sortfield, $sortorder);
518  }
519  if (!empty($limit)) {
520  $sql .= $this->db->plimit($limit, $offset);
521  }
522 
523  $resql = $this->db->query($sql);
524  if ($resql) {
525  $num = $this->db->num_rows($resql);
526  $i = 0;
527  while ($i < ($limit ? min($limit, $num) : $num)) {
528  $obj = $this->db->fetch_object($resql);
529 
530  $record = new self($this->db);
531  $record->setVarsFromFetchObj($obj);
532 
533  $records[$record->id] = $record;
534 
535  $i++;
536  }
537  $this->db->free($resql);
538 
539  return $records;
540  } else {
541  $this->errors[] = 'Error '.$this->db->lasterror();
542  dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
543 
544  return -1;
545  }
546  }
547 
555  public function update(User $user, $notrigger = false)
556  {
557  if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
558  $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
559  return -1;
560  }
561 
562  return $this->updateCommon($user, $notrigger);
563  }
564 
572  public function delete(User $user, $notrigger = false)
573  {
574  return $this->deleteCommon($user, $notrigger);
575  //return $this->deleteCommon($user, $notrigger, 1);
576  }
577 
586  public function deleteLine(User $user, $idline, $notrigger = false)
587  {
588  if ($this->status < 0) {
589  $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
590  return -2;
591  }
592 
593  return $this->deleteLineCommon($user, $idline, $notrigger);
594  }
595 
596 
604  public function validate($user, $notrigger = 0)
605  {
606  global $conf, $langs;
607 
608  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
609 
610  $error = 0;
611 
612  // Protection
613  if ($this->status == self::STATUS_VALIDATED) {
614  dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
615  return 0;
616  }
617 
618  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write))
619  || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->partnership_advance->validate))))
620  {
621  $this->error='NotEnoughPermissions';
622  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
623  return -1;
624  }*/
625 
626  $now = dol_now();
627 
628  $this->db->begin();
629 
630  // Define new ref
631  if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
632  $num = $this->getNextNumRef();
633  } else {
634  $num = $this->ref;
635  }
636  $this->newref = $num;
637 
638  if (!empty($num)) {
639  // Validate
640  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
641  $sql .= " SET ref = '".$this->db->escape($num)."',";
642  $sql .= " status = ".self::STATUS_VALIDATED;
643  if (!empty($this->fields['date_validation'])) {
644  $sql .= ", date_validation = '".$this->db->idate($now)."'";
645  }
646  if (!empty($this->fields['fk_user_valid'])) {
647  $sql .= ", fk_user_valid = ".$user->id;
648  }
649  $sql .= " WHERE rowid = ".((int) $this->id);
650 
651  dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
652  $resql = $this->db->query($sql);
653  if (!$resql) {
654  dol_print_error($this->db);
655  $this->error = $this->db->lasterror();
656  $error++;
657  }
658 
659  if (!$error && !$notrigger) {
660  // Call trigger
661  $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
662  if ($result < 0) {
663  $error++;
664  }
665  // End call triggers
666  }
667  }
668 
669  if (!$error) {
670  $this->oldref = $this->ref;
671 
672  // Rename directory if dir was a temporary ref
673  if (preg_match('/^[\(]?PROV/i', $this->ref)) {
674  // Now we rename also files into index
675  $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'partnership/".$this->db->escape($this->newref)."'";
676  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
677  $resql = $this->db->query($sql);
678  if (!$resql) {
679  $error++; $this->error = $this->db->lasterror();
680  }
681 
682  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
683  $oldref = dol_sanitizeFileName($this->ref);
684  $newref = dol_sanitizeFileName($num);
685  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
686  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
687  if (!$error && file_exists($dirsource)) {
688  dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
689 
690  if (@rename($dirsource, $dirdest)) {
691  dol_syslog("Rename ok");
692  // Rename docs starting with $oldref with $newref
693  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
694  foreach ($listoffiles as $fileentry) {
695  $dirsource = $fileentry['name'];
696  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
697  $dirsource = $fileentry['path'].'/'.$dirsource;
698  $dirdest = $fileentry['path'].'/'.$dirdest;
699  @rename($dirsource, $dirdest);
700  }
701  }
702  }
703  }
704  }
705 
706  // Set new ref and current status
707  if (!$error) {
708  $this->ref = $num;
709  $this->status = self::STATUS_VALIDATED;
710  }
711 
712  if (!$error) {
713  $this->db->commit();
714  return 1;
715  } else {
716  $this->db->rollback();
717  return -1;
718  }
719  }
720 
728  public function approve($user, $notrigger = 0)
729  {
730  global $conf, $langs;
731 
732  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
733 
734  $error = 0;
735 
736  // Protection
737  if ($this->status == self::STATUS_APPROVED) {
738  dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING);
739  return 0;
740  }
741 
742  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write))
743  || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->partnership_advance->accept))))
744  {
745  $this->error='NotEnoughPermissions';
746  dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
747  return -1;
748  }*/
749 
750  $now = dol_now();
751 
752  $this->db->begin();
753 
754  // Define new ref
755  if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
756  $num = $this->getNextNumRef();
757  } else {
758  $num = $this->ref;
759  }
760  $this->newref = $num;
761 
762  if (!empty($num)) {
763  // Accept
764  $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
765  $sql .= " SET ref = '".$this->db->escape($num)."',";
766  $sql .= " status = ".self::STATUS_APPROVED;
767  // if (!empty($this->fields['date_validation'])) {
768  // $sql .= ", date_validation = '".$this->db->idate($now)."'";
769  // }
770  // if (!empty($this->fields['fk_user_valid'])) {
771  // $sql .= ", fk_user_valid = ".$user->id;
772  // }
773  $sql .= " WHERE rowid = ".((int) $this->id);
774 
775  dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
776  $resql = $this->db->query($sql);
777  if (!$resql) {
778  dol_print_error($this->db);
779  $this->error = $this->db->lasterror();
780  $error++;
781  }
782 
783  if (!$error && !$notrigger) {
784  // Call trigger
785  $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
786  if ($result < 0) {
787  $error++;
788  }
789  // End call triggers
790  }
791  }
792 
793  if (!$error) {
794  $this->oldref = $this->ref;
795 
796  // Rename directory if dir was a temporary ref
797  if (preg_match('/^[\(]?PROV/i', $this->ref)) {
798  // Now we rename also files into index
799  $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'partnership/".$this->db->escape($this->newref)."'";
800  $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
801  $resql = $this->db->query($sql);
802  if (!$resql) {
803  $error++; $this->error = $this->db->lasterror();
804  }
805 
806  // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
807  $oldref = dol_sanitizeFileName($this->ref);
808  $newref = dol_sanitizeFileName($num);
809  $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
810  $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
811  if (!$error && file_exists($dirsource)) {
812  dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
813 
814  if (@rename($dirsource, $dirdest)) {
815  dol_syslog("Rename ok");
816  // Rename docs starting with $oldref with $newref
817  $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
818  foreach ($listoffiles as $fileentry) {
819  $dirsource = $fileentry['name'];
820  $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
821  $dirsource = $fileentry['path'].'/'.$dirsource;
822  $dirdest = $fileentry['path'].'/'.$dirdest;
823  @rename($dirsource, $dirdest);
824  }
825  }
826  }
827  }
828  }
829 
830  // Set new ref and current status
831  if (!$error) {
832  $this->ref = $num;
833  $this->status = self::STATUS_APPROVED;
834  }
835 
836  if (!$error) {
837  $this->db->commit();
838  return 1;
839  } else {
840  $this->db->rollback();
841  return -1;
842  }
843  }
844 
845 
853  public function setDraft($user, $notrigger = 0)
854  {
855  // Protection
856  if ($this->status <= self::STATUS_DRAFT) {
857  return 0;
858  }
859 
860  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write))
861  || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate))))
862  {
863  $this->error='Permission denied';
864  return -1;
865  }*/
866 
867  return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
868  }
869 
878  public function refused($user, $reasondeclinenote = '', $notrigger = 0)
879  {
880  // Protection
881  if ($this->status == self::STATUS_REFUSED) {
882  return 0;
883  }
884 
885  $this->status = self::STATUS_REFUSED;
886  $this->reason_decline_or_cancel = $reasondeclinenote;
887 
888  $result = $this->update($user);
889 
890  if ($result) {
891  $this->reason_decline_or_cancel = $reasondeclinenote;
892  return 1;
893  }
894 
895  return -1;
896  }
897 
905  public function cancel($user, $notrigger = 0)
906  {
907  // Protection
908  if ($this->status != self::STATUS_APPROVED) {
909  return 0;
910  }
911 
912  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write))
913  || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate))))
914  {
915  $this->error='Permission denied';
916  return -1;
917  }*/
918 
919  return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
920  }
921 
929  public function reopen($user, $notrigger = 0)
930  {
931  // Protection
932  if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
933  return 0;
934  }
935 
936  /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership->write))
937  || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->partnership_advance->validate))))
938  {
939  $this->error='Permission denied';
940  return -1;
941  }*/
942 
943  return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
944  }
945 
956  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
957  {
958  global $conf, $langs, $hookmanager;
959 
960  if (!empty($conf->dol_no_mouse_hover)) {
961  $notooltip = 1; // Force disable tooltips
962  }
963 
964  $result = '';
965 
966  $label = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
967  if (isset($this->status)) {
968  $label .= ' '.$this->getLibStatut(5);
969  }
970  $label .= '<br>';
971  $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
972 
973  $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
974 
975  if ($option != 'nolink') {
976  // Add param to save lastsearch_values or not
977  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
978  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
979  $add_save_lastsearch_values = 1;
980  }
981  if ($add_save_lastsearch_values) {
982  $url .= '&save_lastsearch_values=1';
983  }
984  }
985 
986  $linkclose = '';
987  if (empty($notooltip)) {
988  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
989  $label = $langs->trans("ShowPartnership");
990  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
991  }
992  $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
993  $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
994  } else {
995  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
996  }
997 
998  if ($option == 'nolink') {
999  $linkstart = '<span';
1000  } else {
1001  $linkstart = '<a href="'.$url.'"';
1002  }
1003  $linkstart .= $linkclose.'>';
1004  if ($option == 'nolink') {
1005  $linkend = '</span>';
1006  } else {
1007  $linkend = '</a>';
1008  }
1009 
1010  $result .= $linkstart;
1011 
1012  if (empty($this->showphoto_on_popup)) {
1013  if ($withpicto) {
1014  $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);
1015  }
1016  } else {
1017  if ($withpicto) {
1018  require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1019 
1020  list($class, $module) = explode('@', $this->picto);
1021  $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1022  $filearray = dol_dir_list($upload_dir, "files");
1023  $filename = $filearray[0]['name'];
1024  if (!empty($filename)) {
1025  $pospoint = strpos($filearray[0]['name'], '.');
1026 
1027  $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1028  if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) {
1029  $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>';
1030  } else {
1031  $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>';
1032  }
1033 
1034  $result .= '</div>';
1035  } else {
1036  $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);
1037  }
1038  }
1039  }
1040 
1041  if ($withpicto != 2) {
1042  $result .= $this->ref;
1043  }
1044 
1045  $result .= $linkend;
1046  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1047 
1048  global $action, $hookmanager;
1049  $hookmanager->initHooks(array('partnershipdao'));
1050  $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1051  $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1052  if ($reshook > 0) {
1053  $result = $hookmanager->resPrint;
1054  } else {
1055  $result .= $hookmanager->resPrint;
1056  }
1057 
1058  return $result;
1059  }
1060 
1067  public function getLibStatut($mode = 0)
1068  {
1069  return $this->LibStatut($this->status, $mode);
1070  }
1071 
1072  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1080  public function LibStatut($status, $mode = 0)
1081  {
1082  // phpcs:enable
1083  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1084  global $langs;
1085  //$langs->load("partnership");
1086  $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1087  $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1088  $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1089  $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1090  $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1091  $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1092  $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1093  $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1094  $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1095  $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1096  }
1097 
1098  $statusType = 'status'.$status;
1099  if ($status == self::STATUS_APPROVED) {
1100  $statusType = 'status4';
1101  }
1102  if ($status == self::STATUS_REFUSED) {
1103  $statusType = 'status9';
1104  }
1105  if ($status == self::STATUS_CANCELED) {
1106  $statusType = 'status6';
1107  }
1108 
1109  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1110  }
1111 
1118  public function info($id)
1119  {
1120  $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1121  $sql .= ' fk_user_creat, fk_user_modif';
1122  $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1123  $sql .= ' WHERE t.rowid = '.((int) $id);
1124  $result = $this->db->query($sql);
1125  if ($result) {
1126  if ($this->db->num_rows($result)) {
1127  $obj = $this->db->fetch_object($result);
1128  $this->id = $obj->rowid;
1129 
1130  $this->user_creation_id = $obj->fk_user_creat;
1131  $this->user_modification_id = $obj->fk_user_modif;
1132  $this->date_creation = $this->db->jdate($obj->datec);
1133  $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1134  }
1135 
1136  $this->db->free($result);
1137  } else {
1138  dol_print_error($this->db);
1139  }
1140  }
1141 
1148  public function initAsSpecimen()
1149  {
1150  $this->initAsSpecimenCommon();
1151  }
1152 
1158  public function getLinesArray()
1159  {
1160  $this->lines = array();
1161 
1162  $objectline = new PartnershipLine($this->db);
1163  $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_partnership = '.((int) $this->id)));
1164 
1165  if (is_numeric($result)) {
1166  $this->error = $this->error;
1167  $this->errors = $this->errors;
1168  return $result;
1169  } else {
1170  $this->lines = $result;
1171  return $this->lines;
1172  }
1173  }
1174 
1180  public function getNextNumRef()
1181  {
1182  global $langs, $conf;
1183  $langs->load("partnership");
1184 
1185  if (empty($conf->global->PARTNERSHIP_ADDON)) {
1186  $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1187  }
1188 
1189  if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1190  $mybool = false;
1191 
1192  $file = $conf->global->PARTNERSHIP_ADDON.".php";
1193  $classname = $conf->global->PARTNERSHIP_ADDON;
1194 
1195  // Include file with class
1196  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1197  foreach ($dirmodels as $reldir) {
1198  $dir = dol_buildpath($reldir."core/modules/partnership/");
1199 
1200  // Load file with numbering class (if found)
1201  $mybool |= @include_once $dir.$file;
1202  }
1203 
1204  if ($mybool === false) {
1205  dol_print_error('', "Failed to include file ".$file);
1206  return '';
1207  }
1208 
1209  if (class_exists($classname)) {
1210  $obj = new $classname();
1211  $numref = $obj->getNextValue($this);
1212 
1213  if ($numref != '' && $numref != '-1') {
1214  return $numref;
1215  } else {
1216  $this->error = $obj->error;
1217  //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1218  return "";
1219  }
1220  } else {
1221  print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1222  return "";
1223  }
1224  } else {
1225  print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1226  return "";
1227  }
1228  }
1229 
1241  public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1242  {
1243  global $conf, $langs;
1244 
1245  $result = 0;
1246  $includedocgeneration = 0;
1247 
1248  $langs->load("partnership");
1249 
1250  if (!dol_strlen($modele)) {
1251  $modele = 'standard_partnership';
1252 
1253  if (!empty($this->model_pdf)) {
1254  $modele = $this->model_pdf;
1255  } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1256  $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1257  }
1258  }
1259 
1260  $modelpath = "core/modules/partnership/doc/";
1261 
1262  if ($includedocgeneration && !empty($modele)) {
1263  $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1264  }
1265 
1266  return $result;
1267  }
1268 
1276  public function doScheduledJob()
1277  {
1278  global $conf, $langs;
1279 
1280  //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1281 
1282  $error = 0;
1283  $this->output = '';
1284  $this->error = '';
1285 
1286  dol_syslog(__METHOD__, LOG_DEBUG);
1287 
1288  $now = dol_now();
1289 
1290  $this->db->begin();
1291 
1292  // ...
1293 
1294  $this->db->commit();
1295 
1296  return $error;
1297  }
1298 }
1299 
1300 
1301 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1302 
1307 {
1308  // To complete with content of an object PartnershipLine
1309  // We should have a field rowid, fk_partnership and position
1310 
1314  public $isextrafieldmanaged = 0;
1315 
1321  public function __construct(DoliDB $db)
1322  {
1323  $this->db = $db;
1324  }
1325 }
CommonObject\deleteCommon
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
Definition: commonobject.class.php:9406
Partnership\__construct
__construct(DoliDB $db)
Constructor.
Definition: partnership.class.php:196
CommonObject\setStatusCommon
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
Definition: commonobject.class.php:9683
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:1226
CommonObject\copy_linked_contact
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
Definition: commonobject.class.php:1217
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:4844
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:956
Partnership
Class for Partnership.
Definition: partnership.class.php:34
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
CommonObject\fetchLinesCommon
fetchLinesCommon($morewhere='')
Load object in memory from the database.
Definition: commonobject.class.php:9258
ref
$object ref
Definition: info.php:77
Partnership\setDraft
setDraft($user, $notrigger=0)
Set draft status.
Definition: partnership.class.php:853
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)
Scan a directory and return a list of files/directories.
Definition: files.lib.php:60
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:878
Partnership\approve
approve($user, $notrigger=0)
Approve object.
Definition: partnership.class.php:728
Partnership\getLibStatut
getLibStatut($mode=0)
Return the label of the status.
Definition: partnership.class.php:1067
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:3880
Partnership\info
info($id)
Load the info information in the object.
Definition: partnership.class.php:1118
CommonObject\createCommon
createCommon(User $user, $notrigger=false)
Create object into database.
Definition: commonobject.class.php:9035
Partnership\fetchLines
fetchLines()
Load object lines in memory from the database.
Definition: partnership.class.php:459
Partnership\initAsSpecimen
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
Definition: partnership.class.php:1148
Partnership\doScheduledJob
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
Definition: partnership.class.php:1276
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:1241
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
Partnership\validate
validate($user, $notrigger=0)
Validate object.
Definition: partnership.class.php:604
Partnership\getNextNumRef
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
Definition: partnership.class.php:1180
PartnershipLine\__construct
__construct(DoliDB $db)
Constructor.
Definition: partnership.class.php:1321
Partnership\deleteLine
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
Definition: partnership.class.php:586
CommonObject\fetch_optionals
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
Definition: commonobject.class.php:6007
CommonObject\updateCommon
updateCommon(User $user, $notrigger=false)
Update object into database.
Definition: commonobject.class.php:9308
Partnership\create
create(User $user, $notrigger=false)
Create object into database.
Definition: partnership.class.php:247
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
dol_strlen
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
Definition: functions.lib.php:3747
User
Class to manage Dolibarr users.
Definition: user.class.php:44
Partnership\reopen
reopen($user, $notrigger=0)
Set back to validated status.
Definition: partnership.class.php:929
Partnership\fetchAll
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
Definition: partnership.class.php:479
dolGetStatus
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
Definition: functions.lib.php:10338
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:4211
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
Partnership\update
update(User $user, $notrigger=false)
Update object into database.
Definition: partnership.class.php:555
Partnership\getLinesArray
getLinesArray()
Create an array of lines.
Definition: partnership.class.php:1158
CommonObject\deleteLineCommon
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
Definition: commonobject.class.php:9622
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5791
Partnership\cancel
cancel($user, $notrigger=0)
Set cancel status.
Definition: partnership.class.php:905
Partnership\createFromClone
createFromClone(User $user, $fromid)
Clone an object into another one.
Definition: partnership.class.php:265
CommonObject\getFieldList
getFieldList($alias='')
Function to concat keys of fields.
Definition: commonobject.class.php:8987
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:368
PartnershipLine
Class PartnershipLine.
Definition: partnership.class.php:1306
Partnership\LibStatut
LibStatut($status, $mode=0)
Return the status.
Definition: partnership.class.php:1080