From 09807706f0459de88bdc8331f7986b6293babc7d Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 23 Apr 2021 14:51:02 +0200 Subject: [PATCH 01/21] first try on productlot traceability fields --- htdocs/core/class/html.form.class.php | 41 +++++++++++++++++++++++ htdocs/product/card.php | 5 +++ htdocs/product/stock/productlot_card.php | 42 ++++++++++++++++++++++++ 3 files changed, 88 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 835810ff065..e7bff68ccee 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5742,6 +5742,47 @@ class Form } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load into the cache productbatch status + * + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + */ + public function load_cache_productbatch_status() + { + // phpcs:enable + global $langs; + + $num = count($this->cache_vatrates); + if ($num > 0) { + return $num; // Cache already loaded + } + + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = "SELECT s.rowid, s.code, s.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_status as c"; + $sql .= " WHERE t.active > 0"; + $sql .= " ORDER BY c.code ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + if ($num) { + for ($i = 0; $i < $num; $i++) { + $obj = $this->db->fetch_object($resql); + $this->cache_status[$i]['rowid'] = $obj->rowid; + $this->cache_status[$i]['code'] = $obj->code; + $this->cache_status[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or * + } + return $num; + } + } else { + $this->error = ''.$this->db->error().''; + return -2; + } + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output an HTML select vat rate. diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 64e5b844cb0..f3dc87f41ba 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1294,6 +1294,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } + // Traceability + if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + print ''.$langs->trans("LifeTime").''; + print ''.$langs->trans("QCFrequency").''; + } // Other attributes $parameters = array('colspan' => 3, 'cols' => '3'); diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 646f3d322d7..b797d7bccc7 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -428,6 +428,48 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; } + // Traceability info + if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + print ''; + print $form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print ''; + print ''; + print $form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print ''; + print ''; + print $form->editfieldkey($langs->trans('DestructionDate'), 'destruction_date', $object->destruction_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('DestructionDate'), 'destruction_date', $object->destruction_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print ''; + print ''; + print $form->editfieldkey($langs->trans('FirstUseDate'), 'first_use_date', $object->first_use_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print $form->editfieldval($langs->trans('FirstUseDate'), 'first_use_date', $object->first_use_date, $object, $user->rights->stock->creer, 'datepicker'); + print ''; + print ''; + print ''; + print $form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string'); + print ''; + print $form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string'); + print ''; + print ''; + $form->load_cache_productbatch_status(); + print ''; + print $form->editfieldkey($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->status], $object, $user->rights->stock->creer, 'select:productbatch_status'); + print ''; + print $form->editfieldval($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->status], $object, $user->rights->stock->creer, 'select:productbatch_status'); + print ''; + print ''; + /*print ''.$langs->trans("Status").'select à voir';*/ + } + // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; From 99df144e04994ff59fc869db9481dac40df55351 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 27 Apr 2021 15:28:39 +0200 Subject: [PATCH 02/21] edit traceability fields in productlot card --- htdocs/core/class/html.form.class.php | 41 ----- .../product/class/html.formproduct.class.php | 125 +++++++++++++++ .../product/stock/class/productlot.class.php | 45 ++++++ htdocs/product/stock/productlot_card.php | 149 ++++++++++++++---- 4 files changed, 284 insertions(+), 76 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e7bff68ccee..835810ff065 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -5742,47 +5742,6 @@ class Form } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load into the cache productbatch status - * - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO - */ - public function load_cache_productbatch_status() - { - // phpcs:enable - global $langs; - - $num = count($this->cache_vatrates); - if ($num > 0) { - return $num; // Cache already loaded - } - - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = "SELECT s.rowid, s.code, s.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_status as c"; - $sql .= " WHERE t.active > 0"; - $sql .= " ORDER BY c.code ASC"; - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - if ($num) { - for ($i = 0; $i < $num; $i++) { - $obj = $this->db->fetch_object($resql); - $this->cache_status[$i]['rowid'] = $obj->rowid; - $this->cache_status[$i]['code'] = $obj->code; - $this->cache_status[$i]['label'] = $obj->taux.'%'.($obj->code ? ' ('.$obj->code.')' : ''); // Label must contains only 0-9 , . % or * - } - return $num; - } - } else { - $this->error = ''.$this->db->error().''; - return -2; - } - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Output an HTML select vat rate. diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 718acef6970..bfddbc024db 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -672,4 +672,129 @@ class FormProduct } } } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return select list of productbatch status + * + * @param string $selected Id or Code of preselected incoterm + * @param string $page Defined the form action + * @param string $htmlname Name of html select object + * @param string $htmloption Options html on select object + * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) + * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) + * @return string HTML string with select and input + */ + public function select_productbatch_status($selected = '', $page = '', $htmlname = 'fk_status', $htmloption = '', $forcecombo = 1, $events = array()) + { + // phpcs:enable + global $conf, $langs; + + $langs->load("dict"); + + $out = ''; + $statusArray = array(); + + $sql = "SELECT code, label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_status"; + $sql .= " WHERE active > 0"; + $sql .= " ORDER BY code ASC"; + + dol_syslog(get_class($this)."::select_productbatch_status", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) { + if ($conf->use_javascript_ajax && !$forcecombo) { + include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; + $out .= ajax_combobox($htmlname, $events); + } + + if (!empty($page)) { + $out .= '
'; + $out .= ''; + $out .= ''; + } + + $out .= ''; + + // if ($user->admin) { + $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + // } + + if (!empty($page)) { + $out .= '
'; + } + } else { + dol_print_error($this->db); + } + + return $out; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Load into the cache productbatch status + * + * @return int Nb of loaded lines, 0 if already loaded, <0 if KO + */ + public function load_cache_productbatch_status() + { + // phpcs:enable + global $langs; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $sql = "SELECT s.rowid, s.code, s.label"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_status as s"; + $sql .= " WHERE s.active > 0"; + $sql .= " ORDER BY s.code ASC"; + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $obj = $this->db->fetch_object($resql); + + // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label)); + $this->cache_productbatch_status[$obj->code] = $label; + $i++; + } + + asort($this->cache_productbatch_status); + + return $num; + } else { + dol_print_error($this->db); + return -1; + } + } + } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index f05d6ebc168..fb9a6b5815c 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -91,6 +91,12 @@ class Productlot extends CommonObject 'batch' => array('type'=>'varchar(30)', 'label'=>'Batch', 'enabled'=>1, 'visible'=>1, 'notnull'=>0, 'showoncombobox'=>1, 'index'=>1, 'position'=>10, 'comment'=>'Batch', 'searchall'=>1), 'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>1, 'visible'=>0, 'default'=>1, 'notnull'=>1, 'index'=>1, 'position'=>20), 'sellby' => array('type'=>'date', 'label'=>'SellByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_SELLBY)?1:0', 'visible'=>5, 'position'=>60), + 'eol_date' => array('type'=>'date', 'label'=>'EndOfLife', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>70), + 'manufacturing_date' => array('type'=>'date', 'label'=>'ManufacturingDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>80), + 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>90), + 'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>100), + 'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>110), + 'fk_status' => array('type'=>'varchar(6)', 'label'=>'Status', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>120), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), @@ -112,6 +118,12 @@ class Productlot extends CommonObject public $batch; public $eatby = ''; public $sellby = ''; + public $eol_date = ''; + public $manufacturing_date = ''; + public $scrapping_date = ''; + public $commissionning_date = ''; + public $qc_frequency = ''; + public $fk_status = ''; public $datec = ''; public $tms = ''; @@ -186,6 +198,12 @@ class Productlot extends CommonObject $sql .= 'batch,'; $sql .= 'eatby,'; $sql .= 'sellby,'; + $sql .= 'eol_date,'; + $sql .= 'manufacturing_date,'; + $sql .= 'scrapping_date,'; + $sql .= 'commissionning_date,'; + $sql .= 'qc_frequency,'; + $sql .= 'fk_status,'; $sql .= 'datec,'; $sql .= 'fk_user_creat,'; $sql .= 'fk_user_modif,'; @@ -196,6 +214,13 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->batch) ? 'NULL' : "'".$this->db->escape($this->batch)."'").','; $sql .= ' '.(!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'".$this->db->idate($this->eatby)."'").','; $sql .= ' '.(!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'".$this->db->idate($this->sellby)."'").','; + $sql .= ' '.(!isset($this->eol_date) || dol_strlen($this->eol_date) == 0 ? 'NULL' : "'".$this->db->idate($this->eol_date)."'").','; + $sql .= ' '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) == 0 ? 'NULL' : "'".$this->db->idate($this->manufacturing_date)."'").','; + $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; + $sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; + $sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; + $sql .= ' '.(!isset($this->fk_status) || dol_strlen($this->fk_status) == 0 ? 'NULL' : $this->fk_status).','; + $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; $sql .= ' '.(!isset($this->fk_user_modif) ? 'NULL' : $this->fk_user_modif).','; @@ -268,6 +293,12 @@ class Productlot extends CommonObject $sql .= " t.batch,"; $sql .= " t.eatby,"; $sql .= " t.sellby,"; + $sql .= " t.eol_date,"; + $sql .= " t.manufacturing_date,"; + $sql .= " t.scrapping_date,"; + $sql .= " t.commissionning_date,"; + $sql .= " t.qc_frequency,"; + $sql .= " t.fk_status,"; $sql .= " t.datec,"; $sql .= " t.tms,"; $sql .= " t.fk_user_creat,"; @@ -295,6 +326,14 @@ class Productlot extends CommonObject $this->fk_product = $obj->fk_product; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); + $this->eol_date = $this->db->jdate($obj->eol_date); + + $this->manufacturing_date = $this->db->jdate($obj->manufacturing_date); + $this->scrapping_date = $this->db->jdate($obj->scrapping_date); + $this->commissionning_date = $this->db->jdate($obj->commissionning_date); + $this->qc_frequency = $obj->qc_frequency; + $this->fk_status = $obj->fk_status; + $this->datec = $this->db->jdate($obj->datec); $this->tms = $this->db->jdate($obj->tms); $this->fk_user_creat = $obj->fk_user_creat; @@ -371,6 +410,12 @@ class Productlot extends CommonObject $sql .= ' batch = '.(isset($this->batch) ? "'".$this->db->escape($this->batch)."'" : "null").','; $sql .= ' eatby = '.(!isset($this->eatby) || dol_strlen($this->eatby) != 0 ? "'".$this->db->idate($this->eatby)."'" : 'null').','; $sql .= ' sellby = '.(!isset($this->sellby) || dol_strlen($this->sellby) != 0 ? "'".$this->db->idate($this->sellby)."'" : 'null').','; + $sql .= ' eol_date = '.(!isset($this->eol_date) || dol_strlen($this->eol_date) != 0 ? "'".$this->db->idate($this->eol_date)."'" : 'null').','; + $sql .= ' manufacturing_date = '.(!isset($this->manufacturing_date) || dol_strlen($this->manufacturing_date) != 0 ? "'".$this->db->idate($this->manufacturing_date)."'" : 'null').','; + $sql .= ' scrapping_date = '.(!isset($this->destruction_date) || dol_strlen($this->destruction_date) != 0 ? "'".$this->db->idate($this->destruction_date)."'" : 'null').','; + $sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; + $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; + $sql .= ' fk_status = '.(!isset($this->fk_status) || dol_strlen($this->fk_status) != 0 ? "'".$this->db->escape($this->fk_status)."'" : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index b797d7bccc7..9fd971a70d8 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 All-3kcis + * Copyright (C) 2021 Noé Cendrier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // Load translation files required by the page $langs->loadLangs(array('stocks', 'other', 'productbatch')); @@ -138,7 +140,7 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); - if ($action == 'seteatby' && $user->rights->stock->creer) { + if ($action == 'seteatby' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -149,7 +151,7 @@ if (empty($reshook)) { } } - if ($action == 'setsellby' && $user->rights->stock->creer) { + if ($action == 'setsellby' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -160,6 +162,70 @@ if (empty($reshook)) { } } + if ($action == 'seteol_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int')); + $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, null, 'errors'); + $action == 'editeol_date'; + } else { + $action = 'view'; + } + } + + if ($action == 'setmanufacturing_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int')); + $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, null, 'errors'); + $action == 'editmanufacturing_date'; + } else { + $action = 'view'; + } + } + + if ($action == 'setscrapping_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int')); + $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, null, 'errors'); + $action == 'editscrapping_date'; + } else { + $action = 'view'; + } + } + + if ($action == 'setcommissionning_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int')); + $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, null, 'errors'); + $action == 'editcommissionning_date'; + } else { + $action = 'view'; + } + } + + if ($action == 'setqc_frequency' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); + if ($result < 0) { // Prévoir un test de format de durée + setEventMessages($object->error, null, 'errors'); + $action == 'editqc_frequency'; + } else { + $action = 'view'; + } + } + + if ($action == 'setfk_status' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $result = $object->setValueFrom('fk_status', GETPOST('fk_status') ? GETPOST('fk_status') : null, '', null, 'text', '', $user, 'PRODUCT_MODIFY'); + if ($result < 0) { + setEventMessages($object->error, null, 'errors'); + $action == 'editfk_status'; + } else { + $action = 'view'; + } + } + $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen @@ -308,6 +374,7 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); +$formproduct = new FormProduct($db); $title = $langs->trans("ProductLot"); $help_url = ''; @@ -430,45 +497,57 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Traceability info if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { - print ''; - print $form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; + print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; + print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; - print ''; - print $form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; + print ''.$form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer).''; + print ''.$form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; - print ''; - print $form->editfieldkey($langs->trans('DestructionDate'), 'destruction_date', $object->destruction_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('DestructionDate'), 'destruction_date', $object->destruction_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; + print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; + print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; - print ''; - print $form->editfieldkey($langs->trans('FirstUseDate'), 'first_use_date', $object->first_use_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; - print $form->editfieldval($langs->trans('FirstUseDate'), 'first_use_date', $object->first_use_date, $object, $user->rights->stock->creer, 'datepicker'); - print ''; + print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; - print ''; - print $form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string'); - print ''; - print $form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string'); - print ''; + print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; + print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string').''; print ''; - $form->load_cache_productbatch_status(); - print ''; - print $form->editfieldkey($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->status], $object, $user->rights->stock->creer, 'select:productbatch_status'); - print ''; - print $form->editfieldval($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->status], $object, $user->rights->stock->creer, 'select:productbatch_status'); + print ''; + print ''; + print $form->editfieldkey("Status", 'fk_status', $object->fk_status, $object, $user->rights->stock->creer); print ''; - print ''; - /*print ''.$langs->trans("Status").'select à voir';*/ - } + print ''; + if ($action != 'editfk_status') { + $formproduct->load_cache_productbatch_status(); + print $formproduct->cache_productbatch_status[$object->fk_status]; + } else { + // $fk_status = GETPOST('fk_status'); + if (empty($fk_status)) { + $fk_status = $object->fk_status; + } + print $formproduct->select_productbatch_status($fk_status,'?id='.$object->id); + } + print ''; + + + /* print ''.$form->editfieldkey('Status', 'fk_status', '', $object, 0); + // print_r($formproductlot->productbatch_status_array(0)); + print ''; + print ''.$form->selectarray('fk_status', $formproductlot->productbatch_status_array(0), $object->fk_status, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); + if ($user->admin) { + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + } + print ''; */ + /* $form->load_cache_productbatch_status(); + print ''; + print implode(',',$form->cache_productbatch_status); + print $form->editfieldkey($langs->trans('Status'), 'fk_status', $langs->trans($object->laberl), $object, $user->rights->stock->creer, 'select;'.implode(',', $form->cache_productbatch_status)); + print ''; + print $form->editfieldval($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->label], $object, $user->rights->stock->creer, 'select;'.implode(',', $form->cache_productbatch_status)); + // print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->rights->deplacement->creer, 'select:types_fees'); + print ''; + print ''; */ +} // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; From 1a52ff6990bcdb2163a0cbe720ebac746c2aa523 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Tue, 27 Apr 2021 17:38:32 +0200 Subject: [PATCH 03/21] language strings --- htdocs/langs/en_US/productbatch.lang | 10 +++++++++- htdocs/langs/fr_FR/productbatch.lang | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 644da334851..6d9b9844382 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -32,4 +32,12 @@ ManageLotMask=Custom mask CustomMasks=Adds an option to define mask in the product card LotProductTooltip=Adds an option in the product card to define a dedicated batch number mask SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask -QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned \ No newline at end of file +QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned +LifeTime=Life span +EndOfLife=End of life +ManufacturingDate=Manufacturing date +DestructionDate=Destruction date +FirstUseDate=First use date +QCFrequency=Quality control frequency +InWorkingOrder=In working order +OutOfOrder=Out of order diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 5a1ddd19ae8..86fbd5ed4f0 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -32,3 +32,11 @@ ManageLotMask=Masque personnalisé CustomMasks=Ajoute une option pour définir le masque dans la fiche produit LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série +LifeTime=Durée de vie +EndOfLife=Date de fin de vie +ManufacturingDate=Date de fabrication +DestructionDate=Date de mise au rebut +FirstUseDate=Date de mise en service +QCFrequency=Periodicité de contrôle +InWorkingOrder=En état de marche +OutOfOrder=Hors d’usage From d6b936dd6ecb9d08abeaa5fe7682e8966fdd78b0 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Wed, 28 Apr 2021 16:36:15 +0200 Subject: [PATCH 04/21] add lifetime and qc_frequency in product card --- htdocs/product/card.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f3dc87f41ba..b715bab29c2 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -473,6 +473,8 @@ if (empty($reshook)) { $object->customcode = GETPOST('customcode', 'alpha'); $object->country_id = GETPOST('country_id', 'int'); $object->state_id = GETPOST('state_id', 'int'); + $object->lifetime = GETPOST('lifetime', 'int'); + $object->qc_frequency = GETPOST('qc_frequency', 'int'); $object->status = GETPOST('statut', 'int'); $object->status_buy = GETPOST('statut_buy', 'int'); $object->status_batch = GETPOST('status_batch', 'aZ09'); @@ -1535,7 +1537,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $object->country = $tmparray['label']; } - $type = $langs->trans('Product'); if ($object->isService()) { $type = $langs->trans('Service'); @@ -1604,10 +1605,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $tooltip .= $langs->trans("GenericMaskCodes5"); print ''.$langs->trans("ManageLotMask").''; if ($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') { - $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; + $mask = !empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; } if ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced') { - $mask = !is_empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; + $mask = !empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; } $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; @@ -1798,6 +1799,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } + // Traceability + if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + print ''.$langs->trans("LifeTime").''; + print ''.$langs->trans("QCFrequency").''; + } + // Other attributes $parameters = array('colspan' => ' colspan="3"', 'cols' => 3); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -2275,6 +2282,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } + // Traceability + if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + print ''.$langs->trans("LifeTime").''.$object->lifetime.' '; + !empty($object->lifetime) ? print $langs->trans('Days') : print ''; + print ''; + print ''.$langs->trans("QCFrequency").''.$object->qc_frequency.' '; + !empty($object->qc_frequency) ? print $langs->trans('Days') : print ''; + print ''; + } + // Other attributes $parameters = array('colspan' => ' colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).'"', 'cols' => (2 + (($showphoto || $showbarcode) ? 1 : 0))); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; From 82ae633617273ab004ae8823f23e104dd90fcb27 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Wed, 28 Apr 2021 17:08:17 +0200 Subject: [PATCH 05/21] lifetime and qc_frequency now treated in add and update --- htdocs/product/card.php | 6 ++++-- htdocs/product/class/product.class.php | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b715bab29c2..f0bfd090eaa 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -332,6 +332,8 @@ if (empty($reshook)) { $object->customcode = GETPOST('customcode', 'alphanohtml'); $object->country_id = GETPOST('country_id', 'int'); $object->state_id = GETPOST('state_id', 'int'); + $object->lifetime = GETPOST('lifetime', 'int'); + $object->qc_frequency = GETPOST('qc_frequency', 'int'); $object->duration_value = $duration_value; $object->duration_unit = $duration_unit; $object->fk_default_warehouse = GETPOST('fk_default_warehouse'); @@ -473,8 +475,8 @@ if (empty($reshook)) { $object->customcode = GETPOST('customcode', 'alpha'); $object->country_id = GETPOST('country_id', 'int'); $object->state_id = GETPOST('state_id', 'int'); - $object->lifetime = GETPOST('lifetime', 'int'); - $object->qc_frequency = GETPOST('qc_frequency', 'int'); + $object->lifetime = GETPOST('lifetime', 'int'); + $object->qc_frequency = GETPOST('qc_frequency', 'int'); $object->status = GETPOST('statut', 'int'); $object->status_buy = GETPOST('statut_buy', 'int'); $object->status_batch = GETPOST('status_batch', 'aZ09'); diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 6ed0b4266a8..9eea64a6b03 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1092,6 +1092,8 @@ class Product extends CommonObject $sql .= ", customcode = '".$this->db->escape($this->customcode)."'"; $sql .= ", fk_country = ".($this->country_id > 0 ? (int) $this->country_id : 'null'); $sql .= ", fk_state = ".($this->state_id > 0 ? (int) $this->state_id : 'null'); + $sql .= ", lifetime = ".($this->lifetime > 0 ? (int) $this->lifetime : 'null'); + $sql .= ", qc_frequency = ".($this->qc_frequency > 0 ? (int) $this->qc_frequency : 'null'); $sql .= ", note = ".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : 'null'); $sql .= ", duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."'"; if (empty($conf->global->MAIN_PRODUCT_PERENTITY_SHARED)) { @@ -2171,7 +2173,7 @@ class Product extends CommonObject return -1; } - $sql = "SELECT p.rowid, p.ref, p.ref_ext, p.label, p.description, p.url, p.note_public, p.note as note_private, p.customcode, p.fk_country, p.fk_state, p.price, p.price_ttc,"; + $sql = "SELECT p.rowid, p.ref, p.ref_ext, p.label, p.description, p.url, p.note_public, p.note as note_private, p.customcode, p.fk_country, p.fk_state, p.lifetime, p.qc_frequency, p.price, p.price_ttc,"; $sql .= " p.price_min, p.price_min_ttc, p.price_base_type, p.cost_price, p.default_vat_code, p.tva_tx, p.recuperableonly as tva_npr, p.localtax1_tx, p.localtax2_tx, p.localtax1_type, p.localtax2_type, p.tosell,"; $sql .= " p.tobuy, p.fk_product_type, p.duration, p.fk_default_warehouse, p.seuil_stock_alerte, p.canvas, p.net_measure, p.net_measure_units, p.weight, p.weight_units,"; $sql .= " p.length, p.length_units, p.width, p.width_units, p.height, p.height_units,"; @@ -2227,6 +2229,8 @@ class Product extends CommonObject $this->country_id = $obj->fk_country; $this->country_code = getCountry($this->country_id, 2, $this->db); $this->state_id = $obj->fk_state; + $this->lifetime = $obj->lifetime; + $this->qc_frequency = $obj->qc_frequency; $this->price = $obj->price; $this->price_ttc = $obj->price_ttc; $this->price_min = $obj->price_min; From 1224327f913bc7ed72e32fab33b38ba8539dcd96 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 29 Apr 2021 17:50:11 +0200 Subject: [PATCH 06/21] qcstatus everywhere --- .../product/class/html.formproduct.class.php | 18 ++++---- .../product/stock/class/productlot.class.php | 14 +++---- htdocs/product/stock/productlot_card.php | 42 +++++-------------- 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index bfddbc024db..9b2ad20dd28 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -684,7 +684,7 @@ class FormProduct * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string HTML string with select and input */ - public function select_productbatch_status($selected = '', $page = '', $htmlname = 'fk_status', $htmloption = '', $forcecombo = 1, $events = array()) + public function select_productbatch_qcstatus($selected = '', $page = '', $htmlname = 'fk_qcstatus', $htmloption = '', $forcecombo = 1, $events = array()) { // phpcs:enable global $conf, $langs; @@ -695,11 +695,11 @@ class FormProduct $statusArray = array(); $sql = "SELECT code, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_status"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus"; $sql .= " WHERE active > 0"; $sql .= " ORDER BY code ASC"; - dol_syslog(get_class($this)."::select_productbatch_status", LOG_DEBUG); + dol_syslog(get_class($this)."::select_productbatch_qcstatus", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { if ($conf->use_javascript_ajax && !$forcecombo) { @@ -709,7 +709,7 @@ class FormProduct if (!empty($page)) { $out .= '
'; - $out .= ''; + $out .= ''; $out .= ''; } @@ -735,7 +735,7 @@ class FormProduct } if ($row['label']) { - $out .= $row['label']; + $out .= $langs->trans($row['label']); } $out .= ''; @@ -762,7 +762,7 @@ class FormProduct * * @return int Nb of loaded lines, 0 if already loaded, <0 if KO */ - public function load_cache_productbatch_status() + public function load_cache_productbatch_qcstatus() { // phpcs:enable global $langs; @@ -770,7 +770,7 @@ class FormProduct dol_syslog(__METHOD__, LOG_DEBUG); $sql = "SELECT s.rowid, s.code, s.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_status as s"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus as s"; $sql .= " WHERE s.active > 0"; $sql .= " ORDER BY s.code ASC"; @@ -784,11 +784,11 @@ class FormProduct // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label)); - $this->cache_productbatch_status[$obj->code] = $label; + $this->cache_productbatch_qcstatus[$obj->code] = $label; $i++; } - asort($this->cache_productbatch_status); + asort($this->cache_productbatch_qcstatus); return $num; } else { diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index fb9a6b5815c..0fbef103d83 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -96,7 +96,7 @@ class Productlot extends CommonObject 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>90), 'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>100), 'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>110), - 'fk_status' => array('type'=>'varchar(6)', 'label'=>'Status', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>120), + 'fk_qcstatus' => array('type'=>'varchar(6)', 'label'=>'Status', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>120), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), @@ -123,7 +123,7 @@ class Productlot extends CommonObject public $scrapping_date = ''; public $commissionning_date = ''; public $qc_frequency = ''; - public $fk_status = ''; + public $fk_qcstatus = ''; public $datec = ''; public $tms = ''; @@ -203,7 +203,7 @@ class Productlot extends CommonObject $sql .= 'scrapping_date,'; $sql .= 'commissionning_date,'; $sql .= 'qc_frequency,'; - $sql .= 'fk_status,'; + $sql .= 'fk_qcstatus,'; $sql .= 'datec,'; $sql .= 'fk_user_creat,'; $sql .= 'fk_user_modif,'; @@ -219,7 +219,7 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; $sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; $sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; - $sql .= ' '.(!isset($this->fk_status) || dol_strlen($this->fk_status) == 0 ? 'NULL' : $this->fk_status).','; + $sql .= ' '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) == 0 ? 'NULL' : $this->fk_qcstatus).','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; @@ -298,7 +298,7 @@ class Productlot extends CommonObject $sql .= " t.scrapping_date,"; $sql .= " t.commissionning_date,"; $sql .= " t.qc_frequency,"; - $sql .= " t.fk_status,"; + $sql .= " t.fk_qcstatus,"; $sql .= " t.datec,"; $sql .= " t.tms,"; $sql .= " t.fk_user_creat,"; @@ -332,7 +332,7 @@ class Productlot extends CommonObject $this->scrapping_date = $this->db->jdate($obj->scrapping_date); $this->commissionning_date = $this->db->jdate($obj->commissionning_date); $this->qc_frequency = $obj->qc_frequency; - $this->fk_status = $obj->fk_status; + $this->fk_qcstatus = $obj->fk_qcstatus; $this->datec = $this->db->jdate($obj->datec); $this->tms = $this->db->jdate($obj->tms); @@ -415,7 +415,7 @@ class Productlot extends CommonObject $sql .= ' scrapping_date = '.(!isset($this->destruction_date) || dol_strlen($this->destruction_date) != 0 ? "'".$this->db->idate($this->destruction_date)."'" : 'null').','; $sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; - $sql .= ' fk_status = '.(!isset($this->fk_status) || dol_strlen($this->fk_status) != 0 ? "'".$this->db->escape($this->fk_status)."'" : 'null').','; + $sql .= ' fk_qcstatus = '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) != 0 ? "'".$this->db->escape($this->fk_qcstatus)."'" : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 9fd971a70d8..e19d2f7b9e6 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -216,11 +216,11 @@ if (empty($reshook)) { } } - if ($action == 'setfk_status' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { - $result = $object->setValueFrom('fk_status', GETPOST('fk_status') ? GETPOST('fk_status') : null, '', null, 'text', '', $user, 'PRODUCT_MODIFY'); + if ($action == 'setfk_qcstatus' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + $result = $object->setValueFrom('fk_qcstatus', GETPOST('fk_qcstatus') ? GETPOST('fk_qcstatus') : null, '', null, 'text', '', $user, 'PRODUCT_MODIFY'); if ($result < 0) { setEventMessages($object->error, null, 'errors'); - $action == 'editfk_status'; + $action == 'editfk_qcstatus'; } else { $action = 'view'; } @@ -514,40 +514,20 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; print ''; - print $form->editfieldkey("Status", 'fk_status', $object->fk_status, $object, $user->rights->stock->creer); + print $form->editfieldkey("Status", 'fk_qcstatus', $object->fk_qcstatus, $object, $user->rights->stock->creer); print ''; print ''; - if ($action != 'editfk_status') { - $formproduct->load_cache_productbatch_status(); - print $formproduct->cache_productbatch_status[$object->fk_status]; + if ($action != 'editfk_qcstatus') { + $formproduct->load_cache_productbatch_qcstatus(); + print $formproduct->cache_productbatch_qcstatus[$object->fk_qcstatus]; } else { - // $fk_status = GETPOST('fk_status'); - if (empty($fk_status)) { - $fk_status = $object->fk_status; + if (empty($fk_qcstatus)) { + $fk_qcstatus = $object->fk_qcstatus; } - print $formproduct->select_productbatch_status($fk_status,'?id='.$object->id); + print $formproduct->select_productbatch_qcstatus($fk_qcstatus,'?id='.$object->id); } print ''; - - - /* print ''.$form->editfieldkey('Status', 'fk_status', '', $object, 0); - // print_r($formproductlot->productbatch_status_array(0)); - print ''; - print ''.$form->selectarray('fk_status', $formproductlot->productbatch_status_array(0), $object->fk_status, 1, 0, 0, '', 0, 0, 0, $sortparam, '', 1); - if ($user->admin) { - print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - print ''; */ - /* $form->load_cache_productbatch_status(); - print ''; - print implode(',',$form->cache_productbatch_status); - print $form->editfieldkey($langs->trans('Status'), 'fk_status', $langs->trans($object->laberl), $object, $user->rights->stock->creer, 'select;'.implode(',', $form->cache_productbatch_status)); - print ''; - print $form->editfieldval($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->label], $object, $user->rights->stock->creer, 'select;'.implode(',', $form->cache_productbatch_status)); - // print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->rights->deplacement->creer, 'select:types_fees'); - print ''; - print ''; */ -} + } // Other attributes include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; From fd42979defb5499033cf85155aa913affec992d3 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 30 Apr 2021 11:12:33 +0200 Subject: [PATCH 07/21] qc_status change in stock transfer -> display select --- .../product/class/html.formproduct.class.php | 18 ++++++++---------- htdocs/product/stock/productlot_card.php | 4 ++-- htdocs/product/stock/tpl/stocktransfer.tpl.php | 17 +++++++++++++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 9b2ad20dd28..6f626e40244 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -677,17 +677,15 @@ class FormProduct * Return select list of productbatch status * * @param string $selected Id or Code of preselected incoterm - * @param string $page Defined the form action * @param string $htmlname Name of html select object * @param string $htmloption Options html on select object - * @param int $forcecombo Force to load all values and output a standard combobox (with no beautification) * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) * @return string HTML string with select and input */ - public function select_productbatch_qcstatus($selected = '', $page = '', $htmlname = 'fk_qcstatus', $htmloption = '', $forcecombo = 1, $events = array()) + public function selectProductbatchQcstatus($selected = '', $htmlname = 'fk_qcstatus', $htmloption = '', $forcecombo = 0, $events = array()) { // phpcs:enable - global $conf, $langs; + global $conf, $langs, $user; $langs->load("dict"); @@ -707,11 +705,11 @@ class FormProduct $out .= ajax_combobox($htmlname, $events); } - if (!empty($page)) { + /* if (!empty($page)) { $out .= ''; $out .= ''; $out .= ''; - } + } */ $out .= ''; - // if ($user->admin) { + if ($user->admin) { $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - // } + } - if (!empty($page)) { + /* if (!empty($page)) { $out .= ''; - } + } */ } else { dol_print_error($this->db); } diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index e19d2f7b9e6..5dacea42801 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -512,7 +512,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string').''; print ''; - print ''; + /* print ''; print ''; print $form->editfieldkey("Status", 'fk_qcstatus', $object->fk_qcstatus, $object, $user->rights->stock->creer); print ''; @@ -526,7 +526,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } print $formproduct->select_productbatch_qcstatus($fk_qcstatus,'?id='.$object->id); } - print ''; + print ''; */ } // Other attributes diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index dcd19be4ad6..42a6f992fb8 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -89,8 +89,21 @@ if ($object->element == 'stock') { print ''.$langs->trans("WarehouseTarget").''; print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print ''; -print ''.$langs->trans("NumberOfUnit").''; -print ''; +print ''.$langs->trans("NumberOfUnit").''; +// print ''; +// print ''; +print ''.$langs->trans("StatusChangeIfNeeded").''; +print ''; +// if ($action != 'editfk_qcstatus') { + $formproduct->load_cache_productbatch_qcstatus(); + // print $formproduct->cache_productbatch_qcstatus[$object->fk_qcstatus]; +/* } else { +if (empty($fk_qcstatus)) { + $fk_qcstatus = $object->fk_qcstatus; +} */ +print $formproduct->selectProductbatchQcstatus('-1','fk_qcstatus'); +// } +print ''; // Serial / Eat-by date if (!empty($conf->productbatch->enabled) && From c10b165d337a0a0e9521f161e9f82001e8d94656 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 30 Apr 2021 14:36:25 +0200 Subject: [PATCH 08/21] qc_status change in stock correct -> display select --- htdocs/product/class/html.formproduct.class.php | 15 +-------------- htdocs/product/stock/class/productlot.class.php | 14 +++++++------- htdocs/product/stock/productlot_card.php | 2 +- htdocs/product/stock/tpl/stockcorrection.tpl.php | 5 ++++- htdocs/product/stock/tpl/stocktransfer.tpl.php | 15 ++------------- 5 files changed, 15 insertions(+), 36 deletions(-) diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 6f626e40244..ace2cfa0008 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -672,7 +672,7 @@ class FormProduct } } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Return select list of productbatch status * @@ -705,26 +705,17 @@ class FormProduct $out .= ajax_combobox($htmlname, $events); } - /* if (!empty($page)) { - $out .= '
'; - $out .= ''; - $out .= ''; - } */ - $out .= '
'; - } */ } else { dol_print_error($this->db); } diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 0fbef103d83..0d891e8eb76 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -96,7 +96,7 @@ class Productlot extends CommonObject 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>90), 'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>100), 'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>110), - 'fk_qcstatus' => array('type'=>'varchar(6)', 'label'=>'Status', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>120), + // 'fk_qcstatus' => array('type'=>'varchar(6)', 'label'=>'Status', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>120), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), @@ -123,7 +123,7 @@ class Productlot extends CommonObject public $scrapping_date = ''; public $commissionning_date = ''; public $qc_frequency = ''; - public $fk_qcstatus = ''; + // public $fk_qcstatus = ''; public $datec = ''; public $tms = ''; @@ -203,7 +203,7 @@ class Productlot extends CommonObject $sql .= 'scrapping_date,'; $sql .= 'commissionning_date,'; $sql .= 'qc_frequency,'; - $sql .= 'fk_qcstatus,'; + // $sql .= 'fk_qcstatus,'; $sql .= 'datec,'; $sql .= 'fk_user_creat,'; $sql .= 'fk_user_modif,'; @@ -219,7 +219,7 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; $sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; $sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; - $sql .= ' '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) == 0 ? 'NULL' : $this->fk_qcstatus).','; + // $sql .= ' '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) == 0 ? 'NULL' : $this->fk_qcstatus).','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; @@ -298,7 +298,7 @@ class Productlot extends CommonObject $sql .= " t.scrapping_date,"; $sql .= " t.commissionning_date,"; $sql .= " t.qc_frequency,"; - $sql .= " t.fk_qcstatus,"; + // $sql .= " t.fk_qcstatus,"; $sql .= " t.datec,"; $sql .= " t.tms,"; $sql .= " t.fk_user_creat,"; @@ -332,7 +332,7 @@ class Productlot extends CommonObject $this->scrapping_date = $this->db->jdate($obj->scrapping_date); $this->commissionning_date = $this->db->jdate($obj->commissionning_date); $this->qc_frequency = $obj->qc_frequency; - $this->fk_qcstatus = $obj->fk_qcstatus; + // $this->fk_qcstatus = $obj->fk_qcstatus; $this->datec = $this->db->jdate($obj->datec); $this->tms = $this->db->jdate($obj->tms); @@ -415,7 +415,7 @@ class Productlot extends CommonObject $sql .= ' scrapping_date = '.(!isset($this->destruction_date) || dol_strlen($this->destruction_date) != 0 ? "'".$this->db->idate($this->destruction_date)."'" : 'null').','; $sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; - $sql .= ' fk_qcstatus = '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) != 0 ? "'".$this->db->escape($this->fk_qcstatus)."'" : 'null').','; + // $sql .= ' fk_qcstatus = '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) != 0 ? "'".$this->db->escape($this->fk_qcstatus)."'" : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 5dacea42801..06bce2a4f9d 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -207,7 +207,7 @@ if (empty($reshook)) { } if ($action == 'setqc_frequency' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { - $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'text', '', $user, 'PRODUCT_MODIFY'); + $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY'); if ($result < 0) { // Prévoir un test de format de durée setEventMessages($object->error, null, 'errors'); $action == 'editqc_frequency'; diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 6e2ab53dd0e..f0175942511 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -115,9 +115,12 @@ if (!empty($conf->productbatch->enabled) && || ($object->element == 'stock')) ) { print ''; - print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; + print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print ''; + print ''.$langs->trans("StatusChangeIfNeeded").''; + $formproduct->load_cache_productbatch_qcstatus(); + print ''.$formproduct->selectProductbatchQcstatus($object->fk_qcstatus, 'fk_qcstatus').''; print ''; print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 42a6f992fb8..32a197b7857 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -90,20 +90,9 @@ print ''.$langs->trans("WarehouseTarget").''; print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print ''; print ''.$langs->trans("NumberOfUnit").''; -// print ''; -// print ''; print ''.$langs->trans("StatusChangeIfNeeded").''; -print ''; -// if ($action != 'editfk_qcstatus') { - $formproduct->load_cache_productbatch_qcstatus(); - // print $formproduct->cache_productbatch_qcstatus[$object->fk_qcstatus]; -/* } else { -if (empty($fk_qcstatus)) { - $fk_qcstatus = $object->fk_qcstatus; -} */ -print $formproduct->selectProductbatchQcstatus('-1','fk_qcstatus'); -// } -print ''; +$formproduct->load_cache_productbatch_qcstatus(); +print ''.$formproduct->selectProductbatchQcstatus('0','fk_qcstatus').''; // Serial / Eat-by date if (!empty($conf->productbatch->enabled) && From 94e485aa061808ad0d6712f3522847893b668a36 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Wed, 5 May 2021 16:56:25 +0200 Subject: [PATCH 09/21] qc_frequency in days and qcstatus elsewhere --- htdocs/langs/en_US/productbatch.lang | 2 +- htdocs/langs/fr_FR/productbatch.lang | 2 +- htdocs/product/stock/productlot_card.php | 29 +----------------------- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 6d9b9844382..50be94a859d 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -38,6 +38,6 @@ EndOfLife=End of life ManufacturingDate=Manufacturing date DestructionDate=Destruction date FirstUseDate=First use date -QCFrequency=Quality control frequency +QCFrequency=Quality control frequency (in days) InWorkingOrder=In working order OutOfOrder=Out of order diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 86fbd5ed4f0..ce448998094 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -37,6 +37,6 @@ EndOfLife=Date de fin de vie ManufacturingDate=Date de fabrication DestructionDate=Date de mise au rebut FirstUseDate=Date de mise en service -QCFrequency=Periodicité de contrôle +QCFrequency=Periodicité de contrôle (en jours) InWorkingOrder=En état de marche OutOfOrder=Hors d’usage diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 06bce2a4f9d..ef8dde76896 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -31,7 +31,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; // Load translation files required by the page $langs->loadLangs(array('stocks', 'other', 'productbatch')); @@ -216,16 +215,6 @@ if (empty($reshook)) { } } - if ($action == 'setfk_qcstatus' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { - $result = $object->setValueFrom('fk_qcstatus', GETPOST('fk_qcstatus') ? GETPOST('fk_qcstatus') : null, '', null, 'text', '', $user, 'PRODUCT_MODIFY'); - if ($result < 0) { - setEventMessages($object->error, null, 'errors'); - $action == 'editfk_qcstatus'; - } else { - $action = 'view'; - } - } - $triggermodname = 'PRODUCT_LOT_MODIFY'; // Name of trigger action code to execute when we modify record // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen @@ -374,7 +363,6 @@ if (empty($reshook)) { $form = new Form($db); $formfile = new FormFile($db); -$formproduct = new FormProduct($db); $title = $langs->trans("ProductLot"); $help_url = ''; @@ -510,23 +498,8 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; - print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string').''; + print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; print ''; - /* print ''; - print ''; - print $form->editfieldkey("Status", 'fk_qcstatus', $object->fk_qcstatus, $object, $user->rights->stock->creer); - print ''; - print ''; - if ($action != 'editfk_qcstatus') { - $formproduct->load_cache_productbatch_qcstatus(); - print $formproduct->cache_productbatch_qcstatus[$object->fk_qcstatus]; - } else { - if (empty($fk_qcstatus)) { - $fk_qcstatus = $object->fk_qcstatus; - } - print $formproduct->select_productbatch_qcstatus($fk_qcstatus,'?id='.$object->id); - } - print ''; */ } // Other attributes From b1a4031bde7721511918a76a58ac45b1abdda792 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Wed, 5 May 2021 17:47:01 +0200 Subject: [PATCH 10/21] no qcstatus in productlot class --- htdocs/product/stock/class/productlot.class.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/htdocs/product/stock/class/productlot.class.php b/htdocs/product/stock/class/productlot.class.php index 0d891e8eb76..09c21a1eaa7 100644 --- a/htdocs/product/stock/class/productlot.class.php +++ b/htdocs/product/stock/class/productlot.class.php @@ -96,7 +96,6 @@ class Productlot extends CommonObject 'scrapping_date' => array('type'=>'date', 'label'=>'DestructionDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>90), 'commissionning_date' => array('type'=>'date', 'label'=>'FirstUseDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>100), 'qc_frequency' => array('type'=>'varchar(6)', 'label'=>'QCFrequency', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>110), - // 'fk_qcstatus' => array('type'=>'varchar(6)', 'label'=>'Status', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)?1:0', 'visible'=>5, 'position'=>120), 'eatby' => array('type'=>'date', 'label'=>'EatByDate', 'enabled'=>'empty($conf->global->PRODUCT_DISABLE_EATBY)?1:0', 'visible'=>5, 'position'=>62), 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>1, 'notnull'=>1, 'position'=>500), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>501), @@ -123,7 +122,6 @@ class Productlot extends CommonObject public $scrapping_date = ''; public $commissionning_date = ''; public $qc_frequency = ''; - // public $fk_qcstatus = ''; public $datec = ''; public $tms = ''; @@ -203,7 +201,6 @@ class Productlot extends CommonObject $sql .= 'scrapping_date,'; $sql .= 'commissionning_date,'; $sql .= 'qc_frequency,'; - // $sql .= 'fk_qcstatus,'; $sql .= 'datec,'; $sql .= 'fk_user_creat,'; $sql .= 'fk_user_modif,'; @@ -219,7 +216,6 @@ class Productlot extends CommonObject $sql .= ' '.(!isset($this->scrapping_date) || dol_strlen($this->scrapping_date) == 0 ? 'NULL' : "'".$this->db->idate($this->scrapping_date)."'").','; $sql .= ' '.(!isset($this->commissionning_date) || dol_strlen($this->commissionning_date) == 0 ? 'NULL' : "'".$this->db->idate($this->commissionning_date)."'").','; $sql .= ' '.(!isset($this->qc_frequency) ? 'NULL' : $this->qc_frequency).','; - // $sql .= ' '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) == 0 ? 'NULL' : $this->fk_qcstatus).','; $sql .= ' '."'".$this->db->idate(dol_now())."'".','; $sql .= ' '.(!isset($this->fk_user_creat) ? 'NULL' : $this->fk_user_creat).','; @@ -298,7 +294,6 @@ class Productlot extends CommonObject $sql .= " t.scrapping_date,"; $sql .= " t.commissionning_date,"; $sql .= " t.qc_frequency,"; - // $sql .= " t.fk_qcstatus,"; $sql .= " t.datec,"; $sql .= " t.tms,"; $sql .= " t.fk_user_creat,"; @@ -332,7 +327,6 @@ class Productlot extends CommonObject $this->scrapping_date = $this->db->jdate($obj->scrapping_date); $this->commissionning_date = $this->db->jdate($obj->commissionning_date); $this->qc_frequency = $obj->qc_frequency; - // $this->fk_qcstatus = $obj->fk_qcstatus; $this->datec = $this->db->jdate($obj->datec); $this->tms = $this->db->jdate($obj->tms); @@ -415,7 +409,6 @@ class Productlot extends CommonObject $sql .= ' scrapping_date = '.(!isset($this->destruction_date) || dol_strlen($this->destruction_date) != 0 ? "'".$this->db->idate($this->destruction_date)."'" : 'null').','; $sql .= ' commissionning_date = '.(!isset($this->first_use_date) || dol_strlen($this->first_use_date) != 0 ? "'".$this->db->idate($this->first_use_date)."'" : 'null').','; $sql .= ' qc_frequency = '.(!isset($this->qc_frequency) || dol_strlen($this->qc_frequency) != 0 ? "'".$this->db->escape($this->qc_frequency)."'" : 'null').','; - // $sql .= ' fk_qcstatus = '.(!isset($this->fk_qcstatus) || dol_strlen($this->fk_qcstatus) != 0 ? "'".$this->db->escape($this->fk_qcstatus)."'" : 'null').','; $sql .= ' datec = '.(!isset($this->datec) || dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').','; $sql .= ' tms = '.(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : "'".$this->db->idate(dol_now())."'").','; $sql .= ' fk_user_creat = '.(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").','; From 5be2bdd123024aca095e555598ff8b7a6f861051 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Wed, 5 May 2021 18:01:47 +0200 Subject: [PATCH 11/21] qcstatus is not for this branch --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 5 +---- htdocs/product/stock/tpl/stocktransfer.tpl.php | 6 ++---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index f0175942511..6e2ab53dd0e 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -115,12 +115,9 @@ if (!empty($conf->productbatch->enabled) && || ($object->element == 'stock')) ) { print ''; - print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; + print 'element == 'stock' ? '' : ' class="fieldrequired"').'>'.$langs->trans("batch_number").''; print ''; print ''; - print ''.$langs->trans("StatusChangeIfNeeded").''; - $formproduct->load_cache_productbatch_qcstatus(); - print ''.$formproduct->selectProductbatchQcstatus($object->fk_qcstatus, 'fk_qcstatus').''; print ''; print ''; if (empty($conf->global->PRODUCT_DISABLE_EATBY)) { diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 32a197b7857..d09d584aa8e 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -89,10 +89,8 @@ if ($object->element == 'stock') { print ''.$langs->trans("WarehouseTarget").''; print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print ''; -print ''.$langs->trans("NumberOfUnit").''; -print ''.$langs->trans("StatusChangeIfNeeded").''; -$formproduct->load_cache_productbatch_qcstatus(); -print ''.$formproduct->selectProductbatchQcstatus('0','fk_qcstatus').''; +print ''.$langs->trans("NumberOfUnit").''; +print ''; // Serial / Eat-by date if (!empty($conf->productbatch->enabled) && From 8a108ae5e8bc108e8535f97664fdb19d128ff2bb Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 09:59:33 +0200 Subject: [PATCH 12/21] qcstatus out of formproduct and corrections in syntax --- htdocs/product/card.php | 8 +- .../product/class/html.formproduct.class.php | 110 ------------------ 2 files changed, 4 insertions(+), 114 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index f0bfd090eaa..a11f6b8ca8a 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1607,10 +1607,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { $tooltip .= $langs->trans("GenericMaskCodes5"); print ''.$langs->trans("ManageLotMask").''; if ($object->status_batch == '1' && $conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_LOT_ADDON == 'mod_lot_advanced') { - $mask = !empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; + $mask = ! empty($object->batch_mask) ? $object->batch_mask : $conf->global->LOT_ADVANCED_MASK; } if ($object->status_batch == '2' && $conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON == 'mod_sn_advanced') { - $mask = !empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; + $mask = ! empty($object->batch_mask) ? $object->batch_mask : $conf->global->SN_ADVANCED_MASK; } $inherited_mask_lot = $conf->global->LOT_ADVANCED_MASK; $inherited_mask_sn = $conf->global->SN_ADVANCED_MASK; @@ -1802,7 +1802,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Traceability - if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { print ''.$langs->trans("LifeTime").''; print ''.$langs->trans("QCFrequency").''; } @@ -2285,7 +2285,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Traceability - if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { print ''.$langs->trans("LifeTime").''.$object->lifetime.' '; !empty($object->lifetime) ? print $langs->trans('Days') : print ''; print ''; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index ace2cfa0008..718acef6970 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -672,114 +672,4 @@ class FormProduct } } } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Return select list of productbatch status - * - * @param string $selected Id or Code of preselected incoterm - * @param string $htmlname Name of html select object - * @param string $htmloption Options html on select object - * @param array $events Event options to run on change. Example: array(array('method'=>'getContacts', 'url'=>dol_buildpath('/core/ajax/contacts.php',1), 'htmlname'=>'contactid', 'params'=>array('add-customer-contact'=>'disabled'))) - * @return string HTML string with select and input - */ - public function selectProductbatchQcstatus($selected = '', $htmlname = 'fk_qcstatus', $htmloption = '', $forcecombo = 0, $events = array()) - { - // phpcs:enable - global $conf, $langs, $user; - - $langs->load("dict"); - - $out = ''; - $statusArray = array(); - - $sql = "SELECT code, label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus"; - $sql .= " WHERE active > 0"; - $sql .= " ORDER BY code ASC"; - - dol_syslog(get_class($this)."::select_productbatch_qcstatus", LOG_DEBUG); - $resql = $this->db->query($sql); - if ($resql) { - if ($conf->use_javascript_ajax && !$forcecombo) { - include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; - $out .= ajax_combobox($htmlname, $events); - } - - $out .= ''; - - if ($user->admin) { - $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - } - } else { - dol_print_error($this->db); - } - - return $out; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Load into the cache productbatch status - * - * @return int Nb of loaded lines, 0 if already loaded, <0 if KO - */ - public function load_cache_productbatch_qcstatus() - { - // phpcs:enable - global $langs; - - dol_syslog(__METHOD__, LOG_DEBUG); - - $sql = "SELECT s.rowid, s.code, s.label"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_productbatch_qcstatus as s"; - $sql .= " WHERE s.active > 0"; - $sql .= " ORDER BY s.code ASC"; - - $resql = $this->db->query($sql); - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) { - $obj = $this->db->fetch_object($resql); - - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut - $label = ($obj->code != $langs->trans($obj->code) ? $langs->trans($obj->code) : $langs->trans($obj->label)); - $this->cache_productbatch_qcstatus[$obj->code] = $label; - $i++; - } - - asort($this->cache_productbatch_qcstatus); - - return $num; - } else { - dol_print_error($this->db); - return -1; - } - } - } From 435cbcd16c8a91459d5d0738c89b7f7d6084fdde Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 10:01:53 +0200 Subject: [PATCH 13/21] spaces after ! --- htdocs/product/stock/productlot_card.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index ef8dde76896..2c3d0ebee08 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -139,7 +139,7 @@ if (empty($reshook)) { $backurlforlist = dol_buildpath('/product/stock/productlot_list.php', 1); - if ($action == 'seteatby' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'seteatby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eatbymonth', 'int'), GETPOST('eatbyday', 'int'), GETPOST('eatbyyear', 'int')); $result = $object->setValueFrom('eatby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -150,7 +150,7 @@ if (empty($reshook)) { } } - if ($action == 'setsellby' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'setsellby' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('sellbymonth', 'int'), GETPOST('sellbyday', 'int'), GETPOST('sellbyyear', 'int')); $result = $object->setValueFrom('sellby', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -161,7 +161,7 @@ if (empty($reshook)) { } } - if ($action == 'seteol_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'seteol_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('eol_datemonth', 'int'), GETPOST('eol_dateday', 'int'), GETPOST('eol_dateyear', 'int')); $result = $object->setValueFrom('eol_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -172,7 +172,7 @@ if (empty($reshook)) { } } - if ($action == 'setmanufacturing_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'setmanufacturing_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('manufacturing_datemonth', 'int'), GETPOST('manufacturing_dateday', 'int'), GETPOST('manufacturing_dateyear', 'int')); $result = $object->setValueFrom('manufacturing_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -183,7 +183,7 @@ if (empty($reshook)) { } } - if ($action == 'setscrapping_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'setscrapping_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('scrapping_datemonth', 'int'), GETPOST('scrapping_dateday', 'int'), GETPOST('scrapping_dateyear', 'int')); $result = $object->setValueFrom('scrapping_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -194,7 +194,7 @@ if (empty($reshook)) { } } - if ($action == 'setcommissionning_date' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'setcommissionning_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int')); $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -205,7 +205,7 @@ if (empty($reshook)) { } } - if ($action == 'setqc_frequency' && $user->rights->stock->creer && !GETPOST('cancel', 'alpha')) { + if ($action == 'setqc_frequency' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY'); if ($result < 0) { // Prévoir un test de format de durée setEventMessages($object->error, null, 'errors'); From cce132b8daa2a34b988b855573847114ffe3c817 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 10:04:54 +0200 Subject: [PATCH 14/21] one more space --- htdocs/product/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index a11f6b8ca8a..03b9a0c0552 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1299,7 +1299,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } // Traceability - if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { print ''.$langs->trans("LifeTime").''; print ''.$langs->trans("QCFrequency").''; } From 7c53e2bb1822f90f2d72cd52bba286149d9dc9fc Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 11:16:22 +0200 Subject: [PATCH 15/21] too much td --- htdocs/product/stock/tpl/stocktransfer.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index d09d584aa8e..dcd19be4ad6 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -90,7 +90,7 @@ print ''.$langs->trans("WarehouseTarget").''; print img_picto('', 'stock').$formproduct->selectWarehouses(GETPOST('id_entrepot_destination'), 'id_entrepot_destination', 'warehouseopen,warehouseinternal', 1); print ''; print ''.$langs->trans("NumberOfUnit").''; -print ''; +print ''; // Serial / Eat-by date if (!empty($conf->productbatch->enabled) && From 2bdea3732dac0212bc06e528afbec2232ad01207 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 14:52:48 +0200 Subject: [PATCH 16/21] days in lifetime trans --- htdocs/langs/en_US/productbatch.lang | 2 +- htdocs/langs/fr_FR/productbatch.lang | 2 +- htdocs/product/card.php | 8 ++------ 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/productbatch.lang b/htdocs/langs/en_US/productbatch.lang index 50be94a859d..e7105c544ed 100644 --- a/htdocs/langs/en_US/productbatch.lang +++ b/htdocs/langs/en_US/productbatch.lang @@ -33,7 +33,7 @@ CustomMasks=Adds an option to define mask in the product card LotProductTooltip=Adds an option in the product card to define a dedicated batch number mask SNProductTooltip=Adds an option in the product card to define a dedicated serial number mask QtyToAddAfterBarcodeScan=Qty to add for each barcode/lot/serial scanned -LifeTime=Life span +LifeTime=Life span (in days) EndOfLife=End of life ManufacturingDate=Manufacturing date DestructionDate=Destruction date diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index ce448998094..2cce7c91e8d 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -32,7 +32,7 @@ ManageLotMask=Masque personnalisé CustomMasks=Ajoute une option pour définir le masque dans la fiche produit LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série -LifeTime=Durée de vie +LifeTime=Durée de vie (en jours) EndOfLife=Date de fin de vie ManufacturingDate=Date de fabrication DestructionDate=Date de mise au rebut diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 03b9a0c0552..038af02808b 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -2286,12 +2286,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // Traceability if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { - print ''.$langs->trans("LifeTime").''.$object->lifetime.' '; - !empty($object->lifetime) ? print $langs->trans('Days') : print ''; - print ''; - print ''.$langs->trans("QCFrequency").''.$object->qc_frequency.' '; - !empty($object->qc_frequency) ? print $langs->trans('Days') : print ''; - print ''; + print ''.$langs->trans("LifeTime").''.$object->lifetime.''; + print ''.$langs->trans("QCFrequency").''.$object->qc_frequency.''; } // Other attributes From b979fad85938286e4a37e3a53e86db2c6f7fee02 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 15:19:29 +0200 Subject: [PATCH 17/21] reconcile before PR --- htdocs/langs/fr_FR/productbatch.lang | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index 2cce7c91e8d..e2309cb91da 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -30,8 +30,9 @@ BatchLotNumberingModules=Modèle de génération et contrôle des numéros de lo BatchSerialNumberingModules=Modèle de génération et contrôle des numéros de série ManageLotMask=Masque personnalisé CustomMasks=Ajoute une option pour définir le masque dans la fiche produit -LotProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de lot -SNProductTooltip=Crée un champ dans la fiche produit pour définir un modèle spécifique de numéro de série +LotProductTooltip=Ajoute une option dans la fiche produit pour définir un masque de numéro de lot dédié +SNProductTooltip=Ajoute une option dans la fiche produit pour définir un masque de numéro de série dédié +QtyToAddAfterBarcodeScan=Quantité à ajouter pour chaque code à barres/lot/série scanné LifeTime=Durée de vie (en jours) EndOfLife=Date de fin de vie ManufacturingDate=Date de fabrication From c1b5d26ca04c22085c4c6508bbf46f6ca4e5bf43 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Thu, 6 May 2021 15:20:49 +0200 Subject: [PATCH 18/21] reconcile before PR - second take --- htdocs/langs/fr_FR/productbatch.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/fr_FR/productbatch.lang b/htdocs/langs/fr_FR/productbatch.lang index e2309cb91da..464443e1355 100644 --- a/htdocs/langs/fr_FR/productbatch.lang +++ b/htdocs/langs/fr_FR/productbatch.lang @@ -41,3 +41,4 @@ FirstUseDate=Date de mise en service QCFrequency=Periodicité de contrôle (en jours) InWorkingOrder=En état de marche OutOfOrder=Hors d’usage + From 8e61fc44faf3cec69ad1bce7c273c65bb5677656 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 7 May 2021 15:34:11 +0200 Subject: [PATCH 19/21] =?UTF-8?q?traceability=20must=20be=20a=20choice=20a?= =?UTF-8?q?nd=20we=E2=80=99ll=20see=20later=20about=20commisioning=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/product/card.php | 6 +++--- htdocs/product/stock/productlot_card.php | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 352a66e42cc..4839f26772f 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1299,7 +1299,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; } // Traceability - if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if ($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY) { print ''.$langs->trans("LifeTime").''; print ''.$langs->trans("QCFrequency").''; } @@ -1802,7 +1802,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Traceability - if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if ($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY) { print ''.$langs->trans("LifeTime").''; print ''.$langs->trans("QCFrequency").''; } @@ -2285,7 +2285,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { } // Traceability - if ( empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if ($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY) { print ''.$langs->trans("LifeTime").''.$object->lifetime.''; print ''.$langs->trans("QCFrequency").''.$object->qc_frequency.''; } diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 2c3d0ebee08..8e311c185bb 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -484,7 +484,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Traceability info - if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) { + if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; @@ -494,9 +494,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''.$form->editfieldkey($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer).''; print ''.$form->editfieldval($langs->trans('DestructionDate'), 'scrapping_date', $object->scrapping_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; - print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; - print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; - print ''; + // print ''.$form->editfieldkey($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer).''; + // print ''.$form->editfieldval($langs->trans('FirstUseDate'), 'commissionning_date', $object->commissionning_date, $object, $user->rights->stock->creer, 'datepicker').''; + // print ''; print ''.$form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer).''; print ''.$form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'numeric').''; print ''; From 6d92eb2e84435ae63b30c607fd1c0b0f6a87c62b Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 7 May 2021 15:38:46 +0200 Subject: [PATCH 20/21] little correction --- htdocs/product/stock/productlot_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index 8e311c185bb..a468a302698 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -484,7 +484,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea } // Traceability info - if (!empty($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY)) { + if ($conf->global->PRODUCT_LOT_ENABLE_TRACEABILITY) { print ''.$form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer).''; print ''.$form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker').''; print ''; From 61f8a03df636d9cc0d68565b444a33d44824e597 Mon Sep 17 00:00:00 2001 From: altairis-noe Date: Fri, 7 May 2021 15:41:48 +0200 Subject: [PATCH 21/21] commisionning_date out, we said --- htdocs/product/stock/productlot_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/productlot_card.php b/htdocs/product/stock/productlot_card.php index a468a302698..909782bdbc5 100644 --- a/htdocs/product/stock/productlot_card.php +++ b/htdocs/product/stock/productlot_card.php @@ -194,7 +194,7 @@ if (empty($reshook)) { } } - if ($action == 'setcommissionning_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { + /* if ($action == 'setcommissionning_date' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $newvalue = dol_mktime(12, 0, 0, GETPOST('commissionning_datemonth', 'int'), GETPOST('commissionning_dateday', 'int'), GETPOST('commissionning_dateyear', 'int')); $result = $object->setValueFrom('commissionning_date', $newvalue, '', null, 'date', '', $user, 'PRODUCTLOT_MODIFY'); if ($result < 0) { @@ -203,7 +203,7 @@ if (empty($reshook)) { } else { $action = 'view'; } - } + } */ if ($action == 'setqc_frequency' && $user->rights->stock->creer && ! GETPOST('cancel', 'alpha')) { $result = $object->setValueFrom('qc_frequency', GETPOST('qc_frequency'), '', null, 'int', '', $user, 'PRODUCT_MODIFY');