29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $module =
'partnership';
45 public $element =
'partnership';
50 public $table_element =
'partnership';
55 public $picto =
'partnership';
61 const STATUS_DRAFT = 0;
62 const STATUS_VALIDATED = 1;
63 const STATUS_APPROVED = 2;
64 const STATUS_REFUSED = 3;
65 const STATUS_CANCELED = 9;
98 public $fields = array(
99 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => 0,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
100 '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'),
101 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' =>
'isModEnabled("multicompany")',
'position' => 15,
'notnull' => 1,
'visible' => -2,
'default' =>
'1',
'index' => 1,),
102 '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'),
103 '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',),
104 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'position' => 61,
'notnull' => 0,
'visible' => 0,),
105 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'position' => 62,
'notnull' => 0,
'visible' => 0,),
106 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,
'csslist' =>
'nowraponall'),
107 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => -2,
'csslist' =>
'nowraponall'),
108 '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'),
109 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,
'csslist' =>
'tdoverflowmax125'),
110 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 0,),
111 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
112 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'position' => 1010,
'notnull' => -1,
'visible' => 0,),
113 'date_partnership_start' => array(
'type' =>
'date',
'label' =>
'DatePartnershipStart',
'enabled' => 1,
'position' => 52,
'notnull' => 1,
'visible' => 1,),
114 'date_partnership_end' => array(
'type' =>
'date',
'label' =>
'DatePartnershipEnd',
'enabled' => 1,
'position' => 53,
'notnull' => 0,
'visible' => 1,),
115 'url_to_check' => array(
'type' =>
'url',
'label' =>
'UrlToCheck',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 70,
'notnull' => 0,
'visible' => -1,
'csslist' =>
'tdoverflowmax150'),
116 'count_last_url_check_error' => array(
'type' =>
'integer',
'label' =>
'CountLastUrlCheckError',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 71,
'notnull' => 0,
'visible' => -4,
'default' =>
'0',),
117 'last_check_backlink' => array(
'type' =>
'datetime',
'label' =>
'LastCheckBacklink',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 72,
'notnull' => 0,
'visible' => -4,
'csslist' =>
'nowraponall'),
118 'reason_decline_or_cancel' => array(
'type' =>
'text',
'label' =>
'ReasonDeclineOrCancel',
'enabled' => 1,
'position' => 73,
'notnull' => 0,
'visible' => -2,),
119 'ip' => array(
'type' =>
'ip',
'label' =>
'IPOfApplicant',
'enabled' => 1,
'position' => 74,
'notnull' => 0,
'visible' => -2,),
120 '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'),),
127 public $note_private;
128 public $date_creation;
129 public $fk_user_creat;
130 public $fk_user_modif;
131 public $last_main_doc;
134 public $date_partnership_start;
135 public $date_partnership_end;
136 public $url_to_check;
137 public $count_last_url_check_error;
138 public $last_check_backlink;
139 public $reason_decline_or_cancel;
158 $this->ismultientitymanaged = 0;
159 $this->isextrafieldmanaged = 1;
162 $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',
'css' =>
'maxwidth500',
'csslist' =>
'tdoverflowmax150');
163 unset($this->fields[
'fk_soc']);
165 $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');
166 unset($this->fields[
'fk_member']);
169 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
170 $this->fields[
'rowid'][
'visible'] = 0;
174 foreach ($this->fields as $key => $val) {
175 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
176 unset($this->fields[$key]);
181 if (is_object($langs)) {
182 foreach ($this->fields as $key => $val) {
183 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
184 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
185 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
201 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
202 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
219 global $langs, $extrafields;
229 $result =
$object->fetchCommon($fromid);
230 if ($result > 0 && !empty(
$object->table_element_line)) {
244 if (property_exists(
$object,
'ref')) {
245 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
247 if (property_exists(
$object,
'label')) {
248 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".
$object->label : $this->fields[
'label'][
'default'];
250 if (property_exists(
$object,
'status')) {
251 $object->status = self::STATUS_DRAFT;
253 if (property_exists(
$object,
'date_creation')) {
256 if (property_exists(
$object,
'date_modification')) {
257 $object->date_modification =
null;
261 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
262 $extrafields->fetch_name_optionals_label($this->table_element);
263 foreach (
$object->array_options as $key => $option) {
264 $shortkey = preg_replace(
'/options_/',
'', $key);
265 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
268 unset(
$object->array_options[$key]);
274 $object->context[
'createfromclone'] =
'createfromclone';
275 $result =
$object->createCommon($user);
279 $this->errors =
$object->errors;
291 if (property_exists($this,
'fk_soc') && $this->fk_soc ==
$object->socid) {
298 unset(
$object->context[
'createfromclone']);
305 $this->db->rollback();
320 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
323 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
327 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
328 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
329 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
330 $sql .=
', p.note_private, p.note_public, p.url_to_check';
331 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
332 $sql .=
', p.import_key, p.model_pdf';
333 $sql .=
', pt.code as type_code, pt.label as type_label';
334 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
335 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
338 $sql .=
" WHERE p.rowid = ".((int) $id);
340 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
344 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
347 if ($fk_member > 0) {
348 $sql .=
' AND p.fk_member = '.((int) $fk_member);
351 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
353 $sql .=
' ORDER BY p.date_partnership_end DESC';
355 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
356 $result = $this->db->query($sql);
358 $obj = $this->db->fetch_object($result);
360 $this->
id = $obj->rowid;
361 $this->entity = $obj->entity;
362 $this->
ref = $obj->ref;
364 $this->fk_type = $obj->fk_type;
365 $this->type_code = $obj->type_code;
366 $this->type_label = $obj->type_label;
368 $this->fk_soc = $obj->fk_soc;
369 $this->fk_member = $obj->fk_member;
370 $this->
status = $obj->status;
371 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
372 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
373 $this->date_creation = $this->db->jdate($obj->date_creation);
374 $this->fk_user_creat = $obj->fk_user_creat;
375 $this->tms = $obj->tms;
376 $this->fk_user_modif = $obj->fk_user_modif;
377 $this->note_private = $obj->note_private;
378 $this->note_public = $obj->note_public;
379 $this->last_main_doc = $obj->last_main_doc;
380 $this->count_last_url_check_error = $obj->count_last_url_check_error;
381 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
382 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
383 $this->import_key = $obj->import_key;
384 $this->model_pdf = $obj->model_pdf;
385 $this->url_to_check = $obj->url_to_check;
391 $this->db->free($result);
399 $this->error = $this->db->error();
412 $this->lines = array();
430 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
438 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
439 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
440 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
442 $sql .=
' WHERE 1 = 1';
446 if (is_array($filter)) {
448 if (count($filter) > 0) {
449 foreach ($filter as $key => $value) {
450 if ($key ==
't.rowid') {
451 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
452 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
453 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
454 } elseif (strpos($value,
'%') ===
false) {
455 $sqlwhere[] = $this->db->sanitize($key).
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
457 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
461 if (count($sqlwhere) > 0) {
462 $sql .=
' AND ('.implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
472 $this->errors[] = $errormessage;
473 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
477 if (!empty($sortfield)) {
478 $sql .= $this->db->order($sortfield, $sortorder);
480 if (!empty($limit)) {
481 $sql .= $this->db->plimit($limit, $offset);
484 $resql = $this->db->query($sql);
486 $num = $this->db->num_rows($resql);
488 while ($i < ($limit ? min($limit, $num) : $num)) {
489 $obj = $this->db->fetch_object($resql);
491 $record =
new self($this->db);
492 $record->setVarsFromFetchObj($obj);
494 $records[$record->id] = $record;
498 $this->db->free($resql);
502 $this->errors[] =
'Error '.$this->db->lasterror();
503 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
518 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
519 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
522 if (empty($this->fk_user_creat)) {
523 $this->fk_user_creat = $user->id;
536 public function delete(
User $user, $notrigger = 0)
553 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
572 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
577 if ($this->
status == self::STATUS_VALIDATED) {
578 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
595 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
600 $this->newref = $num;
604 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
605 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
606 $sql .=
" status = ".self::STATUS_VALIDATED;
607 if (!empty($this->fields[
'date_validation'])) {
608 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
610 if (!empty($this->fields[
'fk_user_valid'])) {
611 $sql .=
", fk_user_valid = ".$user->id;
613 $sql .=
" WHERE rowid = ".((int) $this->
id);
615 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
616 $resql = $this->db->query($sql);
619 $this->error = $this->db->lasterror();
623 if (!$error && !$notrigger) {
625 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
634 $this->oldref = $this->ref;
637 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
639 $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).
"'";
640 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
641 $resql = $this->db->query($sql);
644 $this->error = $this->db->lasterror();
646 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
647 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
648 $resql = $this->db->query($sql);
651 $this->error = $this->db->lasterror();
657 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
658 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
659 if (!$error && file_exists($dirsource)) {
660 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
662 if (@rename($dirsource, $dirdest)) {
665 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
666 foreach ($listoffiles as $fileentry) {
667 $dirsource = $fileentry[
'name'];
668 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
669 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
670 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
671 @rename($dirsource, $dirdest);
681 $this->
status = self::STATUS_VALIDATED;
688 $this->db->rollback();
700 public function approve($user, $notrigger = 0)
704 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
709 if ($this->
status == self::STATUS_APPROVED) {
710 dol_syslog(get_class($this).
"::accept action abandoned: already acceptd", LOG_WARNING);
727 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
732 $this->newref = $num;
736 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
737 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
738 $sql .=
" status = ".self::STATUS_APPROVED;
745 $sql .=
" WHERE rowid = ".((int) $this->
id);
747 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
748 $resql = $this->db->query($sql);
751 $this->error = $this->db->lasterror();
755 if (!$error && !$notrigger) {
757 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
766 $this->oldref = $this->ref;
769 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
771 $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).
"'";
772 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
773 $resql = $this->db->query($sql);
776 $this->error = $this->db->lasterror();
778 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
779 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
780 $resql = $this->db->query($sql);
783 $this->error = $this->db->lasterror();
789 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
790 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
791 if (!$error && file_exists($dirsource)) {
792 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
794 if (@rename($dirsource, $dirdest)) {
797 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
798 foreach ($listoffiles as $fileentry) {
799 $dirsource = $fileentry[
'name'];
800 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
801 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
802 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
803 @rename($dirsource, $dirdest);
813 $this->
status = self::STATUS_APPROVED;
820 $this->db->rollback();
836 if ($this->
status <= self::STATUS_DRAFT) {
847 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
858 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
861 if ($this->
status == self::STATUS_REFUSED) {
865 $this->
status = self::STATUS_REFUSED;
866 $this->reason_decline_or_cancel = $reasondeclinenote;
868 $result = $this->
update($user);
871 $this->reason_decline_or_cancel = $reasondeclinenote;
885 public function cancel($user, $notrigger = 0)
888 if ($this->
status != self::STATUS_APPROVED) {
899 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
909 public function reopen($user, $notrigger = 0)
912 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_REFUSED) {
923 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
937 $langs->load(
'partnership');
940 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
941 if (isset($this->
status)) {
942 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
944 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
959 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
961 global $conf, $langs, $hookmanager;
963 if (!empty($conf->dol_no_mouse_hover)) {
970 'objecttype' => $this->element,
973 $classfortooltip =
'classfortooltip';
976 $classfortooltip =
'classforajaxtooltip';
977 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
983 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
985 if ($option !=
'nolink') {
987 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
988 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
989 $add_save_lastsearch_values = 1;
991 if ($add_save_lastsearch_values) {
992 $url .=
'&save_lastsearch_values=1';
997 if (empty($notooltip)) {
999 $label = $langs->trans(
"ShowPartnership");
1000 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1002 $linkclose .= ($label ?
' title="'.dol_escape_htmltag($label, 1).
'"' :
' title="tocomplete"');
1003 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1005 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1008 if ($option ==
'nolink') {
1009 $linkstart =
'<span';
1011 $linkstart =
'<a href="'.$url.
'"';
1013 $linkstart .= $linkclose.
'>';
1014 if ($option ==
'nolink') {
1015 $linkend =
'</span>';
1020 $result .= $linkstart;
1022 if (empty($this->showphoto_on_popup)) {
1024 $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);
1028 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1030 list($class, $module) = explode(
'@', $this->picto);
1033 $filename = $filearray[0][
'name'];
1034 if (!empty($filename)) {
1035 $pospoint = strpos($filearray[0][
'name'],
'.');
1037 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1038 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1039 $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>';
1041 $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>';
1044 $result .=
'</div>';
1046 $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);
1051 if ($withpicto != 2) {
1052 $result .= $this->ref;
1055 $result .= $linkend;
1058 global $action, $hookmanager;
1059 $hookmanager->initHooks(array(
'partnershipdao'));
1060 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1061 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1063 $result = $hookmanager->resPrint;
1065 $result .= $hookmanager->resPrint;
1081 $tables = array(
'partnership');
1108 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1111 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1112 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1113 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1114 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1115 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1116 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1117 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1118 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1119 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1120 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1123 $statusType =
'status'.$status;
1124 if ($status == self::STATUS_APPROVED) {
1125 $statusType =
'status4';
1127 if ($status == self::STATUS_REFUSED) {
1128 $statusType =
'status9';
1130 if ($status == self::STATUS_CANCELED) {
1131 $statusType =
'status6';
1134 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1145 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1146 $sql .=
' fk_user_creat, fk_user_modif';
1147 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1148 $sql .=
' WHERE t.rowid = '.((int) $id);
1149 $result = $this->db->query($sql);
1151 if ($this->db->num_rows($result)) {
1152 $obj = $this->db->fetch_object($result);
1154 $this->
id = $obj->rowid;
1156 $this->user_creation_id = $obj->fk_user_creat;
1157 $this->user_modification_id = $obj->fk_user_modif;
1158 $this->date_creation = $this->db->jdate($obj->datec);
1159 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1162 $this->db->free($result);
1186 $this->lines = array();
1189 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_partnership:=:'.((
int) $this->
id).
')');
1191 if (is_numeric($result)) {
1192 $this->error = $objectline->error;
1193 $this->errors = $objectline->errors;
1196 $this->lines = $result;
1197 return $this->lines;
1208 global $langs, $conf;
1209 $langs->load(
"partnership");
1212 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1222 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1223 foreach ($dirmodels as $reldir) {
1227 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1230 if ($mybool ===
false) {
1235 if (class_exists($classname)) {
1236 $obj =
new $classname();
1237 $numref = $obj->getNextValue($this);
1239 if ($numref !=
'' && $numref !=
'-1') {
1242 $this->error = $obj->error;
1247 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1251 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1267 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1269 global $conf, $langs;
1272 $includedocgeneration = 0;
1274 $langs->load(
"partnership");
1277 $modele =
'standard_partnership';
1279 if (!empty($this->model_pdf)) {
1280 $modele = $this->model_pdf;
1286 $modelpath =
"core/modules/partnership/doc/";
1288 if ($includedocgeneration && !empty($modele)) {
1289 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1318 $this->db->commit();
1332 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1334 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1335 $return .=
'<div class="info-box info-box-sm">';
1336 $return .=
'<span class="info-box-icon bg-infobox-action">';
1338 $return .=
'</span>';
1339 $return .=
'<div class="info-box-content">';
1340 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1341 if ($selected >= 0) {
1342 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1344 if (property_exists($this,
'label')) {
1345 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1347 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1348 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1350 if (method_exists($this,
'getLibStatut')) {
1351 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1353 $return .=
'</div>';
1354 $return .=
'</div>';
1355 $return .=
'</div>';
1362require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1382 $this->isextrafieldmanaged = 0;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteLineCommon(User $user, $idline, $notrigger=0)
Delete a line of object in database.
commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
Common function for all objects extending CommonObject for generating documents.
createCommon(User $user, $notrigger=0)
Create object in the database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=0)
Update object into database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
initAsSpecimenCommon()
Initialise object with example values Id must be 0 if object instance is a specimen.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
static commonReplaceThirdparty(DoliDB $dbs, $origin_id, $dest_id, array $tables, $ignoreerrors=0)
Function used to replace a thirdparty id with another one.
fetchLinesCommon($morewhere='', $noextrafields=0)
Load object in memory from the database.
deleteCommon(User $user, $notrigger=0, $forcechilddeletion=0)
Delete object in database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionally the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
static replaceThirdparty($db, $origin_id, $dest_id)
Function used to replace a thirdparty id with another one.
create(User $user, $notrigger=0)
Create object into database.
update(User $user, $notrigger=0)
Update object into database.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
getLinesArray()
Create an array of lines.
getTooltipContentArray($params)
getTooltipContentArray
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetchLines()
Load object lines in memory from the database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, $filter='', $filtermode='AND')
Load list of objects in memory from the database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
deleteLine(User $user, $idline, $notrigger=0)
Delete a line of object in database.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
forgeSQLFromUniversalSearchCriteria($filter, &$errorstr='', $noand=0, $nopar=0, $noerror=0)
forgeSQLFromUniversalSearchCriteria
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.