mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
UI and db OK
This commit is contained in:
parent
a2ef7bc61e
commit
940d478aec
|
|
@ -408,13 +408,16 @@ DELETE FROM llx_rights_def where module = 'holiday' and perms = 'lire_tous';
|
|||
|
||||
CREATE TABLE llx_c_product_nature (
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
code integer NOT NULL,
|
||||
code tinyint NOT NULL,
|
||||
label varchar(100),
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
) ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_c_product_nature ADD UNIQUE INDEX uk_c_product_nature(code);
|
||||
|
||||
INSERT INTO llx_c_product_nature (code, label, active) VALUES (-1, '', 1);
|
||||
INSERT INTO llx_c_product_nature (code, label, active) VALUES (0, 'RowMaterial', 1);
|
||||
INSERT INTO llx_c_product_nature (code, label, active) VALUES (1, 'Finished', 1);
|
||||
|
||||
ALTER TABLE llx_product MODIFY COLUMN finished tinyint DEFAULT NULL;
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code);
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
CREATE TABLE llx_c_product_nature (
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
code varchar(3) NOT NULL,
|
||||
code tinyint NOT NULL,
|
||||
label varchar(100),
|
||||
active tinyint DEFAULT 1 NOT NULL
|
||||
) ENGINE=innodb;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ ALTER TABLE llx_product ADD INDEX idx_product_fk_barcode_type (fk_barcode_type);
|
|||
ALTER TABLE llx_product ADD INDEX idx_product_fk_project (fk_project);
|
||||
ALTER TABLE llx_product ADD UNIQUE INDEX uk_product_barcode (barcode, fk_barcode_type, entity);
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_unit FOREIGN KEY (fk_unit) REFERENCES llx_c_units (rowid);
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_finished FOREIGN KEY (finished) REFERENCES llx_c_product_nature (code);
|
||||
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_fk_country FOREIGN KEY (fk_country) REFERENCES llx_c_country (rowid);
|
||||
ALTER TABLE llx_product ADD CONSTRAINT fk_product_barcode_type FOREIGN KEY (fk_barcode_type) REFERENCES llx_c_barcode_type (rowid);
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ create table llx_product
|
|||
lifo double(24,8), -- To store valuation of stock calculated using lifo method, for this product. TODO Not used, should be replaced by stock value stored into movement table.
|
||||
fk_default_warehouse integer DEFAULT NULL,
|
||||
canvas varchar(32) DEFAULT NULL,
|
||||
finished tinyint DEFAULT NULL, -- 1=manufactured product, 0=matiere premiere
|
||||
finished tinyint DEFAULT NULL, -- see dictionnary c_product_nature
|
||||
hidden tinyint DEFAULT 0, -- Not used. Deprecated.
|
||||
import_key varchar(14), -- Import key
|
||||
model_pdf varchar(255), -- model save dodument used
|
||||
|
|
|
|||
|
|
@ -321,8 +321,19 @@ if (empty($reshook))
|
|||
$object->surface_units = GETPOST('surface_units'); // This is not the fk_unit but the power of unit
|
||||
$object->volume = GETPOST('volume');
|
||||
$object->volume_units = GETPOST('volume_units'); // This is not the fk_unit but the power of unit
|
||||
$object->finished = GETPOST('finished', 'alpha');
|
||||
$object->fk_unit = GETPOST('units', 'alpha'); // This is the fk_unit of sale
|
||||
$finished = GETPOST('finished', 'int');
|
||||
if ($finished > 0) {
|
||||
$object->finished = $finished;
|
||||
} else {
|
||||
$object->finished = null;
|
||||
}
|
||||
|
||||
$units = GETPOST('units', 'int');
|
||||
if ($units > 0) {
|
||||
$object->fk_unit = $units;
|
||||
} else {
|
||||
$object->fk_unit = null;
|
||||
}
|
||||
|
||||
$accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha');
|
||||
$accountancy_code_sell_intra = GETPOST('accountancy_code_sell_intra', 'alpha');
|
||||
|
|
@ -435,10 +446,15 @@ if (empty($reshook))
|
|||
$object->surface_units = GETPOST('surface_units'); // This is not the fk_unit but the power of unit
|
||||
$object->volume = GETPOST('volume');
|
||||
$object->volume_units = GETPOST('volume_units'); // This is not the fk_unit but the power of unit
|
||||
$object->finished = GETPOST('finished', 'alpha');
|
||||
|
||||
$finished = GETPOST('finished', 'int');
|
||||
if ($finished >= 0) {
|
||||
$object->finished = $finished;
|
||||
} else {
|
||||
$object->finished = null;
|
||||
}
|
||||
|
||||
$units = GETPOST('units', 'int');
|
||||
|
||||
if ($units > 0) {
|
||||
$object->fk_unit = $units;
|
||||
} else {
|
||||
|
|
@ -1547,8 +1563,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
|
|||
} else {
|
||||
// Nature
|
||||
print '<tr><td>'.$form->textwithpicto($langs->trans("NatureOfProductShort"), $langs->trans("NatureOfProductDesc")).'</td><td colspan="3">';
|
||||
$statutarray = array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||
print $form->selectarray('finished', $statutarray, $object->finished);
|
||||
print $formproduct->selectProductNature('finished', $object->finished);
|
||||
print '</td></tr>';
|
||||
|
||||
// Brut Weight
|
||||
|
|
|
|||
|
|
@ -430,14 +430,16 @@ class FormProduct
|
|||
* NAture of product labels are defined in llx_c_product_nature
|
||||
*
|
||||
* @param string $name Name of HTML field
|
||||
* @param string $default Preselected value
|
||||
* @param int $mode 1=Use label as value, 0=Use rowid
|
||||
* @param string $selected Preselected value
|
||||
* @param int $mode 1=Use label as value, 0=Use code
|
||||
* @return string
|
||||
*/
|
||||
public function selectProductNature($name = 'finished', $default = '-1', $mode = 0)
|
||||
public function selectProductNature($name = 'finished', $selected = '', $mode = 0)
|
||||
{
|
||||
global $langs, $db;
|
||||
|
||||
$langs->load('products');
|
||||
|
||||
$return = '';
|
||||
|
||||
// TODO Use a cache
|
||||
|
|
@ -459,18 +461,29 @@ class FormProduct
|
|||
return -1;
|
||||
} else {
|
||||
$return .= '<select class="flat" name="'.$name.'">';
|
||||
$return .= '<option value="-1"';
|
||||
if ($selected=='' || $selected=='-1') {
|
||||
$return .= ' selected';
|
||||
}
|
||||
$return .= '></option>';
|
||||
if (!empty($productNature->records) && is_array($productNature->records)) {
|
||||
foreach ($productNature->records as $lines) {
|
||||
$return .= '<option value="';
|
||||
if ($mode == 1) $return .= $lines->label;
|
||||
else $return .= $lines->code;
|
||||
|
||||
foreach ($productNature->records as $lines)
|
||||
{
|
||||
$return .= '<option value="';
|
||||
if ($mode == 1) $return .= $lines->label;
|
||||
else $return .= $lines->id;
|
||||
$return .= '"';
|
||||
if ($mode == 1 && $lines->label == $default) $return .= ' selected';
|
||||
elseif ($mode == 0 && $lines->code == $default) $return .= ' selected';
|
||||
$return .= '>';
|
||||
else $return .= $langs->trans($lines->label);
|
||||
$return .= '</option>';
|
||||
$return .= '"';
|
||||
|
||||
if ($mode == 1 && $lines->label == $selected) {
|
||||
$return .= ' selected';
|
||||
} elseif ($lines->code == $selected) {
|
||||
$return .= ' selected';
|
||||
}
|
||||
|
||||
$return .= '>';
|
||||
$return .= $langs->trans($lines->label);
|
||||
$return .= '</option>';
|
||||
}
|
||||
}
|
||||
$return .= '</select>';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ class Product extends CommonObject
|
|||
$sql .= ", tosell = ".(int) $this->status;
|
||||
$sql .= ", tobuy = ".(int) $this->status_buy;
|
||||
$sql .= ", tobatch = ".((empty($this->status_batch) || $this->status_batch < 0) ? '0' : (int) $this->status_batch);
|
||||
$sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0) ? "null" : (int) $this->finished);
|
||||
$sql .= ", finished = ".((!isset($this->finished) || $this->finished < 0 || $this->finished == '') ? "null" : (int) $this->finished);
|
||||
$sql .= ", net_measure = ".($this->net_measure != '' ? "'".$this->db->escape($this->net_measure)."'" : 'null');
|
||||
$sql .= ", net_measure_units = ".($this->net_measure_units != '' ? "'".$this->db->escape($this->net_measure_units)."'" : 'null');
|
||||
$sql .= ", weight = ".($this->weight != '' ? "'".$this->db->escape($this->weight)."'" : 'null');
|
||||
|
|
@ -4562,10 +4562,21 @@ class Product extends CommonObject
|
|||
global $langs;
|
||||
$langs->load('products');
|
||||
|
||||
if ($this->finished == '0') { return $langs->trans("RowMaterial");
|
||||
}
|
||||
if ($this->finished == '1') { return $langs->trans("Finished");
|
||||
if (isset($this->finished) && $this->finished>=0) {
|
||||
$sql = 'SELECT label, code FROM '.MAIN_DB_PREFIX.'c_product_nature where code='.$this->finished.' AND active=1';
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql && $this->db->num_rows($resql) > 0) {
|
||||
$res = $this->db->fetch_array($resql);
|
||||
$label = $langs->trans($res['label']);
|
||||
$this->db->free($resql);
|
||||
return $label;
|
||||
} else {
|
||||
$this->error = $this->db->error().' sql='.$sql;
|
||||
dol_syslog(get_class($this)."::".__METHOD__.' Error '.$this->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user