31require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
42 public $module =
'partnership';
47 public $element =
'partnership';
52 public $table_element =
'partnership';
57 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",
'csslist' =>
'tdoverflowmax150'),
109 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'enabled' =>
'isModEnabled("multicompany")',
'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',
'help' =>
'YouCanChangeValuesForThisListFromDictionarySetup'),
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 'date_creation' => array(
'type' =>
'datetime',
'label' =>
'DateCreation',
'enabled' => 1,
'position' => 500,
'notnull' => 1,
'visible' => -2,
'csslist' =>
'nowraponall'),
113 'tms' => array(
'type' =>
'timestamp',
'label' =>
'DateModification',
'enabled' => 1,
'position' => 501,
'notnull' => 0,
'visible' => -2,
'csslist' =>
'nowraponall'),
114 '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'),
115 'fk_user_modif' => array(
'type' =>
'integer:User:user/class/user.class.php',
'label' =>
'UserModif',
'enabled' => 1,
'position' => 511,
'notnull' => -1,
'visible' => -2,
'csslist' =>
'tdoverflowmax125'),
116 'last_main_doc' => array(
'type' =>
'varchar(255)',
'label' =>
'LastMainDoc',
'enabled' => 1,
'position' => 600,
'notnull' => 0,
'visible' => 0,),
117 'import_key' => array(
'type' =>
'varchar(14)',
'label' =>
'ImportId',
'enabled' => 1,
'position' => 1000,
'notnull' => -1,
'visible' => -2,),
118 'model_pdf' => array(
'type' =>
'varchar(255)',
'label' =>
'Model pdf',
'enabled' => 1,
'position' => 1010,
'notnull' => -1,
'visible' => 0,),
119 'date_partnership_start' => array(
'type' =>
'date',
'label' =>
'DatePartnershipStart',
'enabled' => 1,
'position' => 60,
'notnull' => 1,
'visible' => 1,),
120 'date_partnership_end' => array(
'type' =>
'date',
'label' =>
'DatePartnershipEnd',
'enabled' => 1,
'position' => 65,
'notnull' => 0,
'visible' => 1,),
121 'url_to_check' => array(
'type' =>
'url',
'label' =>
'UrlToCheck',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 70,
'notnull' => 0,
'visible' => -1,
'csslist' =>
'tdoverflowmax150'),
122 'count_last_url_check_error' => array(
'type' =>
'integer',
'label' =>
'CountLastUrlCheckError',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 71,
'notnull' => 0,
'visible' => -4,
'default' =>
'0',),
123 'last_check_backlink' => array(
'type' =>
'datetime',
'label' =>
'LastCheckBacklink',
'enabled' =>
'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")',
'position' => 72,
'notnull' => 0,
'visible' => -4,
'csslist' =>
'nowraponall'),
124 'reason_decline_or_cancel' => array(
'type' =>
'text',
'label' =>
'ReasonDeclineOrCancel',
'enabled' => 1,
'position' => 73,
'notnull' => 0,
'visible' => -2,),
125 'ip' => array(
'type' =>
'ip',
'label' =>
'IPOfApplicant',
'enabled' => 1,
'position' => 74,
'notnull' => 0,
'visible' => -2,),
126 'note_public' => array(
'type' =>
'html',
'label' =>
'NotePublic',
'enabled' => 1,
'position' => 80,
'notnull' => 0,
'visible' => 0,),
127 'note_private' => array(
'type' =>
'html',
'label' =>
'NotePrivate',
'enabled' => 1,
'position' => 81,
'notnull' => 0,
'visible' => 0,),
128 'status' => array(
'type' =>
'smallint',
'label' =>
'Status',
'enabled' => 1,
'position' => 2000,
'notnull' => 1,
'visible' => 2,
'default' =>
'0',
'index' => 1,
'arrayofkeyval' => array(0 =>
'Draft', 1 =>
'Validated', 2 =>
'Approved', 3 =>
'Refused', 9 =>
'Terminated'),),
152 public $note_private;
156 public $fk_user_creat;
160 public $fk_user_modif;
164 public $last_main_doc;
176 public $date_partnership_start;
180 public $date_partnership_end;
184 public $url_to_check;
188 public $count_last_url_check_error;
192 public $last_check_backlink;
196 public $reason_decline_or_cancel;
227 $this->ismultientitymanaged = 0;
228 $this->isextrafieldmanaged = 1;
231 $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');
232 unset($this->fields[
'fk_soc']);
234 $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');
235 unset($this->fields[
'fk_member']);
239 if (!
getDolGlobalString(
'MAIN_SHOW_TECHNICAL_ID') && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
240 $this->fields[
'rowid'][
'visible'] = 0;
244 foreach ($this->fields as $key => $val) {
245 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
246 unset($this->fields[$key]);
251 if (is_object($langs)) {
252 foreach ($this->fields as $key => $val) {
253 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
254 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
255 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
271 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
272 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
289 global $langs, $extrafields;
299 $result =
$object->fetchCommon($fromid);
300 if ($result > 0 && !empty(
$object->table_element_line)) {
311 unset(
$object->user_creation_id);
315 if (property_exists(
$object,
'ref')) {
317 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
319 if (property_exists(
$object,
'status')) {
320 $object->status = self::STATUS_DRAFT;
322 if (property_exists(
$object,
'date_creation')) {
325 if (property_exists(
$object,
'date_modification')) {
326 $object->date_modification =
null;
330 if (is_array(
$object->array_options) && count(
$object->array_options) > 0) {
331 $extrafields->fetch_name_optionals_label($this->table_element);
332 foreach (
$object->array_options as $key => $option) {
333 $shortkey = preg_replace(
'/options_/',
'', $key);
334 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
337 unset(
$object->array_options[$key]);
343 $object->context[
'createfromclone'] =
'createfromclone';
344 $result =
$object->createCommon($user);
359 if (!empty(
$object->socid) && ((property_exists($this,
'fk_soc') && ($this->fk_soc ==
$object->socid)) || (property_exists($this,
'socid') && ($this->socid ==
$object->socid)))) {
366 unset(
$object->context[
'createfromclone']);
373 $this->db->rollback();
388 public function fetch($id, $ref =
'', $fk_member = 0, $fk_soc = 0)
391 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
395 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
396 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
397 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
398 $sql .=
', p.note_private, p.note_public, p.url_to_check';
399 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
400 $sql .=
', p.import_key, p.model_pdf';
401 $sql .=
', pt.code as type_code, pt.label as type_label';
402 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
403 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
406 $sql .=
" WHERE p.rowid = ".((int) $id);
408 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
412 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
415 if ($fk_member > 0) {
416 $sql .=
' AND p.fk_member = '.((int) $fk_member);
419 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
421 $sql .=
' ORDER BY p.date_partnership_end DESC';
423 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
424 $result = $this->db->query($sql);
426 $obj = $this->db->fetch_object($result);
428 $this->
id = $obj->rowid;
429 $this->entity = $obj->entity;
430 $this->
ref = $obj->ref;
432 $this->fk_type = $obj->fk_type;
433 $this->type_code = $obj->type_code;
434 $this->type_label = $obj->type_label;
436 $this->fk_soc = $obj->fk_soc;
437 $this->fk_member = $obj->fk_member;
438 $this->
status = $obj->status;
439 $this->date_partnership_start = $this->db->jdate($obj->date_partnership_start);
440 $this->date_partnership_end = $this->db->jdate($obj->date_partnership_end);
441 $this->date_creation = $this->db->jdate($obj->date_creation);
442 $this->fk_user_creat = $obj->fk_user_creat;
443 $this->tms = $obj->tms;
444 $this->fk_user_modif = $obj->fk_user_modif;
445 $this->note_private = $obj->note_private;
446 $this->note_public = $obj->note_public;
447 $this->last_main_doc = $obj->last_main_doc;
448 $this->count_last_url_check_error = $obj->count_last_url_check_error;
449 $this->last_check_backlink = $this->db->jdate($obj->last_check_backlink);
450 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
451 $this->import_key = $obj->import_key;
452 $this->model_pdf = $obj->model_pdf;
453 $this->url_to_check = $obj->url_to_check;
459 $this->db->free($result);
467 $this->error = $this->db->error();
481 $this->lines = array();
501 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, $filter =
'', $filtermode =
'AND')
509 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
510 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
511 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
513 $sql .=
" WHERE 1 = 1";
517 if (is_array($filter)) {
519 if (count($filter) > 0) {
520 foreach ($filter as $key => $value) {
521 if ($key ==
't.rowid') {
522 $sqlwhere[] = $this->db->sanitize($key).
" = ".((int) $value);
523 } elseif (array_key_exists($key, $this->fields) && in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
524 $sqlwhere[] = $this->db->sanitize($key).
" = '".$this->db->idate($value).
"'";
525 } elseif (strpos($value,
'%') ===
false) {
526 $sqlwhere[] = $this->db->sanitize($key).
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
528 $sqlwhere[] = $this->db->sanitize($key).
" LIKE '%".$this->db->escape($this->db->escapeforlike($value)).
"%'";
532 if (count($sqlwhere) > 0) {
533 $sql .=
" AND (".implode(
' '.$this->db->escape($filtermode).
' ', $sqlwhere).
')';
541 $sql .= forgeSQLFromUniversalSearchCriteria($filter, $errormessage);
543 $this->errors[] = $errormessage;
544 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
548 if (!empty($sortfield)) {
549 $sql .= $this->db->order($sortfield, $sortorder);
551 if (!empty($limit)) {
552 $sql .= $this->db->plimit($limit, $offset);
555 $resql = $this->db->query($sql);
557 $num = $this->db->num_rows($resql);
559 while ($i < ($limit ? min($limit, $num) : $num)) {
560 $obj = $this->db->fetch_object($resql);
562 $record =
new self($this->db);
563 $record->setVarsFromFetchObj($obj);
565 $record->fetch_optionals();
567 $records[$record->id] = $record;
571 $this->db->free($resql);
575 $this->errors[] =
'Error '.$this->db->lasterror();
576 dol_syslog(__METHOD__.
' '.implode(
',', $this->errors), LOG_ERR);
591 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
592 $this->errors[] =
"ErrorThirpdartyOrMemberidIsMandatory";
595 if (empty($this->fk_user_creat)) {
596 $this->fk_user_creat = $user->id;
609 public function delete(
User $user, $notrigger = 0)
626 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
645 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
650 if ($this->
status == self::STATUS_VALIDATED) {
651 dol_syslog(get_class($this).
"::validate action abandoned: already validated", LOG_WARNING);
668 if (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref)) {
673 $this->newref = $num;
677 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
678 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
679 $sql .=
" status = ".self::STATUS_VALIDATED;
680 if (!empty($this->fields[
'date_validation'])) {
681 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
683 if (!empty($this->fields[
'fk_user_valid'])) {
684 $sql .=
", fk_user_valid = ".((int) $user->id);
686 $sql .=
" WHERE rowid = ".((int) $this->
id);
688 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
689 $resql = $this->db->query($sql);
692 $this->error = $this->db->lasterror();
696 if (!$error && !$notrigger) {
698 $result = $this->call_trigger(
'PARTNERSHIP_VALIDATE', $user);
707 $this->oldref = $this->ref;
710 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
712 $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).
"'";
713 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
714 $resql = $this->db->query($sql);
717 $this->error = $this->db->lasterror();
719 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
720 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
721 $resql = $this->db->query($sql);
724 $this->error = $this->db->lasterror();
730 $dirsource =
$conf->partnership->dir_output.
'/partnership/'.$oldref;
731 $dirdest =
$conf->partnership->dir_output.
'/partnership/'.$newref;
732 if (!$error && file_exists($dirsource)) {
733 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
735 if (@rename($dirsource, $dirdest)) {
738 $listoffiles =
dol_dir_list(
$conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
739 foreach ($listoffiles as $fileentry) {
740 $dirsource = $fileentry[
'name'];
741 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
742 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
743 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
744 @rename($dirsource, $dirdest);
754 $this->
status = self::STATUS_VALIDATED;
761 $this->db->rollback();
773 public function approve($user, $notrigger = 0)
777 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
782 if ($this->
status == self::STATUS_APPROVED) {
783 dol_syslog(get_class($this).
"::accept action abandoned: already acceptd", LOG_WARNING);
800 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
805 $this->newref = $num;
809 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
810 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
811 $sql .=
" status = ".self::STATUS_APPROVED;
812 $sql .=
" WHERE rowid = ".((int) $this->
id);
814 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
815 $resql = $this->db->query($sql);
818 $this->error = $this->db->lasterror();
822 if (!$error && !$notrigger) {
824 $result = $this->call_trigger(
'PARTNERSHIP_ACCEPT', $user);
833 $this->oldref = $this->ref;
836 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
838 $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).
"'";
839 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
840 $resql = $this->db->query($sql);
843 $this->error = $this->db->lasterror();
845 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filepath = 'partnership/".$this->db->escape($this->newref).
"'";
846 $sql .=
" WHERE filepath = 'partnership/".$this->db->escape($this->
ref).
"' and entity = ".$conf->entity;
847 $resql = $this->db->query($sql);
850 $this->error = $this->db->lasterror();
856 $dirsource =
$conf->partnership->dir_output.
'/partnership/'.$oldref;
857 $dirdest =
$conf->partnership->dir_output.
'/partnership/'.$newref;
858 if (!$error && file_exists($dirsource)) {
859 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
861 if (@rename($dirsource, $dirdest)) {
864 $listoffiles =
dol_dir_list(
$conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
865 foreach ($listoffiles as $fileentry) {
866 $dirsource = $fileentry[
'name'];
867 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
868 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
869 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
870 @rename($dirsource, $dirdest);
880 $this->
status = self::STATUS_APPROVED;
887 $this->db->rollback();
903 if ($this->
status <= self::STATUS_DRAFT) {
914 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
925 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
928 if ($this->
status == self::STATUS_REFUSED) {
932 $this->
status = self::STATUS_REFUSED;
933 $this->reason_decline_or_cancel = $reasondeclinenote;
935 $result = $this->
update($user);
938 $this->reason_decline_or_cancel = $reasondeclinenote;
952 public function cancel($user, $notrigger = 0)
955 if ($this->
status != self::STATUS_APPROVED) {
966 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
976 public function reopen($user, $notrigger = 0)
979 if ($this->
status != self::STATUS_CANCELED && $this->
status != self::STATUS_REFUSED) {
990 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
1003 $langs->load(
'partnership');
1007 $datas[
'picto'] =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
1008 if (isset($this->
status)) {
1009 $datas[
'picto'] .=
' '.$this->getLibStatut(5);
1011 $datas[
'ref'] =
'<br><b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
1026 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1028 global
$conf, $langs, $hookmanager;
1030 if (!empty(
$conf->dol_no_mouse_hover)) {
1036 'id' => (
string) $this->
id,
1037 'objecttype' => $this->element,
1038 'option' => $option,
1040 $classfortooltip =
'classfortooltip';
1043 $classfortooltip =
'classforajaxtooltip';
1044 $dataparams =
' data-params="'.dol_escape_htmltag(json_encode($params)).
'"';
1050 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
1052 if ($option !=
'nolink') {
1054 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1055 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1056 $add_save_lastsearch_values = 1;
1058 if ($add_save_lastsearch_values) {
1059 $url .=
'&save_lastsearch_values=1';
1064 if (empty($notooltip)) {
1066 $label = $langs->trans(
"ShowPartnership");
1067 $linkclose .=
' alt="'.dolPrintHTMLForAttribute($label).
'"';
1069 $linkclose .= ($label ?
' title="'.dolPrintHTMLForAttribute($label).
'"' :
' title="tocomplete"');
1070 $linkclose .= $dataparams.
' class="'.$classfortooltip.($morecss ?
' '.$morecss :
'').
'"';
1072 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1075 if ($option ==
'nolink') {
1076 $linkstart =
'<span';
1078 $linkstart =
'<a href="'.$url.
'"';
1080 $linkstart .= $linkclose.
'>';
1081 if ($option ==
'nolink') {
1082 $linkend =
'</span>';
1087 $result .= $linkstart;
1089 if (empty($this->showphoto_on_popup)) {
1091 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), (($withpicto != 2) ?
'class="paddingright"' :
''), 0, 0, $notooltip ? 0 : 1);
1095 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1097 list($class, $module) = explode(
'@', $this->picto);
1100 $filename = $filearray[0][
'name'];
1101 if (!empty($filename)) {
1102 $pospoint = strpos($filearray[0][
'name'],
'.');
1104 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1105 if (!
getDolGlobalString(strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS')) {
1106 $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>';
1108 $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>';
1111 $result .=
'</div>';
1113 $result .=
img_object(($notooltip ?
'' : $label), ($this->picto ? $this->picto :
'generic'), ($notooltip ? (($withpicto != 2) ?
'class="paddingright"' :
'') :
'class="'.(($withpicto != 2) ?
'paddingright ' :
'').
'"'), 0, 0, $notooltip ? 0 : 1);
1118 if ($withpicto != 2) {
1119 $result .= $this->ref;
1122 $result .= $linkend;
1125 global $action, $hookmanager;
1126 $hookmanager->initHooks(array(
'partnershipdao'));
1127 $parameters = array(
'id' => $this->
id,
'getnomurl' => &$result);
1128 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1130 $result = $hookmanager->resPrint;
1132 $result .= $hookmanager->resPrint;
1148 $tables = array(
'partnership');
1175 if (is_null($status)) {
1179 $paramsBadge = array(
'badgeParams' => array(
'attr' => array(
1180 'data-status-element' => $this->element,
1181 'data-status' => (
int) $status
1184 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1187 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1188 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1189 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1190 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1191 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1192 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1193 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1194 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1195 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1196 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1199 $statusType =
'status'.$status;
1200 if ($status == self::STATUS_APPROVED) {
1201 $statusType =
'status4';
1203 if ($status == self::STATUS_REFUSED) {
1204 $statusType =
'status9';
1206 if ($status == self::STATUS_CANCELED) {
1207 $statusType =
'status6';
1210 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode,
'', $paramsBadge);
1221 $sql =
"SELECT rowid, date_creation as datec, tms as datem,";
1222 $sql .=
" fk_user_creat, fk_user_modif";
1223 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
1224 $sql .=
" WHERE t.rowid = ".((int) $id);
1225 $result = $this->db->query($sql);
1227 if ($this->db->num_rows($result)) {
1228 $obj = $this->db->fetch_object($result);
1230 $this->
id = $obj->rowid;
1232 $this->user_creation_id = $obj->fk_user_creat;
1233 $this->user_modification_id = $obj->fk_user_modif;
1234 $this->date_creation = $this->db->jdate($obj->datec);
1235 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
1238 $this->db->free($result);
1262 $this->lines = array();
1265 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0,
'(fk_partnership:=:'.((
int) $this->
id).
')');
1267 if (is_numeric($result)) {
1268 $this->error = $objectline->error;
1269 $this->errors = $objectline->errors;
1272 $this->lines = $result;
1285 global $langs,
$conf;
1286 $langs->load(
"partnership");
1289 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1299 $dirmodels = array_merge(array(
'/'), (array)
$conf->modules_parts[
'models']);
1300 foreach ($dirmodels as $reldir) {
1304 $mybool = ((bool) @include_once $dir.$file) || $mybool;
1312 if (class_exists($classname)) {
1313 $obj =
new $classname();
1314 '@phan-var-force ModeleNumRefPartnership $obj';
1315 $numref = $obj->getNextValue($this);
1317 if ($numref !=
'' && $numref !=
'-1') {
1320 $this->error = $obj->error;
1325 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1329 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1345 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1350 $includedocgeneration = 0;
1352 $langs->load(
"partnership");
1355 $modele =
'standard_partnership';
1357 if (!empty($this->model_pdf)) {
1358 $modele = $this->model_pdf;
1364 $modelpath =
"core/modules/partnership/doc/";
1366 if ($includedocgeneration && !empty($modele)) {
1367 $result = $this->
commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1396 $this->db->commit();
1412 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1414 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1415 $return .=
'<div class="info-box info-box-sm">';
1416 $return .=
'<span class="info-box-icon bg-infobox-action">';
1418 $return .=
'</span>';
1419 $return .=
'<div class="info-box-content">';
1420 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1421 if ($selected >= 0) {
1422 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1424 if (property_exists($this,
'label')) {
1425 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1427 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1428 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1430 if (method_exists($this,
'getLibStatut')) {
1431 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1433 $return .=
'</div>';
1434 $return .=
'</div>';
1435 $return .=
'</div>';
1442require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1462 $this->isextrafieldmanaged = 0;
if(! $sortfield) if(! $sortorder) $object
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.
setErrorsFromObject($object)
setErrorsFromObject
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.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
initAsSpecimen()
Initialize 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.
fetchLines($noextrafields=0)
Load object lines in memory from the database.
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.
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.
fetch($id, $ref='', $fk_member=0, $fk_soc=0)
Load object in memory from the database Get object from 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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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.
dol_now($mode='gmt')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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_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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php