20 require_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,),
117 public $lines = array();
131 global $conf, $langs;
134 $this->entity = $conf->entity;
136 if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields[
'rowid'])) {
137 $this->fields[
'rowid'][
'visible'] = 0;
139 if (empty($conf->multicompany->enabled) && isset($this->fields[
'entity'])) {
140 $this->fields[
'entity'][
'enabled'] = 0;
144 foreach ($this->fields as $key => $val) {
145 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
146 unset($this->fields[$key]);
151 if (is_object($langs)) {
152 foreach ($this->fields as $key => $val) {
153 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
154 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
155 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
176 $this->label = trim($this->label);
177 $this->position = $this->position > 0 ? $this->position : 0;
180 if (empty($this->position)) {
182 $this->position = $positionmax + 1;
186 if (empty($this->
ref)) {
187 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
190 if (empty($this->label)) {
191 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
201 $sql =
"INSERT INTO " . MAIN_DB_PREFIX . $this->table_element .
" (";
202 $sql .=
" ref, ref_ext, label, entity, position";
205 $sql .=
" '" . $this->
db->escape($this->
ref) .
"'";
206 $sql .=
", '" . $this->
db->escape($this->ref_ext) .
"'";
207 $sql .=
", '" . $this->
db->escape($this->label) .
"'";
208 $sql .=
", " . ((int) $this->entity);
209 $sql .=
", " . ((int) $this->position);
215 $this->errors[] =
"Error " . $this->
db->lasterror();
220 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
223 if (!$error && !$notrigger) {
225 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_CREATE', $user);
236 $this->
db->rollback();
253 $id = $id > 0 ? $id : 0;
257 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
265 $sql =
"SELECT rowid, ref, ref_ext, label, position";
266 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
267 $sql .=
" WHERE rowid = " . ((int) $id);
268 $sql .=
" AND entity IN (" .
getEntity(
'product') .
")";
273 $this->errors[] =
"Error " . $this->
db->lasterror();
278 $numrows = $this->
db->num_rows(
$resql);
280 $obj = $this->
db->fetch_object(
$resql);
282 $this->
id = $obj->rowid;
283 $this->
ref = $obj->ref;
284 $this->ref_ext = $obj->ref_ext;
285 $this->label = $obj->label;
286 $this->rang = $obj->position;
287 $this->position = $obj->position;
303 $sql =
"SELECT rowid, ref, ref_ext, label, position";
304 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
305 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
306 $sql .= $this->
db->order(
"position",
"asc");
311 $this->errors[] =
"Error " . $this->
db->lasterror();
316 while ($obj = $this->
db->fetch_object(
$resql)) {
319 $tmp->id = $obj->rowid;
320 $tmp->ref = $obj->ref;
321 $tmp->ref_ext = $obj->ref_ext;
322 $tmp->label = $obj->label;
323 $tmp->rang = $obj->position;
324 $tmp->position = $obj->position;
345 $this->
id = $this->
id > 0 ? $this->
id : 0;
347 $this->label = trim($this->label);
350 if (empty($this->
id)) {
351 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
354 if (empty($this->
ref)) {
355 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
358 if (empty($this->label)) {
359 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
369 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET";
371 $sql .=
" ref = '" . $this->
db->escape($this->
ref) .
"'";
372 $sql .=
", ref_ext = '" . $this->
db->escape($this->ref_ext) .
"'";
373 $sql .=
", label = '" . $this->
db->escape($this->label) .
"'";
374 $sql .=
", position = " . ((int) $this->position);
376 $sql .=
" WHERE rowid = " . ((int) $this->
id);
381 $this->errors[] =
"Error " . $this->
db->lasterror();
385 if (!$error && !$notrigger) {
387 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_MODIFY', $user);
398 $this->
db->rollback();
410 public function delete(
User $user, $notrigger = 0)
416 $this->
id = $this->
id > 0 ? $this->
id : 0;
419 if (empty($this->
id)) {
420 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
428 $result = $this->
isUsed();
431 } elseif ($result > 0) {
432 $this->errors[] = $langs->trans(
'ErrorAttributeIsUsedIntoProduct');
440 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_DELETE', $user);
449 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line;
450 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
452 dol_syslog(__METHOD__ .
' - Delete values', LOG_DEBUG);
455 $this->errors[] =
"Error " . $this->
db->lasterror();
461 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element;
462 $sql .=
" WHERE rowid = " . ((int) $this->
id);
464 dol_syslog(__METHOD__ .
' - Delete attribute', LOG_DEBUG);
467 $this->errors[] =
"Error " . $this->
db->lasterror();
476 $this->
db->rollback();
493 $this->lines = array();
498 $this->
id = $this->
id > 0 ? $this->
id : 0;
501 if (empty($this->
id)) {
502 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
510 $sql =
"SELECT td.rowid, td.fk_product_attribute, td.ref, td.value, td.position";
511 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line .
" AS td";
512 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX . $this->table_element .
" AS t ON t.rowid = td." . $this->fk_element;
513 $sql .=
" WHERE t.rowid = " . ((int) $this->
id);
514 $sql .=
" AND t.entity IN (" .
getEntity(
'product') .
")";
518 $sql .= $this->
db->order(
"td.position",
"asc");
523 $this->errors[] =
"Error " . $this->
db->lasterror();
532 $obj = $this->
db->fetch_object(
$resql);
536 $line->id = $obj->rowid;
537 $line->fk_product_attribute = $obj->fk_product_attribute;
538 $line->ref = $obj->ref;
539 $line->value = $obj->value;
540 $line->position = $obj->position;
542 $this->lines[$i] = $line;
575 public function addLine($ref, $value, $position = -1, $notrigger = 0)
577 global $langs, $user;
578 dol_syslog(__METHOD__ .
" id={$this->id}, ref=$ref, value=$value, notrigger=$notrigger");
582 $this->
id = $this->
id > 0 ? $this->
id : 0;
585 if (empty($this->
id)) {
586 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
600 $positiontouse = $position;
601 if ($positiontouse == -1) {
603 $positiontouse = $positionmax + 1;
606 $this->line->context = $this->context;
607 $this->line->fk_product_attribute = $this->id;
608 $this->line->ref = $ref;
609 $this->line->value = $value;
610 $this->line->position = $positiontouse;
612 $result = $this->line->create($user, $notrigger);
615 $this->error = $this->line->error;
616 $this->errors = $this->line->errors;
617 $this->
db->rollback();
621 return $this->line->id;
635 public function updateLine($lineid, $ref, $value, $notrigger = 0)
639 dol_syslog(__METHOD__ .
" lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger");
642 $lineid = $lineid > 0 ? $lineid : 0;
648 $result = $this->line->fetch($lineid);
650 $this->line->oldcopy = clone $this->line;
652 $this->line->context = $this->context;
653 $this->line->ref = $ref;
654 $this->line->value = $value;
656 $result = $this->line->update($user, $notrigger);
660 $this->error = $this->line->error;
661 $this->errors = $this->line->errors;
662 $this->
db->rollback();
680 dol_syslog(__METHOD__ .
" lineid=$lineid, notrigger=$notrigger");
683 $lineid = $lineid > 0 ? $lineid : 0;
689 $result = $this->line->fetch($lineid);
691 $this->line->context = $this->context;
693 $result = $this->line->delete($user, $notrigger);
697 $this->error = $this->line->error;
698 $this->errors = $this->line->errors;
699 $this->
db->rollback();
719 $this->
id = $this->
id > 0 ? $this->
id : 0;
722 if (empty($this->
id)) {
723 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
731 $sql =
"SELECT COUNT(*) AS count";
732 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line;
733 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
738 $this->errors[] =
"Error " . $this->
db->lasterror();
743 if ($obj = $this->
db->fetch_object(
$resql)) {
744 $count = $obj->count;
762 $this->
id = $this->
id > 0 ? $this->
id : 0;
765 if (empty($this->
id)) {
766 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
774 $sql =
"SELECT COUNT(*) AS count";
775 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val AS pac2v";
776 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid";
777 $sql .=
" WHERE pac2v.fk_prod_attr = " . ((int) $this->
id);
778 $sql .=
" AND pac.entity IN (" .
getEntity(
'product') .
")";
783 $this->errors[] =
"Error " . $this->
db->lasterror();
788 if ($obj = $this->
db->fetch_object(
$resql)) {
789 $count = $obj->count;
806 $this->
id = $this->
id > 0 ? $this->
id : 0;
809 if (empty($this->
id)) {
810 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
818 $sql =
"SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->
id);
823 $this->errors[] =
"Error " . $this->
db->lasterror();
828 if ($obj = $this->
db->fetch_object(
$resql)) {
832 return $used ? 1 : 0;
847 $sql =
"SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element;
848 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
850 $sql .=
" AND position = 0";
852 $sql .=
" AND position <> 0";
858 $row = $this->
db->fetch_row(
$resql);
868 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX . $this->table_element;
869 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
870 $sql .=
" ORDER BY position ASC, rowid " . $rowidorder;
872 dol_syslog(__METHOD__ .
" search all attributes", LOG_DEBUG);
878 $row = $this->
db->fetch_row(
$resql);
885 foreach ($rows as $key => $row) {
907 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
908 $sql .=
" WHERE rowid = " . ((int) $rowid);
911 if (!$this->
db->query($sql)) {
915 $parameters = array(
'rowid' => $rowid,
'position' => $position);
917 $reshook = $hookmanager->executeHooks(
'afterPositionOfAttributeUpdate', $parameters, $this, $action);
930 $sql =
"SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element;
931 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
936 $row = $this->
db->fetch_row(
$resql);
990 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
991 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
992 $sql .=
" AND position = " . ((int) ($position - 1));
993 if ($this->
db->query($sql)) {
994 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position - 1));
995 $sql .=
" WHERE rowid = " . ((int) $rowid);
996 if (!$this->
db->query($sql)) {
1015 if ($position < $max) {
1016 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1017 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1018 $sql .=
" AND position = " . ((int) ($position + 1));
1019 if ($this->
db->query($sql)) {
1020 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position + 1));
1021 $sql .=
" WHERE rowid = " . ((int) $rowid);
1022 if (!$this->
db->query($sql)) {
1039 $sql =
"SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element;
1040 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1045 $row = $this->
db->fetch_row(
$resql);
1060 $num = count($rows);
1061 for ($i = 0; $i < $num; $i++) {
1076 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1078 global $conf, $langs, $hookmanager;
1080 if (!empty($conf->dol_no_mouse_hover)) {
1086 $label =
img_picto(
'', $this->picto) .
' <u>' . $langs->trans(
"ProductAttribute") .
'</u>';
1087 if (isset($this->status)) {
1091 $label .=
'<b>' . $langs->trans(
'Ref') .
':</b> ' . $this->ref;
1092 if (!empty($this->label)) {
1093 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $this->label;
1096 $url =
dol_buildpath(
'/variants/card.php', 1) .
'?id=' . $this->id;
1098 if ($option !=
'nolink') {
1100 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1101 if ($save_lastsearch_value == -1 && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1102 $add_save_lastsearch_values = 1;
1104 if ($url && $add_save_lastsearch_values) {
1105 $url .=
'&save_lastsearch_values=1';
1110 if (empty($notooltip)) {
1111 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1112 $label = $langs->trans(
"ShowProductAttribute");
1116 $linkclose .=
' class="classfortooltip' . ($morecss ?
' ' . $morecss :
'') .
'"';
1118 $linkclose = ($morecss ?
' class="' . $morecss .
'"' :
'');
1121 if ($option ==
'nolink' || empty($url)) {
1122 $linkstart =
'<span';
1124 $linkstart =
'<a href="' . $url .
'"';
1126 $linkstart .= $linkclose .
'>';
1127 if ($option ==
'nolink' || empty($url)) {
1128 $linkend =
'</span>';
1133 $result .= $linkstart;
1135 if (empty($this->showphoto_on_popup)) {
1137 $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);
1141 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
1143 list($class, $module) = explode(
'@', $this->picto);
1146 $filename = $filearray[0][
'name'];
1147 if (!empty($filename)) {
1148 $pospoint = strpos($filearray[0][
'name'],
'.');
1150 $pathtophoto = $class .
'/' . $this->
ref .
'/thumbs/' . substr($filename, 0, $pospoint) .
'_mini' . substr($filename, $pospoint);
1151 if (empty($conf->global->{strtoupper($module .
'_' . $class) .
'_FORMATLISTPHOTOSASUSERS'})) {
1152 $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>';
1154 $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>';
1157 $result .=
'</div>';
1159 $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);
1164 if ($withpicto != 2) {
1165 $result .= $this->ref;
1168 $result .= $linkend;
1171 global $action, $hookmanager;
1172 $hookmanager->initHooks(array(
'variantsdao'));
1173 $parameters = array(
'id' => $this->
id,
'getnomurl' => $result);
1174 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1176 $result = $hookmanager->resPrint;
1178 $result .= $hookmanager->resPrint;
1237 global $conf, $user, $langs, $object, $hookmanager;
1243 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1244 foreach ($dirtpls as $module => $reldir) {
1245 if (!empty($module)) {
1246 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_create.tpl.php');
1248 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_create.tpl.php';
1251 if (empty($conf->file->strict_mode)) {
1252 $res = @include $tpl;
1254 $res = include $tpl;
1278 public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir =
'/variants/tpl')
1280 global $conf, $hookmanager, $langs, $user,
$form, $object;
1282 global $disableedit, $disablemove, $disableremove;
1284 $num = count($this->lines);
1286 $parameters = array(
'num' => $num,
'selected' => $selected,
'table_element_line' => $this->table_element_line);
1287 $reshook = $hookmanager->executeHooks(
'printObjectLineTitle', $parameters, $this, $action);
1288 if (empty($reshook)) {
1292 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1293 foreach ($dirtpls as $module => $reldir) {
1294 if (!empty($module)) {
1295 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_title.tpl.php');
1297 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_title.tpl.php';
1299 if (empty($conf->file->strict_mode)) {
1300 $res = @include $tpl;
1302 $res = include $tpl;
1312 print
"<!-- begin printObjectLines() --><tbody>\n";
1313 foreach ($this->lines as $line) {
1314 if (is_object($hookmanager)) {
1315 $parameters = array(
'line' => $line,
'num' => $num,
'i' => $i,
'selected' => $selected,
'table_element_line' => $line->table_element);
1316 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $this, $action);
1318 if (empty($reshook)) {
1319 $this->
printObjectLine($action, $line,
'', $num, $i, $dateSelector, $seller, $buyer, $selected, null, $defaulttpldir);
1324 print
"</tbody><!-- end printObjectLines() -->\n";
1344 public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir =
'/variants/tpl')
1346 global $conf, $langs, $user, $object, $hookmanager;
1348 global $object_rights, $disableedit, $disablemove, $disableremove;
1350 $object_rights = $user->rights->variants;
1353 if ($action !=
'editline' || $selected != $line->id) {
1357 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1358 foreach ($dirtpls as $module => $reldir) {
1359 if (!empty($module)) {
1360 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_view.tpl.php');
1362 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_view.tpl.php';
1365 if (empty($conf->file->strict_mode)) {
1366 $res = @include $tpl;
1368 $res = include $tpl;
1377 if ($action ==
'editline' && $selected == $line->id) {
1381 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1382 foreach ($dirtpls as $module => $reldir) {
1383 if (!empty($module)) {
1384 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_edit.tpl.php');
1386 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_edit.tpl.php';
1389 if (empty($conf->file->strict_mode)) {
1390 $res = @include $tpl;
1392 $res = include $tpl;
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.class.php)
countChildProducts()
Returns the number of products that are using this attribute.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
countChildValues()
Returns the number of values for this attribute.
updateLine($lineid, $ref, $value, $notrigger=0)
Update a line.
attributeOrder($renum=false, $rowidorder= 'ASC')
Save a new position (field position) for details lines.
$conf db
API class for accounts.
getNomUrl($withpicto=0, $option= '', $notooltip=0, $morecss= '', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
Class to manage Dolibarr users.
fetchAll()
Returns an array of all product variants.
Class to manage Dolibarr database access.
getPositionOfAttribute($rowid)
Get position of attribute.
dol_string_nospecial($str, $newstr= '_', $badcharstoreplace= '', $badcharstoremove= '')
Clean a string from all punctuation characters to use it as a ref or login.
Class ProductAttributeValue Used to represent a product attribute value.
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_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Class ProductAttribute Used to represent a product attribute.
LibStatut($status, $mode=1)
Return label of a status.
formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir= '/variants/tpl')
Show add free and predefined products/services form.
updateAttributePositionDown($rowid, $position, $max)
Update position of attribute (down)
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
getMaxAttributesPosition()
Get max value used for position of attributes.
update(User $user, $notrigger=0)
Updates a product attribute.
fetch_lines($filters= '')
Load array lines.
__construct(DoliDB $db)
Constructor.
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0)
Scan a directory and return a list of files/directories.
fetch($id)
Fetches the properties of a product attribute.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
addLine($ref, $value, $position=-1, $notrigger=0)
Add a proposal line into database (linked to product/service or not) The parameters are already suppo...
call_trigger($triggerName, $user)
Call trigger based on this instance.
isUsed()
Test if used by a product.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
printObjectLines($action, $seller, $buyer, $selected=0, $dateSelector=0, $defaulttpldir= '/variants/tpl')
Return HTML table for object lines TODO Move this into an output class file (htmlline.class.php) If lines are into a template, title must also be into a template But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
attributeMoveUp($rowid)
Update a attribute to have a higher position.
errorsToString()
Method to output saved errors.
attributeMoveDown($rowid)
Update a attribute to have a lower position.
create(User $user, $notrigger=0)
Creates a product attribute.
getLabelStatus($mode=0)
Return the label of the status.
deleteLine(User $user, $lineid, $notrigger=0)
Delete a line.
attributesAjaxOrder($rows)
Update position of attributes with ajax.
getLinesArray($filters= '')
Retrieve an array of proposal lines.
updateAttributePositionUp($rowid, $position)
Update position of attribute (up)
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
updatePositionOfAttribute($rowid, $position)
Update position of line (rang)
getLibStatut($mode=0)
Return label of status of product attribute.