29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $module =
'partnership';
45 public $element =
'partnership';
50 public $table_element =
'partnership';
55 public $picto =
'partnership';
67 const STATUS_DRAFT = 0;
68 const STATUS_VALIDATED = 1;
69 const STATUS_APPROVED = 2;
70 const STATUS_REFUSED = 3;
71 const STATUS_CANCELED = 9;
104 public $fields = array(
105 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => 0,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
106 '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'),
107 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' =>
'isModEnabled("multicompany")',
'position' => 15,
'notnull' => 1,
'visible' => -2,
'default' =>
'1',
'index' => 1,),
108 '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'),
109 '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',),
110 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'position' => 61,
'notnull' => 0,
'visible' => 0,),
111 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'position' => 62,
'notnull' => 0,
'visible' => 0,),
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' => 52,
'notnull' => 1,
'visible' => 1,),
120 'date_partnership_end' => array(
'type' =>
'date',
'label' =>
'DatePartnershipEnd',
'enabled' => 1,
'position' => 53,
'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 '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'),),
151 public $note_private;
155 public $fk_user_creat;
159 public $fk_user_modif;
163 public $last_main_doc;
175 public $date_partnership_start;
179 public $date_partnership_end;
183 public $url_to_check;
187 public $count_last_url_check_error;
191 public $last_check_backlink;
195 public $reason_decline_or_cancel;
222 global
$conf, $langs;
226 $this->ismultientitymanaged = 0;
227 $this->isextrafieldmanaged = 1;
230 $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');
232 $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');
236 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
237 $this->fields[
'rowid'][
'visible'] = 0;
241 foreach ($this->fields as $key => $val) {
242 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
243 unset($this->fields[$key]);
248 if (is_object($langs)) {
249 foreach ($this->fields as $key => $val) {
250 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
251 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
252 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
268 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
269 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
286 global $langs, $extrafields;
296 $result =
$object->fetchCommon($fromid);
297 if ($result > 0 && !empty(
$object->table_element_line)) {
311 if (property_exists(
$object,
'ref')) {
313 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
315 if (property_exists(
$object,
'label')) {
316 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
318 if (property_exists(
$object,
'status')) {
319 $object->status = self::STATUS_DRAFT;
321 if (property_exists(
$object,
'date_creation')) {
324 if (property_exists(
$object,
'date_modification')) {
325 $object->date_modification =
null;
329 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
330 $extrafields->fetch_name_optionals_label($this->table_element);
331 foreach (
$object->array_options as $key => $option) {
332 $shortkey = preg_replace(
'/options_/',
'', $key);
333 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
336 unset(
$object->array_options[$key]);
342 $object->context[
'createfromclone'] =
'createfromclone';
343 $result =
$object->createCommon($user);
347 $this->errors =
$object->errors;
359 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
366 unset(
$object->context[
'createfromclone']);
373 $this->db->rollback();
388 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
391 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
395 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
396 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
397 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
398 $sql .=
', p.note_private, p.note_public, p.url_to_check';
399 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
400 $sql .=
', p.import_key, p.model_pdf';
401 $sql .=
', pt.code as type_code, pt.label as type_label';
402 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
403 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
406 $sql .=
" WHERE p.rowid = ".((int) $id);
408 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
412 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
415 if ($fk_member > 0) {
416 $sql .=
' AND p.fk_member = '.((int) $fk_member);
419 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
421 $sql .=
' ORDER BY p.date_partnership_end DESC';
423 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
424 $result = $this->db->query($sql);
426 $obj = $this->db->fetch_object($result);
428 $this->
id = $obj->rowid;
429 $this->entity = $obj->entity;
430 $this->
ref = $obj->ref;
432 $this->fk_type = $obj->fk_type;
433 $this->type_code = $obj->type_code;
434 $this->type_label = $obj->type_label;
436 $this->fk_soc = $obj->fk_soc;
437 $this->fk_member = $obj->fk_member;
438 $this->
status = $obj->status;
439 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
440 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
441 $this->date_creation = $this->db->jdate($obj->date_creation);
442 $this->fk_user_creat = $obj->fk_user_creat;
443 $this->tms = $obj->tms;
444 $this->fk_user_modif = $obj->fk_user_modif;
445 $this->note_private = $obj->note_private;
446 $this->note_public = $obj->note_public;
447 $this->last_main_doc = $obj->last_main_doc;
448 $this->count_last_url_check_error = $obj->count_last_url_check_error;
449 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
450 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
451 $this->import_key = $obj->import_key;
452 $this->model_pdf = $obj->model_pdf;
453 $this->url_to_check = $obj->url_to_check;
459 $this->db->free($result);
467 $this->error = $this->db->error();
480 $this->lines = array();
498 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
506 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
507 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
508 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
510 $sql .=
' WHERE 1 = 1';
514 if (is_array($filter)) {
516 if (count($filter) > 0) {
517 foreach ($filter as $key => $value) {
518 if ($key ==
't.rowid') {
519 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
520 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
521 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
522 } elseif (strpos($value,
'%') ===
false) {
523 $sqlwhere[] = $this->db->sanitize($key).
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
525 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
529 if (count($sqlwhere) > 0) {
530 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
540 $this->errors[] = $errormessage;
541 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
545 if (!empty($sortfield)) {
546 $sql .= $this->db->order($sortfield, $sortorder);
548 if (!empty($limit)) {
549 $sql .= $this->db->plimit($limit, $offset);
552 $resql = $this->db->query($sql);
554 $num = $this->db->num_rows($resql);
556 while ($i < ($limit ? min($limit, $num) : $num)) {
557 $obj = $this->db->fetch_object($resql);
559 $record =
new self($this->db);
560 $record->setVarsFromFetchObj($obj);
562 $records[$record->id] = $record;
566 $this->db->free($resql);
570 $this->errors[] =
'Error '.$this->db->lasterror();
571 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
586 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
587 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
590 if (empty($this->fk_user_creat)) {
591 $this->fk_user_creat = $user->id;
604 public function delete(
User $user, $notrigger = 0)
621 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
640 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
645 if ($this->
status == self::STATUS_VALIDATED) {
646 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
663 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
668 $this->newref = $num;
672 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
673 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
674 $sql .=
" status = ".self::STATUS_VALIDATED;
675 if (!empty($this->fields[
'date_validation'])) {
676 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
678 if (!empty($this->fields[
'fk_user_valid'])) {
679 $sql .=
", fk_user_valid = ".((int) $user->id);
681 $sql .=
" WHERE rowid = ".((int) $this->
id);
683 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
684 $resql = $this->db->query($sql);
687 $this->error = $this->db->lasterror();
691 if (!$error && !$notrigger) {
693 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
702 $this->oldref = $this->ref;
705 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
707 $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).
"'";
708 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
709 $resql = $this->db->query($sql);
712 $this->error = $this->db->lasterror();
714 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
715 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
716 $resql = $this->db->query($sql);
719 $this->error = $this->db->lasterror();
725 $dirsource =
$conf->partnership->dir_output.
'/partnership/'.$oldref;
726 $dirdest =
$conf->partnership->dir_output.
'/partnership/'.$newref;
727 if (!$error && file_exists($dirsource)) {
728 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
730 if (@rename($dirsource, $dirdest)) {
733 $listoffiles =
dol_dir_list(
$conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
734 foreach ($listoffiles as $fileentry) {
735 $dirsource = $fileentry[
'name'];
736 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
737 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
738 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
739 @rename($dirsource, $dirdest);
749 $this->
status = self::STATUS_VALIDATED;
756 $this->db->rollback();
768 public function approve($user, $notrigger = 0)
772 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
777 if ($this->
status == self::STATUS_APPROVED) {
778 dol_syslog(get_class($this).
"::accept action abandoned: already acceptd", LOG_WARNING);
795 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
800 $this->newref = $num;
804 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
805 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
806 $sql .=
" status = ".self::STATUS_APPROVED;
807 $sql .=
" WHERE rowid = ".((int) $this->
id);
809 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
810 $resql = $this->db->query($sql);
813 $this->error = $this->db->lasterror();
817 if (!$error && !$notrigger) {
819 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
828 $this->oldref = $this->ref;
831 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
833 $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).
"'";
834 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
835 $resql = $this->db->query($sql);
838 $this->error = $this->db->lasterror();
840 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
841 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
842 $resql = $this->db->query($sql);
845 $this->error = $this->db->lasterror();
851 $dirsource =
$conf->partnership->dir_output.
'/partnership/'.$oldref;
852 $dirdest =
$conf->partnership->dir_output.
'/partnership/'.$newref;
853 if (!$error && file_exists($dirsource)) {
854 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
856 if (@rename($dirsource, $dirdest)) {
859 $listoffiles =
dol_dir_list(
$conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
860 foreach ($listoffiles as $fileentry) {
861 $dirsource = $fileentry[
'name'];
862 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
863 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
864 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
865 @rename($dirsource, $dirdest);
875 $this->
status = self::STATUS_APPROVED;
882 $this->db->rollback();
898 if ($this->
status <= self::STATUS_DRAFT) {
909 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
920 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
923 if ($this->
status == self::STATUS_REFUSED) {
927 $this->
status = self::STATUS_REFUSED;
928 $this->reason_decline_or_cancel = $reasondeclinenote;
930 $result = $this->
update($user);
933 $this->reason_decline_or_cancel = $reasondeclinenote;
947 public function cancel($user, $notrigger = 0)
950 if ($this->
status != self::STATUS_APPROVED) {
961 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
971 public function reopen($user, $notrigger = 0)
974 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_REFUSED) {
985 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
998 $langs->load(
'partnership');
1001 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
1002 if (isset($this->
status)) {
1003 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1005 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1020 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1022 global
$conf, $langs, $hookmanager;
1024 if (!empty(
$conf->dol_no_mouse_hover)) {
1031 'objecttype' => $this->element,
1032 'option' => $option,
1034 $classfortooltip =
'classfortooltip';
1037 $classfortooltip =
'classforajaxtooltip';
1038 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1044 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1046 if ($option !=
'nolink') {
1048 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1049 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1050 $add_save_lastsearch_values = 1;
1052 if ($add_save_lastsearch_values) {
1053 $url .=
'&save_lastsearch_values=1';
1058 if (empty($notooltip)) {
1060 $label = $langs->trans(
"ShowPartnership");
1061 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1063 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1064 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1066 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1069 if ($option ==
'nolink') {
1070 $linkstart =
'<span';
1072 $linkstart =
'<a href="'.$url.
'"';
1074 $linkstart .= $linkclose.
'>';
1075 if ($option ==
'nolink') {
1076 $linkend =
'</span>';
1081 $result .= $linkstart;
1083 if (empty($this->showphoto_on_popup)) {
1085 $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);
1089 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1091 list($class, $module) = explode(
'@', $this->picto);
1094 $filename = $filearray[0][
'name'];
1095 if (!empty($filename)) {
1096 $pospoint = strpos($filearray[0][
'name'],
'.');
1098 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1099 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1100 $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>';
1102 $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>';
1105 $result .=
'</div>';
1107 $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);
1112 if ($withpicto != 2) {
1113 $result .= $this->ref;
1116 $result .= $linkend;
1119 global $action, $hookmanager;
1120 $hookmanager->initHooks(array(
'partnershipdao'));
1121 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1122 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1124 $result = $hookmanager->resPrint;
1126 $result .= $hookmanager->resPrint;
1142 $tables = array(
'partnership');
1169 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1172 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1173 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1174 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1175 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1176 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1177 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1178 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1179 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1180 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1181 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1184 $statusType =
'status'.$status;
1185 if ($status == self::STATUS_APPROVED) {
1186 $statusType =
'status4';
1188 if ($status == self::STATUS_REFUSED) {
1189 $statusType =
'status9';
1191 if ($status == self::STATUS_CANCELED) {
1192 $statusType =
'status6';
1195 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1206 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1207 $sql .=
' fk_user_creat, fk_user_modif';
1208 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1209 $sql .=
' WHERE t.rowid = '.((int) $id);
1210 $result = $this->db->query($sql);
1212 if ($this->db->num_rows($result)) {
1213 $obj = $this->db->fetch_object($result);
1215 $this->
id = $obj->rowid;
1217 $this->user_creation_id = $obj->fk_user_creat;
1218 $this->user_modification_id = $obj->fk_user_modif;
1219 $this->date_creation = $this->db->jdate($obj->datec);
1220 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1223 $this->db->free($result);
1247 $this->lines = array();
1250 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_partnership:=:'.((
int) $this->
id).
')');
1252 if (is_numeric($result)) {
1253 $this->error = $objectline->error;
1254 $this->errors = $objectline->errors;
1257 $this->lines = $result;
1270 global $langs,
$conf;
1271 $langs->load(
"partnership");
1274 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1284 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
1285 foreach ($dirmodels as $reldir) {
1289 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1297 if (class_exists($classname)) {
1298 $obj =
new $classname();
1299 '@phan-var-force ModeleNumRefPartnership $obj';
1300 $numref = $obj->getNextValue($this);
1302 if ($numref !=
'' && $numref !=
'-1') {
1305 $this->error = $obj->error;
1310 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1314 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1330 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1332 global
$conf, $langs;
1335 $includedocgeneration = 0;
1337 $langs->load(
"partnership");
1340 $modele =
'standard_partnership';
1342 if (!empty($this->model_pdf)) {
1343 $modele = $this->model_pdf;
1349 $modelpath =
"core/modules/partnership/doc/";
1351 if ($includedocgeneration && !empty($modele)) {
1352 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1381 $this->db->commit();
1395 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1397 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1398 $return .=
'<div class="info-box info-box-sm">';
1399 $return .=
'<span class="info-box-icon bg-infobox-action">';
1401 $return .=
'</span>';
1402 $return .=
'<div class="info-box-content">';
1403 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1404 if ($selected >= 0) {
1405 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1407 if (property_exists($this,
'label')) {
1408 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1410 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1411 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1413 if (method_exists($this,
'getLibStatut')) {
1414 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1416 $return .=
'</div>';
1417 $return .=
'</div>';
1418 $return .=
'</div>';
1425require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1445 $this->isextrafieldmanaged = 0;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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.
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.
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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...