first try on productlot traceability fields

This commit is contained in:
altairis-noe 2021-04-23 14:51:02 +02:00
parent 891de3350f
commit 09807706f0
3 changed files with 88 additions and 0 deletions

View File

@ -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 = '<font class="error">'.$this->db->error().'</font>';
return -2;
}
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
* Output an HTML select vat rate.

View File

@ -1294,6 +1294,11 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
print '</tr>';
}
// Traceability
if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) {
print '<tr><td>'.$langs->trans("LifeTime").'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.GETPOST('lifetime').'"></td></tr>';
print '<tr><td>'.$langs->trans("QCFrequency").'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.GETPOST('qc_frequency').'"></td></tr>';
}
// Other attributes
$parameters = array('colspan' => 3, 'cols' => '3');

View File

@ -428,6 +428,48 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '</tr>';
}
// Traceability info
if (empty($conf->global->PRODUCT_DISABLE_TRACEABILITY)) {
print '<tr><td>';
print $form->editfieldkey($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td><td>';
print $form->editfieldval($langs->trans('EndOfLife'), 'eol_date', $object->eol_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td>';
print '</tr>';
print '<tr><td>';
print $form->editfieldkey($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td><td>';
print $form->editfieldval($langs->trans('ManufacturingDate'), 'manufacturing_date', $object->manufacturing_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td>';
print '</tr>';
print '<tr><td>';
print $form->editfieldkey($langs->trans('DestructionDate'), 'destruction_date', $object->destruction_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td><td>';
print $form->editfieldval($langs->trans('DestructionDate'), 'destruction_date', $object->destruction_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td>';
print '</tr>';
print '<tr><td>';
print $form->editfieldkey($langs->trans('FirstUseDate'), 'first_use_date', $object->first_use_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td><td>';
print $form->editfieldval($langs->trans('FirstUseDate'), 'first_use_date', $object->first_use_date, $object, $user->rights->stock->creer, 'datepicker');
print '</td>';
print '</tr>';
print '<tr><td>';
print $form->editfieldkey($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string');
print '</td><td>';
print $form->editfieldval($langs->trans('QCFrequency'), 'qc_frequency', $object->qc_frequency, $object, $user->rights->stock->creer, 'string');
print '</td>';
print '</tr>';
$form->load_cache_productbatch_status();
print '<tr><td>';
print $form->editfieldkey($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->status], $object, $user->rights->stock->creer, 'select:productbatch_status');
print '</td><td>';
print $form->editfieldval($langs->trans('Status'), 'fk_status', $form->cache_productbatch_status[$object->status], $object, $user->rights->stock->creer, 'select:productbatch_status');
print '</td>';
print '</tr>';
/*print '<tr><td>'.$langs->trans("Status").'</td><td>select à voir</td></tr>';*/
}
// Other attributes
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';