31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42 public $module =
'partnership';
47 public $element =
'partnership';
52 public $table_element =
'partnership';
57 public $picto =
'partnership';
69 const STATUS_DRAFT = 0;
70 const STATUS_VALIDATED = 1;
71 const STATUS_APPROVED = 2;
72 const STATUS_REFUSED = 3;
73 const STATUS_CANCELED = 9;
106 public $fields = array(
107 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => -2,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
108 'ref' => array(
'type' =>
'varchar(128)',
'label' =>
'Ref',
'enabled' => 1,
'position' => 10,
'notnull' => 1,
'visible' => 4,
'noteditable' => 1,
'default' =>
'(PROV)',
'index' => 1,
'searchall' => 1,
'showoncombobox' => 1,
'comment' =>
"Reference of object",
'csslist' =>
'tdoverflowmax150'),
109 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' =>
'isModEnabled("multicompany")',
'position' => 15,
'notnull' => 1,
'visible' => -2,
'default' =>
'1',
'index' => 1,),
110 'fk_type' => array(
'type' =>
'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)',
'label' =>
'Type',
'enabled' => 1,
'position' => 20,
'notnull' => 1,
'visible' => 1,
'csslist' =>
'tdoverflowmax100',
'help' =>
'YouCanChangeValuesForThisListFromDictionarySetup'),
111 'fk_soc' => array(
'type' =>
'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))',
'label' =>
'ThirdParty',
'picto' =>
'company',
'enabled' => 1,
'position' => 50,
'notnull' => -1,
'visible' => 1,
'index' => 1,
'css' =>
'maxwidth500',
'csslist' =>
'tdoverflowmax125',),
112 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,
'csslist' =>
'nowraponall'),
113 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => -2,
'csslist' =>
'nowraponall'),
114 'fk_user_creat' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserAuthor',
'enabled' => 1,
'position' => 510,
'notnull' => 1,
'visible' => -2,
'foreignkey' =>
'user.rowid',
'csslist' =>
'tdoverflowmax125'),
115 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,
'csslist' =>
'tdoverflowmax125'),
116 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 0,),
117 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
118 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'position' => 1010,
'notnull' => -1,
'visible' => 0,),
119 'date_partnership_start' => array(
'type' =>
'date',
'label' =>
'DatePartnershipStart',
'enabled' => 1,
'position' => 60,
'notnull' => 1,
'visible' => 1,),
120 'date_partnership_end' => array(
'type' =>
'date',
'label' =>
'DatePartnershipEnd',
'enabled' => 1,
'position' => 65,
'notnull' => 0,
'visible' => 1,),
121 'url_to_check' => array(
'type' =>
'url',
'label' =>
'UrlToCheck',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 70,
'notnull' => 0,
'visible' => -1,
'csslist' =>
'tdoverflowmax150'),
122 'count_last_url_check_error' => array(
'type' =>
'integer',
'label' =>
'CountLastUrlCheckError',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 71,
'notnull' => 0,
'visible' => -4,
'default' =>
'0',),
123 'last_check_backlink' => array(
'type' =>
'datetime',
'label' =>
'LastCheckBacklink',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 72,
'notnull' => 0,
'visible' => -4,
'csslist' =>
'nowraponall'),
124 'reason_decline_or_cancel' => array(
'type' =>
'text',
'label' =>
'ReasonDeclineOrCancel',
'enabled' => 1,
'position' => 73,
'notnull' => 0,
'visible' => -2,),
125 'ip' => array(
'type' =>
'ip',
'label' =>
'IPOfApplicant',
'enabled' => 1,
'position' => 74,
'notnull' => 0,
'visible' => -2,),
126 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'position' => 80,
'notnull' => 0,
'visible' => 0,),
127 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'position' => 81,
'notnull' => 0,
'visible' => 0,),
128 'status' => array(
'type' =>
'smallint',
'label' =>
'Status',
'enabled' => 1,
'position' => 2000,
'notnull' => 1,
'visible' => 2,
'default' =>
'0',
'index' => 1,
'arrayofkeyval' => array(0 =>
'Draft', 1 =>
'Validated', 2 =>
'Approved', 3 =>
'Refused', 9 =>
'Terminated'),),
152 public $note_private;
156 public $fk_user_creat;
160 public $fk_user_modif;
164 public $last_main_doc;
176 public $date_partnership_start;
180 public $date_partnership_end;
184 public $url_to_check;
188 public $count_last_url_check_error;
192 public $last_check_backlink;
196 public $reason_decline_or_cancel;
227 $this->ismultientitymanaged = 0;
228 $this->isextrafieldmanaged = 1;
231 $this->fields[
'fk_member'] = array(
'type' =>
'integer:Adherent:adherents/class/adherent.class.php:1',
'label' =>
'Member',
'enabled' =>
'1',
'position' => 50,
'notnull' => -1,
'visible' => 1,
'index' => 1,
'picto' =>
'member',
'css' =>
'maxwidth500',
'csslist' =>
'tdoverflowmax150');
232 unset($this->fields[
'fk_soc']);
234 $this->fields[
'fk_soc'] = array(
'type' =>
'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))',
'label' =>
'ThirdParty',
'enabled' =>
'1',
'position' => 50,
'notnull' => -1,
'visible' => 1,
'index' => 1,
'picto' =>
'company',
'css' =>
'maxwidth500',
'csslist' =>
'tdoverflowmax150');
235 unset($this->fields[
'fk_member']);
239 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
240 $this->fields[
'rowid'][
'visible'] = 0;
244 foreach ($this->fields as $key => $val) {
245 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
246 unset($this->fields[$key]);
251 if (is_object($langs)) {
252 foreach ($this->fields as $key => $val) {
253 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
254 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
255 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
271 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
272 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
289 global $langs, $extrafields;
299 $result =
$object->fetchCommon($fromid);
300 if ($result > 0 && !empty(
$object->table_element_line)) {
311 unset(
$object->user_creation_id);
315 if (property_exists(
$object,
'ref')) {
317 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
319 if (property_exists(
$object,
'status')) {
320 $object->status = self::STATUS_DRAFT;
322 if (property_exists(
$object,
'date_creation')) {
325 if (property_exists(
$object,
'date_modification')) {
326 $object->date_modification =
null;
330 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
331 $extrafields->fetch_name_optionals_label($this->table_element);
332 foreach (
$object->array_options as $key => $option) {
333 $shortkey = preg_replace(
'/options_/',
'', $key);
334 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
337 unset(
$object->array_options[$key]);
343 $object->context[
'createfromclone'] =
'createfromclone';
344 $result =
$object->createCommon($user);
357 unset(
$object->context[
'createfromclone']);
364 $this->db->rollback();
379 public function fetch($id, $ref =
'', $fk_member = 0, $fk_soc = 0)
382 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
386 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
387 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
388 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
389 $sql .=
', p.note_private, p.note_public, p.url_to_check';
390 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
391 $sql .=
', p.import_key, p.model_pdf';
392 $sql .=
', pt.code as type_code, pt.label as type_label';
393 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
394 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
397 $sql .=
" WHERE p.rowid = ".((int) $id);
399 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
403 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
406 if ($fk_member > 0) {
407 $sql .=
' AND p.fk_member = '.((int) $fk_member);
410 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
412 $sql .=
' ORDER BY p.date_partnership_end DESC';
414 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
415 $result = $this->db->query($sql);
417 $obj = $this->db->fetch_object($result);
419 $this->
id = $obj->rowid;
420 $this->entity = $obj->entity;
421 $this->
ref = $obj->ref;
423 $this->fk_type = $obj->fk_type;
424 $this->type_code = $obj->type_code;
425 $this->type_label = $obj->type_label;
427 $this->fk_soc = $obj->fk_soc;
428 $this->fk_member = $obj->fk_member;
429 $this->
status = $obj->status;
430 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
431 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
432 $this->date_creation = $this->db->jdate($obj->date_creation);
433 $this->fk_user_creat = $obj->fk_user_creat;
434 $this->tms = $obj->tms;
435 $this->fk_user_modif = $obj->fk_user_modif;
436 $this->note_private = $obj->note_private;
437 $this->note_public = $obj->note_public;
438 $this->last_main_doc = $obj->last_main_doc;
439 $this->count_last_url_check_error = $obj->count_last_url_check_error;
440 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
441 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
442 $this->import_key = $obj->import_key;
443 $this->model_pdf = $obj->model_pdf;
444 $this->url_to_check = $obj->url_to_check;
450 $this->db->free($result);
458 $this->error = $this->db->error();
472 $this->lines = array();
492 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
500 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
501 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
502 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
504 $sql .=
" WHERE 1 = 1";
508 if (is_array($filter)) {
510 if (count($filter) > 0) {
511 foreach ($filter as $key => $value) {
512 if ($key ==
't.rowid') {
513 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
514 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
515 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
516 } elseif (strpos($value,
'%') ===
false) {
517 $sqlwhere[] = $this->db->sanitize($key).
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
519 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
523 if (count($sqlwhere) > 0) {
524 $sql .=
" AND (".implode(
' '.$this->db->sanitize($filtermode).
' ', $sqlwhere).
')';
534 $this->errors[] = $errormessage;
535 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
539 if (!empty($sortfield)) {
540 $sql .= $this->db->order($sortfield, $sortorder);
542 if (!empty($limit)) {
543 $sql .= $this->db->plimit($limit, $offset);
546 $resql = $this->db->query($sql);
548 $num = $this->db->num_rows($resql);
550 while ($i < ($limit ? min($limit, $num) : $num)) {
551 $obj = $this->db->fetch_object($resql);
553 $record =
new self($this->db);
554 $record->setVarsFromFetchObj($obj);
556 $record->fetch_optionals();
558 $records[$record->id] = $record;
562 $this->db->free($resql);
566 $this->errors[] =
'Error '.$this->db->lasterror();
567 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
582 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
583 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
586 if (empty($this->fk_user_creat)) {
587 $this->fk_user_creat = $user->id;
600 public function delete(
User $user, $notrigger = 0)
617 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
636 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
641 if ($this->
status == self::STATUS_VALIDATED) {
642 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
659 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
662 $num = (string) $this->
ref;
664 $this->newref = $num;
668 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
669 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
670 $sql .=
" status = ".self::STATUS_VALIDATED;
671 if (!empty($this->fields[
'date_validation'])) {
672 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
674 if (!empty($this->fields[
'fk_user_valid'])) {
675 $sql .=
", fk_user_valid = ".((int) $user->id);
677 $sql .=
" WHERE rowid = ".((int) $this->
id);
679 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
680 $resql = $this->db->query($sql);
682 dol_print_error($this->db);
683 $this->error = $this->db->lasterror();
687 if (!$error && !$notrigger) {
689 $result = $this->call_trigger(
'PARTNERSHIP_VALIDATE', $user);
698 $this->oldref = $this->ref;
701 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
703 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'partnership/".$this->db->escape($this->newref).
"'";
704 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
705 $resql = $this->db->query($sql);
708 $this->error = $this->db->lasterror();
710 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
711 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
712 $resql = $this->db->query($sql);
715 $this->error = $this->db->lasterror();
721 $dirsource =
$conf->partnership->dir_output.
'/partnership/'.$oldref;
722 $dirdest =
$conf->partnership->dir_output.
'/partnership/'.$newref;
723 if (!$error && file_exists($dirsource)) {
724 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
726 if (@rename($dirsource, $dirdest)) {
729 $listoffiles =
dol_dir_list(
$conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
730 foreach ($listoffiles as $fileentry) {
731 $dirsource = $fileentry[
'name'];
732 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
733 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
734 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
735 @rename($dirsource, $dirdest);
745 $this->
status = self::STATUS_VALIDATED;
752 $this->db->rollback();
764 public function approve($user, $notrigger = 0)
768 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
773 if ($this->
status == self::STATUS_APPROVED) {
774 dol_syslog(get_class($this).
"::accept action abandoned: already acceptd", LOG_WARNING);
791 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
794 $num = (string) $this->
ref;
796 $this->newref = $num;
800 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
801 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
802 $sql .=
" status = ".self::STATUS_APPROVED;
803 $sql .=
" WHERE rowid = ".((int) $this->
id);
805 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
806 $resql = $this->db->query($sql);
808 dol_print_error($this->db);
809 $this->error = $this->db->lasterror();
813 if (!$error && !$notrigger) {
815 $result = $this->call_trigger(
'PARTNERSHIP_ACCEPT', $user);
824 $this->oldref = $this->ref;
827 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
829 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'partnership/".$this->db->escape($this->newref).
"'";
830 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
831 $resql = $this->db->query($sql);
834 $this->error = $this->db->lasterror();
836 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
837 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".((int)
$conf->entity);
838 $resql = $this->db->query($sql);
841 $this->error = $this->db->lasterror();
847 $dirsource =
$conf->partnership->dir_output.
'/partnership/'.$oldref;
848 $dirdest =
$conf->partnership->dir_output.
'/partnership/'.$newref;
849 if (!$error && file_exists($dirsource)) {
850 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
852 if (@rename($dirsource, $dirdest)) {
855 $listoffiles =
dol_dir_list(
$conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
856 foreach ($listoffiles as $fileentry) {
857 $dirsource = $fileentry[
'name'];
858 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
859 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
860 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
861 @rename($dirsource, $dirdest);
871 $this->
status = self::STATUS_APPROVED;
878 $this->db->rollback();
894 if ($this->
status <= self::STATUS_DRAFT) {
905 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
916 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
919 if ($this->
status == self::STATUS_REFUSED) {
923 $this->
status = self::STATUS_REFUSED;
924 $this->reason_decline_or_cancel = $reasondeclinenote;
926 $result = $this->
update($user);
929 $this->reason_decline_or_cancel = $reasondeclinenote;
943 public function cancel($user, $notrigger = 0)
946 if ($this->
status != self::STATUS_APPROVED) {
957 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
967 public function reopen($user, $notrigger = 0)
970 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_REFUSED) {
981 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
994 $langs->load(
'partnership');
998 $datas[
'picto'] = img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
999 if (isset($this->
status)) {
1000 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1002 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1017 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1019 global
$conf, $langs, $hookmanager;
1021 if (!empty(
$conf->dol_no_mouse_hover)) {
1027 'id' => (string) $this->
id,
1028 'objecttype' => $this->element,
1029 'option' => $option,
1031 $classfortooltip =
'classfortooltip';
1034 $classfortooltip =
'classforajaxtooltip';
1035 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1041 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1043 if ($option !=
'nolink') {
1045 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1046 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1047 $add_save_lastsearch_values = 1;
1049 if ($add_save_lastsearch_values) {
1050 $url .=
'&save_lastsearch_values=1';
1055 if (empty($notooltip)) {
1057 $label = $langs->trans(
"ShowPartnership");
1058 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1060 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1061 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1063 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1066 if ($option ==
'nolink') {
1067 $linkstart =
'<span';
1069 $linkstart =
'<a href="'.$url.
'"';
1071 $linkstart .= $linkclose.
'>';
1072 if ($option ==
'nolink') {
1073 $linkend =
'</span>';
1078 $result .= $linkstart;
1080 if (empty($this->showphoto_on_popup)) {
1082 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1086 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1088 list($class, $module) = explode(
'@', $this->picto);
1091 $filename = $filearray[0][
'name'];
1092 if (!empty($filename)) {
1093 $pospoint = strpos($filearray[0][
'name'],
'.');
1095 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.
dol_substr($filename, 0, $pospoint).
'_mini'.
dol_substr($filename, $pospoint);
1096 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1097 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.
'" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.
$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div></div>';
1099 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.
$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
1102 $result .=
'</div>';
1104 $result .= img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1109 if ($withpicto != 2) {
1110 $result .= $this->ref;
1113 $result .= $linkend;
1116 global $action, $hookmanager;
1117 $hookmanager->initHooks(array(
'partnershipdao'));
1118 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1119 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1121 $result = $hookmanager->resPrint;
1123 $result .= $hookmanager->resPrint;
1139 $tables = array(
'partnership');
1166 if (is_null($status)) {
1170 $paramsBadge = array(
'badgeParams' => array(
'attr' => array(
1171 'data-status-element' => $this->element,
1172 'data-status' => (
int) $status
1175 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1178 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1179 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1180 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1181 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1182 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1183 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1184 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1185 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1186 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1187 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1190 $statusType =
'status'.$status;
1191 if ($status == self::STATUS_APPROVED) {
1192 $statusType =
'status4';
1194 if ($status == self::STATUS_REFUSED) {
1195 $statusType =
'status9';
1197 if ($status == self::STATUS_CANCELED) {
1198 $statusType =
'status6';
1201 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode,
'', $paramsBadge);
1212 $sql =
"SELECT rowid, date_creation as datec, tms as datem,";
1213 $sql .=
" fk_user_creat, fk_user_modif";
1214 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1215 $sql .=
" WHERE t.rowid = ".((int) $id);
1216 $result = $this->db->query($sql);
1218 if ($this->db->num_rows($result)) {
1219 $obj = $this->db->fetch_object($result);
1221 $this->
id = $obj->rowid;
1223 $this->user_creation_id = $obj->fk_user_creat;
1224 $this->user_modification_id = $obj->fk_user_modif;
1225 $this->date_creation = $this->db->jdate($obj->datec);
1226 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1229 $this->db->free($result);
1231 dol_print_error($this->db);
1253 $this->lines = array();
1256 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_partnership:=:'.((
int) $this->
id).
')');
1258 if (is_numeric($result)) {
1259 $this->error = $objectline->error;
1260 $this->errors = $objectline->errors;
1263 $this->lines = $result;
1276 global $langs,
$conf;
1277 $langs->load(
"partnership");
1280 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1290 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
1291 foreach ($dirmodels as $reldir) {
1295 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1299 dol_print_error(
null,
"Failed to include file ".$file);
1303 if (class_exists($classname)) {
1304 $obj =
new $classname();
1305 '@phan-var-force ModeleNumRefPartnership $obj';
1306 $numref = $obj->getNextValue($this);
1308 if ($numref !=
'' && $numref !=
'-1') {
1311 $this->error = $obj->error;
1316 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1320 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1336 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1341 $includedocgeneration = 0;
1343 $langs->load(
"partnership");
1346 $modele =
'standard_partnership';
1348 if (!empty($this->model_pdf)) {
1349 $modele = $this->model_pdf;
1355 $modelpath =
"core/modules/partnership/doc/";
1357 if ($includedocgeneration && !empty($modele)) {
1358 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1387 $this->db->commit();
1403 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1405 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1406 $return .=
'<div class="info-box info-box-sm">';
1407 $return .=
'<span class="info-box-icon bg-infobox-action">';
1408 $return .= img_picto(
'', $this->picto);
1409 $return .=
'</span>';
1410 $return .=
'<div class="info-box-content">';
1411 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1412 if ($selected >= 0) {
1413 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1415 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1416 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1418 if (method_exists($this,
'getLibStatut')) {
1419 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1421 $return .=
'</div>';
1422 $return .=
'</div>';
1423 $return .=
'</div>';
1430require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1450 $this->isextrafieldmanaged = 0;
if(! $sortfield) if(! $sortorder) $object
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
setErrorsFromObject($object)
setErrorsFromObject
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
initAsSpecimen()
Initialize object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetch($id, $ref='', $fk_member=0, $fk_soc=0)
Load object in memory from the database Get object from database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
dol_now($mode='gmt')
Return date for now.
dol_strlen($string, $stringencoding='UTF-8', $binarycount=0)
Make a strlen call.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0, $forbiddenfields=array())
forgeSQLFromUniversalSearchCriteria
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.