dolibarr 19.0.3
partnership.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2021 NextGestion <contact@nextgestion.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
26// Put here all includes required by your class file
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28
29
34{
38 public $module = 'partnership';
39
43 public $element = 'partnership';
44
48 public $table_element = 'partnership';
49
54 public $ismultientitymanaged = 0;
55
59 public $isextrafieldmanaged = 1;
60
64 public $picto = 'partnership';
65
66 public $type_code;
67 public $type_label;
68
69
70 const STATUS_DRAFT = 0;
71 const STATUS_VALIDATED = 1; // Validate (no more draft)
72 const STATUS_APPROVED = 2; // Approved
73 const STATUS_REFUSED = 3; // Refused
74 const STATUS_CANCELED = 9;
75
76
103 // BEGIN MODULEBUILDER PROPERTIES
107 public $fields=array(
108 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
109 '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'),
110 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'isModEnabled("multicompany")', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
111 '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'),
112 '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',),
113 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
114 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
115 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2, 'csslist'=>'nowraponall'),
116 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>'1', 'position'=>501, 'notnull'=>0, 'visible'=>-2, 'csslist'=>'nowraponall'),
117 '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'),
118 'fk_user_modif' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>'1', 'position'=>511, 'notnull'=>-1, 'visible'=>-2, 'csslist'=>'tdoverflowmax125'),
119 'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
120 'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
121 'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
122 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
123 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
124 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'),
125 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-4, 'default'=>'0',),
126 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4, 'csslist'=>'nowraponall'),
127 'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
128 'ip' => array('type'=>'ip', 'label'=>'IPOfApplicant', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
129 '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'),),
130 );
131 public $rowid;
132 public $ref;
133 public $entity;
134 public $fk_type;
135 public $note_public;
136 public $note_private;
137 public $date_creation;
138 public $tms;
139 public $fk_user_creat;
140 public $fk_user_modif;
141 public $last_main_doc;
142 public $import_key;
143 public $model_pdf;
144 public $date_partnership_start;
145 public $date_partnership_end;
146 public $url_to_check;
147 public $count_last_url_check_error;
148 public $last_check_backlink;
149 public $reason_decline_or_cancel;
150 public $fk_soc;
151 public $fk_member;
152 public $ip;
153 public $status;
154 // END MODULEBUILDER PROPERTIES
155
156
162 public function __construct(DoliDB $db)
163 {
164 global $conf, $langs;
165
166 $this->db = $db;
167
168 if (getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') {
169 $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');
170 } else {
171 $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');
172 }
173
174 if (!getDolGlobalString('MAIN_SHOW_TECHNICAL_ID') && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
175 $this->fields['rowid']['visible'] = 0;
176 }
177
178 // Unset fields that are disabled
179 foreach ($this->fields as $key => $val) {
180 if (isset($val['enabled']) && empty($val['enabled'])) {
181 unset($this->fields[$key]);
182 }
183 }
184
185 // Translate some data of arrayofkeyval
186 if (is_object($langs)) {
187 foreach ($this->fields as $key => $val) {
188 if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
189 foreach ($val['arrayofkeyval'] as $key2 => $val2) {
190 $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2);
191 }
192 }
193 }
194 }
195 }
196
204 public function create(User $user, $notrigger = false)
205 {
206 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
207 $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
208 return -1;
209 }
210
211 $this->status = 0;
212 return $this->createCommon($user, $notrigger);
213 }
214
222 public function createFromClone(User $user, $fromid)
223 {
224 global $langs, $extrafields;
225 $error = 0;
226
227 dol_syslog(__METHOD__, LOG_DEBUG);
228
229 $object = new self($this->db);
230
231 $this->db->begin();
232
233 // Load source object
234 $result = $object->fetchCommon($fromid);
235 if ($result > 0 && !empty($object->table_element_line)) {
236 $object->fetchLines();
237 }
238
239 // get lines so they will be clone
240 //foreach($this->lines as $line)
241 // $line->fetch_optionals();
242
243 // Reset some properties
244 unset($object->id);
245 unset($object->fk_user_creat);
246 unset($object->import_key);
247
248 // Clear fields
249 if (property_exists($object, 'ref')) {
250 $object->ref = empty($this->fields['ref']['default']) ? "Copy_Of_".$object->ref : $this->fields['ref']['default'];
251 }
252 if (property_exists($object, 'label')) {
253 $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label : $this->fields['label']['default'];
254 }
255 if (property_exists($object, 'status')) {
256 $object->status = self::STATUS_DRAFT;
257 }
258 if (property_exists($object, 'date_creation')) {
259 $object->date_creation = dol_now();
260 }
261 if (property_exists($object, 'date_modification')) {
262 $object->date_modification = null;
263 }
264 // ...
265 // Clear extrafields that are unique
266 if (is_array($object->array_options) && count($object->array_options) > 0) {
267 $extrafields->fetch_name_optionals_label($this->table_element);
268 foreach ($object->array_options as $key => $option) {
269 $shortkey = preg_replace('/options_/', '', $key);
270 if (!empty($extrafields->attributes[$this->table_element]['unique'][$shortkey])) {
271 //var_dump($key);
272 //var_dump($clonedObj->array_options[$key]); exit;
273 unset($object->array_options[$key]);
274 }
275 }
276 }
277
278 // Create clone
279 $object->context['createfromclone'] = 'createfromclone';
280 $result = $object->createCommon($user);
281 if ($result < 0) {
282 $error++;
283 $this->error = $object->error;
284 $this->errors = $object->errors;
285 }
286
287 if (!$error) {
288 // copy internal contacts
289 if ($this->copy_linked_contact($object, 'internal') < 0) {
290 $error++;
291 }
292 }
293
294 if (!$error) {
295 // copy external contacts if same company
296 if (property_exists($this, 'fk_soc') && $this->fk_soc == $object->socid) {
297 if ($this->copy_linked_contact($object, 'external') < 0) {
298 $error++;
299 }
300 }
301 }
302
303 unset($object->context['createfromclone']);
304
305 // End
306 if (!$error) {
307 $this->db->commit();
308 return $object;
309 } else {
310 $this->db->rollback();
311 return -1;
312 }
313 }
314
325 public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
326 {
327 // Check parameters
328 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
329 return -1;
330 }
331
332 $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
333 $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
334 $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
335 $sql .= ', p.note_private, p.note_public, p.url_to_check';
336 $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
337 $sql .= ', p.import_key, p.model_pdf';
338 $sql .= ', pt.code as type_code, pt.label as type_label';
339 $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p';
340 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid';
341
342 if ($id) {
343 $sql .= " WHERE p.rowid = ".((int) $id);
344 } else {
345 $sql .= " WHERE p.entity IN (0,".getEntity('partnership').")"; // Dont't use entity if you use rowid
346 }
347
348 if ($ref) {
349 $sql .= " AND p.ref='".$this->db->escape($ref)."'";
350 }
351
352 if ($fk_member > 0) {
353 $sql .= ' AND p.fk_member = '.((int) $fk_member);
354 }
355 if ($fk_soc > 0) {
356 $sql .= ' AND p.fk_soc = '.((int) $fk_soc);
357 }
358 $sql .= ' ORDER BY p.date_partnership_end DESC';
359
360 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
361 $result = $this->db->query($sql);
362 if ($result) {
363 $obj = $this->db->fetch_object($result);
364 if ($obj) {
365 $this->id = $obj->rowid;
366 $this->entity = $obj->entity;
367 $this->ref = $obj->ref;
368
369 $this->fk_type = $obj->fk_type;
370 $this->type_code = $obj->type_code;
371 $this->type_label = $obj->type_label;
372
373 $this->fk_soc = $obj->fk_soc;
374 $this->fk_member = $obj->fk_member;
375 $this->status = $obj->status;
376 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
377 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
378 $this->date_creation = $this->db->jdate($obj->date_creation);
379 $this->fk_user_creat = $obj->fk_user_creat;
380 $this->tms = $obj->tms;
381 $this->fk_user_modif = $obj->fk_user_modif;
382 $this->note_private = $obj->note_private;
383 $this->note_public = $obj->note_public;
384 $this->last_main_doc = $obj->last_main_doc;
385 $this->count_last_url_check_error = $obj->count_last_url_check_error;
386 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
387 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
388 $this->import_key = $obj->import_key;
389 $this->model_pdf = $obj->model_pdf;
390 $this->url_to_check = $obj->url_to_check;
391
392 // Retrieve all extrafield
393 // fetch optionals attributes and labels
394 $this->fetch_optionals();
395
396 $this->db->free($result);
397
398 return 1;
399 } else {
400 // $this->error = 'Partnership with id '.$id.' not found sql='.$sql;
401 return 0;
402 }
403 } else {
404 $this->error = $this->db->error();
405 return -1;
406 }
407 }
408
409
415 public function fetchLines()
416 {
417 $this->lines = array();
418
419 $result = $this->fetchLinesCommon();
420 return $result;
421 }
422
423
435 public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
436 {
437 dol_syslog(__METHOD__, LOG_DEBUG);
438
439 $records = array();
440
441 $sql = 'SELECT ';
442 $sql .= $this->getFieldList('t');
443 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
444 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
445 $sql .= ' WHERE t.entity IN ('.getEntity($this->element).')';
446 } else {
447 $sql .= ' WHERE 1 = 1';
448 }
449 // Manage filter
450 $sqlwhere = array();
451 if (count($filter) > 0) {
452 foreach ($filter as $key => $value) {
453 if ($key == 't.rowid') {
454 $sqlwhere[] = $key." = ".((int) $value);
455 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) {
456 $sqlwhere[] = $key." = '".$this->db->idate($value)."'";
457 } elseif ($key == 'customsql') {
458 $sqlwhere[] = $value;
459 } elseif (strpos($value, '%') === false) {
460 $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")";
461 } else {
462 $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'";
463 }
464 }
465 }
466 if (count($sqlwhere) > 0) {
467 $sql .= ' AND ('.implode(' '.$this->db->escape($filtermode).' ', $sqlwhere).')';
468 }
469
470 if (!empty($sortfield)) {
471 $sql .= $this->db->order($sortfield, $sortorder);
472 }
473 if (!empty($limit)) {
474 $sql .= $this->db->plimit($limit, $offset);
475 }
476
477 $resql = $this->db->query($sql);
478 if ($resql) {
479 $num = $this->db->num_rows($resql);
480 $i = 0;
481 while ($i < ($limit ? min($limit, $num) : $num)) {
482 $obj = $this->db->fetch_object($resql);
483
484 $record = new self($this->db);
485 $record->setVarsFromFetchObj($obj);
486
487 $records[$record->id] = $record;
488
489 $i++;
490 }
491 $this->db->free($resql);
492
493 return $records;
494 } else {
495 $this->errors[] = 'Error '.$this->db->lasterror();
496 dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR);
497
498 return -1;
499 }
500 }
501
509 public function update(User $user, $notrigger = false)
510 {
511 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
512 $this->error[] = "ErrorThirpdartyOrMemberidIsMandatory";
513 return -1;
514 }
515 if (empty($this->fk_user_creat)) { // For the case the object was created with empty user (from public page).
516 $this->fk_user_creat = $user->id;
517 }
518
519 return $this->updateCommon($user, $notrigger);
520 }
521
529 public function delete(User $user, $notrigger = false)
530 {
531 return $this->deleteCommon($user, $notrigger);
532 //return $this->deleteCommon($user, $notrigger, 1);
533 }
534
543 public function deleteLine(User $user, $idline, $notrigger = false)
544 {
545 if ($this->status < 0) {
546 $this->error = 'ErrorDeleteLineNotAllowedByObjectStatus';
547 return -2;
548 }
549
550 return $this->deleteLineCommon($user, $idline, $notrigger);
551 }
552
553
561 public function validate($user, $notrigger = 0)
562 {
563 global $conf;
564
565 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
566
567 $error = 0;
568
569 // Protection
570 if ($this->status == self::STATUS_VALIDATED) {
571 dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
572 return 0;
573 }
574
575 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
576 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->validate))))
577 {
578 $this->error='NotEnoughPermissions';
579 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
580 return -1;
581 }*/
582
583 $now = dol_now();
584
585 $this->db->begin();
586
587 // Define new ref
588 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
589 $num = $this->getNextNumRef();
590 } else {
591 $num = $this->ref;
592 }
593 $this->newref = $num;
594
595 if (!empty($num)) {
596 // Validate
597 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
598 $sql .= " SET ref = '".$this->db->escape($num)."',";
599 $sql .= " status = ".self::STATUS_VALIDATED;
600 if (!empty($this->fields['date_validation'])) {
601 $sql .= ", date_validation = '".$this->db->idate($now)."'";
602 }
603 if (!empty($this->fields['fk_user_valid'])) {
604 $sql .= ", fk_user_valid = ".$user->id;
605 }
606 $sql .= " WHERE rowid = ".((int) $this->id);
607
608 dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
609 $resql = $this->db->query($sql);
610 if (!$resql) {
611 dol_print_error($this->db);
612 $this->error = $this->db->lasterror();
613 $error++;
614 }
615
616 if (!$error && !$notrigger) {
617 // Call trigger
618 $result = $this->call_trigger('PARTNERSHIP_VALIDATE', $user);
619 if ($result < 0) {
620 $error++;
621 }
622 // End call triggers
623 }
624 }
625
626 if (!$error) {
627 $this->oldref = $this->ref;
628
629 // Rename directory if dir was a temporary ref
630 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
631 // Now we rename also files into index
632 $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)."'";
633 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
634 $resql = $this->db->query($sql);
635 if (!$resql) {
636 $error++;
637 $this->error = $this->db->lasterror();
638 }
639 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
640 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
641 $resql = $this->db->query($sql);
642 if (!$resql) {
643 $error++;
644 $this->error = $this->db->lasterror();
645 }
646
647 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
648 $oldref = dol_sanitizeFileName($this->ref);
649 $newref = dol_sanitizeFileName($num);
650 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
651 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
652 if (!$error && file_exists($dirsource)) {
653 dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
654
655 if (@rename($dirsource, $dirdest)) {
656 dol_syslog("Rename ok");
657 // Rename docs starting with $oldref with $newref
658 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
659 foreach ($listoffiles as $fileentry) {
660 $dirsource = $fileentry['name'];
661 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
662 $dirsource = $fileentry['path'].'/'.$dirsource;
663 $dirdest = $fileentry['path'].'/'.$dirdest;
664 @rename($dirsource, $dirdest);
665 }
666 }
667 }
668 }
669 }
670
671 // Set new ref and current status
672 if (!$error) {
673 $this->ref = $num;
674 $this->status = self::STATUS_VALIDATED;
675 }
676
677 if (!$error) {
678 $this->db->commit();
679 return 1;
680 } else {
681 $this->db->rollback();
682 return -1;
683 }
684 }
685
693 public function approve($user, $notrigger = 0)
694 {
695 global $conf;
696
697 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
698
699 $error = 0;
700
701 // Protection
702 if ($this->status == self::STATUS_APPROVED) {
703 dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING);
704 return 0;
705 }
706
707 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
708 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->partnership_advance->accept))))
709 {
710 $this->error='NotEnoughPermissions';
711 dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
712 return -1;
713 }*/
714
715 $now = dol_now();
716
717 $this->db->begin();
718
719 // Define new ref
720 if (!$error && (preg_match('/^[\‍(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
721 $num = $this->getNextNumRef();
722 } else {
723 $num = $this->ref;
724 }
725 $this->newref = $num;
726
727 if (!empty($num)) {
728 // Accept
729 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
730 $sql .= " SET ref = '".$this->db->escape($num)."',";
731 $sql .= " status = ".self::STATUS_APPROVED;
732 // if (!empty($this->fields['date_validation'])) {
733 // $sql .= ", date_validation = '".$this->db->idate($now)."'";
734 // }
735 // if (!empty($this->fields['fk_user_valid'])) {
736 // $sql .= ", fk_user_valid = ".$user->id;
737 // }
738 $sql .= " WHERE rowid = ".((int) $this->id);
739
740 dol_syslog(get_class($this)."::accept()", LOG_DEBUG);
741 $resql = $this->db->query($sql);
742 if (!$resql) {
743 dol_print_error($this->db);
744 $this->error = $this->db->lasterror();
745 $error++;
746 }
747
748 if (!$error && !$notrigger) {
749 // Call trigger
750 $result = $this->call_trigger('PARTNERSHIP_ACCEPT', $user);
751 if ($result < 0) {
752 $error++;
753 }
754 // End call triggers
755 }
756 }
757
758 if (!$error) {
759 $this->oldref = $this->ref;
760
761 // Rename directory if dir was a temporary ref
762 if (preg_match('/^[\‍(]?PROV/i', $this->ref)) {
763 // Now we rename also files into index
764 $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)."'";
765 $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
766 $resql = $this->db->query($sql);
767 if (!$resql) {
768 $error++;
769 $this->error = $this->db->lasterror();
770 }
771 $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filepath = 'partnership/".$this->db->escape($this->newref)."'";
772 $sql .= " WHERE filepath = 'partnership/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
773 $resql = $this->db->query($sql);
774 if (!$resql) {
775 $error++;
776 $this->error = $this->db->lasterror();
777 }
778
779 // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
780 $oldref = dol_sanitizeFileName($this->ref);
781 $newref = dol_sanitizeFileName($num);
782 $dirsource = $conf->partnership->dir_output.'/partnership/'.$oldref;
783 $dirdest = $conf->partnership->dir_output.'/partnership/'.$newref;
784 if (!$error && file_exists($dirsource)) {
785 dol_syslog(get_class($this)."::accept() rename dir ".$dirsource." into ".$dirdest);
786
787 if (@rename($dirsource, $dirdest)) {
788 dol_syslog("Rename ok");
789 // Rename docs starting with $oldref with $newref
790 $listoffiles = dol_dir_list($conf->partnership->dir_output.'/partnership/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
791 foreach ($listoffiles as $fileentry) {
792 $dirsource = $fileentry['name'];
793 $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
794 $dirsource = $fileentry['path'].'/'.$dirsource;
795 $dirdest = $fileentry['path'].'/'.$dirdest;
796 @rename($dirsource, $dirdest);
797 }
798 }
799 }
800 }
801 }
802
803 // Set new ref and current status
804 if (!$error) {
805 $this->ref = $num;
806 $this->status = self::STATUS_APPROVED;
807 }
808
809 if (!$error) {
810 $this->db->commit();
811 return 1;
812 } else {
813 $this->db->rollback();
814 return -1;
815 }
816 }
817
818
826 public function setDraft($user, $notrigger = 0)
827 {
828 // Protection
829 if ($this->status <= self::STATUS_DRAFT) {
830 return 0;
831 }
832
833 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
834 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
835 {
836 $this->error='Permission denied';
837 return -1;
838 }*/
839
840 return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIP_UNVALIDATE');
841 }
842
851 public function refused($user, $reasondeclinenote = '', $notrigger = 0)
852 {
853 // Protection
854 if ($this->status == self::STATUS_REFUSED) {
855 return 0;
856 }
857
858 $this->status = self::STATUS_REFUSED;
859 $this->reason_decline_or_cancel = $reasondeclinenote;
860
861 $result = $this->update($user);
862
863 if ($result) {
864 $this->reason_decline_or_cancel = $reasondeclinenote;
865 return 1;
866 }
867
868 return -1;
869 }
870
878 public function cancel($user, $notrigger = 0)
879 {
880 // Protection
881 if ($this->status != self::STATUS_APPROVED) {
882 return 0;
883 }
884
885 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
886 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
887 {
888 $this->error='Permission denied';
889 return -1;
890 }*/
891
892 return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIP_CANCEL');
893 }
894
902 public function reopen($user, $notrigger = 0)
903 {
904 // Protection
905 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
906 return 0;
907 }
908
909 /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership->write))
910 || (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && !empty($user->rights->partnership_advance->validate))))
911 {
912 $this->error='Permission denied';
913 return -1;
914 }*/
915
916 return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN');
917 }
918
926 public function getTooltipContentArray($params)
927 {
928 global $langs;
929
930 $langs->load('partnership');
931
932 $datas = [];
933 $datas['picto'] = img_picto('', $this->picto).' <u>'.$langs->trans("Partnership").'</u>';
934 if (isset($this->status)) {
935 $datas['picto'] .= ' '.$this->getLibStatut(5);
936 }
937 $datas['ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
938
939 return $datas;
940 }
941
952 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
953 {
954 global $conf, $langs, $hookmanager;
955
956 if (!empty($conf->dol_no_mouse_hover)) {
957 $notooltip = 1; // Force disable tooltips
958 }
959
960 $result = '';
961 $params = [
962 'id' => $this->id,
963 'objecttype' => $this->element,
964 'option' => $option,
965 ];
966 $classfortooltip = 'classfortooltip';
967 $dataparams = '';
968 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
969 $classfortooltip = 'classforajaxtooltip';
970 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
971 $label = '';
972 } else {
973 $label = implode($this->getTooltipContentArray($params));
974 }
975
976 $url = DOL_URL_ROOT.'/partnership/partnership_card.php?id='.$this->id;
977
978 if ($option != 'nolink') {
979 // Add param to save lastsearch_values or not
980 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
981 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
982 $add_save_lastsearch_values = 1;
983 }
984 if ($add_save_lastsearch_values) {
985 $url .= '&save_lastsearch_values=1';
986 }
987 }
988
989 $linkclose = '';
990 if (empty($notooltip)) {
991 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
992 $label = $langs->trans("ShowPartnership");
993 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
994 }
995 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
996 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
997 } else {
998 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
999 }
1000
1001 if ($option == 'nolink') {
1002 $linkstart = '<span';
1003 } else {
1004 $linkstart = '<a href="'.$url.'"';
1005 }
1006 $linkstart .= $linkclose.'>';
1007 if ($option == 'nolink') {
1008 $linkend = '</span>';
1009 } else {
1010 $linkend = '</a>';
1011 }
1012
1013 $result .= $linkstart;
1014
1015 if (empty($this->showphoto_on_popup)) {
1016 if ($withpicto) {
1017 $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);
1018 }
1019 } else {
1020 if ($withpicto) {
1021 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
1022
1023 list($class, $module) = explode('@', $this->picto);
1024 $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref);
1025 $filearray = dol_dir_list($upload_dir, "files");
1026 $filename = $filearray[0]['name'];
1027 if (!empty($filename)) {
1028 $pospoint = strpos($filearray[0]['name'], '.');
1029
1030 $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint);
1031 if (!getDolGlobalString(strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS')) {
1032 $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>';
1033 } else {
1034 $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>';
1035 }
1036
1037 $result .= '</div>';
1038 } else {
1039 $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);
1040 }
1041 }
1042 }
1043
1044 if ($withpicto != 2) {
1045 $result .= $this->ref;
1046 }
1047
1048 $result .= $linkend;
1049 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1050
1051 global $action, $hookmanager;
1052 $hookmanager->initHooks(array('partnershipdao'));
1053 $parameters = array('id'=>$this->id, 'getnomurl' => &$result);
1054 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1055 if ($reshook > 0) {
1056 $result = $hookmanager->resPrint;
1057 } else {
1058 $result .= $hookmanager->resPrint;
1059 }
1060
1061 return $result;
1062 }
1063
1070 public function getLibStatut($mode = 0)
1071 {
1072 return $this->LibStatut($this->status, $mode);
1073 }
1074
1075 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1083 public function LibStatut($status, $mode = 0)
1084 {
1085 // phpcs:enable
1086 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1087 global $langs;
1088 //$langs->load("partnership");
1089 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1090 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1091 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1092 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1093 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1094 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
1095 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
1096 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved');
1097 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused');
1098 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Terminated');
1099 }
1100
1101 $statusType = 'status'.$status;
1102 if ($status == self::STATUS_APPROVED) {
1103 $statusType = 'status4';
1104 }
1105 if ($status == self::STATUS_REFUSED) {
1106 $statusType = 'status9';
1107 }
1108 if ($status == self::STATUS_CANCELED) {
1109 $statusType = 'status6';
1110 }
1111
1112 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
1113 }
1114
1121 public function info($id)
1122 {
1123 $sql = 'SELECT rowid, date_creation as datec, tms as datem,';
1124 $sql .= ' fk_user_creat, fk_user_modif';
1125 $sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
1126 $sql .= ' WHERE t.rowid = '.((int) $id);
1127 $result = $this->db->query($sql);
1128 if ($result) {
1129 if ($this->db->num_rows($result)) {
1130 $obj = $this->db->fetch_object($result);
1131
1132 $this->id = $obj->rowid;
1133
1134 $this->user_creation_id = $obj->fk_user_creat;
1135 $this->user_modification_id = $obj->fk_user_modif;
1136 $this->date_creation = $this->db->jdate($obj->datec);
1137 $this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
1138 }
1139
1140 $this->db->free($result);
1141 } else {
1142 dol_print_error($this->db);
1143 }
1144 }
1145
1152 public function initAsSpecimen()
1153 {
1154 $this->initAsSpecimenCommon();
1155 }
1156
1162 public function getLinesArray()
1163 {
1164 $this->lines = array();
1165
1166 $objectline = new PartnershipLine($this->db);
1167 $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_partnership = '.((int) $this->id)));
1168
1169 if (is_numeric($result)) {
1170 $this->error = $objectline->error;
1171 $this->errors = $objectline->errors;
1172 return $result;
1173 } else {
1174 $this->lines = $result;
1175 return $this->lines;
1176 }
1177 }
1178
1184 public function getNextNumRef()
1185 {
1186 global $langs, $conf;
1187 $langs->load("partnership");
1188
1189 if (!getDolGlobalString('PARTNERSHIP_ADDON')) {
1190 $conf->global->PARTNERSHIP_ADDON = 'mod_partnership_standard';
1191 }
1192
1193 if (getDolGlobalString('PARTNERSHIP_ADDON')) {
1194 $mybool = false;
1195
1196 $file = getDolGlobalString('PARTNERSHIP_ADDON') . ".php";
1197 $classname = $conf->global->PARTNERSHIP_ADDON;
1198
1199 // Include file with class
1200 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
1201 foreach ($dirmodels as $reldir) {
1202 $dir = dol_buildpath($reldir."core/modules/partnership/");
1203
1204 // Load file with numbering class (if found)
1205 $mybool |= @include_once $dir.$file;
1206 }
1207
1208 if ($mybool === false) {
1209 dol_print_error('', "Failed to include file ".$file);
1210 return '';
1211 }
1212
1213 if (class_exists($classname)) {
1214 $obj = new $classname();
1215 $numref = $obj->getNextValue($this);
1216
1217 if ($numref != '' && $numref != '-1') {
1218 return $numref;
1219 } else {
1220 $this->error = $obj->error;
1221 //dol_print_error($this->db,get_class($this)."::getNextNumRef ".$obj->error);
1222 return "";
1223 }
1224 } else {
1225 print $langs->trans("Error")." ".$langs->trans("ClassNotFound").' '.$classname;
1226 return "";
1227 }
1228 } else {
1229 print $langs->trans("ErrorNumberingModuleNotSetup", $this->element);
1230 return "";
1231 }
1232 }
1233
1245 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
1246 {
1247 global $conf, $langs;
1248
1249 $result = 0;
1250 $includedocgeneration = 0;
1251
1252 $langs->load("partnership");
1253
1254 if (!dol_strlen($modele)) {
1255 $modele = 'standard_partnership';
1256
1257 if (!empty($this->model_pdf)) {
1258 $modele = $this->model_pdf;
1259 } elseif (getDolGlobalString('PARTNERSHIP_ADDON_PDF')) {
1260 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1261 }
1262 }
1263
1264 $modelpath = "core/modules/partnership/doc/";
1265
1266 if ($includedocgeneration && !empty($modele)) {
1267 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1268 }
1269
1270 return $result;
1271 }
1272
1280 public function doScheduledJob()
1281 {
1282 //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
1283
1284 $error = 0;
1285 $this->output = '';
1286 $this->error = '';
1287
1288 dol_syslog(__METHOD__, LOG_DEBUG);
1289
1290 //$now = dol_now();
1291
1292 $this->db->begin();
1293
1294 // ...
1295
1296 $this->db->commit();
1297
1298 return $error;
1299 }
1300
1308 public function getKanbanView($option = '', $arraydata = null)
1309 {
1310 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
1311
1312 $return = '<div class="box-flex-item box-flex-grow-zero">';
1313 $return .= '<div class="info-box info-box-sm">';
1314 $return .= '<span class="info-box-icon bg-infobox-action">';
1315 $return .= img_picto('', $this->picto);
1316 $return .= '</span>';
1317 $return .= '<div class="info-box-content">';
1318 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl() : $this->ref).'</span>';
1319 if ($selected >= 0) {
1320 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
1321 }
1322 if (property_exists($this, 'label')) {
1323 $return .= ' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.'</div>';
1324 }
1325 if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
1326 $return .= '<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).'</div>';
1327 }
1328 if (method_exists($this, 'getLibStatut')) {
1329 $return .= '<br><div class="info-box-status">'.$this->getLibStatut(3).'</div>';
1330 }
1331 $return .= '</div>';
1332 $return .= '</div>';
1333 $return .= '</div>';
1334
1335 return $return;
1336 }
1337}
1338
1339
1340require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php';
1341
1346{
1347 // To complete with content of an object PartnershipLine
1348 // We should have a field rowid, fk_partnership and position
1349
1353 public $isextrafieldmanaged = 0;
1354
1360 public function __construct(DoliDB $db)
1361 {
1362 $this->db = $db;
1363 }
1364}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Definition security.php:604
$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...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
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.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the 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.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
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 optionaly the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
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.
update(User $user, $notrigger=false)
Update object into database.
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
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.
create(User $user, $notrigger=false)
Create object into 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.
Class PartnershipLine.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
dol_dir_list($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:62
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.
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.