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 'status' => array(
'type'=>
'smallint',
'label'=>
'Status',
'enabled'=>
'1',
'position'=>54,
'notnull'=>1,
'visible'=>2,
'default'=>
'0',
'index'=>1,
'arrayofkeyval'=>array(
'0'=>
'Draft',
'1'=>
'Accepted',
'2'=>
'Refused',
'8'=>
'Suspended',
'9'=>
'Terminated'),),
121 'url_to_check' => array(
'type'=>
'varchar(255)',
'label'=>
'UrlToCheck',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>-1,),
122 'count_last_url_check_error' => array(
'type'=>
'integer',
'label'=>
'CountLastUrlCheckError',
'enabled'=>
'1',
'position'=>71,
'notnull'=>0,
'visible'=>-2,
'default'=>
'0',),
123 'last_check_backlink' => array(
'type'=>
'datetime',
'label'=>
'LastCheckBacklink',
'enabled'=>
'1',
'position'=>72,
'notnull'=>0,
'visible'=>-2,),
124 'reason_decline_or_cancel' => array(
'type'=>
'text',
'label'=>
'ReasonDeclineOrCancel',
'enabled'=>
'1',
'position'=>73,
'notnull'=>0,
'visible'=>-2,),
125 'ip' => array(
'type'=>
'varchar(250)',
'label'=>
'Ip',
'enabled'=>
'1',
'position'=>74,
'notnull'=>0,
'visible'=>-2,),
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;
193 global $conf, $langs;
198 $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');
200 $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');
203 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
204 $this->fields[
'rowid'][
'visible'] = 0;
217 foreach ($this->fields as $key => $val) {
218 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
219 unset($this->fields[$key]);
224 if (is_object($langs)) {
225 foreach ($this->fields as $key => $val) {
226 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
227 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
228 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
244 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
245 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
262 global $langs, $extrafields;
267 $object =
new self($this->db);
272 $result = $object->fetchCommon($fromid);
273 if ($result > 0 && !empty($object->table_element_line)) {
274 $object->fetchLines();
283 unset($object->fk_user_creat);
284 unset($object->import_key);
287 if (property_exists($object,
'ref')) {
288 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
290 if (property_exists($object,
'label')) {
291 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
293 if (property_exists($object,
'status')) {
294 $object->status = self::STATUS_DRAFT;
296 if (property_exists($object,
'date_creation')) {
297 $object->date_creation =
dol_now();
299 if (property_exists($object,
'date_modification')) {
300 $object->date_modification =
null;
304 if (is_array($object->array_options) && count($object->array_options) > 0) {
305 $extrafields->fetch_name_optionals_label($this->table_element);
306 foreach ($object->array_options as $key => $option) {
307 $shortkey = preg_replace(
'/options_/',
'', $key);
308 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
311 unset($object->array_options[$key]);
317 $object->context[
'createfromclone'] =
'createfromclone';
318 $result = $object->createCommon($user);
321 $this->error = $object->error;
322 $this->errors = $object->errors;
334 if (property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
341 unset($object->context[
'createfromclone']);
348 $this->
db->rollback();
363 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
368 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
372 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
373 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
374 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
375 $sql .=
', p.note_private, p.note_public, p.url_to_check';
376 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
377 $sql .=
', p.import_key, p.model_pdf';
378 $sql .=
', pt.code as type_code, pt.label as type_label';
379 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
380 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
383 $sql .=
" WHERE p.rowid = ".((int) $id);
385 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
389 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
392 if ($fk_member > 0) {
393 $sql .=
' AND p.fk_member = '.((int) $fk_member);
396 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
398 $sql .=
' ORDER BY p.date_partnership_end DESC';
400 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
401 $result = $this->
db->query($sql);
403 $obj = $this->
db->fetch_object($result);
405 $this->
id = $obj->rowid;
406 $this->entity = $obj->entity;
407 $this->
ref = $obj->ref;
409 $this->fk_type = $obj->fk_type;
410 $this->type_code = $obj->type_code;
411 $this->type_label = $obj->type_label;
413 $this->fk_soc = $obj->fk_soc;
414 $this->fk_member = $obj->fk_member;
415 $this->status = $obj->status;
416 $this->date_partnership_start = $this->
db->jdate($obj->date_partnership_start);
417 $this->date_partnership_end = $this->
db->jdate($obj->date_partnership_end);
418 $this->date_creation = $this->
db->jdate($obj->date_creation);
419 $this->fk_user_creat = $obj->fk_user_creat;
420 $this->tms = $obj->tms;
421 $this->fk_user_modif = $obj->fk_user_modif;
422 $this->note_private = $obj->note_private;
423 $this->note_public = $obj->note_public;
424 $this->last_main_doc = $obj->last_main_doc;
425 $this->count_last_url_check_error = $obj->count_last_url_check_error;
426 $this->last_check_backlink = $this->
db->jdate($obj->last_check_backlink);
427 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
428 $this->import_key = $obj->import_key;
429 $this->model_pdf = $obj->model_pdf;
430 $this->url_to_check = $obj->url_to_check;
436 $this->
db->free($result);
444 $this->error = $this->
db->error();
457 $this->lines = array();
475 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
485 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
486 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
487 $sql .=
' WHERE t.entity IN ('.getEntity($this->element).
')';
489 $sql .=
' WHERE 1 = 1';
493 if (count($filter) > 0) {
494 foreach ($filter as $key => $value) {
495 if ($key ==
't.rowid') {
496 $sqlwhere[] = $key.
" = ".((int) $value);
497 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
498 $sqlwhere[] = $key.
" = '".$this->
db->idate($value).
"'";
499 } elseif ($key ==
'customsql') {
500 $sqlwhere[] = $value;
501 } elseif (strpos($value,
'%') ===
false) {
502 $sqlwhere[] = $key.
" IN (".$this->
db->sanitize($this->
db->escape($value)).
")";
504 $sqlwhere[] = $key.
" LIKE '%".$this->
db->escape($value).
"%'";
508 if (count($sqlwhere) > 0) {
509 $sql .=
' AND ('.implode(
' '.$this->
db->escape($filtermode).
' ', $sqlwhere).
')';
512 if (!empty($sortfield)) {
513 $sql .= $this->
db->order($sortfield, $sortorder);
515 if (!empty($limit)) {
516 $sql .= $this->
db->plimit($limit, $offset);
523 while ($i < ($limit ? min($limit, $num) : $num)) {
524 $obj = $this->
db->fetch_object(
$resql);
526 $record =
new self($this->db);
527 $record->setVarsFromFetchObj($obj);
529 $records[$record->id] = $record;
537 $this->errors[] =
'Error '.$this->db->lasterror();
538 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
553 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
554 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
557 if (empty($this->fk_user_creat)) {
558 $this->fk_user_creat = $user->id;
571 public function delete(
User $user, $notrigger =
false)
587 if ($this->status < 0) {
588 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
605 global $conf, $langs;
607 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
612 if ($this->status == self::STATUS_VALIDATED) {
613 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
630 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
635 $this->newref = $num;
639 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
640 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
641 $sql .=
" status = ".self::STATUS_VALIDATED;
642 if (!empty($this->fields[
'date_validation'])) {
643 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
645 if (!empty($this->fields[
'fk_user_valid'])) {
646 $sql .=
", fk_user_valid = ".$user->id;
648 $sql .=
" WHERE rowid = ".((int) $this->
id);
650 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
654 $this->error = $this->
db->lasterror();
658 if (!$error && !$notrigger) {
660 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
669 $this->oldref = $this->ref;
672 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
674 $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).
"'";
675 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
678 $error++; $this->error = $this->
db->lasterror();
684 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
685 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
686 if (!$error && file_exists($dirsource)) {
687 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
689 if (@rename($dirsource, $dirdest)) {
692 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
693 foreach ($listoffiles as $fileentry) {
694 $dirsource = $fileentry[
'name'];
695 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
696 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
697 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
698 @rename($dirsource, $dirdest);
708 $this->status = self::STATUS_VALIDATED;
715 $this->
db->rollback();
727 public function approve($user, $notrigger = 0)
729 global $conf, $langs;
731 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
736 if ($this->status == self::STATUS_APPROVED) {
737 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
754 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
759 $this->newref = $num;
763 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
764 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
765 $sql .=
" status = ".self::STATUS_APPROVED;
772 $sql .=
" WHERE rowid = ".((int) $this->
id);
774 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
778 $this->error = $this->
db->lasterror();
782 if (!$error && !$notrigger) {
784 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
793 $this->oldref = $this->ref;
796 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
798 $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).
"'";
799 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
802 $error++; $this->error = $this->
db->lasterror();
808 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
809 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
810 if (!$error && file_exists($dirsource)) {
811 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
813 if (@rename($dirsource, $dirdest)) {
816 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
817 foreach ($listoffiles as $fileentry) {
818 $dirsource = $fileentry[
'name'];
819 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
820 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
821 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
822 @rename($dirsource, $dirdest);
832 $this->status = self::STATUS_APPROVED;
839 $this->
db->rollback();
855 if ($this->status <= self::STATUS_DRAFT) {
866 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
877 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
880 if ($this->status == self::STATUS_REFUSED) {
884 $this->status = self::STATUS_REFUSED;
885 $this->reason_decline_or_cancel = $reasondeclinenote;
887 $result = $this->
update($user);
890 $this->reason_decline_or_cancel = $reasondeclinenote;
904 public function cancel($user, $notrigger = 0)
907 if ($this->status != self::STATUS_APPROVED) {
918 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
928 public function reopen($user, $notrigger = 0)
931 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
942 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
955 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
957 global $conf, $langs, $hookmanager;
959 if (!empty($conf->dol_no_mouse_hover)) {
965 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
966 if (isset($this->status)) {
967 $label .=
' '.$this->getLibStatut(5);
970 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
972 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
974 if ($option !=
'nolink') {
976 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
977 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
978 $add_save_lastsearch_values = 1;
980 if ($add_save_lastsearch_values) {
981 $url .=
'&save_lastsearch_values=1';
986 if (empty($notooltip)) {
987 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
988 $label = $langs->trans(
"ShowPartnership");
989 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
991 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
992 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
994 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
997 if ($option ==
'nolink') {
998 $linkstart =
'<span';
1000 $linkstart =
'<a href="'.$url.
'"';
1002 $linkstart .= $linkclose.
'>';
1003 if ($option ==
'nolink') {
1004 $linkend =
'</span>';
1009 $result .= $linkstart;
1011 if (empty($this->showphoto_on_popup)) {
1013 $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);
1017 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1019 list($class, $module) = explode(
'@', $this->picto);
1022 $filename = $filearray[0][
'name'];
1023 if (!empty($filename)) {
1024 $pospoint = strpos($filearray[0][
'name'],
'.');
1026 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1027 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
1028 $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>';
1030 $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>';
1033 $result .=
'</div>';
1035 $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);
1040 if ($withpicto != 2) {
1041 $result .= $this->ref;
1044 $result .= $linkend;
1047 global $action, $hookmanager;
1048 $hookmanager->initHooks(array(
'partnershipdao'));
1049 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1050 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1052 $result = $hookmanager->resPrint;
1054 $result .= $hookmanager->resPrint;
1068 return $this->LibStatut($this->status, $mode);
1082 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1085 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1086 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1087 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1088 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1089 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1090 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1091 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1092 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1093 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1094 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1097 $statusType =
'status'.$status;
1098 if ($status == self::STATUS_APPROVED) {
1099 $statusType =
'status4';
1101 if ($status == self::STATUS_REFUSED) {
1102 $statusType =
'status9';
1104 if ($status == self::STATUS_CANCELED) {
1105 $statusType =
'status6';
1108 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1119 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1120 $sql .=
' fk_user_creat, fk_user_modif';
1121 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1122 $sql .=
' WHERE t.rowid = '.((int) $id);
1123 $result = $this->
db->query($sql);
1125 if ($this->
db->num_rows($result)) {
1126 $obj = $this->
db->fetch_object($result);
1127 $this->
id = $obj->rowid;
1129 $this->user_creation_id = $obj->fk_user_creat;
1130 $this->user_modification_id = $obj->fk_user_modif;
1131 $this->date_creation = $this->
db->jdate($obj->datec);
1132 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
1135 $this->
db->free($result);
1149 $this->initAsSpecimenCommon();
1159 $this->lines = array();
1162 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1164 if (is_numeric($result)) {
1165 $this->error = $objectline->error;
1166 $this->errors = $objectline->errors;
1169 $this->lines = $result;
1170 return $this->lines;
1181 global $langs, $conf;
1182 $langs->load(
"partnership");
1184 if (empty($conf->global->PARTNERSHIP_ADDON)) {
1185 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1188 if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1191 $file = $conf->global->PARTNERSHIP_ADDON.
".php";
1192 $classname = $conf->global->PARTNERSHIP_ADDON;
1195 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1196 foreach ($dirmodels as $reldir) {
1200 $mybool |= @include_once $dir.$file;
1203 if ($mybool ===
false) {
1208 if (class_exists($classname)) {
1209 $obj =
new $classname();
1210 $numref = $obj->getNextValue($this);
1212 if ($numref !=
'' && $numref !=
'-1') {
1215 $this->error = $obj->error;
1220 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1224 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1240 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1242 global $conf, $langs;
1245 $includedocgeneration = 0;
1247 $langs->load(
"partnership");
1250 $modele =
'standard_partnership';
1252 if (!empty($this->model_pdf)) {
1253 $modele = $this->model_pdf;
1254 } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1255 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1259 $modelpath =
"core/modules/partnership/doc/";
1261 if ($includedocgeneration && !empty($modele)) {
1262 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1277 global $conf, $langs;
1293 $this->
db->commit();
1300 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1313 public $isextrafieldmanaged = 0;
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
deleteLineCommon(User $user, $idline, $notrigger=false)
Delete a line of object in database.
getFieldList($alias='')
Function to concat keys of fields.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
setStatusCommon($user, $status, $notrigger=0, $triggercode='')
Set to a status.
copy_linked_contact($objFrom, $source='internal')
Copy contact from one element to current.
updateCommon(User $user, $notrigger=false)
Update object into database.
fetchLinesCommon($morewhere='')
Load object in memory from the database.
call_trigger($triggerName, $user)
Call trigger based on this instance.
Parent class for class inheritance lines of business objects This class is useless for the moment so ...
Class to manage Dolibarr database access.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNextNumRef()
Returns the reference to the following non used object depending on the active numbering module.
validate($user, $notrigger=0)
Validate object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
generateDocument($modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0, $moreparams=null)
Create a document onto disk according to template module.
createFromClone(User $user, $fromid)
Clone an object into another one.
setDraft($user, $notrigger=0)
Set draft status.
refused($user, $reasondeclinenote='', $notrigger=0)
Set refused status.
update(User $user, $notrigger=false)
Update object into database.
deleteLine(User $user, $idline, $notrigger=false)
Delete a line of object in database.
fetch($id, $ref=null, $fk_member=null, $fk_soc=null)
Load object in memory from the database Get object from database.
getLinesArray()
Create an array of lines.
cancel($user, $notrigger=0)
Set cancel status.
reopen($user, $notrigger=0)
Set back to validated status.
fetchLines()
Load object lines in memory from the database.
create(User $user, $notrigger=false)
Create object into database.
doScheduledJob()
Action executed by scheduler CAN BE A CRON TASK.
getLibStatut($mode=0)
Return the label of the status.
LibStatut($status, $mode=0)
Return the status.
info($id)
Load the info information in the object.
approve($user, $notrigger=0)
Approve object.
__construct(DoliDB $db)
Constructor.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.