From 77d77642154d1aeb15f544d58e3407cf9f3040d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 12 Oct 2014 14:22:32 +0200 Subject: [PATCH] Create productonoff.php --- htdocs/core/ajax/productonoff.php | 65 +++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 htdocs/core/ajax/productonoff.php diff --git a/htdocs/core/ajax/productonoff.php b/htdocs/core/ajax/productonoff.php new file mode 100644 index 00000000000..4def2898c10 --- /dev/null +++ b/htdocs/core/ajax/productonoff.php @@ -0,0 +1,65 @@ +. + */ + +/** + * \file htdocs/core/ajax/productonoff.php + * \brief File to set tosell and tobuy for product + */ + +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +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'; + +$action=GETPOST('action','alpha'); +$name=GETPOST('name','alpha'); +$id=GETPOST('id', 'int'); + +/* + * View + */ + +top_httphead(); + +print ''."\n"; + +// Registering the location of boxes +if (! empty($action) && ! empty($name) &&! 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); + } + + } +}