27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
38 public $module =
'partnership';
43 public $element =
'partnership';
48 public $table_element =
'partnership';
54 public $ismultientitymanaged = 0;
59 public $isextrafieldmanaged = 1;
64 public $picto =
'partnership';
70 const STATUS_DRAFT = 0;
71 const STATUS_VALIDATED = 1;
72 const STATUS_APPROVED = 2;
73 const STATUS_REFUSED = 3;
74 const STATUS_CANCELED = 9;
107 public $fields=array(
108 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
109 'ref' => array(
'type'=>
'varchar(128)',
'label'=>
'Ref',
'enabled'=>
'1',
'position'=>10,
'notnull'=>1,
'visible'=>4,
'noteditable'=>
'1',
'default'=>
'(PROV)',
'index'=>1,
'searchall'=>1,
'showoncombobox'=>
'1',
'comment'=>
"Reference of object",
'csslist'=>
'tdoverflowmax150'),
110 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>
'isModEnabled("multicompany")',
'position'=>15,
'notnull'=>1,
'visible'=>-2,
'default'=>
'1',
'index'=>1,),
111 'fk_type' => array(
'type'=>
'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)',
'label'=>
'Type',
'enabled'=>
'1',
'position'=>20,
'notnull'=>1,
'visible'=>1,
'csslist'=>
'tdoverflowmax125'),
112 'fk_soc' => array(
'type'=>
'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))',
'label'=>
'ThirdParty',
'picto'=>
'company',
'enabled'=>
'1',
'position'=>50,
'notnull'=>-1,
'visible'=>1,
'index'=>1,
'css'=>
'maxwidth500',
'csslist'=>
'tdoverflowmax125',),
113 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>
'1',
'position'=>61,
'notnull'=>0,
'visible'=>0,),
114 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>
'1',
'position'=>62,
'notnull'=>0,
'visible'=>0,),
115 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>
'1',
'position'=>500,
'notnull'=>1,
'visible'=>-2,
'csslist'=>
'nowraponall'),
116 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,
'csslist'=>
'nowraponall'),
117 'fk_user_creat' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserAuthor',
'enabled'=>
'1',
'position'=>510,
'notnull'=>1,
'visible'=>-2,
'foreignkey'=>
'user.rowid',
'csslist'=>
'tdoverflowmax125'),
118 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,
'csslist'=>
'tdoverflowmax125'),
119 'last_main_doc' => array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>
'1',
'position'=>600,
'notnull'=>0,
'visible'=>0,),
120 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>
'1',
'position'=>1000,
'notnull'=>-1,
'visible'=>-2,),
121 'model_pdf' => array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>
'1',
'position'=>1010,
'notnull'=>-1,
'visible'=>0,),
122 'date_partnership_start' => array(
'type'=>
'date',
'label'=>
'DatePartnershipStart',
'enabled'=>
'1',
'position'=>52,
'notnull'=>1,
'visible'=>1,),
123 'date_partnership_end' => array(
'type'=>
'date',
'label'=>
'DatePartnershipEnd',
'enabled'=>
'1',
'position'=>53,
'notnull'=>0,
'visible'=>1,),
124 'url_to_check' => array(
'type'=>
'url',
'label'=>
'UrlToCheck',
'enabled'=>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position'=>70,
'notnull'=>0,
'visible'=>-1,
'csslist'=>
'tdoverflowmax150'),
125 'count_last_url_check_error' => array(
'type'=>
'integer',
'label'=>
'CountLastUrlCheckError',
'enabled'=>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position'=>71,
'notnull'=>0,
'visible'=>-4,
'default'=>
'0',),
126 'last_check_backlink' => array(
'type'=>
'datetime',
'label'=>
'LastCheckBacklink',
'enabled'=>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position'=>72,
'notnull'=>0,
'visible'=>-4,
'csslist'=>
'nowraponall'),
127 'reason_decline_or_cancel' => array(
'type'=>
'text',
'label'=>
'ReasonDeclineOrCancel',
'enabled'=>
'1',
'position'=>73,
'notnull'=>0,
'visible'=>-2,),
128 'ip' => array(
'type'=>
'ip',
'label'=>
'IPOfApplicant',
'enabled'=>
'1',
'position'=>74,
'notnull'=>0,
'visible'=>-2,),
129 'status' => array(
'type'=>
'smallint',
'label'=>
'Status',
'enabled'=>
'1',
'position'=>2000,
'notnull'=>1,
'visible'=>2,
'default'=>
'0',
'index'=>1,
'arrayofkeyval'=>array(
'0'=>
'Draft',
'1'=>
'Validated',
'2'=>
'Approved',
'3'=>
'Refused',
'9'=>
'Terminated'),),
136 public $note_private;
137 public $date_creation;
139 public $fk_user_creat;
140 public $fk_user_modif;
141 public $last_main_doc;
144 public $date_partnership_start;
145 public $date_partnership_end;
146 public $url_to_check;
147 public $count_last_url_check_error;
148 public $last_check_backlink;
149 public $reason_decline_or_cancel;
164 global $conf, $langs;
169 $this->fields[
'fk_member'] = array(
'type'=>
'integer:Adherent:adherents/class/adherent.class.php:1',
'label'=>
'Member',
'enabled'=>
'1',
'position'=>50,
'notnull'=>-1,
'visible'=>1,
'index'=>1,
'picto'=>
'member',
'csslist'=>
'tdoverflowmax150');
171 $this->fields[
'fk_soc'] = array(
'type'=>
'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))',
'label'=>
'ThirdParty',
'enabled'=>
'1',
'position'=>50,
'notnull'=>-1,
'visible'=>1,
'index'=>1,
'picto'=>
'company',
'css'=>
'maxwidth500',
'csslist'=>
'tdoverflowmax150');
174 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
175 $this->fields[
'rowid'][
'visible'] = 0;
179 foreach ($this->fields as $key => $val) {
180 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
181 unset($this->fields[$key]);
186 if (is_object($langs)) {
187 foreach ($this->fields as $key => $val) {
188 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
189 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
190 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
206 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
207 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
224 global $langs, $extrafields;
229 $object =
new self($this->db);
234 $result = $object->fetchCommon($fromid);
235 if ($result > 0 && !empty($object->table_element_line)) {
236 $object->fetchLines();
245 unset($object->fk_user_creat);
246 unset($object->import_key);
249 if (property_exists($object,
'ref')) {
250 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
252 if (property_exists($object,
'label')) {
253 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
255 if (property_exists($object,
'status')) {
256 $object->status = self::STATUS_DRAFT;
258 if (property_exists($object,
'date_creation')) {
259 $object->date_creation =
dol_now();
261 if (property_exists($object,
'date_modification')) {
262 $object->date_modification =
null;
266 if (is_array($object->array_options) && count($object->array_options) > 0) {
267 $extrafields->fetch_name_optionals_label($this->table_element);
268 foreach ($object->array_options as $key => $option) {
269 $shortkey = preg_replace(
'/options_/',
'', $key);
270 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
273 unset($object->array_options[$key]);
279 $object->context[
'createfromclone'] =
'createfromclone';
280 $result = $object->createCommon($user);
283 $this->error = $object->error;
284 $this->errors = $object->errors;
296 if (property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
303 unset($object->context[
'createfromclone']);
310 $this->db->rollback();
325 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
328 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
332 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
333 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
334 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
335 $sql .=
', p.note_private, p.note_public, p.url_to_check';
336 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
337 $sql .=
', p.import_key, p.model_pdf';
338 $sql .=
', pt.code as type_code, pt.label as type_label';
339 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
340 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
343 $sql .=
" WHERE p.rowid = ".((int) $id);
345 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
349 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
352 if ($fk_member > 0) {
353 $sql .=
' AND p.fk_member = '.((int) $fk_member);
356 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
358 $sql .=
' ORDER BY p.date_partnership_end DESC';
360 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
361 $result = $this->db->query($sql);
363 $obj = $this->db->fetch_object($result);
365 $this->
id = $obj->rowid;
366 $this->entity = $obj->entity;
367 $this->
ref = $obj->ref;
369 $this->fk_type = $obj->fk_type;
370 $this->type_code = $obj->type_code;
371 $this->type_label = $obj->type_label;
373 $this->fk_soc = $obj->fk_soc;
374 $this->fk_member = $obj->fk_member;
375 $this->
status = $obj->status;
376 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
377 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
378 $this->date_creation = $this->db->jdate($obj->date_creation);
379 $this->fk_user_creat = $obj->fk_user_creat;
380 $this->tms = $obj->tms;
381 $this->fk_user_modif = $obj->fk_user_modif;
382 $this->note_private = $obj->note_private;
383 $this->note_public = $obj->note_public;
384 $this->last_main_doc = $obj->last_main_doc;
385 $this->count_last_url_check_error = $obj->count_last_url_check_error;
386 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
387 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
388 $this->import_key = $obj->import_key;
389 $this->model_pdf = $obj->model_pdf;
390 $this->url_to_check = $obj->url_to_check;
396 $this->db->free($result);
404 $this->error = $this->db->error();
417 $this->lines = array();
435 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
443 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
444 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
445 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
447 $sql .=
' WHERE 1 = 1';
451 if (count($filter) > 0) {
452 foreach ($filter as $key => $value) {
453 if ($key ==
't.rowid') {
454 $sqlwhere[] = $key.
" = ".((int) $value);
455 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
456 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
457 } elseif ($key ==
'customsql') {
458 $sqlwhere[] = $value;
459 } elseif (strpos($value,
'%') ===
false) {
460 $sqlwhere[] = $key.
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
462 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
466 if (count($sqlwhere) > 0) {
467 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
470 if (!empty($sortfield)) {
471 $sql .= $this->db->order($sortfield, $sortorder);
473 if (!empty($limit)) {
474 $sql .= $this->db->plimit($limit, $offset);
477 $resql = $this->db->query($sql);
479 $num = $this->db->num_rows($resql);
481 while ($i < ($limit ? min($limit, $num) : $num)) {
482 $obj = $this->db->fetch_object($resql);
484 $record =
new self($this->db);
485 $record->setVarsFromFetchObj($obj);
487 $records[$record->id] = $record;
491 $this->db->free($resql);
495 $this->errors[] =
'Error '.$this->db->lasterror();
496 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
511 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
512 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
515 if (empty($this->fk_user_creat)) {
516 $this->fk_user_creat = $user->id;
529 public function delete(
User $user, $notrigger =
false)
546 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
565 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
570 if ($this->
status == self::STATUS_VALIDATED) {
571 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
588 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
593 $this->newref = $num;
597 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
598 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
599 $sql .=
" status = ".self::STATUS_VALIDATED;
600 if (!empty($this->fields[
'date_validation'])) {
601 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
603 if (!empty($this->fields[
'fk_user_valid'])) {
604 $sql .=
", fk_user_valid = ".$user->id;
606 $sql .=
" WHERE rowid = ".((int) $this->
id);
608 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
609 $resql = $this->db->query($sql);
612 $this->error = $this->db->lasterror();
616 if (!$error && !$notrigger) {
618 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
627 $this->oldref = $this->ref;
630 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
632 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'partnership/".$this->db->escape($this->newref).
"'";
633 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
634 $resql = $this->db->query($sql);
637 $this->error = $this->db->lasterror();
639 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
640 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
641 $resql = $this->db->query($sql);
644 $this->error = $this->db->lasterror();
650 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
651 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
652 if (!$error && file_exists($dirsource)) {
653 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
655 if (@rename($dirsource, $dirdest)) {
658 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
659 foreach ($listoffiles as $fileentry) {
660 $dirsource = $fileentry[
'name'];
661 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
662 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
663 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
664 @rename($dirsource, $dirdest);
674 $this->
status = self::STATUS_VALIDATED;
681 $this->db->rollback();
693 public function approve($user, $notrigger = 0)
697 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
702 if ($this->
status == self::STATUS_APPROVED) {
703 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
720 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
725 $this->newref = $num;
729 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
730 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
731 $sql .=
" status = ".self::STATUS_APPROVED;
738 $sql .=
" WHERE rowid = ".((int) $this->
id);
740 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
741 $resql = $this->db->query($sql);
744 $this->error = $this->db->lasterror();
748 if (!$error && !$notrigger) {
750 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
759 $this->oldref = $this->ref;
762 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
764 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'partnership/".$this->db->escape($this->newref).
"'";
765 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
766 $resql = $this->db->query($sql);
769 $this->error = $this->db->lasterror();
771 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
772 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
773 $resql = $this->db->query($sql);
776 $this->error = $this->db->lasterror();
782 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
783 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
784 if (!$error && file_exists($dirsource)) {
785 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
787 if (@rename($dirsource, $dirdest)) {
790 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
791 foreach ($listoffiles as $fileentry) {
792 $dirsource = $fileentry[
'name'];
793 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
794 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
795 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
796 @rename($dirsource, $dirdest);
806 $this->
status = self::STATUS_APPROVED;
813 $this->db->rollback();
829 if ($this->
status <= self::STATUS_DRAFT) {
840 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
851 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
854 if ($this->
status == self::STATUS_REFUSED) {
858 $this->
status = self::STATUS_REFUSED;
859 $this->reason_decline_or_cancel = $reasondeclinenote;
861 $result = $this->
update($user);
864 $this->reason_decline_or_cancel = $reasondeclinenote;
878 public function cancel($user, $notrigger = 0)
881 if ($this->
status != self::STATUS_APPROVED) {
892 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
902 public function reopen($user, $notrigger = 0)
905 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_REFUSED) {
916 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
930 $langs->load(
'partnership');
933 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
934 if (isset($this->
status)) {
935 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
937 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
952 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
954 global $conf, $langs, $hookmanager;
956 if (!empty($conf->dol_no_mouse_hover)) {
963 'objecttype' => $this->element,
966 $classfortooltip =
'classfortooltip';
969 $classfortooltip =
'classforajaxtooltip';
970 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
976 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
978 if ($option !=
'nolink') {
980 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
981 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
982 $add_save_lastsearch_values = 1;
984 if ($add_save_lastsearch_values) {
985 $url .=
'&save_lastsearch_values=1';
990 if (empty($notooltip)) {
992 $label = $langs->trans(
"ShowPartnership");
993 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
995 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
996 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
998 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1001 if ($option ==
'nolink') {
1002 $linkstart =
'<span';
1004 $linkstart =
'<a href="'.$url.
'"';
1006 $linkstart .= $linkclose.
'>';
1007 if ($option ==
'nolink') {
1008 $linkend =
'</span>';
1013 $result .= $linkstart;
1015 if (empty($this->showphoto_on_popup)) {
1017 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') : $dataparams.
' class="'.(($withpicto != 2) ?
'paddingright ' :
'').$classfortooltip.
'"'), 0, 0, $notooltip ? 0 : 1);
1021 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1023 list($class, $module) = explode(
'@', $this->picto);
1026 $filename = $filearray[0][
'name'];
1027 if (!empty($filename)) {
1028 $pospoint = strpos($filearray[0][
'name'],
'.');
1030 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1031 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1032 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$module.
'" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div></div>';
1034 $result .=
'<div class="floatleft inline-block valignmiddle divphotoref"><img class="photouserphoto userphoto" alt="No photo" border="0" src="'.DOL_URL_ROOT.
'/viewimage.php?modulepart='.$module.
'&entity='.$conf->entity.
'&file='.urlencode($pathtophoto).
'"></div>';
1037 $result .=
'</div>';
1039 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
1044 if ($withpicto != 2) {
1045 $result .= $this->ref;
1048 $result .= $linkend;
1051 global $action, $hookmanager;
1052 $hookmanager->initHooks(array(
'partnershipdao'));
1053 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1054 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1056 $result = $hookmanager->resPrint;
1058 $result .= $hookmanager->resPrint;
1086 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1089 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1090 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1091 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1092 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1093 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1094 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1095 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1096 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1097 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1098 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1101 $statusType =
'status'.$status;
1102 if ($status == self::STATUS_APPROVED) {
1103 $statusType =
'status4';
1105 if ($status == self::STATUS_REFUSED) {
1106 $statusType =
'status9';
1108 if ($status == self::STATUS_CANCELED) {
1109 $statusType =
'status6';
1112 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1123 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1124 $sql .=
' fk_user_creat, fk_user_modif';
1125 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1126 $sql .=
' WHERE t.rowid = '.((int) $id);
1127 $result = $this->db->query($sql);
1129 if ($this->db->num_rows($result)) {
1130 $obj = $this->db->fetch_object($result);
1132 $this->
id = $obj->rowid;
1134 $this->user_creation_id = $obj->fk_user_creat;
1135 $this->user_modification_id = $obj->fk_user_modif;
1136 $this->date_creation = $this->db->jdate($obj->datec);
1137 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1140 $this->db->free($result);
1164 $this->lines = array();
1167 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1169 if (is_numeric($result)) {
1170 $this->error = $objectline->error;
1171 $this->errors = $objectline->errors;
1174 $this->lines = $result;
1175 return $this->lines;
1186 global $langs, $conf;
1187 $langs->load(
"partnership");
1190 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1197 $classname = $conf->global->PARTNERSHIP_ADDON;
1200 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1201 foreach ($dirmodels as $reldir) {
1205 $mybool |= @include_once $dir.$file;
1208 if ($mybool ===
false) {
1213 if (class_exists($classname)) {
1214 $obj =
new $classname();
1215 $numref = $obj->getNextValue($this);
1217 if ($numref !=
'' && $numref !=
'-1') {
1220 $this->error = $obj->error;
1225 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1229 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1245 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1247 global $conf, $langs;
1250 $includedocgeneration = 0;
1252 $langs->load(
"partnership");
1255 $modele =
'standard_partnership';
1257 if (!empty($this->model_pdf)) {
1258 $modele = $this->model_pdf;
1260 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1264 $modelpath =
"core/modules/partnership/doc/";
1266 if ($includedocgeneration && !empty($modele)) {
1267 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1296 $this->db->commit();
1310 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1312 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1313 $return .=
'<div class="info-box info-box-sm">';
1314 $return .=
'<span class="info-box-icon bg-infobox-action">';
1316 $return .=
'</span>';
1317 $return .=
'<div class="info-box-content">';
1318 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1319 if ($selected >= 0) {
1320 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1322 if (property_exists($this,
'label')) {
1323 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1325 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1326 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1328 if (method_exists($this,
'getLibStatut')) {
1329 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1331 $return .=
'</div>';
1332 $return .=
'</div>';
1333 $return .=
'</div>';
1340require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1353 public $isextrafieldmanaged = 0;
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
update(User $user, $notrigger=false)
Update object into database.
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetchLines()
Load object lines in memory from the database.
create(User $user, $notrigger=false)
Create object into database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.