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