26 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
39 public $module =
'partnership';
44 public $element =
'partnership';
49 public $table_element =
'partnership';
55 public $ismultientitymanaged = 0;
60 public $isextrafieldmanaged = 1;
65 public $picto =
'partnership';
68 const STATUS_DRAFT = 0;
69 const STATUS_VALIDATED = 1;
70 const STATUS_APPROVED = 2;
71 const STATUS_REFUSED = 3;
72 const STATUS_CANCELED = 9;
105 public $fields=array(
106 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
107 '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"),
108 'entity' => array(
'type' =>
'integer',
'label' =>
'Entity',
'default' => 1,
'enabled' => 1,
'visible' => -2,
'notnull' => 1,
'position' => 15,
'index' => 1),
109 'fk_type' => array(
'type' =>
'integer:PartnershipType:partnership/class/partnership_type.class.php:0:active=1',
'label' =>
'Type',
'notnull'=>1,
'enabled' => 1,
'visible' => 1,
'position' => 20),
110 'note_public' => array(
'type'=>
'html',
'label'=>
'NotePublic',
'enabled'=>
'1',
'position'=>61,
'notnull'=>0,
'visible'=>0,),
111 'note_private' => array(
'type'=>
'html',
'label'=>
'NotePrivate',
'enabled'=>
'1',
'position'=>62,
'notnull'=>0,
'visible'=>0,),
112 'date_creation' => array(
'type'=>
'datetime',
'label'=>
'DateCreation',
'enabled'=>
'1',
'position'=>500,
'notnull'=>1,
'visible'=>-2,),
113 'tms' => array(
'type'=>
'timestamp',
'label'=>
'DateModification',
'enabled'=>
'1',
'position'=>501,
'notnull'=>0,
'visible'=>-2,),
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',),
115 'fk_user_modif' => array(
'type'=>
'integer:User:user/class/user.class.php',
'label'=>
'UserModif',
'enabled'=>
'1',
'position'=>511,
'notnull'=>-1,
'visible'=>-2,),
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'=>52,
'notnull'=>1,
'visible'=>1,),
120 'date_partnership_end' => array(
'type'=>
'date',
'label'=>
'DatePartnershipEnd',
'enabled'=>
'1',
'position'=>53,
'notnull'=>0,
'visible'=>1,),
121 'status' => array(
'type'=>
'smallint',
'label'=>
'Status',
'enabled'=>
'1',
'position'=>54,
'notnull'=>1,
'visible'=>2,
'default'=>
'0',
'index'=>1,
'arrayofkeyval'=>array(
'-1'=>
'',
'0'=>
'Draft',
'1'=>
'Accepted',
'2'=>
'Refused',
'9'=>
'Terminated'),),
122 'url_to_check' => array(
'type'=>
'varchar(255)',
'label'=>
'UrlToCheck',
'enabled'=>
'1',
'position'=>70,
'notnull'=>0,
'visible'=>-1),
123 'count_last_url_check_error' => array(
'type'=>
'integer',
'label'=>
'CountLastUrlCheckError',
'enabled'=>
'1',
'position'=>71,
'notnull'=>0,
'visible'=>-2,
'default'=>
'0',),
124 'last_check_backlink' => array(
'type'=>
'datetime',
'label'=>
'LastCheckBacklink',
'enabled'=>
'1',
'position'=>72,
'notnull'=>0,
'visible'=>-2,),
125 'reason_decline_or_cancel' => array(
'type'=>
'text',
'label'=>
'ReasonDeclineOrCancel',
'enabled'=>
'1',
'position'=>73,
'notnull'=>0,
'visible'=>-2,),
140 public $fk_user_creat;
141 public $fk_user_modif;
144 public $date_partnership_start;
145 public $date_partnership_end;
146 public $count_last_url_check_error;
147 public $last_check_backlink;
152 public $reason_decline_or_cancel;
198 global $conf, $langs;
202 if (!empty($conf->global->PARTNERSHIP_IS_MANAGED_FOR) &&
getDolGlobalString(
'PARTNERSHIP_IS_MANAGED_FOR') ==
'member') {
203 $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');
205 $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');
208 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid']) && !empty($this->fields[
'ref'])) {
209 $this->fields[
'rowid'][
'visible'] = 0;
222 foreach ($this->fields as $key => $val) {
223 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
224 unset($this->fields[$key]);
229 if (is_object($langs)) {
230 foreach ($this->fields as $key => $val) {
231 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
232 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
233 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
249 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
250 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
267 global $langs, $extrafields;
272 $object =
new self($this->db);
277 $result = $object->fetchCommon($fromid);
278 if ($result > 0 && !empty($object->table_element_line)) {
279 $object->fetchLines();
288 unset($object->fk_user_creat);
289 unset($object->import_key);
292 if (property_exists($object,
'ref')) {
293 $object->ref = empty($this->fields[
'ref'][
'default']) ?
"Copy_Of_".$object->ref : $this->fields[
'ref'][
'default'];
295 if (property_exists($object,
'label')) {
296 $object->label = empty($this->fields[
'label'][
'default']) ? $langs->trans(
"CopyOf").
" ".$object->label : $this->fields[
'label'][
'default'];
298 if (property_exists($object,
'status')) {
299 $object->status = self::STATUS_DRAFT;
301 if (property_exists($object,
'date_creation')) {
302 $object->date_creation =
dol_now();
304 if (property_exists($object,
'date_modification')) {
305 $object->date_modification =
null;
309 if (is_array($object->array_options) && count($object->array_options) > 0) {
310 $extrafields->fetch_name_optionals_label($this->table_element);
311 foreach ($object->array_options as $key => $option) {
312 $shortkey = preg_replace(
'/options_/',
'', $key);
313 if (!empty($extrafields->attributes[$this->table_element][
'unique'][$shortkey])) {
316 unset($object->array_options[$key]);
322 $object->context[
'createfromclone'] =
'createfromclone';
323 $result = $object->createCommon($user);
326 $this->error = $object->error;
327 $this->errors = $object->errors;
339 if (property_exists($this,
'fk_soc') && $this->fk_soc == $object->socid) {
346 unset($object->context[
'createfromclone']);
353 $this->
db->rollback();
368 public function fetch($id, $ref =
null, $fk_member =
null, $fk_soc =
null)
373 if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
377 $sql =
'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status';
378 $sql .=
', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation';
379 $sql .=
', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif';
380 $sql .=
', p.note_private, p.note_public';
381 $sql .=
', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel';
382 $sql .=
', p.import_key, p.model_pdf';
383 $sql .=
', pt.code as type_code, pt.label as type_label';
384 $sql .=
' FROM '.MAIN_DB_PREFIX.
'partnership as p';
385 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'c_partnership_type as pt ON p.fk_type = pt.rowid';
388 $sql .=
" WHERE p.rowid=".((int) $id);
390 $sql .=
" WHERE p.entity IN (0,".getEntity(
'partnership').
")";
394 $sql .=
" AND p.ref='".$this->db->escape($ref).
"'";
397 if ($fk_member > 0) {
398 $sql .=
' AND p.fk_member = '.((int) $fk_member);
401 $sql .=
' AND p.fk_soc = '.((int) $fk_soc);
403 $sql .=
' ORDER BY p.date_partnership_end DESC';
405 dol_syslog(get_class($this).
"::fetch", LOG_DEBUG);
406 $result = $this->
db->query($sql);
408 $obj = $this->
db->fetch_object($result);
410 $this->
id = $obj->rowid;
411 $this->entity = $obj->entity;
412 $this->
ref = $obj->ref;
414 $this->fk_type = $obj->fk_type;
415 $this->type_code = $obj->type_code;
416 $this->type_label = $obj->type_label;
418 $this->fk_soc = $obj->fk_soc;
419 $this->fk_member = $obj->fk_member;
420 $this->status = $obj->status;
421 $this->date_partnership_start = $this->
db->jdate($obj->date_partnership_start);
422 $this->date_partnership_end = $this->
db->jdate($obj->date_partnership_end);
423 $this->date_creation = $this->
db->jdate($obj->date_creation);
424 $this->fk_user_creat = $obj->fk_user_creat;
425 $this->tms = $obj->tms;
426 $this->fk_user_modif = $obj->fk_user_modif;
427 $this->note_private = $obj->note_private;
428 $this->note_public = $obj->note_public;
429 $this->last_main_doc = $obj->last_main_doc;
430 $this->count_last_url_check_error = $obj->count_last_url_check_error;
431 $this->last_check_backlink = $this->
db->jdate($obj->last_check_backlink);
432 $this->reason_decline_or_cancel = $obj->reason_decline_or_cancel;
433 $this->import_key = $obj->import_key;
434 $this->model_pdf = $obj->model_pdf;
440 $this->
db->free($result);
448 $this->error = $this->
db->error();
461 $this->lines = array();
479 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
489 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
490 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
491 $sql .=
' WHERE t.entity IN ('.getEntity($this->table_element).
')';
493 $sql .=
' WHERE 1 = 1';
497 if (count($filter) > 0) {
498 foreach ($filter as $key => $value) {
499 if ($key ==
't.rowid') {
500 $sqlwhere[] = $key.
" = ".((int) $value);
501 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
502 $sqlwhere[] = $key.
" = '".$this->
db->idate($value).
"'";
503 } elseif ($key ==
'customsql') {
504 $sqlwhere[] = $value;
505 } elseif (strpos($value,
'%') ===
false) {
506 $sqlwhere[] = $key.
" IN (".$this->
db->sanitize($this->
db->escape($value)).
")";
508 $sqlwhere[] = $key.
" LIKE '%".$this->
db->escape($value).
"%'";
512 if (count($sqlwhere) > 0) {
513 $sql .=
' AND ('.implode(
' '.$this->
db->escape($filtermode).
' ', $sqlwhere).
')';
516 if (!empty($sortfield)) {
517 $sql .= $this->
db->order($sortfield, $sortorder);
519 if (!empty($limit)) {
520 $sql .= $this->
db->plimit($limit, $offset);
527 while ($i < ($limit ? min($limit, $num) : $num)) {
528 $obj = $this->
db->fetch_object(
$resql);
530 $record =
new self($this->db);
531 $record->setVarsFromFetchObj($obj);
533 $records[$record->id] = $record;
541 $this->errors[] =
'Error '.$this->db->lasterror();
542 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
557 if ($this->fk_soc <= 0 && $this->fk_member <= 0) {
558 $this->error[] =
"ErrorThirpdartyOrMemberidIsMandatory";
572 public function delete(
User $user, $notrigger =
false)
588 if ($this->status < 0) {
589 $this->error =
'ErrorDeleteLineNotAllowedByObjectStatus';
606 global $conf, $langs;
608 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
613 if ($this->status == self::STATUS_VALIDATED) {
614 dol_syslog(get_class($this).
"::validate action abandonned: already validated", LOG_WARNING);
631 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
636 $this->newref = $num;
640 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
641 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
642 $sql .=
" status = ".self::STATUS_VALIDATED;
643 if (!empty($this->fields[
'date_validation'])) {
644 $sql .=
", date_validation = '".$this->db->idate($now).
"'";
646 if (!empty($this->fields[
'fk_user_valid'])) {
647 $sql .=
", fk_user_valid = ".$user->id;
649 $sql .=
" WHERE rowid = ".((int) $this->
id);
651 dol_syslog(get_class($this).
"::validate()", LOG_DEBUG);
655 $this->error = $this->
db->lasterror();
659 if (!$error && !$notrigger) {
661 $result = $this->
call_trigger(
'PARTNERSHIP_VALIDATE', $user);
670 $this->oldref = $this->ref;
673 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
675 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->
db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'partnership/".$this->
db->escape($this->newref).
"'";
676 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
679 $error++; $this->error = $this->
db->lasterror();
685 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
686 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
687 if (!$error && file_exists($dirsource)) {
688 dol_syslog(get_class($this).
"::validate() rename dir ".$dirsource.
" into ".$dirdest);
690 if (@rename($dirsource, $dirdest)) {
693 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
694 foreach ($listoffiles as $fileentry) {
695 $dirsource = $fileentry[
'name'];
696 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
697 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
698 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
699 @rename($dirsource, $dirdest);
709 $this->status = self::STATUS_VALIDATED;
716 $this->
db->rollback();
728 public function approve($user, $notrigger = 0)
730 global $conf, $langs;
732 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
737 if ($this->status == self::STATUS_APPROVED) {
738 dol_syslog(get_class($this).
"::accept action abandonned: already acceptd", LOG_WARNING);
755 if (!$error && (preg_match(
'/^[\(]?PROV/i', $this->
ref) || empty($this->
ref))) {
760 $this->newref = $num;
764 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
765 $sql .=
" SET ref = '".$this->db->escape($num).
"',";
766 $sql .=
" status = ".self::STATUS_APPROVED;
773 $sql .=
" WHERE rowid = ".((int) $this->
id);
775 dol_syslog(get_class($this).
"::accept()", LOG_DEBUG);
779 $this->error = $this->
db->lasterror();
783 if (!$error && !$notrigger) {
785 $result = $this->
call_trigger(
'PARTNERSHIP_ACCEPT', $user);
794 $this->oldref = $this->ref;
797 if (preg_match(
'/^[\(]?PROV/i', $this->
ref)) {
799 $sql =
'UPDATE '.MAIN_DB_PREFIX.
"ecm_files set filename = CONCAT('".$this->
db->escape($this->newref).
"', SUBSTR(filename, ".(strlen($this->
ref) + 1).
")), filepath = 'partnership/".$this->
db->escape($this->newref).
"'";
800 $sql .=
" WHERE filename LIKE '".$this->db->escape($this->
ref).
"%' AND filepath = 'partnership/".$this->
db->escape($this->
ref).
"' and entity = ".$conf->entity;
803 $error++; $this->error = $this->
db->lasterror();
809 $dirsource = $conf->partnership->dir_output.
'/partnership/'.$oldref;
810 $dirdest = $conf->partnership->dir_output.
'/partnership/'.$newref;
811 if (!$error && file_exists($dirsource)) {
812 dol_syslog(get_class($this).
"::accept() rename dir ".$dirsource.
" into ".$dirdest);
814 if (@rename($dirsource, $dirdest)) {
817 $listoffiles =
dol_dir_list($conf->partnership->dir_output.
'/partnership/'.$newref,
'files', 1,
'^'.preg_quote($oldref,
'/'));
818 foreach ($listoffiles as $fileentry) {
819 $dirsource = $fileentry[
'name'];
820 $dirdest = preg_replace(
'/^'.preg_quote($oldref,
'/').
'/', $newref, $dirsource);
821 $dirsource = $fileentry[
'path'].
'/'.$dirsource;
822 $dirdest = $fileentry[
'path'].
'/'.$dirdest;
823 @rename($dirsource, $dirdest);
833 $this->status = self::STATUS_APPROVED;
840 $this->
db->rollback();
856 if ($this->status <= self::STATUS_DRAFT) {
867 return $this->
setStatusCommon($user, self::STATUS_DRAFT, $notrigger,
'PARTNERSHIP_UNVALIDATE');
878 public function refused($user, $reasondeclinenote =
'', $notrigger = 0)
881 if ($this->status == self::STATUS_REFUSED) {
885 $this->status = self::STATUS_REFUSED;
886 $this->reason_decline_or_cancel = $reasondeclinenote;
888 $result = $this->
update($user);
891 $this->reason_decline_or_cancel = $reasondeclinenote;
905 public function cancel($user, $notrigger = 0)
908 if ($this->status != self::STATUS_APPROVED) {
919 return $this->
setStatusCommon($user, self::STATUS_CANCELED, $notrigger,
'PARTNERSHIP_CANCEL');
929 public function reopen($user, $notrigger = 0)
932 if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_REFUSED) {
943 return $this->
setStatusCommon($user, self::STATUS_APPROVED, $notrigger,
'PARTNERSHIP_REOPEN');
956 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
958 global $conf, $langs, $hookmanager;
960 if (!empty($conf->dol_no_mouse_hover)) {
966 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Partnership").
'</u>';
967 if (isset($this->status)) {
968 $label .=
' '.$this->getLibStatut(5);
971 $label .=
'<b>'.$langs->trans(
'Ref').
':</b> '.$this->ref;
973 $url = DOL_URL_ROOT.
'/partnership/partnership_card.php?id='.$this->id;
975 if ($option !=
'nolink') {
977 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
978 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
979 $add_save_lastsearch_values = 1;
981 if ($add_save_lastsearch_values) {
982 $url .=
'&save_lastsearch_values=1';
987 if (empty($notooltip)) {
988 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
989 $label = $langs->trans(
"ShowPartnership");
990 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
992 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
993 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
995 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
998 if ($option ==
'nolink') {
999 $linkstart =
'<span';
1001 $linkstart =
'<a href="'.$url.
'"';
1003 $linkstart .= $linkclose.
'>';
1004 if ($option ==
'nolink') {
1005 $linkend =
'</span>';
1010 $result .= $linkstart;
1012 if (empty($this->showphoto_on_popup)) {
1014 $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);
1018 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
1020 list($class, $module) = explode(
'@', $this->picto);
1023 $filename = $filearray[0][
'name'];
1024 if (!empty($filename)) {
1025 $pospoint = strpos($filearray[0][
'name'],
'.');
1027 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
1028 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
1029 $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>';
1031 $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>';
1034 $result .=
'</div>';
1036 $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);
1041 if ($withpicto != 2) {
1042 $result .= $this->ref;
1045 $result .= $linkend;
1048 global $action, $hookmanager;
1049 $hookmanager->initHooks(array(
'partnershipdao'));
1050 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1051 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1053 $result = $hookmanager->resPrint;
1055 $result .= $hookmanager->resPrint;
1069 return $this->LibStatut($this->status, $mode);
1083 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
1086 $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1087 $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1088 $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1089 $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1090 $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1091 $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv(
'Draft');
1092 $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv(
'Validated');
1093 $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv(
'Approved');
1094 $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv(
'Refused');
1095 $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv(
'Terminated');
1098 $statusType =
'status'.$status;
1099 if ($status == self::STATUS_APPROVED) {
1100 $statusType =
'status4';
1102 if ($status == self::STATUS_REFUSED) {
1103 $statusType =
'status9';
1105 if ($status == self::STATUS_CANCELED) {
1106 $statusType =
'status6';
1109 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status],
'', $statusType, $mode);
1120 $sql =
'SELECT rowid, date_creation as datec, tms as datem,';
1121 $sql .=
' fk_user_creat, fk_user_modif';
1122 $sql .=
' FROM '.MAIN_DB_PREFIX.$this->table_element.
' as t';
1123 $sql .=
' WHERE t.rowid = '.((int) $id);
1124 $result = $this->
db->query($sql);
1126 if ($this->
db->num_rows($result)) {
1127 $obj = $this->
db->fetch_object($result);
1128 $this->
id = $obj->rowid;
1130 $this->user_creation_id = $obj->fk_user_creat;
1131 $this->user_modification_id = $obj->fk_user_modif;
1132 $this->date_creation = $this->
db->jdate($obj->datec);
1133 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
1136 $this->
db->free($result);
1150 $this->initAsSpecimenCommon();
1160 $this->lines = array();
1163 $result = $objectline->fetchAll(
'ASC',
'position', 0, 0, array(
'customsql'=>
'fk_partnership = '.((
int) $this->
id)));
1165 if (is_numeric($result)) {
1166 $this->error = $this->error;
1167 $this->errors = $this->errors;
1170 $this->lines = $result;
1171 return $this->lines;
1182 global $langs, $conf;
1183 $langs->load(
"partnership");
1185 if (empty($conf->global->PARTNERSHIP_ADDON)) {
1186 $conf->global->PARTNERSHIP_ADDON =
'mod_partnership_standard';
1189 if (!empty($conf->global->PARTNERSHIP_ADDON)) {
1192 $file = $conf->global->PARTNERSHIP_ADDON.
".php";
1193 $classname = $conf->global->PARTNERSHIP_ADDON;
1196 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1197 foreach ($dirmodels as $reldir) {
1201 $mybool |= @include_once $dir.$file;
1204 if ($mybool ===
false) {
1209 if (class_exists($classname)) {
1210 $obj =
new $classname();
1211 $numref = $obj->getNextValue($this);
1213 if ($numref !=
'' && $numref !=
'-1') {
1216 $this->error = $obj->error;
1221 print $langs->trans(
"Error").
" ".$langs->trans(
"ClassNotFound").
' '.$classname;
1225 print $langs->trans(
"ErrorNumberingModuleNotSetup", $this->element);
1241 public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams =
null)
1243 global $conf, $langs;
1246 $includedocgeneration = 0;
1248 $langs->load(
"partnership");
1251 $modele =
'standard_partnership';
1253 if (!empty($this->model_pdf)) {
1254 $modele = $this->model_pdf;
1255 } elseif (!empty($conf->global->PARTNERSHIP_ADDON_PDF)) {
1256 $modele = $conf->global->PARTNERSHIP_ADDON_PDF;
1260 $modelpath =
"core/modules/partnership/doc/";
1262 if ($includedocgeneration && !empty($modele)) {
1263 $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);
1278 global $conf, $langs;
1294 $this->
db->commit();
1301 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobjectline.class.php';
1314 public $isextrafieldmanaged = 0;