* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2010 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, see . */ /** * \file htdocs/product/barcode.php * \ingroup product * \brief Page with bar code informations of product */ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php"); $langs->load("products"); $langs->load("bills"); // Security check if (isset($_GET["id"]) || isset($_GET["ref"])) { $id = isset($_GET["id"])?$_GET["id"]:(isset($_GET["ref"])?$_GET["ref"]:''); } $fieldid = isset($_GET["ref"])?'ref':'rowid'; if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'produit|service&barcode',$id,'product','','',$fieldid); /* * Actions */ // Modification du type de code barre if ($_POST['action'] == 'setbarcodetype' && $user->rights->barcode->creer) { $product = new Product($db); $product->fetch($_GET["id"]); $product->barcode_type = $_POST['barcodetype_id']; $result = $product->update_barcode_type($user); Header("Location: barcode.php?id=".$_GET["id"]); exit; } // Modification du code barre if ($_POST['action'] == 'setbarcode' && $user->rights->barcode->creer) { $product = new Product($db); $product->fetch($_GET["id"]); $product->barcode = $_POST['barcode']; //Todo: ajout verification de la validite du code barre en fonction du type $result = $product->update_barcode($user); Header("Location: barcode.php?id=".$_GET["id"]); exit; } /* * View */ llxHeader("","",$langs->trans("BarCode")); $html = new Form($db); $formbarcode = new FormBarCode($db); $product = new Product($db); if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]); if ($_GET["id"]) $result = $product->fetch($_GET["id"]); $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); $picto=($product->type==1?'service':'product'); dol_fiche_head($head, 'barcode', $titre, 0, $picto); print ''."\n"; // Reference print ''; print ''; print ''."\n"; // Libelle print ''; // Barcode image $url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($product->barcode_type_coder).'&code='.urlencode($product->barcode).'&encoding='.urlencode($product->barcode_type_code); print ''; print ''."\n"; // Status (to sell) print ''; // Status (to buy) print ''; // Barcode type print ''."\n"; // Barcode value print ''."\n"; print "
'.$langs->trans("Ref").''; print $html->showrefnav($product,'ref','',1,'ref'); print '
'.$langs->trans("Label").''.$product->libelle.''; print ''; print ''; print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.''; print $product->getLibStatut(2,0); print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.''; print $product->getLibStatut(2,1); print '
'; print ''; print '
'; print $langs->trans("BarcodeType"); print ''; if (($_GET['action'] != 'editbarcodetype') && $user->rights->barcode->creer) print 'id.'">'.img_edit($langs->trans('SetBarcodeType'),1).'
'; print '
'; if ($_GET['action'] == 'editbarcodetype') { $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$product->id,$product->barcode_type,'barcodetype_id'); } else { print $product->barcode_type_label?$product->barcode_type_label:'
'.$langs->trans("SetDefaultBarcodeType").'
'; } print '
'; print ''; print '
'; print $langs->trans("BarcodeValue"); print ''; if (($_GET['action'] != 'editbarcode') && $user->rights->barcode->creer) print 'id.'">'.img_edit($langs->trans('SetBarcode'),1).'
'; print '
'; if ($_GET['action'] == 'editbarcode') { print '
'; print ''; print ''; print ''; print ' '; } else { print $product->barcode; } print '
\n"; print "\n"; $db->close(); llxFooter(); ?>