29 require_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;
70 'rowid' =>array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>10),
71 'entity' =>array(
'type'=>
'integer',
'label'=>
'Entity',
'default'=>1,
'enabled'=>1,
'visible'=>-2,
'notnull'=>1,
'position'=>15,
'index'=>1),
72 'code' =>array(
'type'=>
'varchar(32)',
'label'=>
'Code',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>20),
73 'label' =>array(
'type'=>
'varchar(64)',
'label'=>
'Label',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>25,
'showoncombobox'=>1),
74 'active' =>array(
'type'=>
'integer',
'label'=>
'Active',
'enabled'=>1,
'visible'=>-1,
'notnull'=>1,
'position'=>30),
90 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
91 $this->fields[
'rowid'][
'visible'] = 0;
93 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
94 $this->fields[
'entity'][
'enabled'] = 0;
104 foreach ($this->fields as $key => $val) {
105 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
106 unset($this->fields[$key]);
111 if (is_object($langs)) {
112 foreach ($this->fields as $key => $val) {
113 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
114 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
115 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
132 return $resultcreate;
142 public function fetch($id, $ref =
null)
159 public function fetchAll($sortorder =
'', $sortfield =
'', $limit = 0, $offset = 0, array $filter = array(), $filtermode =
'AND')
169 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
170 if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
171 $sql .=
" WHERE t.entity IN (".getEntity($this->table_element).
")";
173 $sql .=
" WHERE 1 = 1";
177 if (count($filter) > 0) {
178 foreach ($filter as $key => $value) {
179 if ($key ==
't.rowid') {
180 $sqlwhere[] = $key.
" = ".((int) $value);
181 } elseif (in_array($this->fields[$key][
'type'], array(
'date',
'datetime',
'timestamp'))) {
182 $sqlwhere[] = $key.
" = '".$this->
db->idate($value).
"'";
183 } elseif ($key ==
'customsql') {
184 $sqlwhere[] = $value;
185 } elseif (strpos($value,
'%') ===
false) {
186 $sqlwhere[] = $key.
" IN (".$this->
db->sanitize($this->
db->escape($value)).
")";
188 $sqlwhere[] = $key.
" LIKE '%".$this->
db->escape($value).
"%'";
192 if (count($sqlwhere) > 0) {
193 $sql .=
" AND (".implode(
" ".$filtermode.
" ", $sqlwhere).
")";
196 if (!empty($sortfield)) {
197 $sql .= $this->
db->order($sortfield, $sortorder);
199 if (!empty($limit)) {
200 $sql .= $this->
db->plimit($limit, $offset);
207 while ($i < ($limit ? min($limit, $num) : $num)) {
208 $obj = $this->
db->fetch_object(
$resql);
210 $record =
new self($this->db);
211 $record->setVarsFromFetchObj($obj);
213 $records[$record->id] = $record;
221 $this->errors[] =
'Error '.$this->db->lasterror();
222 dol_syslog(__METHOD__.
' '.join(
',', $this->errors), LOG_ERR);
247 public function delete(
User $user, $notrigger =
false)
262 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
264 global $conf, $langs, $hookmanager;
266 if (!empty($conf->dol_no_mouse_hover)) {
272 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"PartnershipType").
'</u>';
273 if (isset($this->status)) {
274 $label .=
' '.$this->getLibStatut(5);
277 $label .=
'<b>'.$langs->trans(
'Code').
':</b> '.$this->code;
278 $label .=
'<br><b>'.$langs->trans(
'Label').
':</b> '.$this->label;
283 if ($option !=
'nolink') {
285 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
286 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
287 $add_save_lastsearch_values = 1;
289 if ($url && $add_save_lastsearch_values) {
290 $url .=
'&save_lastsearch_values=1';
295 if (empty($notooltip)) {
296 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
297 $label = $langs->trans(
"ShowMyObject");
298 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
300 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
301 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
303 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
306 if ($option ==
'nolink' || empty($url)) {
307 $linkstart =
'<span';
309 $linkstart =
'<a href="'.$url.
'"';
311 $linkstart .= $linkclose.
'>';
312 if ($option ==
'nolink' || empty($url)) {
313 $linkend =
'</span>';
318 $result .= $linkstart;
320 if (empty($this->showphoto_on_popup)) {
322 $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);
326 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
328 list($class, $module) = explode(
'@', $this->picto);
331 $filename = $filearray[0][
'name'];
332 if (!empty($filename)) {
333 $pospoint = strpos($filearray[0][
'name'],
'.');
335 $pathtophoto = $class.
'/'.$this->
ref.
'/thumbs/'.substr($filename, 0, $pospoint).
'_mini'.substr($filename, $pospoint);
336 if (empty($conf->global->{strtoupper($module.
'_'.$class).
'_FORMATLISTPHOTOSASUSERS'})) {
337 $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>';
339 $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>';
344 $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);
349 if ($withpicto != 2) {
350 $result .= $this->ref;
356 global $action, $hookmanager;
357 $hookmanager->initHooks(array(
'myobjectdao'));
358 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
359 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
361 $result = $hookmanager->resPrint;
363 $result .= $hookmanager->resPrint;
377 $sql =
"SELECT rowid, date_creation as datec, tms as datem,";
378 $sql .=
" fk_user_creat, fk_user_modif";
379 $sql .=
" FROM ".MAIN_DB_PREFIX.$this->table_element.
" as t";
380 $sql .=
" WHERE t.rowid = ".((int) $id);
382 $result = $this->
db->query($sql);
384 if ($this->
db->num_rows($result)) {
385 $obj = $this->
db->fetch_object($result);
386 $this->
id = $obj->rowid;
388 $this->user_creation_id = $obj->fk_user_creat;
389 $this->user_modification_id = $obj->fk_user_modif;
390 $this->date_creation = $this->
db->jdate($obj->datec);
391 $this->date_modification = empty($obj->datem) ?
'' : $this->
db->jdate($obj->datem);
394 $this->
db->free($result);
412 $this->initAsSpecimenCommon();
Parent class of all other business classes (invoices, contracts, proposals, orders,...
getFieldList($alias='')
Function to concat keys of fields.
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.
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.
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)
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.