Remove field stock_loc because location of product in a warehouse can't be set into the product table as it can differs between warehouses. Such feature must be stored in the join table.
This commit is contained in:
parent
5d5eb3c829
commit
4a5bb8a327
@ -1,146 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/includes/triggers/interface_modEditeur_editeur.class.php
|
||||
\ingroup core
|
||||
\brief Fichier de demo de personalisation des actions du workflow
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
\class InterfaceEditeur
|
||||
\brief Classe des fonctions triggers des actions personalisees du workflow
|
||||
*/
|
||||
|
||||
class InterfaceEditeur
|
||||
{
|
||||
var $db;
|
||||
var $error;
|
||||
|
||||
/**
|
||||
* \brief Constructeur.
|
||||
* \param DB Handler d'acces base
|
||||
*/
|
||||
function InterfaceEditeur($DB)
|
||||
{
|
||||
$this->db = $DB ;
|
||||
|
||||
$this->name = preg_replace('/^Interface/i','',get_class($this));
|
||||
$this->family = "editeur";
|
||||
$this->description = "Les triggers de ce composant tri les lignes commandes par stock_loc.";
|
||||
$this->revision = explode(' ','$Revision$');
|
||||
$this->version = $this->revision[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi nom du lot de triggers
|
||||
* \return string Nom du lot de triggers
|
||||
*/
|
||||
function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi descriptif du lot de triggers
|
||||
* \return string Descriptif du lot de triggers
|
||||
*/
|
||||
function getDesc()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Renvoi version du lot de triggers
|
||||
* \return string Version du lot de triggers
|
||||
*/
|
||||
function getVersion()
|
||||
{
|
||||
global $langs;
|
||||
$langs->load("admin");
|
||||
|
||||
if ($this->version == 'experimental') return $langs->trans("Experimental");
|
||||
elseif ($this->version == 'dolibarr') return DOL_VERSION;
|
||||
elseif ($this->version) return $this->version;
|
||||
else return $langs->trans("Unknown");
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Fonction appelee lors du declenchement d'un evenement Dolibarr.
|
||||
* D'autres fonctions run_trigger peuvent etre presentes dans includes/triggers
|
||||
* \param action Code de l'evenement
|
||||
* \param object Objet concern
|
||||
* \param user Objet user
|
||||
* \param lang Objet lang
|
||||
* \param conf Objet conf
|
||||
* \return int <0 si ko, 0 si aucune action faite, >0 si ok
|
||||
*/
|
||||
function run_trigger($action,$object,$user,$langs,$conf)
|
||||
{
|
||||
// Mettre ici le code a executer en reaction de l'action
|
||||
// Les donnees de l'action sont stockees dans $object
|
||||
|
||||
// Users
|
||||
if ($action == 'LINEBILL_INSERT')
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
|
||||
$sql = "SELECT fd.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product as p,".MAIN_DB_PREFIX."facturedet as fd";
|
||||
$sql.= " WHERE fd.fk_product = p.rowid";
|
||||
$sql.= " AND fd.special_code = 0";
|
||||
$sql.= " AND fd.fk_facture = '".$object->fk_facture."'";
|
||||
$sql.= " ORDER BY p.stock_loc ASC;";
|
||||
|
||||
$resql = $this->db->query($sql) ;
|
||||
|
||||
if ($resql)
|
||||
{
|
||||
$datas = array();
|
||||
$i = 1;
|
||||
while ( $row = $this->db->fetch_row($resql) )
|
||||
{
|
||||
$datas[$i] = $row[0];
|
||||
$i++;
|
||||
}
|
||||
|
||||
foreach($datas as $key => $value)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."facturedet ";
|
||||
$sql.= " SET rang=$key WHERE rowid=$value";
|
||||
$resql = $this->db->query($sql) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' in action '$action' SQL ERROR ");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -85,3 +85,4 @@ alter table llx_product add column accountancy_code_sell varchar(15) aft
|
||||
alter table llx_product add column accountancy_code_buy varchar(15) after accountancy_code_sell;
|
||||
|
||||
ALTER TABLE llx_product drop column stock_loc;
|
||||
ALTER TABLE llx_product add column location varchar(32);
|
||||
|
||||
@ -43,7 +43,6 @@ create table llx_product
|
||||
fk_product_type integer DEFAULT 0, -- Type 0 for regular product, 1 for service
|
||||
duration varchar(6),
|
||||
seuil_stock_alerte integer DEFAULT 0,
|
||||
stock_loc varchar(10), -- emplacement dans le stock
|
||||
barcode varchar(255) DEFAULT NULL,
|
||||
fk_barcode_type integer DEFAULT 0,
|
||||
accountancy_code_sell varchar(15), -- code compta vente
|
||||
|
||||
@ -32,7 +32,6 @@ create table llx_product_cnv_livre
|
||||
px_reliure float(12,4), -- prix de la reliure
|
||||
px_couverture float(12,4), -- prix de la couverture
|
||||
px_revient float(12,4), -- prix de revient
|
||||
stock_loc varchar(5), -- emplacement dans le stock
|
||||
|
||||
pages smallint UNSIGNED, -- nombre de page
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ create table llx_product_stock
|
||||
fk_product integer NOT NULL,
|
||||
fk_entrepot integer NOT NULL,
|
||||
reel real, -- physical stock
|
||||
pmp double(24,8) default 0 NOT NULL -- PMP value for product in this warehous
|
||||
pmp double(24,8) default 0 NOT NULL, -- PMP value for product in this warehouse
|
||||
location varchar(32) -- More information on location of product in warehouse
|
||||
)type=innodb;
|
||||
|
||||
|
||||
@ -398,7 +398,6 @@ class Product extends CommonObject
|
||||
$this->libelle = trim($this->libelle);
|
||||
$this->description = trim($this->description);
|
||||
$this->note = trim($this->note);
|
||||
$this->stock_loc = trim($this->stock_loc);
|
||||
$this->weight = price2num($this->weight);
|
||||
$this->weight_units = trim($this->weight_units);
|
||||
$this->length = price2num($this->length);
|
||||
@ -428,7 +427,6 @@ class Product extends CommonObject
|
||||
$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 .= ",description = '" . addslashes($this->description) ."'";
|
||||
$sql .= ",stock_loc = '" . addslashes($this->stock_loc) ."'";
|
||||
$sql .= ",note = '" . addslashes($this->note) ."'";
|
||||
$sql .= ",duration = '" . $this->duration_value . $this->duration_unit ."'";
|
||||
$sql .= " WHERE rowid = " . $id;
|
||||
@ -921,7 +919,7 @@ class Product extends CommonObject
|
||||
$sql = "SELECT rowid, ref, label, description, note, price, price_ttc,";
|
||||
$sql.= " price_min, price_min_ttc, price_base_type, tva_tx, envente,";
|
||||
$sql.= " fk_product_type, duration, seuil_stock_alerte, canvas,";
|
||||
$sql.= " stock_loc, 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,";
|
||||
$sql.= " stock, pmp,";
|
||||
$sql.= " import_key";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."product";
|
||||
@ -954,7 +952,6 @@ class Product extends CommonObject
|
||||
$this->duration_unit = substr($result["duration"],-1);
|
||||
$this->seuil_stock_alerte = $result["seuil_stock_alerte"];
|
||||
$this->canvas = $result["canvas"];
|
||||
$this->stock_loc = $result["stock_loc"];
|
||||
$this->weight = $result["weight"];
|
||||
$this->weight_units = $result["weight_units"];
|
||||
$this->length = $result["length"];
|
||||
|
||||
@ -182,7 +182,6 @@ if ($_POST["action"] == 'update' && ($user->rights->produit->creer || $user->rig
|
||||
$product->note = dol_htmlcleanlastbr($_POST["note"]);
|
||||
$product->status = $_POST["statut"];
|
||||
$product->seuil_stock_alerte = $_POST["seuil_stock_alerte"];
|
||||
$product->stock_loc = $_POST["stock_loc"];
|
||||
$product->duration_value = $_POST["duration_value"];
|
||||
$product->duration_unit = $_POST["duration_unit"];
|
||||
$product->canvas = $_POST["canvas"];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user