diff --git a/htdocs/categories/categorie.class.php b/htdocs/categories/categorie.class.php index 95d813cae61..c391b31c831 100644 --- a/htdocs/categories/categorie.class.php +++ b/htdocs/categories/categorie.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2006 Regis Houssin * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -24,6 +25,7 @@ */ require_once(DOL_DOCUMENT_ROOT."/product.class.php"); +require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php"); class Categorie @@ -34,6 +36,7 @@ class Categorie var $label; var $description; var $statut; + var $type; var $cats=array(); // Tableau en memoire des categories var $motherof = array(); // Tableau des correspondances id_fille -> id_mere @@ -60,7 +63,7 @@ class Categorie */ function fetch($id) { - $sql = "SELECT rowid, label, description, visible"; + $sql = "SELECT rowid, label, description, visible, type"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie WHERE rowid = ".$id; $resql = $this->db->query ($sql); @@ -73,6 +76,7 @@ class Categorie $this->label = $res['label']; $this->description = stripslashes($res['description']); $this->visible = $res['visible']; + $this->type = $res['type']; $this->db->free($resql); } @@ -115,8 +119,8 @@ class Categorie return -1; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, visible) "; - $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."', '".$this->visible."')"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description, visible,type) "; + $sql .= "VALUES ('".addslashes($this->label)."', '".addslashes($this->description)."', '".$this->visible."',".$this->type.")"; $res = $this->db->query ($sql); @@ -303,15 +307,15 @@ class Categorie * -1 : erreur SQL * -2 : id non renseign */ - function add_product($prod) + function add_type($obj,$type) { if ($this->id == -1) { return -2; } - $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_product (fk_categorie, fk_product)"; - $sql .= " VALUES (".$this->id.", ".$prod->id.")"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type." (fk_categorie, fk_".$type.")"; + $sql .= " VALUES (".$this->id.", ".$obj->id.")"; if ($this->db->query($sql)) { @@ -330,11 +334,11 @@ class Categorie * retour : 1 : OK * -1 : erreur SQL */ - function del_product($prod) + function del_type($obj,$type) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_product"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."categorie_".$type; $sql .= " WHERE fk_categorie = ".$this->id; - $sql .= " AND fk_product = ".$prod->id; + $sql .= " AND fk_".$type." = ".$obj->id; if ($this->db->query($sql)) { @@ -350,23 +354,23 @@ class Categorie /** * Retourne les produits de la catégorie */ - function get_products() + function get_type($type,$class) { - $sql = "SELECT fk_product FROM ".MAIN_DB_PREFIX."categorie_product "; + $sql = "SELECT fk_".$type." FROM ".MAIN_DB_PREFIX."categorie_".$type." "; $sql .= "WHERE fk_categorie = ".$this->id; $res = $this->db->query($sql); if ($res) { - $prods = array(); + $obj = array(); while ($rec = $this->db->fetch_array ($res)) { - $prod = new Product ($this->db, $rec['fk_product']); - $prod->fetch ($prod->id); - $prods[] = $prod; + $obj = new $class ($this->db, $rec['fk_'.$type]); + $obj->fetch ($obj->id); + $objs[] = $obj; } - return $prods; + return $objs; } else { @@ -374,6 +378,10 @@ class Categorie return -1; } } + + + + /** * Retourne les filles de la catégorie */ @@ -444,7 +452,7 @@ class Categorie * fullpath = chemin complet compose des id * \return array Tableau de array */ - function get_full_arbo() + function get_full_arbo($type) { // Charge tableau des meres $sql = "SELECT fk_categorie_mere as id_mere, fk_categorie_fille as id_fille"; @@ -468,6 +476,7 @@ class Categorie $sql.= " FROM ".MAIN_DB_PREFIX."categorie as c"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_association as ca"; $sql.= " ON c.rowid=ca.fk_categorie_mere"; + $sql.= " WHERE c.type = ".$type; $sql.= " ORDER BY c.label, c.rowid"; $res = $this->db->query ($sql); if ($res) @@ -476,9 +485,11 @@ class Categorie $i=0; while ($obj = $this->db->fetch_object($res)) { + $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['id_mere'] = $this->motherof[$obj->rowid]; $this->cats[$obj->rowid]['label'] = $obj->label; + if ($obj->rowid_fille) { if (is_array($this->cats[$obj->rowid]['id_children'])) @@ -494,6 +505,7 @@ class Categorie } } $i++; + } } else @@ -820,12 +832,12 @@ class Categorie /** * Retourne les catégories contenant le produit $id */ - function containing ($id) + function containing ($id,$type) { $cats = array (); - $sql = "SELECT fk_categorie FROM ".MAIN_DB_PREFIX."categorie_product "; - $sql .= "WHERE fk_product = ".$id; + $sql = "SELECT fk_categorie FROM ".MAIN_DB_PREFIX."categorie_".$type." "; + $sql .= "WHERE fk_".$type." = ".$id; $res = $this->db->query ($sql); @@ -848,13 +860,13 @@ class Categorie /** * Retourne les catégories contenant le produit $ref */ - function containing_ref ($ref) + function containing_ref ($ref,$type) { $cats = array (); - $sql = "SELECT c.fk_categorie, c.fk_product, p.rowid, p.ref"; - $sql.= " FROM ".MAIN_DB_PREFIX."categorie_product as c, ".MAIN_DB_PREFIX."product as p"; - $sql.= " WHERE p.ref = '".$ref."' AND c.fk_product = p.rowid"; + $sql = "SELECT c.fk_categorie, c.fk_".$type.", p.rowid, p.ref"; + $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as c, ".MAIN_DB_PREFIX.$type." as p"; + $sql.= " WHERE p.ref = '".$ref."' AND c.fk_".$type." = p.rowid"; $res = $this->db->query ($sql); @@ -873,28 +885,34 @@ class Categorie return -1; } } + + + + + /** * \brief Retourne les catégories dont l'id ou le nom correspond * ajoute des wildcards au nom sauf si $exact = true */ - function rechercher($id, $nom, $exact = false) + function rechercher($id, $nom, $type, $exact = false) { $cats = array (); // Generation requete recherche $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie "; + $sql .= "WHERE type = ".$type." "; if ($nom) { if (! $exact) { $nom = '%'.str_replace ('*', '%', $nom).'%'; } - $sql.= "WHERE label LIKE '".$nom."'"; + $sql.= "AND label LIKE '".$nom."'"; } if ($id) { - $sql.="WHERE rowid = '".$id."'"; + $sql.="AND rowid = '".$id."'"; } $res = $this->db->query ($sql); diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 6a901ace600..5baaa07e65e 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -117,7 +118,7 @@ else print ''; print ''.$langs->trans("AddIn").''; -print $html->select_all_categories($categorie->id_mere); +print $html->select_all_categories($categorie->type,$categorie->id_mere); print ''; print ''.$langs->trans("ContentsVisibleByAll").''; diff --git a/htdocs/categories/fiche.php b/htdocs/categories/fiche.php index af1f76cd8b7..17fe80b5b80 100644 --- a/htdocs/categories/fiche.php +++ b/htdocs/categories/fiche.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2006 Laurent Destailleur * Copyright (C) 2006 Regis Houssin + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -43,7 +44,10 @@ else if ($_REQUEST['origin']) { - $idprodorigin = $_REQUEST['origin']; + if($_GET['type'] == 0)$idprodorigin = $_REQUEST['origin']; + if($_GET['type'] == 1)$idSupplierorigin = $_REQUEST['origin']; + if($_GET['type'] == 2)$idCompanyorigin = $_REQUEST['origin']; + } @@ -60,6 +64,7 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) $categorie->label = $_POST["nom"]; $categorie->description = $_POST["description"]; $categorie->visible = $_POST["visible"]; + $categorie->type = $_POST["type"]; if($_POST['catMere'] != "-1") $categorie->id_mere = $_POST['catMere']; @@ -97,11 +102,18 @@ if ($_POST["action"] == 'add' && $user->rights->categorie->creer) print '
'.$langs->trans("CategorySuccessfullyCreated",$categorie->label).'
'; - if ($_REQUEST['idprodorigin']) + if ($idprodorigin) { - $idprodorigin = $_REQUEST['idprodorigin']; print ''.$langs->trans("ReturnInProduct").''; } + if ($idSupplierorigin) + { + print ''.$langs->trans("ReturnInSupplier").''; + } + if ($idCompanyorigin) + { + print ''.$langs->trans("ReturnInCompany").''; + } print ''; } @@ -121,14 +133,16 @@ if ($user->rights->categorie->creer) print $categorie->error; print ''; } - print '
'; + print ''; print ''; print ''; - if ($idprodorigin) + print ''; + if ($_REQUEST['origin']) { - print ''; + print ''; } - + print ''; + print ''; print_fiche_titre($langs->trans("CreateCat")); print ''; @@ -152,7 +166,7 @@ if ($user->rights->categorie->creer) print ''; print ''; print '
'.$langs->trans ("AddIn").''; - print $html->select_all_categories(); + print $html->select_all_categories($_GET['type']); print '
'.$langs->trans ("ContentsVisibleByAll").''; print $html->selectyesnonum("visible", 1); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 3c2b66031ec..18d2ce6c499 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005 Éric Seigne * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -32,6 +33,7 @@ require "./pre.inc.php"; if (!$user->rights->categorie->lire) accessforbidden(); + /** * Affichage page accueil */ @@ -50,7 +52,8 @@ print '
'; /* * Zone recherche produit/service */ -print ''; +print ''; +print ''; print ''; print ''; print ''; @@ -77,7 +80,7 @@ print '
'.$langs->trans("Search").''; */ if($_POST['catname'] || $_REQUEST['id']) { - $cats = $c->rechercher($_REQUEST['id'],$_POST['catname']); + $cats = $c->rechercher($_REQUEST['id'],$_POST['catname'],$_POST['type']); print ''; print ''; @@ -101,7 +104,7 @@ print '
'; // Charge tableau des categories -$cate_arbo = $c->get_full_arbo(); +$cate_arbo = $c->get_full_arbo($_GET['type']); /* @@ -157,7 +160,6 @@ if ($conf->use_javascript) $i++; $nodeparent=ereg_replace('_[0-9]+$','',$cate_arbo[$key]['fullpath']); if (! $nodeparent) $nodeparent=$rootnode; - // Definition du nouvel element a ajouter dans l'arbre $newelement=array( 'text' => $cate_arbo[$key]['label'], @@ -179,8 +181,8 @@ if ($conf->use_javascript) $newelement['expanded']=false; } } - - //print 'x'.$cate_arbo[$key]['fullpath'].' ' expand='.$newelement['expanded'].'
'; + //echo $nodeparent."|"; + //print 'x'.$cate_arbo[$key]['fullpath'].' expand='.$newelement['expanded'].'
'; $node[$cate_arbo[$key]['fullpath']]=&$node[$nodeparent]->addItem(new HTML_TreeNode($newelement)); //print 'Resultat: noeud '.$cate_arbo[$key]['fullpath']." créé
\n"; } diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index d128d201e99..909248243cb 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -1,6 +1,7 @@ * Copyright (C) 2006-2007 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -183,42 +184,119 @@ else } -$prods = $c->get_products (); -if ($prods < 0) +if($c->type == 0) { - dolibarr_print_error(); -} -else -{ - print "
"; - print "
'.$langs->trans("FoundCats").'
\n"; - print "\n"; - - if (sizeof ($prods) > 0) + + $prods = $c->get_type ("product","Product"); + if ($prods < 0) { - $i = 0; - $var=true; - foreach ($prods as $prod) - { - $i++; - $var=!$var; - print "\t\n"; - print '\n"; - print '\n"; - print '\n"; - print "\n"; - } + dolibarr_print_error(); } else { - print ""; + print "
"; + print "
".$langs->trans("ProductsAndServices")."
'; - if ($prod->type == 1) print img_object($langs->trans("ShowService"),"service"); - else print img_object($langs->trans("ShowProduct"),"product"); - print " ".$prod->ref."'.$prod->libelle."'.$prod->description."
".$langs->trans ("NoProd")."
\n"; + print "\n"; + + if (sizeof ($prods) > 0) + { + $i = 0; + $var=true; + foreach ($prods as $prod) + { + $i++; + $var=!$var; + print "\t\n"; + print '\n"; + print '\n"; + print '\n"; + print "\n"; + } + } + else + { + print ""; + } + print "
".$langs->trans("ProductsAndServices")."
'; + if ($prod->type == 1) print img_object($langs->trans("ShowService"),"service"); + else print img_object($langs->trans("ShowProduct"),"product"); + print " ".$prod->ref."'.$prod->libelle."'.$prod->description."
".$langs->trans ("NoProd")."
\n"; } - print "
\n"; } +if($c->type == 1) +{ + $socs = $c->get_type ("societe","Fournisseur"); + if ($socs < 0) + { + dolibarr_print_error(); + } + else + { + print "
"; + print "\n"; + print "\n"; + + if (sizeof ($socs) > 0) + { + $i = 0; + $var=true; + foreach ($socs as $soc) + { + $i++; + $var=!$var; + print "\t\n"; + print '\n"; + + print "\n"; + } + } + else + { + print ""; + } + print "
".$langs->trans("Suppliers")."
'; + print img_object($langs->trans("ShowSuppliers"),"company"); + print " ".$soc->nom."
".$langs->trans ("NoProd")."
\n"; + } +} + +if($c->type == 2) +{ + $socs = $c->get_type ("societe","Societe"); + if ($socs < 0) + { + dolibarr_print_error(); + } + else + { + print "
"; + print "\n"; + print "\n"; + + if (sizeof ($socs) > 0) + { + $i = 0; + $var=true; + foreach ($socs as $soc) + { + $i++; + $var=!$var; + print "\t\n"; + print '\n"; + + print "\n"; + } + } + else + { + print ""; + } + print "
".$langs->trans("Commercial")."
'; + print img_object($langs->trans("ShowCompany"),"company"); + print " ".$soc->nom."
".$langs->trans ("NoProd")."
\n"; + } +} $db->close(); diff --git a/htdocs/comm/categorie.php b/htdocs/comm/categorie.php new file mode 100644 index 00000000000..3d110db8e93 --- /dev/null +++ b/htdocs/comm/categorie.php @@ -0,0 +1,372 @@ + + * Copyright (C) 2005 Brice Davoleau + * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin + * + * 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/categorie.php + \ingroup product + \brief Page de l'onglet categories de produits + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/societe.class.php"); +require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); + +$langs->load("categories"); +$langs->load("companies"); + +if (!$user->rights->societe->lire) accessforbidden(); + +$mesg = ''; + + +/* +* Actions +*/ + +//on veut supprimer une catégorie +if ($_REQUEST["removecat"] && $user->rights->societe->creer) +{ + $soc = new Societe($db); + if ($_REQUEST["socid"]) $result = $soc->fetch($_REQUEST["socid"]); + + $cat = new Categorie($db,$_REQUEST["removecat"]); + $result=$cat->del_type($soc,"societe"); +} + +//on veut ajouter une catégorie +if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0 && $user->rights->societe->creer) +{ + $soc = new Societe($db); + if ($_REQUEST["socid"]) $result = $soc->fetch($_REQUEST["socid"]); + + $cat = new Categorie($db,$_REQUEST["catMere"]); + $result=$cat->add_type($soc,"societe"); + if ($result >= 0) + { + $mesg='
'.$langs->trans("Added").'
'; + } + else + { + $mesg='
'.$langs->trans("Error").' '.$cat->error.'
'; + } + +} + + + +/* +* Creation de l'objet fournisseur correspondant à l'id +*/ +if ($_GET["socid"] || $_GET["ref"]) +{ + $soc = new Societe($db); + if ($_GET["socid"]) $result = $soc->fetch($_GET["socid"]); + + llxHeader("","",$langs->trans("CardCompany".$soc->type)); +} + + +$html = new Form($db); + + +/* + * Fiche produit + */ +if ($_GET["socid"] || $_GET["ref"]) +{ + + + + + /* + * Affichage onglets + */ + $head = societe_prepare_head($soc); + + dolibarr_fiche_head($head, 'category', $soc->nom); + + + print ''; + print '
'; + print ''; + + print ''; + + print ''; + + if ($soc->client) + { + print ''; + } + + print ""; + + print '"; + print '"; + if ($soc->pays) { + print ''; + } + + print ''; + print ''; + + print '"; + + // Assujeti à TVA ou pas + print ''; + print ''; + print ''; + + // Conditions de réglement par défaut + $langs->load('bills'); + $html = new Form($db); + print '"; + print ''; + + // Mode de règlement + print '"; + print ''; + + // Réductions relative (Remises-Ristournes-Rabbais) + print ''; + print ''; + + // Réductions absolues (Remises-Ristournes-Rabbais) + print ''; + print ''; + print ''; + + // multiprix + if($conf->global->PRODUIT_MULTIPRICES == 1) + { + print '"; + print ''; + } + + // Adresse de livraison + if ($conf->expedition->enabled) + { + print ''; + print ''; + } + + print "
'.$langs->trans("Name").''; + print $soc->nom; + print '
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print $soc->code_client; + if ($soc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode"); + print '
".$langs->trans('Address')."".nl2br($soc->adresse)."
'.$langs->trans('Zip').''.$soc->cp."'.$langs->trans('Town').''.$soc->ville."
'.$langs->trans('Country').''.$soc->pays.'
'.$langs->trans('Phone').''.dolibarr_print_phone($soc->tel,$soc->pays_code).''.$langs->trans('Fax').''.dolibarr_print_phone($soc->fax,$soc->pays_code).'
'.$langs->trans("Web")."url\" target=\"_blank\">".$soc->url." 
'.$langs->trans('VATIsUsed').''; + print yn($soc->tva_assuj); + print '
'; + print ''; + print '
'; + print $langs->trans('PaymentConditions'); + print ''; + if (($_GET['action'] != 'editconditions') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print '
'; + if ($_GET['action'] == 'editconditions') + { + $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$soc->id,$soc->cond_reglement,'cond_reglement_id',-1,1); + } + else + { + $html->form_conditions_reglement($_SERVER['PHP_SELF'].'?socid='.$soc->id,$soc->cond_reglement,'none'); + } + print "
'; + print ''; + print '
'; + print $langs->trans('PaymentMode'); + print ''; + if (($_GET['action'] != 'editmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; + print '
'; + if ($_GET['action'] == 'editmode') + { + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$soc->id,$soc->mode_reglement,'mode_reglement_id'); + } + else + { + $html->form_modes_reglement($_SERVER['PHP_SELF'].'?socid='.$soc->id,$soc->mode_reglement,'none'); + } + print "
'; + print '
'; + print $langs->trans("CustomerRelativeDiscountShort"); + print ''; + if ($user->rights->societe->creer) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.($soc->remise_client?$soc->remise_client.'%':$langs->trans("DiscountNone")).'
'; + print ''; + print '
'; + print $langs->trans("CustomerAbsoluteDiscountShort"); + print ''; + if ($user->rights->societe->creer) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; + $amount_discount=$soc->getcurrentDiscount(); + if ($amount_discount < 0) dolibarr_print_error($db,$societe->error); + if ($amount_discount > 0) print $amount_discount.' '.$langs->trans("Currency".$conf->monnaie); + else print $langs->trans("DiscountNone"); + print '
'; + print '
'; + print $langs->trans("PriceLevel"); + print ''; + if ($user->rights->societe->creer) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'.$soc->price_level."
'; + print '
'; + print $langs->trans("DeliveriesAddress"); + print ''; + if ($user->rights->societe->creer) + { + print ''.img_edit($langs->trans("Modify")).''; + } + print '
'; + print '
'; + + $sql = "SELECT count(rowid) as nb"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_adresse_livraison"; + $sql.= " WHERE fk_societe =".$soc->id; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $objal = $db->fetch_object($resql); + print $objal->nb?($objal->nb):$langs->trans("NoOtherDeliveryAddress"); + } + else + { + dolibarr_print_error($db); + } + + print '
"; + + print ''; + + + if ($mesg) print($mesg); + + + /* + * Barre d'actions + * + */ + print '
'; + if ($user->rights->categorie->creer) + { + print ''.$langs->trans("NewCat").''; + } + print '
'; + + + // Formulaire ajout dans une categorie + if ($user->rights->societe->creer) + { + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("ClassifyInCategory").' '; + print $html->select_all_categories(2,$categorie->id_mere).'
'; + print ''; + print '
'; + } + + + $c = new Categorie($db); + + if ($_GET["socid"]) + { + $cats = $c->containing($_REQUEST["socid"],"societe"); + } + + + if (sizeof($cats) > 0) + { + print_fiche_titre($langs->trans("CompanyIsInCategories")); + print ''; + print ''; + + $var = true; + foreach ($cats as $cat) + { + $ways = $cat->print_all_ways (); + foreach ($ways as $way) + { + $var = ! $var; + print ""; + + // Categorie + print ""; + + // Lien supprimer + print '"; + + print "\n"; + } + + } + print "
'.$langs->trans("Categories").'
".$way."'; + if ($user->rights->societe->creer) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + else + { + print ' '; + } + print "

\n"; + } + else if($cats < 0) + { + print $langs->trans("ErrorUnknown"); + } + + else + { + print $langs->trans("CompanyHasNoCategory")."
"; + } + +} +$db->close(); + + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/fourn/categorie.php b/htdocs/fourn/categorie.php new file mode 100644 index 00000000000..83eb2bfffba --- /dev/null +++ b/htdocs/fourn/categorie.php @@ -0,0 +1,242 @@ + + * Copyright (C) 2005 Brice Davoleau + * Copyright (C) 2005-2006 Regis Houssin + * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin + * + * 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/categorie.php + \ingroup product + \brief Page de l'onglet categories de produits + \version $Revision$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.class.php"); +require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); + +$langs->load("categories"); +$langs->load("companies"); + +if (!$user->rights->societe->lire) accessforbidden(); + +$mesg = ''; + + +/* +* Actions +*/ + +//on veut supprimer une catégorie +if ($_REQUEST["removecat"] && $user->rights->societe->creer) +{ + $soc = new Fournisseur($db); + if ($_REQUEST["socid"]) $result = $soc->fetch($_REQUEST["socid"]); + + $cat = new Categorie($db,$_REQUEST["removecat"]); + $result=$cat->del_type($soc,"societe"); +} + +//on veut ajouter une catégorie +if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0 && $user->rights->societe->creer) +{ + $soc = new Fournisseur($db); + if ($_REQUEST["socid"]) $result = $soc->fetch($_REQUEST["socid"]); + + $cat = new Categorie($db,$_REQUEST["catMere"]); + $result=$cat->add_type($soc,"societe"); + if ($result >= 0) + { + $mesg='
'.$langs->trans("Added").'
'; + } + else + { + $mesg='
'.$langs->trans("Error").' '.$cat->error.'
'; + } + +} + + + +/* +* Creation de l'objet fournisseur correspondant à l'id +*/ +if ($_GET["socid"] || $_GET["ref"]) +{ + $soc = new Fournisseur($db); + if ($_GET["socid"]) $result = $soc->fetch($_GET["socid"]); + + llxHeader("","",$langs->trans("CardSupplier".$soc->type)); +} + + +$html = new Form($db); + + +/* + * Fiche produit + */ +if ($_GET["socid"] || $_GET["ref"]) +{ + + + + + /* + * Affichage onglets + */ + $head = societe_prepare_head($soc); + + dolibarr_fiche_head($head, 'category', $soc->nom); + + + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'; + + print ''; + print ''; + + print ''; + + if ($soc->fournisseur) + { + print ''; + } + + print ''; + + print ''; + print ''; + print ''; + print ''; + print '"; + + // Assujeti à TVA ou pas + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Name").''.$soc->nom.'
'.$langs->trans('Prefix').''.$soc->prefix_comm.'
'; + print $langs->trans('SupplierCode').''; + print $soc->code_fournisseur; + if ($soc->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); + print '
'.$langs->trans("Address").''.nl2br($soc->adresse).'
'.$langs->trans("Zip").''.$soc->cp.''.$langs->trans("Town").''.$soc->ville.'
'.$langs->trans("Country").''.$soc->pays.'
'.$langs->trans("Phone").''.dolibarr_print_phone($soc->tel).' '.$langs->trans("Fax").''.dolibarr_print_phone($soc->fax).' 
'.$langs->trans("Web")."url\">$soc->url 
'.$langs->trans('VATIsUsed').''; + print yn($soc->tva_assuj); + print '
'; + + print ''; + + + if ($mesg) print($mesg); + + + /* + * Barre d'actions + * + */ + print '
'; + if ($user->rights->categorie->creer) + { + print ''.$langs->trans("NewCat").''; + } + print '
'; + + + // Formulaire ajout dans une categorie + if ($user->rights->societe->creer) + { + print '
'; + print '
'; + print ''; + print ''; + print ''; + print '
'; + print $langs->trans("ClassifyInCategory").' '; + print $html->select_all_categories(1,$categorie->id_mere).'
'; + print '
'; + print '
'; + } + + + $c = new Categorie($db); + + if ($_GET["socid"]) + { + $cats = $c->containing($_REQUEST["socid"],"societe"); + } + + + if (sizeof($cats) > 0) + { + print_fiche_titre($langs->trans("SupplierIsInCategories")); + print ''; + print ''; + + $var = true; + foreach ($cats as $cat) + { + $ways = $cat->print_all_ways (); + foreach ($ways as $way) + { + $var = ! $var; + print ""; + + // Categorie + print ""; + + // Lien supprimer + print '"; + + print "\n"; + } + + } + print "
'.$langs->trans("Categories").'
".$way."'; + if ($user->rights->societe->creer) + { + print ""; + print img_delete($langs->trans("DeleteFromCat")).' '; + print $langs->trans("DeleteFromCat").""; + } + else + { + print ' '; + } + print "

\n"; + } + else if($cats < 0) + { + print $langs->trans("ErrorUnknown"); + } + + else + { + print $langs->trans("SupplierHasNoCategory")."
"; + } + +} +$db->close(); + + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 48aeef5ed18..62828477e3f 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2006 Marc Barilley/Océbo * Copyright (C) 2007 Franky Van Liedekerke + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -1350,7 +1351,7 @@ class Form * du nombre choisi * \param selected nombre de catégorie à créer */ - function select_all_categories($selected='',$select_name="") + function select_all_categories($type,$selected='',$select_name="") { global $langs; $langs->load("categorie"); @@ -1358,7 +1359,7 @@ class Form if ($select_name=="") $select_name="catMere"; $cat = new Categorie ($this -> db); - $cate_arbo = $cat->get_full_arbo(); + $cate_arbo = $cat->get_full_arbo($type); $output = ''; - + print_titre($langs->trans("Documents")); print ''; diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index 33dc558e1ee..232e8430d7d 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2006 Rodolphe Quiedeville + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -62,6 +63,26 @@ function societe_prepare_head($objsoc) $head[$h][2] = 'supplier'; $h++; } + + //affichage onglet catégorie + if ($conf->categorie->enabled) + { + if ($objsoc->fournisseur) + { + + $head[$h][0] = DOL_URL_ROOT.'/fourn/categorie.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans('Categories'); + $head[$h][2] = 'category'; + $h++; + } + else + { + $head[$h][0] = DOL_URL_ROOT.'/comm/categorie.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans('Categories'); + $head[$h][2] = 'category'; + $h++; + } + } if ($conf->facture->enabled || $conf->compta->enabled || $conf->comptaexpert->enabled) { diff --git a/htdocs/lib/functions.inc.php b/htdocs/lib/functions.inc.php index fe24f2e507b..704c14138f6 100644 --- a/htdocs/lib/functions.inc.php +++ b/htdocs/lib/functions.inc.php @@ -1250,7 +1250,12 @@ function dol_loginfunction($notused,$pearstatus) } print '
'; } - + if (defined("MAIN_HOME") && strlen(trim(MAIN_HOME))) + { + print '
'; + print nl2br(MAIN_HOME); + print '

'; + } print "\n\n"; } diff --git a/htdocs/product/categorie.php b/htdocs/product/categorie.php index 6d228abcc91..91aaa7d2c3a 100644 --- a/htdocs/product/categorie.php +++ b/htdocs/product/categorie.php @@ -3,6 +3,7 @@ * Copyright (C) 2005 Brice Davoleau * Copyright (C) 2005-2006 Regis Houssin * Copyright (C) 2006 Laurent Destailleur + * Copyright (C) 2007 Patrick Raguin * * 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 @@ -53,7 +54,7 @@ if ($_REQUEST["removecat"] && $user->rights->produit->creer) if ($_REQUEST["id"]) $result = $product->fetch($_REQUEST["id"]); $cat = new Categorie($db,$_REQUEST["removecat"]); - $result=$cat->del_product($product); + $result=$cat->del_type($product,"product"); } //on veut ajouter une catégorie @@ -64,7 +65,7 @@ if (isset($_REQUEST["catMere"]) && $_REQUEST["catMere"]>=0 && $user->rights->pr if ($_REQUEST["id"]) $result = $product->fetch($_REQUEST["id"]); $cat = new Categorie($db,$_REQUEST["catMere"]); - $result=$cat->add_product($product); + $result=$cat->add_type($product,"product"); if ($result >= 0) { $mesg='
'.$langs->trans("Added").'
'; @@ -144,7 +145,7 @@ if ($_GET["id"] || $_GET["ref"]) print '
'; if ($user->rights->categorie->creer) { - print ''.$langs->trans("NewCat").''; + print ''.$langs->trans("NewCat").''; } print '
'; @@ -152,12 +153,12 @@ if ($_GET["id"] || $_GET["ref"]) // Formulaire ajout dans une categorie if ($user->rights->produit->creer) { - print '
'; + print '
'; print ''; print ''; + print $html->select_all_categories(0,$categorie->id_mere).' '; print ''; print '
'; print $langs->trans("ClassifyInCategory").' '; - print $html->select_all_categories($categorie->id_mere).'
'; print '
'; @@ -169,12 +170,12 @@ if ($_GET["id"] || $_GET["ref"]) if ($_GET["id"]) { - $cats = $c->containing($_REQUEST["id"]); + $cats = $c->containing($_REQUEST["id"],"product"); } if ($_GET["ref"]) { - $cats = $c->containing_ref($_REQUEST["ref"]); + $cats = $c->containing_ref($_REQUEST["ref"],"product"); } if (sizeof($cats) > 0) diff --git a/htdocs/societe/notify/fiche.php b/htdocs/societe/notify/fiche.php index 31ef77e4cd3..300e172e00a 100644 --- a/htdocs/societe/notify/fiche.php +++ b/htdocs/societe/notify/fiche.php @@ -153,57 +153,61 @@ if ( $soc->fetch($soc->id) ) print "\n"; - - print_fiche_titre($langs->trans("AddNewNotification")); + if(count($soc->contact_email_array()) > 0) + { + print_fiche_titre($langs->trans("AddNewNotification")); + + print '
'; - print ''; + // Ligne de titres + print ''; + print ''; + print_liste_field_titre($langs->trans("Contact"),"fiche.php","c.name",'',"&socid=$socid",'"width="45%"',$sortfield); + print_liste_field_titre($langs->trans("Action"),"fiche.php","a.titre",'',"&socid=$socid",'"width="45%"',$sortfield); + print ''; + print ''; + + // Charge tableau $actions + $sql = "SELECT a.rowid, a.code, a.titre"; + $sql.= " FROM ".MAIN_DB_PREFIX."action_def as a"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $obj = $db->fetch_object($resql); + $libelle=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->titre); + $actions[$obj->rowid] = $libelle; + + $i++; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + + $var=false; + echo count($soc->contact_email_array()); - // Ligne de titres - print '
 
'; - print ''; - print_liste_field_titre($langs->trans("Contact"),"fiche.php","c.name",'',"&socid=$socid",'"width="45%"',$sortfield); - print_liste_field_titre($langs->trans("Action"),"fiche.php","a.titre",'',"&socid=$socid",'"width="45%"',$sortfield); - print ''; - print ''; - - // Charge tableau $actions - $sql = "SELECT a.rowid, a.code, a.titre"; - $sql.= " FROM ".MAIN_DB_PREFIX."action_def as a"; - - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $obj = $db->fetch_object($resql); - $libelle=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->titre); - $actions[$obj->rowid] = $libelle; - - $i++; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - - $var=false; - print ''; - print ''; - print ''; - print ''; - print ''; - print '
 
'; - $html->select_array("contactid",$soc->contact_email_array()); - print ''; - $html->select_array("actionid",$actions); - print '
'; - - print '
'; - print '
'; + print ''; + print '
'; + $html->select_array("contactid",$soc->contact_email_array()); + print ''; + $html->select_array("actionid",$actions); + print '
'; + + print ''; + print '
'; + } print_fiche_titre($langs->trans("ListOfActiveNotifications")); diff --git a/mysql/tables/llx_categorie.sql b/mysql/tables/llx_categorie.sql index 267c0d7b5de..c8867305031 100644 --- a/mysql/tables/llx_categorie.sql +++ b/mysql/tables/llx_categorie.sql @@ -27,5 +27,6 @@ create table llx_categorie rowid integer AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255), -- nom de la catégorie description text, -- description de la catégorie - visible tinyint DEFAULT 1 NOT NULL -- determine si les produits sont visible ou pas + visible tinyint DEFAULT 1 NOT NULL, -- determine si les produits sont visible ou pas + type tinyint DEFAULT 1 NOT NULL -- Type de catégorie (product, supplier, societe) )type=innodb; diff --git a/mysql/tables/llx_categorie_societe.key.sql b/mysql/tables/llx_categorie_societe.key.sql new file mode 100644 index 00000000000..824e4ac2dd3 --- /dev/null +++ b/mysql/tables/llx_categorie_societe.key.sql @@ -0,0 +1,25 @@ +-- ============================================================================ +-- Copyright (C) 2007 Patrick Raguin +-- +-- 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. +-- +-- ============================================================================ + +ALTER TABLE llx_categorie_societe ADD PRIMARY KEY (fk_categorie, fk_societe); +ALTER TABLE llx_categorie_societe ADD INDEX idx_categorie_societe_fk_categorie (fk_categorie); +ALTER TABLE llx_categorie_societe ADD INDEX idx_categorie_societe_fk_societe (fk_societe); + +ALTER TABLE llx_categorie_societe ADD CONSTRAINT fk_categorie_societe_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid); +ALTER TABLE llx_categorie_societe ADD CONSTRAINT fk_categorie_societe_societe_rowid FOREIGN KEY (fk_societe) REFERENCES llx_societe (rowid); diff --git a/mysql/tables/llx_categorie_societe.sql b/mysql/tables/llx_categorie_societe.sql new file mode 100644 index 00000000000..8848ddd9b98 --- /dev/null +++ b/mysql/tables/llx_categorie_societe.sql @@ -0,0 +1,24 @@ +-- ============================================================================ +-- Copyright (C) 2007 Patrick Raguin +-- +-- 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. +-- +-- ============================================================================ + +create table llx_categorie_societe +( + fk_categorie integer NOT NULL, + fk_societe integer NOT NULL +)type=innodb; diff --git a/mysql/tables/llx_droitpret_rapport.sql b/mysql/tables/llx_droitpret_rapport.sql new file mode 100644 index 00000000000..a937ae6107f --- /dev/null +++ b/mysql/tables/llx_droitpret_rapport.sql @@ -0,0 +1,33 @@ +-- ======================================================================== +-- Copyright (C) 2007 Patrick Raguin +-- +-- 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$ +-- +-- ======================================================================== + + +CREATE TABLE `llx_droitpret_rapport` ( + `rowid` int(11) NOT NULL auto_increment, + `date_envoie` datetime NOT NULL, + `format` varchar(10) NOT NULL, + `date_debut` datetime NOT NULL, + `date_fin` datetime NOT NULL, + `fichier` varchar(255) NOT NULL, + `nbfact` int(11) NOT NULL, + PRIMARY KEY (`rowid`) +) type=innodb;