From 9023ec01ff962abbd2ac38133e0d09a629e2010f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 22 Mar 2010 18:43:39 +0000 Subject: [PATCH] Works on canvas capability --- .../canvas/default/product.default.class.php | 15 +- htdocs/product/canvas/service/index.php | 0 .../canvas/service/product.service.class.php | 143 ++++++++++++++++++ .../canvas/service/templates/index.php | 0 .../canvas/service/templates/liste.tpl | 102 +++++++++++++ 5 files changed, 246 insertions(+), 14 deletions(-) create mode 100644 htdocs/product/canvas/service/index.php create mode 100644 htdocs/product/canvas/service/product.service.class.php create mode 100644 htdocs/product/canvas/service/templates/index.php create mode 100644 htdocs/product/canvas/service/templates/liste.tpl diff --git a/htdocs/product/canvas/default/product.default.class.php b/htdocs/product/canvas/default/product.default.class.php index 8fab63da92e..273ab1d8955 100644 --- a/htdocs/product/canvas/default/product.default.class.php +++ b/htdocs/product/canvas/default/product.default.class.php @@ -64,7 +64,7 @@ class ProductDefault extends Product $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; $sql.= ' p.fk_product_type, p.tms as datem,'; - $sql.= ' p.duration, p.envente as statut, p.seuil_stock_alerte'; + $sql.= ' p.envente as statut, p.seuil_stock_alerte'; $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; // We'll need this table joined to the select in order to filter by categ if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; @@ -76,23 +76,10 @@ class ProductDefault extends Product $sql.= " WHERE p.entity = ".$conf->entity; if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ if (!$user->rights->produit->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 0)'; - if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; if ($sall) { $sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')"; } - # if the type is not 1, we show all products (type = 0,2,3) - if (strlen($_GET["type"]) || strlen($_POST["type"])) - { - if ($type==1) - { - $sql.= " AND p.fk_product_type = '1'"; - } - else - { - $sql.= " AND p.fk_product_type <> '1'"; - } - } if ($sref) $sql.= " AND p.ref like '%".$sref."%'"; if ($sbarcode) $sql.= " AND p.barcode like '%".$sbarcode."%'"; if ($snom) $sql.= " AND p.label like '%".addslashes($snom)."%'"; diff --git a/htdocs/product/canvas/service/index.php b/htdocs/product/canvas/service/index.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/product/canvas/service/product.service.class.php b/htdocs/product/canvas/service/product.service.class.php new file mode 100644 index 00000000000..5dd22ed5a57 --- /dev/null +++ b/htdocs/product/canvas/service/product.service.class.php @@ -0,0 +1,143 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/product/canvas/service/product.service.class.php + * \ingroup service + * \brief Fichier de la classe des services par defaut + * \version $Id$ + */ + +/** + * \class ProductService + * \brief Classe permettant la gestion services par defaut, cette classe surcharge la classe produit + */ +class ProductService extends Product +{ + //! Numero d'erreur Plage 1280-1535 + var $errno = 0; + + /** + * \brief Constructeur de la classe + * \param DB Handler acces base de donnees + * \param id Id service (0 par defaut) + */ + function ProductService($DB=0, $id=0, $user=0) + { + $this->db = $DB; + $this->id = $id ; + $this->user = $user; + $this->module = "service"; + $this->canvas = "service"; + $this->name = "service"; + $this->description = "Canvas des services"; + + $this->next_prev_filter = "canvas='service'"; + } + + function GetListeTitre() + { + return 'Services'; + } + + /** + * \brief Fetch datas list + */ + function LoadListDatas($limit, $offset, $sortfield, $sortorder) + { + global $conf; + + $sql = 'SELECT DISTINCT p.rowid, p.ref, p.label, p.barcode, p.price, p.price_ttc, p.price_base_type,'; + $sql.= ' p.fk_product_type, p.tms as datem,'; + $sql.= ' p.duration, p.envente as statut, p.seuil_stock_alerte'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; + // We'll need this table joined to the select in order to filter by categ + if ($search_categ) $sql.= ", ".MAIN_DB_PREFIX."categorie_product as cp"; + if ($_GET["fourn_id"] > 0) + { + $fourn_id = $_GET["fourn_id"]; + $sql.= ", ".MAIN_DB_PREFIX."product_fournisseur as pf"; + } + $sql.= " WHERE p.entity = ".$conf->entity; + if ($search_categ) $sql.= " AND p.rowid = cp.fk_product"; // Join for the needed table to filter by categ + if (!$user->rights->service->hidden) $sql.=' AND (p.hidden=0 OR p.fk_product_type != 1)'; + if ($sall) + { + $sql.= " AND (p.ref like '%".addslashes($sall)."%' OR p.label like '%".addslashes($sall)."%' OR p.description like '%".addslashes($sall)."%' OR p.note like '%".addslashes($sall)."%')"; + } + if ($sref) $sql.= " AND p.ref like '%".$sref."%'"; + if ($sbarcode) $sql.= " AND p.barcode like '%".$sbarcode."%'"; + if ($snom) $sql.= " AND p.label like '%".addslashes($snom)."%'"; + if (isset($_GET["envente"]) && strlen($_GET["envente"]) > 0) + { + $sql.= " AND p.envente = ".addslashes($_GET["envente"]); + } + if (isset($_GET["canvas"]) && strlen($_GET["canvas"]) > 0) + { + $sql.= " AND p.canvas = '".addslashes($_GET["canvas"])."'"; + } + if($catid) + { + $sql.= " AND cp.fk_categorie = ".$catid; + } + if ($fourn_id > 0) + { + $sql.= " AND p.rowid = pf.fk_product AND pf.fk_soc = ".$fourn_id; + } + // Insert categ filter + if ($search_categ) + { + $sql .= " AND cp.fk_categorie = ".addslashes($search_categ); + } + $sql.= $this->db->order($sortfield,$sortorder); + $sql.= $this->db->plimit($limit + 1 ,$offset); + + $this->list_datas = array(); + + $resql = $this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + + $i = 0; + while ($i < min($num,$limit)) + { + $datas = array(); + $obj = $this->db->fetch_object($resql); + + $datas["id"] = $obj->rowid; + $datas["ref"] = $obj->ref; + $datas["label"] = $obj->label; + $datas["barcode"] = $obj->barcode; + $datas["statut"] = $obj->statut; + + array_push($this->list_datas,$datas); + + $i++; + } + $this->db->free($resql); + } + else + { + print $sql; + } + } + +} + +?> \ No newline at end of file diff --git a/htdocs/product/canvas/service/templates/index.php b/htdocs/product/canvas/service/templates/index.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/product/canvas/service/templates/liste.tpl b/htdocs/product/canvas/service/templates/liste.tpl new file mode 100644 index 00000000000..cb4458900e0 --- /dev/null +++ b/htdocs/product/canvas/service/templates/liste.tpl @@ -0,0 +1,102 @@ +{* Copyright (C) 2009-2010 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + *} + + + + + + + + +
+ {$title_picto} + +
{$title_text}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +{section name=mysec loop=$datas} +{strip} + + + + + + + + + +{/strip} +{/section} + +
Référence + + A-Z + + + Z-A + + Libellé + + A-Z + + + Z-A + + Code barre + + A-Z + + + Z-A + + Date de modificationDuréePrix de venteEtat
    + + +
{$datas[mysec].ref}{$datas[mysec].label}{$datas[mysec].barcode}{$datas[mysec].datem}{$datas[mysec].duration}{$datas[mysec].sellingprice}{$datas[mysec].status}
+
+ + \ No newline at end of file