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 = 1;
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);
264 if (!$error && !$notrigger) {
266 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_CREATE', $user);
277 $this->db->rollback();
294 $id = $id > 0 ? $id : 0;
298 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
306 $sql =
"SELECT rowid, ref, ref_ext, label, position";
307 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
308 $sql .=
" WHERE rowid = " . ((int) $id);
309 $sql .=
" AND entity IN (" .
getEntity(
'product') .
")";
312 $resql = $this->db->query($sql);
314 $this->errors[] =
"Error " . $this->db->lasterror();
319 $numrows = $this->db->num_rows($resql);
321 $obj = $this->db->fetch_object($resql);
323 $this->
id = $obj->rowid;
324 $this->
ref = $obj->ref;
325 $this->ref_ext = $obj->ref_ext;
326 $this->label = $obj->label;
327 $this->rang = $obj->position;
331 $this->db->free($resql);
345 $sql =
"SELECT rowid, ref, ref_ext, label, position";
346 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element;
347 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
348 $sql .= $this->db->order(
"position",
"asc");
351 $resql = $this->db->query($sql);
353 $this->errors[] =
"Error " . $this->db->lasterror();
358 while ($obj = $this->db->fetch_object($resql)) {
361 $tmp->id = $obj->rowid;
362 $tmp->ref = $obj->ref;
363 $tmp->ref_ext = $obj->ref_ext;
364 $tmp->label = $obj->label;
365 $tmp->rang = $obj->position;
366 $tmp->position = $obj->position;
387 $this->
id = $this->
id > 0 ? $this->id : 0;
389 $this->label = trim($this->label);
392 if (empty($this->
id)) {
393 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
396 if (empty($this->
ref)) {
397 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref"));
400 if (empty($this->label)) {
401 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label"));
411 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET";
413 $sql .=
" ref = '" . $this->db->escape($this->
ref) .
"'";
414 $sql .=
", ref_ext = '" . $this->db->escape($this->ref_ext) .
"'";
415 $sql .=
", label = '" . $this->db->escape($this->label) .
"'";
416 $sql .=
", position = " . ((int) $this->
position);
418 $sql .=
" WHERE rowid = " . ((int) $this->
id);
421 $resql = $this->db->query($sql);
423 $this->errors[] =
"Error " . $this->db->lasterror();
432 if (!$error && !$notrigger) {
434 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_MODIFY', $user);
445 $this->db->rollback();
457 public function delete(
User $user, $notrigger = 0)
463 $this->
id = $this->
id > 0 ? $this->id : 0;
466 if (empty($this->
id)) {
467 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
475 $result = $this->
isUsed();
478 } elseif ($result > 0) {
479 $this->errors[] = $langs->trans(
'ErrorAttributeIsUsedIntoProduct');
487 $result = $this->
call_trigger(
'PRODUCT_ATTRIBUTE_DELETE', $user);
496 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line;
497 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
499 dol_syslog(__METHOD__ .
' - Delete values', LOG_DEBUG);
500 $resql = $this->db->query($sql);
502 $this->errors[] =
"Error " . $this->db->lasterror();
508 $sql =
"DELETE FROM " . MAIN_DB_PREFIX . $this->table_element;
509 $sql .=
" WHERE rowid = " . ((int) $this->
id);
511 dol_syslog(__METHOD__ .
' - Delete attribute', LOG_DEBUG);
512 $resql = $this->db->query($sql);
514 $this->errors[] =
"Error " . $this->db->lasterror();
523 $this->db->rollback();
540 $this->lines = array();
545 $this->
id = $this->
id > 0 ? $this->id : 0;
548 if (empty($this->
id)) {
549 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
557 $sql =
"SELECT td.rowid, td.fk_product_attribute, td.ref, td.value, td.position";
558 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line .
" AS td";
559 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX . $this->table_element .
" AS t ON t.rowid = td." . $this->fk_element;
560 $sql .=
" WHERE t.rowid = " . ((int) $this->
id);
561 $sql .=
" AND t.entity IN (" .
getEntity(
'product') .
")";
565 $sql .= $this->db->order(
"td.position",
"asc");
568 $resql = $this->db->query($sql);
570 $this->errors[] =
"Error " . $this->db->lasterror();
575 $num = $this->db->num_rows($resql);
579 $obj = $this->db->fetch_object($resql);
583 $line->id = $obj->rowid;
584 $line->fk_product_attribute = $obj->fk_product_attribute;
585 $line->ref = $obj->ref;
586 $line->value = $obj->value;
587 $line->position = $obj->position;
588 $line->fetch_optionals();
590 $this->lines[$i] = $line;
594 $this->db->free($resql);
623 public function addLine($ref, $value, $position = -1, $notrigger = 0)
625 global $langs, $user;
626 dol_syslog(__METHOD__ .
" id=".$this->
id.
", ref=".$ref.
", value=".$value.
", notrigger=".$notrigger);
630 $this->
id = $this->
id > 0 ? $this->id : 0;
633 if (empty($this->
id)) {
634 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
648 $positiontouse = $position;
649 if ($positiontouse == -1) {
651 $positiontouse = $positionmax + 1;
654 $this->line->context = $this->context;
655 $this->line->fk_product_attribute = $this->id;
656 $this->line->ref = $ref;
657 $this->line->value = $value;
658 $this->line->position = $positiontouse;
660 $result = $this->line->create($user, $notrigger);
663 $this->error = $this->line->error;
664 $this->errors = $this->line->errors;
665 $this->db->rollback();
669 return $this->line->id;
683 public function updateLine($lineid, $ref, $value, $notrigger = 0)
687 dol_syslog(__METHOD__ .
" lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger");
690 $lineid = $lineid > 0 ? $lineid : 0;
696 $result = $this->line->fetch($lineid);
698 $this->line->oldcopy = clone $this->line;
700 $this->line->context = $this->context;
701 $this->line->ref = $ref;
702 $this->line->value = $value;
704 $result = $this->line->update($user, $notrigger);
708 $this->error = $this->line->error;
709 $this->errors = $this->line->errors;
710 $this->db->rollback();
728 dol_syslog(__METHOD__ .
" lineid=$lineid, notrigger=$notrigger");
731 $lineid = $lineid > 0 ? $lineid : 0;
737 $result = $this->line->fetch($lineid);
739 $this->line->context = $this->context;
741 $result = $this->line->delete($user, $notrigger);
745 $this->error = $this->line->error;
746 $this->errors = $this->line->errors;
747 $this->db->rollback();
767 $this->
id = $this->
id > 0 ? $this->id : 0;
770 if (empty($this->
id)) {
771 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
779 $sql =
"SELECT COUNT(*) AS count";
780 $sql .=
" FROM " . MAIN_DB_PREFIX . $this->table_element_line;
781 $sql .=
" WHERE " . $this->fk_element .
" = " . ((int) $this->
id);
784 $resql = $this->db->query($sql);
786 $this->errors[] =
"Error " . $this->db->lasterror();
791 if ($obj = $this->db->fetch_object($resql)) {
792 $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 count";
823 $sql .=
" FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val AS pac2v";
824 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_attribute_combination AS pac ON pac2v.fk_prod_combination = pac.rowid";
825 $sql .=
" WHERE pac2v.fk_prod_attr = " . ((int) $this->
id);
826 $sql .=
" AND pac.entity IN (" .
getEntity(
'product') .
")";
829 $resql = $this->db->query($sql);
831 $this->errors[] =
"Error " . $this->db->lasterror();
836 if ($obj = $this->db->fetch_object($resql)) {
837 $count = $obj->count;
854 $this->
id = $this->
id > 0 ? $this->id : 0;
857 if (empty($this->
id)) {
858 $this->errors[] = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"TechnicalID"));
866 $sql =
"SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX .
"product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->
id);
869 $resql = $this->db->query($sql);
871 $this->errors[] =
"Error " . $this->db->lasterror();
876 if ($obj = $this->db->fetch_object($resql)) {
880 return $used ? 1 : 0;
895 $sql =
"SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element;
896 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
898 $sql .=
" AND position = 0";
900 $sql .=
" AND position <> 0";
904 $resql = $this->db->query($sql);
906 $row = $this->db->fetch_row($resql);
916 $sql =
"SELECT rowid FROM " . MAIN_DB_PREFIX . $this->table_element;
917 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
918 $sql .=
" ORDER BY position ASC, rowid " . $rowidorder;
920 dol_syslog(__METHOD__ .
" search all attributes", LOG_DEBUG);
921 $resql = $this->db->query($sql);
924 $num = $this->db->num_rows($resql);
926 $row = $this->db->fetch_row($resql);
933 foreach ($rows as $key => $row) {
955 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
956 $sql .=
" WHERE rowid = " . ((int) $rowid);
959 if (!$this->db->query($sql)) {
963 $parameters = array(
'rowid' => $rowid,
'position' => $position);
965 $reshook = $hookmanager->executeHooks(
'afterPositionOfAttributeUpdate', $parameters, $this, $action);
966 return ($reshook >= 0 ? 1 : -1);
978 $sql =
"SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element;
979 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
982 $resql = $this->db->query($sql);
984 $row = $this->db->fetch_row($resql);
1041 if ($position > 1) {
1042 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1043 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1044 $sql .=
" AND position = " . ((int) ($position - 1));
1045 if ($this->db->query($sql)) {
1046 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position - 1));
1047 $sql .=
" WHERE rowid = " . ((int) $rowid);
1048 if (!$this->db->query($sql)) {
1067 if ($position < $max) {
1068 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) $position);
1069 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1070 $sql .=
" AND position = " . ((int) ($position + 1));
1071 if ($this->db->query($sql)) {
1072 $sql =
"UPDATE " . MAIN_DB_PREFIX . $this->table_element .
" SET position = " . ((int) ($position + 1));
1073 $sql .=
" WHERE rowid = " . ((int) $rowid);
1074 if (!$this->db->query($sql)) {
1091 $sql =
"SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element;
1092 $sql .=
" WHERE entity IN (" .
getEntity(
'product') .
")";
1095 $resql = $this->db->query($sql);
1097 $row = $this->db->fetch_row($resql);
1112 $num = count($rows);
1113 for ($i = 0; $i < $num; $i++) {
1128 public function getNomUrl($withpicto = 0, $option =
'', $notooltip = 0, $morecss =
'', $save_lastsearch_value = -1)
1130 global
$conf, $langs, $hookmanager;
1132 if (!empty(
$conf->dol_no_mouse_hover)) {
1138 $label =
img_picto(
'', $this->picto) .
' <u>' . $langs->trans(
"ProductAttribute") .
'</u>';
1139 if (isset($this->
status)) {
1143 $label .=
'<b>' . $langs->trans(
'Ref') .
':</b> ' . $this->ref;
1144 if (!empty($this->label)) {
1145 $label .=
'<br><b>' . $langs->trans(
'Label') .
':</b> ' . $this->label;
1148 $url =
dol_buildpath(
'/variants/card.php', 1) .
'?id=' . $this->id;
1150 if ($option !=
'nolink') {
1152 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
1153 if ($save_lastsearch_value == -1 && isset($_SERVER[
"PHP_SELF"]) && preg_match(
'/list\.php/', $_SERVER[
"PHP_SELF"])) {
1154 $add_save_lastsearch_values = 1;
1156 if ($url && $add_save_lastsearch_values) {
1157 $url .=
'&save_lastsearch_values=1';
1162 if (empty($notooltip)) {
1164 $label = $langs->trans(
"ShowProductAttribute");
1168 $linkclose .=
' class="classfortooltip' . ($morecss ?
' ' . $morecss :
'') .
'"';
1170 $linkclose = ($morecss ?
' class="' . $morecss .
'"' :
'');
1173 if ($option ==
'nolink' || empty($url)) {
1174 $linkstart =
'<span';
1176 $linkstart =
'<a href="' . $url .
'"';
1178 $linkstart .= $linkclose .
'>';
1179 if ($option ==
'nolink' || empty($url)) {
1180 $linkend =
'</span>';
1185 $result .= $linkstart;
1187 if (empty($this->showphoto_on_popup)) {
1189 $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);
1193 require_once DOL_DOCUMENT_ROOT .
'/core/lib/files.lib.php';
1195 list($class, $module) = explode(
'@', $this->picto);
1198 $filename = $filearray[0][
'name'];
1199 if (!empty($filename)) {
1200 $pospoint = strpos($filearray[0][
'name'],
'.');
1202 $pathtophoto = $class .
'/' . $this->
ref .
'/thumbs/' . substr($filename, 0, $pospoint) .
'_mini' . substr($filename, $pospoint);
1203 if (!
getDolGlobalString(strtoupper($module .
'_' . $class) .
'_FORMATLISTPHOTOSASUSERS')) {
1204 $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>';
1206 $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>';
1209 $result .=
'</div>';
1211 $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);
1216 if ($withpicto != 2) {
1217 $result .= $this->ref;
1220 $result .= $linkend;
1223 global $action, $hookmanager;
1224 $hookmanager->initHooks(array(
'variantsdao'));
1225 $parameters = array(
'id' => $this->
id,
'getnomurl' => $result);
1226 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1228 $result = $hookmanager->resPrint;
1230 $result .= $hookmanager->resPrint;
1245 $selected = (empty($arraydata[
'selected']) ? 0 : $arraydata[
'selected']);
1247 $return =
'<div class="box-flex-item box-flex-grow-zero">';
1248 $return .=
'<div class="info-box info-box-sm">';
1249 $return .=
'<span class="info-box-icon bg-infobox-action">';
1251 $return .=
'</span>';
1252 $return .=
'<div class="info-box-content">';
1253 $return .=
'<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this,
'getNomUrl') ? $this->
getNomUrl() : $this->ref).
'</span>';
1254 if ($selected >= 0) {
1255 $return .=
'<input id="cb'.$this->id.
'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->
id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
1257 if (property_exists($this,
'label')) {
1258 $return .=
' <div class="inline-block opacitymedium valignmiddle tdoverflowmax100">'.$this->label.
'</div>';
1260 if (property_exists($this,
'thirdparty') && is_object($this->thirdparty)) {
1261 $return .=
'<br><div class="info-box-ref tdoverflowmax150">'.$this->thirdparty->getNomUrl(1).
'</div>';
1263 if (method_exists($this,
'getLibStatut')) {
1264 $return .=
'<br><div class="info-box-status">'.$this->getLibStatut(3).
'</div>';
1266 $return .=
'</div>';
1267 $return .=
'</div>';
1268 $return .=
'</div>';
1332 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array($defaulttpldir));
1333 foreach ($dirtpls as $module => $reldir) {
1334 if (!empty($module)) {
1335 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_create.tpl.php');
1337 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_create.tpl.php';
1340 if (empty(
$conf->file->strict_mode)) {
1341 $res = @include $tpl;
1343 $res = include $tpl;
1368 public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir =
'/variants/tpl', $addcreateline = 0)
1370 global
$conf, $hookmanager, $langs, $user, $form,
$object;
1373 global $disableedit, $disablemove, $disableremove;
1375 $num = count($this->lines);
1377 $parameters = array(
'num' => $num,
'selected' => $selected,
'table_element_line' => $this->table_element_line);
1378 $reshook = $hookmanager->executeHooks(
'printObjectLineTitle', $parameters, $this, $action);
1379 if (empty($reshook)) {
1383 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array($defaulttpldir));
1384 foreach ($dirtpls as $module => $reldir) {
1385 if (!empty($module)) {
1386 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_title.tpl.php');
1388 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_title.tpl.php';
1390 if (empty(
$conf->file->strict_mode)) {
1391 $res = @include $tpl;
1393 $res = include $tpl;
1402 if ($addcreateline) {
1404 if ($action !=
'selectlines') {
1405 if ($action !=
'editline') {
1408 $parameters = array();
1409 $reshook = $hookmanager->executeHooks(
'formAddObjectLine', $parameters,
$object, $action);
1413 if (empty($reshook)) {
1414 $object->formAddObjectLine(1, $mysoc, $buyer);
1422 print
"<!-- begin printObjectLines() -->\n";
1423 foreach ($this->lines as $line) {
1424 if (is_object($hookmanager)) {
1425 $parameters = array(
'line' => $line,
'num' => $num,
'i' => $i,
'selected' => $selected,
'table_element_line' => $line->table_element);
1426 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $this, $action);
1428 if (empty($reshook)) {
1429 $this->
printObjectLine($action, $line,
'', $num, $i, $dateSelector, $seller, $buyer, $selected,
null, $defaulttpldir);
1434 print
"<!-- end printObjectLines() -->\n";
1454 public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields =
null, $defaulttpldir =
'/variants/tpl')
1458 global $disableedit, $disablemove, $disableremove;
1461 if ($action !=
'editline' || $selected != $line->id) {
1465 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array($defaulttpldir));
1466 foreach ($dirtpls as $module => $reldir) {
1467 if (!empty($module)) {
1468 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_view.tpl.php');
1470 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_view.tpl.php';
1473 if (empty(
$conf->file->strict_mode)) {
1474 $res = @include $tpl;
1476 $res = include $tpl;
1485 if ($action ==
'editline' && $selected == $line->id) {
1489 $dirtpls = array_merge(
$conf->modules_parts[
'tpl'], array($defaulttpldir));
1490 foreach ($dirtpls as $module => $reldir) {
1491 if (!empty($module)) {
1492 $tpl =
dol_buildpath($reldir .
'/productattributevalueline_edit.tpl.php');
1494 $tpl = DOL_DOCUMENT_ROOT . $reldir .
'/productattributevalueline_edit.tpl.php';
1497 if (empty(
$conf->file->strict_mode)) {
1498 $res = @include $tpl;
1500 $res = include $tpl;
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Parent class of all other business classes (invoices, contracts, proposals, orders,...
fetch_optionals($rowid=null, $optionsArray=null)
Function to get extra fields of an object into $this->array_options This method is in most cases call...
errorsToString()
Method to output saved errors.
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
insertExtraFields($trigger='', $userused=null)
Add/Update all extra fields values for the current object.
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.
print $langs trans("Ref").' m titre as m m statut as status
Or an array listing all the potential status of the object: array: int of the status => translated la...
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)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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 a 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...