Skip to content

Commit

Permalink
Fix: update new path and uniform code
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Nov 27, 2011
1 parent 0e4d70d commit 5dd6e17
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 42 deletions.
6 changes: 3 additions & 3 deletions htdocs/core/class/html.formbarcode.class.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2007-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008-2010 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008-2011 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
Expand All @@ -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
*/

Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/admin/produit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
74 changes: 36 additions & 38 deletions htdocs/product/barcode.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* 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
Expand All @@ -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");

$id = GETPOST('id');
$ref = GETPOST('ref');
$action = GETPOST('action');

// 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';
$fieldvalue = (! empty($id) ? $id : $ref);
$fieldname = (! empty($ref) ? 'ref' : 'rowid');
if ($user->societe_id) $socid=$user->societe_id;
$result=restrictedArea($user,'produit|service&barcode',$id,'product','','',$fieldid);
$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;
}

Expand All @@ -77,13 +77,11 @@
$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);


Expand All @@ -92,15 +90,15 @@
// Reference
print '<tr>';
print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($product,'ref','',1,'ref');
print $form->showrefnav($object,'ref','',1,'ref');
print '</td>';
print '</tr>'."\n";

// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->libelle.'</td>';

// 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 '<td width="300" align="center" rowspan="5">';
print '<!-- url barcode = '.$url.' -->';
print '<img src="'.$url.'">';
Expand All @@ -110,29 +108,29 @@

// Status (to sell)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Sell").')'.'</td><td>';
print $product->getLibStatut(2,0);
print $object->getLibStatut(2,0);
print '</td></tr>';

// Status (to buy)
print '<tr><td>'.$langs->trans("Status").' ('.$langs->trans("Buy").')'.'</td><td>';
print $product->getLibStatut(2,1);
print $object->getLibStatut(2,1);
print '</td></tr>';

// Barcode type
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("BarcodeType");
print '<td>';
if (($_GET['action'] != 'editbarcodetype') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$product->id.'">'.img_edit($langs->trans('SetBarcodeType'),1).'</a></td>';
if (($_GET['action'] != 'editbarcodetype') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcodetype&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBarcodeType'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
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:'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>';
print $object->barcode_type_label?$object->barcode_type_label:'<div class="warning">'.$langs->trans("SetDefaultBarcodeType").'<div>';
}
print '</td></tr>'."\n";

Expand All @@ -141,20 +139,20 @@
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("BarcodeValue");
print '<td>';
if (($_GET['action'] != 'editbarcode') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&amp;id='.$product->id.'">'.img_edit($langs->trans('SetBarcode'),1).'</a></td>';
if (($_GET['action'] != 'editbarcode') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&amp;id='.$object->id.'">'.img_edit($langs->trans('SetBarcode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editbarcode')
{
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setbarcode">';
print '<input size="40" type="text" name="barcode" value="'.$product->barcode.'">';
print '<input size="40" type="text" name="barcode" value="'.$object->barcode.'">';
print '&nbsp;<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
}
else
{
print $product->barcode;
print $object->barcode;
}
print '</td></tr>'."\n";

Expand Down

0 comments on commit 5dd6e17

Please sign in to comment.