From 2433dfaea26942f63342ac0bef3eb51a24193aa8 Mon Sep 17 00:00:00 2001 From: Andre Cianfarani Date: Mon, 20 Mar 2006 08:54:48 +0000 Subject: [PATCH] ajout arbo sousproduits --- htdocs/product/sousproduits/dolibarr.log | 30 ++ htdocs/product/sousproduits/fiche.php | 419 +++++++++++++++++++++++ htdocs/product/sousproduits/pre.inc.php | 112 ++++++ 3 files changed, 561 insertions(+) create mode 100644 htdocs/product/sousproduits/dolibarr.log create mode 100644 htdocs/product/sousproduits/fiche.php create mode 100644 htdocs/product/sousproduits/pre.inc.php diff --git a/htdocs/product/sousproduits/dolibarr.log b/htdocs/product/sousproduits/dolibarr.log new file mode 100644 index 00000000000..3bb32bba7ce --- /dev/null +++ b/htdocs/product/sousproduits/dolibarr.log @@ -0,0 +1,30 @@ +2006-03-20 09:46:11 3 andre Authentification ok (en mode Pear) +2006-03-20 09:46:11 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:46:55 3 andre Authentification ok (en mode Pear) +2006-03-20 09:46:55 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:47:02 3 andre Authentification ok (en mode Pear) +2006-03-20 09:47:02 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:47:14 3 andre Authentification ok (en mode Pear) +2006-03-20 09:47:14 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:47:14 3 andre Product::fecth 6=6 ref= +2006-03-20 09:47:20 3 andre Authentification ok (en mode Pear) +2006-03-20 09:47:20 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:47:20 3 andre Product::fecth 6=6 ref= +2006-03-20 09:47:26 3 andre Authentification ok (en mode Pear) +2006-03-20 09:47:26 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:47:26 3 andre Product::fecth 6=6 ref= +2006-03-20 09:48:30 3 andre Authentification ok (en mode Pear) +2006-03-20 09:48:30 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:48:30 3 andre Product::fecth 6=6 ref= +2006-03-20 09:48:33 3 andre Authentification ok (en mode Pear) +2006-03-20 09:48:33 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:48:33 3 andre Product::fecth 6=6 ref= +2006-03-20 09:48:36 3 andre Authentification ok (en mode Pear) +2006-03-20 09:48:36 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:48:36 3 andre Product::fecth 6=6 ref= +2006-03-20 09:48:41 3 andre Authentification ok (en mode Pear) +2006-03-20 09:48:41 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:48:41 3 andre Product::fecth 6=6 ref= +2006-03-20 09:48:46 3 andre Authentification ok (en mode Pear) +2006-03-20 09:48:46 3 andre Access to /~andre/dev/dolibarr/htdocs/product/sousproduits/fiche.php +2006-03-20 09:48:46 3 andre Product::fecth 6=6 ref= diff --git a/htdocs/product/sousproduits/fiche.php b/htdocs/product/sousproduits/fiche.php new file mode 100644 index 00000000000..63e906e61ea --- /dev/null +++ b/htdocs/product/sousproduits/fiche.php @@ -0,0 +1,419 @@ + + * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2006 Régis Houssin + * Copyright (C) 2006 Andre Cianfarani + * + * 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$ + * $Source$ + */ + +/** + \file htdocs/product/fiche.php + \ingroup product + \brief Page de la fiche produit + \version $Revision$ +*/ + +require("./pre.inc.php"); + +require_once(DOL_DOCUMENT_ROOT."/product.class.php"); +// if(MAIN_MODULE_CATEGORIE) + require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); + + + +$langs->load("bills"); +$langs->load("product"); + + +$mesg = ''; +$ref=isset($_GET["ref"])?$_GET["ref"]:$_POST["ref"]; +$key=isset($_GET["key"])?$_GET["key"]:$_POST["key"]; +$catMere=isset($_GET["catMere"])?$_GET["catMere"]:$_POST["catMere"]; +$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; +$action=isset($_GET["action"])?$_GET["action"]:$_POST["action"]; +$cancel=isset($_GET["cancel"])?$_GET["cancel"]:$_POST["cancel"]; + + + +if (!$user->rights->produit->lire) accessforbidden(); + +$html = new Form($db); +$types[0] = $langs->trans("Product"); +$types[1] = $langs->trans("Service"); + +// Action mise a jour d'un produit ou service +if ($action == 'update' && + $cancel <> $langs->trans("Cancel") && + $user->rights->produit->creer) +{ + $product = new Product($db); + if ($product->fetch($_POST["id"])) + { + $product->ref = stripslashes($_POST["ref"]); + $product->libelle = stripslashes($_POST["libelle"]); + if ( isset( $_POST["price"] ) ) + $product->price = stripslashes($_POST["price"]); + $product->tva_tx = $_POST["tva_tx"]; + $product->description = stripslashes($_POST["desc"]); + $product->note = stripslashes($_POST["note"]); + $product->envente = $_POST["statut"]; + $product->seuil_stock_alerte = $_POST["seuil_stock_alerte"]; + $product->duration_value = $_POST["duration_value"]; + $product->duration_unit = $_POST["duration_unit"]; + + if ($product->check()) + { + if ($product->update($product->id, $user) > 0) + { + $action = ''; + $_GET["id"] = $_POST["id"]; + } + else + { + $action = 're-edit'; + $_GET["id"] = $_POST["id"]; + $mesg = $product->mesg_error; + } + } + else + { + $action = 're-edit'; + $_GET["id"] = $_POST["id"]; + $mesg = $langs->trans("ErrorProductBadRefOrLabel"); + } + } +} +// action recherche des produits par mot-clé et/ou par catégorie +if($action == 'search' ) +{ + $sql = 'SELECT p.rowid, p.ref, p.label, p.price, p.fk_product_type'; + $sql.= ' FROM '.MAIN_DB_PREFIX.'product as p'; + if($catMere != -1) + { + $sql .= ', '.MAIN_DB_PREFIX.'categorie_product as cp'; + } + $sql .= " WHERE 1=1"; + if($key != "") + { + $sql .= " AND (p.ref like '%".$key."%'"; + $sql .= " OR p.label like '%".$key."%')"; + } + if($catMere != -1) + { + $sql .= " AND p.rowid=cp.fk_product AND cp.fk_categorie ='".$catMere."'"; + + } + $sql .= " ORDER BY p.ref ASC "; + // $sql .= $db->plimit($limit + 1 ,$offset); + $resql = $db->query($sql) ; + + + + + + + + + + +} + +if ($cancel == $langs->trans("Cancel")) +{ + $action = ''; + Header("Location: fiche.php?id=".$_POST["id"]); + exit; +} + + + +llxHeader("","",$langs->trans("ProductServiceCard")); +$html = new Form($db); + + +/* + * Fiche produit + */ +if ($id || $ref) +{ + + if ($action <> 're-edit') + { + $product = new Product($db); + if ($id) $result = $product->fetch($id); + if ($ref) $result = $product->fetch($ref); + } + + if ( $result ) + { + + if ($action <> 'edit' &&$action <> 'search' && $action <> 're-edit') + { + /* + * En mode visu + */ + + $h=0; + + $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans("Card"); + $h++; + + $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id; + $head[$h][1] = $langs->trans("Price"); + $h++; + + //affichage onglet catégorie + if ($conf->categorie->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/categorie.php?id=".$product->id; + $head[$h][1] = $langs->trans('Categories'); + $h++; + } + + if($product->type == 0) + { + if ($user->rights->barcode->lire) + { + if ($conf->barcode->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id; + $head[$h][1] = $langs->trans("BarCode"); + $h++; + } + } + } + + $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id; + $head[$h][1] = $langs->trans("Photos"); + $h++; + + if($product->type == 0) + { + if ($conf->stock->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id; + $head[$h][1] = $langs->trans("Stock"); + $h++; + } + } + + if ($conf->fournisseur->enabled) + { + $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id; + $head[$h][1] = $langs->trans("Suppliers"); + $h++; + } + + $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans('Statistics'); + $h++; + + // sousproduits + if($conf->global->PRODUIT_SOUSPRODUITS == 1) + { + $head[$h][0] = DOL_URL_ROOT."/product/sousproduits/fiche.php?id=".$product->id; + $head[$h][1] = $langs->trans('AssociatedProducts'); + $hselected = $h; + $h++; + } + + + $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id; + $head[$h][1] = $langs->trans('Referers'); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id; + $head[$h][1] = $langs->trans('Documents'); + $h++; + + + $titre=$langs->trans("CardProduct".$product->type); + dolibarr_fiche_head($head, $hselected, $titre); + + + print($mesg); + + print ''; + + print ""; + + $nblignes=6; + if ($product->type == 0 && $conf->stock->enabled) $nblignes++; + if ($product->type == 1) $nblignes++; + + // Reference + print ''; + + if ($product->is_photo_available($conf->produit->dir_output)) + { + // Photo + print ''; + } + + print ''; + + // Libelle + print ''; + print ''; + + + + // associations sousproduits + print ''; + + + print "
'.$langs->trans("Ref").''; + print ''; + $nbphoto=$product->show_photo($conf->produit->dir_output,1); + print '
'.$langs->trans("Label").''.$product->libelle.'
'; + $product->get_sousproduits_arbo(); + $prods_arbo = $product->get_arbo_each_prod(); + foreach($prods_arbo as $key => $value) + { + // if($value[1] != $product->id) + print '
'.$value[1].' :: '.$value[0]; + } + + + print '
\n"; + + print "\n"; + } + } + + /* + * Fiche en mode edition + */ + if (($action == 'edit' || $action == 'search' || $action == 're-edit') && $user->rights->produit->creer) + { + + print_fiche_titre($langs->trans('EditAssociate').' '.$types[$product->type].' : '.$product->ref, ""); + + if ($mesg) { + print '
'.$mesg.'

'; + } + + print ''; + + print ""; + + $nblignes=6; + if ($product->type == 0 && $conf->stock->enabled) $nblignes++; + if ($product->type == 1) $nblignes++; + + // Reference + print ''; + + if ($product->is_photo_available($conf->produit->dir_output)) + { + // Photo + print ''; + } + + print ''; + + // Libelle + print ''; + print ''; + // Nombre de sousproduits associés + $product->get_sousproduits_arbo (); + print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref").''; + print ''.$product->ref.''; + print ''; + $nbphoto=$product->show_photo($conf->produit->dir_output,1); + print '
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("AssociatedProductsNumber").''.sizeof($product->get_arbo_each_prod()).'
'.$langs->trans("ProductSearch").''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("KeywordFilter"); + print '
'; + print ''; + print ''; + print '
'.$langs->trans("CategoryFilter"); + // if(MAIN_MODULE_CATEGORIE) + print ''.$html->select_all_categories($catMere).'
'; + print ''; + print ''; + print ''; + print 'num_rows($resql); + $i=0; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $i++; + } + } + else + { + dolibarr_print_error($db); + } + } + print '
RefLibelleAjouter
'.$objp->ref.''.$objp->label.'
'; + print '
'; + print '
'; + } +} + + +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ + +print "\n
\n"; + +if ($action == '') +{ + + if ( $user->rights->produit->creer) + { + print ''.$langs->trans("Edit").''; + + } + +} + +print "\n

\n"; + + + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/product/sousproduits/pre.inc.php b/htdocs/product/sousproduits/pre.inc.php new file mode 100644 index 00000000000..64735fb69a8 --- /dev/null +++ b/htdocs/product/sousproduits/pre.inc.php @@ -0,0 +1,112 @@ + + * Copyright (C) 2004 Laurent Destailleur + * + * 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$ + * $Source$ + * + */ + +/*! + \file htdocs/product/pre.inc.php + \ingroup product,service + \brief Fichier gestionnaire du menu gauche des produits et services + \version $Revision$ +*/ +require("../../main.inc.php"); + +$langs->load("products"); + +$user->getrights('produit'); +$user->getrights('propale'); +$user->getrights('facture'); + +function llxHeader($head = "", $urlp = "", $title="") +{ + global $user, $conf, $langs; + $langs->load("products"); + $user->getrights("produit"); + + top_menu($head, $title); + + $menu = new Menu(); + + if ($conf->produit->enabled) + { + $menu->add(DOL_URL_ROOT."/product/index.php?type=0", $langs->trans("Products")); + $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=0", $langs->trans("List")); + + if ($user->societe_id == 0 && $user->rights->produit->creer) + { + $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=0", $langs->trans("NewProduct")); + } + } + + if ($conf->service->enabled) + { + $menu->add(DOL_URL_ROOT."/product/index.php?type=1", $langs->trans("Services")); + $menu->add_submenu(DOL_URL_ROOT."/product/liste.php?type=1", $langs->trans("List")); + if ($user->societe_id == 0 && $user->rights->produit->creer) + { + $menu->add_submenu(DOL_URL_ROOT."/product/fiche.php?action=create&type=1", $langs->trans("NewService")); + } + } + + if ($conf->boutique->enabled) + { + $menu->add(DOL_URL_ROOT."/product/osc-liste.php", "Osc"); + $menu->add_submenu(DOL_URL_ROOT."/product/osc-liste.php?reqstock=epuise", "Produits Epuisés"); + + $menu->add(DOL_URL_ROOT."/product/osc-reviews.php", $langs->trans("Criticals")); + + $menu->add_submenu(DOL_URL_ROOT."/product/osc-productsbyreviews.php", "Meilleurs produits"); + + $menu->add(DOL_URL_ROOT."/product/album/", "Albums"); + $menu->add(DOL_URL_ROOT."/product/groupart/", "Groupes/Artistes"); + + $menu->add(DOL_URL_ROOT."/product/categorie/", $langs->trans("Categories")); + } + + if ($conf->fournisseur->enabled) { + $langs->load("suppliers"); + $menu->add(DOL_URL_ROOT."/fourn/index.php", $langs->trans("Suppliers")); + } + + $menu->add(DOL_URL_ROOT."/product/stats/", $langs->trans("Statistics")); + if ($conf->propal->enabled) + { + $menu->add_submenu(DOL_URL_ROOT."/product/popuprop.php", $langs->trans("Popularity")); + } + + if ($conf->stock->enabled) + { + $menu->add(DOL_URL_ROOT."/product/stock/", $langs->trans("Stock")); + } + + if ($conf->categorie->enabled) + { + $menu->add(DOL_URL_ROOT."/categories/", $langs->trans("Categories")); + } + + left_menu($menu->liste); + /* + * + * + */ + +} +?>