From 052e507271961c87b32b10d1197125b58f3db4da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Oct 2014 15:56:04 +0200 Subject: [PATCH] Update productonoff.php --- htdocs/core/ajax/productonoff.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/htdocs/core/ajax/productonoff.php b/htdocs/core/ajax/productonoff.php index 4def2898c10..227a9ef9001 100644 --- a/htdocs/core/ajax/productonoff.php +++ b/htdocs/core/ajax/productonoff.php @@ -27,12 +27,14 @@ if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; $action=GETPOST('action','alpha'); $name=GETPOST('name','alpha'); $id=GETPOST('id', 'int'); +$value=GETPOST('value', 'int'); +$object = new GenericObject($db); /* * View */ @@ -42,24 +44,15 @@ top_httphead(); print ''."\n"; // Registering the location of boxes -if (! empty($action) && ! empty($name) &&! empty($id)) +if (! empty($action) && ! empty($id)) { //$entity = GETPOST('entity','int'); if ($user->rights->produit->creer) { - if ($action == 'set' && $name== 'status') { - $sql = "UPDATE llx_product SET tosell=1 WHERE rowid=".$id; - $resql = $db->query($sql); - } else if ($action == 'set' && $name== 'status_buy') { - $sql = "UPDATE llx_product SET tobuy=1 WHERE rowid=".$id; - $resql = $db->query($sql); - } else if ($action == 'del' && $name== 'status') { - $sql = "UPDATE llx_product SET tosell=0 WHERE rowid=".$id; - $resql = $db->query($sql); - } else if ($action == 'del' && $name== 'status_buy') { - $sql = "UPDATE llx_product SET tobuy=0 WHERE rowid=".$id; - $resql = $db->query($sql); - } + if ($action == 'setstatus') + $object->setValueFrom('tosell', $value, 'product', $id); + else if ($action == 'setstatus_buy') + $object->setValueFrom('tobuy', $value, 'product', $id); } }