27 require_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'=>
'varchar(255)',
'label'=>
'UrlToCheck',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>-1,),
124 'count_last_url_check_error' => array(
'type'=>
'integer',
'label'=>
'CountLastUrlCheckError',
'enabled'=>
'1',
'position'=>71,
'notnull'=>0,
'visible'=>-2,
'default'=>
'0',),
125 'last_check_backlink' => array(
'type'=>
'datetime',
'label'=>
'LastCheckBacklink',
'enabled'=>
'1',
'position'=>72,
'notnull'=>0,
'visible'=>-2,),
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'=>
'Accepted',
'2'=>
'Refused',
'8'=>
'Suspended',
'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();
689 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
690 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
691 if (!$error && file_exists($dirsource)) {
692 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
694 if (@rename($dirsource, $dirdest)) {
697 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
698 foreach ($listoffiles as $fileentry) {
699 $dirsource = $fileentry[
'name'];
700 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
701 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
702 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
703 @rename($dirsource, $dirdest);
713 $this->status = self::STATUS_VALIDATED;
720 $this->db->rollback();
732 public function approve($user, $notrigger = 0)
734 global $conf, $langs;
736 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
741 if ($this->status == self::STATUS_APPROVED) {
742 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
759 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
764 $this->newref = $num;
768 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
769 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
770 $sql .=
" status = ".self::STATUS_APPROVED;
777 $sql .=
" WHERE rowid = ".((int) $this->
id);
779 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
780 $resql = $this->db->query(
$sql);
783 $this->error = $this->db->lasterror();
787 if (!$error && !$notrigger) {
789 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
798 $this->oldref = $this->ref;
801 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
803 $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).
"'";
804 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
805 $resql = $this->db->query(
$sql);
807 $error++; $this->error = $this->db->lasterror();
813 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
814 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
815 if (!$error && file_exists($dirsource)) {
816 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
818 if (@rename($dirsource, $dirdest)) {
821 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
822 foreach ($listoffiles as $fileentry) {
823 $dirsource = $fileentry[
'name'];
824 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
825 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
826 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
827 @rename($dirsource, $dirdest);
837 $this->status = self::STATUS_APPROVED;
844 $this->db->rollback();
860 if ($this->status <= self::STATUS_DRAFT) {
871 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
882 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
885 if ($this->status == self::STATUS_REFUSED) {
889 $this->status = self::STATUS_REFUSED;
890 $this->reason_decline_or_cancel = $reasondeclinenote;
892 $result = $this->
update($user);
895 $this->reason_decline_or_cancel = $reasondeclinenote;
909 public function cancel($user, $notrigger = 0)
912 if ($this->status != self::STATUS_APPROVED) {
923 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
933 public function reopen($user, $notrigger = 0)
936 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
947 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
961 $langs->load(
'partnership');
964 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
965 if (isset($this->status)) {
966 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
968 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
983 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
985 global $conf, $langs, $hookmanager;
987 if (!empty($conf->dol_no_mouse_hover)) {
994 'objecttype' => $this->element,
997 $classfortooltip =
'classfortooltip';
1000 $classfortooltip =
'classforajaxtooltip';
1001 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1007 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1009 if ($option !=
'nolink') {
1011 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1012 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1013 $add_save_lastsearch_values = 1;
1015 if ($add_save_lastsearch_values) {
1016 $url .=
'&save_lastsearch_values=1';
1021 if (empty($notooltip)) {
1022 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1023 $label = $langs->trans(
"ShowPartnership");
1024 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1026 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1027 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1029 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1032 if ($option ==
'nolink') {
1033 $linkstart =
'<span';
1035 $linkstart =
'<a href="'.$url.
'"';
1037 $linkstart .= $linkclose.
'>';
1038 if ($option ==
'nolink') {
1039 $linkend =
'</span>';
1044 $result .= $linkstart;
1046 if (empty($this->showphoto_on_popup)) {
1048 $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);
1052 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1054 list($class, $module) = explode(
'@', $this->picto);
1057 $filename = $filearray[0][
'name'];
1058 if (!empty($filename)) {
1059 $pospoint = strpos($filearray[0][
'name'],
'.');
1061 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1062 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1063 $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>';
1065 $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>';
1068 $result .=
'</div>';
1070 $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);
1075 if ($withpicto != 2) {
1076 $result .= $this->ref;
1079 $result .= $linkend;
1082 global $action, $hookmanager;
1083 $hookmanager->initHooks(array(
'partnershipdao'));
1084 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1085 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1087 $result = $hookmanager->resPrint;
1089 $result .= $hookmanager->resPrint;
1103 return $this->
LibStatut($this->status, $mode);
1117 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1120 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1121 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1122 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1123 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1124 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1125 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1126 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1127 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1128 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1129 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1132 $statusType =
'status'.$status;
1133 if ($status == self::STATUS_APPROVED) {
1134 $statusType =
'status4';
1136 if ($status == self::STATUS_REFUSED) {
1137 $statusType =
'status9';
1139 if ($status == self::STATUS_CANCELED) {
1140 $statusType =
'status6';
1143 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1154 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1155 $sql .=
' fk_user_creat, fk_user_modif';
1156 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1157 $sql .=
' WHERE t.rowid = '.((int) $id);
1158 $result = $this->db->query(
$sql);
1160 if ($this->db->num_rows($result)) {
1161 $obj = $this->db->fetch_object($result);
1162 $this->
id = $obj->rowid;
1164 $this->user_creation_id = $obj->fk_user_creat;
1165 $this->user_modification_id = $obj->fk_user_modif;
1166 $this->date_creation = $this->db->jdate($obj->datec);
1167 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1170 $this->db->free($result);
1194 $this->lines = array();
1197 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1199 if (is_numeric($result)) {
1200 $this->error = $objectline->error;
1201 $this->errors = $objectline->errors;
1204 $this->lines = $result;
1205 return $this->lines;
1216 global $langs, $conf;
1217 $langs->load(
"partnership");
1219 if (empty($conf->global->PARTNERSHIP_ADDON)) {
1220 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1223 if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1226 $file = $conf->global->PARTNERSHIP_ADDON.
".php";
1227 $classname = $conf->global->PARTNERSHIP_ADDON;
1230 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1231 foreach ($dirmodels as $reldir) {
1235 $mybool |= @include_once $dir.$file;
1238 if ($mybool ===
false) {
1243 if (class_exists($classname)) {
1244 $obj =
new $classname();
1245 $numref = $obj->getNextValue($this);
1247 if ($numref !=
'' && $numref !=
'-1') {
1250 $this->error = $obj->error;
1255 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1259 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1275 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1277 global $conf, $langs;
1280 $includedocgeneration = 0;
1282 $langs->load(
"partnership");
1285 $modele =
'standard_partnership';
1287 if (!empty($this->model_pdf)) {
1288 $modele = $this->model_pdf;
1289 } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1290 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1294 $modelpath =
"core/modules/partnership/doc/";
1296 if ($includedocgeneration && !empty($modele)) {
1297 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1312 global $conf, $langs;
1328 $this->db->commit();
1342 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1344 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1345 $return .=
'<div class="info-box info-box-sm">';
1346 $return .=
'<span class="info-box-icon bg-infobox-action">';
1348 $return .=
'</span>';
1349 $return .=
'<div class="info-box-content">';
1350 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1351 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1352 if (property_exists($this,
'label')) {
1353 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1355 if (method_exists($this,
'getLibStatut')) {
1356 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).
'</div>';
1358 $return .=
'</div>';
1359 $return .=
'</div>';
1360 $return .=
'</div>';
1367 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1380 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...
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.
getFieldList($alias='')
Function to concat keys of fields.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in 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.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
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)
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.
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.