19 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
34 public $module =
'variants';
39 public $element =
'productattribute';
44 public $table_element =
'product_attribute';
49 public $table_element_line =
'product_attribute_value';
54 public $fk_element =
'fk_product_attribute';
60 public $ismultientitymanaged = 1;
65 public $isextrafieldmanaged = 0;
70 public $picto =
'product';
100 public $fields=array(
101 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
102 'ref' => array(
'type'=>
'varchar(255)',
'label'=>
'Ref',
'visible'=>1,
'enabled'=>1,
'position'=>10,
'notnull'=>1,
'index'=>1,
'searchall'=>1,
'comment'=>
"Reference of object",
'css'=>
''),
103 'ref_ext' => array(
'type' =>
'varchar(255)',
'label' =>
'ExternalRef',
'enabled' => 1,
'visible' => 0,
'position' => 20,
'searchall'=>1),
104 'label' => array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>
'1',
'position'=>30,
'notnull'=>1,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'help'=>
"",
'showoncombobox'=>
'1',),
105 'position' => array(
'type'=>
'integer',
'label'=>
'Rank',
'enabled'=>1,
'visible'=>0,
'default'=>0,
'position'=>40,
'notnull'=>1,),
116 public $lines = array();
125 public $is_used_by_products;
135 global $conf, $langs;
138 $this->entity = $conf->entity;
140 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
141 $this->fields[
'rowid'][
'visible'] = 0;
143 if (!
isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
144 $this->fields[
'entity'][
'enabled'] = 0;
148 foreach ($this->fields as $key => $val) {
149 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
150 unset($this->fields[$key]);
155 if (is_object($langs)) {
156 foreach ($this->fields as $key => $val) {
157 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
158 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
159 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
180 $this->label = trim($this->label);
181 $this->position = $this->position > 0 ? $this->position : 0;
184 if (empty($this->position)) {
186 $this->position = $positionmax + 1;
190 if (empty($this->
ref)) {
191 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
194 if (empty($this->label)) {
195 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
205 $sql =
"INSERT INTO " . MAIN_DB_PREFIX . $this->table_element .
" (";
206 $sql .=
" ref, ref_ext, label, entity, position";
209 $sql .=
" '" . $this->
db->escape($this->
ref) .
"'";
210 $sql .=
", '" . $this->
db->escape($this->ref_ext) .
"'";
211 $sql .=
", '" . $this->
db->escape($this->label) .
"'";
212 $sql .=
", " . ((int) $this->entity);
213 $sql .=
", " . ((int) $this->position);
219 $this->errors[] =
"Error " . $this->
db->lasterror();
224 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
227 if (!$error && !$notrigger) {
229 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_CREATE', $user);
240 $this->
db->rollback();
257 $id = $id > 0 ? $id : 0;
261 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
269 $sql =
"SELECT rowid, ref, ref_ext, label, position";
270 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
271 $sql .=
" WHERE rowid = " . ((int) $id);
272 $sql .=
" AND entity IN (" .
getEntity(
'product') .
")";
277 $this->errors[] =
"Error " . $this->
db->lasterror();
282 $numrows = $this->
db->num_rows(
$resql);
284 $obj = $this->
db->fetch_object(
$resql);
286 $this->
id = $obj->rowid;
287 $this->
ref = $obj->ref;
288 $this->ref_ext = $obj->ref_ext;
289 $this->label = $obj->label;
290 $this->rang = $obj->position;
291 $this->position = $obj->position;
307 $sql =
"SELECT rowid, ref, ref_ext, label, position";
308 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
309 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
310 $sql .= $this->
db->order(
"position",
"asc");
315 $this->errors[] =
"Error " . $this->
db->lasterror();
320 while ($obj = $this->
db->fetch_object(
$resql)) {
323 $tmp->id = $obj->rowid;
324 $tmp->ref = $obj->ref;
325 $tmp->ref_ext = $obj->ref_ext;
326 $tmp->label = $obj->label;
327 $tmp->rang = $obj->position;
328 $tmp->position = $obj->position;
349 $this->
id = $this->
id > 0 ? $this->id : 0;
351 $this->label = trim($this->label);
354 if (empty($this->
id)) {
355 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
358 if (empty($this->
ref)) {
359 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
362 if (empty($this->label)) {
363 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
373 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET";
375 $sql .=
" ref = '" . $this->
db->escape($this->
ref) .
"'";
376 $sql .=
", ref_ext = '" . $this->
db->escape($this->ref_ext) .
"'";
377 $sql .=
", label = '" . $this->
db->escape($this->label) .
"'";
378 $sql .=
", position = " . ((int) $this->position);
380 $sql .=
" WHERE rowid = " . ((int) $this->
id);
385 $this->errors[] =
"Error " . $this->
db->lasterror();
389 if (!$error && !$notrigger) {
391 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_MODIFY', $user);
402 $this->
db->rollback();
414 public function delete(
User $user, $notrigger = 0)
420 $this->
id = $this->
id > 0 ? $this->id : 0;
423 if (empty($this->
id)) {
424 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
432 $result = $this->
isUsed();
435 } elseif ($result > 0) {
436 $this->errors[] = $langs->trans(
'ErrorAttributeIsUsedIntoProduct');
444 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_DELETE', $user);
453 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line;
454 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
456 dol_syslog(__METHOD__ .
' - Delete values', LOG_DEBUG);
459 $this->errors[] =
"Error " . $this->
db->lasterror();
465 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element;
466 $sql .=
" WHERE rowid = " . ((int) $this->
id);
468 dol_syslog(__METHOD__ .
' - Delete attribute', LOG_DEBUG);
471 $this->errors[] =
"Error " . $this->
db->lasterror();
480 $this->
db->rollback();
497 $this->lines = array();
502 $this->
id = $this->
id > 0 ? $this->id : 0;
505 if (empty($this->
id)) {
506 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
514 $sql =
"SELECT td.rowid, td.fk_product_attribute, td.ref, td.value, td.position";
515 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line .
" AS td";
516 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX . $this->table_element .
" AS t ON t.rowid = td." . $this->fk_element;
517 $sql .=
" WHERE t.rowid = " . ((int) $this->
id);
518 $sql .=
" AND t.entity IN (" .
getEntity(
'product') .
")";
522 $sql .= $this->
db->order(
"td.position",
"asc");
527 $this->errors[] =
"Error " . $this->
db->lasterror();
536 $obj = $this->
db->fetch_object(
$resql);
540 $line->id = $obj->rowid;
541 $line->fk_product_attribute = $obj->fk_product_attribute;
542 $line->ref = $obj->ref;
543 $line->value = $obj->value;
544 $line->position = $obj->position;
546 $this->lines[$i] = $line;
579 public function addLine($ref, $value, $position = -1, $notrigger = 0)
581 global $langs, $user;
582 dol_syslog(__METHOD__ .
" id={$this->id}, ref=$ref, value=$value, notrigger=$notrigger");
586 $this->
id = $this->
id > 0 ? $this->id : 0;
589 if (empty($this->
id)) {
590 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
604 $positiontouse = $position;
605 if ($positiontouse == -1) {
607 $positiontouse = $positionmax + 1;
610 $this->line->context = $this->context;
611 $this->line->fk_product_attribute = $this->id;
612 $this->line->ref = $ref;
613 $this->line->value = $value;
614 $this->line->position = $positiontouse;
616 $result = $this->line->create($user, $notrigger);
619 $this->error = $this->line->error;
620 $this->errors = $this->line->errors;
621 $this->
db->rollback();
625 return $this->line->id;
639 public function updateLine($lineid, $ref, $value, $notrigger = 0)
643 dol_syslog(__METHOD__ .
" lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger");
646 $lineid = $lineid > 0 ? $lineid : 0;
652 $result = $this->line->fetch($lineid);
654 $this->line->oldcopy = clone $this->line;
656 $this->line->context = $this->context;
657 $this->line->ref = $ref;
658 $this->line->value = $value;
660 $result = $this->line->update($user, $notrigger);
664 $this->error = $this->line->error;
665 $this->errors = $this->line->errors;
666 $this->
db->rollback();
684 dol_syslog(__METHOD__ .
" lineid=$lineid, notrigger=$notrigger");
687 $lineid = $lineid > 0 ? $lineid : 0;
693 $result = $this->line->fetch($lineid);
695 $this->line->context = $this->context;
697 $result = $this->line->delete($user, $notrigger);
701 $this->error = $this->line->error;
702 $this->errors = $this->line->errors;
703 $this->
db->rollback();
723 $this->
id = $this->
id > 0 ? $this->id : 0;
726 if (empty($this->
id)) {
727 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
735 $sql =
"SELECT COUNT(*) AS count";
736 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line;
737 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
742 $this->errors[] =
"Error " . $this->
db->lasterror();
747 if ($obj = $this->
db->fetch_object(
$resql)) {
748 $count = $obj->count;
766 $this->
id = $this->
id > 0 ? $this->id : 0;
769 if (empty($this->
id)) {
770 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
778 $sql =
"SELECT COUNT(*) AS count";
779 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val AS pac2v";
780 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid";
781 $sql .=
" WHERE pac2v.fk_prod_attr = " . ((int) $this->
id);
782 $sql .=
" AND pac.entity IN (" .
getEntity(
'product') .
")";
787 $this->errors[] =
"Error " . $this->
db->lasterror();
792 if ($obj = $this->
db->fetch_object(
$resql)) {
793 $count = $obj->count;
810 $this->
id = $this->
id > 0 ? $this->id : 0;
813 if (empty($this->
id)) {
814 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
822 $sql =
"SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->
id);
827 $this->errors[] =
"Error " . $this->
db->lasterror();
832 if ($obj = $this->
db->fetch_object(
$resql)) {
836 return $used ? 1 : 0;
851 $sql =
"SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element;
852 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
854 $sql .=
" AND position = 0";
856 $sql .=
" AND position <> 0";
862 $row = $this->
db->fetch_row(
$resql);
872 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX . $this->table_element;
873 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
874 $sql .=
" ORDER BY position ASC, rowid " . $rowidorder;
876 dol_syslog(__METHOD__ .
" search all attributes", LOG_DEBUG);
882 $row = $this->
db->fetch_row(
$resql);
889 foreach ($rows as $key => $row) {
911 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
912 $sql .=
" WHERE rowid = " . ((int) $rowid);
915 if (!$this->
db->query($sql)) {
919 $parameters = array(
'rowid' => $rowid,
'position' => $position);
921 $reshook = $hookmanager->executeHooks(
'afterPositionOfAttributeUpdate', $parameters, $this, $action);
934 $sql =
"SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element;
935 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
940 $row = $this->
db->fetch_row(
$resql);
994 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
995 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
996 $sql .=
" AND position = " . ((int) ($position - 1));
997 if ($this->
db->query($sql)) {
998 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position - 1));
999 $sql .=
" WHERE rowid = " . ((int) $rowid);
1000 if (!$this->
db->query($sql)) {
1019 if ($position < $max) {
1020 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1021 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1022 $sql .=
" AND position = " . ((int) ($position + 1));
1023 if ($this->
db->query($sql)) {
1024 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position + 1));
1025 $sql .=
" WHERE rowid = " . ((int) $rowid);
1026 if (!$this->
db->query($sql)) {
1043 $sql =
"SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element;
1044 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1049 $row = $this->
db->fetch_row(
$resql);
1064 $num = count($rows);
1065 for ($i = 0; $i < $num; $i++) {
1080 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1082 global $conf, $langs, $hookmanager;
1084 if (!empty($conf->dol_no_mouse_hover)) {
1090 $label =
img_picto(
'', $this->picto) .
' <u>' . $langs->trans(
"ProductAttribute") .
'</u>';
1091 if (isset($this->status)) {
1095 $label .=
'<b>' . $langs->trans(
'Ref') .
':</b> ' . $this->ref;
1096 if (!empty($this->label)) {
1097 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $this->label;
1100 $url =
dol_buildpath(
'/variants/card.php', 1) .
'?id=' . $this->id;
1102 if ($option !=
'nolink') {
1104 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1105 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1106 $add_save_lastsearch_values = 1;
1108 if ($url && $add_save_lastsearch_values) {
1109 $url .=
'&save_lastsearch_values=1';
1114 if (empty($notooltip)) {
1115 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1116 $label = $langs->trans(
"ShowProductAttribute");
1120 $linkclose .=
' class="classfortooltip' . ($morecss ?
' ' . $morecss :
'') .
'"';
1122 $linkclose = ($morecss ?
' class="' . $morecss .
'"' :
'');
1125 if ($option ==
'nolink' || empty($url)) {
1126 $linkstart =
'<span';
1128 $linkstart =
'<a href="' . $url .
'"';
1130 $linkstart .= $linkclose .
'>';
1131 if ($option ==
'nolink' || empty($url)) {
1132 $linkend =
'</span>';
1137 $result .= $linkstart;
1139 if (empty($this->showphoto_on_popup)) {
1141 $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);
1145 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
1147 list($class, $module) = explode(
'@', $this->picto);
1150 $filename = $filearray[0][
'name'];
1151 if (!empty($filename)) {
1152 $pospoint = strpos($filearray[0][
'name'],
'.');
1154 $pathtophoto = $class .
'/' . $this->
ref .
'/thumbs/' . substr($filename, 0, $pospoint) .
'_mini' . substr($filename, $pospoint);
1155 if (empty($conf->global->{strtoupper($module .
'_' . $class) .
'_FORMATLISTPHOTOSASUSERS'})) {
1156 $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>';
1158 $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>';
1161 $result .=
'</div>';
1163 $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);
1168 if ($withpicto != 2) {
1169 $result .= $this->ref;
1172 $result .= $linkend;
1175 global $action, $hookmanager;
1176 $hookmanager->initHooks(array(
'variantsdao'));
1177 $parameters = array(
'id' => $this->
id,
'getnomurl' => $result);
1178 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1180 $result = $hookmanager->resPrint;
1182 $result .= $hookmanager->resPrint;
1196 return $this->LibStatut(0, $mode);
1207 return $this->LibStatut(0, $mode);
1241 global $conf, $user, $langs, $object, $hookmanager;
1247 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1248 foreach ($dirtpls as $module => $reldir) {
1249 if (!empty($module)) {
1250 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_create.tpl.php');
1252 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_create.tpl.php';
1255 if (empty($conf->file->strict_mode)) {
1256 $res = @include $tpl;
1258 $res = include $tpl;
1283 public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir =
'/variants/tpl', $addcreateline = 0)
1285 global $conf, $hookmanager, $langs, $user,
$form, $object;
1288 global $disableedit, $disablemove, $disableremove;
1290 $num = count($this->lines);
1292 $parameters = array(
'num' => $num,
'selected' => $selected,
'table_element_line' => $this->table_element_line);
1293 $reshook = $hookmanager->executeHooks(
'printObjectLineTitle', $parameters, $this, $action);
1294 if (empty($reshook)) {
1298 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1299 foreach ($dirtpls as $module => $reldir) {
1300 if (!empty($module)) {
1301 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_title.tpl.php');
1303 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_title.tpl.php';
1305 if (empty($conf->file->strict_mode)) {
1306 $res = @include $tpl;
1308 $res = include $tpl;
1317 if ($addcreateline) {
1319 if ($action !=
'selectlines') {
1320 if ($action !=
'editline') {
1323 $parameters = array();
1324 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1325 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1326 if (empty($reshook))
1327 $object->formAddObjectLine(1, $mysoc, $buyer);
1334 print
"<!-- begin printObjectLines() -->\n";
1335 foreach ($this->lines as $line) {
1336 if (is_object($hookmanager)) {
1337 $parameters = array(
'line' => $line,
'num' => $num,
'i' => $i,
'selected' => $selected,
'table_element_line' => $line->table_element);
1338 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $this, $action);
1340 if (empty($reshook)) {
1341 $this->printObjectLine($action, $line,
'', $num, $i, $dateSelector, $seller, $buyer, $selected,
null, $defaulttpldir);
1346 print
"<!-- end printObjectLines() -->\n";
1366 public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields =
null, $defaulttpldir =
'/variants/tpl')
1368 global $conf, $langs, $user, $object, $hookmanager;
1370 global $object_rights, $disableedit, $disablemove, $disableremove;
1372 $object_rights = $user->rights->variants;
1375 if ($action !=
'editline' || $selected != $line->id) {
1379 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1380 foreach ($dirtpls as $module => $reldir) {
1381 if (!empty($module)) {
1382 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_view.tpl.php');
1384 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_view.tpl.php';
1387 if (empty($conf->file->strict_mode)) {
1388 $res = @include $tpl;
1390 $res = include $tpl;
1399 if ($action ==
'editline' && $selected == $line->id) {
1403 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1404 foreach ($dirtpls as $module => $reldir) {
1405 if (!empty($module)) {
1406 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_edit.tpl.php');
1408 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_edit.tpl.php';
1411 if (empty($conf->file->strict_mode)) {
1412 $res = @include $tpl;
1414 $res = include $tpl;
Parent class of all other business classes (invoices, contracts, proposals, orders,...
errorsToString()
Method to output saved errors.
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage Dolibarr database access.
Class ProductAttribute Used to represent a product attribute.
updateAttributePositionDown($rowid, $position, $max)
Update position of attribute (down)
updatePositionOfAttribute($rowid, $position)
Update position of line (rang)
addLine($ref, $value, $position=-1, $notrigger=0)
attributeMoveDown($rowid)
Update a attribute to have a lower position.
fetch($id)
Fetches the properties of a product attribute.
update(User $user, $notrigger=0)
Updates a product attribute.
attributeOrder($renum=false, $rowidorder='ASC')
Save a new position (field position) for details lines.
fetchAll()
Returns an array of all product variants.
updateAttributePositionUp($rowid, $position)
Update position of attribute (up)
isUsed()
Test if used by a product.
updateLine($lineid, $ref, $value, $notrigger=0)
Update a line.
__construct(DoliDB $db)
Constructor.
getMaxAttributesPosition()
Get max value used for position of attributes.
LibStatut($status, $mode=1)
Return label of a status.
attributesAjaxOrder($rows)
Update position of attributes with ajax.
getLinesArray($filters='')
Retrieve an array of proposal lines.
fetch_lines($filters='')
Load array lines.
attributeMoveUp($rowid)
Update a attribute to have a higher position.
create(User $user, $notrigger=0)
Creates a product attribute.
countChildProducts()
Returns the number of products that are using this attribute.
deleteLine(User $user, $lineid, $notrigger=0)
Delete a line.
formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir='/variants/tpl')
Show add free and predefined products/services form.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
getLibStatut($mode=0)
Return label of status of product attribute.
getPositionOfAttribute($rowid)
Get position of attribute.
printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected=0, $extrafields=null, $defaulttpldir='/variants/tpl')
Return HTML content of a detail line TODO Move this into an output class file (htmlline....
printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $defaulttpldir='/variants/tpl', $addcreateline=0)
Return HTML table for object lines TODO Move this into an output class file (htmlline....
getLabelStatus($mode=0)
Return the label of the status.
countChildValues()
Returns the number of values for this attribute.
Class ProductAttributeValue Used to represent a product attribute value.
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.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db
API class for accounts.