From ef6f5f54f4cde3345ce916d1480edbd1f88e5120 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 6 Jun 2011 16:15:02 +0000 Subject: [PATCH] New: Commercial proposal has its home area. --- htdocs/comm/propal/index.php | 421 ++++++++++++++++++ htdocs/commande/index.php | 4 +- htdocs/includes/menus/init_menu_auguria.sql | 2 +- htdocs/includes/menus/standard/eldy.lib.php | 6 +- .../install/mysql/migration/3.0.0-3.1.0.sql | 2 + htdocs/install/mysql/tables/llx_propal.sql | 2 + htdocs/langs/en_US/commercial.lang | 4 +- htdocs/langs/fr_FR/commercial.lang | 4 +- 8 files changed, 437 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/index.php b/htdocs/comm/propal/index.php index e69de29bb2d..cf5aa0b8b6b 100644 --- a/htdocs/comm/propal/index.php +++ b/htdocs/comm/propal/index.php @@ -0,0 +1,421 @@ + + * Copyright (C) 2004-2011 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/comm/propal/index.php + * \ingroup propal + * \brief Home page of proposal area + * \version $Id$ + */ + +require("../../main.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT ."/comm/propal/class/propal.class.php"); + +if (!$user->rights->propale->lire) accessforbidden(); + +$langs->load("propal"); + +// Security check +$socid=''; +if ($_GET["socid"]) { $socid=$_GET["socid"]; } +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + + + +/* + * View + */ + +$propal_static=new Propal($db); +$html = new Form($db); +$formfile = new FormFile($db); +$help_url="EN:Module_Commercial_Proposals|FR:Module_Propositions_commerciales|ES:Módulo Presupuestos"; + +llxHeader("",$langs->trans("ProspectionArea"),$help_url); + +print_fiche_titre($langs->trans("ProspectionArea")); + +print ''; + +print '
'; + +/* + * Search form + */ +$var=false; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "
'.$langs->trans("SearchPropal").'
'; +print $langs->trans("Ref").':
'.$langs->trans("Other").':

\n"; + + +/* + * Statistics + */ + +$sql = "SELECT count(cf.rowid), cf.fk_statut"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; +$sql.= ", ".MAIN_DB_PREFIX."propal as cf"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE cf.fk_soc = s.rowid"; +$sql.= " AND s.entity = ".$conf->entity; +if ($user->societe_id) $sql.=' AND cf.fk_soc = '.$user->societe_id; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " AND cf.fk_statut in (0,1,2,3,4)"; +$sql.= " GROUP BY cf.fk_statut"; +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + $i = 0; + + $total=0; + $totalinprocess=0; + $dataseries=array(); + $vals=array(); + // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) + while ($i < $num) + { + $row = $db->fetch_row($resql); + if ($row) + { + //if ($row[1]!=-1 && ($row[1]!=3 || $row[2]!=1)) + { + $vals[$row[1]]=$row[0]; + $totalinprocess+=$row[0]; + } + $total+=$row[0]; + } + $i++; + } + $db->free($resql); + + print ''; + print ''."\n"; + $var=true; + $listofstatus=array(0,1,2,3,4); + foreach ($listofstatus as $status) + { + $dataseries[]=array('label'=>$propal_static->LibStatut($status,0),'values'=>array(0=>(isset($vals[$status])?$vals[$status]:0))); + if (! $conf->use_javascript_ajax) + { + $var=!$var; + print ""; + print ''; + print ''; + print "\n"; + } + } + if ($conf->use_javascript_ajax) + { + print ''; + } + //if ($totalinprocess != $total) + //print ''; + print ''; + print "
'.$langs->trans("Statistics").' - '.$langs->trans("Proposals").'
'.$propal_static->LibStatut($status,0).''.(isset($vals[$status])?$vals[$status]:0).'
'; + $data=array('series'=>$dataseries); + dol_print_graph('stats',300,180,$data,1,'pie'); + print '
'.$langs->trans("Total").' ('.$langs->trans("CustomersOrdersRunning").')'.$totalinprocess.'
'.$langs->trans("Total").''.$total.'

"; +} +else +{ + dol_print_error($db); +} + + +/* + * Draft proposals + */ +if ($conf->propal->enabled) +{ + $sql = "SELECT c.rowid, c.ref, s.nom, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 0"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + + $resql=$db->query($sql); + if ($resql) + { + print ''; + print ''; + print ''; + $langs->load("propal"); + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print '"; + print ''; + $i++; + } + } + print "
'.$langs->trans("DraftPropals").'
'; + print "rowid."\">".img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref."'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).'

"; + } +} + +print '
'; + + +$max=5; + +/* + * Last modified proposals + */ + +$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom, s.rowid as socid,"; +$sql.= " date_cloture as datec"; +$sql.= " FROM ".MAIN_DB_PREFIX."propal as c"; +$sql.= ", ".MAIN_DB_PREFIX."societe as s"; +if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; +$sql.= " WHERE c.fk_soc = s.rowid"; +$sql.= " AND c.entity = ".$conf->entity; +//$sql.= " AND c.fk_statut > 2"; +if ($socid) $sql .= " AND c.fk_soc = ".$socid; +if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; +$sql.= " ORDER BY c.tms DESC"; +$sql.= $db->plimit($max, 0); + +$resql=$db->query($sql); +if ($resql) +{ + print ''; + print ''; + print ''; + + $num = $db->num_rows($resql); + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + + print ""; + print ''; + + print ''; + print ''; + print ''; + print ''; + $i++; + } + } + print "
'.$langs->trans("LastModifiedProposals",$max).'
'; + + $propal_static->id=$obj->rowid; + $propal_static->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $propal_static->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->propal->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.dol_print_date($db->jdate($obj->datec),'day').''.$propal_static->LibStatut($obj->fk_statut,5).'

"; +} +else dol_print_error($db); + + +/* + * Proposals to process + */ +/* +if ($conf->propal->enabled) +{ + $sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom, s.rowid as socid"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 1"; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + + print "
'.$langs->trans("ProposalsToProcess").' ('.$num.')
'; + + $propal_static->id=$obj->rowid; + $propal_static->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $propal_static->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->nom,24).''.$propal_static->LibStatut($obj->fk_statut,$obj->facture,5).'

"; + } + else dol_print_error($db); +} +*/ + +/* + * Proposal that are in a shipping process + */ +/*if ($conf->propal->enabled) +{ + $sql = "SELECT c.rowid, c.ref, c.fk_statut, c.facture, s.nom, s.rowid as socid"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande as c"; + $sql.= ", ".MAIN_DB_PREFIX."societe as s"; + if (!$user->rights->societe->client->voir && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.fk_soc = s.rowid"; + $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.fk_statut = 2 "; + if ($socid) $sql.= " AND c.fk_soc = ".$socid; + if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; + $sql.= " ORDER BY c.rowid DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + + print ''; + print ''; + print ''; + + if ($num) + { + $i = 0; + $var = True; + while ($i < $num) + { + $var=!$var; + $obj = $db->fetch_object($resql); + print ""; + print ''; + + print ''; + + print ''; + + print ''; + $i++; + } + } + print "
'.$langs->trans("OnProcessOrders").' ('.$num.')
'; + + $propal_static->id=$obj->rowid; + $propal_static->ref=$obj->ref; + + print ''; + print ''; + + print ''; + + print '
'; + print $propal_static->getNomUrl(1); + print ''; + print ' '; + print ''; + $filename=dol_sanitizeFileName($obj->ref); + $filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref); + $urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid; + $formfile->show_documents('commande',$filename,$filedir,$urlsource,'','','',1,'',1); + print '
'; + + print '
'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''.$propal_static->LibStatut($obj->fk_statut,$obj->facture,5).'

"; + } + else dol_print_error($db); +} +*/ + +print '
'; + +$db->close(); + +llxFooter('$Date$ - $Revision$'); + +?> diff --git a/htdocs/commande/index.php b/htdocs/commande/index.php index 892ecd0313f..5336f6f2e35 100644 --- a/htdocs/commande/index.php +++ b/htdocs/commande/index.php @@ -258,7 +258,7 @@ if ($resql) print ''; print ''.img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom.''; - print ''.dol_print_date($db->jdate($obj->datec)).''; + print ''.dol_print_date($db->jdate($obj->datec),'day').''; print ''.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).''; print ''; $i++; @@ -303,7 +303,7 @@ if ($conf->commande->enabled) $var=!$var; $obj = $db->fetch_object($resql); print ""; - print ''; + print ''; $commandestatic->id=$obj->rowid; $commandestatic->ref=$obj->ref; diff --git a/htdocs/includes/menus/init_menu_auguria.sql b/htdocs/includes/menus/init_menu_auguria.sql index 1323f2adea6..c572ecf184c 100644 --- a/htdocs/includes/menus/init_menu_auguria.sql +++ b/htdocs/includes/menus/init_menu_auguria.sql @@ -111,7 +111,7 @@ insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->expedition->enabled && $leftmenu=="sendings"', __HANDLER__, 'left', 1302__+MAX_llx_menu__, 'commercial', '', 1300__+MAX_llx_menu__, '/expedition/stats/index.php?leftmenu=sendings', 'Statistics', 1, 'sendings', '$user->rights->expedition->lire', '', 2, 1, __ENTITY__); -- Commercial - Proposals -insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->propal->enabled', __HANDLER__, 'left', 1100__+MAX_llx_menu__, 'commercial', '', 5__+MAX_llx_menu__, '/comm/propal.php?leftmenu=propals', 'Prop', 0, 'propal', '$user->rights->propale->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->propal->enabled', __HANDLER__, 'left', 1100__+MAX_llx_menu__, 'commercial', '', 5__+MAX_llx_menu__, '/comm/propal/index.php?leftmenu=propals', 'Prop', 0, 'propal', '$user->rights->propale->lire', '', 2, 4, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->propal->enabled', __HANDLER__, 'left', 1101__+MAX_llx_menu__, 'commercial', '', 1100__+MAX_llx_menu__, '/societe/societe.php?leftmenu=propals', 'NewPropal', 1, 'propal', '$user->rights->propale->creer', '', 2, 0, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->propal->enabled', __HANDLER__, 'left', 1102__+MAX_llx_menu__, 'commercial', '', 1100__+MAX_llx_menu__, '/comm/propal.php?leftmenu=propals', 'List', 1, 'propal', '$user->rights->propale->lire', '', 2, 1, __ENTITY__); insert into llx_menu (enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('$conf->propal->enabled && $leftmenu=="propals"', __HANDLER__, 'left', 1103__+MAX_llx_menu__, 'commercial', '', 1102__+MAX_llx_menu__, '/comm/propal.php?leftmenu=propals&viewstatut=0', 'PropalsDraft', 1, 'propal', '$user->rights->propale->lire', '', 2, 2, __ENTITY__); diff --git a/htdocs/includes/menus/standard/eldy.lib.php b/htdocs/includes/menus/standard/eldy.lib.php index 3403655126b..cbd7681633e 100644 --- a/htdocs/includes/menus/standard/eldy.lib.php +++ b/htdocs/includes/menus/standard/eldy.lib.php @@ -1,6 +1,6 @@ - * Copyright (C) 2010 Regis Houssin +/* Copyright (C) 2010-2011 Laurent Destailleur + * Copyright (C) 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 @@ -783,7 +783,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after) if (! empty($conf->propal->enabled)) { $langs->load("propal"); - $newmenu->add("/comm/propal.php?leftmenu=propals", $langs->trans("Prop"), 0 ,$user->rights->propale->lire); + $newmenu->add("/comm/propal/index.php?leftmenu=propals", $langs->trans("Prop"), 0 ,$user->rights->propale->lire); $newmenu->add("/societe/societe.php?leftmenu=propals", $langs->trans("NewPropal"), 1, $user->rights->propale->creer); $newmenu->add("/comm/propal.php?leftmenu=propals", $langs->trans("List"), 1, $user->rights->propale->lire); if ($leftmenu=="propals") $newmenu->add("/comm/propal.php?leftmenu=propals&viewstatut=0", $langs->trans("PropalsDraft"), 2, $user->rights->propale->lire); diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index 26b5a1c9d44..56fa30c376d 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -373,3 +373,5 @@ update llx_actioncomm set elementtype='invoice' where elementtype='facture'; update llx_actioncomm set elementtype='order' where elementtype='commande'; update llx_actioncomm set elementtype='contract' where elementtype='contrat'; + +alter table llx_propal add column tms timestamp after fk_projet; diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql index cb866b0fe55..38aefa7d4e7 100644 --- a/htdocs/install/mysql/tables/llx_propal.sql +++ b/htdocs/install/mysql/tables/llx_propal.sql @@ -32,6 +32,8 @@ create table llx_propal fk_soc integer, fk_projet integer DEFAULT 0, -- projet auquel est rattache la propale + + tms timestamp, datec datetime, -- date de creation datep date, -- date de la propal fin_validite datetime, -- date de fin de validite diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index 7e12b70a16d..07667ed4a15 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -80,4 +80,6 @@ ActionAC_SHIP=Send shipping by mail ActionAC_SUP_ORD=Send supplier order by mail ActionAC_SUP_INV=Send supplier invoice by mail ActionAC_OTH=Other -StatusProsp=Prospect status \ No newline at end of file +StatusProsp=Prospect status +DraftPropals=Draft commercial proposals +SearchPropal=Search a commercial proposal \ No newline at end of file diff --git a/htdocs/langs/fr_FR/commercial.lang b/htdocs/langs/fr_FR/commercial.lang index 3ff85718105..9218c5651d5 100644 --- a/htdocs/langs/fr_FR/commercial.lang +++ b/htdocs/langs/fr_FR/commercial.lang @@ -86,4 +86,6 @@ FromTo=du %s au %s MargeOrder=Marge réalisée (Commandes validées) RecapAnnee=Récapitulatif de l'année NoData=Aucune donnée -StatusProsp=Status prospection \ No newline at end of file +StatusProsp=Status prospection +DraftPropals=Propositions brouillons +SearchPropal=Rechercher une proposition \ No newline at end of file