dolibarr 20.0.0
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 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
28// Put here all includes required by your class file
29require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30
31
36{
40 public $module = 'partnership';
41
45 public $element = 'partnership';
46
50 public $table_element = 'partnership';
51
55 public $picto = 'partnership';
56
57 public $type_code;
58 public $type_label;
59
60
61 const STATUS_DRAFT = 0;
62 const STATUS_VALIDATED = 1; // Validate (no more draft)
63 const STATUS_APPROVED = 2; // Approved
64 const STATUS_REFUSED = 3; // Refused
65 const STATUS_CANCELED = 9;
66
67
94 // BEGIN MODULEBUILDER PROPERTIES
98 public $fields = array(
99 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'position' => 1, 'notnull' => 1, 'visible' => 0, 'noteditable' => 1, 'index' => 1, 'css' => 'left', 'comment' => "Id"),
100 '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'),
101 'entity' => array('type' => 'integer', 'label' => 'Entity', 'enabled' => 'isModEnabled("multicompany")', 'position' => 15, 'notnull' => 1, 'visible' => -2, 'default' => '1', 'index' => 1,),
102 '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' => 'tdoverflowmax125'),
103 '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',),
104 'note_public' => array('type' => 'html', 'label' => 'NotePublic', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 0,),
105 'note_private' => array('type' => 'html', 'label' => 'NotePrivate', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 0,),
106 'date_creation' => array('type' => 'datetime', 'label' => 'DateCreation', 'enabled' => 1, 'position' => 500, 'notnull' => 1, 'visible' => -2, 'csslist' => 'nowraponall'),
107 'tms' => array('type' => 'timestamp', 'label' => 'DateModification', 'enabled' => 1, 'position' => 501, 'notnull' => 0, 'visible' => -2, 'csslist' => 'nowraponall'),
108 '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'),
109 'fk_user_modif' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserModif', 'enabled' => 1, 'position' => 511, 'notnull' => -1, 'visible' => -2, 'csslist' => 'tdoverflowmax125'),
110 'last_main_doc' => array('type' => 'varchar(255)', 'label' => 'LastMainDoc', 'enabled' => 1, 'position' => 600, 'notnull' => 0, 'visible' => 0,),
111 'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 1000, 'notnull' => -1, 'visible' => -2,),
112 'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'position' => 1010, 'notnull' => -1, 'visible' => 0,),
113 'date_partnership_start' => array('type' => 'date', 'label' => 'DatePartnershipStart', 'enabled' => 1, 'position' => 52, 'notnull' => 1, 'visible' => 1,),
114 'date_partnership_end' => array('type' => 'date', 'label' => 'DatePartnershipEnd', 'enabled' => 1, 'position' => 53, 'notnull' => 0, 'visible' => 1,),
115 'url_to_check' => array('type' => 'url', 'label' => 'UrlToCheck', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 70, 'notnull' => 0, 'visible' => -1, 'csslist' => 'tdoverflowmax150'),
116 'count_last_url_check_error' => array('type' => 'integer', 'label' => 'CountLastUrlCheckError', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 71, 'notnull' => 0, 'visible' => -4, 'default' => '0',),
117 'last_check_backlink' => array('type' => 'datetime', 'label' => 'LastCheckBacklink', 'enabled' => 'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position' => 72, 'notnull' => 0, 'visible' => -4, 'csslist' => 'nowraponall'),
118 'reason_decline_or_cancel' => array('type' => 'text', 'label' => 'ReasonDeclineOrCancel', 'enabled' => 1, 'position' => 73, 'notnull' => 0, 'visible' => -2,),
119 'ip' => array('type' => 'ip', 'label' => 'IPOfApplicant', 'enabled' => 1, 'position' => 74, 'notnull' => 0, 'visible' => -2,),
120 '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'),),
121 );
122 public $rowid;
123 public $ref;
124 public $entity;
125 public $fk_type;
126 public $note_public;
127 public $note_private;
128 public $date_creation;
129 public $fk_user_creat;
130 public $fk_user_modif;
131 public $last_main_doc;
132 public $import_key;
133 public $model_pdf;
134 public $date_partnership_start;
135 public $date_partnership_end;
136 public $url_to_check;
137 public $count_last_url_check_error;
138 public $last_check_backlink;
139 public $reason_decline_or_cancel;
140 public $fk_soc;
141 public $fk_member;
142 public $ip;
143 public $status;
144 // END MODULEBUILDER PROPERTIES
145
146
152 public function __construct(DoliDB $db)
153 {
154 global $conf, $langs;
155
156 $this->db = $db;
157
158 $this->ismultientitymanaged = 0;
159 $this->isextrafieldmanaged = 1;
160
161 if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
162 $this->fields['fk_member'] = array('type' => 'integer:Adherent:adherents/class/adherent.class.php:1', 'label' => 'Member', 'enabled' => '1', 'position' => 50, 'notnull' => -1, 'visible' => 1, 'index' => 1, 'picto' => 'member', 'csslist' => 'tdoverflowmax150');
163 } else {
164 $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');
165 }
166
167 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
168 $this->fields['rowid']['visible'] = 0;
169 }
170
171 // Unset fields that are disabled
172 foreach ($this->fields as $key => $val) {
173 if (isset($val['enabled']) && empty($val['enabled'])) {
174 unset($this->fields[$key]);
175 }
176 }
177
178 // Translate some data of arrayofkeyval
179 if (is_object($langs)) {
180 foreach ($this->fields as $key => $val) {
181 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
182 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
183 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
184 }
185 }
186 }
187 }
188 }
189
197 public function create(User $user, $notrigger = 0)
198 {
199 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
200 $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory";
201 return -1;
202 }
203
204 $this->status = 0;
205 return $this->createCommon($user, $notrigger);
206 }
207
215 public function createFromClone(User $user, $fromid)
216 {
217 global $langs, $extrafields;
218 $error = 0;
219
220 dol_syslog(__METHOD__, LOG_DEBUG);
221
222 $object = new self($this->db);
223
224 $this->db->begin();
225
226 // Load source object
227 $result = $object->fetchCommon($fromid);
228 if ($result > 0 && !empty($object->table_element_line)) {
229 $object->fetchLines();
230 }
231
232 // get lines so they will be clone
233 //foreach($this->lines as $line)
234 // $line->fetch_optionals();
235
236 // Reset some properties
237 unset($object->id);
238 unset($object->fk_user_creat);
239 unset($object->import_key);
240
241 // Clear fields
242 if (property_exists($object, 'ref')) {
243 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
244 }
245 if (property_exists($object, 'label')) {
246 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
247 }
248 if (property_exists($object, 'status')) {
249 $object->status = self::STATUS_DRAFT;
250 }
251 if (property_exists($object, 'date_creation')) {
252 $object->date_creation = dol_now();
253 }
254 if (property_exists($object, 'date_modification')) {
255 $object->date_modification = null;
256 }
257 // ...
258 // Clear extrafields that are unique
259 if (is_array($object->array_options) && count($object->array_options) > 0) {
260 $extrafields->fetch_name_optionals_label($this->table_element);
261 foreach ($object->array_options as $key => $option) {
262 $shortkey = preg_replace('/options_/', '', $key);
263 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
264 //var_dump($key);
265 //var_dump($clonedObj->array_options[$key]); exit;
266 unset($object->array_options[$key]);
267 }
268 }
269 }
270
271 // Create clone
272 $object->context['createfromclone'] = 'createfromclone';
273 $result = $object->createCommon($user);
274 if ($result < 0) {
275 $error++;
276 $this->error = $object->error;
277 $this->errors = $object->errors;
278 }
279
280 if (!$error) {
281 // copy internal contacts
282 if ($this->copy_linked_contact($object, 'internal') < 0) {
283 $error++;
284 }
285 }
286
287 if (!$error) {
288 // copy external contacts if same company
289 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
290 if ($this->copy_linked_contact($object, 'external') < 0) {
291 $error++;
292 }
293 }
294 }
295
296 unset($object->context['createfromclone']);
297
298 // End
299 if (!$error) {
300 $this->db->commit();
301 return $object;
302 } else {
303 $this->db->rollback();
304 return -1;
305 }
306 }
307
318 public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
319 {
320 // Check parameters
321 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
322 return -1;
323 }
324
325 $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
326 $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
327 $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
328 $sql .= ', p.note_private, p.note_public, p.url_to_check';
329 $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
330 $sql .= ', p.import_key, p.model_pdf';
331 $sql .= ', pt.code as type_code, pt.label as type_label';
332 $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
333 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
334
335 if ($id) {
336 $sql .= " WHERE p.rowid = ".((int) $id);
337 } else {
338 $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Don't use entity if you use rowid
339 }
340
341 if ($ref) {
342 $sql .= " AND p.ref='".$this->db->escape($ref)."'";
343 }
344
345 if ($fk_member > 0) {
346 $sql .= ' AND p.fk_member = '.((int) $fk_member);
347 }
348 if ($fk_soc > 0) {
349 $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
350 }
351 $sql .= ' ORDER BY p.date_partnership_end DESC';
352
353 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
354 $result = $this->db->query($sql);
355 if ($result) {
356 $obj = $this->db->fetch_object($result);
357 if ($obj) {
358 $this->id = $obj->rowid;
359 $this->entity = $obj->entity;
360 $this->ref = $obj->ref;
361
362 $this->fk_type = $obj->fk_type;
363 $this->type_code = $obj->type_code;
364 $this->type_label = $obj->type_label;
365
366 $this->fk_soc = $obj->fk_soc;
367 $this->fk_member = $obj->fk_member;
368 $this->status = $obj->status;
369 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
370 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
371 $this->date_creation = $this->db->jdate($obj->date_creation);
372 $this->fk_user_creat = $obj->fk_user_creat;
373 $this->tms = $obj->tms;
374 $this->fk_user_modif = $obj->fk_user_modif;
375 $this->note_private = $obj->note_private;
376 $this->note_public = $obj->note_public;
377 $this->last_main_doc = $obj->last_main_doc;
378 $this->count_last_url_check_error = $obj->count_last_url_check_error;
379 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
380 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
381 $this->import_key = $obj->import_key;
382 $this->model_pdf = $obj->model_pdf;
383 $this->url_to_check = $obj->url_to_check;
384
385 // Retrieve all extrafield
386 // fetch optionals attributes and labels
387 $this->fetch_optionals();
388
389 $this->db->free($result);
390
391 return 1;
392 } else {
393 // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
394 return 0;
395 }
396 } else {
397 $this->error = $this->db->error();
398 return -1;
399 }
400 }
401
402
408 public function fetchLines()
409 {
410 $this->lines = array();
411
412 $result = $this->fetchLinesCommon();
413 return $result;
414 }
415
416
428 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND')
429 {
430 dol_syslog(__METHOD__, LOG_DEBUG);
431
432 $records = array();
433
434 $sql = 'SELECT ';
435 $sql .= $this->getFieldList('t');
436 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
437 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
438 $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
439 } else {
440 $sql .= ' WHERE 1 = 1';
441 }
442
443 // Manage filter
444 if (is_array($filter)) {
445 $sqlwhere = array();
446 if (count($filter) > 0) {
447 foreach ($filter as $key => $value) {
448 if ($key == 't.rowid') {
449 $sqlwhere[] = $this->db->sanitize($key)." = ".((int) $value);
450 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
451 $sqlwhere[] = $this->db->sanitize($key)." = '".$this->db->idate($value)."'";
452 } elseif (strpos($value, '%') === false) {
453 $sqlwhere[] = $this->db->sanitize($key)." IN (".$this->db->sanitize($this->db->escape($value)).")";
454 } else {
455 $sqlwhere[] = $this->db->sanitize($key)." LIKE '%".$this->db->escape($this->db->escapeforlike($value))."%'";
456 }
457 }
458 }
459 if (count($sqlwhere) > 0) {
460 $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
461 }
462
463 $filter = '';
464 }
465
466 // Manage filter
467 $errormessage = '';
468 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
469 if ($errormessage) {
470 $this->errors[] = $errormessage;
471 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
472 return -1;
473 }
474
475 if (!empty($sortfield)) {
476 $sql .= $this->db->order($sortfield, $sortorder);
477 }
478 if (!empty($limit)) {
479 $sql .= $this->db->plimit($limit, $offset);
480 }
481
482 $resql = $this->db->query($sql);
483 if ($resql) {
484 $num = $this->db->num_rows($resql);
485 $i = 0;
486 while ($i < ($limit ? min($limit, $num) : $num)) {
487 $obj = $this->db->fetch_object($resql);
488
489 $record = new self($this->db);
490 $record->setVarsFromFetchObj($obj);
491
492 $records[$record->id] = $record;
493
494 $i++;
495 }
496 $this->db->free($resql);
497
498 return $records;
499 } else {
500 $this->errors[] = 'Error '.$this->db->lasterror();
501 dol_syslog(__METHOD__.' '.implode(',', $this->errors), LOG_ERR);
502
503 return -1;
504 }
505 }
506
514 public function update(User $user, $notrigger = 0)
515 {
516 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
517 $this->errors[] = "ErrorThirpdartyOrMemberidIsMandatory"; // Mistyping in key is in translations
518 return -1;
519 }
520 if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
521 $this->fk_user_creat = $user->id;
522 }
523
524 return $this->updateCommon($user, $notrigger);
525 }
526
534 public function delete(User $user, $notrigger = 0)
535 {
536 return $this->deleteCommon($user, $notrigger);
537 //return $this->deleteCommon($user, $notrigger, 1);
538 }
539
548 public function deleteLine(User $user, $idline, $notrigger = 0)
549 {
550 if ($this->status < 0) {
551 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
552 return -2;
553 }
554
555 return $this->deleteLineCommon($user, $idline, $notrigger);
556 }
557
558
566 public function validate($user, $notrigger = 0)
567 {
568 global $conf;
569
570 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
571
572 $error = 0;
573
574 // Protection
575 if ($this->status == self::STATUS_VALIDATED) {
576 dol_syslog(get_class($this)."::validate action abandoned: already validated", LOG_WARNING);
577 return 0;
578 }
579
580 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
581 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->validate))))
582 {
583 $this->error='NotEnoughPermissions';
584 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
585 return -1;
586 }*/
587
588 $now = dol_now();
589
590 $this->db->begin();
591
592 // Define new ref
593 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
594 $num = $this->getNextNumRef();
595 } else {
596 $num = $this->ref;
597 }
598 $this->newref = $num;
599
600 if (!empty($num)) {
601 // Validate
602 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
603 $sql .= " SET ref = '".$this->db->escape($num)."',";
604 $sql .= " status = ".self::STATUS_VALIDATED;
605 if (!empty($this->fields['date_validation'])) {
606 $sql .= ", date_validation = '".$this->db->idate($now)."'";
607 }
608 if (!empty($this->fields['fk_user_valid'])) {
609 $sql .= ", fk_user_valid = ".$user->id;
610 }
611 $sql .= " WHERE rowid = ".((int) $this->id);
612
613 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
614 $resql = $this->db->query($sql);
615 if (!$resql) {
616 dol_print_error($this->db);
617 $this->error = $this->db->lasterror();
618 $error++;
619 }
620
621 if (!$error && !$notrigger) {
622 // Call trigger
623 $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
624 if ($result < 0) {
625 $error++;
626 }
627 // End call triggers
628 }
629 }
630
631 if (!$error) {
632 $this->oldref = $this->ref;
633
634 // Rename directory if dir was a temporary ref
635 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
636 // Now we rename also files into index
637 $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)."'";
638 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
639 $resql = $this->db->query($sql);
640 if (!$resql) {
641 $error++;
642 $this->error = $this->db->lasterror();
643 }
644 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
645 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
646 $resql = $this->db->query($sql);
647 if (!$resql) {
648 $error++;
649 $this->error = $this->db->lasterror();
650 }
651
652 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
653 $oldref = dol_sanitizeFileName($this->ref);
654 $newref = dol_sanitizeFileName($num);
655 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
656 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
657 if (!$error && file_exists($dirsource)) {
658 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
659
660 if (@rename($dirsource, $dirdest)) {
661 dol_syslog("Rename ok");
662 // Rename docs starting with $oldref with $newref
663 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
664 foreach ($listoffiles as $fileentry) {
665 $dirsource = $fileentry['name'];
666 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
667 $dirsource = $fileentry['path'].'/'.$dirsource;
668 $dirdest = $fileentry['path'].'/'.$dirdest;
669 @rename($dirsource, $dirdest);
670 }
671 }
672 }
673 }
674 }
675
676 // Set new ref and current status
677 if (!$error) {
678 $this->ref = $num;
679 $this->status = self::STATUS_VALIDATED;
680 }
681
682 if (!$error) {
683 $this->db->commit();
684 return 1;
685 } else {
686 $this->db->rollback();
687 return -1;
688 }
689 }
690
698 public function approve($user, $notrigger = 0)
699 {
700 global $conf;
701
702 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
703
704 $error = 0;
705
706 // Protection
707 if ($this->status == self::STATUS_APPROVED) {
708 dol_syslog(get_class($this)."::accept action abandoned: already acceptd", LOG_WARNING);
709 return 0;
710 }
711
712 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
713 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
714 {
715 $this->error='NotEnoughPermissions';
716 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
717 return -1;
718 }*/
719
720 $now = dol_now();
721
722 $this->db->begin();
723
724 // Define new ref
725 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
726 $num = $this->getNextNumRef();
727 } else {
728 $num = $this->ref;
729 }
730 $this->newref = $num;
731
732 if (!empty($num)) {
733 // Accept
734 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
735 $sql .= " SET ref = '".$this->db->escape($num)."',";
736 $sql .= " status = ".self::STATUS_APPROVED;
737 // if (!empty($this->fields['date_validation'])) {
738 // $sql .= ", date_validation = '".$this->db->idate($now)."'";
739 // }
740 // if (!empty($this->fields['fk_user_valid'])) {
741 // $sql .= ", fk_user_valid = ".$user->id;
742 // }
743 $sql .= " WHERE rowid = ".((int) $this->id);
744
745 dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
746 $resql = $this->db->query($sql);
747 if (!$resql) {
748 dol_print_error($this->db);
749 $this->error = $this->db->lasterror();
750 $error++;
751 }
752
753 if (!$error && !$notrigger) {
754 // Call trigger
755 $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
756 if ($result < 0) {
757 $error++;
758 }
759 // End call triggers
760 }
761 }
762
763 if (!$error) {
764 $this->oldref = $this->ref;
765
766 // Rename directory if dir was a temporary ref
767 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
768 // Now we rename also files into index
769 $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)."'";
770 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
771 $resql = $this->db->query($sql);
772 if (!$resql) {
773 $error++;
774 $this->error = $this->db->lasterror();
775 }
776 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
777 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
778 $resql = $this->db->query($sql);
779 if (!$resql) {
780 $error++;
781 $this->error = $this->db->lasterror();
782 }
783
784 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
785 $oldref = dol_sanitizeFileName($this->ref);
786 $newref = dol_sanitizeFileName($num);
787 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
788 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
789 if (!$error && file_exists($dirsource)) {
790 dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
791
792 if (@rename($dirsource, $dirdest)) {
793 dol_syslog("Rename ok");
794 // Rename docs starting with $oldref with $newref
795 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
796 foreach ($listoffiles as $fileentry) {
797 $dirsource = $fileentry['name'];
798 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
799 $dirsource = $fileentry['path'].'/'.$dirsource;
800 $dirdest = $fileentry['path'].'/'.$dirdest;
801 @rename($dirsource, $dirdest);
802 }
803 }
804 }
805 }
806 }
807
808 // Set new ref and current status
809 if (!$error) {
810 $this->ref = $num;
811 $this->status = self::STATUS_APPROVED;
812 }
813
814 if (!$error) {
815 $this->db->commit();
816 return 1;
817 } else {
818 $this->db->rollback();
819 return -1;
820 }
821 }
822
823
831 public function setDraft($user, $notrigger = 0)
832 {
833 // Protection
834 if ($this->status <= self::STATUS_DRAFT) {
835 return 0;
836 }
837
838 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
839 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
840 {
841 $this->error='Permission denied';
842 return -1;
843 }*/
844
845 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
846 }
847
856 public function refused($user, $reasondeclinenote = '', $notrigger = 0)
857 {
858 // Protection
859 if ($this->status == self::STATUS_REFUSED) {
860 return 0;
861 }
862
863 $this->status = self::STATUS_REFUSED;
864 $this->reason_decline_or_cancel = $reasondeclinenote;
865
866 $result = $this->update($user);
867
868 if ($result) {
869 $this->reason_decline_or_cancel = $reasondeclinenote;
870 return 1;
871 }
872
873 return -1;
874 }
875
883 public function cancel($user, $notrigger = 0)
884 {
885 // Protection
886 if ($this->status != self::STATUS_APPROVED) {
887 return 0;
888 }
889
890 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
891 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
892 {
893 $this->error='Permission denied';
894 return -1;
895 }*/
896
897 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
898 }
899
907 public function reopen($user, $notrigger = 0)
908 {
909 // Protection
910 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
911 return 0;
912 }
913
914 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
915 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
916 {
917 $this->error='Permission denied';
918 return -1;
919 }*/
920
921 return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
922 }
923
931 public function getTooltipContentArray($params)
932 {
933 global $langs;
934
935 $langs->load('partnership');
936
937 $datas = [];
938 $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
939 if (isset($this->status)) {
940 $datas['picto'] .= ' '.$this->getLibStatut(5);
941 }
942 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
943
944 return $datas;
945 }
946
957 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
958 {
959 global $conf, $langs, $hookmanager;
960
961 if (!empty($conf->dol_no_mouse_hover)) {
962 $notooltip = 1; // Force disable tooltips
963 }
964
965 $result = '';
966 $params = [
967 'id' => $this->id,
968 'objecttype' => $this->element,
969 'option' => $option,
970 ];
971 $classfortooltip = 'classfortooltip';
972 $dataparams = '';
973 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
974 $classfortooltip = 'classforajaxtooltip';
975 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
976 $label = '';
977 } else {
978 $label = implode($this->getTooltipContentArray($params));
979 }
980
981 $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
982
983 if ($option != 'nolink') {
984 // Add param to save lastsearch_values or not
985 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
986 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
987 $add_save_lastsearch_values = 1;
988 }
989 if ($add_save_lastsearch_values) {
990 $url .= '&save_lastsearch_values=1';
991 }
992 }
993
994 $linkclose = '';
995 if (empty($notooltip)) {
996 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
997 $label = $langs->trans("ShowPartnership");
998 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
999 }
1000 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
1001 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
1002 } else {
1003 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
1004 }
1005
1006 if ($option == 'nolink') {
1007 $linkstart = '<span';
1008 } else {
1009 $linkstart = '<a href="'.$url.'"';
1010 }
1011 $linkstart .= $linkclose.'>';
1012 if ($option == 'nolink') {
1013 $linkend = '</span>';
1014 } else {
1015 $linkend = '</a>';
1016 }
1017
1018 $result .= $linkstart;
1019
1020 if (empty($this->showphoto_on_popup)) {
1021 if ($withpicto) {
1022 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : $dataparams.' class="'.(($withpicto != 2) ? 'paddingright ' : '').$classfortooltip.'"'), 0, 0, $notooltip ? 0 : 1);
1023 }
1024 } else {
1025 if ($withpicto) {
1026 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1027
1028 list($class, $module) = explode('@', $this->picto);
1029 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1030 $filearray = dol_dir_list($upload_dir, "files");
1031 $filename = $filearray[0]['name'];
1032 if (!empty($filename)) {
1033 $pospoint = strpos($filearray[0]['name'], '.');
1034
1035 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1036 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
1037 $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>';
1038 } else {
1039 $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>';
1040 }
1041
1042 $result .= '</div>';
1043 } else {
1044 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1045 }
1046 }
1047 }
1048
1049 if ($withpicto != 2) {
1050 $result .= $this->ref;
1051 }
1052
1053 $result .= $linkend;
1054 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1055
1056 global $action, $hookmanager;
1057 $hookmanager->initHooks(array('partnershipdao'));
1058 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
1059 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1060 if ($reshook > 0) {
1061 $result = $hookmanager->resPrint;
1062 } else {
1063 $result .= $hookmanager->resPrint;
1064 }
1065
1066 return $result;
1067 }
1068
1077 public static function replaceThirdparty($db, $origin_id, $dest_id)
1078 {
1079 $tables = array('partnership');
1080
1081 return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables);
1082 }
1083
1090 public function getLibStatut($mode = 0)
1091 {
1092 return $this->LibStatut($this->status, $mode);
1093 }
1094
1095 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1103 public function LibStatut($status, $mode = 0)
1104 {
1105 // phpcs:enable
1106 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1107 global $langs;
1108 //$langs->load("partnership");
1109 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1110 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1111 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1112 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1113 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1114 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1115 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1116 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1117 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1118 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1119 }
1120
1121 $statusType = 'status'.$status;
1122 if ($status == self::STATUS_APPROVED) {
1123 $statusType = 'status4';
1124 }
1125 if ($status == self::STATUS_REFUSED) {
1126 $statusType = 'status9';
1127 }
1128 if ($status == self::STATUS_CANCELED) {
1129 $statusType = 'status6';
1130 }
1131
1132 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1133 }
1134
1141 public function info($id)
1142 {
1143 $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1144 $sql .= ' fk_user_creat, fk_user_modif';
1145 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1146 $sql .= ' WHERE t.rowid = '.((int) $id);
1147 $result = $this->db->query($sql);
1148 if ($result) {
1149 if ($this->db->num_rows($result)) {
1150 $obj = $this->db->fetch_object($result);
1151
1152 $this->id = $obj->rowid;
1153
1154 $this->user_creation_id = $obj->fk_user_creat;
1155 $this->user_modification_id = $obj->fk_user_modif;
1156 $this->date_creation = $this->db->jdate($obj->datec);
1157 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1158 }
1159
1160 $this->db->free($result);
1161 } else {
1162 dol_print_error($this->db);
1163 }
1164 }
1165
1172 public function initAsSpecimen()
1173 {
1174 return $this->initAsSpecimenCommon();
1175 }
1176
1182 public function getLinesArray()
1183 {
1184 $this->lines = array();
1185
1186 $objectline = new PartnershipLine($this->db);
1187 $result = $objectline->fetchAll('ASC', 'position', 0, 0, '(fk_partnership:=:'.((int) $this->id).')');
1188
1189 if (is_numeric($result)) {
1190 $this->error = $objectline->error;
1191 $this->errors = $objectline->errors;
1192 return $result;
1193 } else {
1194 $this->lines = $result;
1195 return $this->lines;
1196 }
1197 }
1198
1204 public function getNextNumRef()
1205 {
1206 global $langs, $conf;
1207 $langs->load("partnership");
1208
1209 if (!getDolGlobalString('PARTNERSHIP_ADDON')) {
1210 $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1211 }
1212
1213 if (getDolGlobalString('PARTNERSHIP_ADDON')) {
1214 $mybool = false;
1215
1216 $file = getDolGlobalString('PARTNERSHIP_ADDON') . ".php";
1217 $classname = getDolGlobalString('PARTNERSHIP_ADDON');
1218
1219 // Include file with class
1220 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1221 foreach ($dirmodels as $reldir) {
1222 $dir = dol_buildpath($reldir."core/modules/partnership/");
1223
1224 // Load file with numbering class (if found)
1225 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1226 }
1227
1228 if ($mybool === false) {
1229 dol_print_error(null, "Failed to include file ".$file);
1230 return '';
1231 }
1232
1233 if (class_exists($classname)) {
1234 $obj = new $classname();
1235 $numref = $obj->getNextValue($this);
1236
1237 if ($numref != '' && $numref != '-1') {
1238 return $numref;
1239 } else {
1240 $this->error = $obj->error;
1241 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1242 return "";
1243 }
1244 } else {
1245 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1246 return "";
1247 }
1248 } else {
1249 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1250 return "";
1251 }
1252 }
1253
1265 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1266 {
1267 global $conf, $langs;
1268
1269 $result = 0;
1270 $includedocgeneration = 0;
1271
1272 $langs->load("partnership");
1273
1274 if (!dol_strlen($modele)) {
1275 $modele = 'standard_partnership';
1276
1277 if (!empty($this->model_pdf)) {
1278 $modele = $this->model_pdf;
1279 } elseif (getDolGlobalString('PARTNERSHIP_ADDON_PDF')) {
1280 $modele = getDolGlobalString('PARTNERSHIP_ADDON_PDF');
1281 }
1282 }
1283
1284 $modelpath = "core/modules/partnership/doc/";
1285
1286 if ($includedocgeneration && !empty($modele)) {
1287 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1288 }
1289
1290 return $result;
1291 }
1292
1300 public function doScheduledJob()
1301 {
1302 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1303
1304 $error = 0;
1305 $this->output = '';
1306 $this->error = '';
1307
1308 dol_syslog(__METHOD__, LOG_DEBUG);
1309
1310 //$now = dol_now();
1311
1312 $this->db->begin();
1313
1314 // ...
1315
1316 $this->db->commit();
1317
1318 return $error;
1319 }
1320
1328 public function getKanbanView($option = '', $arraydata = null)
1329 {
1330 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1331
1332 $return = '<div class="box-flex-item box-flex-grow-zero">';
1333 $return .= '<div class="info-box info-box-sm">';
1334 $return .= '<span class="info-box-icon bg-infobox-action">';
1335 $return .= img_picto('', $this->picto);
1336 $return .= '</span>';
1337 $return .= '<div class="info-box-content">';
1338 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1339 if ($selected >= 0) {
1340 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1341 }
1342 if (property_exists($this, 'label')) {
1343 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
1344 }
1345 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
1346 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
1347 }
1348 if (method_exists($this, 'getLibStatut')) {
1349 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
1350 }
1351 $return .= '</div>';
1352 $return .= '</div>';
1353 $return .= '</div>';
1354
1355 return $return;
1356 }
1357}
1358
1359
1360require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1361
1366{
1367 // To complete with content of an object PartnershipLine
1368 // We should have a field rowid, fk_partnership and position
1369
1370
1376 public function __construct(DoliDB $db)
1377 {
1378 $this->db = $db;
1379
1380 $this->isextrafieldmanaged = 0;
1381 }
1382}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:637
$object ref
Definition info.php:79
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
Class for Partnership.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetchLines()
Load object lines in memory from the database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
Class PartnershipLine.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
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:63
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
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 dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.