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' => 0,
'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 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'position' => 61,
'notnull' => 0,
'visible' => 0,),
113 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'position' => 62,
'notnull' => 0,
'visible' => 0,),
114 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,
'csslist' =>
'nowraponall'),
115 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => -2,
'csslist' =>
'nowraponall'),
116 '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'),
117 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,
'csslist' =>
'tdoverflowmax125'),
118 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 0,),
119 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
120 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'position' => 1010,
'notnull' => -1,
'visible' => 0,),
121 'date_partnership_start' => array(
'type' =>
'date',
'label' =>
'DatePartnershipStart',
'enabled' => 1,
'position' => 52,
'notnull' => 1,
'visible' => 1,),
122 'date_partnership_end' => array(
'type' =>
'date',
'label' =>
'DatePartnershipEnd',
'enabled' => 1,
'position' => 53,
'notnull' => 0,
'visible' => 1,),
123 'url_to_check' => array(
'type' =>
'url',
'label' =>
'UrlToCheck',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 70,
'notnull' => 0,
'visible' => -1,
'csslist' =>
'tdoverflowmax150'),
124 'count_last_url_check_error' => array(
'type' =>
'integer',
'label' =>
'CountLastUrlCheckError',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 71,
'notnull' => 0,
'visible' => -4,
'default' =>
'0',),
125 'last_check_backlink' => array(
'type' =>
'datetime',
'label' =>
'LastCheckBacklink',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 72,
'notnull' => 0,
'visible' => -4,
'csslist' =>
'nowraponall'),
126 'reason_decline_or_cancel' => array(
'type' =>
'text',
'label' =>
'ReasonDeclineOrCancel',
'enabled' => 1,
'position' => 73,
'notnull' => 0,
'visible' => -2,),
127 'ip' => array(
'type' =>
'ip',
'label' =>
'IPOfApplicant',
'enabled' => 1,
'position' => 74,
'notnull' => 0,
'visible' => -2,),
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);
348 $this->errors =
$object->errors;
360 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
367 unset(
$object->context[
'createfromclone']);
374 $this->db->rollback();
389 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
392 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
396 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
397 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
398 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
399 $sql .=
', p.note_private, p.note_public, p.url_to_check';
400 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
401 $sql .=
', p.import_key, p.model_pdf';
402 $sql .=
', pt.code as type_code, pt.label as type_label';
403 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
404 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
407 $sql .=
" WHERE p.rowid = ".((int) $id);
409 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
413 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
416 if ($fk_member > 0) {
417 $sql .=
' AND p.fk_member = '.((int) $fk_member);
420 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
422 $sql .=
' ORDER BY p.date_partnership_end DESC';
424 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
425 $result = $this->db->query($sql);
427 $obj = $this->db->fetch_object($result);
429 $this->
id = $obj->rowid;
430 $this->entity = $obj->entity;
431 $this->
ref = $obj->ref;
433 $this->fk_type = $obj->fk_type;
434 $this->type_code = $obj->type_code;
435 $this->type_label = $obj->type_label;
437 $this->fk_soc = $obj->fk_soc;
438 $this->fk_member = $obj->fk_member;
439 $this->
status = $obj->status;
440 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
441 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
442 $this->date_creation = $this->db->jdate($obj->date_creation);
443 $this->fk_user_creat = $obj->fk_user_creat;
444 $this->tms = $obj->tms;
445 $this->fk_user_modif = $obj->fk_user_modif;
446 $this->note_private = $obj->note_private;
447 $this->note_public = $obj->note_public;
448 $this->last_main_doc = $obj->last_main_doc;
449 $this->count_last_url_check_error = $obj->count_last_url_check_error;
450 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
451 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
452 $this->import_key = $obj->import_key;
453 $this->model_pdf = $obj->model_pdf;
454 $this->url_to_check = $obj->url_to_check;
460 $this->db->free($result);
468 $this->error = $this->db->error();
481 $this->lines = array();
499 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
507 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
508 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
509 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
511 $sql .=
' WHERE 1 = 1';
515 if (is_array($filter)) {
517 if (count($filter) > 0) {
518 foreach ($filter as $key => $value) {
519 if ($key ==
't.rowid') {
520 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
521 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
522 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
523 } elseif (strpos($value,
'%') ===
false) {
524 $sqlwhere[] = $this->db->sanitize($key).
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
526 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
530 if (count($sqlwhere) > 0) {
531 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
541 $this->errors[] = $errormessage;
542 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
546 if (!empty($sortfield)) {
547 $sql .= $this->db->order($sortfield, $sortorder);
549 if (!empty($limit)) {
550 $sql .= $this->db->plimit($limit, $offset);
553 $resql = $this->db->query($sql);
555 $num = $this->db->num_rows($resql);
557 while ($i < ($limit ? min($limit, $num) : $num)) {
558 $obj = $this->db->fetch_object($resql);
560 $record =
new self($this->db);
561 $record->setVarsFromFetchObj($obj);
563 $records[$record->id] = $record;
567 $this->db->free($resql);
571 $this->errors[] =
'Error '.$this->db->lasterror();
572 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
587 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
588 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
591 if (empty($this->fk_user_creat)) {
592 $this->fk_user_creat = $user->id;
605 public function delete(
User $user, $notrigger = 0)
622 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
641 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
646 if ($this->
status == self::STATUS_VALIDATED) {
647 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
664 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
667 $num = (string) $this->
ref;
669 $this->newref = $num;
673 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
674 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
675 $sql .=
" status = ".self::STATUS_VALIDATED;
676 if (!empty($this->fields[
'date_validation'])) {
677 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
679 if (!empty($this->fields[
'fk_user_valid'])) {
680 $sql .=
", fk_user_valid = ".((int) $user->id);
682 $sql .=
" WHERE rowid = ".((int) $this->
id);
684 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
685 $resql = $this->db->query($sql);
688 $this->error = $this->db->lasterror();
692 if (!$error && !$notrigger) {
694 $result = $this->call_trigger(
'PARTNERSHIP_VALIDATE', $user);
703 $this->oldref = $this->ref;
706 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
708 $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).
"'";
709 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
710 $resql = $this->db->query($sql);
713 $this->error = $this->db->lasterror();
715 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
716 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
717 $resql = $this->db->query($sql);
720 $this->error = $this->db->lasterror();
726 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
727 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
728 if (!$error && file_exists($dirsource)) {
729 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
731 if (@rename($dirsource, $dirdest)) {
734 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
735 foreach ($listoffiles as $fileentry) {
736 $dirsource = $fileentry[
'name'];
737 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
738 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
739 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
740 @rename($dirsource, $dirdest);
750 $this->
status = self::STATUS_VALIDATED;
757 $this->db->rollback();
769 public function approve($user, $notrigger = 0)
773 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
778 if ($this->
status == self::STATUS_APPROVED) {
779 dol_syslog(get_class($this).
"::accept action abandoned: already acceptd", LOG_WARNING);
796 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
799 $num = (string) $this->
ref;
801 $this->newref = $num;
805 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
806 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
807 $sql .=
" status = ".self::STATUS_APPROVED;
808 $sql .=
" WHERE rowid = ".((int) $this->
id);
810 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
811 $resql = $this->db->query($sql);
814 $this->error = $this->db->lasterror();
818 if (!$error && !$notrigger) {
820 $result = $this->call_trigger(
'PARTNERSHIP_ACCEPT', $user);
829 $this->oldref = $this->ref;
832 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
834 $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).
"'";
835 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
836 $resql = $this->db->query($sql);
839 $this->error = $this->db->lasterror();
841 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
842 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
843 $resql = $this->db->query($sql);
846 $this->error = $this->db->lasterror();
852 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
853 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
854 if (!$error && file_exists($dirsource)) {
855 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
857 if (@rename($dirsource, $dirdest)) {
860 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
861 foreach ($listoffiles as $fileentry) {
862 $dirsource = $fileentry[
'name'];
863 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
864 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
865 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
866 @rename($dirsource, $dirdest);
876 $this->
status = self::STATUS_APPROVED;
883 $this->db->rollback();
899 if ($this->
status <= self::STATUS_DRAFT) {
910 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
921 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
924 if ($this->
status == self::STATUS_REFUSED) {
928 $this->
status = self::STATUS_REFUSED;
929 $this->reason_decline_or_cancel = $reasondeclinenote;
931 $result = $this->
update($user);
934 $this->reason_decline_or_cancel = $reasondeclinenote;
948 public function cancel($user, $notrigger = 0)
951 if ($this->
status != self::STATUS_APPROVED) {
962 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
972 public function reopen($user, $notrigger = 0)
975 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_REFUSED) {
986 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
999 $langs->load(
'partnership');
1002 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
1003 if (isset($this->
status)) {
1004 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1006 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1021 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1023 global $conf, $langs, $hookmanager;
1025 if (!empty($conf->dol_no_mouse_hover)) {
1032 'objecttype' => $this->element,
1033 'option' => $option,
1035 $classfortooltip =
'classfortooltip';
1038 $classfortooltip =
'classforajaxtooltip';
1039 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1045 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1047 if ($option !=
'nolink') {
1049 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1050 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1051 $add_save_lastsearch_values = 1;
1053 if ($add_save_lastsearch_values) {
1054 $url .=
'&save_lastsearch_values=1';
1059 if (empty($notooltip)) {
1061 $label = $langs->trans(
"ShowPartnership");
1062 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1064 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1065 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1067 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1070 if ($option ==
'nolink') {
1071 $linkstart =
'<span';
1073 $linkstart =
'<a href="'.$url.
'"';
1075 $linkstart .= $linkclose.
'>';
1076 if ($option ==
'nolink') {
1077 $linkend =
'</span>';
1082 $result .= $linkstart;
1084 if (empty($this->showphoto_on_popup)) {
1086 $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);
1090 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1092 list($class, $module) = explode(
'@', $this->picto);
1095 $filename = $filearray[0][
'name'];
1096 if (!empty($filename)) {
1097 $pospoint = strpos($filearray[0][
'name'],
'.');
1099 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1100 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1101 $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>';
1103 $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>';
1106 $result .=
'</div>';
1108 $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);
1113 if ($withpicto != 2) {
1114 $result .= $this->ref;
1117 $result .= $linkend;
1120 global $action, $hookmanager;
1121 $hookmanager->initHooks(array(
'partnershipdao'));
1122 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1123 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1125 $result = $hookmanager->resPrint;
1127 $result .= $hookmanager->resPrint;
1143 $tables = array(
'partnership');
1172 if (is_null($status)) {
1176 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1179 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1180 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1181 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1182 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1183 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1184 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1185 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1186 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1187 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1188 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1191 $statusType =
'status'.$status;
1192 if ($status == self::STATUS_APPROVED) {
1193 $statusType =
'status4';
1195 if ($status == self::STATUS_REFUSED) {
1196 $statusType =
'status9';
1198 if ($status == self::STATUS_CANCELED) {
1199 $statusType =
'status6';
1202 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1213 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1214 $sql .=
' fk_user_creat, fk_user_modif';
1215 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1216 $sql .=
' WHERE t.rowid = '.((int) $id);
1217 $result = $this->db->query($sql);
1219 if ($this->db->num_rows($result)) {
1220 $obj = $this->db->fetch_object($result);
1222 $this->
id = $obj->rowid;
1224 $this->user_creation_id = $obj->fk_user_creat;
1225 $this->user_modification_id = $obj->fk_user_modif;
1226 $this->date_creation = $this->db->jdate($obj->datec);
1227 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1230 $this->db->free($result);
1254 $this->lines = array();
1257 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_partnership:=:'.((
int) $this->
id).
')');
1259 if (is_numeric($result)) {
1260 $this->error = $objectline->error;
1261 $this->errors = $objectline->errors;
1264 $this->lines = $result;
1277 global $langs, $conf;
1278 $langs->load(
"partnership");
1281 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1291 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1292 foreach ($dirmodels as $reldir) {
1296 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1304 if (class_exists($classname)) {
1305 $obj =
new $classname();
1306 '@phan-var-force ModeleNumRefPartnership $obj';
1307 $numref = $obj->getNextValue($this);
1309 if ($numref !=
'' && $numref !=
'-1') {
1312 $this->error = $obj->error;
1317 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1321 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1337 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1339 global $conf, $langs;
1342 $includedocgeneration = 0;
1344 $langs->load(
"partnership");
1347 $modele =
'standard_partnership';
1349 if (!empty($this->model_pdf)) {
1350 $modele = $this->model_pdf;
1356 $modelpath =
"core/modules/partnership/doc/";
1358 if ($includedocgeneration && !empty($modele)) {
1359 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1388 $this->db->commit();
1402 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1404 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1405 $return .=
'<div class="info-box info-box-sm">';
1406 $return .=
'<span class="info-box-icon bg-infobox-action">';
1408 $return .=
'</span>';
1409 $return .=
'<div class="info-box-content">';
1410 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1411 if ($selected >= 0) {
1412 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1414 if (property_exists($this,
'label')) {
1415 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1417 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1418 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1420 if (method_exists($this,
'getLibStatut')) {
1421 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1423 $return .=
'</div>';
1424 $return .=
'</div>';
1425 $return .=
'</div>';
1432require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1452 $this->isextrafieldmanaged = 0;
if(! $sortfield) if(! $sortorder) $object
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.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
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.
__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.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.