dolibarr  16.0.5
ProductAttribute.class.php
1 <?php
2 
3 /* Copyright (C) 2016 Marcos GarcĂ­a <marcosgdf@gmail.com>
4  * Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
26 {
31  public $db;
35  public $module = 'variants';
36 
40  public $element = 'productattribute';
41 
45  public $table_element = 'product_attribute';
46 
50  public $table_element_line = 'product_attribute_value';
51 
55  public $fk_element = 'fk_product_attribute';
56 
61  public $ismultientitymanaged = 1;
62 
66  public $isextrafieldmanaged = 0;
67 
71  public $picto = 'product';
72 
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,),
107  );
108  public $id;
109  public $ref;
110  public $ref_ext;
111  public $label;
112  public $position;
113 
117  public $lines = array();
121  public $line;
122 
123 
129  public function __construct(DoliDB $db)
130  {
131  global $conf, $langs;
132 
133  $this->db = $db;
134  $this->entity = $conf->entity;
135 
136  if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
137  $this->fields['rowid']['visible'] = 0;
138  }
139  if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) {
140  $this->fields['entity']['enabled'] = 0;
141  }
142 
143  // Unset fields that are disabled
144  foreach ($this->fields as $key => $val) {
145  if (isset($val['enabled']) && empty($val['enabled'])) {
146  unset($this->fields[$key]);
147  }
148  }
149 
150  // Translate some data of arrayofkeyval
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);
156  }
157  }
158  }
159  }
160  }
161 
169  public function create(User $user, $notrigger = 0)
170  {
171  global $langs;
172  $error = 0;
173 
174  // Clean parameters
175  $this->ref = strtoupper(dol_sanitizeFileName(dol_string_nospecial(trim($this->ref)))); // Ref must be uppercase
176  $this->label = trim($this->label);
177  $this->position = $this->position > 0 ? $this->position : 0;
178 
179  // Position to use
180  if (empty($this->position)) {
181  $positionmax = $this->getMaxAttributesPosition();
182  $this->position = $positionmax + 1;
183  }
184 
185  // Check parameters
186  if (empty($this->ref)) {
187  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref"));
188  $error++;
189  }
190  if (empty($this->label)) {
191  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label"));
192  $error++;
193  }
194  if ($error) {
195  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
196  return -1;
197  }
198 
199  $this->db->begin();
200 
201  $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . " (";
202  $sql .= " ref, ref_ext, label, entity, position";
203  $sql .= ")";
204  $sql .= " VALUES (";
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);
210  $sql .= ")";
211 
212  dol_syslog(__METHOD__, LOG_DEBUG);
213  $resql = $this->db->query($sql);
214  if (!$resql) {
215  $this->errors[] = "Error " . $this->db->lasterror();
216  $error++;
217  }
218 
219  if (!$error) {
220  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element);
221  }
222 
223  if (!$error && !$notrigger) {
224  // Call trigger
225  $result = $this->call_trigger('PRODUCT_ATTRIBUTE_CREATE', $user);
226  if ($result < 0) {
227  $error++;
228  }
229  // End call triggers
230  }
231 
232  if (!$error) {
233  $this->db->commit();
234  return $this->id;
235  } else {
236  $this->db->rollback();
237  return -1 * $error;
238  }
239  }
240 
247  public function fetch($id)
248  {
249  global $langs;
250  $error = 0;
251 
252  // Clean parameters
253  $id = $id > 0 ? $id : 0;
254 
255  // Check parameters
256  if (empty($id)) {
257  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
258  $error++;
259  }
260  if ($error) {
261  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
262  return -1;
263  }
264 
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') . ")";
269 
270  dol_syslog(__METHOD__, LOG_DEBUG);
271  $resql = $this->db->query($sql);
272  if (!$resql) {
273  $this->errors[] = "Error " . $this->db->lasterror();
274  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
275  return -1;
276  }
277 
278  $numrows = $this->db->num_rows($resql);
279  if ($numrows) {
280  $obj = $this->db->fetch_object($resql);
281 
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; // deprecated
287  $this->position = $obj->position;
288  }
289  $this->db->free($resql);
290 
291  return $numrows;
292  }
293 
299  public function fetchAll()
300  {
301  $return = array();
302 
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");
307 
308  dol_syslog(__METHOD__, LOG_DEBUG);
309  $resql = $this->db->query($sql);
310  if (!$resql) {
311  $this->errors[] = "Error " . $this->db->lasterror();
312  dol_print_error($this->db);
313  return $return;
314  }
315 
316  while ($obj = $this->db->fetch_object($resql)) {
317  $tmp = new ProductAttribute($this->db);
318 
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; // deprecated
324  $tmp->position = $obj->position;
325 
326  $return[] = $tmp;
327  }
328 
329  return $return;
330  }
331 
339  public function update(User $user, $notrigger = 0)
340  {
341  global $langs;
342  $error = 0;
343 
344  // Clean parameters
345  $this->id = $this->id > 0 ? $this->id : 0;
346  $this->ref = strtoupper(dol_sanitizeFileName(dol_string_nospecial(trim($this->ref)))); // Ref must be uppercase
347  $this->label = trim($this->label);
348 
349  // Check parameters
350  if (empty($this->id)) {
351  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
352  $error++;
353  }
354  if (empty($this->ref)) {
355  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref"));
356  $error++;
357  }
358  if (empty($this->label)) {
359  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Label"));
360  $error++;
361  }
362  if ($error) {
363  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
364  return -1;
365  }
366 
367  $this->db->begin();
368 
369  $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET";
370 
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);
375 
376  $sql .= " WHERE rowid = " . ((int) $this->id);
377 
378  dol_syslog(__METHOD__, LOG_DEBUG);
379  $resql = $this->db->query($sql);
380  if (!$resql) {
381  $this->errors[] = "Error " . $this->db->lasterror();
382  $error++;
383  }
384 
385  if (!$error && !$notrigger) {
386  // Call trigger
387  $result = $this->call_trigger('PRODUCT_ATTRIBUTE_MODIFY', $user);
388  if ($result < 0) {
389  $error++;
390  }
391  // End call triggers
392  }
393 
394  if (!$error) {
395  $this->db->commit();
396  return 1;
397  } else {
398  $this->db->rollback();
399  return -1 * $error;
400  }
401  }
402 
410  public function delete(User $user, $notrigger = 0)
411  {
412  global $langs;
413  $error = 0;
414 
415  // Clean parameters
416  $this->id = $this->id > 0 ? $this->id : 0;
417 
418  // Check parameters
419  if (empty($this->id)) {
420  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
421  $error++;
422  }
423  if ($error) {
424  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
425  return -1;
426  }
427 
428  $result = $this->isUsed();
429  if ($result < 0) {
430  return -1;
431  } elseif ($result > 0) {
432  $this->errors[] = $langs->trans('ErrorAttributeIsUsedIntoProduct');
433  return -1;
434  }
435 
436  $this->db->begin();
437 
438  if (!$notrigger) {
439  // Call trigger
440  $result = $this->call_trigger('PRODUCT_ATTRIBUTE_DELETE', $user);
441  if ($result < 0) {
442  $error++;
443  }
444  // End call triggers
445  }
446 
447  if (!$error) {
448  // Delete values
449  $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element_line;
450  $sql .= " WHERE " . $this->fk_element . " = " . ((int) $this->id);
451 
452  dol_syslog(__METHOD__ . ' - Delete values', LOG_DEBUG);
453  $resql = $this->db->query($sql);
454  if (!$resql) {
455  $this->errors[] = "Error " . $this->db->lasterror();
456  $error++;
457  }
458  }
459 
460  if (!$error) {
461  $sql = "DELETE FROM " . MAIN_DB_PREFIX . $this->table_element;
462  $sql .= " WHERE rowid = " . ((int) $this->id);
463 
464  dol_syslog(__METHOD__ . ' - Delete attribute', LOG_DEBUG);
465  $resql = $this->db->query($sql);
466  if (!$resql) {
467  $this->errors[] = "Error " . $this->db->lasterror();
468  $error++;
469  }
470  }
471 
472  if (!$error) {
473  $this->db->commit();
474  return 1;
475  } else {
476  $this->db->rollback();
477  return -1 * $error;
478  }
479  }
480 
481  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
488  public function fetch_lines($filters = '')
489  {
490  // phpcs:enable
491  global $langs;
492 
493  $this->lines = array();
494 
495  $error = 0;
496 
497  // Clean parameters
498  $this->id = $this->id > 0 ? $this->id : 0;
499 
500  // Check parameters
501  if (empty($this->id)) {
502  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
503  $error++;
504  }
505  if ($error) {
506  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
507  return -1;
508  }
509 
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') . ")";
515  if ($filters) {
516  $sql .= $filters;
517  }
518  $sql .= $this->db->order("td.position", "asc");
519 
520  dol_syslog(__METHOD__, LOG_DEBUG);
521  $resql = $this->db->query($sql);
522  if (!$resql) {
523  $this->errors[] = "Error " . $this->db->lasterror();
524  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
525  return -3;
526  }
527 
528  $num = $this->db->num_rows($resql);
529  if ($num) {
530  $i = 0;
531  while ($i < $num) {
532  $obj = $this->db->fetch_object($resql);
533 
534  $line = new ProductAttributeValue($this->db);
535 
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;
541 
542  $this->lines[$i] = $line;
543  $i++;
544  }
545  }
546  $this->db->free($resql);
547 
548  return $num;
549  }
550 
557  public function getLinesArray($filters = '')
558  {
559  return $this->fetch_lines($filters);
560  }
561 
575  public function addLine($ref, $value, $position = -1, $notrigger = 0)
576  {
577  global $langs, $user;
578  dol_syslog(__METHOD__ . " id={$this->id}, ref=$ref, value=$value, notrigger=$notrigger");
579  $error = 0;
580 
581  // Clean parameters
582  $this->id = $this->id > 0 ? $this->id : 0;
583 
584  // Check parameters
585  if (empty($this->id)) {
586  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
587  $error++;
588  }
589  if ($error) {
590  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
591  return -1;
592  }
593 
594  $this->db->begin();
595 
596  //Fetch current line from the database and then clone the object and set it in $oldcopy property
597  $this->line = new ProductAttributeValue($this->db);
598 
599  // Position to use
600  $positiontouse = $position;
601  if ($positiontouse == -1) {
602  $positionmax = $this->line_max(0);
603  $positiontouse = $positionmax + 1;
604  }
605 
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;
611 
612  $result = $this->line->create($user, $notrigger);
613 
614  if ($result < 0) {
615  $this->error = $this->line->error;
616  $this->errors = $this->line->errors;
617  $this->db->rollback();
618  return -1;
619  } else {
620  $this->db->commit();
621  return $this->line->id;
622  }
623  }
624 
625 
635  public function updateLine($lineid, $ref, $value, $notrigger = 0)
636  {
637  global $user;
638 
639  dol_syslog(__METHOD__ . " lineid=$lineid, ref=$ref, value=$value, notrigger=$notrigger");
640 
641  // Clean parameters
642  $lineid = $lineid > 0 ? $lineid : 0;
643 
644  $this->db->begin();
645 
646  //Fetch current line from the database and then clone the object and set it in $oldcopy property
647  $this->line = new ProductAttributeValue($this->db);
648  $result = $this->line->fetch($lineid);
649  if ($result > 0) {
650  $this->line->oldcopy = clone $this->line;
651 
652  $this->line->context = $this->context;
653  $this->line->ref = $ref;
654  $this->line->value = $value;
655 
656  $result = $this->line->update($user, $notrigger);
657  }
658 
659  if ($result < 0) {
660  $this->error = $this->line->error;
661  $this->errors = $this->line->errors;
662  $this->db->rollback();
663  return -1;
664  } else {
665  $this->db->commit();
666  return $result;
667  }
668  }
669 
678  public function deleteLine(User $user, $lineid, $notrigger = 0)
679  {
680  dol_syslog(__METHOD__ . " lineid=$lineid, notrigger=$notrigger");
681 
682  // Clean parameters
683  $lineid = $lineid > 0 ? $lineid : 0;
684 
685  $this->db->begin();
686 
687  //Fetch current line from the database
688  $this->line = new ProductAttributeValue($this->db);
689  $result = $this->line->fetch($lineid);
690  if ($result > 0) {
691  $this->line->context = $this->context;
692 
693  $result = $this->line->delete($user, $notrigger);
694  }
695 
696  if ($result < 0) {
697  $this->error = $this->line->error;
698  $this->errors = $this->line->errors;
699  $this->db->rollback();
700  return -1;
701  } else {
702  $this->db->commit();
703  return $result;
704  }
705  }
706 
712  public function countChildValues()
713  {
714  global $langs;
715  $error = 0;
716  $count = 0;
717 
718  // Clean parameters
719  $this->id = $this->id > 0 ? $this->id : 0;
720 
721  // Check parameters
722  if (empty($this->id)) {
723  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
724  $error++;
725  }
726  if ($error) {
727  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
728  return -1;
729  }
730 
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);
734 
735  dol_syslog(__METHOD__, LOG_DEBUG);
736  $resql = $this->db->query($sql);
737  if (!$resql) {
738  $this->errors[] = "Error " . $this->db->lasterror();
739  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
740  return -1;
741  }
742 
743  if ($obj = $this->db->fetch_object($resql)) {
744  $count = $obj->count;
745  }
746 
747  return $count;
748  }
749 
755  public function countChildProducts()
756  {
757  global $langs;
758  $error = 0;
759  $count = 0;
760 
761  // Clean parameters
762  $this->id = $this->id > 0 ? $this->id : 0;
763 
764  // Check parameters
765  if (empty($this->id)) {
766  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
767  $error++;
768  }
769  if ($error) {
770  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
771  return -1;
772  }
773 
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') . ")";
779 
780  dol_syslog(__METHOD__, LOG_DEBUG);
781  $resql = $this->db->query($sql);
782  if (!$resql) {
783  $this->errors[] = "Error " . $this->db->lasterror();
784  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
785  return -1;
786  }
787 
788  if ($obj = $this->db->fetch_object($resql)) {
789  $count = $obj->count;
790  }
791 
792  return $count;
793  }
794 
800  public function isUsed()
801  {
802  global $langs;
803  $error = 0;
804 
805  // Clean parameters
806  $this->id = $this->id > 0 ? $this->id : 0;
807 
808  // Check parameters
809  if (empty($this->id)) {
810  $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("TechnicalID"));
811  $error++;
812  }
813  if ($error) {
814  dol_syslog(__METHOD__ . ' ' . $this->errorsToString(), LOG_ERR);
815  return -1;
816  }
817 
818  $sql = "SELECT COUNT(*) AS nb FROM " . MAIN_DB_PREFIX . "product_attribute_combination2val WHERE fk_prod_attr = " . ((int) $this->id);
819 
820  dol_syslog(__METHOD__, LOG_DEBUG);
821  $resql = $this->db->query($sql);
822  if (!$resql) {
823  $this->errors[] = "Error " . $this->db->lasterror();
824  return -1;
825  }
826 
827  $used = 0;
828  if ($obj = $this->db->fetch_object($resql)) {
829  $used = $obj->nb;
830  }
831 
832  return $used ? 1 : 0;
833  }
834 
843  public function attributeOrder($renum = false, $rowidorder = 'ASC')
844  {
845  // Count number of attributes to reorder (according to choice $renum)
846  $nl = 0;
847  $sql = "SELECT count(rowid) FROM " . MAIN_DB_PREFIX . $this->table_element;
848  $sql .= " WHERE entity IN (" . getEntity('product') . ")";
849  if (!$renum) {
850  $sql .= " AND position = 0";
851  } else {
852  $sql .= " AND position <> 0";
853  }
854 
855  dol_syslog(__METHOD__, LOG_DEBUG);
856  $resql = $this->db->query($sql);
857  if ($resql) {
858  $row = $this->db->fetch_row($resql);
859  $nl = $row[0];
860  } else {
861  dol_print_error($this->db);
862  }
863  if ($nl > 0) {
864  // The goal of this part is to reorder all attributes.
865  $rows = array();
866 
867  // We first search all attributes
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;
871 
872  dol_syslog(__METHOD__ . " search all attributes", LOG_DEBUG);
873  $resql = $this->db->query($sql);
874  if ($resql) {
875  $i = 0;
876  $num = $this->db->num_rows($resql);
877  while ($i < $num) {
878  $row = $this->db->fetch_row($resql);
879  $rows[] = $row[0]; // Add attributes into array rows
880  $i++;
881  }
882 
883  // Now we set a new number for each attributes
884  if (!empty($rows)) {
885  foreach ($rows as $key => $row) {
886  $this->updatePositionOfAttribute($row, ($key + 1));
887  }
888  }
889  } else {
890  dol_print_error($this->db);
891  }
892  }
893  return 1;
894  }
895 
903  public function updatePositionOfAttribute($rowid, $position)
904  {
905  global $hookmanager;
906 
907  $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET position = " . ((int) $position);
908  $sql .= " WHERE rowid = " . ((int) $rowid);
909 
910  dol_syslog(__METHOD__, LOG_DEBUG);
911  if (!$this->db->query($sql)) {
912  dol_print_error($this->db);
913  return -1;
914  } else {
915  $parameters = array('rowid' => $rowid, 'position' => $position);
916  $action = '';
917  $reshook = $hookmanager->executeHooks('afterPositionOfAttributeUpdate', $parameters, $this, $action);
918  return 1;
919  }
920  }
921 
928  public function getPositionOfAttribute($rowid)
929  {
930  $sql = "SELECT position FROM " . MAIN_DB_PREFIX . $this->table_element;
931  $sql .= " WHERE entity IN (" . getEntity('product') . ")";
932 
933  dol_syslog(__METHOD__, LOG_DEBUG);
934  $resql = $this->db->query($sql);
935  if ($resql) {
936  $row = $this->db->fetch_row($resql);
937  return $row[0];
938  }
939 
940  return 0;
941  }
942 
949  public function attributeMoveUp($rowid)
950  {
951  $this->attributeOrder(false, 'ASC');
952 
953  // Get position of attribute
954  $position = $this->getPositionOfAttribute($rowid);
955 
956  // Update position of attribute
957  $this->updateAttributePositionUp($rowid, $position);
958  }
959 
966  public function attributeMoveDown($rowid)
967  {
968  $this->attributeOrder(false, 'ASC');
969 
970  // Get position of line
971  $position = $this->getPositionOfAttribute($rowid);
972 
973  // Get max value for position
974  $max = $this->getMaxAttributesPosition();
975 
976  // Update position of attribute
977  $this->updateAttributePositionDown($rowid, $position, $max);
978  }
979 
987  public function updateAttributePositionUp($rowid, $position)
988  {
989  if ($position > 1) {
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)) {
997  dol_print_error($this->db);
998  }
999  } else {
1000  dol_print_error($this->db);
1001  }
1002  }
1003  }
1004 
1013  public function updateAttributePositionDown($rowid, $position, $max)
1014  {
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)) {
1023  dol_print_error($this->db);
1024  }
1025  } else {
1026  dol_print_error($this->db);
1027  }
1028  }
1029  }
1030 
1036  public function getMaxAttributesPosition()
1037  {
1038  // Search the last position of attributes
1039  $sql = "SELECT max(position) FROM " . MAIN_DB_PREFIX . $this->table_element;
1040  $sql .= " WHERE entity IN (" . getEntity('product') . ")";
1041 
1042  dol_syslog(__METHOD__, LOG_DEBUG);
1043  $resql = $this->db->query($sql);
1044  if ($resql) {
1045  $row = $this->db->fetch_row($resql);
1046  return $row[0];
1047  }
1048 
1049  return 0;
1050  }
1051 
1058  public function attributesAjaxOrder($rows)
1059  {
1060  $num = count($rows);
1061  for ($i = 0; $i < $num; $i++) {
1062  $this->updatePositionOfAttribute($rows[$i], ($i + 1));
1063  }
1064  }
1065 
1076  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
1077  {
1078  global $conf, $langs, $hookmanager;
1079 
1080  if (!empty($conf->dol_no_mouse_hover)) {
1081  $notooltip = 1; // Force disable tooltips
1082  }
1083 
1084  $result = '';
1085 
1086  $label = img_picto('', $this->picto) . ' <u>' . $langs->trans("ProductAttribute") . '</u>';
1087  if (isset($this->status)) {
1088  $label .= ' ' . $this->getLibStatut(5);
1089  }
1090  $label .= '<br>';
1091  $label .= '<b>' . $langs->trans('Ref') . ':</b> ' . $this->ref;
1092  if (!empty($this->label)) {
1093  $label .= '<br><b>' . $langs->trans('Label') . ':</b> ' . $this->label;
1094  }
1095 
1096  $url = dol_buildpath('/variants/card.php', 1) . '?id=' . $this->id;
1097 
1098  if ($option != 'nolink') {
1099  // Add param to save lastsearch_values or not
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;
1103  }
1104  if ($url && $add_save_lastsearch_values) {
1105  $url .= '&save_lastsearch_values=1';
1106  }
1107  }
1108 
1109  $linkclose = '';
1110  if (empty($notooltip)) {
1111  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1112  $label = $langs->trans("ShowProductAttribute");
1113  $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';
1114  }
1115  $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"';
1116  $linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"';
1117  } else {
1118  $linkclose = ($morecss ? ' class="' . $morecss . '"' : '');
1119  }
1120 
1121  if ($option == 'nolink' || empty($url)) {
1122  $linkstart = '<span';
1123  } else {
1124  $linkstart = '<a href="' . $url . '"';
1125  }
1126  $linkstart .= $linkclose . '>';
1127  if ($option == 'nolink' || empty($url)) {
1128  $linkend = '</span>';
1129  } else {
1130  $linkend = '</a>';
1131  }
1132 
1133  $result .= $linkstart;
1134 
1135  if (empty($this->showphoto_on_popup)) {
1136  if ($withpicto) {
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);
1138  }
1139  } else {
1140  if ($withpicto) {
1141  require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
1142 
1143  list($class, $module) = explode('@', $this->picto);
1144  $upload_dir = $conf->$module->multidir_output[$conf->entity] . "/$class/" . dol_sanitizeFileName($this->ref);
1145  $filearray = dol_dir_list($upload_dir, "files");
1146  $filename = $filearray[0]['name'];
1147  if (!empty($filename)) {
1148  $pospoint = strpos($filearray[0]['name'], '.');
1149 
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>';
1153  } else {
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>';
1155  }
1156 
1157  $result .= '</div>';
1158  } else {
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);
1160  }
1161  }
1162  }
1163 
1164  if ($withpicto != 2) {
1165  $result .= $this->ref;
1166  }
1167 
1168  $result .= $linkend;
1169  //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
1170 
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); // Note that $action and $object may have been modified by some hooks
1175  if ($reshook > 0) {
1176  $result = $hookmanager->resPrint;
1177  } else {
1178  $result .= $hookmanager->resPrint;
1179  }
1180 
1181  return $result;
1182  }
1183 
1190  public function getLabelStatus($mode = 0)
1191  {
1192  return $this->LibStatut(0, $mode);
1193  }
1194 
1201  public function getLibStatut($mode = 0)
1202  {
1203  return $this->LibStatut(0, $mode);
1204  }
1205 
1206  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
1214  public function LibStatut($status, $mode = 1)
1215  {
1216  // phpcs:enable
1217  return '';
1218  }
1219 
1220  // --------------------
1221  // TODO: All functions here must be redesigned and moved as they are not business functions but output functions
1222  // --------------------
1223 
1224  /* This is to show add lines */
1225 
1235  public function formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir = '/variants/tpl')
1236  {
1237  global $conf, $user, $langs, $object, $hookmanager;
1238  global $form;
1239 
1240  // Output template part (modules that overwrite templates must declare this into descriptor)
1241  // Use global variables + $dateSelector + $seller and $buyer
1242  // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook 'formAddObjectLine'.
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');
1247  } else {
1248  $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_create.tpl.php';
1249  }
1250 
1251  if (empty($conf->file->strict_mode)) {
1252  $res = @include $tpl;
1253  } else {
1254  $res = include $tpl; // for debug
1255  }
1256  if ($res) {
1257  break;
1258  }
1259  }
1260  }
1261 
1262  /* This is to show array of line of details */
1263 
1278  public function printObjectLines($action, $seller, $buyer, $selected = 0, $dateSelector = 0, $defaulttpldir = '/variants/tpl')
1279  {
1280  global $conf, $hookmanager, $langs, $user, $form, $object;
1281  // TODO We should not use global var for this
1282  global $disableedit, $disablemove, $disableremove;
1283 
1284  $num = count($this->lines);
1285 
1286  $parameters = array('num' => $num, 'selected' => $selected, 'table_element_line' => $this->table_element_line);
1287  $reshook = $hookmanager->executeHooks('printObjectLineTitle', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
1288  if (empty($reshook)) {
1289  // Output template part (modules that overwrite templates must declare this into descriptor)
1290  // Use global variables + $dateSelector + $seller and $buyer
1291  // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook.
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');
1296  } else {
1297  $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_title.tpl.php';
1298  }
1299  if (empty($conf->file->strict_mode)) {
1300  $res = @include $tpl;
1301  } else {
1302  $res = include $tpl; // for debug
1303  }
1304  if ($res) {
1305  break;
1306  }
1307  }
1308  }
1309 
1310  $i = 0;
1311 
1312  print "<!-- begin printObjectLines() --><tbody>\n";
1313  foreach ($this->lines as $line) {
1314  if (is_object($hookmanager)) { // Old code is commented on preceding line.
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); // Note that $action and $object may have been modified by some hooks
1317  }
1318  if (empty($reshook)) {
1319  $this->printObjectLine($action, $line, '', $num, $i, $dateSelector, $seller, $buyer, $selected, null, $defaulttpldir);
1320  }
1321 
1322  $i++;
1323  }
1324  print "</tbody><!-- end printObjectLines() -->\n";
1325  }
1326 
1344  public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/variants/tpl')
1345  {
1346  global $conf, $langs, $user, $object, $hookmanager;
1347  global $form;
1348  global $object_rights, $disableedit, $disablemove, $disableremove; // TODO We should not use global var for this !
1349 
1350  $object_rights = $user->rights->variants;
1351 
1352  // Line in view mode
1353  if ($action != 'editline' || $selected != $line->id) {
1354  // Output template part (modules that overwrite templates must declare this into descriptor)
1355  // Use global variables + $dateSelector + $seller and $buyer
1356  // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook printObjectLine and printObjectSubLine.
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');
1361  } else {
1362  $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_view.tpl.php';
1363  }
1364 
1365  if (empty($conf->file->strict_mode)) {
1366  $res = @include $tpl;
1367  } else {
1368  $res = include $tpl; // for debug
1369  }
1370  if ($res) {
1371  break;
1372  }
1373  }
1374  }
1375 
1376  // Line in update mode
1377  if ($action == 'editline' && $selected == $line->id) {
1378  // Output template part (modules that overwrite templates must declare this into descriptor)
1379  // Use global variables + $dateSelector + $seller and $buyer
1380  // Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook printObjectLine and printObjectSubLine.
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');
1385  } else {
1386  $tpl = DOL_DOCUMENT_ROOT . $reldir . '/productattributevalueline_edit.tpl.php';
1387  }
1388 
1389  if (empty($conf->file->strict_mode)) {
1390  $res = @include $tpl;
1391  } else {
1392  $res = include $tpl; // for debug
1393  }
1394  if ($res) {
1395  break;
1396  }
1397  }
1398  }
1399  }
1400 
1401  /* This is to show array of line of details of source object */
1402 }
db
$conf db
API class for accounts.
Definition: inc.php:41
ProductAttribute\fetchAll
fetchAll()
Returns an array of all product variants.
Definition: ProductAttribute.class.php:299
dol_escape_htmltag
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.
Definition: functions.lib.php:1468
ProductAttribute\attributeMoveUp
attributeMoveUp($rowid)
Update a attribute to have a higher position.
Definition: ProductAttribute.class.php:949
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
ProductAttribute\attributeMoveDown
attributeMoveDown($rowid)
Update a attribute to have a lower position.
Definition: ProductAttribute.class.php:966
DoliDB
Class to manage Dolibarr database access.
Definition: DoliDB.class.php:30
ProductAttribute\getPositionOfAttribute
getPositionOfAttribute($rowid)
Get position of attribute.
Definition: ProductAttribute.class.php:928
ProductAttribute\attributesAjaxOrder
attributesAjaxOrder($rows)
Update position of attributes with ajax.
Definition: ProductAttribute.class.php:1058
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
dol_buildpath
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Definition: functions.lib.php:1062
ProductAttributeValue
Class ProductAttributeValue Used to represent a product attribute value.
Definition: ProductAttributeValue.class.php:25
ref
$object ref
Definition: info.php:77
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
ProductAttribute\formAddObjectLine
formAddObjectLine($dateSelector, $seller, $buyer, $defaulttpldir='/variants/tpl')
Show add free and predefined products/services form.
Definition: ProductAttribute.class.php:1235
dol_dir_list
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.
Definition: files.lib.php:60
CommonObject
Parent class of all other business classes (invoices, contracts, proposals, orders,...
Definition: commonobject.class.php:44
ProductAttribute\update
update(User $user, $notrigger=0)
Updates a product attribute.
Definition: ProductAttribute.class.php:339
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
ProductAttribute\__construct
__construct(DoliDB $db)
Constructor.
Definition: ProductAttribute.class.php:129
ProductAttribute
Class ProductAttribute Used to represent a product attribute.
Definition: ProductAttribute.class.php:25
getEntity
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
Definition: functions.lib.php:148
dol_string_nospecial
dol_string_nospecial($str, $newstr='_', $badcharstoreplace='', $badcharstoremove='')
Clean a string from all punctuation characters to use it as a ref or login.
Definition: functions.lib.php:1376
ProductAttribute\fetch
fetch($id)
Fetches the properties of a product attribute.
Definition: ProductAttribute.class.php:247
ProductAttribute\isUsed
isUsed()
Test if used by a product.
Definition: ProductAttribute.class.php:800
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
ProductAttribute\LibStatut
LibStatut($status, $mode=1)
Return label of a status.
Definition: ProductAttribute.class.php:1214
ProductAttribute\updateAttributePositionDown
updateAttributePositionDown($rowid, $position, $max)
Update position of attribute (down)
Definition: ProductAttribute.class.php:1013
CommonObject\line_max
line_max($fk_parent_line=0)
Get max value used for position of line (rang)
Definition: commonobject.class.php:3373
ProductAttribute\getLinesArray
getLinesArray($filters='')
Retrieve an array of proposal lines.
Definition: ProductAttribute.class.php:557
ProductAttribute\getMaxAttributesPosition
getMaxAttributesPosition()
Get max value used for position of attributes.
Definition: ProductAttribute.class.php:1036
ProductAttribute\fetch_lines
fetch_lines($filters='')
Load array lines.
Definition: ProductAttribute.class.php:488
ProductAttribute\getLabelStatus
getLabelStatus($mode=0)
Return the label of the status.
Definition: ProductAttribute.class.php:1190
User
Class to manage Dolibarr users.
Definition: user.class.php:44
ProductAttribute\updateAttributePositionUp
updateAttributePositionUp($rowid, $position)
Update position of attribute (up)
Definition: ProductAttribute.class.php:987
ProductAttribute\create
create(User $user, $notrigger=0)
Creates a product attribute.
Definition: ProductAttribute.class.php:169
ProductAttribute\updatePositionOfAttribute
updatePositionOfAttribute($rowid, $position)
Update position of line (rang)
Definition: ProductAttribute.class.php:903
ProductAttribute\deleteLine
deleteLine(User $user, $lineid, $notrigger=0)
Delete a line.
Definition: ProductAttribute.class.php:678
ProductAttribute\getLibStatut
getLibStatut($mode=0)
Return label of status of product attribute.
Definition: ProductAttribute.class.php:1201
ProductAttribute\getNomUrl
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return a link to the object card (with optionaly the picto)
Definition: ProductAttribute.class.php:1076
img_object
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Definition: functions.lib.php:4211
$resql
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.
Definition: index.php:742
ProductAttribute\attributeOrder
attributeOrder($renum=false, $rowidorder='ASC')
Save a new position (field position) for details lines.
Definition: ProductAttribute.class.php:843
ProductAttribute\countChildValues
countChildValues()
Returns the number of values for this attribute.
Definition: ProductAttribute.class.php:712
ProductAttribute\countChildProducts
countChildProducts()
Returns the number of products that are using this attribute.
Definition: ProductAttribute.class.php:755
CommonObject\call_trigger
call_trigger($triggerName, $user)
Call trigger based on this instance.
Definition: commonobject.class.php:5791
CommonObject\errorsToString
errorsToString()
Method to output saved errors.
Definition: commonobject.class.php:659
ProductAttribute\addLine
addLine($ref, $value, $position=-1, $notrigger=0)
Definition: ProductAttribute.class.php:575
ProductAttribute\printObjectLine
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....
Definition: ProductAttribute.class.php:1344
ProductAttribute\updateLine
updateLine($lineid, $ref, $value, $notrigger=0)
Update a line.
Definition: ProductAttribute.class.php:635
ProductAttribute\printObjectLines
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....
Definition: ProductAttribute.class.php:1278