ajout arbo sousproduits

This commit is contained in:
Andre Cianfarani 2006-03-20 08:54:48 +00:00
parent 646f653450
commit 2433dfaea2
3 changed files with 561 additions and 0 deletions

View File

@ -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=

View File

@ -0,0 +1,419 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2006 Régis Houssin <regis.houssin@cap-networks.com>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
*
* 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 '<table class="border" width="100%">';
print "<tr>";
$nblignes=6;
if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
if ($product->type == 1) $nblignes++;
// Reference
print '<td width="15%">'.$langs->trans("Ref").'</td><td>';
print '</td>';
if ($product->is_photo_available($conf->produit->dir_output))
{
// Photo
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
$nbphoto=$product->show_photo($conf->produit->dir_output,1);
print '</td>';
}
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '</tr>';
// associations sousproduits
print '<tr><td colspan="2">';
$product->get_sousproduits_arbo();
$prods_arbo = $product->get_arbo_each_prod();
foreach($prods_arbo as $key => $value)
{
// if($value[1] != $product->id)
print '<br>'.$value[1].' :: '.$value[0];
}
print '</td></tr>';
print "</table>\n";
print "</div>\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 '<br><div class="error">'.$mesg.'</div><br>';
}
print '<table class="border" width="100%">';
print "<tr>";
$nblignes=6;
if ($product->type == 0 && $conf->stock->enabled) $nblignes++;
if ($product->type == 1) $nblignes++;
// Reference
print '<td width="15%">'.$langs->trans("Ref").'</td><td>';
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
print '</td>';
if ($product->is_photo_available($conf->produit->dir_output))
{
// Photo
print '<td valign="middle" align="center" rowspan="'.$nblignes.'">';
$nbphoto=$product->show_photo($conf->produit->dir_output,1);
print '</td>';
}
print '</tr>';
// Libelle
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$product->libelle.'</td>';
print '</tr>';
// Nombre de sousproduits associés
$product->get_sousproduits_arbo ();
print '<tr><td>'.$langs->trans("AssociatedProductsNumber").'</td><td>'.sizeof($product->get_arbo_each_prod()).'</td>';
print '</tr>';
print '<tr><td colspan="2"><b>'.$langs->trans("ProductSearch").'</b>';
print '<table class="noborder">';
print '<tr><td><form action="./fiche.php" method="post">';
print $langs->trans("KeywordFilter");
print '</td><td><input type="text" name="key" value="'.$key.'">';
print '<input type="hidden" name="action" value="search">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '</td></tr>';
print '<tr><td>'.$langs->trans("CategoryFilter");
// if(MAIN_MODULE_CATEGORIE)
print '</td><td>'.$html->select_all_categories($catMere).'</td></tr>';
print '<tr><td colspan="2"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
print '<tr><td colspan="2">';
print '<table class="border">';
print '<tr>';
print '<td>Ref</td><td>Libelle</td><td>Ajouter</td>';
print '<form action="./fiche.php"';
if($action == 'search')
{
if ($resql)
{
$num = $db->num_rows($resql);
$i=0;
while ($i < $num)
{
$objp = $db->fetch_object($resql);
print '<tr>';
print '<td>'.$objp->ref.'</td>';
print '<td>'.$objp->label.'</td>';
print '<td align="center"><input type="checkbox" name="prod_'.$i.'" value="'.$objp->rowid.'"></td>';
print '</td>';
print '</tr>';
$i++;
}
}
else
{
dolibarr_print_error($db);
}
}
print '</table>';
print '</form></td></tr>';
print '</table>';
print '</td></tr>';
print '</table>';
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
print "\n<div class=\"tabsAction\">\n";
if ($action == '')
{
if ( $user->rights->produit->creer)
{
print '<a class="tabAction" href="./fiche.php?action=edit&amp;id='.$product->id.'">'.$langs->trans("Edit").'</a>';
}
}
print "\n</div><br>\n";
$db->close();
llxFooter('$Date$ - $Revision$');
?>

View File

@ -0,0 +1,112 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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&amp;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&amp;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);
/*
*
*
*/
}
?>