Ajout modification de la valeur du code barre et du type de code barre
This commit is contained in:
parent
77646e79e7
commit
e45f4bae77
@ -3571,6 +3571,28 @@ class Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Affiche formulaire de selection du type de code barre
|
||||||
|
* \param page Page
|
||||||
|
* \param selected Id condition présélectionnée
|
||||||
|
* \param htmlname Nom du formulaire select
|
||||||
|
*/
|
||||||
|
function form_barcode_type($page, $selected='', $htmlname='barcodetype_id')
|
||||||
|
{
|
||||||
|
global $langs,$conf;
|
||||||
|
if ($htmlname != "none")
|
||||||
|
{
|
||||||
|
print '<form method="post" action="'.$page.'">';
|
||||||
|
print '<input type="hidden" name="action" value="setbarcodetype">';
|
||||||
|
print '<table class="noborder" cellpadding="0" cellspacing="0">';
|
||||||
|
print '<tr><td>';
|
||||||
|
$this->select_barcode_type($selected, $htmlname, 1);
|
||||||
|
print '</td>';
|
||||||
|
print '<td align="left"><input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
print '</td></tr></table></form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -2494,6 +2494,52 @@ class Product
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Mise à jour du code barre
|
||||||
|
* \param user Utilisateur qui fait la modification
|
||||||
|
*/
|
||||||
|
function update_barcode($user)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
||||||
|
$sql .= " SET barcode = '".$this->barcode."'";
|
||||||
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
|
dolibarr_syslog("Product::update_barcode sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Mise à jour du type de code barre
|
||||||
|
* \param user Utilisateur qui fait la modification
|
||||||
|
*/
|
||||||
|
function update_barcode_type($user)
|
||||||
|
{
|
||||||
|
$sql = "UPDATE ".MAIN_DB_PREFIX."product";
|
||||||
|
$sql .= " SET fk_barcode_type = '".$this->barcode_type."'";
|
||||||
|
$sql .= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
|
dolibarr_syslog("Product::update_barcode_type sql=".$sql);
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Affecte les valeurs smarty
|
\brief Affecte les valeurs smarty
|
||||||
\remarks Rodolphe : pour l'instant la fonction est vide mais necessaire pour compatibilite
|
\remarks Rodolphe : pour l'instant la fonction est vide mais necessaire pour compatibilite
|
||||||
|
|||||||
@ -41,9 +41,38 @@ if (!$user->rights->barcode->lire)
|
|||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Affiche historique prix
|
* 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 vérification de la validité du code barre en fonction du type
|
||||||
|
$result = $product->update_barcode($user);
|
||||||
|
Header("Location: barcode.php?id=".$_GET["id"]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* *****************************************/
|
||||||
|
/* */
|
||||||
|
/* Mode vue et edition */
|
||||||
|
/* */
|
||||||
|
/* *************************************** */
|
||||||
|
|
||||||
llxHeader("","",$langs->trans("BarCode"));
|
llxHeader("","",$langs->trans("BarCode"));
|
||||||
|
|
||||||
$html = new Form($db);
|
$html = new Form($db);
|
||||||
@ -93,17 +122,45 @@ print $product->getLibStatut(2);
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Barcode type
|
// Barcode type
|
||||||
print '<tr><td>'.$langs->trans("BarcodeType").'</td><td colspan="2">';
|
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&id='.$product->id.'">'.img_edit($langs->trans('SetBarcodeType'),1).'</a></td>';
|
||||||
|
print '</tr></table>';
|
||||||
|
print '</td><td colspan="2">';
|
||||||
|
if ($_GET['action'] == 'editbarcodetype')
|
||||||
|
{
|
||||||
|
$html->form_barcode_type($_SERVER['PHP_SELF'].'?id='.$product->id,$product->barcode_type,'barcodetype_id');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print $product->barcode_type_label;
|
print $product->barcode_type_label;
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Barcode
|
// Barcode
|
||||||
print '<tr><td>'.$langs->trans("Barcode").'</td><td colspan="2">';
|
print '<tr><td nowrap>';
|
||||||
|
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
|
||||||
|
print $langs->trans("Barcode");
|
||||||
|
print '<td>';
|
||||||
|
if (($_GET['action'] != 'editbarcode') && $user->rights->barcode->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editbarcode&id='.$product->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 '<input type="hidden" name="action" value="setbarcode">';
|
||||||
|
print '<input size="40" type="text" name="barcode" value="'.$product->barcode.'">';
|
||||||
|
print ' <input type="submit" class="button" value="'.$langs->trans("Modify").'">';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print $product->barcode;
|
print $product->barcode;
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
|
|
||||||
print "</div>\n";
|
print "</div>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user