forked from Wavyzz/dolibarr
New: Add custom code and origin country
This commit is contained in:
@@ -164,3 +164,6 @@ ProductIsUsed=This product is used
|
|||||||
NewRefForClone=Ref. of new product/service
|
NewRefForClone=Ref. of new product/service
|
||||||
CustomerPrices=Customers prices
|
CustomerPrices=Customers prices
|
||||||
SuppliersPrices=Suppliers prices
|
SuppliersPrices=Suppliers prices
|
||||||
|
CustomCode=Custom code
|
||||||
|
CountryOrigin=Origin country
|
||||||
|
HiddenIntoCombo=Hidden into select lists
|
||||||
@@ -164,3 +164,6 @@ ProductIsUsed=Ce produit est utilisé
|
|||||||
NewRefForClone=Réf. du nouveau produit/service
|
NewRefForClone=Réf. du nouveau produit/service
|
||||||
CustomerPrices=Prix clients
|
CustomerPrices=Prix clients
|
||||||
SuppliersPrices=Prix fournisseurs
|
SuppliersPrices=Prix fournisseurs
|
||||||
|
CustomCode=Code douane
|
||||||
|
CountryOrigin=Pays d'origine
|
||||||
|
HiddenIntoCombo=Caché dans les listes
|
||||||
@@ -3373,13 +3373,13 @@ function dol_osencode($str)
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return an id from a Code. Store Code-Id in a cache.
|
* Return an id from a Code. Store Code-Id in a cache.
|
||||||
* \param db Database handler
|
* @param db Database handler
|
||||||
* \param key Code to get Id
|
* @param key Code to get Id
|
||||||
* \param tablename Table name without prefix
|
* @param tablename Table name without prefix
|
||||||
* \param fieldkey Field for code
|
* @param fieldkey Field for code
|
||||||
* \param fieldid Field for id
|
* @param fieldid Field for id
|
||||||
* \return int Id of code
|
* @return int Id of code
|
||||||
*/
|
*/
|
||||||
function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
|
function dol_getIdFromCode($db,$key,$tablename,$fieldkey='code',$fieldid='id')
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,6 +91,11 @@ class Product extends CommonObject
|
|||||||
// Statut indique si le produit est un produit fini '1' ou une matiere premiere '0'
|
// Statut indique si le produit est un produit fini '1' ou une matiere premiere '0'
|
||||||
var $finished;
|
var $finished;
|
||||||
|
|
||||||
|
var $customcode; // Custom code
|
||||||
|
var $country_id; // Country origin id
|
||||||
|
var $country_code; // Country origin code (US, FR, ...)
|
||||||
|
|
||||||
|
// Hidden into combo boxes
|
||||||
var $hidden;
|
var $hidden;
|
||||||
|
|
||||||
//! Unites de mesure
|
//! Unites de mesure
|
||||||
@@ -185,9 +190,9 @@ class Product extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Insert product into database
|
* Insert product into database
|
||||||
* \param user User making insert
|
* @param user User making insert
|
||||||
* \return int id of product/service if OK or number of error < 0
|
* @return int id of product/service if OK or number of error < 0
|
||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user)
|
||||||
{
|
{
|
||||||
@@ -405,10 +410,10 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mise a jour du produit en base
|
* Update a record into database
|
||||||
* \param id id du produit
|
* @param id Id of product
|
||||||
* \param user utilisateur qui effectue l'insertion
|
* @param user Object user making update
|
||||||
* \return int 1 si ok, -1 si ref deja existante, -2 autre erreur
|
* @return int 1 if OK, -1 if ref already exists, -2 if other error
|
||||||
*/
|
*/
|
||||||
function update($id, $user)
|
function update($id, $user)
|
||||||
{
|
{
|
||||||
@@ -417,7 +422,7 @@ class Product extends CommonObject
|
|||||||
// Verification parametres
|
// Verification parametres
|
||||||
if (! $this->libelle) $this->libelle = 'LIBELLE MANQUANT';
|
if (! $this->libelle) $this->libelle = 'LIBELLE MANQUANT';
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Clean parameters
|
||||||
$this->ref = dol_string_nospecial(trim($this->ref));
|
$this->ref = dol_string_nospecial(trim($this->ref));
|
||||||
$this->libelle = trim($this->libelle);
|
$this->libelle = trim($this->libelle);
|
||||||
$this->description = trim($this->description);
|
$this->description = trim($this->description);
|
||||||
@@ -437,6 +442,8 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
if (empty($this->finished)) $this->finished = 0;
|
if (empty($this->finished)) $this->finished = 0;
|
||||||
if (empty($this->hidden)) $this->hidden = 0;
|
if (empty($this->hidden)) $this->hidden = 0;
|
||||||
|
if (empty($this->country_id)) $this->country_id = 0;
|
||||||
|
|
||||||
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
|
$this->accountancy_code_buy = trim($this->accountancy_code_buy);
|
||||||
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
|
$this->accountancy_code_sell= trim($this->accountancy_code_sell);
|
||||||
|
|
||||||
@@ -463,7 +470,9 @@ class Product extends CommonObject
|
|||||||
$sql.= ",volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null');
|
$sql.= ",volume_units = " . ($this->volume_units!='' ? "'".$this->volume_units."'" : 'null');
|
||||||
$sql.= ",seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->seuil_stock_alerte."'" : "null");
|
$sql.= ",seuil_stock_alerte = " . ((isset($this->seuil_stock_alerte) && $this->seuil_stock_alerte != '') ? "'".$this->seuil_stock_alerte."'" : "null");
|
||||||
$sql.= ",description = '" . addslashes($this->description) ."'";
|
$sql.= ",description = '" . addslashes($this->description) ."'";
|
||||||
$sql.= ",note = '" . addslashes($this->note) ."'";
|
$sql.= ",customcode = '" . addslashes($this->customcode) ."'";
|
||||||
|
$sql.= ",fk_country = " . ($this->country_id > 0 ? $this->country_id : 'null');
|
||||||
|
$sql.= ",note = '" . addslashes($this->note) ."'";
|
||||||
$sql.= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
|
$sql.= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
|
||||||
$sql.= ",accountancy_code_buy = '" . $this->accountancy_code_buy."'";
|
$sql.= ",accountancy_code_buy = '" . $this->accountancy_code_buy."'";
|
||||||
$sql.= ",accountancy_code_sell= '" . $this->accountancy_code_sell."'";
|
$sql.= ",accountancy_code_sell= '" . $this->accountancy_code_sell."'";
|
||||||
@@ -538,9 +547,9 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Delete a product from database (if not used)
|
* Delete a product from database (if not used)
|
||||||
* \param id Product id
|
* @param id Product id
|
||||||
* \return int < 0 if KO, >= 0 if OK
|
* @return int < 0 if KO, >= 0 if OK
|
||||||
*/
|
*/
|
||||||
function delete($id)
|
function delete($id)
|
||||||
{
|
{
|
||||||
@@ -951,13 +960,15 @@ class Product extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Load a product in memory from database
|
* Load a product in memory from database
|
||||||
* \param id Id of product/service to load
|
* @param id Id of product/service to load
|
||||||
* \param ref Ref of product/service to load
|
* @param ref Ref of product/service to load
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($id='',$ref='')
|
function fetch($id='',$ref='')
|
||||||
{
|
{
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/lib/company.lib.php');
|
||||||
|
|
||||||
global $langs;
|
global $langs;
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
@@ -971,7 +982,7 @@ class Product extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc,";
|
$sql = "SELECT rowid, ref, label, description, note, customcode, fk_country, price, price_ttc,";
|
||||||
$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,";
|
$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, recuperableonly as tva_npr, localtax1_tx, localtax2_tx, tosell,";
|
||||||
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
|
$sql.= " tobuy, fk_product_type, duration, seuil_stock_alerte, canvas,";
|
||||||
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished, hidden,";
|
$sql.= " weight, weight_units, length, length_units, surface, surface_units, volume, volume_units, barcode, fk_barcode_type, finished, hidden,";
|
||||||
@@ -992,7 +1003,10 @@ class Product extends CommonObject
|
|||||||
$this->libelle = $result["label"];
|
$this->libelle = $result["label"];
|
||||||
$this->description = $result["description"];
|
$this->description = $result["description"];
|
||||||
$this->note = $result["note"];
|
$this->note = $result["note"];
|
||||||
$this->price = $result["price"];
|
$this->customcode = $result["customcode"];
|
||||||
|
$this->country_id = $result["fk_country"];
|
||||||
|
$this->country_code = getCountry($this->country_id,2,$this->db);
|
||||||
|
$this->price = $result["price"];
|
||||||
$this->price_ttc = $result["price_ttc"];
|
$this->price_ttc = $result["price_ttc"];
|
||||||
$this->price_min = $result["price_min"];
|
$this->price_min = $result["price_min"];
|
||||||
$this->price_min_ttc = $result["price_min_ttc"];
|
$this->price_min_ttc = $result["price_min_ttc"];
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php");
|
|||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product/class/html.formproduct.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||||
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
|
if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php");
|
||||||
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
if ($conf->facture->enabled) require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
|
||||||
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
if ($conf->commande->enabled) require_once(DOL_DOCUMENT_ROOT."/commande/class/commande.class.php");
|
||||||
@@ -159,6 +160,8 @@ if ($_POST["action"] == 'add' && ($user->rights->produit->creer || $user->rights
|
|||||||
$product->status_buy = $_POST["statut_buy"];
|
$product->status_buy = $_POST["statut_buy"];
|
||||||
$product->description = dol_htmlcleanlastbr($_POST["desc"]);
|
$product->description = dol_htmlcleanlastbr($_POST["desc"]);
|
||||||
$product->note = dol_htmlcleanlastbr($_POST["note"]);
|
$product->note = dol_htmlcleanlastbr($_POST["note"]);
|
||||||
|
$product->customcode = $_POST["customcode"];
|
||||||
|
$product->country_id = $_POST["country_id"];
|
||||||
$product->duration_value = $_POST["duration_value"];
|
$product->duration_value = $_POST["duration_value"];
|
||||||
$product->duration_unit = $_POST["duration_unit"];
|
$product->duration_unit = $_POST["duration_unit"];
|
||||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0;
|
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]?$_POST["seuil_stock_alerte"]:0;
|
||||||
@@ -234,6 +237,8 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig
|
|||||||
$product->libelle = $_POST["libelle"];
|
$product->libelle = $_POST["libelle"];
|
||||||
$product->description = dol_htmlcleanlastbr($_POST["desc"]);
|
$product->description = dol_htmlcleanlastbr($_POST["desc"]);
|
||||||
$product->note = dol_htmlcleanlastbr($_POST["note"]);
|
$product->note = dol_htmlcleanlastbr($_POST["note"]);
|
||||||
|
$product->customcode = $_POST["customcode"];
|
||||||
|
$product->country_id = $_POST["country_id"];
|
||||||
$product->status = $_POST["statut"];
|
$product->status = $_POST["statut"];
|
||||||
$product->status_buy = $_POST["statut_buy"];
|
$product->status_buy = $_POST["statut_buy"];
|
||||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||||
@@ -745,7 +750,17 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hidden
|
// Custom code
|
||||||
|
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" size="10" value="'.$_POST["customcode"].'"></td></tr>';
|
||||||
|
|
||||||
|
// Origin country
|
||||||
|
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
|
||||||
|
$html->select_pays($_POST["country_id"],'country_id');
|
||||||
|
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Hidden
|
||||||
|
/*
|
||||||
if (($_GET["type"] != 1 && $user->rights->produit->hidden)
|
if (($_GET["type"] != 1 && $user->rights->produit->hidden)
|
||||||
|| ($_GET["type"] == 1 && $user->rights->service->hidden))
|
|| ($_GET["type"] == 1 && $user->rights->service->hidden))
|
||||||
{
|
{
|
||||||
@@ -759,6 +774,7 @@ if ($_GET["action"] == 'create' && ($user->rights->produit->creer || $user->righ
|
|||||||
print yn("No");
|
print yn("No");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Note (invisible sur facture, propales...)
|
// Note (invisible sur facture, propales...)
|
||||||
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
|
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td>';
|
||||||
@@ -867,7 +883,11 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
print '<input type="hidden" name="id" value="'.$product->id.'">';
|
||||||
print '<input type="hidden" name="canvas" value="'.$product->canvas.'">';
|
print '<input type="hidden" name="canvas" value="'.$product->canvas.'">';
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
|
// Ref
|
||||||
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="40" maxlength="32" value="'.$product->ref.'"></td></tr>';
|
print '<tr><td width="15%">'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" size="40" maxlength="32" value="'.$product->ref.'"></td></tr>';
|
||||||
|
|
||||||
|
// Label
|
||||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
print '<tr><td>'.$langs->trans("Label").'</td><td><input name="libelle" size="40" value="'.$product->libelle.'"></td></tr>';
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
@@ -971,20 +991,31 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hidden
|
// Custom code
|
||||||
|
print '<tr><td>'.$langs->trans("CustomCode").'</td><td><input name="customcode" size="10" value="'.$product->customcode.'"></td></tr>';
|
||||||
|
|
||||||
|
// Origin country
|
||||||
|
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>';
|
||||||
|
$html->select_pays($product->country_id,'country_id');
|
||||||
|
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
// Hidden
|
||||||
|
/*
|
||||||
if ((! $product->isservice() && $user->rights->produit->hidden)
|
if ((! $product->isservice() && $user->rights->produit->hidden)
|
||||||
|| ($product->isservice() && $user->rights->service->hidden))
|
|| ($product->isservice() && $user->rights->service->hidden))
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
|
print '<tr><td>'.$langs->trans("HiddenIntoCombo").'</td><td>';
|
||||||
print $html->selectyesno('hidden',$product->hidden);
|
print $html->selectyesno('hidden',$product->hidden);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
|
print '<tr><td>'.$langs->trans("HiddenIntoCombo").'</td><td>';
|
||||||
print yn("No");
|
print yn("No");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Note
|
// Note
|
||||||
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
|
print '<tr><td valign="top">'.$langs->trans("NoteNotVisibleOnBill").'</td><td colspan="2">';
|
||||||
@@ -1145,20 +1176,27 @@ if ($_GET["id"] || $_GET["ref"])
|
|||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Custom code
|
||||||
|
print '<tr><td>'.$langs->trans("CustomCode").'</td><td colspan="2">'.$product->customcode.'</td>';
|
||||||
|
// Origin country code
|
||||||
|
print '<tr><td>'.$langs->trans("CountryOrigin").'</td><td>'.getCountry($product->country_id,0,$db).'</td>';
|
||||||
|
|
||||||
// Hidden
|
// Hidden
|
||||||
|
/*
|
||||||
if ((! $product->isservice() && $user->rights->produit->hidden)
|
if ((! $product->isservice() && $user->rights->produit->hidden)
|
||||||
|| ($product->isservice() && $user->rights->service->hidden))
|
|| ($product->isservice() && $user->rights->service->hidden))
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Hidden").'</td><td colspan="2">';
|
print '<tr><td>'.$langs->trans("HiddenIntoCombo").'</td><td colspan="2">';
|
||||||
print yn($product->hidden);
|
print yn($product->hidden);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Hidden").'</td><td>';
|
print '<tr><td>'.$langs->trans("HiddenIntoCombo").'</td><td>';
|
||||||
print yn("No");
|
print yn("No");
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Note
|
// Note
|
||||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.nl2br($product->note).'</td></tr>';
|
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="2">'.nl2br($product->note).'</td></tr>';
|
||||||
|
|||||||
Reference in New Issue
Block a user