20require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
35 public $module =
'variants';
40 public $element =
'productattribute';
45 public $table_element =
'product_attribute';
50 public $table_element_line =
'product_attribute_value';
55 public $fk_element =
'fk_product_attribute';
61 public $ismultientitymanaged = 1;
66 public $isextrafieldmanaged = 0;
71 public $picto =
'product';
101 public $fields=array(
102 'rowid' => array(
'type'=>
'integer',
'label'=>
'TechnicalID',
'enabled'=>
'1',
'position'=>1,
'notnull'=>1,
'visible'=>0,
'noteditable'=>
'1',
'index'=>1,
'css'=>
'left',
'comment'=>
"Id"),
103 'ref' => array(
'type'=>
'varchar(255)',
'label'=>
'Ref',
'visible'=>1,
'enabled'=>1,
'position'=>10,
'notnull'=>1,
'index'=>1,
'searchall'=>1,
'comment'=>
"Reference of object",
'css'=>
''),
104 'ref_ext' => array(
'type' =>
'varchar(255)',
'label' =>
'ExternalRef',
'enabled' => 1,
'visible' => 0,
'position' => 20,
'searchall'=>1),
105 'label' => array(
'type'=>
'varchar(255)',
'label'=>
'Label',
'enabled'=>
'1',
'position'=>30,
'notnull'=>1,
'visible'=>1,
'searchall'=>1,
'css'=>
'minwidth300',
'help'=>
"",
'showoncombobox'=>
'1',),
106 'position' => array(
'type'=>
'integer',
'label'=>
'Rank',
'enabled'=>1,
'visible'=>0,
'default'=>0,
'position'=>40,
'notnull'=>1,),
144 public $lines = array();
153 public $is_used_by_products;
163 global $conf, $langs;
166 $this->entity = $conf->entity;
168 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
169 $this->fields[
'rowid'][
'visible'] = 0;
171 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
172 $this->fields[
'entity'][
'enabled'] = 0;
176 foreach ($this->fields as $key => $val) {
177 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
178 unset($this->fields[$key]);
183 if (is_object($langs)) {
184 foreach ($this->fields as $key => $val) {
185 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
186 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
187 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
208 $this->label = trim($this->label);
218 if (empty($this->
ref)) {
219 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
222 if (empty($this->label)) {
223 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
233 $sql =
"INSERT INTO " . MAIN_DB_PREFIX . $this->table_element .
" (";
234 $sql .=
" ref, ref_ext, label, entity, position";
237 $sql .=
" '" . $this->db->escape($this->
ref) .
"'";
238 $sql .=
", '" . $this->db->escape($this->ref_ext) .
"'";
239 $sql .=
", '" . $this->db->escape($this->label) .
"'";
240 $sql .=
", " . ((int) $this->entity);
241 $sql .=
", " . ((int) $this->
position);
245 $resql = $this->db->query($sql);
247 $this->errors[] =
"Error " . $this->db->lasterror();
252 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
255 if (!$error && !$notrigger) {
257 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_CREATE', $user);
268 $this->db->rollback();
285 $id = $id > 0 ? $id : 0;
289 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
297 $sql =
"SELECT rowid, ref, ref_ext, label, position";
298 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
299 $sql .=
" WHERE rowid = " . ((int) $id);
300 $sql .=
" AND entity IN (" .
getEntity(
'product') .
")";
303 $resql = $this->db->query($sql);
305 $this->errors[] =
"Error " . $this->db->lasterror();
310 $numrows = $this->db->num_rows($resql);
312 $obj = $this->db->fetch_object($resql);
314 $this->
id = $obj->rowid;
315 $this->
ref = $obj->ref;
316 $this->ref_ext = $obj->ref_ext;
317 $this->label = $obj->label;
318 $this->rang = $obj->position;
321 $this->db->free($resql);
335 $sql =
"SELECT rowid, ref, ref_ext, label, position";
336 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
337 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
338 $sql .= $this->db->order(
"position",
"asc");
341 $resql = $this->db->query($sql);
343 $this->errors[] =
"Error " . $this->db->lasterror();
348 while ($obj = $this->db->fetch_object($resql)) {
351 $tmp->id = $obj->rowid;
352 $tmp->ref = $obj->ref;
353 $tmp->ref_ext = $obj->ref_ext;
354 $tmp->label = $obj->label;
355 $tmp->rang = $obj->position;
356 $tmp->position = $obj->position;
377 $this->
id = $this->
id > 0 ? $this->id : 0;
379 $this->label = trim($this->label);
382 if (empty($this->
id)) {
383 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
386 if (empty($this->
ref)) {
387 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
390 if (empty($this->label)) {
391 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
401 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET";
403 $sql .=
" ref = '" . $this->db->escape($this->
ref) .
"'";
404 $sql .=
", ref_ext = '" . $this->db->escape($this->ref_ext) .
"'";
405 $sql .=
", label = '" . $this->db->escape($this->label) .
"'";
406 $sql .=
", position = " . ((int) $this->
position);
408 $sql .=
" WHERE rowid = " . ((int) $this->
id);
411 $resql = $this->db->query($sql);
413 $this->errors[] =
"Error " . $this->db->lasterror();
417 if (!$error && !$notrigger) {
419 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_MODIFY', $user);
430 $this->db->rollback();
442 public function delete(
User $user, $notrigger = 0)
448 $this->
id = $this->
id > 0 ? $this->id : 0;
451 if (empty($this->
id)) {
452 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
460 $result = $this->
isUsed();
463 } elseif ($result > 0) {
464 $this->errors[] = $langs->trans(
'ErrorAttributeIsUsedIntoProduct');
472 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_DELETE', $user);
481 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line;
482 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
484 dol_syslog(__METHOD__ .
' - Delete values', LOG_DEBUG);
485 $resql = $this->db->query($sql);
487 $this->errors[] =
"Error " . $this->db->lasterror();
493 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element;
494 $sql .=
" WHERE rowid = " . ((int) $this->
id);
496 dol_syslog(__METHOD__ .
' - Delete attribute', LOG_DEBUG);
497 $resql = $this->db->query($sql);
499 $this->errors[] =
"Error " . $this->db->lasterror();
508 $this->db->rollback();
525 $this->lines = array();
530 $this->
id = $this->
id > 0 ? $this->id : 0;
533 if (empty($this->
id)) {
534 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
542 $sql =
"SELECT td.rowid, td.fk_product_attribute, td.ref, td.value, td.position";
543 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line .
" AS td";
544 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX . $this->table_element .
" AS t ON t.rowid = td." . $this->fk_element;
545 $sql .=
" WHERE t.rowid = " . ((int) $this->
id);
546 $sql .=
" AND t.entity IN (" .
getEntity(
'product') .
")";
550 $sql .= $this->db->order(
"td.position",
"asc");
553 $resql = $this->db->query($sql);
555 $this->errors[] =
"Error " . $this->db->lasterror();
560 $num = $this->db->num_rows($resql);
564 $obj = $this->db->fetch_object($resql);
568 $line->id = $obj->rowid;
569 $line->fk_product_attribute = $obj->fk_product_attribute;
570 $line->ref = $obj->ref;
571 $line->value = $obj->value;
572 $line->position = $obj->position;
574 $this->lines[$i] = $line;
578 $this->db->free($resql);
607 public function addLine($ref, $value, $position = -1, $notrigger = 0)
609 global $langs, $user;
610 dol_syslog(__METHOD__ .
" id=".$this->
id.
", ref=".$ref.
", value=".$value.
", notrigger=".$notrigger);
614 $this->
id = $this->
id > 0 ? $this->id : 0;
617 if (empty($this->
id)) {
618 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
632 $positiontouse = $position;
633 if ($positiontouse == -1) {
635 $positiontouse = $positionmax + 1;
638 $this->line->context = $this->context;
639 $this->line->fk_product_attribute = $this->id;
640 $this->line->ref = $ref;
641 $this->line->value = $value;
642 $this->line->position = $positiontouse;
644 $result = $this->line->create($user, $notrigger);
647 $this->error = $this->line->error;
648 $this->errors = $this->line->errors;
649 $this->db->rollback();
653 return $this->line->id;
667 public function updateLine($lineid, $ref, $value, $notrigger = 0)
671 dol_syslog(__METHOD__ .
" lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger");
674 $lineid = $lineid > 0 ? $lineid : 0;
680 $result = $this->line->fetch($lineid);
682 $this->line->oldcopy = clone $this->line;
684 $this->line->context = $this->context;
685 $this->line->ref = $ref;
686 $this->line->value = $value;
688 $result = $this->line->update($user, $notrigger);
692 $this->error = $this->line->error;
693 $this->errors = $this->line->errors;
694 $this->db->rollback();
712 dol_syslog(__METHOD__ .
" lineid=$lineid, notrigger=$notrigger");
715 $lineid = $lineid > 0 ? $lineid : 0;
721 $result = $this->line->fetch($lineid);
723 $this->line->context = $this->context;
725 $result = $this->line->delete($user, $notrigger);
729 $this->error = $this->line->error;
730 $this->errors = $this->line->errors;
731 $this->db->rollback();
751 $this->
id = $this->
id > 0 ? $this->id : 0;
754 if (empty($this->
id)) {
755 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
763 $sql =
"SELECT COUNT(*) AS count";
764 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line;
765 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
768 $resql = $this->db->query($sql);
770 $this->errors[] =
"Error " . $this->db->lasterror();
775 if ($obj = $this->db->fetch_object($resql)) {
776 $count = $obj->count;
794 $this->
id = $this->
id > 0 ? $this->id : 0;
797 if (empty($this->
id)) {
798 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
806 $sql =
"SELECT COUNT(*) AS count";
807 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val AS pac2v";
808 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid";
809 $sql .=
" WHERE pac2v.fk_prod_attr = " . ((int) $this->
id);
810 $sql .=
" AND pac.entity IN (" .
getEntity(
'product') .
")";
813 $resql = $this->db->query($sql);
815 $this->errors[] =
"Error " . $this->db->lasterror();
820 if ($obj = $this->db->fetch_object($resql)) {
821 $count = $obj->count;
838 $this->
id = $this->
id > 0 ? $this->id : 0;
841 if (empty($this->
id)) {
842 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
850 $sql =
"SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->
id);
853 $resql = $this->db->query($sql);
855 $this->errors[] =
"Error " . $this->db->lasterror();
860 if ($obj = $this->db->fetch_object($resql)) {
864 return $used ? 1 : 0;
879 $sql =
"SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element;
880 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
882 $sql .=
" AND position = 0";
884 $sql .=
" AND position <> 0";
888 $resql = $this->db->query($sql);
890 $row = $this->db->fetch_row($resql);
900 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX . $this->table_element;
901 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
902 $sql .=
" ORDER BY position ASC, rowid " . $rowidorder;
904 dol_syslog(__METHOD__ .
" search all attributes", LOG_DEBUG);
905 $resql = $this->db->query($sql);
908 $num = $this->db->num_rows($resql);
910 $row = $this->db->fetch_row($resql);
917 foreach ($rows as $key => $row) {
939 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
940 $sql .=
" WHERE rowid = " . ((int) $rowid);
943 if (!$this->db->query($sql)) {
947 $parameters = array(
'rowid' => $rowid,
'position' => $position);
949 $reshook = $hookmanager->executeHooks(
'afterPositionOfAttributeUpdate', $parameters, $this, $action);
950 return ($reshook >= 0 ? 1 : -1);
962 $sql =
"SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element;
963 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
966 $resql = $this->db->query($sql);
968 $row = $this->db->fetch_row($resql);
1025 if ($position > 1) {
1026 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1027 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1028 $sql .=
" AND position = " . ((int) ($position - 1));
1029 if ($this->db->query($sql)) {
1030 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position - 1));
1031 $sql .=
" WHERE rowid = " . ((int) $rowid);
1032 if (!$this->db->query($sql)) {
1051 if ($position < $max) {
1052 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1053 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1054 $sql .=
" AND position = " . ((int) ($position + 1));
1055 if ($this->db->query($sql)) {
1056 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position + 1));
1057 $sql .=
" WHERE rowid = " . ((int) $rowid);
1058 if (!$this->db->query($sql)) {
1075 $sql =
"SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element;
1076 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1079 $resql = $this->db->query($sql);
1081 $row = $this->db->fetch_row($resql);
1096 $num = count($rows);
1097 for ($i = 0; $i < $num; $i++) {
1112 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1114 global $conf, $langs, $hookmanager;
1116 if (!empty($conf->dol_no_mouse_hover)) {
1122 $label =
img_picto(
'', $this->picto) .
' <u>' . $langs->trans(
"ProductAttribute") .
'</u>';
1123 if (isset($this->status)) {
1127 $label .=
'<b>' . $langs->trans(
'Ref') .
':</b> ' . $this->ref;
1128 if (!empty($this->label)) {
1129 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $this->label;
1132 $url =
dol_buildpath(
'/variants/card.php', 1) .
'?id=' . $this->id;
1134 if ($option !=
'nolink') {
1136 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1137 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1138 $add_save_lastsearch_values = 1;
1140 if ($url && $add_save_lastsearch_values) {
1141 $url .=
'&save_lastsearch_values=1';
1146 if (empty($notooltip)) {
1147 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1148 $label = $langs->trans(
"ShowProductAttribute");
1152 $linkclose .=
' class="classfortooltip' . ($morecss ?
' ' . $morecss :
'') .
'"';
1154 $linkclose = ($morecss ?
' class="' . $morecss .
'"' :
'');
1157 if ($option ==
'nolink' || empty($url)) {
1158 $linkstart =
'<span';
1160 $linkstart =
'<a href="' . $url .
'"';
1162 $linkstart .= $linkclose .
'>';
1163 if ($option ==
'nolink' || empty($url)) {
1164 $linkend =
'</span>';
1169 $result .= $linkstart;
1171 if (empty($this->showphoto_on_popup)) {
1173 $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);
1177 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
1179 list($class, $module) = explode(
'@', $this->picto);
1182 $filename = $filearray[0][
'name'];
1183 if (!empty($filename)) {
1184 $pospoint = strpos($filearray[0][
'name'],
'.');
1186 $pathtophoto = $class .
'/' . $this->
ref .
'/thumbs/' . substr($filename, 0, $pospoint) .
'_mini' . substr($filename, $pospoint);
1187 if (empty($conf->global->{strtoupper($module .
'_' . $class) .
'_FORMATLISTPHOTOSASUSERS'})) {
1188 $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>';
1190 $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>';
1193 $result .=
'</div>';
1195 $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);
1200 if ($withpicto != 2) {
1201 $result .= $this->ref;
1204 $result .= $linkend;
1207 global $action, $hookmanager;
1208 $hookmanager->initHooks(array(
'variantsdao'));
1209 $parameters = array(
'id' => $this->
id,
'getnomurl' => $result);
1210 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1212 $result = $hookmanager->resPrint;
1214 $result .= $hookmanager->resPrint;
1228 return $this->LibStatut(0, $mode);
1239 return $this->LibStatut(0, $mode);
1273 global $conf, $user, $langs, $object, $hookmanager;
1279 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1280 foreach ($dirtpls as $module => $reldir) {
1281 if (!empty($module)) {
1282 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_create.tpl.php');
1284 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_create.tpl.php';
1287 if (empty($conf->file->strict_mode)) {
1288 $res = @include $tpl;
1290 $res = include $tpl;
1315 public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir =
'/variants/tpl', $addcreateline = 0)
1317 global $conf, $hookmanager, $langs, $user, $form, $object;
1320 global $disableedit, $disablemove, $disableremove;
1322 $num = count($this->lines);
1324 $parameters = array(
'num' => $num,
'selected' => $selected,
'table_element_line' => $this->table_element_line);
1325 $reshook = $hookmanager->executeHooks(
'printObjectLineTitle', $parameters, $this, $action);
1326 if (empty($reshook)) {
1330 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1331 foreach ($dirtpls as $module => $reldir) {
1332 if (!empty($module)) {
1333 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_title.tpl.php');
1335 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_title.tpl.php';
1337 if (empty($conf->file->strict_mode)) {
1338 $res = @include $tpl;
1340 $res = include $tpl;
1349 if ($addcreateline) {
1351 if ($action !=
'selectlines') {
1352 if ($action !=
'editline') {
1355 $parameters = array();
1356 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters, $object, $action);
1357 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
1358 if (empty($reshook))
1359 $object->formAddObjectLine(1, $mysoc, $buyer);
1366 print
"<!-- begin printObjectLines() -->\n";
1367 foreach ($this->lines as $line) {
1368 if (is_object($hookmanager)) {
1369 $parameters = array(
'line' => $line,
'num' => $num,
'i' => $i,
'selected' => $selected,
'table_element_line' => $line->table_element);
1370 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $this, $action);
1372 if (empty($reshook)) {
1373 $this->printObjectLine($action, $line,
'', $num, $i, $dateSelector, $seller, $buyer, $selected,
null, $defaulttpldir);
1378 print
"<!-- end printObjectLines() -->\n";
1398 public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields =
null, $defaulttpldir =
'/variants/tpl')
1400 global $conf, $langs, $user, $object, $hookmanager;
1402 global $object_rights, $disableedit, $disablemove, $disableremove;
1404 $object_rights = $user->rights->variants;
1407 if ($action !=
'editline' || $selected != $line->id) {
1411 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1412 foreach ($dirtpls as $module => $reldir) {
1413 if (!empty($module)) {
1414 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_view.tpl.php');
1416 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_view.tpl.php';
1419 if (empty($conf->file->strict_mode)) {
1420 $res = @include $tpl;
1422 $res = include $tpl;
1431 if ($action ==
'editline' && $selected == $line->id) {
1435 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1436 foreach ($dirtpls as $module => $reldir) {
1437 if (!empty($module)) {
1438 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_edit.tpl.php');
1440 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_edit.tpl.php';
1443 if (empty($conf->file->strict_mode)) {
1444 $res = @include $tpl;
1446 $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.
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_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='', $keepspaces=0)
Clean a string from all punctuation characters to use it as a ref or login.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...