27require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
47 public $module =
'variants';
52 public $element =
'productattribute';
57 public $table_element =
'product_attribute';
62 public $table_element_line =
'product_attribute_value';
67 public $fk_element =
'fk_product_attribute';
72 public $picto =
'product';
102 public $fields = array(
103 'rowid' => array(
'type' =>
'integer',
'label' =>
'TechnicalID',
'enabled' => 1,
'position' => 1,
'notnull' => 1,
'visible' => 0,
'noteditable' => 1,
'index' => 1,
'css' =>
'left',
'comment' =>
"Id"),
104 'ref' => array(
'type' =>
'varchar(255)',
'label' =>
'Ref',
'visible' => 1,
'enabled' => 1,
'position' => 10,
'notnull' => 1,
'index' => 1,
'searchall' => 1,
'comment' =>
"Reference of object",
'css' =>
'width200'),
105 'ref_ext' => array(
'type' =>
'varchar(255)',
'label' =>
'ExternalRef',
'enabled' => 1,
'visible' => 0,
'position' => 20,
'searchall' => 1),
106 'label' => array(
'type' =>
'varchar(255)',
'label' =>
'Label',
'enabled' => 1,
'position' => 30,
'notnull' => 1,
'visible' => 1,
'searchall' => 1,
'css' =>
'minwidth300',
'help' =>
"",
'showoncombobox' => 1,),
107 'position' => array(
'type' =>
'integer',
'label' =>
'Rank',
'enabled' => 1,
'visible' => 0,
'default' =>
'0',
'position' => 40,
'notnull' => 1,),
145 public $lines = array();
155 public $is_used_by_products;
165 global $conf, $langs;
169 $this->ismultientitymanaged = 1;
170 $this->isextrafieldmanaged = 0;
171 $this->entity = $conf->entity;
174 $this->fields[
'rowid'][
'visible'] = 0;
176 if (!isModEnabled(
'multicompany') && isset($this->fields[
'entity'])) {
177 $this->fields[
'entity'][
'enabled'] = 0;
181 foreach ($this->fields as $key => $val) {
182 if (isset($val[
'enabled']) && empty($val[
'enabled'])) {
183 unset($this->fields[$key]);
188 if (is_object($langs)) {
189 foreach ($this->fields as $key => $val) {
190 if (!empty($val[
'arrayofkeyval']) && is_array($val[
'arrayofkeyval'])) {
191 foreach ($val[
'arrayofkeyval'] as $key2 => $val2) {
192 $this->fields[$key][
'arrayofkeyval'][$key2] = $langs->trans($val2);
213 $this->label = trim($this->label);
223 if (empty($this->
ref)) {
224 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
227 if (empty($this->label)) {
228 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
238 $sql =
"INSERT INTO " . MAIN_DB_PREFIX . $this->table_element .
" (";
239 $sql .=
" ref, ref_ext, label, entity, position";
242 $sql .=
" '" . $this->db->escape($this->
ref) .
"'";
243 $sql .=
", '" . $this->db->escape($this->ref_ext) .
"'";
244 $sql .=
", '" . $this->db->escape($this->label) .
"'";
245 $sql .=
", " . ((int) $this->entity);
246 $sql .=
", " . ((int) $this->
position);
250 $resql = $this->db->query($sql);
252 $this->errors[] =
"Error " . $this->db->lasterror();
257 $this->
id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
260 if (!$error && !$notrigger) {
262 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_CREATE', $user);
273 $this->db->rollback();
290 $id = $id > 0 ? $id : 0;
294 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
302 $sql =
"SELECT rowid, ref, ref_ext, label, position";
303 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
304 $sql .=
" WHERE rowid = " . ((int) $id);
305 $sql .=
" AND entity IN (" .
getEntity(
'product') .
")";
308 $resql = $this->db->query($sql);
310 $this->errors[] =
"Error " . $this->db->lasterror();
315 $numrows = $this->db->num_rows($resql);
317 $obj = $this->db->fetch_object($resql);
319 $this->
id = $obj->rowid;
320 $this->
ref = $obj->ref;
321 $this->ref_ext = $obj->ref_ext;
322 $this->label = $obj->label;
323 $this->rang = $obj->position;
326 $this->db->free($resql);
340 $sql =
"SELECT rowid, ref, ref_ext, label, position";
341 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
342 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
343 $sql .= $this->db->order(
"position",
"asc");
346 $resql = $this->db->query($sql);
348 $this->errors[] =
"Error " . $this->db->lasterror();
353 while ($obj = $this->db->fetch_object($resql)) {
356 $tmp->id = $obj->rowid;
357 $tmp->ref = $obj->ref;
358 $tmp->ref_ext = $obj->ref_ext;
359 $tmp->label = $obj->label;
360 $tmp->rang = $obj->position;
361 $tmp->position = $obj->position;
382 $this->
id = $this->
id > 0 ? $this->id : 0;
384 $this->label = trim($this->label);
387 if (empty($this->
id)) {
388 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
391 if (empty($this->
ref)) {
392 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
395 if (empty($this->label)) {
396 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
406 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET";
408 $sql .=
" ref = '" . $this->db->escape($this->
ref) .
"'";
409 $sql .=
", ref_ext = '" . $this->db->escape($this->ref_ext) .
"'";
410 $sql .=
", label = '" . $this->db->escape($this->label) .
"'";
411 $sql .=
", position = " . ((int) $this->
position);
413 $sql .=
" WHERE rowid = " . ((int) $this->
id);
416 $resql = $this->db->query($sql);
418 $this->errors[] =
"Error " . $this->db->lasterror();
422 if (!$error && !$notrigger) {
424 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_MODIFY', $user);
435 $this->db->rollback();
447 public function delete(
User $user, $notrigger = 0)
453 $this->
id = $this->
id > 0 ? $this->id : 0;
456 if (empty($this->
id)) {
457 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
465 $result = $this->
isUsed();
468 } elseif ($result > 0) {
469 $this->errors[] = $langs->trans(
'ErrorAttributeIsUsedIntoProduct');
477 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_DELETE', $user);
486 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line;
487 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
489 dol_syslog(__METHOD__ .
' - Delete values', LOG_DEBUG);
490 $resql = $this->db->query($sql);
492 $this->errors[] =
"Error " . $this->db->lasterror();
498 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element;
499 $sql .=
" WHERE rowid = " . ((int) $this->
id);
501 dol_syslog(__METHOD__ .
' - Delete attribute', LOG_DEBUG);
502 $resql = $this->db->query($sql);
504 $this->errors[] =
"Error " . $this->db->lasterror();
513 $this->db->rollback();
530 $this->lines = array();
535 $this->
id = $this->
id > 0 ? $this->id : 0;
538 if (empty($this->
id)) {
539 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
547 $sql =
"SELECT td.rowid, td.fk_product_attribute, td.ref, td.value, td.position";
548 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line .
" AS td";
549 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX . $this->table_element .
" AS t ON t.rowid = td." . $this->fk_element;
550 $sql .=
" WHERE t.rowid = " . ((int) $this->
id);
551 $sql .=
" AND t.entity IN (" .
getEntity(
'product') .
")";
555 $sql .= $this->db->order(
"td.position",
"asc");
558 $resql = $this->db->query($sql);
560 $this->errors[] =
"Error " . $this->db->lasterror();
565 $num = $this->db->num_rows($resql);
569 $obj = $this->db->fetch_object($resql);
573 $line->id = $obj->rowid;
574 $line->fk_product_attribute = $obj->fk_product_attribute;
575 $line->ref = $obj->ref;
576 $line->value = $obj->value;
577 $line->position = $obj->position;
579 $this->lines[$i] = $line;
583 $this->db->free($resql);
612 public function addLine($ref, $value, $position = -1, $notrigger = 0)
614 global $langs, $user;
615 dol_syslog(__METHOD__ .
" id=".$this->
id.
", ref=".$ref.
", value=".$value.
", notrigger=".$notrigger);
619 $this->
id = $this->
id > 0 ? $this->id : 0;
622 if (empty($this->
id)) {
623 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
637 $positiontouse = $position;
638 if ($positiontouse == -1) {
640 $positiontouse = $positionmax + 1;
643 $this->line->context = $this->context;
644 $this->line->fk_product_attribute = $this->id;
645 $this->line->ref = $ref;
646 $this->line->value = $value;
647 $this->line->position = $positiontouse;
649 $result = $this->line->create($user, $notrigger);
652 $this->error = $this->line->error;
653 $this->errors = $this->line->errors;
654 $this->db->rollback();
658 return $this->line->id;
672 public function updateLine($lineid, $ref, $value, $notrigger = 0)
676 dol_syslog(__METHOD__ .
" lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger");
679 $lineid = $lineid > 0 ? $lineid : 0;
685 $result = $this->line->fetch($lineid);
687 $this->line->oldcopy = clone $this->line;
689 $this->line->context = $this->context;
690 $this->line->ref = $ref;
691 $this->line->value = $value;
693 $result = $this->line->update($user, $notrigger);
697 $this->error = $this->line->error;
698 $this->errors = $this->line->errors;
699 $this->db->rollback();
717 dol_syslog(__METHOD__ .
" lineid=$lineid, notrigger=$notrigger");
720 $lineid = $lineid > 0 ? $lineid : 0;
726 $result = $this->line->fetch($lineid);
728 $this->line->context = $this->context;
730 $result = $this->line->delete($user, $notrigger);
734 $this->error = $this->line->error;
735 $this->errors = $this->line->errors;
736 $this->db->rollback();
756 $this->
id = $this->
id > 0 ? $this->id : 0;
759 if (empty($this->
id)) {
760 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
768 $sql =
"SELECT COUNT(*) AS count";
769 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line;
770 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
773 $resql = $this->db->query($sql);
775 $this->errors[] =
"Error " . $this->db->lasterror();
780 if ($obj = $this->db->fetch_object($resql)) {
781 $count = $obj->count;
799 $this->
id = ($this->
id > 0) ? $this->
id : 0;
802 if (empty($this->
id)) {
803 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
811 $sql =
"SELECT COUNT(*) AS count";
812 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val AS pac2v";
813 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid";
814 $sql .=
" WHERE pac2v.fk_prod_attr = " . ((int) $this->
id);
815 $sql .=
" AND pac.entity IN (" .
getEntity(
'product') .
")";
818 $resql = $this->db->query($sql);
820 $this->errors[] =
"Error " . $this->db->lasterror();
825 if ($obj = $this->db->fetch_object($resql)) {
826 $count = $obj->count;
843 $this->
id = $this->
id > 0 ? $this->id : 0;
846 if (empty($this->
id)) {
847 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
855 $sql =
"SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->
id);
858 $resql = $this->db->query($sql);
860 $this->errors[] =
"Error " . $this->db->lasterror();
865 if ($obj = $this->db->fetch_object($resql)) {
869 return $used ? 1 : 0;
884 $sql =
"SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element;
885 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
887 $sql .=
" AND position = 0";
889 $sql .=
" AND position <> 0";
893 $resql = $this->db->query($sql);
895 $row = $this->db->fetch_row($resql);
905 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX . $this->table_element;
906 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
907 $sql .=
" ORDER BY position ASC, rowid " . $rowidorder;
909 dol_syslog(__METHOD__ .
" search all attributes", LOG_DEBUG);
910 $resql = $this->db->query($sql);
913 $num = $this->db->num_rows($resql);
915 $row = $this->db->fetch_row($resql);
922 foreach ($rows as $key => $row) {
944 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
945 $sql .=
" WHERE rowid = " . ((int) $rowid);
948 if (!$this->db->query($sql)) {
952 $parameters = array(
'rowid' => $rowid,
'position' => $position);
954 $reshook = $hookmanager->executeHooks(
'afterPositionOfAttributeUpdate', $parameters, $this, $action);
955 return ($reshook >= 0 ? 1 : -1);
967 $sql =
"SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element;
968 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
971 $resql = $this->db->query($sql);
973 $row = $this->db->fetch_row($resql);
1030 if ($position > 1) {
1031 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1032 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1033 $sql .=
" AND position = " . ((int) ($position - 1));
1034 if ($this->db->query($sql)) {
1035 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position - 1));
1036 $sql .=
" WHERE rowid = " . ((int) $rowid);
1037 if (!$this->db->query($sql)) {
1056 if ($position < $max) {
1057 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1058 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1059 $sql .=
" AND position = " . ((int) ($position + 1));
1060 if ($this->db->query($sql)) {
1061 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position + 1));
1062 $sql .=
" WHERE rowid = " . ((int) $rowid);
1063 if (!$this->db->query($sql)) {
1080 $sql =
"SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element;
1081 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1084 $resql = $this->db->query($sql);
1086 $row = $this->db->fetch_row($resql);
1101 $num = count($rows);
1102 for ($i = 0; $i < $num; $i++) {
1117 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1119 global $conf, $langs, $hookmanager;
1121 if (!empty($conf->dol_no_mouse_hover)) {
1127 $label =
img_picto(
'', $this->picto) .
' <u>' . $langs->trans(
"ProductAttribute") .
'</u>';
1128 if (isset($this->
status)) {
1132 $label .=
'<b>' . $langs->trans(
'Ref') .
':</b> ' . $this->ref;
1133 if (!empty($this->label)) {
1134 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $this->label;
1137 $url =
dol_buildpath(
'/variants/card.php', 1) .
'?id=' . $this->id;
1139 if ($option !=
'nolink') {
1141 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1142 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1143 $add_save_lastsearch_values = 1;
1145 if ($url && $add_save_lastsearch_values) {
1146 $url .=
'&save_lastsearch_values=1';
1151 if (empty($notooltip)) {
1153 $label = $langs->trans(
"ShowProductAttribute");
1157 $linkclose .=
' class="classfortooltip' . ($morecss ?
' ' . $morecss :
'') .
'"';
1159 $linkclose = ($morecss ?
' class="' . $morecss .
'"' :
'');
1162 if ($option ==
'nolink' || empty($url)) {
1163 $linkstart =
'<span';
1165 $linkstart =
'<a href="' . $url .
'"';
1167 $linkstart .= $linkclose .
'>';
1168 if ($option ==
'nolink' || empty($url)) {
1169 $linkend =
'</span>';
1174 $result .= $linkstart;
1176 if (empty($this->showphoto_on_popup)) {
1178 $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);
1182 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
1184 list($class, $module) = explode(
'@', $this->picto);
1187 $filename = $filearray[0][
'name'];
1188 if (!empty($filename)) {
1189 $pospoint = strpos($filearray[0][
'name'],
'.');
1191 $pathtophoto = $class .
'/' . $this->
ref .
'/thumbs/' . substr($filename, 0, $pospoint) .
'_mini' . substr($filename, $pospoint);
1192 if (!
getDolGlobalString(strtoupper($module .
'_' . $class) .
'_FORMATLISTPHOTOSASUSERS')) {
1193 $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>';
1195 $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>';
1198 $result .=
'</div>';
1200 $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);
1205 if ($withpicto != 2) {
1206 $result .= $this->ref;
1209 $result .= $linkend;
1212 global $action, $hookmanager;
1213 $hookmanager->initHooks(array(
'variantsdao'));
1214 $parameters = array(
'id' => $this->
id,
'getnomurl' => $result);
1215 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1217 $result = $hookmanager->resPrint;
1219 $result .= $hookmanager->resPrint;
1234 global $conf, $langs;
1236 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1238 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1239 $return .=
'<div class="info-box info-box-sm">';
1240 $return .=
'<span class="info-box-icon bg-infobox-action">';
1242 $return .=
'</span>';
1243 $return .=
'<div class="info-box-content">';
1244 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1245 if ($selected >= 0) {
1246 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1248 if (property_exists($this,
'label')) {
1249 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1251 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1252 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1254 if (method_exists($this,
'getLibStatut')) {
1255 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1257 $return .=
'</div>';
1258 $return .=
'</div>';
1259 $return .=
'</div>';
1317 global $conf, $user, $langs,
$object, $hookmanager;
1323 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1324 foreach ($dirtpls as $module => $reldir) {
1325 if (!empty($module)) {
1326 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_create.tpl.php');
1328 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_create.tpl.php';
1331 if (empty($conf->file->strict_mode)) {
1332 $res = @include $tpl;
1334 $res = include $tpl;
1359 public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir =
'/variants/tpl', $addcreateline = 0)
1361 global $conf, $hookmanager, $langs, $user, $form,
$object;
1364 global $disableedit, $disablemove, $disableremove;
1366 $num = count($this->lines);
1368 $parameters = array(
'num' => $num,
'selected' => $selected,
'table_element_line' => $this->table_element_line);
1369 $reshook = $hookmanager->executeHooks(
'printObjectLineTitle', $parameters, $this, $action);
1370 if (empty($reshook)) {
1374 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1375 foreach ($dirtpls as $module => $reldir) {
1376 if (!empty($module)) {
1377 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_title.tpl.php');
1379 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_title.tpl.php';
1381 if (empty($conf->file->strict_mode)) {
1382 $res = @include $tpl;
1384 $res = include $tpl;
1393 if ($addcreateline) {
1395 if ($action !=
'selectlines') {
1396 if ($action !=
'editline') {
1399 $parameters = array();
1400 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
1404 if (empty($reshook)) {
1405 $object->formAddObjectLine(1, $mysoc, $buyer);
1413 print
"<!-- begin printObjectLines() -->\n";
1414 foreach ($this->lines as $line) {
1415 if (is_object($hookmanager)) {
1416 $parameters = array(
'line' => $line,
'num' => $num,
'i' => $i,
'selected' => $selected,
'table_element_line' => $line->table_element);
1417 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $this, $action);
1419 if (empty($reshook)) {
1420 $this->
printObjectLine($action, $line,
'', $num, $i, $dateSelector, $seller, $buyer, $selected,
null, $defaulttpldir);
1425 print
"<!-- end printObjectLines() -->\n";
1445 public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields =
null, $defaulttpldir =
'/variants/tpl')
1447 global $conf, $langs, $user,
$object, $hookmanager;
1449 global $object_rights, $disableedit, $disablemove, $disableremove;
1451 $object_rights = $user->rights->variants;
1454 if ($action !=
'editline' || $selected != $line->id) {
1458 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1459 foreach ($dirtpls as $module => $reldir) {
1460 if (!empty($module)) {
1461 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_view.tpl.php');
1463 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_view.tpl.php';
1466 if (empty($conf->file->strict_mode)) {
1467 $res = @include $tpl;
1469 $res = include $tpl;
1478 if ($action ==
'editline' && $selected == $line->id) {
1482 $dirtpls = array_merge($conf->modules_parts[
'tpl'], array($defaulttpldir));
1483 foreach ($dirtpls as $module => $reldir) {
1484 if (!empty($module)) {
1485 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_edit.tpl.php');
1487 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_edit.tpl.php';
1490 if (empty($conf->file->strict_mode)) {
1491 $res = @include $tpl;
1493 $res = include $tpl;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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 Examples:
updateAttributePositionDown($rowid, $position, $max)
Update position of attribute (down)
updatePositionOfAttribute($rowid, $position)
Update position of line (rang)
addLine($ref, $value, $position=-1, $notrigger=0)
getKanbanView($option='', $arraydata=null)
Return a thumb for kanban views.
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 with all the ProductAttribute objects of a given entity.
updateAttributePositionUp($rowid, $position)
Update position of attribute (up)
isUsed()
Test if this attribute is 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()
Return the number of product variants 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 optionally 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($utf8_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.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (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.
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_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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...