dolibarr 25.0.0-alpha
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' => -2, '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 unset($object->context['createfromclone']);
358
359 // End
360 if (!$error) {
361 $this->db->commit();
362 return $object;
363 } else {
364 $this->db->rollback();
365 return -1;
366 }
367 }
368
379 public function fetch($id, $ref = '', $fk_member = 0, $fk_soc = 0)
380 {
381 // Check parameters
382 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
383 return -1;
384 }
385
386 $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
387 $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
388 $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
389 $sql .= ', p.note_private, p.note_public, p.url_to_check';
390 $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
391 $sql .= ', p.import_key, p.model_pdf';
392 $sql .= ', pt.code as type_code, pt.label as type_label';
393 $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
394 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
395
396 if ($id) {
397 $sql .= " WHERE p.rowid = ".((int) $id);
398 } else {
399 $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Don't use entity if you use rowid
400 }
401
402 if ($ref) {
403 $sql .= " AND p.ref='".$this->db->escape($ref)."'";
404 }
405
406 if ($fk_member > 0) {
407 $sql .= ' AND p.fk_member = '.((int) $fk_member);
408 }
409 if ($fk_soc > 0) {
410 $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
411 }
412 $sql .= ' ORDER BY p.date_partnership_end DESC';
413
414 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
415 $result = $this->db->query($sql);
416 if ($result) {
417 $obj = $this->db->fetch_object($result);
418 if ($obj) {
419 $this->id = $obj->rowid;
420 $this->entity = $obj->entity;
421 $this->ref = $obj->ref;
422
423 $this->fk_type = $obj->fk_type;
424 $this->type_code = $obj->type_code;
425 $this->type_label = $obj->type_label;
426
427 $this->fk_soc = $obj->fk_soc;
428 $this->fk_member = $obj->fk_member;
429 $this->status = $obj->status;
430 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
431 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
432 $this->date_creation = $this->db->jdate($obj->date_creation);
433 $this->fk_user_creat = $obj->fk_user_creat;
434 $this->tms = $obj->tms;
435 $this->fk_user_modif = $obj->fk_user_modif;
436 $this->note_private = $obj->note_private;
437 $this->note_public = $obj->note_public;
438 $this->last_main_doc = $obj->last_main_doc;
439 $this->count_last_url_check_error = $obj->count_last_url_check_error;
440 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
441 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
442 $this->import_key = $obj->import_key;
443 $this->model_pdf = $obj->model_pdf;
444 $this->url_to_check = $obj->url_to_check;
445
446 // Retrieve all extrafield
447 // fetch optionals attributes and labels
448 $this->fetch_optionals();
449
450 $this->db->free($result);
451
452 return 1;
453 } else {
454 // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
455 return 0;
456 }
457 } else {
458 $this->error = $this->db->error();
459 return -1;
460 }
461 }
462
463
470 public function fetchLines($noextrafields = 0)
471 {
472 $this->lines = array();
473
474 $result = $this->fetchLinesCommon('', $noextrafields);
475 return $result;
476 }
477
478
492 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
493 {
494 dol_syslog(__METHOD__, LOG_DEBUG);
495
496 $records = array();
497
498 $sql = "SELECT ";
499 $sql .= $this->getFieldList('t');
500 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
501 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
502 $sql .= " WHERE t.entity IN (".getEntity($this->element).")";
503 } else {
504 $sql .= " WHERE 1 = 1";
505 }
506
507 // Manage filter
508 if (is_array($filter)) {
509 $sqlwhere = array();
510 if (count($filter) > 0) {
511 foreach ($filter as $key => $value) {
512 if ($key == 't.rowid') {
513 $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value);
514 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
515 $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'";
516 } elseif (strpos($value, '%') === false) {
517 $sqlwhere[] = $this->db->sanitize($key)." IN (".$this->db->sanitize($this->db->escape($value)).")";
518 } else {
519 $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
520 }
521 }
522 }
523 if (count($sqlwhere) > 0) {
524 $sql .= " AND (".implode(' '.$this->db->sanitize($filtermode).' ', $sqlwhere).')';
525 }
526
527 $filter = '';
528 }
529
530 // Manage filter
531 $errormessage = '';
532 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
533 if ($errormessage) {
534 $this->errors[] = $errormessage;
535 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
536 return -1;
537 }
538
539 if (!empty($sortfield)) {
540 $sql .= $this->db->order($sortfield, $sortorder);
541 }
542 if (!empty($limit)) {
543 $sql .= $this->db->plimit($limit, $offset);
544 }
545
546 $resql = $this->db->query($sql);
547 if ($resql) {
548 $num = $this->db->num_rows($resql);
549 $i = 0;
550 while ($i < ($limit ? min($limit, $num) : $num)) {
551 $obj = $this->db->fetch_object($resql);
552
553 $record = new self($this->db);
554 $record->setVarsFromFetchObj($obj);
555
556 $record->fetch_optionals();
557
558 $records[$record->id] = $record;
559
560 $i++;
561 }
562 $this->db->free($resql);
563
564 return $records;
565 } else {
566 $this->errors[] = 'Error '.$this->db->lasterror();
567 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
568
569 return -1;
570 }
571 }
572
580 public function update(User $user, $notrigger = 0)
581 {
582 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
583 $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; // Mistyping in key is in translations
584 return -1;
585 }
586 if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
587 $this->fk_user_creat = $user->id;
588 }
589
590 return $this->updateCommon($user, $notrigger);
591 }
592
600 public function delete(User $user, $notrigger = 0)
601 {
602 return $this->deleteCommon($user, $notrigger);
603 //return $this->deleteCommon($user, $notrigger, 1);
604 }
605
614 public function deleteLine(User $user, $idline, $notrigger = 0)
615 {
616 if ($this->status < 0) {
617 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
618 return -2;
619 }
620
621 return $this->deleteLineCommon($user, $idline, $notrigger);
622 }
623
624
632 public function validate($user, $notrigger = 0)
633 {
634 global $conf;
635
636 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
637
638 $error = 0;
639
640 // Protection
641 if ($this->status == self::STATUS_VALIDATED) {
642 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
643 return 0;
644 }
645
646 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule', 'myobject', 'write'))
647 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule', 'myobject_advance', 'validate')))
648 {
649 $this->error='NotEnoughPermissions';
650 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
651 return -1;
652 }*/
653
654 $now = dol_now();
655
656 $this->db->begin();
657
658 // Define new ref
659 if (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref)) { // empty should not happened, but when it occurs, the test save life
660 $num = $this->getNextNumRef();
661 } else {
662 $num = (string) $this->ref;
663 }
664 $this->newref = $num;
665
666 if (!empty($num)) {
667 // Validate
668 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
669 $sql .= " SET ref = '".$this->db->escape($num)."',";
670 $sql .= " status = ".self::STATUS_VALIDATED;
671 if (!empty($this->fields['date_validation'])) {
672 $sql .= ", date_validation = '".$this->db->idate($now)."'";
673 }
674 if (!empty($this->fields['fk_user_valid'])) { // @phan-suppress-current-line PhanTypeMismatchProperty
675 $sql .= ", fk_user_valid = ".((int) $user->id);
676 }
677 $sql .= " WHERE rowid = ".((int) $this->id);
678
679 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
680 $resql = $this->db->query($sql);
681 if (!$resql) {
682 dol_print_error($this->db);
683 $this->error = $this->db->lasterror();
684 $error++;
685 }
686
687 if (!$error && !$notrigger) {
688 // Call trigger
689 $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
690 if ($result < 0) {
691 $error++;
692 }
693 // End call triggers
694 }
695 }
696
697 if (!$error) {
698 $this->oldref = $this->ref;
699
700 // Rename directory if dir was a temporary ref
701 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
702 // Now we rename also files into index
703 $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)."'";
704 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
705 $resql = $this->db->query($sql);
706 if (!$resql) {
707 $error++;
708 $this->error = $this->db->lasterror();
709 }
710 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
711 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
712 $resql = $this->db->query($sql);
713 if (!$resql) {
714 $error++;
715 $this->error = $this->db->lasterror();
716 }
717
718 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
719 $oldref = dol_sanitizeFileName($this->ref);
720 $newref = dol_sanitizeFileName($num);
721 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
722 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
723 if (!$error && file_exists($dirsource)) {
724 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
725
726 if (@rename($dirsource, $dirdest)) {
727 dol_syslog("Rename ok");
728 // Rename docs starting with $oldref with $newref
729 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
730 foreach ($listoffiles as $fileentry) {
731 $dirsource = $fileentry['name'];
732 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
733 $dirsource = $fileentry['path'].'/'.$dirsource;
734 $dirdest = $fileentry['path'].'/'.$dirdest;
735 @rename($dirsource, $dirdest);
736 }
737 }
738 }
739 }
740 }
741
742 // Set new ref and current status
743 if (!$error) {
744 $this->ref = $num;
745 $this->status = self::STATUS_VALIDATED;
746 }
747
748 if (!$error) {
749 $this->db->commit();
750 return 1;
751 } else {
752 $this->db->rollback();
753 return -1;
754 }
755 }
756
764 public function approve($user, $notrigger = 0)
765 {
766 global $conf;
767
768 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
769
770 $error = 0;
771
772 // Protection
773 if ($this->status == self::STATUS_APPROVED) {
774 dol_syslog(get_class($this)."::accept action abandoned: already acceptd", LOG_WARNING);
775 return 0;
776 }
777
778 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
779 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
780 {
781 $this->error='NotEnoughPermissions';
782 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
783 return -1;
784 }*/
785
786 $now = dol_now();
787
788 $this->db->begin();
789
790 // Define new ref
791 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
792 $num = $this->getNextNumRef();
793 } else {
794 $num = (string) $this->ref;
795 }
796 $this->newref = $num;
797
798 if (!empty($num)) {
799 // Accept
800 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
801 $sql .= " SET ref = '".$this->db->escape($num)."',";
802 $sql .= " status = ".self::STATUS_APPROVED;
803 $sql .= " WHERE rowid = ".((int) $this->id);
804
805 dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
806 $resql = $this->db->query($sql);
807 if (!$resql) {
808 dol_print_error($this->db);
809 $this->error = $this->db->lasterror();
810 $error++;
811 }
812
813 if (!$error && !$notrigger) {
814 // Call trigger
815 $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
816 if ($result < 0) {
817 $error++;
818 }
819 // End call triggers
820 }
821 }
822
823 if (!$error) {
824 $this->oldref = $this->ref;
825
826 // Rename directory if dir was a temporary ref
827 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
828 // Now we rename also files into index
829 $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)."'";
830 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
831 $resql = $this->db->query($sql);
832 if (!$resql) {
833 $error++;
834 $this->error = $this->db->lasterror();
835 }
836 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
837 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".((int) $conf->entity);
838 $resql = $this->db->query($sql);
839 if (!$resql) {
840 $error++;
841 $this->error = $this->db->lasterror();
842 }
843
844 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
845 $oldref = dol_sanitizeFileName($this->ref);
846 $newref = dol_sanitizeFileName($num);
847 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
848 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
849 if (!$error && file_exists($dirsource)) {
850 dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
851
852 if (@rename($dirsource, $dirdest)) {
853 dol_syslog("Rename ok");
854 // Rename docs starting with $oldref with $newref
855 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
856 foreach ($listoffiles as $fileentry) {
857 $dirsource = $fileentry['name'];
858 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
859 $dirsource = $fileentry['path'].'/'.$dirsource;
860 $dirdest = $fileentry['path'].'/'.$dirdest;
861 @rename($dirsource, $dirdest);
862 }
863 }
864 }
865 }
866 }
867
868 // Set new ref and current status
869 if (!$error) {
870 $this->ref = $num;
871 $this->status = self::STATUS_APPROVED;
872 }
873
874 if (!$error) {
875 $this->db->commit();
876 return 1;
877 } else {
878 $this->db->rollback();
879 return -1;
880 }
881 }
882
883
891 public function setDraft($user, $notrigger = 0)
892 {
893 // Protection
894 if ($this->status <= self::STATUS_DRAFT) {
895 return 0;
896 }
897
898 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
899 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
900 {
901 $this->error='Permission denied';
902 return -1;
903 }*/
904
905 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
906 }
907
916 public function refused($user, $reasondeclinenote = '', $notrigger = 0)
917 {
918 // Protection
919 if ($this->status == self::STATUS_REFUSED) {
920 return 0;
921 }
922
923 $this->status = self::STATUS_REFUSED;
924 $this->reason_decline_or_cancel = $reasondeclinenote;
925
926 $result = $this->update($user);
927
928 if ($result) {
929 $this->reason_decline_or_cancel = $reasondeclinenote;
930 return 1;
931 }
932
933 return -1;
934 }
935
943 public function cancel($user, $notrigger = 0)
944 {
945 // Protection
946 if ($this->status != self::STATUS_APPROVED) {
947 return 0;
948 }
949
950 /* if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
951 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
952 {
953 $this->error='Permission denied';
954 return -1;
955 }*/
956
957 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
958 }
959
967 public function reopen($user, $notrigger = 0)
968 {
969 // Protection
970 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
971 return 0;
972 }
973
974 /*if (! ((!getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','write'))
975 || (getDolGlobalInt('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('mymodule','mymodule_advance','validate'))))
976 {
977 $this->error='Permission denied';
978 return -1;
979 }*/
980
981 return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
982 }
983
990 public function getTooltipContentArray($params)
991 {
992 global $langs;
993
994 $langs->load('partnership');
995
996 $datas = [];
997
998 $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
999 if (isset($this->status)) {
1000 $datas['picto'] .= ' '.$this->getLibStatut(5);
1001 }
1002 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
1003
1004 return $datas;
1005 }
1006
1017 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
1018 {
1019 global $conf, $langs, $hookmanager;
1020
1021 if (!empty($conf->dol_no_mouse_hover)) {
1022 $notooltip = 1; // Force disable tooltips
1023 }
1024
1025 $result = '';
1026 $params = [
1027 'id' => (string) $this->id,
1028 'objecttype' => $this->element,
1029 'option' => $option,
1030 ];
1031 $classfortooltip = 'classfortooltip';
1032 $dataparams = '';
1033 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
1034 $classfortooltip = 'classforajaxtooltip';
1035 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
1036 $label = '';
1037 } else {
1038 $label = implode($this->getTooltipContentArray($params));
1039 }
1040
1041 $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
1042
1043 if ($option != 'nolink') {
1044 // Add param to save lastsearch_values or not
1045 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1046 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
1047 $add_save_lastsearch_values = 1;
1048 }
1049 if ($add_save_lastsearch_values) {
1050 $url .= '&save_lastsearch_values=1';
1051 }
1052 }
1053
1054 $linkclose = '';
1055 if (empty($notooltip)) {
1056 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
1057 $label = $langs->trans("ShowPartnership");
1058 $linkclose .= ' alt="'.dolPrintHTMLForAttribute($label).'"';
1059 }
1060 $linkclose .= ($label ? ' title="'.dolPrintHTMLForAttribute($label).'"' : ' title="tocomplete"');
1061 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
1062 } else {
1063 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
1064 }
1065
1066 if ($option == 'nolink') {
1067 $linkstart = '<span';
1068 } else {
1069 $linkstart = '<a href="'.$url.'"';
1070 }
1071 $linkstart .= $linkclose.'>';
1072 if ($option == 'nolink') {
1073 $linkend = '</span>';
1074 } else {
1075 $linkend = '</a>';
1076 }
1077
1078 $result .= $linkstart;
1079
1080 if (empty($this->showphoto_on_popup)) {
1081 if ($withpicto) {
1082 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
1083 }
1084 } else {
1085 if ($withpicto) {
1086 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1087
1088 list($class, $module) = explode('@', $this->picto);
1089 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1090 $filearray = dol_dir_list($upload_dir, "files");
1091 $filename = $filearray[0]['name'];
1092 if (!empty($filename)) {
1093 $pospoint = strpos($filearray[0]['name'], '.');
1094
1095 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.dol_substr($filename, 0, $pospoint).'_mini'.dol_substr($filename, $pospoint);
1096 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
1097 $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>';
1098 } else {
1099 $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>';
1100 }
1101
1102 $result .= '</div>';
1103 } else {
1104 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'"'), 0, 0, $notooltip ? 0 : 1);
1105 }
1106 }
1107 }
1108
1109 if ($withpicto != 2) {
1110 $result .= $this->ref;
1111 }
1112
1113 $result .= $linkend;
1114 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1115
1116 global $action, $hookmanager;
1117 $hookmanager->initHooks(array('partnershipdao'));
1118 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
1119 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1120 if ($reshook > 0) {
1121 $result = $hookmanager->resPrint;
1122 } else {
1123 $result .= $hookmanager->resPrint;
1124 }
1125
1126 return $result;
1127 }
1128
1137 public static function replaceThirdparty($db, $origin_id, $dest_id)
1138 {
1139 $tables = array('partnership');
1140
1141 return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
1142 }
1143
1150 public function getLibStatut($mode = 0)
1151 {
1152 return $this->LibStatut($this->status, $mode);
1153 }
1154
1155 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1163 public function LibStatut($status, $mode = 0)
1164 {
1165 // phpcs:enable
1166 if (is_null($status)) {
1167 return '';
1168 }
1169
1170 $paramsBadge = array('badgeParams' => array('attr' => array(
1171 'data-status-element' => $this->element,
1172 'data-status' => (int) $status
1173 )));
1174
1175 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1176 global $langs;
1177 //$langs->load("partnership");
1178 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1179 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1180 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1181 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1182 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1183 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1184 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1185 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1186 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1187 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1188 }
1189
1190 $statusType = 'status'.$status;
1191 if ($status == self::STATUS_APPROVED) {
1192 $statusType = 'status4';
1193 }
1194 if ($status == self::STATUS_REFUSED) {
1195 $statusType = 'status9';
1196 }
1197 if ($status == self::STATUS_CANCELED) {
1198 $statusType = 'status6';
1199 }
1200
1201 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode, '', $paramsBadge);
1202 }
1203
1210 public function info($id)
1211 {
1212 $sql = "SELECT rowid, date_creation as datec, tms as datem,";
1213 $sql .= " fk_user_creat, fk_user_modif";
1214 $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t";
1215 $sql .= " WHERE t.rowid = ".((int) $id);
1216 $result = $this->db->query($sql);
1217 if ($result) {
1218 if ($this->db->num_rows($result)) {
1219 $obj = $this->db->fetch_object($result);
1220
1221 $this->id = $obj->rowid;
1222
1223 $this->user_creation_id = $obj->fk_user_creat;
1224 $this->user_modification_id = $obj->fk_user_modif;
1225 $this->date_creation = $this->db->jdate($obj->datec);
1226 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1227 }
1228
1229 $this->db->free($result);
1230 } else {
1231 dol_print_error($this->db);
1232 }
1233 }
1234
1241 public function initAsSpecimen()
1242 {
1243 return $this->initAsSpecimenCommon();
1244 }
1245
1251 public function getLinesArray()
1252 {
1253 $this->lines = array();
1254
1255 $objectline = new PartnershipLine($this->db);
1256 $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_partnership:=:'.((int) $this->id).')');
1257
1258 if (is_numeric($result)) {
1259 $this->error = $objectline->error;
1260 $this->errors = $objectline->errors;
1261 return $result;
1262 } else {
1263 $this->lines = $result;
1264 // @phpstan-ignore-next-line
1265 return $result; // @phan-suppress-current-line PhanTypeMismatchReturn
1266 }
1267 }
1268
1274 public function getNextNumRef()
1275 {
1276 global $langs, $conf;
1277 $langs->load("partnership");
1278
1279 if (!getDolGlobalString('PARTNERSHIP_ADDON')) {
1280 $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1281 }
1282
1283 if (getDolGlobalString('PARTNERSHIP_ADDON')) {
1284 $mybool = false;
1285
1286 $file = getDolGlobalString('PARTNERSHIP_ADDON') . ".php";
1287 $classname = getDolGlobalString('PARTNERSHIP_ADDON');
1288
1289 // Include file with class
1290 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1291 foreach ($dirmodels as $reldir) {
1292 $dir = dol_buildpath($reldir."core/modules/partnership/");
1293
1294 // Load file with numbering class (if found)
1295 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1296 }
1297
1298 if (!$mybool) {
1299 dol_print_error(null, "Failed to include file ".$file);
1300 return '';
1301 }
1302
1303 if (class_exists($classname)) {
1304 $obj = new $classname();
1305 '@phan-var-force ModeleNumRefPartnership $obj';
1306 $numref = $obj->getNextValue($this);
1307
1308 if ($numref != '' && $numref != '-1') {
1309 return $numref;
1310 } else {
1311 $this->error = $obj->error;
1312 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1313 return "";
1314 }
1315 } else {
1316 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1317 return "";
1318 }
1319 } else {
1320 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1321 return "";
1322 }
1323 }
1324
1336 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1337 {
1338 global $langs;
1339
1340 $result = 0;
1341 $includedocgeneration = 0;
1342
1343 $langs->load("partnership");
1344
1345 if (!dol_strlen($modele)) {
1346 $modele = 'standard_partnership';
1347
1348 if (!empty($this->model_pdf)) {
1349 $modele = $this->model_pdf;
1350 } elseif (getDolGlobalString('PARTNERSHIP_ADDON_PDF')) {
1351 $modele = getDolGlobalString('PARTNERSHIP_ADDON_PDF');
1352 }
1353 }
1354
1355 $modelpath = "core/modules/partnership/doc/";
1356
1357 if ($includedocgeneration && !empty($modele)) {
1358 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1359 }
1360
1361 return $result;
1362 }
1363
1371 public function doScheduledJob()
1372 {
1373 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1374
1375 $error = 0;
1376 $this->output = '';
1377 $this->error = '';
1378
1379 dol_syslog(__METHOD__." start", LOG_INFO);
1380
1381 //$now = dol_now();
1382
1383 $this->db->begin();
1384
1385 // ...
1386
1387 $this->db->commit();
1388
1389 dol_syslog(__METHOD__." end", LOG_INFO);
1390
1391 return $error;
1392 }
1393
1401 public function getKanbanView($option = '', $arraydata = null)
1402 {
1403 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1404
1405 $return = '<div class="box-flex-item box-flex-grow-zero">';
1406 $return .= '<div class="info-box info-box-sm">';
1407 $return .= '<span class="info-box-icon bg-infobox-action">';
1408 $return .= img_picto('', $this->picto);
1409 $return .= '</span>';
1410 $return .= '<div class="info-box-content">';
1411 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1412 if ($selected >= 0) {
1413 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1414 }
1415 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
1416 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
1417 }
1418 if (method_exists($this, 'getLibStatut')) {
1419 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
1420 }
1421 $return .= '</div>';
1422 $return .= '</div>';
1423 $return .= '</div>';
1424
1425 return $return;
1426 }
1427}
1428
1429
1430require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1431
1436{
1437 // To complete with content of an object PartnershipLine
1438 // We should have a field rowid, fk_partnership and position
1439
1440
1446 public function __construct(DoliDB $db)
1447 {
1448 $this->db = $db;
1449
1450 $this->isextrafieldmanaged = 0;
1451 }
1452}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
$object ref
Definition info.php:90
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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:169
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:66
dol_now($mode='gmt')
Return date for now.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.