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';
66 const STATUS_DRAFT = 0;
67 const STATUS_VALIDATED = 1;
68 const STATUS_APPROVED = 2;
69 const STATUS_REFUSED = 3;
70 const STATUS_CANCELED = 9;
103 public $fields=array(
104 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
105 '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"),
106 'entity' => array(
'type'=>
'integer',
'label'=>
'Entity',
'enabled'=>
'1',
'position'=>15,
'notnull'=>1,
'visible'=>-2,
'default'=>
'1',
'index'=>1,),
107 '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'),
108 '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',),
109 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>
'1',
'position'=>61,
'notnull'=>0,
'visible'=>0,),
110 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>
'1',
'position'=>62,
'notnull'=>0,
'visible'=>0,),
111 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>
'1',
'position'=>500,
'notnull'=>1,
'visible'=>-2,),
112 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,),
113 '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',),
114 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
115 'last_main_doc' => array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>
'1',
'position'=>600,
'notnull'=>0,
'visible'=>0,),
116 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>
'1',
'position'=>1000,
'notnull'=>-1,
'visible'=>-2,),
117 'model_pdf' => array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>
'1',
'position'=>1010,
'notnull'=>-1,
'visible'=>0,),
118 'date_partnership_start' => array(
'type'=>
'date',
'label'=>
'DatePartnershipStart',
'enabled'=>
'1',
'position'=>52,
'notnull'=>1,
'visible'=>1,),
119 'date_partnership_end' => array(
'type'=>
'date',
'label'=>
'DatePartnershipEnd',
'enabled'=>
'1',
'position'=>53,
'notnull'=>0,
'visible'=>1,),
120 'url_to_check' => array(
'type'=>
'varchar(255)',
'label'=>
'UrlToCheck',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>-1,),
121 'count_last_url_check_error' => array(
'type'=>
'integer',
'label'=>
'CountLastUrlCheckError',
'enabled'=>
'1',
'position'=>71,
'notnull'=>0,
'visible'=>-2,
'default'=>
'0',),
122 'last_check_backlink' => array(
'type'=>
'datetime',
'label'=>
'LastCheckBacklink',
'enabled'=>
'1',
'position'=>72,
'notnull'=>0,
'visible'=>-2,),
123 'reason_decline_or_cancel' => array(
'type'=>
'text',
'label'=>
'ReasonDeclineOrCancel',
'enabled'=>
'1',
'position'=>73,
'notnull'=>0,
'visible'=>-2,),
124 'ip' => array(
'type'=>
'varchar(250)',
'label'=>
'Ip',
'enabled'=>
'1',
'position'=>74,
'notnull'=>0,
'visible'=>-2,),
125 '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'),),
132 public $note_private;
133 public $date_creation;
135 public $fk_user_creat;
136 public $fk_user_modif;
137 public $last_main_doc;
140 public $date_partnership_start;
141 public $date_partnership_end;
143 public $url_to_check;
144 public $count_last_url_check_error;
145 public $last_check_backlink;
146 public $reason_decline_or_cancel;
194 global $conf, $langs;
199 $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');
201 $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');
204 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
205 $this->fields[
'rowid'][
'visible'] = 0;
218 foreach ($this->fields as $key => $val) {
219 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
220 unset($this->fields[$key]);
225 if (is_object($langs)) {
226 foreach ($this->fields as $key => $val) {
227 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
228 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
229 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
245 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
246 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
263 global $langs, $extrafields;
268 $object =
new self($this->db);
273 $result = $object->fetchCommon($fromid);
274 if ($result > 0 && !empty($object->table_element_line)) {
275 $object->fetchLines();
284 unset($object->fk_user_creat);
285 unset($object->import_key);
288 if (property_exists($object,
'ref')) {
289 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
291 if (property_exists($object,
'label')) {
292 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
294 if (property_exists($object,
'status')) {
295 $object->status = self::STATUS_DRAFT;
297 if (property_exists($object,
'date_creation')) {
298 $object->date_creation =
dol_now();
300 if (property_exists($object,
'date_modification')) {
301 $object->date_modification =
null;
305 if (is_array($object->array_options) && count($object->array_options) > 0) {
306 $extrafields->fetch_name_optionals_label($this->table_element);
307 foreach ($object->array_options as $key => $option) {
308 $shortkey = preg_replace(
'/options_/',
'', $key);
309 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
312 unset($object->array_options[$key]);
318 $object->context[
'createfromclone'] =
'createfromclone';
319 $result = $object->createCommon($user);
322 $this->error = $object->error;
323 $this->errors = $object->errors;
335 if (property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
342 unset($object->context[
'createfromclone']);
349 $this->db->rollback();
364 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
369 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
373 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
374 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
375 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
376 $sql .=
', p.note_private, p.note_public, p.url_to_check';
377 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
378 $sql .=
', p.import_key, p.model_pdf';
379 $sql .=
', pt.code as type_code, pt.label as type_label';
380 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
381 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
384 $sql .=
" WHERE p.rowid = ".((int) $id);
386 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
390 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
393 if ($fk_member > 0) {
394 $sql .=
' AND p.fk_member = '.((int) $fk_member);
397 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
399 $sql .=
' ORDER BY p.date_partnership_end DESC';
401 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
402 $result = $this->db->query(
$sql);
404 $obj = $this->db->fetch_object($result);
406 $this->
id = $obj->rowid;
407 $this->entity = $obj->entity;
408 $this->
ref = $obj->ref;
410 $this->fk_type = $obj->fk_type;
411 $this->type_code = $obj->type_code;
412 $this->type_label = $obj->type_label;
414 $this->fk_soc = $obj->fk_soc;
415 $this->fk_member = $obj->fk_member;
416 $this->status = $obj->status;
417 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
418 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
419 $this->date_creation = $this->db->jdate($obj->date_creation);
420 $this->fk_user_creat = $obj->fk_user_creat;
421 $this->tms = $obj->tms;
422 $this->fk_user_modif = $obj->fk_user_modif;
423 $this->note_private = $obj->note_private;
424 $this->note_public = $obj->note_public;
425 $this->last_main_doc = $obj->last_main_doc;
426 $this->count_last_url_check_error = $obj->count_last_url_check_error;
427 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
428 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
429 $this->import_key = $obj->import_key;
430 $this->model_pdf = $obj->model_pdf;
431 $this->url_to_check = $obj->url_to_check;
437 $this->db->free($result);
445 $this->error = $this->db->error();
458 $this->lines = array();
476 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
486 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
487 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
488 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
490 $sql .=
' WHERE 1 = 1';
494 if (count($filter) > 0) {
495 foreach ($filter as $key => $value) {
496 if ($key ==
't.rowid') {
497 $sqlwhere[] = $key.
" = ".((int) $value);
498 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
499 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
500 } elseif ($key ==
'customsql') {
501 $sqlwhere[] = $value;
502 } elseif (strpos($value,
'%') ===
false) {
503 $sqlwhere[] = $key.
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
505 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
509 if (count($sqlwhere) > 0) {
510 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
513 if (!empty($sortfield)) {
514 $sql .= $this->db->order($sortfield, $sortorder);
516 if (!empty($limit)) {
517 $sql .= $this->db->plimit($limit, $offset);
520 $resql = $this->db->query(
$sql);
522 $num = $this->db->num_rows($resql);
524 while ($i < ($limit ? min($limit, $num) : $num)) {
525 $obj = $this->db->fetch_object($resql);
527 $record =
new self($this->db);
528 $record->setVarsFromFetchObj($obj);
530 $records[$record->id] = $record;
534 $this->db->free($resql);
538 $this->errors[] =
'Error '.$this->db->lasterror();
539 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
554 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
555 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
558 if (empty($this->fk_user_creat)) {
559 $this->fk_user_creat = $user->id;
572 public function delete(
User $user, $notrigger =
false)
588 if ($this->status < 0) {
589 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
606 global $conf, $langs;
608 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
613 if ($this->status == self::STATUS_VALIDATED) {
614 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
631 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
636 $this->newref = $num;
640 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
641 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
642 $sql .=
" status = ".self::STATUS_VALIDATED;
643 if (!empty($this->fields[
'date_validation'])) {
644 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
646 if (!empty($this->fields[
'fk_user_valid'])) {
647 $sql .=
", fk_user_valid = ".$user->id;
649 $sql .=
" WHERE rowid = ".((int) $this->
id);
651 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
652 $resql = $this->db->query(
$sql);
655 $this->error = $this->db->lasterror();
659 if (!$error && !$notrigger) {
661 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
670 $this->oldref = $this->ref;
673 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
675 $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).
"'";
676 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
677 $resql = $this->db->query(
$sql);
679 $error++; $this->error = $this->db->lasterror();
685 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
686 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
687 if (!$error && file_exists($dirsource)) {
688 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
690 if (@rename($dirsource, $dirdest)) {
693 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
694 foreach ($listoffiles as $fileentry) {
695 $dirsource = $fileentry[
'name'];
696 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
697 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
698 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
699 @rename($dirsource, $dirdest);
709 $this->status = self::STATUS_VALIDATED;
716 $this->db->rollback();
728 public function approve($user, $notrigger = 0)
730 global $conf, $langs;
732 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
737 if ($this->status == self::STATUS_APPROVED) {
738 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
755 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
760 $this->newref = $num;
764 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
765 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
766 $sql .=
" status = ".self::STATUS_APPROVED;
773 $sql .=
" WHERE rowid = ".((int) $this->
id);
775 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
776 $resql = $this->db->query(
$sql);
779 $this->error = $this->db->lasterror();
783 if (!$error && !$notrigger) {
785 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
794 $this->oldref = $this->ref;
797 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
799 $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).
"'";
800 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
801 $resql = $this->db->query(
$sql);
803 $error++; $this->error = $this->db->lasterror();
809 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
810 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
811 if (!$error && file_exists($dirsource)) {
812 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
814 if (@rename($dirsource, $dirdest)) {
817 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
818 foreach ($listoffiles as $fileentry) {
819 $dirsource = $fileentry[
'name'];
820 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
821 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
822 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
823 @rename($dirsource, $dirdest);
833 $this->status = self::STATUS_APPROVED;
840 $this->db->rollback();
856 if ($this->status <= self::STATUS_DRAFT) {
867 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
878 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
881 if ($this->status == self::STATUS_REFUSED) {
885 $this->status = self::STATUS_REFUSED;
886 $this->reason_decline_or_cancel = $reasondeclinenote;
888 $result = $this->
update($user);
891 $this->reason_decline_or_cancel = $reasondeclinenote;
905 public function cancel($user, $notrigger = 0)
908 if ($this->status != self::STATUS_APPROVED) {
919 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
929 public function reopen($user, $notrigger = 0)
932 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
943 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
957 $langs->load(
'partnership');
960 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
961 if (isset($this->status)) {
962 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
964 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
979 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
981 global $conf, $langs, $hookmanager;
983 if (!empty($conf->dol_no_mouse_hover)) {
990 'objecttype' => $this->element,
993 $classfortooltip =
'classfortooltip';
996 $classfortooltip =
'classforajaxtooltip';
997 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1003 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1005 if ($option !=
'nolink') {
1007 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1008 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1009 $add_save_lastsearch_values = 1;
1011 if ($add_save_lastsearch_values) {
1012 $url .=
'&save_lastsearch_values=1';
1017 if (empty($notooltip)) {
1018 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1019 $label = $langs->trans(
"ShowPartnership");
1020 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1022 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1023 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1025 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1028 if ($option ==
'nolink') {
1029 $linkstart =
'<span';
1031 $linkstart =
'<a href="'.$url.
'"';
1033 $linkstart .= $linkclose.
'>';
1034 if ($option ==
'nolink') {
1035 $linkend =
'</span>';
1040 $result .= $linkstart;
1042 if (empty($this->showphoto_on_popup)) {
1044 $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);
1048 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1050 list($class, $module) = explode(
'@', $this->picto);
1053 $filename = $filearray[0][
'name'];
1054 if (!empty($filename)) {
1055 $pospoint = strpos($filearray[0][
'name'],
'.');
1057 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1058 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
1059 $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>';
1061 $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>';
1064 $result .=
'</div>';
1066 $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);
1071 if ($withpicto != 2) {
1072 $result .= $this->ref;
1075 $result .= $linkend;
1078 global $action, $hookmanager;
1079 $hookmanager->initHooks(array(
'partnershipdao'));
1080 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1081 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1083 $result = $hookmanager->resPrint;
1085 $result .= $hookmanager->resPrint;
1099 return $this->LibStatut($this->status, $mode);
1113 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1116 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1117 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1118 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1119 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1120 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1121 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1122 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1123 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1124 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1125 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1128 $statusType =
'status'.$status;
1129 if ($status == self::STATUS_APPROVED) {
1130 $statusType =
'status4';
1132 if ($status == self::STATUS_REFUSED) {
1133 $statusType =
'status9';
1135 if ($status == self::STATUS_CANCELED) {
1136 $statusType =
'status6';
1139 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1150 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1151 $sql .=
' fk_user_creat, fk_user_modif';
1152 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1153 $sql .=
' WHERE t.rowid = '.((int) $id);
1154 $result = $this->db->query(
$sql);
1156 if ($this->db->num_rows($result)) {
1157 $obj = $this->db->fetch_object($result);
1158 $this->
id = $obj->rowid;
1160 $this->user_creation_id = $obj->fk_user_creat;
1161 $this->user_modification_id = $obj->fk_user_modif;
1162 $this->date_creation = $this->db->jdate($obj->datec);
1163 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1166 $this->db->free($result);
1180 $this->initAsSpecimenCommon();
1190 $this->lines = array();
1193 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1195 if (is_numeric($result)) {
1196 $this->error = $objectline->error;
1197 $this->errors = $objectline->errors;
1200 $this->lines = $result;
1201 return $this->lines;
1212 global $langs, $conf;
1213 $langs->load(
"partnership");
1215 if (empty($conf->global->PARTNERSHIP_ADDON)) {
1216 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1219 if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1222 $file = $conf->global->PARTNERSHIP_ADDON.
".php";
1223 $classname = $conf->global->PARTNERSHIP_ADDON;
1226 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1227 foreach ($dirmodels as $reldir) {
1231 $mybool |= @include_once $dir.$file;
1234 if ($mybool ===
false) {
1239 if (class_exists($classname)) {
1240 $obj =
new $classname();
1241 $numref = $obj->getNextValue($this);
1243 if ($numref !=
'' && $numref !=
'-1') {
1246 $this->error = $obj->error;
1251 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1255 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1271 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1273 global $conf, $langs;
1276 $includedocgeneration = 0;
1278 $langs->load(
"partnership");
1281 $modele =
'standard_partnership';
1283 if (!empty($this->model_pdf)) {
1284 $modele = $this->model_pdf;
1285 } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1286 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1290 $modelpath =
"core/modules/partnership/doc/";
1292 if ($includedocgeneration && !empty($modele)) {
1293 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1308 global $conf, $langs;
1324 $this->db->commit();
1338 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1340 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1341 $return .=
'<div class="info-box info-box-sm">';
1342 $return .=
'<span class="info-box-icon bg-infobox-action">';
1344 $return .=
'</span>';
1345 $return .=
'<div class="info-box-content">';
1346 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->getNomUrl() : $this->ref).
'</span>';
1347 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1348 if (property_exists($this,
'label')) {
1349 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1351 if (method_exists($this,
'getLibStatut')) {
1352 $return .=
'<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3).
'</div>';
1354 $return .=
'</div>';
1355 $return .=
'</div>';
1356 $return .=
'</div>';
1363 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1376 public $isextrafieldmanaged = 0;