dolibarr 24.0.0-beta
partnership.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
4 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2026 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 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2, 'csslist' => 'nowraponall'),
113 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2, 'csslist' => 'nowraponall'),
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', 'csslist' => 'tdoverflowmax125'),
115 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2, 'csslist' => 'tdoverflowmax125'),
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' => 60, 'notnull' => 1, 'visible' => 1,),
120 'date_partnership_end' => array('type' => 'date', 'label' => 'DatePartnershipEnd', 'enabled' => 1, 'position' => 65, 'notnull' => 0, 'visible' => 1,),
121 'url_to_check' => array('type' => 'url', 'label' => 'UrlToCheck', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 70, 'notnull' => 0, 'visible' => -1, 'csslist' => 'tdoverflowmax150'),
122 'count_last_url_check_error' => array('type' => 'integer', 'label' => 'CountLastUrlCheckError', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 71, 'notnull' => 0, 'visible' => -4, 'default' => '0',),
123 'last_check_backlink' => array('type' => 'datetime', 'label' => 'LastCheckBacklink', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 72, 'notnull' => 0, 'visible' => -4, 'csslist' => 'nowraponall'),
124 'reason_decline_or_cancel' => array('type' => 'text', 'label' => 'ReasonDeclineOrCancel', 'enabled' => 1, 'position' => 73, 'notnull' => 0, 'visible' => -2,),
125 'ip' => array('type' => 'ip', 'label' => 'IPOfApplicant', 'enabled' => 1, 'position' => 74, 'notnull' => 0, 'visible' => -2,),
126 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 0,),
127 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 81, 'notnull' => 0, 'visible' => 0,),
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++;
348 }
349
350 if (!$error) {
351 // copy internal contacts
352 if ($this->copy_linked_contact($object, 'internal') < 0) {
353 $error++;
354 }
355 }
356
357 if (!$error) {
358 // copy external contacts if same company
359 if (!empty($object->socid) && ((property_exists($this, 'fk_soc') && ($this->fk_soc == $object->socid)) || (property_exists($this, 'socid') && ($this->socid == $object->socid)))) { // @phpstan-ignore-line
360 if ($this->copy_linked_contact($object, 'external') < 0) {
361 $error++;
362 }
363 }
364 }
365
366 unset($object->context['createfromclone']);
367
368 // End
369 if (!$error) {
370 $this->db->commit();
371 return $object;
372 } else {
373 $this->db->rollback();
374 return -1;
375 }
376 }
377
388 public function fetch($id, $ref = '', $fk_member = 0, $fk_soc = 0)
389 {
390 // Check parameters
391 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
392 return -1;
393 }
394
395 $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
396 $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
397 $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
398 $sql .= ', p.note_private, p.note_public, p.url_to_check';
399 $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
400 $sql .= ', p.import_key, p.model_pdf';
401 $sql .= ', pt.code as type_code, pt.label as type_label';
402 $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
403 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
404
405 if ($id) {
406 $sql .= " WHERE p.rowid = ".((int) $id);
407 } else {
408 $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Don't use entity if you use rowid
409 }
410
411 if ($ref) {
412 $sql .= " AND p.ref='".$this->db->escape($ref)."'";
413 }
414
415 if ($fk_member > 0) {
416 $sql .= ' AND p.fk_member = '.((int) $fk_member);
417 }
418 if ($fk_soc > 0) {
419 $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
420 }
421 $sql .= ' ORDER BY p.date_partnership_end DESC';
422
423 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
424 $result = $this->db->query($sql);
425 if ($result) {
426 $obj = $this->db->fetch_object($result);
427 if ($obj) {
428 $this->id = $obj->rowid;
429 $this->entity = $obj->entity;
430 $this->ref = $obj->ref;
431
432 $this->fk_type = $obj->fk_type;
433 $this->type_code = $obj->type_code;
434 $this->type_label = $obj->type_label;
435
436 $this->fk_soc = $obj->fk_soc;
437 $this->fk_member = $obj->fk_member;
438 $this->status = $obj->status;
439 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
440 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
441 $this->date_creation = $this->db->jdate($obj->date_creation);
442 $this->fk_user_creat = $obj->fk_user_creat;
443 $this->tms = $obj->tms;
444 $this->fk_user_modif = $obj->fk_user_modif;
445 $this->note_private = $obj->note_private;
446 $this->note_public = $obj->note_public;
447 $this->last_main_doc = $obj->last_main_doc;
448 $this->count_last_url_check_error = $obj->count_last_url_check_error;
449 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
450 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
451 $this->import_key = $obj->import_key;
452 $this->model_pdf = $obj->model_pdf;
453 $this->url_to_check = $obj->url_to_check;
454
455 // Retrieve all extrafield
456 // fetch optionals attributes and labels
457 $this->fetch_optionals();
458
459 $this->db->free($result);
460
461 return 1;
462 } else {
463 // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
464 return 0;
465 }
466 } else {
467 $this->error = $this->db->error();
468 return -1;
469 }
470 }
471
472
479 public function fetchLines($noextrafields = 0)
480 {
481 $this->lines = array();
482
483 $result = $this->fetchLinesCommon('', $noextrafields);
484 return $result;
485 }
486
487
501 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
502 {
503 dol_syslog(__METHOD__, LOG_DEBUG);
504
505 $records = array();
506
507 $sql = "SELECT ";
508 $sql .= $this->getFieldList('t');
509 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
510 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
511 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
512 } else {
513 $sql .= " WHERE 1 = 1";
514 }
515
516 // Manage filter
517 if (is_array($filter)) {
518 $sqlwhere = array();
519 if (count($filter) > 0) {
520 foreach ($filter as $key => $value) {
521 if ($key == 't.rowid') {
522 $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value);
523 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
524 $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'";
525 } elseif (strpos($value, '%') === false) {
526 $sqlwhere[] = $this->db->sanitize($key)." IN (".$this->db->sanitize($this->db->escape($value)).")";
527 } else {
528 $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
529 }
530 }
531 }
532 if (count($sqlwhere) > 0) {
533 $sql .= " AND (".implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
534 }
535
536 $filter = '';
537 }
538
539 // Manage filter
540 $errormessage = '';
541 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
542 if ($errormessage) {
543 $this->errors[] = $errormessage;
544 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
545 return -1;
546 }
547
548 if (!empty($sortfield)) {
549 $sql .= $this->db->order($sortfield, $sortorder);
550 }
551 if (!empty($limit)) {
552 $sql .= $this->db->plimit($limit, $offset);
553 }
554
555 $resql = $this->db->query($sql);
556 if ($resql) {
557 $num = $this->db->num_rows($resql);
558 $i = 0;
559 while ($i < ($limit ? min($limit, $num) : $num)) {
560 $obj = $this->db->fetch_object($resql);
561
562 $record = new self($this->db);
563 $record->setVarsFromFetchObj($obj);
564
565 $record->fetch_optionals();
566
567 $records[$record->id] = $record;
568
569 $i++;
570 }
571 $this->db->free($resql);
572
573 return $records;
574 } else {
575 $this->errors[] = 'Error '.$this->db->lasterror();
576 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
577
578 return -1;
579 }
580 }
581
589 public function update(User $user, $notrigger = 0)
590 {
591 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
592 $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; // Mistyping in key is in translations
593 return -1;
594 }
595 if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
596 $this->fk_user_creat = $user->id;
597 }
598
599 return $this->updateCommon($user, $notrigger);
600 }
601
609 public function delete(User $user, $notrigger = 0)
610 {
611 return $this->deleteCommon($user, $notrigger);
612 //return $this->deleteCommon($user, $notrigger, 1);
613 }
614
623 public function deleteLine(User $user, $idline, $notrigger = 0)
624 {
625 if ($this->status < 0) {
626 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
627 return -2;
628 }
629
630 return $this->deleteLineCommon($user, $idline, $notrigger);
631 }
632
633
641 public function validate($user, $notrigger = 0)
642 {
643 global $conf;
644
645 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
646
647 $error = 0;
648
649 // Protection
650 if ($this->status == self::STATUS_VALIDATED) {
651 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
652 return 0;
653 }
654
655 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule', 'myobject', 'write'))
656 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule', 'myobject_advance', 'validate')))
657 {
658 $this->error='NotEnoughPermissions';
659 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
660 return -1;
661 }*/
662
663 $now = dol_now();
664
665 $this->db->begin();
666
667 // Define new ref
668 if (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life
669 $num = $this->getNextNumRef();
670 } else {
671 $num = (string) $this->ref;
672 }
673 $this->newref = $num;
674
675 if (!empty($num)) {
676 // Validate
677 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
678 $sql .= " SET ref = '".$this->db->escape($num)."',";
679 $sql .= " status = ".self::STATUS_VALIDATED;
680 if (!empty($this->fields['date_validation'])) {
681 $sql .= ", date_validation = '".$this->db->idate($now)."'";
682 }
683 if (!empty($this->fields['fk_user_valid'])) { // @phan-suppress-current-line PhanTypeMismatchProperty
684 $sql .= ", fk_user_valid = ".((int) $user->id);
685 }
686 $sql .= " WHERE rowid = ".((int) $this->id);
687
688 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
689 $resql = $this->db->query($sql);
690 if (!$resql) {
691 dol_print_error($this->db);
692 $this->error = $this->db->lasterror();
693 $error++;
694 }
695
696 if (!$error && !$notrigger) {
697 // Call trigger
698 $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
699 if ($result < 0) {
700 $error++;
701 }
702 // End call triggers
703 }
704 }
705
706 if (!$error) {
707 $this->oldref = $this->ref;
708
709 // Rename directory if dir was a temporary ref
710 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
711 // Now we rename also files into index
712 $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)."'";
713 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
714 $resql = $this->db->query($sql);
715 if (!$resql) {
716 $error++;
717 $this->error = $this->db->lasterror();
718 }
719 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
720 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
721 $resql = $this->db->query($sql);
722 if (!$resql) {
723 $error++;
724 $this->error = $this->db->lasterror();
725 }
726
727 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
728 $oldref = dol_sanitizeFileName($this->ref);
729 $newref = dol_sanitizeFileName($num);
730 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
731 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
732 if (!$error && file_exists($dirsource)) {
733 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
734
735 if (@rename($dirsource, $dirdest)) {
736 dol_syslog("Rename ok");
737 // Rename docs starting with $oldref with $newref
738 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
739 foreach ($listoffiles as $fileentry) {
740 $dirsource = $fileentry['name'];
741 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
742 $dirsource = $fileentry['path'].'/'.$dirsource;
743 $dirdest = $fileentry['path'].'/'.$dirdest;
744 @rename($dirsource, $dirdest);
745 }
746 }
747 }
748 }
749 }
750
751 // Set new ref and current status
752 if (!$error) {
753 $this->ref = $num;
754 $this->status = self::STATUS_VALIDATED;
755 }
756
757 if (!$error) {
758 $this->db->commit();
759 return 1;
760 } else {
761 $this->db->rollback();
762 return -1;
763 }
764 }
765
773 public function approve($user, $notrigger = 0)
774 {
775 global $conf;
776
777 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
778
779 $error = 0;
780
781 // Protection
782 if ($this->status == self::STATUS_APPROVED) {
783 dol_syslog(get_class($this)."::accept action abandoned: already acceptd", LOG_WARNING);
784 return 0;
785 }
786
787 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
788 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
789 {
790 $this->error='NotEnoughPermissions';
791 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
792 return -1;
793 }*/
794
795 $now = dol_now();
796
797 $this->db->begin();
798
799 // Define new ref
800 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
801 $num = $this->getNextNumRef();
802 } else {
803 $num = (string) $this->ref;
804 }
805 $this->newref = $num;
806
807 if (!empty($num)) {
808 // Accept
809 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
810 $sql .= " SET ref = '".$this->db->escape($num)."',";
811 $sql .= " status = ".self::STATUS_APPROVED;
812 $sql .= " WHERE rowid = ".((int) $this->id);
813
814 dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
815 $resql = $this->db->query($sql);
816 if (!$resql) {
817 dol_print_error($this->db);
818 $this->error = $this->db->lasterror();
819 $error++;
820 }
821
822 if (!$error && !$notrigger) {
823 // Call trigger
824 $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
825 if ($result < 0) {
826 $error++;
827 }
828 // End call triggers
829 }
830 }
831
832 if (!$error) {
833 $this->oldref = $this->ref;
834
835 // Rename directory if dir was a temporary ref
836 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
837 // Now we rename also files into index
838 $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)."'";
839 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
840 $resql = $this->db->query($sql);
841 if (!$resql) {
842 $error++;
843 $this->error = $this->db->lasterror();
844 }
845 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
846 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
847 $resql = $this->db->query($sql);
848 if (!$resql) {
849 $error++;
850 $this->error = $this->db->lasterror();
851 }
852
853 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
854 $oldref = dol_sanitizeFileName($this->ref);
855 $newref = dol_sanitizeFileName($num);
856 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
857 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
858 if (!$error && file_exists($dirsource)) {
859 dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
860
861 if (@rename($dirsource, $dirdest)) {
862 dol_syslog("Rename ok");
863 // Rename docs starting with $oldref with $newref
864 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
865 foreach ($listoffiles as $fileentry) {
866 $dirsource = $fileentry['name'];
867 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
868 $dirsource = $fileentry['path'].'/'.$dirsource;
869 $dirdest = $fileentry['path'].'/'.$dirdest;
870 @rename($dirsource, $dirdest);
871 }
872 }
873 }
874 }
875 }
876
877 // Set new ref and current status
878 if (!$error) {
879 $this->ref = $num;
880 $this->status = self::STATUS_APPROVED;
881 }
882
883 if (!$error) {
884 $this->db->commit();
885 return 1;
886 } else {
887 $this->db->rollback();
888 return -1;
889 }
890 }
891
892
900 public function setDraft($user, $notrigger = 0)
901 {
902 // Protection
903 if ($this->status <= self::STATUS_DRAFT) {
904 return 0;
905 }
906
907 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
908 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
909 {
910 $this->error='Permission denied';
911 return -1;
912 }*/
913
914 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
915 }
916
925 public function refused($user, $reasondeclinenote = '', $notrigger = 0)
926 {
927 // Protection
928 if ($this->status == self::STATUS_REFUSED) {
929 return 0;
930 }
931
932 $this->status = self::STATUS_REFUSED;
933 $this->reason_decline_or_cancel = $reasondeclinenote;
934
935 $result = $this->update($user);
936
937 if ($result) {
938 $this->reason_decline_or_cancel = $reasondeclinenote;
939 return 1;
940 }
941
942 return -1;
943 }
944
952 public function cancel($user, $notrigger = 0)
953 {
954 // Protection
955 if ($this->status != self::STATUS_APPROVED) {
956 return 0;
957 }
958
959 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
960 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
961 {
962 $this->error='Permission denied';
963 return -1;
964 }*/
965
966 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
967 }
968
976 public function reopen($user, $notrigger = 0)
977 {
978 // Protection
979 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
980 return 0;
981 }
982
983 /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
984 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
985 {
986 $this->error='Permission denied';
987 return -1;
988 }*/
989
990 return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
991 }
992
999 public function getTooltipContentArray($params)
1000 {
1001 global $langs;
1002
1003 $langs->load('partnership');
1004
1005 $datas = [];
1006
1007 $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
1008 if (isset($this->status)) {
1009 $datas['picto'] .= ' '.$this->getLibStatut(5);
1010 }
1011 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
1012
1013 return $datas;
1014 }
1015
1026 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
1027 {
1028 global $conf, $langs, $hookmanager;
1029
1030 if (!empty($conf->dol_no_mouse_hover)) {
1031 $notooltip = 1; // Force disable tooltips
1032 }
1033
1034 $result = '';
1035 $params = [
1036 'id' => (string) $this->id,
1037 'objecttype' => $this->element,
1038 'option' => $option,
1039 ];
1040 $classfortooltip = 'classfortooltip';
1041 $dataparams = '';
1042 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
1043 $classfortooltip = 'classforajaxtooltip';
1044 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
1045 $label = '';
1046 } else {
1047 $label = implode($this->getTooltipContentArray($params));
1048 }
1049
1050 $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
1051
1052 if ($option != 'nolink') {
1053 // Add param to save lastsearch_values or not
1054 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1055 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
1056 $add_save_lastsearch_values = 1;
1057 }
1058 if ($add_save_lastsearch_values) {
1059 $url .= '&save_lastsearch_values=1';
1060 }
1061 }
1062
1063 $linkclose = '';
1064 if (empty($notooltip)) {
1065 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
1066 $label = $langs->trans("ShowPartnership");
1067 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
1068 }
1069 $linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"');
1070 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
1071 } else {
1072 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
1073 }
1074
1075 if ($option == 'nolink') {
1076 $linkstart = '<span';
1077 } else {
1078 $linkstart = '<a href="'.$url.'"';
1079 }
1080 $linkstart .= $linkclose.'>';
1081 if ($option == 'nolink') {
1082 $linkend = '</span>';
1083 } else {
1084 $linkend = '</a>';
1085 }
1086
1087 $result .= $linkstart;
1088
1089 if (empty($this->showphoto_on_popup)) {
1090 if ($withpicto) {
1091 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
1092 }
1093 } else {
1094 if ($withpicto) {
1095 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1096
1097 list($class, $module) = explode('@', $this->picto);
1098 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1099 $filearray = dol_dir_list($upload_dir, "files");
1100 $filename = $filearray[0]['name'];
1101 if (!empty($filename)) {
1102 $pospoint = strpos($filearray[0]['name'], '.');
1103
1104 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1105 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
1106 $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>';
1107 } else {
1108 $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>';
1109 }
1110
1111 $result .= '</div>';
1112 } else {
1113 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
1114 }
1115 }
1116 }
1117
1118 if ($withpicto != 2) {
1119 $result .= $this->ref;
1120 }
1121
1122 $result .= $linkend;
1123 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1124
1125 global $action, $hookmanager;
1126 $hookmanager->initHooks(array('partnershipdao'));
1127 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
1128 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1129 if ($reshook > 0) {
1130 $result = $hookmanager->resPrint;
1131 } else {
1132 $result .= $hookmanager->resPrint;
1133 }
1134
1135 return $result;
1136 }
1137
1146 public static function replaceThirdparty($db, $origin_id, $dest_id)
1147 {
1148 $tables = array('partnership');
1149
1150 return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
1151 }
1152
1159 public function getLibStatut($mode = 0)
1160 {
1161 return $this->LibStatut($this->status, $mode);
1162 }
1163
1164 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1172 public function LibStatut($status, $mode = 0)
1173 {
1174 // phpcs:enable
1175 if (is_null($status)) {
1176 return '';
1177 }
1178
1179 $paramsBadge = array('badgeParams' => array('attr' => array(
1180 'data-status-element' => $this->element,
1181 'data-status' => (int) $status
1182 )));
1183
1184 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1185 global $langs;
1186 //$langs->load("partnership");
1187 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1188 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1189 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1190 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1191 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1192 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1193 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1194 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1195 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1196 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1197 }
1198
1199 $statusType = 'status'.$status;
1200 if ($status == self::STATUS_APPROVED) {
1201 $statusType = 'status4';
1202 }
1203 if ($status == self::STATUS_REFUSED) {
1204 $statusType = 'status9';
1205 }
1206 if ($status == self::STATUS_CANCELED) {
1207 $statusType = 'status6';
1208 }
1209
1210 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode, '', $paramsBadge);
1211 }
1212
1219 public function info($id)
1220 {
1221 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
1222 $sql .= " fk_user_creat, fk_user_modif";
1223 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
1224 $sql .= " WHERE t.rowid = ".((int) $id);
1225 $result = $this->db->query($sql);
1226 if ($result) {
1227 if ($this->db->num_rows($result)) {
1228 $obj = $this->db->fetch_object($result);
1229
1230 $this->id = $obj->rowid;
1231
1232 $this->user_creation_id = $obj->fk_user_creat;
1233 $this->user_modification_id = $obj->fk_user_modif;
1234 $this->date_creation = $this->db->jdate($obj->datec);
1235 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1236 }
1237
1238 $this->db->free($result);
1239 } else {
1240 dol_print_error($this->db);
1241 }
1242 }
1243
1250 public function initAsSpecimen()
1251 {
1252 return $this->initAsSpecimenCommon();
1253 }
1254
1260 public function getLinesArray()
1261 {
1262 $this->lines = array();
1263
1264 $objectline = new PartnershipLine($this->db);
1265 $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_partnership:=:'.((int) $this->id).')');
1266
1267 if (is_numeric($result)) {
1268 $this->error = $objectline->error;
1269 $this->errors = $objectline->errors;
1270 return $result;
1271 } else {
1272 $this->lines = $result;
1273 // @phpstan-ignore-next-line
1274 return $result; // @phan-suppress-current-line PhanTypeMismatchReturn
1275 }
1276 }
1277
1283 public function getNextNumRef()
1284 {
1285 global $langs, $conf;
1286 $langs->load("partnership");
1287
1288 if (!getDolGlobalString('PARTNERSHIP_ADDON')) {
1289 $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1290 }
1291
1292 if (getDolGlobalString('PARTNERSHIP_ADDON')) {
1293 $mybool = false;
1294
1295 $file = getDolGlobalString('PARTNERSHIP_ADDON') . ".php";
1296 $classname = getDolGlobalString('PARTNERSHIP_ADDON');
1297
1298 // Include file with class
1299 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1300 foreach ($dirmodels as $reldir) {
1301 $dir = dol_buildpath($reldir."core/modules/partnership/");
1302
1303 // Load file with numbering class (if found)
1304 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1305 }
1306
1307 if (!$mybool) {
1308 dol_print_error(null, "Failed to include file ".$file);
1309 return '';
1310 }
1311
1312 if (class_exists($classname)) {
1313 $obj = new $classname();
1314 '@phan-var-force ModeleNumRefPartnership $obj';
1315 $numref = $obj->getNextValue($this);
1316
1317 if ($numref != '' && $numref != '-1') {
1318 return $numref;
1319 } else {
1320 $this->error = $obj->error;
1321 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1322 return "";
1323 }
1324 } else {
1325 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1326 return "";
1327 }
1328 } else {
1329 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1330 return "";
1331 }
1332 }
1333
1345 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1346 {
1347 global $langs;
1348
1349 $result = 0;
1350 $includedocgeneration = 0;
1351
1352 $langs->load("partnership");
1353
1354 if (!dol_strlen($modele)) {
1355 $modele = 'standard_partnership';
1356
1357 if (!empty($this->model_pdf)) {
1358 $modele = $this->model_pdf;
1359 } elseif (getDolGlobalString('PARTNERSHIP_ADDON_PDF')) {
1360 $modele = getDolGlobalString('PARTNERSHIP_ADDON_PDF');
1361 }
1362 }
1363
1364 $modelpath = "core/modules/partnership/doc/";
1365
1366 if ($includedocgeneration && !empty($modele)) {
1367 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1368 }
1369
1370 return $result;
1371 }
1372
1380 public function doScheduledJob()
1381 {
1382 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1383
1384 $error = 0;
1385 $this->output = '';
1386 $this->error = '';
1387
1388 dol_syslog(__METHOD__." start", LOG_INFO);
1389
1390 //$now = dol_now();
1391
1392 $this->db->begin();
1393
1394 // ...
1395
1396 $this->db->commit();
1397
1398 dol_syslog(__METHOD__." end", LOG_INFO);
1399
1400 return $error;
1401 }
1402
1410 public function getKanbanView($option = '', $arraydata = null)
1411 {
1412 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1413
1414 $return = '<div class="box-flex-item box-flex-grow-zero">';
1415 $return .= '<div class="info-box info-box-sm">';
1416 $return .= '<span class="info-box-icon bg-infobox-action">';
1417 $return .= img_picto('', $this->picto);
1418 $return .= '</span>';
1419 $return .= '<div class="info-box-content">';
1420 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1421 if ($selected >= 0) {
1422 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1423 }
1424 if (property_exists($this, 'label')) {
1425 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
1426 }
1427 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
1428 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
1429 }
1430 if (method_exists($this, 'getLibStatut')) {
1431 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
1432 }
1433 $return .= '</div>';
1434 $return .= '</div>';
1435 $return .= '</div>';
1436
1437 return $return;
1438 }
1439}
1440
1441
1442require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1443
1448{
1449 // To complete with content of an object PartnershipLine
1450 // We should have a field rowid, fk_partnership and position
1451
1452
1458 public function __construct(DoliDB $db)
1459 {
1460 $this->db = $db;
1461
1462 $this->isextrafieldmanaged = 0;
1463 }
1464}
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.
setErrorsFromObject($object)
setErrorsFromObject
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()
Initialize 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.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
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.
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.
fetch($id, $ref='', $fk_member=0, $fk_soc=0)
Load object in memory from the database Get object from 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:168
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php