From 5dd6e177b5cd637486bcfa1a67c4cb9331fe1b3b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 27 Nov 2011 17:42:25 +0100 Subject: [PATCH] Fix: update new path and uniform code --- htdocs/core/class/html.formbarcode.class.php | 6 +- htdocs/product/admin/produit.php | 2 +- htdocs/product/barcode.php | 78 ++++++++++---------- 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/htdocs/core/class/html.formbarcode.class.php b/htdocs/core/class/html.formbarcode.class.php index 703715c15c4..cd526042024 100644 --- a/htdocs/core/class/html.formbarcode.class.php +++ b/htdocs/core/class/html.formbarcode.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2008-2010 Laurent Destailleur +/* Copyright (C) 2007-2011 Regis Houssin + * Copyright (C) 2008-2011 Laurent Destailleur * * 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 @@ -18,7 +18,7 @@ */ /** - * \file htdocs/includes/barcode/html.formbarcode.class.php + * \file htdocs/core/class/html.formbarcode.class.php * \brief Fichier de la classe des fonctions predefinie de composants html */ diff --git a/htdocs/product/admin/produit.php b/htdocs/product/admin/produit.php index e19fceb7448..a158bc5a4b7 100644 --- a/htdocs/product/admin/produit.php +++ b/htdocs/product/admin/produit.php @@ -28,7 +28,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); -require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formbarcode.class.php"); $langs->load("admin"); diff --git a/htdocs/product/barcode.php b/htdocs/product/barcode.php index 58e9d13ee75..a46d8311cef 100644 --- a/htdocs/product/barcode.php +++ b/htdocs/product/barcode.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2005-2011 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 @@ -26,44 +26,44 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/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"); +require_once(DOL_DOCUMENT_ROOT."/core/class/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); +$id = GETPOST('id'); +$ref = GETPOST('ref'); +$action = GETPOST('action'); +// Security check +$fieldvalue = (! empty($id) ? $id : $ref); +$fieldname = (! empty($ref) ? 'ref' : 'rowid'); +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'produit|service&barcode',$fieldvalue,'product','','',$fieldname); + +$object = new Product($db); /* * Actions */ // Modification du type de code barre -if ($_POST['action'] == 'setbarcodetype' && $user->rights->barcode->creer) +if ($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"]); + $object->fetch($id); + $object->barcode_type = $_POST['barcodetype_id']; + $result = $object->update_barcode_type($user); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } // Modification du code barre -if ($_POST['action'] == 'setbarcode' && $user->rights->barcode->creer) +if ($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"]); + $object->fetch($id); + $object->barcode = $_POST['barcode']; //Todo: ajout verification de la validite du code barre en fonction du type + $result = $object->update_barcode($user); + Header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } @@ -77,13 +77,11 @@ llxHeader("","",$langs->trans("BarCode")); $form = 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"]); +$result = $object->fetch($id,$ref); -$head=product_prepare_head($product, $user); -$titre=$langs->trans("CardProduct".$product->type); -$picto=($product->type==1?'service':'product'); +$head=product_prepare_head($object, $user); +$titre=$langs->trans("CardProduct".$object->type); +$picto=($object->type==1?'service':'product'); dol_fiche_head($head, 'barcode', $titre, 0, $picto); @@ -92,15 +90,15 @@ print ''."\n"; // Reference print ''; print ''; print ''."\n"; // Libelle -print ''; +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); +$url=DOL_URL_ROOT.'/viewimage.php?modulepart=barcode&generator='.urlencode($object->barcode_type_coder).'&code='.urlencode($object->barcode).'&encoding='.urlencode($object->barcode_type_code); print ''."\n"; // Status (to sell) print ''; // Status (to buy) print ''; // Barcode type @@ -123,16 +121,16 @@ print ''."\n"; @@ -141,20 +139,20 @@ print ''."\n";
'.$langs->trans("Ref").''; -print $form->showrefnav($product,'ref','',1,'ref'); +print $form->showrefnav($object,'ref','',1,'ref'); print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("Label").''.$object->libelle.''; print ''; print ''; @@ -110,12 +108,12 @@ print '
'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.''; -print $product->getLibStatut(2,0); +print $object->getLibStatut(2,0); print '
'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.''; -print $product->getLibStatut(2,1); +print $object->getLibStatut(2,1); print '
'; print ''; +if (($_GET['action'] != 'editbarcodetype') && $user->rights->barcode->creer) print ''; print '
'; print $langs->trans("BarcodeType"); print ''; -if (($_GET['action'] != 'editbarcodetype') && $user->rights->barcode->creer) print 'id.'">'.img_edit($langs->trans('SetBarcodeType'),1).'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'); + $formbarcode->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$object->id,$object->barcode_type,'barcodetype_id'); } else { - print $product->barcode_type_label?$product->barcode_type_label:'
'.$langs->trans("SetDefaultBarcodeType").'
'; + print $object->barcode_type_label?$object->barcode_type_label:'
'.$langs->trans("SetDefaultBarcodeType").'
'; } print '
'; print ''; +if (($_GET['action'] != 'editbarcode') && $user->rights->barcode->creer) print ''; print '
'; print $langs->trans("BarcodeValue"); print ''; -if (($_GET['action'] != 'editbarcode') && $user->rights->barcode->creer) print 'id.'">'.img_edit($langs->trans('SetBarcode'),1).'id.'">'.img_edit($langs->trans('SetBarcode'),1).'
'; print '
'; if ($_GET['action'] == 'editbarcode') { - print '
'; + print ''; print ''; print ''; - print ''; + print ''; print ' '; } else { - print $product->barcode; + print $object->barcode; } print '