dolibarr 23.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 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2025 Charlene Benke <charlene@patas-monkey.com>
7 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
30// Put here all includes required by your class file
31require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
32
33
38{
42 public $module = 'partnership';
43
47 public $element = 'partnership';
48
52 public $table_element = 'partnership';
53
57 public $picto = 'partnership';
58
62 public $type_code;
66 public $type_label;
67
68
69 const STATUS_DRAFT = 0;
70 const STATUS_VALIDATED = 1; // Validate (no more draft)
71 const STATUS_APPROVED = 2; // Approved
72 const STATUS_REFUSED = 3; // Refused
73 const STATUS_CANCELED = 9;
74
75
102 // BEGIN MODULEBUILDER PROPERTIES
106 public $fields = array(
107 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
108 'ref' => array('type' => 'varchar(128)', 'label' => 'Ref', 'enabled' => 1, 'position' => 10, 'notnull' => 1, 'visible' => 4, 'noteditable' => 1, 'default' => '(PROV)', 'index' => 1, 'searchall' => 1, 'showoncombobox' => 1, 'comment' => "Reference of object", 'csslist' => 'tdoverflowmax150'),
109 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 'isModEnabled("multicompany")', 'position' => 15, 'notnull' => 1, 'visible' => -2, 'default' => '1', 'index' => 1,),
110 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label' => 'Type', 'enabled' => 1, 'position' => 20, 'notnull' => 1, 'visible' => 1, 'csslist' => 'tdoverflowmax100', 'help' => 'YouCanChangeValuesForThisListFromDictionarySetup'),
111 'fk_soc' => array('type' => 'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label' => 'ThirdParty', 'picto' => 'company', 'enabled' => 1, 'position' => 50, 'notnull' => -1, 'visible' => 1, 'index' => 1, 'css' => 'maxwidth500', 'csslist' => 'tdoverflowmax125',),
112 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0,),
113 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 0,),
114 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2, 'csslist' => 'nowraponall'),
115 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2, 'csslist' => 'nowraponall'),
116 'fk_user_creat' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserAuthor', 'enabled' => 1, 'position' => 510, 'notnull' => 1, 'visible' => -2, 'foreignkey' => 'user.rowid', 'csslist' => 'tdoverflowmax125'),
117 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2, 'csslist' => 'tdoverflowmax125'),
118 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,),
119 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
120 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
121 'date_partnership_start' => array('type' => 'date', 'label' => 'DatePartnershipStart', 'enabled' => 1, 'position' => 52, 'notnull' => 1, 'visible' => 1,),
122 'date_partnership_end' => array('type' => 'date', 'label' => 'DatePartnershipEnd', 'enabled' => 1, 'position' => 53, 'notnull' => 0, 'visible' => 1,),
123 'url_to_check' => array('type' => 'url', 'label' => 'UrlToCheck', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 70, 'notnull' => 0, 'visible' => -1, 'csslist' => 'tdoverflowmax150'),
124 'count_last_url_check_error' => array('type' => 'integer', 'label' => 'CountLastUrlCheckError', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 71, 'notnull' => 0, 'visible' => -4, 'default' => '0',),
125 'last_check_backlink' => array('type' => 'datetime', 'label' => 'LastCheckBacklink', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 72, 'notnull' => 0, 'visible' => -4, 'csslist' => 'nowraponall'),
126 'reason_decline_or_cancel' => array('type' => 'text', 'label' => 'ReasonDeclineOrCancel', 'enabled' => 1, 'position' => 73, 'notnull' => 0, 'visible' => -2,),
127 'ip' => array('type' => 'ip', 'label' => 'IPOfApplicant', 'enabled' => 1, 'position' => 74, 'notnull' => 0, 'visible' => -2,),
128 'status' => array('type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 2000, 'notnull' => 1, 'visible' => 2, 'default' => '0', 'index' => 1, 'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', 2 => 'Approved', 3 => 'Refused', 9 => 'Terminated'),),
129 );
130
134 public $rowid;
135
139 public $ref;
140
144 public $fk_type;
148 public $note_public;
152 public $note_private;
156 public $fk_user_creat;
160 public $fk_user_modif;
164 public $last_main_doc;
168 public $import_key;
172 public $model_pdf;
176 public $date_partnership_start;
180 public $date_partnership_end;
184 public $url_to_check;
188 public $count_last_url_check_error;
192 public $last_check_backlink;
196 public $reason_decline_or_cancel;
200 public $fk_soc;
204 public $fk_member;
208 public $ip;
212 public $status;
213 // END MODULEBUILDER PROPERTIES
214
215
221 public function __construct(DoliDB $db)
222 {
223 global $langs;
224
225 $this->db = $db;
226
227 $this->ismultientitymanaged = 0;
228 $this->isextrafieldmanaged = 1;
229
230 if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
231 $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', 'css' => 'maxwidth500', 'csslist' => 'tdoverflowmax150');
232 unset($this->fields['fk_soc']);
233 } else {
234 $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');
235 unset($this->fields['fk_member']);
236 }
237
238 // @phan-suppress-next-line PhanTypeMismatchProperty
239 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
240 $this->fields['rowid']['visible'] = 0;
241 }
242
243 // Unset fields that are disabled
244 foreach ($this->fields as $key => $val) {
245 if (isset($val['enabled']) && empty($val['enabled'])) {
246 unset($this->fields[$key]);
247 }
248 }
249
250 // Translate some data of arrayofkeyval
251 if (is_object($langs)) {
252 foreach ($this->fields as $key => $val) {
253 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
254 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
255 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
256 }
257 }
258 }
259 }
260 }
261
269 public function create(User $user, $notrigger = 0)
270 {
271 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
272 $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory";
273 return -1;
274 }
275
276 $this->status = 0;
277 return $this->createCommon($user, $notrigger);
278 }
279
287 public function createFromClone(User $user, $fromid)
288 {
289 global $langs, $extrafields;
290 $error = 0;
291
292 dol_syslog(__METHOD__, LOG_DEBUG);
293
294 $object = new self($this->db);
295
296 $this->db->begin();
297
298 // Load source object
299 $result = $object->fetchCommon($fromid);
300 if ($result > 0 && !empty($object->table_element_line)) {
301 $object->fetchLines();
302 }
303
304 // get lines so they will be clone
305 //foreach($this->lines as $line)
306 // $line->fetch_optionals();
307
308 // Reset some properties
309 unset($object->id);
310 unset($object->fk_user_creat);
311 unset($object->user_creation_id);
312 unset($object->import_key);
313
314 // Clear fields
315 if (property_exists($object, 'ref')) {
316 // @phan-suppress-next-line PhanTypeMismatchProperty
317 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
318 }
319 if (property_exists($object, 'status')) {
320 $object->status = self::STATUS_DRAFT;
321 }
322 if (property_exists($object, 'date_creation')) {
323 $object->date_creation = dol_now();
324 }
325 if (property_exists($object, 'date_modification')) {
326 $object->date_modification = null;
327 }
328 // ...
329 // Clear extrafields that are unique
330 if (is_array($object->array_options) && count($object->array_options) > 0) {
331 $extrafields->fetch_name_optionals_label($this->table_element);
332 foreach ($object->array_options as $key => $option) {
333 $shortkey = preg_replace('/options_/', '', $key);
334 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
335 //var_dump($key);
336 //var_dump($clonedObj->array_options[$key]); exit;
337 unset($object->array_options[$key]);
338 }
339 }
340 }
341
342 // Create clone
343 $object->context['createfromclone'] = 'createfromclone';
344 $result = $object->createCommon($user);
345 if ($result < 0) {
346 $error++;
347 $this->error = $object->error;
348 $this->errors = $object->errors;
349 }
350
351 if (!$error) {
352 // copy internal contacts
353 if ($this->copy_linked_contact($object, 'internal') < 0) {
354 $error++;
355 }
356 }
357
358 if (!$error) {
359 // copy external contacts if same company
360 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
361 if ($this->copy_linked_contact($object, 'external') < 0) {
362 $error++;
363 }
364 }
365 }
366
367 unset($object->context['createfromclone']);
368
369 // End
370 if (!$error) {
371 $this->db->commit();
372 return $object;
373 } else {
374 $this->db->rollback();
375 return -1;
376 }
377 }
378
389 public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
390 {
391 // Check parameters
392 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
393 return -1;
394 }
395
396 $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
397 $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
398 $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
399 $sql .= ', p.note_private, p.note_public, p.url_to_check';
400 $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
401 $sql .= ', p.import_key, p.model_pdf';
402 $sql .= ', pt.code as type_code, pt.label as type_label';
403 $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
404 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
405
406 if ($id) {
407 $sql .= " WHERE p.rowid = ".((int) $id);
408 } else {
409 $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Don't use entity if you use rowid
410 }
411
412 if ($ref) {
413 $sql .= " AND p.ref='".$this->db->escape($ref)."'";
414 }
415
416 if ($fk_member > 0) {
417 $sql .= ' AND p.fk_member = '.((int) $fk_member);
418 }
419 if ($fk_soc > 0) {
420 $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
421 }
422 $sql .= ' ORDER BY p.date_partnership_end DESC';
423
424 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
425 $result = $this->db->query($sql);
426 if ($result) {
427 $obj = $this->db->fetch_object($result);
428 if ($obj) {
429 $this->id = $obj->rowid;
430 $this->entity = $obj->entity;
431 $this->ref = $obj->ref;
432
433 $this->fk_type = $obj->fk_type;
434 $this->type_code = $obj->type_code;
435 $this->type_label = $obj->type_label;
436
437 $this->fk_soc = $obj->fk_soc;
438 $this->fk_member = $obj->fk_member;
439 $this->status = $obj->status;
440 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
441 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
442 $this->date_creation = $this->db->jdate($obj->date_creation);
443 $this->fk_user_creat = $obj->fk_user_creat;
444 $this->tms = $obj->tms;
445 $this->fk_user_modif = $obj->fk_user_modif;
446 $this->note_private = $obj->note_private;
447 $this->note_public = $obj->note_public;
448 $this->last_main_doc = $obj->last_main_doc;
449 $this->count_last_url_check_error = $obj->count_last_url_check_error;
450 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
451 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
452 $this->import_key = $obj->import_key;
453 $this->model_pdf = $obj->model_pdf;
454 $this->url_to_check = $obj->url_to_check;
455
456 // Retrieve all extrafield
457 // fetch optionals attributes and labels
458 $this->fetch_optionals();
459
460 $this->db->free($result);
461
462 return 1;
463 } else {
464 // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
465 return 0;
466 }
467 } else {
468 $this->error = $this->db->error();
469 return -1;
470 }
471 }
472
473
479 public function fetchLines()
480 {
481 $this->lines = array();
482
483 $result = $this->fetchLinesCommon();
484 return $result;
485 }
486
487
499 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
500 {
501 dol_syslog(__METHOD__, LOG_DEBUG);
502
503 $records = array();
504
505 $sql = 'SELECT ';
506 $sql .= $this->getFieldList('t');
507 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
508 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
509 $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
510 } else {
511 $sql .= ' WHERE 1 = 1';
512 }
513
514 // Manage filter
515 if (is_array($filter)) {
516 $sqlwhere = array();
517 if (count($filter) > 0) {
518 foreach ($filter as $key => $value) {
519 if ($key == 't.rowid') {
520 $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value);
521 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
522 $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'";
523 } elseif (strpos($value, '%') === false) {
524 $sqlwhere[] = $this->db->sanitize($key)." IN (".$this->db->sanitize($this->db->escape($value)).")";
525 } else {
526 $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
527 }
528 }
529 }
530 if (count($sqlwhere) > 0) {
531 $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
532 }
533
534 $filter = '';
535 }
536
537 // Manage filter
538 $errormessage = '';
539 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
540 if ($errormessage) {
541 $this->errors[] = $errormessage;
542 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
543 return -1;
544 }
545
546 if (!empty($sortfield)) {
547 $sql .= $this->db->order($sortfield, $sortorder);
548 }
549 if (!empty($limit)) {
550 $sql .= $this->db->plimit($limit, $offset);
551 }
552
553 $resql = $this->db->query($sql);
554 if ($resql) {
555 $num = $this->db->num_rows($resql);
556 $i = 0;
557 while ($i < ($limit ? min($limit, $num) : $num)) {
558 $obj = $this->db->fetch_object($resql);
559
560 $record = new self($this->db);
561 $record->setVarsFromFetchObj($obj);
562
563 $records[$record->id] = $record;
564
565 $i++;
566 }
567 $this->db->free($resql);
568
569 return $records;
570 } else {
571 $this->errors[] = 'Error '.$this->db->lasterror();
572 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
573
574 return -1;
575 }
576 }
577
585 public function update(User $user, $notrigger = 0)
586 {
587 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
588 $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; // Mistyping in key is in translations
589 return -1;
590 }
591 if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
592 $this->fk_user_creat = $user->id;
593 }
594
595 return $this->updateCommon($user, $notrigger);
596 }
597
605 public function delete(User $user, $notrigger = 0)
606 {
607 return $this->deleteCommon($user, $notrigger);
608 //return $this->deleteCommon($user, $notrigger, 1);
609 }
610
619 public function deleteLine(User $user, $idline, $notrigger = 0)
620 {
621 if ($this->status < 0) {
622 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
623 return -2;
624 }
625
626 return $this->deleteLineCommon($user, $idline, $notrigger);
627 }
628
629
637 public function validate($user, $notrigger = 0)
638 {
639 global $conf;
640
641 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
642
643 $error = 0;
644
645 // Protection
646 if ($this->status == self::STATUS_VALIDATED) {
647 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
648 return 0;
649 }
650
651 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
652 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->validate))))
653 {
654 $this->error='NotEnoughPermissions';
655 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
656 return -1;
657 }*/
658
659 $now = dol_now();
660
661 $this->db->begin();
662
663 // Define new ref
664 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
665 $num = $this->getNextNumRef();
666 } else {
667 $num = (string) $this->ref;
668 }
669 $this->newref = $num;
670
671 if (!empty($num)) {
672 // Validate
673 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
674 $sql .= " SET ref = '".$this->db->escape($num)."',";
675 $sql .= " status = ".self::STATUS_VALIDATED;
676 if (!empty($this->fields['date_validation'])) {
677 $sql .= ", date_validation = '".$this->db->idate($now)."'";
678 }
679 if (!empty($this->fields['fk_user_valid'])) { // @phan-suppress-current-line PhanTypeMismatchProperty
680 $sql .= ", fk_user_valid = ".((int) $user->id);
681 }
682 $sql .= " WHERE rowid = ".((int) $this->id);
683
684 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
685 $resql = $this->db->query($sql);
686 if (!$resql) {
687 dol_print_error($this->db);
688 $this->error = $this->db->lasterror();
689 $error++;
690 }
691
692 if (!$error && !$notrigger) {
693 // Call trigger
694 $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
695 if ($result < 0) {
696 $error++;
697 }
698 // End call triggers
699 }
700 }
701
702 if (!$error) {
703 $this->oldref = $this->ref;
704
705 // Rename directory if dir was a temporary ref
706 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
707 // Now we rename also files into index
708 $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)."'";
709 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
710 $resql = $this->db->query($sql);
711 if (!$resql) {
712 $error++;
713 $this->error = $this->db->lasterror();
714 }
715 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
716 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
717 $resql = $this->db->query($sql);
718 if (!$resql) {
719 $error++;
720 $this->error = $this->db->lasterror();
721 }
722
723 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
724 $oldref = dol_sanitizeFileName($this->ref);
725 $newref = dol_sanitizeFileName($num);
726 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
727 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
728 if (!$error && file_exists($dirsource)) {
729 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
730
731 if (@rename($dirsource, $dirdest)) {
732 dol_syslog("Rename ok");
733 // Rename docs starting with $oldref with $newref
734 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
735 foreach ($listoffiles as $fileentry) {
736 $dirsource = $fileentry['name'];
737 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
738 $dirsource = $fileentry['path'].'/'.$dirsource;
739 $dirdest = $fileentry['path'].'/'.$dirdest;
740 @rename($dirsource, $dirdest);
741 }
742 }
743 }
744 }
745 }
746
747 // Set new ref and current status
748 if (!$error) {
749 $this->ref = $num;
750 $this->status = self::STATUS_VALIDATED;
751 }
752
753 if (!$error) {
754 $this->db->commit();
755 return 1;
756 } else {
757 $this->db->rollback();
758 return -1;
759 }
760 }
761
769 public function approve($user, $notrigger = 0)
770 {
771 global $conf;
772
773 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
774
775 $error = 0;
776
777 // Protection
778 if ($this->status == self::STATUS_APPROVED) {
779 dol_syslog(get_class($this)."::accept action abandoned: already acceptd", LOG_WARNING);
780 return 0;
781 }
782
783 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
784 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
785 {
786 $this->error='NotEnoughPermissions';
787 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
788 return -1;
789 }*/
790
791 $now = dol_now();
792
793 $this->db->begin();
794
795 // Define new ref
796 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
797 $num = $this->getNextNumRef();
798 } else {
799 $num = (string) $this->ref;
800 }
801 $this->newref = $num;
802
803 if (!empty($num)) {
804 // Accept
805 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
806 $sql .= " SET ref = '".$this->db->escape($num)."',";
807 $sql .= " status = ".self::STATUS_APPROVED;
808 $sql .= " WHERE rowid = ".((int) $this->id);
809
810 dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
811 $resql = $this->db->query($sql);
812 if (!$resql) {
813 dol_print_error($this->db);
814 $this->error = $this->db->lasterror();
815 $error++;
816 }
817
818 if (!$error && !$notrigger) {
819 // Call trigger
820 $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
821 if ($result < 0) {
822 $error++;
823 }
824 // End call triggers
825 }
826 }
827
828 if (!$error) {
829 $this->oldref = $this->ref;
830
831 // Rename directory if dir was a temporary ref
832 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
833 // Now we rename also files into index
834 $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)."'";
835 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
836 $resql = $this->db->query($sql);
837 if (!$resql) {
838 $error++;
839 $this->error = $this->db->lasterror();
840 }
841 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
842 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
843 $resql = $this->db->query($sql);
844 if (!$resql) {
845 $error++;
846 $this->error = $this->db->lasterror();
847 }
848
849 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
850 $oldref = dol_sanitizeFileName($this->ref);
851 $newref = dol_sanitizeFileName($num);
852 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
853 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
854 if (!$error && file_exists($dirsource)) {
855 dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
856
857 if (@rename($dirsource, $dirdest)) {
858 dol_syslog("Rename ok");
859 // Rename docs starting with $oldref with $newref
860 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
861 foreach ($listoffiles as $fileentry) {
862 $dirsource = $fileentry['name'];
863 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
864 $dirsource = $fileentry['path'].'/'.$dirsource;
865 $dirdest = $fileentry['path'].'/'.$dirdest;
866 @rename($dirsource, $dirdest);
867 }
868 }
869 }
870 }
871 }
872
873 // Set new ref and current status
874 if (!$error) {
875 $this->ref = $num;
876 $this->status = self::STATUS_APPROVED;
877 }
878
879 if (!$error) {
880 $this->db->commit();
881 return 1;
882 } else {
883 $this->db->rollback();
884 return -1;
885 }
886 }
887
888
896 public function setDraft($user, $notrigger = 0)
897 {
898 // Protection
899 if ($this->status <= self::STATUS_DRAFT) {
900 return 0;
901 }
902
903 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
904 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
905 {
906 $this->error='Permission denied';
907 return -1;
908 }*/
909
910 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
911 }
912
921 public function refused($user, $reasondeclinenote = '', $notrigger = 0)
922 {
923 // Protection
924 if ($this->status == self::STATUS_REFUSED) {
925 return 0;
926 }
927
928 $this->status = self::STATUS_REFUSED;
929 $this->reason_decline_or_cancel = $reasondeclinenote;
930
931 $result = $this->update($user);
932
933 if ($result) {
934 $this->reason_decline_or_cancel = $reasondeclinenote;
935 return 1;
936 }
937
938 return -1;
939 }
940
948 public function cancel($user, $notrigger = 0)
949 {
950 // Protection
951 if ($this->status != self::STATUS_APPROVED) {
952 return 0;
953 }
954
955 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
956 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
957 {
958 $this->error='Permission denied';
959 return -1;
960 }*/
961
962 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
963 }
964
972 public function reopen($user, $notrigger = 0)
973 {
974 // Protection
975 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
976 return 0;
977 }
978
979 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
980 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
981 {
982 $this->error='Permission denied';
983 return -1;
984 }*/
985
986 return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
987 }
988
995 public function getTooltipContentArray($params)
996 {
997 global $langs;
998
999 $langs->load('partnership');
1000
1001 $datas = [];
1002 $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
1003 if (isset($this->status)) {
1004 $datas['picto'] .= ' '.$this->getLibStatut(5);
1005 }
1006 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
1007
1008 return $datas;
1009 }
1010
1021 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
1022 {
1023 global $conf, $langs, $hookmanager;
1024
1025 if (!empty($conf->dol_no_mouse_hover)) {
1026 $notooltip = 1; // Force disable tooltips
1027 }
1028
1029 $result = '';
1030 $params = [
1031 'id' => $this->id,
1032 'objecttype' => $this->element,
1033 'option' => $option,
1034 ];
1035 $classfortooltip = 'classfortooltip';
1036 $dataparams = '';
1037 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
1038 $classfortooltip = 'classforajaxtooltip';
1039 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
1040 $label = '';
1041 } else {
1042 $label = implode($this->getTooltipContentArray($params));
1043 }
1044
1045 $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
1046
1047 if ($option != 'nolink') {
1048 // Add param to save lastsearch_values or not
1049 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1050 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
1051 $add_save_lastsearch_values = 1;
1052 }
1053 if ($add_save_lastsearch_values) {
1054 $url .= '&save_lastsearch_values=1';
1055 }
1056 }
1057
1058 $linkclose = '';
1059 if (empty($notooltip)) {
1060 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
1061 $label = $langs->trans("ShowPartnership");
1062 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
1063 }
1064 $linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"');
1065 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
1066 } else {
1067 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
1068 }
1069
1070 if ($option == 'nolink') {
1071 $linkstart = '<span';
1072 } else {
1073 $linkstart = '<a href="'.$url.'"';
1074 }
1075 $linkstart .= $linkclose.'>';
1076 if ($option == 'nolink') {
1077 $linkend = '</span>';
1078 } else {
1079 $linkend = '</a>';
1080 }
1081
1082 $result .= $linkstart;
1083
1084 if (empty($this->showphoto_on_popup)) {
1085 if ($withpicto) {
1086 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
1087 }
1088 } else {
1089 if ($withpicto) {
1090 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1091
1092 list($class, $module) = explode('@', $this->picto);
1093 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1094 $filearray = dol_dir_list($upload_dir, "files");
1095 $filename = $filearray[0]['name'];
1096 if (!empty($filename)) {
1097 $pospoint = strpos($filearray[0]['name'], '.');
1098
1099 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1100 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
1101 $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>';
1102 } else {
1103 $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>';
1104 }
1105
1106 $result .= '</div>';
1107 } else {
1108 $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);
1109 }
1110 }
1111 }
1112
1113 if ($withpicto != 2) {
1114 $result .= $this->ref;
1115 }
1116
1117 $result .= $linkend;
1118 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1119
1120 global $action, $hookmanager;
1121 $hookmanager->initHooks(array('partnershipdao'));
1122 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
1123 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1124 if ($reshook > 0) {
1125 $result = $hookmanager->resPrint;
1126 } else {
1127 $result .= $hookmanager->resPrint;
1128 }
1129
1130 return $result;
1131 }
1132
1141 public static function replaceThirdparty($db, $origin_id, $dest_id)
1142 {
1143 $tables = array('partnership');
1144
1145 return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
1146 }
1147
1154 public function getLibStatut($mode = 0)
1155 {
1156 return $this->LibStatut($this->status, $mode);
1157 }
1158
1159 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1167 public function LibStatut($status, $mode = 0)
1168 {
1169 // phpcs:enable
1170
1171 // if $status is null or undefined, return empty string
1172 if (is_null($status)) {
1173 return '';
1174 }
1175
1176 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1177 global $langs;
1178 //$langs->load("partnership");
1179 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1180 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1181 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1182 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1183 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1184 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1185 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1186 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1187 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1188 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1189 }
1190
1191 $statusType = 'status'.$status;
1192 if ($status == self::STATUS_APPROVED) {
1193 $statusType = 'status4';
1194 }
1195 if ($status == self::STATUS_REFUSED) {
1196 $statusType = 'status9';
1197 }
1198 if ($status == self::STATUS_CANCELED) {
1199 $statusType = 'status6';
1200 }
1201
1202 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1203 }
1204
1211 public function info($id)
1212 {
1213 $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1214 $sql .= ' fk_user_creat, fk_user_modif';
1215 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1216 $sql .= ' WHERE t.rowid = '.((int) $id);
1217 $result = $this->db->query($sql);
1218 if ($result) {
1219 if ($this->db->num_rows($result)) {
1220 $obj = $this->db->fetch_object($result);
1221
1222 $this->id = $obj->rowid;
1223
1224 $this->user_creation_id = $obj->fk_user_creat;
1225 $this->user_modification_id = $obj->fk_user_modif;
1226 $this->date_creation = $this->db->jdate($obj->datec);
1227 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1228 }
1229
1230 $this->db->free($result);
1231 } else {
1232 dol_print_error($this->db);
1233 }
1234 }
1235
1242 public function initAsSpecimen()
1243 {
1244 return $this->initAsSpecimenCommon();
1245 }
1246
1252 public function getLinesArray()
1253 {
1254 $this->lines = array();
1255
1256 $objectline = new PartnershipLine($this->db);
1257 $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_partnership:=:'.((int) $this->id).')');
1258
1259 if (is_numeric($result)) {
1260 $this->error = $objectline->error;
1261 $this->errors = $objectline->errors;
1262 return $result;
1263 } else {
1264 $this->lines = $result;
1265 // @phpstan-ignore-next-line
1266 return $result; // @phan-suppress-current-line PhanTypeMismatchReturn
1267 }
1268 }
1269
1275 public function getNextNumRef()
1276 {
1277 global $langs, $conf;
1278 $langs->load("partnership");
1279
1280 if (!getDolGlobalString('PARTNERSHIP_ADDON')) {
1281 $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1282 }
1283
1284 if (getDolGlobalString('PARTNERSHIP_ADDON')) {
1285 $mybool = false;
1286
1287 $file = getDolGlobalString('PARTNERSHIP_ADDON') . ".php";
1288 $classname = getDolGlobalString('PARTNERSHIP_ADDON');
1289
1290 // Include file with class
1291 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1292 foreach ($dirmodels as $reldir) {
1293 $dir = dol_buildpath($reldir."core/modules/partnership/");
1294
1295 // Load file with numbering class (if found)
1296 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1297 }
1298
1299 if (!$mybool) {
1300 dol_print_error(null, "Failed to include file ".$file);
1301 return '';
1302 }
1303
1304 if (class_exists($classname)) {
1305 $obj = new $classname();
1306 '@phan-var-force ModeleNumRefPartnership $obj';
1307 $numref = $obj->getNextValue($this);
1308
1309 if ($numref != '' && $numref != '-1') {
1310 return $numref;
1311 } else {
1312 $this->error = $obj->error;
1313 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1314 return "";
1315 }
1316 } else {
1317 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1318 return "";
1319 }
1320 } else {
1321 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1322 return "";
1323 }
1324 }
1325
1337 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1338 {
1339 global $conf, $langs;
1340
1341 $result = 0;
1342 $includedocgeneration = 0;
1343
1344 $langs->load("partnership");
1345
1346 if (!dol_strlen($modele)) {
1347 $modele = 'standard_partnership';
1348
1349 if (!empty($this->model_pdf)) {
1350 $modele = $this->model_pdf;
1351 } elseif (getDolGlobalString('PARTNERSHIP_ADDON_PDF')) {
1352 $modele = getDolGlobalString('PARTNERSHIP_ADDON_PDF');
1353 }
1354 }
1355
1356 $modelpath = "core/modules/partnership/doc/";
1357
1358 if ($includedocgeneration && !empty($modele)) {
1359 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1360 }
1361
1362 return $result;
1363 }
1364
1372 public function doScheduledJob()
1373 {
1374 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1375
1376 $error = 0;
1377 $this->output = '';
1378 $this->error = '';
1379
1380 dol_syslog(__METHOD__, LOG_DEBUG);
1381
1382 //$now = dol_now();
1383
1384 $this->db->begin();
1385
1386 // ...
1387
1388 $this->db->commit();
1389
1390 return $error;
1391 }
1392
1400 public function getKanbanView($option = '', $arraydata = null)
1401 {
1402 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1403
1404 $return = '<div class="box-flex-item box-flex-grow-zero">';
1405 $return .= '<div class="info-box info-box-sm">';
1406 $return .= '<span class="info-box-icon bg-infobox-action">';
1407 $return .= img_picto('', $this->picto);
1408 $return .= '</span>';
1409 $return .= '<div class="info-box-content">';
1410 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1411 if ($selected >= 0) {
1412 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1413 }
1414 if (property_exists($this, 'label')) {
1415 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
1416 }
1417 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
1418 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
1419 }
1420 if (method_exists($this, 'getLibStatut')) {
1421 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
1422 }
1423 $return .= '</div>';
1424 $return .= '</div>';
1425 $return .= '</div>';
1426
1427 return $return;
1428 }
1429}
1430
1431
1432require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1433
1438{
1439 // To complete with content of an object PartnershipLine
1440 // We should have a field rowid, fk_partnership and position
1441
1442
1448 public function __construct(DoliDB $db)
1449 {
1450 $this->db = $db;
1451
1452 $this->isextrafieldmanaged = 0;
1453 }
1454}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$object ref
Definition info.php:90
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class for Partnership.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetchLines()
Load object lines in memory from the database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
Class PartnershipLine.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition index.php:171
dol_dir_list($utf8_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:64
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.