diff --git a/htdocs/includes/modules/modBarcode.class.php b/htdocs/includes/modules/modBarcode.class.php new file mode 100644 index 00000000000..153d973e917 --- /dev/null +++ b/htdocs/includes/modules/modBarcode.class.php @@ -0,0 +1,135 @@ + + * Copyright (C) 2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin + * + * 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$ + * $Source$ + * + */ + +/** + \defgroup produit Module code barre + \brief Module pour gérer les codes barres des produits +*/ + +/** + \file htdocs/includes/modules/modBarcode.class.php + \ingroup produit + \brief Fichier de description et activation du module Barcode +*/ + +include_once "DolibarrModules.class.php"; + +/** + \class modBarcode + \brief Classe de description et activation du module Barcode +*/ + +class modBarcode extends DolibarrModules +{ + + /** + * \brief Constructeur. Definit les noms, constantes et boites + * \param DB handler d'accès base + */ + function modBarcode($DB) + { + $this->db = $DB ; + $this->numero = 55 ; + + $this->family = "products"; + $this->name = "Codes barres"; + $this->description = "Gestion des codes barres des produits"; + + //$this->revision = explode(" ","$Revision$"); + $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version + //$this->version = $this->revision[1]; + + $this->const_name = "MAIN_MODULE_BARCODE"; + $this->const_config = MAIN_MODULE_BARCODE; + $this->special = 0; + $this->picto='product'; + + // Dir + $this->dirs = array(); + + // Dépendances + $this->depends = array("modProduit"); + $this->requiredby = array(); + + // Constantes + $this->const = array(); + + // Boxes + $this->boxes = array(); + // $this->boxes[0][0] = "Derniers produits/services enregistrés"; + // $this->boxes[0][1] = "box_produits.php"; + // $this->boxes[1][0] = "Derniers produits/services vendus"; + // $this->boxes[1][1] = "box_services_vendus.php"; + + // Permissions + $this->rights = array(); + $this->rights_class = 'barcode'; + + $this->rights[1][0] = 300; // id de la permission + $this->rights[1][1] = 'Lire les codes barres'; // libelle de la permission + $this->rights[1][2] = 'r'; // type de la permission (déprécié à ce jour) + $this->rights[1][3] = 1; // La permission est-elle une permission par défaut + $this->rights[1][4] = 'lire'; + + $this->rights[2][0] = 301; // id de la permission + $this->rights[2][1] = 'Créer/modifier les codes barres'; // libelle de la permission + $this->rights[2][2] = 'w'; // type de la permission (déprécié à ce jour) + $this->rights[2][3] = 0; // La permission est-elle une permission par défaut + $this->rights[2][4] = 'creer'; + + $this->rights[4][0] = 302; // id de la permission + $this->rights[4][1] = 'Supprimer les codes barres'; // libelle de la permission + $this->rights[4][2] = 'd'; // type de la permission (déprécié à ce jour) + $this->rights[4][3] = 0; // La permission est-elle une permission par défaut + $this->rights[4][4] = 'supprimer'; + + } + + + /** + * \brief Fonction appelée lors de l'activation du module. Insère en base les constantes, boites, permissions du module. + * Définit également les répertoires de données à créer pour ce module. + */ + function init() + { + // Permissions + $this->remove(); + + $sql = array(); + + return $this->_init($sql); + } + + /** + * \brief Fonction appelée lors de la désactivation d'un module. + * Supprime de la base les constantes, boites et permissions du module. + */ + function remove() + { + $sql = array(); + + return $this->_remove($sql); + } +} +?> diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index a8028a48cd7..88d43cd3945 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -4,7 +4,7 @@ * Copyright (C) 2004 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005 Regis Houssin + * Copyright (C) 2005 Regis Houssin * * 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 @@ -251,6 +251,7 @@ $conf->produit->enabled=defined("MAIN_MODULE_PRODUIT")?MAIN_MODULE_PRODUIT:0; if ($conf->produit->enabled) require_once(DOL_DOCUMENT_ROOT ."/product.class.php"); $conf->produit->dir_output=DOL_DATA_ROOT."/produit"; $conf->produit->dir_images=DOL_DATA_ROOT."/produit/images"; +$conf->barcode->enabled=defined("MAIN_MODULE_BARCODE")?MAIN_MODULE_BARCODE:0; $conf->categorie->enabled=defined("MAIN_MODULE_CATEGORIE")?MAIN_MODULE_CATEGORIE:0; $conf->service->enabled=defined("MAIN_MODULE_SERVICE")?MAIN_MODULE_SERVICE:0; if ($conf->service->enabled) require_once(DOL_DOCUMENT_ROOT ."/product.class.php"); diff --git a/htdocs/product/barcode.php b/htdocs/product/barcode.php new file mode 100644 index 00000000000..34d6bfb12d7 --- /dev/null +++ b/htdocs/product/barcode.php @@ -0,0 +1,140 @@ + + * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin + * + * 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$ + * $Source$ + * + */ + +/** + \file htdocs/product/barcode.php + \ingroup product + \brief Page du code barre + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$langs->load("products"); + +$user->getrights('barcode'); + +if (!$user->rights->barcode->lire) +accessforbidden(); + +$types[0] = $langs->trans("Product"); +$types[1] = $langs->trans("Service"); + +/* + * Affiche historique prix + */ + +llxHeader("","",$langs->trans("BarCode")); + +$product = new Product($db); +$result = $product->fetch($_GET["id"]); + + + $h=0; + + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][1] = $langs->trans("Price"); + $h++; + + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $hselected=$h; + $h++; + } + } + } + + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $h++; + + if($product->type == 0) + { + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $h++; + } + } + + if ($conf->fournisseur->enabled) { + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; + $head[$h][1] = $langs->trans("Suppliers"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Statistics"); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans("Bills"); + $h++; + +dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +// Prix +print ''; + +// Statut +print ''; + +print "
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("SellingPrice").''.price($product->price).'
'.$langs->trans("Status").''; +if ($product->envente) print $langs->trans("OnSell"); +else print $langs->trans("NotOnSell"); +print '

\n"; + +print "\n"; + + +/* + * Affiche code barre + */ + + + + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 6ee3e81527f..e3a5fdaab3b 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Régis Houssin * * 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 @@ -302,6 +303,19 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans("Price"); $h++; + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; $head[$h][1] = $langs->trans("Photos"); $h++; diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 3166f549de8..a679b64e08d 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin * * 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 @@ -172,10 +173,24 @@ if ($_GET["id"]) $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; $head[$h][1] = $langs->trans("Price"); $h++; + + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + - $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; - $head[$h][1] = $langs->trans("Photos"); - $h++; + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $h++; if($product->type == 0) { diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 79c70d68d6c..c3781f5da0a 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin * * 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 @@ -99,6 +100,20 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans("Price"); $h++; + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; $head[$h][1] = $langs->trans("Photos"); $hselected = $h; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 132a6509901..d784ad4685a 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin * * 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 @@ -92,6 +93,20 @@ $head[$h][1] = $langs->trans("Price"); $hselected=$h; $h++; + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; $head[$h][1] = $langs->trans("Photos"); $h++; @@ -117,7 +132,7 @@ $head[$h][1] = $langs->trans("Statistics"); $h++; $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; -$head[$h][1] = $langs->trans('Bills'); +$head[$h][1] = $langs->trans("Bills"); $h++; dolibarr_fiche_head($head, $hselected, $langs->trans("CardProduct".$product->type).' : '.$product->ref); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 62f5408aca9..172ede44ea1 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin * * 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 @@ -80,6 +81,20 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans("Price"); $h++; + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; $head[$h][1] = $langs->trans("Photos"); $h++; diff --git a/htdocs/product/stats/fiche.php b/htdocs/product/stats/fiche.php index 61a487b8c61..807f8b8c5fb 100644 --- a/htdocs/product/stats/fiche.php +++ b/htdocs/product/stats/fiche.php @@ -1,6 +1,7 @@ * Copyright (c) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Regis Houssin * * 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 @@ -115,6 +116,20 @@ if ($_GET["id"]) $head[$h][1] = $langs->trans("Price"); $h++; + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; $head[$h][1] = $langs->trans("Photos"); $h++;