27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
37 public $module =
'partnership';
42 public $element =
'partnership';
47 public $table_element =
'partnership';
53 public $ismultientitymanaged = 0;
58 public $isextrafieldmanaged = 1;
63 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"),
109 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>
'1',
'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'),
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,),
115 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,),
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',),
117 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
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'=>
'varchar(250)',
'label'=>
'Ip',
'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'),),
135 public $note_private;
136 public $date_creation;
138 public $fk_user_creat;
139 public $fk_user_modif;
140 public $last_main_doc;
143 public $date_partnership_start;
144 public $date_partnership_end;
145 public $url_to_check;
146 public $count_last_url_check_error;
147 public $last_check_backlink;
148 public $reason_decline_or_cancel;
198 global $conf, $langs;
203 $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');
205 $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');
208 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
209 $this->fields[
'rowid'][
'visible'] = 0;
222 foreach ($this->fields as $key => $val) {
223 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
224 unset($this->fields[$key]);
229 if (is_object($langs)) {
230 foreach ($this->fields as $key => $val) {
231 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
232 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
233 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
249 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
250 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
267 global $langs, $extrafields;
272 $object =
new self($this->db);
277 $result = $object->fetchCommon($fromid);
278 if ($result > 0 && !empty($object->table_element_line)) {
279 $object->fetchLines();
288 unset($object->fk_user_creat);
289 unset($object->import_key);
292 if (property_exists($object,
'ref')) {
293 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
295 if (property_exists($object,
'label')) {
296 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
298 if (property_exists($object,
'status')) {
299 $object->status = self::STATUS_DRAFT;
301 if (property_exists($object,
'date_creation')) {
302 $object->date_creation =
dol_now();
304 if (property_exists($object,
'date_modification')) {
305 $object->date_modification =
null;
309 if (is_array($object->array_options) && count($object->array_options) > 0) {
310 $extrafields->fetch_name_optionals_label($this->table_element);
311 foreach ($object->array_options as $key => $option) {
312 $shortkey = preg_replace(
'/options_/',
'', $key);
313 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
316 unset($object->array_options[$key]);
322 $object->context[
'createfromclone'] =
'createfromclone';
323 $result = $object->createCommon($user);
326 $this->error = $object->error;
327 $this->errors = $object->errors;
339 if (property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
346 unset($object->context[
'createfromclone']);
353 $this->db->rollback();
368 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
373 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
377 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
378 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
379 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
380 $sql .=
', p.note_private, p.note_public, p.url_to_check';
381 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
382 $sql .=
', p.import_key, p.model_pdf';
383 $sql .=
', pt.code as type_code, pt.label as type_label';
384 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
385 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
388 $sql .=
" WHERE p.rowid = ".((int) $id);
390 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
394 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
397 if ($fk_member > 0) {
398 $sql .=
' AND p.fk_member = '.((int) $fk_member);
401 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
403 $sql .=
' ORDER BY p.date_partnership_end DESC';
405 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
406 $result = $this->db->query($sql);
408 $obj = $this->db->fetch_object($result);
410 $this->
id = $obj->rowid;
411 $this->entity = $obj->entity;
412 $this->
ref = $obj->ref;
414 $this->fk_type = $obj->fk_type;
415 $this->type_code = $obj->type_code;
416 $this->type_label = $obj->type_label;
418 $this->fk_soc = $obj->fk_soc;
419 $this->fk_member = $obj->fk_member;
420 $this->status = $obj->status;
421 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
422 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
423 $this->date_creation = $this->db->jdate($obj->date_creation);
424 $this->fk_user_creat = $obj->fk_user_creat;
425 $this->tms = $obj->tms;
426 $this->fk_user_modif = $obj->fk_user_modif;
427 $this->note_private = $obj->note_private;
428 $this->note_public = $obj->note_public;
429 $this->last_main_doc = $obj->last_main_doc;
430 $this->count_last_url_check_error = $obj->count_last_url_check_error;
431 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
432 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
433 $this->import_key = $obj->import_key;
434 $this->model_pdf = $obj->model_pdf;
435 $this->url_to_check = $obj->url_to_check;
441 $this->db->free($result);
449 $this->error = $this->db->error();
462 $this->lines = array();
480 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
490 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
491 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
492 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
494 $sql .=
' WHERE 1 = 1';
498 if (count($filter) > 0) {
499 foreach ($filter as $key => $value) {
500 if ($key ==
't.rowid') {
501 $sqlwhere[] = $key.
" = ".((int) $value);
502 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
503 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
504 } elseif ($key ==
'customsql') {
505 $sqlwhere[] = $value;
506 } elseif (strpos($value,
'%') ===
false) {
507 $sqlwhere[] = $key.
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
509 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
513 if (count($sqlwhere) > 0) {
514 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
517 if (!empty($sortfield)) {
518 $sql .= $this->db->order($sortfield, $sortorder);
520 if (!empty($limit)) {
521 $sql .= $this->db->plimit($limit, $offset);
524 $resql = $this->db->query($sql);
526 $num = $this->db->num_rows($resql);
528 while ($i < ($limit ? min($limit, $num) : $num)) {
529 $obj = $this->db->fetch_object($resql);
531 $record =
new self($this->db);
532 $record->setVarsFromFetchObj($obj);
534 $records[$record->id] = $record;
538 $this->db->free($resql);
542 $this->errors[] =
'Error '.$this->db->lasterror();
543 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
558 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
559 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
562 if (empty($this->fk_user_creat)) {
563 $this->fk_user_creat = $user->id;
576 public function delete(
User $user, $notrigger =
false)
592 if ($this->status < 0) {
593 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
610 global $conf, $langs;
612 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
617 if ($this->status == self::STATUS_VALIDATED) {
618 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
635 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
640 $this->newref = $num;
644 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
645 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
646 $sql .=
" status = ".self::STATUS_VALIDATED;
647 if (!empty($this->fields[
'date_validation'])) {
648 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
650 if (!empty($this->fields[
'fk_user_valid'])) {
651 $sql .=
", fk_user_valid = ".$user->id;
653 $sql .=
" WHERE rowid = ".((int) $this->
id);
655 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
656 $resql = $this->db->query($sql);
659 $this->error = $this->db->lasterror();
663 if (!$error && !$notrigger) {
665 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
674 $this->oldref = $this->ref;
677 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
679 $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).
"'";
680 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
681 $resql = $this->db->query($sql);
683 $error++; $this->error = $this->db->lasterror();
685 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
686 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
687 $resql = $this->db->query($sql);
689 $error++; $this->error = $this->db->lasterror();
695 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
696 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
697 if (!$error && file_exists($dirsource)) {
698 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
700 if (@rename($dirsource, $dirdest)) {
703 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
704 foreach ($listoffiles as $fileentry) {
705 $dirsource = $fileentry[
'name'];
706 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
707 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
708 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
709 @rename($dirsource, $dirdest);
719 $this->status = self::STATUS_VALIDATED;
726 $this->db->rollback();
738 public function approve($user, $notrigger = 0)
740 global $conf, $langs;
742 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
747 if ($this->status == self::STATUS_APPROVED) {
748 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
765 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
770 $this->newref = $num;
774 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
775 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
776 $sql .=
" status = ".self::STATUS_APPROVED;
783 $sql .=
" WHERE rowid = ".((int) $this->
id);
785 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
786 $resql = $this->db->query($sql);
789 $this->error = $this->db->lasterror();
793 if (!$error && !$notrigger) {
795 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
804 $this->oldref = $this->ref;
807 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
809 $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).
"'";
810 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
811 $resql = $this->db->query($sql);
813 $error++; $this->error = $this->db->lasterror();
815 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
816 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
817 $resql = $this->db->query($sql);
819 $error++; $this->error = $this->db->lasterror();
825 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
826 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
827 if (!$error && file_exists($dirsource)) {
828 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
830 if (@rename($dirsource, $dirdest)) {
833 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
834 foreach ($listoffiles as $fileentry) {
835 $dirsource = $fileentry[
'name'];
836 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
837 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
838 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
839 @rename($dirsource, $dirdest);
849 $this->status = self::STATUS_APPROVED;
856 $this->db->rollback();
872 if ($this->status <= self::STATUS_DRAFT) {
883 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
894 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
897 if ($this->status == self::STATUS_REFUSED) {
901 $this->status = self::STATUS_REFUSED;
902 $this->reason_decline_or_cancel = $reasondeclinenote;
904 $result = $this->
update($user);
907 $this->reason_decline_or_cancel = $reasondeclinenote;
921 public function cancel($user, $notrigger = 0)
924 if ($this->status != self::STATUS_APPROVED) {
935 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
945 public function reopen($user, $notrigger = 0)
948 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
959 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
973 $langs->load(
'partnership');
976 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
977 if (isset($this->status)) {
978 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
980 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
995 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
997 global $conf, $langs, $hookmanager;
999 if (!empty($conf->dol_no_mouse_hover)) {
1006 'objecttype' => $this->element,
1007 'option' => $option,
1009 $classfortooltip =
'classfortooltip';
1012 $classfortooltip =
'classforajaxtooltip';
1013 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1019 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1021 if ($option !=
'nolink') {
1023 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1024 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1025 $add_save_lastsearch_values = 1;
1027 if ($add_save_lastsearch_values) {
1028 $url .=
'&save_lastsearch_values=1';
1033 if (empty($notooltip)) {
1034 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1035 $label = $langs->trans(
"ShowPartnership");
1036 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1038 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1039 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1041 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1044 if ($option ==
'nolink') {
1045 $linkstart =
'<span';
1047 $linkstart =
'<a href="'.$url.
'"';
1049 $linkstart .= $linkclose.
'>';
1050 if ($option ==
'nolink') {
1051 $linkend =
'</span>';
1056 $result .= $linkstart;
1058 if (empty($this->showphoto_on_popup)) {
1060 $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);
1064 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1066 list($class, $module) = explode(
'@', $this->picto);
1069 $filename = $filearray[0][
'name'];
1070 if (!empty($filename)) {
1071 $pospoint = strpos($filearray[0][
'name'],
'.');
1073 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1074 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
1075 $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>';
1077 $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>';
1080 $result .=
'</div>';
1082 $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);
1087 if ($withpicto != 2) {
1088 $result .= $this->ref;
1091 $result .= $linkend;
1094 global $action, $hookmanager;
1095 $hookmanager->initHooks(array(
'partnershipdao'));
1096 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1097 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1099 $result = $hookmanager->resPrint;
1101 $result .= $hookmanager->resPrint;
1115 return $this->LibStatut($this->status, $mode);
1129 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1132 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1133 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1134 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1135 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1136 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1137 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1138 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1139 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1140 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1141 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1144 $statusType =
'status'.$status;
1145 if ($status == self::STATUS_APPROVED) {
1146 $statusType =
'status4';
1148 if ($status == self::STATUS_REFUSED) {
1149 $statusType =
'status9';
1151 if ($status == self::STATUS_CANCELED) {
1152 $statusType =
'status6';
1155 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1166 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1167 $sql .=
' fk_user_creat, fk_user_modif';
1168 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1169 $sql .=
' WHERE t.rowid = '.((int) $id);
1170 $result = $this->db->query($sql);
1172 if ($this->db->num_rows($result)) {
1173 $obj = $this->db->fetch_object($result);
1174 $this->
id = $obj->rowid;
1176 $this->user_creation_id = $obj->fk_user_creat;
1177 $this->user_modification_id = $obj->fk_user_modif;
1178 $this->date_creation = $this->db->jdate($obj->datec);
1179 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1182 $this->db->free($result);
1196 $this->initAsSpecimenCommon();
1206 $this->lines = array();
1209 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1211 if (is_numeric($result)) {
1212 $this->error = $objectline->error;
1213 $this->errors = $objectline->errors;
1216 $this->lines = $result;
1217 return $this->lines;
1228 global $langs, $conf;
1229 $langs->load(
"partnership");
1231 if (empty($conf->global->PARTNERSHIP_ADDON)) {
1232 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1235 if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1238 $file = $conf->global->PARTNERSHIP_ADDON.
".php";
1239 $classname = $conf->global->PARTNERSHIP_ADDON;
1242 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1243 foreach ($dirmodels as $reldir) {
1247 $mybool |= @include_once $dir.$file;
1250 if ($mybool ===
false) {
1255 if (class_exists($classname)) {
1256 $obj =
new $classname();
1257 $numref = $obj->getNextValue($this);
1259 if ($numref !=
'' && $numref !=
'-1') {
1262 $this->error = $obj->error;
1267 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1271 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1287 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1289 global $conf, $langs;
1292 $includedocgeneration = 0;
1294 $langs->load(
"partnership");
1297 $modele =
'standard_partnership';
1299 if (!empty($this->model_pdf)) {
1300 $modele = $this->model_pdf;
1301 } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1302 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1306 $modelpath =
"core/modules/partnership/doc/";
1308 if ($includedocgeneration && !empty($modele)) {
1309 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1338 $this->db->commit();
1352 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1354 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1355 $return .=
'<div class="info-box info-box-sm">';
1356 $return .=
'<span class="info-box-icon bg-infobox-action">';
1358 $return .=
'</span>';
1359 $return .=
'<div class="info-box-content">';
1360 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl() : $this->ref).
'</span>';
1361 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1362 if (property_exists($this,
'label')) {
1363 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1365 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1366 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1368 if (method_exists($this,
'getLibStatut')) {
1369 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).
'</div>';
1371 $return .=
'</div>';
1372 $return .=
'</div>';
1373 $return .=
'</div>';
1380require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1393 public $isextrafieldmanaged = 0;
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=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.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='')
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 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.