From da09e5c9ebd7808434268ba1b8740339381ae7c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 16 Nov 2010 23:49:25 +0000 Subject: [PATCH] New: Add a dedicated third party page --- htdocs/includes/menus/init_menu_auguria.sql | 2 +- htdocs/includes/menus/init_menu_iphone.sql | 2 +- htdocs/includes/menus/standard/eldy.lib.php | 4 +- htdocs/index.php | 2 +- htdocs/langs/en_US/companies.lang | 3 + htdocs/langs/fr_FR/companies.lang | 4 +- htdocs/societe/index.php | 214 ++++++++++++++++++++ htdocs/societe/societe.php | 22 +- 8 files changed, 244 insertions(+), 9 deletions(-) diff --git a/htdocs/includes/menus/init_menu_auguria.sql b/htdocs/includes/menus/init_menu_auguria.sql index 6f74e126a26..99015589c33 100644 --- a/htdocs/includes/menus/init_menu_auguria.sql +++ b/htdocs/includes/menus/init_menu_auguria.sql @@ -13,7 +13,7 @@ delete from llx_menu where menu_handler=__HANDLER__; -- table llx_menu -- insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('1', 1__+MAX_llx_menu__, __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 1, __ENTITY__); -insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled || $conf->fournisseur->enabled', 2__+MAX_llx_menu__, __HANDLER__, 'top', 'companies', '', 0, '/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); +insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled || $conf->fournisseur->enabled', 2__+MAX_llx_menu__, __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->product->enabled || $conf->service->enabled', 3__+MAX_llx_menu__, __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'Products/Services', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 3, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire', '', 2, 6, __ENTITY__); diff --git a/htdocs/includes/menus/init_menu_iphone.sql b/htdocs/includes/menus/init_menu_iphone.sql index ce9c655573b..05f3b72814c 100644 --- a/htdocs/includes/menus/init_menu_iphone.sql +++ b/htdocs/includes/menus/init_menu_iphone.sql @@ -13,7 +13,7 @@ delete from llx_menu where menu_handler=__HANDLER__; -- table llx_menu -- insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('1', 1__+MAX_llx_menu__, __HANDLER__, 'top', 'home', '', 0, '/index.php?mainmenu=home&leftmenu=', 'Home', -1, '', '', '', 2, 1, __ENTITY__); -insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled || $conf->fournisseur->enabled', 2__+MAX_llx_menu__, __HANDLER__, 'top', 'companies', '', 0, '/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); +insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled || $conf->fournisseur->enabled', 2__+MAX_llx_menu__, __HANDLER__, 'top', 'companies', '', 0, '/societe/index.php?mainmenu=companies&leftmenu=', 'ThirdParties', -1, 'companies', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 2, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->product->enabled || $conf->service->enabled', 3__+MAX_llx_menu__, __HANDLER__, 'top', 'products', '', 0, '/product/index.php?mainmenu=products&leftmenu=', 'Products/Services', -1, 'products', '$user->rights->produit->lire||$user->rights->service->lire', '', 0, 3, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->societe->enabled', 5__+MAX_llx_menu__, __HANDLER__, 'top', 'commercial', '', 0, '/comm/index.php?mainmenu=commercial&leftmenu=', 'Commercial', -1, 'commercial', '$user->rights->societe->lire || $user->rights->societe->contact->lire', '', 2, 5, __ENTITY__); insert into llx_menu (enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->compta->enabled || $conf->accounting->enabled || $conf->facture->enabled || $conf->deplacement->enabled', 6__+MAX_llx_menu__, __HANDLER__, 'top', 'accountancy', '', 0, '/compta/index.php?mainmenu=accountancy&leftmenu=', 'MenuFinancial', -1, 'compta', '$user->rights->compta->resultat->lire || $user->rights->accounting->plancompte->lire || $user->rights->commande->lire || $user->rights->facture->lire', '', 2, 6, __ENTITY__); diff --git a/htdocs/includes/menus/standard/eldy.lib.php b/htdocs/includes/menus/standard/eldy.lib.php index afe0b7d944d..e850973b5d2 100644 --- a/htdocs/includes/menus/standard/eldy.lib.php +++ b/htdocs/includes/menus/standard/eldy.lib.php @@ -87,10 +87,10 @@ function print_eldy_menu($db,$atarget,$type_user) || ($conf->fournisseur->enabled && $user->rights->fournisseur->lire)) { print_start_menu_entry($idsel); - print ''; + print ''; print '
'; print '
'; - print ''; + print ''; print_text_menu_entry($langs->trans("ThirdParties")); print ''; print_end_menu_entry(); diff --git a/htdocs/index.php b/htdocs/index.php index 8c58d83b7ab..6b07cb13ab6 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -493,7 +493,7 @@ foreach($dashboardlines as $key => $board) { print ''; $text=''; - if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate"); + if ($totallate > 0) $text=$langs->transnoentitiesnoconv("WarningYouHaveAtLeastOneTaskLate").' ('.$langs->transnoentitiesnoconv("NActionsLate",$totallate).')'; $options='height="64px"'; if ($rowspan <= 2) $options='height="24"'; // Weather logo is smaller if dashboard has few elements else if ($rowspan <= 3) $options='height="48"'; // Weather logo is smaller if dashboard has few elements diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 35419bea090..fe8eab1bd43 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -294,6 +294,9 @@ YouMustCreateContactFirst=You must create emails contacts for third party first ListSuppliersShort=List of suppliers ListProspectsShort=List of prospects ListCustomersShort=List of customers +ThirdPartiesArea=Third parties area +LastModifiedThirdParties=Last %s modified third parties +UniqueThirdParties=Total of unique third parties # Monkey MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 28412992564..eec23ef2c37 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -301,7 +301,9 @@ YouMustCreateContactFirst=Vous devez créer des contacts avec emails sur le tier ListSuppliersShort=Liste fournisseurs ListProspectsShort=Liste prospects ListCustomersShort=Liste clients - +ThirdPartiesArea=Espace Tiers +LastModifiedThirdParties=Les %s derniers tiers modifiés +UniqueThirdParties=Total de tiers uniques # Monkey MonkeyNumRefModelDesc=Renvoie le numéro sous la forme %syymm-nnnn pour les codes clients et %syymm-nnnn pour les codes fournisseurs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0. diff --git a/htdocs/societe/index.php b/htdocs/societe/index.php index e69de29bb2d..7458c80cad6 100644 --- a/htdocs/societe/index.php +++ b/htdocs/societe/index.php @@ -0,0 +1,214 @@ + + * Copyright (C) 2004-2010 Laurent Destailleur + * Copyright (C) 2005-2009 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. + */ + +/** + * \file htdocs/societe/index.php + * \ingroup societe + * \brief Home page for third parties area + * \version $Id$ + */ + +require("../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'); + +// Security check +$result=restrictedArea($user,'societe',0,'','','',''); + +$thirdparty_static = new Societe($db); + +$langs->load("companies"); + + +/* + * View + */ + +$transAreaType = $langs->trans("ThirdPartiesArea"); +$helpurl='EN:Module_ThirdParty|FR:Module_Tiers|ES:Módulo_Tierceros'; + +llxHeader("",$langs->trans("ThirdParties"),$helpurl); + +print_fiche_titre($transAreaType); + +print ''; + +print '
'; + +/* + * Zone recherche tiers + */ +$rowspan=2; +print '
'; +print ''; +print ''; +print ""; +print ''; +print "'; +print ''; +print "'; +//print ''; +print ''; + +print "
'.$langs->trans("Search").'
"; +print $langs->trans("Name").':
"; +print $langs->trans("Other").':

"; + + +/* + * Nombre de tiers + */ +$third = array(); +$total=0; + +$sql = "SELECT s.rowid, s.client, s.fournisseur"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " WHERE s.entity = ".$conf->entity; +$result = $db->query($sql); +if ($result) +{ + while ($objp = $db->fetch_object($result)) + { + if ($objp->client == 1 || $objp->client == 3) $third['customer']++; + if ($objp->client == 2 || $objp->client == 3) $third['prospect']++; + if ($objp->fournisseur) $third['supplier']++; + + $total++; + } +} +else dol_print_error($db); + +print ''; +print ''; +if ($conf->societe->enabled) +{ + $statProducts = ""; + $statProducts.= ''; + $statProducts.= ""; + $statProducts.= ""; + $statProducts.= ''; + $statProducts.= ""; +} +if ($conf->fournisseur->enabled) +{ + $statServices = ""; + $statServices.= ''; + $statServices.= ""; +} +print $statProducts; +print $statServices; +print ''; +print '
'.$langs->trans("Statistics").'
'.$langs->trans("Prospects").''.round($third['prospect']).'
'.$langs->trans("Customers").''.round($third['customer']).'
'.$langs->trans("Suppliers").''.round($third['supplier']).'
'.$langs->trans("UniqueThirdParties").''; +print $total; +print '
'; + +print '
'; + +/* + * Last third parties modified + */ +$max=15; +$sql = "SELECT s.rowid, s.nom, s.client, s.fournisseur,"; +$sql.= " s.tms as datem"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= " WHERE s.entity = ".$conf->entity; +$sql.= " AND ("; +if (! empty($conf->societe->enabled)) $sql.=" s.client in (1,2,3)"; +if (! empty($conf->fournisseur->enabled)) $sql.=" OR s.fournisseur in (1)"; +$sql.= ")"; +$sql.= $db->order("s.tms","DESC"); +$sql.= $db->plimit($max,0); + +//print $sql; +$result = $db->query($sql) ; +if ($result) +{ + $num = $db->num_rows($result); + + $i = 0; + + if ($num > 0) + { + $transRecordedType = $langs->trans("LastModifiedThirdParties",$max); + + print ''; + + print ''; + + $var=True; + + while ($i < $num) + { + $objp = $db->fetch_object($result); + + $var=!$var; + print ""; + // Name + print '\n"; + // Type + print ''; + // Last modified date + print '"; +// print '"; + print "\n"; + $i++; + } + + $db->free(); + + print "
'.$transRecordedType.'
'; + $thirdparty_static->id=$objp->rowid; + $thirdparty_static->nom=$objp->nom; + $thirdparty_static->client=$objp->client; + $thirdparty_static->fournisseur=$objp->fournisseur; + $thirdparty_static->datem=$db->jdate($objp->datem); + print $thirdparty_static->getNomUrl(1,'',16); + print "'; + if ($thirdparty_static->client==1 || $thirdparty_static->client==3) + { + print "id."\">".$langs->trans("Customer")."\n"; + } + if ($thirdparty_static->client == 3) print " / "; + if ($thirdparty_static->client==2 || $thirdparty_static->client==3) + { + print "id."\">".$langs->trans("Prospect")."\n"; + } + if ($thirdparty_static->fournisseur) + { + if ($thirdparty_static->client) print " / "; + print ''.$langs->trans("Supplier").''; + } + print ''; + print dol_print_date($thirdparty_static->datem,'day'); + print "'; +// print $product_static->LibStatut($objp->tobuy,5,1); +// print "
"; + } +} +else +{ + dol_print_error($db); +} + +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/societe/societe.php b/htdocs/societe/societe.php index 23aa84675f2..1eac9d3312e 100644 --- a/htdocs/societe/societe.php +++ b/htdocs/societe/societe.php @@ -37,6 +37,8 @@ if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); $search_nom=trim(isset($_GET["search_nom"])?$_GET["search_nom"]:$_POST["search_nom"]); +$search_nom_only=trim(isset($_GET["search_nom_only"])?$_GET["search_nom_only"]:$_POST["search_nom_only"]); +$search_all=trim(isset($_GET["search_all"])?$_GET["search_all"]:$_POST["search_all"]); $search_ville=trim(isset($_GET["search_ville"])?$_GET["search_ville"]:$_POST["search_ville"]); $socname=trim(isset($_GET["socname"])?$_GET["socname"]:$_POST["socname"]); $search_idprof1=trim($_REQUEST['search_idprof1']); @@ -171,7 +173,19 @@ if (! $user->rights->societe->lire || ! $user->rights->fournisseur->lire) { if (! $user->rights->fournisseur->lire) $sql.=" AND s.fournisseur != 1"; } - +if ($search_nom_only) +{ + $sql.= " AND s.nom LIKE '%".addslashes($search_nom_only)."%'"; +} +if ($search_all) +{ + $sql.= " AND ("; + $sql.= "s.nom LIKE '%".addslashes($search_all)."%'"; + $sql.= " OR s.code_client LIKE '%".addslashes($search_all)."%'"; + $sql.= " OR s.email like '%".addslashes($search_all)."%'"; + $sql.= " OR s.url like '%".addslashes($search_all)."%'"; + $sql.= ")"; +} if ($search_nom) { $sql.= " AND ("; @@ -202,6 +216,7 @@ if ($search_idprof4) { $sql .= " AND s.idprof4 LIKE '%".addslashes($search_idprof4)."%'"; } +//print $sql; // Count total nb of records $nbtotalofrecords = 0; @@ -260,6 +275,7 @@ if ($resql) print ''; print ''; print ''; + if (! empty($search_nom_only) && empty($search_nom)) $search_nom=$search_nom_only; print ''; print ''; print ''; @@ -319,8 +335,8 @@ if ($resql) if ($obj->client) print " / "; print ''.$langs->trans("Supplier").''; } - - print ''."\n"; + print ''; + print ''."\n"; $i++; }