29require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
40 public $table_element =
'c_partnership_type';
45 public $element =
'partnership_type';
50 public $picto =
'generic';
56 public $ismultientitymanaged = 1;
72 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
73 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>15,
'index'=>1),
74 'code' =>array(
'type'=>
'varchar(32)',
'label'=>
'Code',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>20),
75 'label' =>array(
'type'=>
'varchar(64)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>25,
'showoncombobox'=>1),
76 'active' =>array(
'type'=>
'integer',
'label'=>
'Active',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>30),
92 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
93 $this->fields[
'rowid'][
'visible'] = 0;
95 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
96 $this->fields[
'entity'][
'enabled'] = 0;
106 foreach ($this->fields as $key => $val) {
107 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
108 unset($this->fields[$key]);
113 if (is_object($langs)) {
114 foreach ($this->fields as $key => $val) {
115 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
116 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
117 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
134 return $resultcreate;
144 public function fetch($id, $ref =
null)
161 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
171 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
172 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
173 $sql .=
" WHERE t.entity IN (".getEntity($this->element).
")";
175 $sql .=
" WHERE 1 = 1";
179 if (count($filter) > 0) {
180 foreach ($filter as $key => $value) {
181 if ($key ==
't.rowid') {
182 $sqlwhere[] = $key.
" = ".((int) $value);
183 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
184 $sqlwhere[] = $key.
" = '".$this->db->idate($value).
"'";
185 } elseif ($key ==
'customsql') {
186 $sqlwhere[] = $value;
187 } elseif (strpos($value,
'%') ===
false) {
188 $sqlwhere[] = $key.
" IN (".$this->db->sanitize($this->db->escape($value)).
")";
190 $sqlwhere[] = $key.
" LIKE '%".$this->db->escape($value).
"%'";
194 if (count($sqlwhere) > 0) {
195 $sql .=
" AND (".implode(
" ".$filtermode.
" ", $sqlwhere).
")";
198 if (!empty($sortfield)) {
199 $sql .= $this->db->order($sortfield, $sortorder);
201 if (!empty($limit)) {
202 $sql .= $this->db->plimit($limit, $offset);
205 $resql = $this->db->query($sql);
207 $num = $this->db->num_rows($resql);
209 while ($i < ($limit ? min($limit, $num) : $num)) {
210 $obj = $this->db->fetch_object($resql);
212 $record =
new self($this->db);
213 $record->setVarsFromFetchObj($obj);
215 $records[$record->id] = $record;
219 $this->db->free($resql);
223 $this->errors[] =
'Error '.$this->db->lasterror();
224 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
249 public function delete(
User $user, $notrigger =
false)
264 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
266 global $conf, $langs, $hookmanager;
268 if (!empty($conf->dol_no_mouse_hover)) {
274 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"PartnershipType").
'</u>';
275 if (isset($this->status)) {
276 $label .=
' '.$this->getLibStatut(5);
279 $label .=
'<b>'.$langs->trans(
'Code').
':</b> '.$this->code;
280 $label .=
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
285 if ($option !=
'nolink') {
287 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
288 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
289 $add_save_lastsearch_values = 1;
291 if ($url && $add_save_lastsearch_values) {
292 $url .=
'&save_lastsearch_values=1';
297 if (empty($notooltip)) {
298 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
299 $label = $langs->trans(
"ShowMyObject");
300 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
302 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
303 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
305 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
308 if ($option ==
'nolink' || empty($url)) {
309 $linkstart =
'<span';
311 $linkstart =
'<a href="'.$url.
'"';
313 $linkstart .= $linkclose.
'>';
314 if ($option ==
'nolink' || empty($url)) {
315 $linkend =
'</span>';
320 $result .= $linkstart;
322 if (empty($this->showphoto_on_popup)) {
324 $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);
328 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
330 list($class, $module) = explode(
'@', $this->picto);
333 $filename = $filearray[0][
'name'];
334 if (!empty($filename)) {
335 $pospoint = strpos($filearray[0][
'name'],
'.');
337 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
338 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
339 $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>';
341 $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>';
346 $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);
351 if ($withpicto != 2) {
352 $result .= $this->ref;
358 global $action, $hookmanager;
359 $hookmanager->initHooks(array(
'myobjectdao'));
360 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
361 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
363 $result = $hookmanager->resPrint;
365 $result .= $hookmanager->resPrint;
379 $sql =
"SELECT rowid, date_creation as datec, tms as datem,";
380 $sql .=
" fk_user_creat, fk_user_modif";
381 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
382 $sql .=
" WHERE t.rowid = ".((int) $id);
384 $result = $this->db->query($sql);
386 if ($this->db->num_rows($result)) {
387 $obj = $this->db->fetch_object($result);
388 $this->
id = $obj->rowid;
390 $this->user_creation_id = $obj->fk_user_creat;
391 $this->user_modification_id = $obj->fk_user_modif;
392 $this->date_creation = $this->db->jdate($obj->datec);
393 $this->date_modification = empty($obj->datem) ?
'' : $this->db->jdate($obj->datem);
396 $this->db->free($result);
414 $this->initAsSpecimenCommon();
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetchCommon($id, $ref=null, $morewhere='')
Load object in memory from the database.
createCommon(User $user, $notrigger=false)
Create object into database.
deleteCommon(User $user, $notrigger=false, $forcechilddeletion=0)
Delete object in database.
getFieldList($alias='', $excludefields=array())
Function to concat keys of fields.
updateCommon(User $user, $notrigger=false)
Update object into database.
Class to manage Dolibarr database access.
Class to manage partnership type.
initAsSpecimen()
Initialise object with example values Id must be 0 if object instance is a specimen.
__construct(DoliDB $db)
Constructor.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
fetch($id, $ref=null)
Load object in memory from the database.
update(User $user, $notrigger=false)
Update object into database.
info($id)
Load the info information in the object.
create(User $user, $notrigger=false)
Create object into database.
fetchAll($sortorder='', $sortfield='', $limit=0, $offset=0, array $filter=array(), $filtermode='AND')
Load list of objects in memory from the database.
Class to manage Dolibarr users.
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)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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.