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,),
108 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>
'1',
'position'=>61,
'notnull'=>0,
'visible'=>0,),
109 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>
'1',
'position'=>62,
'notnull'=>0,
'visible'=>0,),
110 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>
'1',
'position'=>500,
'notnull'=>1,
'visible'=>-2,),
111 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,),
112 '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',),
113 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
114 'last_main_doc' => array(
'type'=>
'varchar(255)',
'label'=>
'LastMainDoc',
'enabled'=>
'1',
'position'=>600,
'notnull'=>0,
'visible'=>0,),
115 'import_key' => array(
'type'=>
'varchar(14)',
'label'=>
'ImportId',
'enabled'=>
'1',
'position'=>1000,
'notnull'=>-1,
'visible'=>-2,),
116 'model_pdf' => array(
'type'=>
'varchar(255)',
'label'=>
'Model pdf',
'enabled'=>
'1',
'position'=>1010,
'notnull'=>-1,
'visible'=>0,),
117 'date_partnership_start' => array(
'type'=>
'date',
'label'=>
'DatePartnershipStart',
'enabled'=>
'1',
'position'=>52,
'notnull'=>1,
'visible'=>1,),
118 'date_partnership_end' => array(
'type'=>
'date',
'label'=>
'DatePartnershipEnd',
'enabled'=>
'1',
'position'=>53,
'notnull'=>0,
'visible'=>1,),
119 'status' => array(
'type'=>
'smallint',
'label'=>
'Status',
'enabled'=>
'1',
'position'=>54,
'notnull'=>0,
'visible'=>2,
'default'=>
'0',
'index'=>1,
'arrayofkeyval'=>array(
'-1'=>
'',
'0'=>
'Draft',
'1'=>
'Accepted',
'2'=>
'Refused',
'8'=>
'Suspended',
'9'=>
'Terminated'),),
120 'url_to_check' => array(
'type'=>
'varchar(255)',
'label'=>
'UrlToCheck',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>-1,),
121 'count_last_url_check_error' => array(
'type'=>
'integer',
'label'=>
'CountLastUrlCheckError',
'enabled'=>
'1',
'position'=>71,
'notnull'=>0,
'visible'=>-2,
'default'=>
'0',),
122 'last_check_backlink' => array(
'type'=>
'datetime',
'label'=>
'LastCheckBacklink',
'enabled'=>
'1',
'position'=>72,
'notnull'=>0,
'visible'=>-2,),
123 'reason_decline_or_cancel' => array(
'type'=>
'text',
'label'=>
'ReasonDeclineOrCancel',
'enabled'=>
'1',
'position'=>73,
'notnull'=>0,
'visible'=>-2,),
124 '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'=>
'tdoverflowmax150',),
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';
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;
435 $this->
db->free($result);
443 $this->error = $this->
db->error();
456 $this->lines = array();
474 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
484 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
485 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
486 $sql .=
' WHERE t.entity IN ('.getEntity($this->table_element).
')';
488 $sql .=
' WHERE 1 = 1';
492 if (count($filter) > 0) {
493 foreach ($filter as $key => $value) {
494 if ($key ==
't.rowid') {
495 $sqlwhere[] = $key.
" = ".((int) $value);
496 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
497 $sqlwhere[] = $key.
" = '".$this->
db->idate($value).
"'";
498 } elseif ($key ==
'customsql') {
499 $sqlwhere[] = $value;
500 } elseif (strpos($value,
'%') ===
false) {
501 $sqlwhere[] = $key.
" IN (".$this->
db->sanitize($this->
db->escape($value)).
")";
503 $sqlwhere[] = $key.
" LIKE '%".$this->
db->escape($value).
"%'";
507 if (count($sqlwhere) > 0) {
508 $sql .=
' AND ('.implode(
' '.$this->
db->escape($filtermode).
' ', $sqlwhere).
')';
511 if (!empty($sortfield)) {
512 $sql .= $this->
db->order($sortfield, $sortorder);
514 if (!empty($limit)) {
515 $sql .= $this->
db->plimit($limit, $offset);
522 while ($i < ($limit ? min($limit, $num) : $num)) {
523 $obj = $this->
db->fetch_object(
$resql);
525 $record =
new self($this->db);
526 $record->setVarsFromFetchObj($obj);
528 $records[$record->id] = $record;
536 $this->errors[] =
'Error '.$this->db->lasterror();
537 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
552 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
553 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
567 public function delete(
User $user, $notrigger =
false)
583 if ($this->status < 0) {
584 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
601 global $conf, $langs;
603 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
608 if ($this->status == self::STATUS_VALIDATED) {
609 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
626 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
631 $this->newref = $num;
635 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
636 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
637 $sql .=
" status = ".self::STATUS_VALIDATED;
638 if (!empty($this->fields[
'date_validation'])) {
639 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
641 if (!empty($this->fields[
'fk_user_valid'])) {
642 $sql .=
", fk_user_valid = ".$user->id;
644 $sql .=
" WHERE rowid = ".((int) $this->
id);
646 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
650 $this->error = $this->
db->lasterror();
654 if (!$error && !$notrigger) {
656 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
665 $this->oldref = $this->ref;
668 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
670 $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).
"'";
671 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
674 $error++; $this->error = $this->
db->lasterror();
680 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
681 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
682 if (!$error && file_exists($dirsource)) {
683 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
685 if (@rename($dirsource, $dirdest)) {
688 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
689 foreach ($listoffiles as $fileentry) {
690 $dirsource = $fileentry[
'name'];
691 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
692 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
693 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
694 @rename($dirsource, $dirdest);
704 $this->status = self::STATUS_VALIDATED;
711 $this->
db->rollback();
723 public function approve($user, $notrigger = 0)
725 global $conf, $langs;
727 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
732 if ($this->status == self::STATUS_APPROVED) {
733 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
750 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
755 $this->newref = $num;
759 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
760 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
761 $sql .=
" status = ".self::STATUS_APPROVED;
768 $sql .=
" WHERE rowid = ".((int) $this->
id);
770 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
774 $this->error = $this->
db->lasterror();
778 if (!$error && !$notrigger) {
780 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
789 $this->oldref = $this->ref;
792 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
794 $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).
"'";
795 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
798 $error++; $this->error = $this->
db->lasterror();
804 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
805 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
806 if (!$error && file_exists($dirsource)) {
807 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
809 if (@rename($dirsource, $dirdest)) {
812 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
813 foreach ($listoffiles as $fileentry) {
814 $dirsource = $fileentry[
'name'];
815 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
816 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
817 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
818 @rename($dirsource, $dirdest);
828 $this->status = self::STATUS_APPROVED;
835 $this->
db->rollback();
851 if ($this->status <= self::STATUS_DRAFT) {
862 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
873 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
876 if ($this->status == self::STATUS_REFUSED) {
880 $this->status = self::STATUS_REFUSED;
881 $this->reason_decline_or_cancel = $reasondeclinenote;
883 $result = $this->
update($user);
886 $this->reason_decline_or_cancel = $reasondeclinenote;
900 public function cancel($user, $notrigger = 0)
903 if ($this->status != self::STATUS_APPROVED) {
914 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
924 public function reopen($user, $notrigger = 0)
927 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
938 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
951 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
953 global $conf, $langs, $hookmanager;
955 if (!empty($conf->dol_no_mouse_hover)) {
961 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
962 if (isset($this->status)) {
963 $label .=
' '.$this->getLibStatut(5);
966 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
968 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
970 if ($option !=
'nolink') {
972 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
973 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
974 $add_save_lastsearch_values = 1;
976 if ($add_save_lastsearch_values) {
977 $url .=
'&save_lastsearch_values=1';
982 if (empty($notooltip)) {
983 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
984 $label = $langs->trans(
"ShowPartnership");
985 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
987 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
988 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
990 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
993 if ($option ==
'nolink') {
994 $linkstart =
'<span';
996 $linkstart =
'<a href="'.$url.
'"';
998 $linkstart .= $linkclose.
'>';
999 if ($option ==
'nolink') {
1000 $linkend =
'</span>';
1005 $result .= $linkstart;
1007 if (empty($this->showphoto_on_popup)) {
1009 $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);
1013 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1015 list($class, $module) = explode(
'@', $this->picto);
1018 $filename = $filearray[0][
'name'];
1019 if (!empty($filename)) {
1020 $pospoint = strpos($filearray[0][
'name'],
'.');
1022 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1023 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
1024 $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>';
1026 $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>';
1029 $result .=
'</div>';
1031 $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);
1036 if ($withpicto != 2) {
1037 $result .= $this->ref;
1040 $result .= $linkend;
1043 global $action, $hookmanager;
1044 $hookmanager->initHooks(array(
'partnershipdao'));
1045 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1046 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1048 $result = $hookmanager->resPrint;
1050 $result .= $hookmanager->resPrint;
1064 return $this->LibStatut($this->status, $mode);
1078 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1081 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1082 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1083 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1084 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1085 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1086 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1087 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1088 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1089 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1090 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1093 $statusType =
'status'.$status;
1094 if ($status == self::STATUS_APPROVED) {
1095 $statusType =
'status4';
1097 if ($status == self::STATUS_REFUSED) {
1098 $statusType =
'status9';
1100 if ($status == self::STATUS_CANCELED) {
1101 $statusType =
'status6';
1104 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1115 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1116 $sql .=
' fk_user_creat, fk_user_modif';
1117 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1118 $sql .=
' WHERE t.rowid = '.((int) $id);
1119 $result = $this->
db->query($sql);
1121 if ($this->
db->num_rows($result)) {
1122 $obj = $this->
db->fetch_object($result);
1123 $this->
id = $obj->rowid;
1125 $this->user_creation_id = $obj->fk_user_creat;
1126 $this->user_modification_id = $obj->fk_user_modif;
1127 $this->date_creation = $this->
db->jdate($obj->datec);
1128 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
1131 $this->
db->free($result);
1145 $this->initAsSpecimenCommon();
1155 $this->lines = array();
1158 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1160 if (is_numeric($result)) {
1161 $this->error = $objectline->error;
1162 $this->errors = $objectline->errors;
1165 $this->lines = $result;
1166 return $this->lines;
1177 global $langs, $conf;
1178 $langs->load(
"partnership");
1180 if (empty($conf->global->PARTNERSHIP_ADDON)) {
1181 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1184 if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1187 $file = $conf->global->PARTNERSHIP_ADDON.
".php";
1188 $classname = $conf->global->PARTNERSHIP_ADDON;
1191 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1192 foreach ($dirmodels as $reldir) {
1196 $mybool |= @include_once $dir.$file;
1199 if ($mybool ===
false) {
1204 if (class_exists($classname)) {
1205 $obj =
new $classname();
1206 $numref = $obj->getNextValue($this);
1208 if ($numref !=
'' && $numref !=
'-1') {
1211 $this->error = $obj->error;
1216 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1220 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1236 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1238 global $conf, $langs;
1241 $includedocgeneration = 0;
1243 $langs->load(
"partnership");
1246 $modele =
'standard_partnership';
1248 if (!empty($this->model_pdf)) {
1249 $modele = $this->model_pdf;
1250 } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1251 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1255 $modelpath =
"core/modules/partnership/doc/";
1257 if ($includedocgeneration && !empty($modele)) {
1258 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1273 global $conf, $langs;
1289 $this->
db->commit();
1296 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1309 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.