Add nature in product fields
This commit is contained in:
parent
fcc5f9f28d
commit
0c848c3d89
@ -686,9 +686,10 @@ class Form
|
||||
* \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
|
||||
* \param limit Limite sur le nombre de lignes retournées
|
||||
* \param price_level Niveau de prix en fonction du client
|
||||
* \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
|
||||
* \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
|
||||
* \param finished 2=all, 1=finished, 0=raw material
|
||||
*/
|
||||
function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1)
|
||||
function select_produits($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$status=1,$finished=2)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
@ -705,13 +706,13 @@ class Form
|
||||
print '</tr>';
|
||||
print '<tr class="nocellnopadd">';
|
||||
print '<td class="nobordernopadding" colspan="3">';
|
||||
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status,'');
|
||||
print ajax_updater($htmlname,'keysearch','/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,'');
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->select_produits_do($selected,$htmlname,$filtertype,$limit,$price_level,'',$status);
|
||||
$this->select_produits_do($selected,$htmlname,$filtertype,$limit,$price_level,'',$status,$finished);
|
||||
}
|
||||
}
|
||||
|
||||
@ -725,7 +726,7 @@ class Form
|
||||
* \param ajaxkeysearch Filtre des produits si ajax est utilisé
|
||||
* \param status -1=Return all products, 0=Products not on sell, 1=Products on sell
|
||||
*/
|
||||
function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$ajaxkeysearch='',$status=1)
|
||||
function select_produits_do($selected='',$htmlname='productid',$filtertype='',$limit=20,$price_level=0,$ajaxkeysearch='',$status=1,$finished=2)
|
||||
{
|
||||
global $langs,$conf,$user;
|
||||
|
||||
@ -741,7 +742,19 @@ class Form
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_product as cp ON p.rowid = cp.fk_product";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cp.fk_categorie = c.rowid";
|
||||
}
|
||||
if ($status >= 0) $sql.= " WHERE p.envente = ".$status;
|
||||
if($finished == 0)
|
||||
{
|
||||
$sql.= " WHERE p.finished = ".$finished;
|
||||
}
|
||||
elseif($finished == 1)
|
||||
{
|
||||
$sql.= " WHERE p.finished = ".$finished;
|
||||
if ($status >= 0) $sql.= " AND p.envente = ".$status;
|
||||
}
|
||||
elseif($status >= 0)
|
||||
{
|
||||
$sql.= " WHERE p.envente = ".$status;
|
||||
}
|
||||
else $sql.= " WHERE 1 = 1";
|
||||
if ($conf->categorie->enabled && ! $user->rights->categorie->voir)
|
||||
{
|
||||
|
||||
@ -136,4 +136,6 @@ RecordedProductsAndServices=Products/services recorded
|
||||
GenerateThumb=Generate thumb
|
||||
ProductCanvasAbility=Use special "canvas" addons
|
||||
ServiceNb=Service #%s
|
||||
ListProductByPopularity=List of products/services by popularity
|
||||
ListProductByPopularity=List of products/services by popularity
|
||||
Finished=Manufactured product
|
||||
RowMaterial=First material
|
||||
@ -138,4 +138,6 @@ RecordedProductsAndServices=Produits/services en vente
|
||||
GenerateThumb=Générer la vignette
|
||||
ProductCanvasAbility=Utiliser les extensions speciales "canvas"
|
||||
ServiceNb=Service no %s
|
||||
ListProductByPopularity=Liste des produits/services par popularité
|
||||
ListProductByPopularity=Liste des produits/services par popularité
|
||||
Finished=Produit manufacturé
|
||||
RowMaterial=Matière première
|
||||
@ -71,6 +71,8 @@ class Product extends CommonObject
|
||||
var $duration_unit;
|
||||
// Statut indique si le produit est en vente '1' ou non '0'
|
||||
var $status;
|
||||
// Statut indique si le produit est un produit finis '1' ou une matiere premi<6D>re '0'
|
||||
var $finished;
|
||||
|
||||
//! Unites de mesure
|
||||
var $weight;
|
||||
@ -118,6 +120,7 @@ class Product extends CommonObject
|
||||
$this->db = $DB;
|
||||
$this->id = $id ;
|
||||
$this->status = 0;
|
||||
$this->finished = 1;
|
||||
$this->stock_reel = 0;
|
||||
$this->seuil_stock_alerte = 0;
|
||||
|
||||
@ -167,7 +170,8 @@ class Product extends CommonObject
|
||||
if ($this->price=='') $this->price = 0;
|
||||
if ($this->price_min=='') $this->price_min = 0;
|
||||
if ($this->status=='') $this->status = 0;
|
||||
|
||||
if ($this->finished=='') $this->finished = 1;
|
||||
|
||||
$price_ht=0;
|
||||
$price_ttc=0;
|
||||
$price_min_ht=0;
|
||||
@ -222,7 +226,7 @@ class Product extends CommonObject
|
||||
if ($this->ref) $sql.= "ref, ";
|
||||
$sql.= "price_min, price_min_ttc, ";
|
||||
$sql.= "label, ";
|
||||
$sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas)";
|
||||
$sql.= "fk_user_author, fk_product_type, price, price_ttc, price_base_type, canvas, finished)";
|
||||
$sql.= " VALUES (".$this->db->idate(mktime()).", ";
|
||||
if ($this->ref) $sql.= "'".$this->ref."',";
|
||||
$sql.= price2num($price_min_ht).",";
|
||||
@ -233,7 +237,8 @@ class Product extends CommonObject
|
||||
$sql.= price2num($price_ht).",";
|
||||
$sql.= price2num($price_ttc).",";
|
||||
$sql.= "'".$this->price_base_type."',";
|
||||
$sql.= "'".$this->canvas."')";
|
||||
$sql.= "'".$this->canvas."',";
|
||||
$sql.= " ".$this->finished.")";
|
||||
|
||||
dolibarr_syslog("Product::Create sql=".$sql);
|
||||
$result = $this->db->query($sql);
|
||||
@ -372,6 +377,7 @@ class Product extends CommonObject
|
||||
if ($this->ref) $sql .= ",ref = '" . $this->ref ."'";
|
||||
$sql .= ",tva_tx = " . $this->tva_tx;
|
||||
$sql .= ",envente = " . $this->status;
|
||||
$sql .= ",finished = " . ($this->finished<0 ? "null" : $this->finished);
|
||||
$sql .= ",weight = " . ($this->weight!='' ? "'".$this->weight."'" : 'null');
|
||||
$sql .= ",weight_units = " . ($this->weight_units!='' ? "'".$this->weight_units."'": 'null');
|
||||
$sql .= ",volume = " . ($this->volume!='' ? "'".$this->volume."'" : 'null');
|
||||
@ -951,7 +957,7 @@ class Product extends CommonObject
|
||||
|
||||
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc, price_min, price_min_ttc, price_base_type, tva_tx, envente,";
|
||||
$sql.= " fk_product_type, duration, seuil_stock_alerte,canvas,";
|
||||
$sql.= " stock_commande, stock_loc, weight, weight_units, volume, volume_units, barcode, fk_barcode_type";
|
||||
$sql.= " stock_commande, stock_loc, weight, weight_units, volume, volume_units, barcode, fk_barcode_type, finished";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
if ($id) $sql.= " WHERE rowid = '".$id."'";
|
||||
if ($ref) $sql.= " WHERE ref = '".addslashes($ref)."'";
|
||||
@ -975,6 +981,7 @@ class Product extends CommonObject
|
||||
$this->tva_tx = $result["tva_tx"];
|
||||
$this->type = $result["fk_product_type"];
|
||||
$this->status = $result["envente"];
|
||||
$this->finished = $result["finished"];
|
||||
$this->duration = $result["duration"];
|
||||
$this->duration_value = substr($result["duration"],0,strlen($result["duration"])-1);
|
||||
$this->duration_unit = substr($result["duration"],-1);
|
||||
@ -2152,6 +2159,21 @@ class Product extends CommonObject
|
||||
}
|
||||
return $langs->trans('Unknown');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Retourne le libell<EFBFBD> du finished du produit
|
||||
* \return string Libelle
|
||||
*/
|
||||
function getLibFinished()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load('products');
|
||||
|
||||
if ($this->finished == '0') return $langs->trans("RowMaterial");
|
||||
if ($this->finished == '1') return $langs->trans("Finished");
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Entre un nombre de piece du produit en stock dans un entrep<EFBFBD>t
|
||||
|
||||
@ -104,6 +104,7 @@ if ($_POST["action"] == 'add' && $user->rights->produit->creer)
|
||||
$product->weight_units = $_POST["weight_units"];
|
||||
$product->volume = $_POST["volume"];
|
||||
$product->volume_units = $_POST["volume_units"];
|
||||
$product->finished = $_POST["finished"];
|
||||
// MultiPrix
|
||||
if($conf->global->PRODUIT_MULTIPRICES == 1)
|
||||
{
|
||||
@ -166,6 +167,7 @@ $user->rights->produit->creer)
|
||||
$product->weight_units = $_POST["weight_units"];
|
||||
$product->volume = $_POST["volume"];
|
||||
$product->volume_units = $_POST["volume_units"];
|
||||
$product->finished = $_POST["finished"];
|
||||
|
||||
if ($product->check())
|
||||
{
|
||||
@ -214,6 +216,7 @@ if ($_GET["action"] == 'clone' && $user->rights->produit->creer)
|
||||
{
|
||||
$product->ref = "Clone ".$product->ref;
|
||||
$product->status = 0;
|
||||
$product->finished = 1;
|
||||
$product->id = null;
|
||||
|
||||
if ($product->check())
|
||||
@ -225,7 +228,7 @@ if ($_GET["action"] == 'clone' && $user->rights->produit->creer)
|
||||
|
||||
$db->commit();
|
||||
$db->close();
|
||||
|
||||
|
||||
Header("Location: fiche.php?id=$id");
|
||||
exit;
|
||||
}
|
||||
@ -234,10 +237,10 @@ if ($_GET["action"] == 'clone' && $user->rights->produit->creer)
|
||||
if ($product->error == 'ErrorProductAlreadyExists')
|
||||
{
|
||||
$db->rollback();
|
||||
|
||||
|
||||
$_error = 1;
|
||||
$_GET["action"] = "";
|
||||
|
||||
|
||||
$mesg='<div class="error">'.$langs->trans("ErrorProductAlreadyExists",$product->ref).'</div>';
|
||||
//dolibarr_print_error($product->db);
|
||||
}
|
||||
@ -630,6 +633,16 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
// Nature
|
||||
if ($_GET["type"] != 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Nature").'</td><td>';
|
||||
$statutarray=array('1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||
$html->select_array('finished',$statutarray,$_POST["finished"]);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
//Duration
|
||||
if ($_GET["type"] == 1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Duration").'</td><td><input name="duration_value" size="6" maxlength="5" value="'.$product->duree.'"> ';
|
||||
@ -640,7 +653,9 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
print '<input name="duration_unit" type="radio" value="y">'.$langs->trans("Year").' ';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
|
||||
// Weight - Volume
|
||||
if ($_GET["type"] != 1)
|
||||
{
|
||||
// Le poids et le volume ne concerne que les produits et pas les services
|
||||
print '<tr><td>'.$langs->trans("Weight").'</td><td>';
|
||||
@ -699,7 +714,7 @@ if ($_GET["action"] == 'create' && $user->rights->produit->creer)
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td>';
|
||||
print '<td><input name="price_min" size="10" value="'.$product->price_min.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// VAT
|
||||
print '<tr><td width="20%">'.$langs->trans("VATRate").'</td><td>';
|
||||
print $html->select_tva("tva_tx",$conf->defaulttx,$mysoc,'');
|
||||
@ -883,7 +898,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
// Prix mini
|
||||
print '<tr><td>'.$langs->trans("MinPrice").'</td><td>';
|
||||
if ($product->price_base_type == 'TTC')
|
||||
@ -903,10 +918,18 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
print $product->getLibStatut(2);
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Description
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'.nl2br($product->description).'</td></tr>';
|
||||
|
||||
// Nature
|
||||
if($product->type!=1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Nature").'</td><td>';
|
||||
print $product->getLibFinished();
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($product->isservice())
|
||||
{
|
||||
// Duration
|
||||
@ -936,7 +959,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print ' ';
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
|
||||
|
||||
print '<tr><td>'.$langs->trans("Volume").'</td><td>';
|
||||
if ($product->volume != '')
|
||||
{
|
||||
@ -948,7 +971,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
}
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td>'.nl2br($product->note).'</td></tr>';
|
||||
|
||||
@ -998,18 +1021,7 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
}
|
||||
print '</select>';
|
||||
print '</td></tr>';
|
||||
|
||||
if ($product->isproduct() && $conf->stock->enabled)
|
||||
{
|
||||
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td colspan="2">';
|
||||
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||
}
|
||||
|
||||
|
||||
// Description (utilisé dans facture, propale...)
|
||||
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td colspan="2">';
|
||||
print "\n";
|
||||
@ -1028,6 +1040,26 @@ if ($_GET["id"] || $_GET["ref"])
|
||||
print "</td></tr>";
|
||||
print "\n";
|
||||
|
||||
// Nature
|
||||
if($product->type!=1)
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Nature").'</td><td>';
|
||||
$statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial"));
|
||||
$html->select_array('finished',$statutarray,$product->finished);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if ($product->isproduct() && $conf->stock->enabled)
|
||||
{
|
||||
print "<tr>".'<td>'.$langs->trans("StockLimit").'</td><td colspan="2">';
|
||||
print '<input name="seuil_stock_alerte" size="4" value="'.$product->seuil_stock_alerte.'">';
|
||||
print '</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input name="seuil_stock_alerte" type="hidden" value="0">';
|
||||
}
|
||||
|
||||
if ($product->isservice())
|
||||
{
|
||||
// Duration
|
||||
|
||||
@ -201,6 +201,46 @@ class MouvementStock
|
||||
|
||||
|
||||
/**
|
||||
* \brief Crée un mouvement en base pour toutes les compositions de produits
|
||||
* \return int <0 si ko, 0 si ok
|
||||
*/
|
||||
function _createProductComposition($user, $fk_product, $entrepot_id, $qty, $type, $price=0)
|
||||
{
|
||||
|
||||
|
||||
dolibarr_syslog("MouvementStock::_createComposition $user->id, $fk_product, $entrepot_id, $qty, $type, $price");
|
||||
$products_compo = array();
|
||||
|
||||
$sql = "SELECT fk_product_composition, qte, etat_stock";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product_composition";
|
||||
$sql.= " WHERE fk_product = $fk_product;";
|
||||
|
||||
$all = $this->db->query($sql);
|
||||
|
||||
if ($all)
|
||||
{
|
||||
while($item = $this->db->fetch_object($all) )
|
||||
{
|
||||
if($item->etat_stock != 0) array_push($products_compo,$item);
|
||||
}
|
||||
$this->db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("MouvementStock::_Create echec update ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
foreach($products_compo as $product)
|
||||
{
|
||||
$this->_create($user, $product->fk_product_composition, $entrepot_id, ($qty*$product->qte), $type, $price=0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* \brief Calcul ???
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
alter table llx_product add column price_min double(24,8) DEFAULT 0;
|
||||
alter table llx_product add column price_min_ttc double(24,8) DEFAULT 0;
|
||||
alter table llx_product add column finished tinyint DEFAULT NULL after canvas;
|
||||
|
||||
alter table llx_product_price add column price_min double(24,8) default NULL;
|
||||
alter table llx_product_price add column price_min_ttc double(24,8) default NULL;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
-- ============================================================================
|
||||
-- Copyright (C) 2002-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- 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
|
||||
@ -49,6 +50,7 @@ create table llx_product
|
||||
volume float DEFAULT NULL,
|
||||
volume_units tinyint DEFAULT NULL,
|
||||
canvas varchar(15) DEFAULT '',
|
||||
finished tinyint DEFAULT NULL,
|
||||
import_key varchar(14)
|
||||
)type=innodb;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user