New: Ajout du "potentiel" des prospects

This commit is contained in:
Laurent Destailleur 2008-03-01 01:12:55 +00:00
parent 65fcfcf69f
commit 86b2a32c69
15 changed files with 201 additions and 46 deletions

View File

@ -65,9 +65,9 @@ $sql.= " c.code as acode, c.libelle,";
$sql.= " ut.login as logintodo, ut.rowid as useridtodo,";
$sql.= " ud.login as logindone, ud.rowid as useriddone,";
$sql.= " sp.name, sp.firstname";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s,";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
if (!$user->rights->societe->client->voir && !$socid) $sql .= " ".MAIN_DB_PREFIX."societe_commerciaux as sc,";
$sql.= " ".MAIN_DB_PREFIX."actioncomm as a";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as ut ON a.fk_user_action = ut.rowid";
@ -85,7 +85,7 @@ if ($socid)
{
$sql .= " AND s.rowid = ".$socid;
}
if (!$user->rights->commercial->client->voir && !$socid) //restriction
if (!$user->rights->societe->client->voir && !$socid) //restriction
{
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
}
@ -164,7 +164,7 @@ if ($resql)
print $obj->label;
print '</td>';
// Société
// Soci<EFBFBD>t<EFBFBD>
print '<td>';
$societestatic->id=$obj->socid;
$societestatic->client=$obj->client;

View File

@ -48,7 +48,7 @@ $result = restrictedArea($user, 'societe',$socid,'',1);
if ($_GET["action"] == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"];
$sql .= " WHERE rowid = ".$_GET["id"];
$sql .= " WHERE rowid = ".$_GET["socid"];
$db->query($sql);
}
@ -77,7 +77,7 @@ if ($socid > 0)
*/
$head = societe_prepare_head($societe);
dolibarr_fiche_head($head, 'prospect', $societe->nom);
dolibarr_fiche_head($head, 'prospect', $langs->trans("ThirdParty"));
print "<table width=\"100%\">\n";
print '<tr><td valign="top" width="50%">';
@ -99,14 +99,30 @@ if ($socid > 0)
print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$societe->forme_juridique.'</td></tr>';
// Status
// Level
// print '<tr><td>'.$langs->trans('ProspectLevel').'</td><td colspan="3">'.$societe->getLibLevel().'</td></tr>';
print '<tr><td>';
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('ProspectLevel');
print '<td><td align="right">';
if ($user->rights->societe->creer)
print '<a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id.'">'.img_edit().'</a>';
else
print '&nbsp;';
print '</td></tr></table>';
print '</td>';
print '<td colspan="3">';
print $societe->getLibLevel();
print '</td></tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$societe->getLibStatut(4).'</td>';
print '<td>';
if ($societe->stcomm_id != -1) print '<a href="fiche.php?id='.$societe->id.'&amp;stcomm=-1&amp;action=cstc">'.img_action(0,-1).'</a>';
if ($societe->stcomm_id != 0) print '<a href="fiche.php?id='.$societe->id.'&amp;stcomm=0&amp;action=cstc">'.img_action(0,0).'</a>';
if ($societe->stcomm_id != 1) print '<a href="fiche.php?id='.$societe->id.'&amp;stcomm=1&amp;action=cstc">'.img_action(0,1).'</a>';
if ($societe->stcomm_id != 2) print '<a href="fiche.php?id='.$societe->id.'&amp;stcomm=2&amp;action=cstc">'.img_action(0,2).'</a>';
if ($societe->stcomm_id != 3) print '<a href="fiche.php?id='.$societe->id.'&amp;stcomm=3&amp;action=cstc">'.img_action(0,3).'</a>';
if ($societe->stcomm_id != -1) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=-1&amp;action=cstc">'.img_action(0,-1).'</a>';
if ($societe->stcomm_id != 0) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=0&amp;action=cstc">'.img_action(0,0).'</a>';
if ($societe->stcomm_id != 1) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=1&amp;action=cstc">'.img_action(0,1).'</a>';
if ($societe->stcomm_id != 2) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=2&amp;action=cstc">'.img_action(0,2).'</a>';
if ($societe->stcomm_id != 3) print '<a href="fiche.php?socid='.$societe->id.'&amp;stcomm=3&amp;action=cstc">'.img_action(0,3).'</a>';
print '</td></tr>';
print '</table>';

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2008 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
@ -55,8 +55,8 @@ $pagenext = $page + 1;
if ($_GET["action"] == 'cstc')
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["pstcomm"];
$sql .= " WHERE rowid = ".$_GET["pid"];
$db->query($sql);
$sql .= " WHERE rowid = ".$_GET["socid"];
$result=$db->query($sql);
}
@ -64,14 +64,15 @@ if ($_GET["action"] == 'cstc')
* Affichage liste
*/
$sql = "SELECT s.rowid, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea, st.libelle as stcomm, s.prefix_comm, s.fk_stcomm ";
$sql .= ", d.nom as departement";
$sql = "SELECT s.rowid, s.nom, s.ville, ".$db->pdate("s.datec")." as datec, ".$db->pdate("s.datea")." as datea,";
$sql.= " st.libelle as stcomm, s.prefix_comm, s.fk_stcomm, s.fk_prospectlevel,";
$sql.= " d.nom as departement";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", sc.fk_soc, sc.fk_user";
$sql .= " FROM ".MAIN_DB_PREFIX."c_stcomm as st";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
$sql .= " WHERE s.fk_stcomm = st.id AND s.client = 2";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_departements as d on (d.rowid = s.fk_departement)";
$sql.= " WHERE s.fk_stcomm = st.id AND s.client = 2";
if (!$user->rights->commercial->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id;
if (isset($stcomm))
@ -132,6 +133,7 @@ if ($resql)
print_liste_field_titre($langs->trans("Town"),"prospects.php","s.ville","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("State"),"prospects.php","s.fk_departement","","","align=\"center\"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("DateCreation"),"prospects.php","s.datec","","","align=\"center\"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ProspectLevelShort"),"prospects.php","s.fk_prospectlevel","","","align=\"center\"",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Status"),"prospects.php","s.fk_stcomm","","","align=\"center\"",$sortfield,$sortorder);
print '<td class="liste_titre" colspan="4">&nbsp;</td>';
print "</tr>\n";
@ -152,7 +154,8 @@ if ($resql)
$var=true;
$prospectstatic=new Prospect($db);
$prospectstatic->client=2;
while ($i < min($num,$conf->liste_limit))
{
$obj = $db->fetch_object($resql);
@ -160,25 +163,31 @@ if ($resql)
$var=!$var;
print "<tr $bc[$var]>";
print '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowProspect"),"company");
print ' '.dolibarr_trunc($obj->nom,44).'</a></td>';
print '<td>';
$prospectstatic->id=$obj->rowid;
$prospectstatic->nom=$obj->nom;
print $prospectstatic->getNomUrl(1);
print '</td>';
print "<td>".$obj->ville."&nbsp;</td>";
print "<td align=\"center\">$obj->departement</td>";
// Date création
// Creation date
print "<td align=\"center\">".dolibarr_print_date($obj->datec)."</td>";
// Level
print "<td align=\"center\">";
print $prospectstatic->LibLevel($obj->fk_prospectlevel);
print "</td>";
// Statut
print "<td align=\"center\">";
print $prospectstatic->LibStatut($obj->fk_stcomm,2);
print "</td>";
$sts = array(-1,0,1,2,3);
print '<td align="right" nowrap>';
foreach ($sts as $key => $value)
{
if ($value <> $obj->fk_stcomm)
{
print '<a href="prospects.php?pid='.$obj->rowid.'&amp;pstcomm='.$value.'&amp;action=cstc&amp;'.$urladd.'">';
print '<a href="prospects.php?socid='.$obj->rowid.'&amp;pstcomm='.$value.'&amp;action=cstc&amp;'.$urladd.'">';
print img_action(0,$value);
print '</a>&nbsp;';
}

View File

@ -183,6 +183,12 @@ ErrorVATCheckMS_UNAVAILABLE=Check not possible. Check service is not provided by
NorProspectNorCustomer=Nor prospect, nor customer
JuridicalStatus=Juridical status
Staff=Staff
ProspectLevelShort=Potentiel
ProspectLevel=Prospect potential
PL_UNKNOWN=Unknown
PL_LOW=Low
PL_MEDIUM=Medium
PL_HIGH=High
TE_STARTUP=Startup
TE_GROUP=Large company
TE_MEDIUM=Medium company

View File

@ -183,6 +183,12 @@ ErrorVATCheckMS_UNAVAILABLE=V
NorProspectNorCustomer=Ni client, ni prospect
JuridicalStatus=Forme juridique
Staff=Effectif
ProspectLevelShort=Potentiel
ProspectLevel=Potentiel du prospect
PL_UNKNOWN=Indéterminé
PL_LOW=Faible
PL_MEDIUM=Moyen
PL_HIGH=Elevé
TE_STARTUP=Startup
TE_GROUP=Grand compte
TE_MEDIUM=PME/PMI

View File

@ -46,7 +46,7 @@ function societe_prepare_head($objsoc)
}
if ($objsoc->client==2)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$objsoc->id;
$head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$objsoc->id;
$head[$h][1] = $langs->trans("Prospect");
$head[$h][2] = 'prospect';
$h++;

View File

@ -15,16 +15,13 @@
* 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/prospect.class.php
\ingroup societe
\brief Fichier de la classe des prospects
\version $Revision$
\version $Id$
*/
@ -43,7 +40,7 @@ class Prospect extends Societe
/**
* \brief Constructeur de la classe
* \param DB handler accès base de données
* \param DB handler acc<EFBFBD>s base de donn<EFBFBD>es
* \param id id societe (0 par defaut)
*/
function Prospect($DB, $id=0)
@ -98,8 +95,8 @@ class Prospect extends Societe
/**
* \brief Retourne le libellé du statut d'une facture (brouillon, validée, abandonnée, payée)
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long
* \brief Retourne le libell<EFBFBD> du statut d'une facture (brouillon, valid<EFBFBD>e, abandonn<EFBFBD>e, pay<EFBFBD>e)
* \param mode 0=libell<EFBFBD> long, 1=libell<EFBFBD> court, 2=Picto + Libell<EFBFBD> court, 3=Picto, 4=Picto + Libell<EFBFBD> long
* \return string Libelle
*/
function getLibStatut($mode=0)
@ -108,10 +105,10 @@ class Prospect extends Societe
}
/**
* \brief Renvoi le libellé d'un statut donné
* \brief Renvoi le libelle d'un statut donne
* \param statut Id statut
* \param mode 0=libellé long, 1=libellé court, 2=Picto + Libellé court, 3=Picto, 4=Picto + Libellé long, 5=Libellé court + Picto
* \return string Libellé du statut
* \param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* \return string Libelle du statut
*/
function LibStatut($statut,$mode=0)
{
@ -146,5 +143,31 @@ class Prospect extends Societe
return "Error, mode/status not found";
}
/**
* \brief Renvoi le libelle du niveau
* \return string Libelle
*/
function getLibLevel()
{
return $this->LibLevel($this->fk_prospectlevel);
}
/**
* \brief Renvoi le libelle du niveau
* \param fk_prospectlevel Prospect level
* \return string Libelle du niveau
*/
function LibLevel($fk_prospectlevel)
{
global $langs;
$lib=$langs->trans("ProspectLevel".$fk_prospectlevel);
// If lib not found in language file, we get label from cache/databse
if ($lib == $langs->trans("ProspectLevel".$fk_prospectlevel))
{
$lib=$langs->getLabelFromKey($this->db,$fk_prospectlevel,'c_prospectlevel','code','label');
}
return $lib;
}
}
?>

View File

@ -1148,7 +1148,7 @@ class Societe extends CommonObject
}
elseif($this->client == 2)
{
$lien= '<a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$this->id.'">';
$lien= '<a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$this->id.'">';
$lienfin='</a>';
}
else

View File

@ -97,7 +97,7 @@ if ($_GET["socid"])
dolibarr_fiche_head($head, 'salesrepresentative', $langs->trans("ThirdParty"));
/*
* Fiche société en mode visu
* Fiche soci<EFBFBD>t<EFBFBD> en mode visu
*/
print '<table class="border" width="100%">';
@ -144,7 +144,7 @@ if ($_GET["socid"])
{
$obj = $db->fetch_object($resql);
if (!$user->rights->commercial->client->voir)
if (!$user->rights->societe->client->voir)
{
print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->rowid.'">';
print img_object($langs->trans("ShowUser"),"user").' ';
@ -179,8 +179,7 @@ if ($_GET["socid"])
print "</div>\n";
if ($user->rights->societe->creer && $user->rights->commercial->client->voir)
if ($user->rights->societe->creer && $user->rights->societe->client->voir)
{
/*
* Liste

View File

@ -39,8 +39,10 @@ class Translate {
var $tab_loaded=array(); // Tableau pour signaler les fichiers deja charges
var $tab_translate=array(); // Tableau des traductions
var $charset_inputfile='ISO-8859-1'; // Codage du contenu du fichier langue
var $cache_labels=array(); // Cache for labels
var $charset_inputfile='ISO-8859-1'; // Codage du contenu du fichier langue
var $charset_output='ISO-8859-1'; // Codage par defaut de la sortie de la methode trans
@ -445,6 +447,42 @@ class Translate {
return false;
}
/**
* \brief Return a label for a key. Store key-label in a cache.
* \param db Database handler
* \param key Key to get label
* \param tablename Table name
* \param fieldkey Field for key
* \param fieldlabel Field for label
* \return string Label
*/
function getLabelFromKey($db,$key,$tablename,$fieldkey,$fieldlabel)
{
// Check in cache
if (! empty($this->cache_labels[$tablename][$key]))
{
return $this->cache_labels[$tablename][$key]; // Found in cache
}
$sql = "SELECT ".$fieldlabel." as label";
$sql.= " FROM ".MAIN_DB_PREFIX.$tablename;
$sql.= " WHERE ".$fieldkey." = '".$key."'";
dolibarr_syslog('Translate::getLabelFromKey ',LOG_DEBUG);
$resql = $db->query($sql);
if ($resql)
{
$obj = $db->fetch_object($resql);
$this->cache_labels[$tablename][$key]=$obj->label;
return $this->cache_labels[$tablename][$key];
}
else
{
dolibarr_print_error($db);
return -1;
}
}
}
?>

View File

@ -1358,4 +1358,15 @@ INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active)
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (6, 'A3', 'Format A3', '297', '420', 'mm', 1);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (7, 'A4', 'Format A4', '210', '297', 'mm', 1);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (8, 'A5', 'Format A5', '148', '210', 'mm', 1);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (9, 'A6', 'Format A6', '105', '148', 'mm', 1);
INSERT INTO llx_c_paper_format (rowid, code, label, width, height, unit, active) VALUES (9, 'A6', 'Format A6', '105', '148', 'mm', 1);
--
-- Prospect level
--
delete from llx_c_prospectlevel;
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_UNKOWN', 'Unknown', 1);
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_LOW', 'Low', 2);
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_MEDIUM', 'Medium', 3);
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_HIGH', 'Eleve', 4);

View File

@ -202,3 +202,19 @@ ALTER TABLE llx_facture_fourn_det ADD product_type integer DEFAULT NULL a
-- V4.1 update llx_facture_fourn_det set product_type = 1 where fk_product in (select rowid from llx_product where fk_product_type = 1);
-- V4.1 update llx_facturedet set product_type = 1 where product_type is null;
-- V4.1 update llx_facture_fourn_det set product_type = 1 where product_type is null;
create table llx_c_prospectlevel
(
code varchar(12) PRIMARY KEY,
label varchar(30),
sortorder smallint,
active smallint DEFAULT 1 NOT NULL
) type=innodb;
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_UNKOWN', 'Unknown', 1);
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_LOW', 'Low', 2);
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_MEDIUM', 'Medium', 3);
insert into llx_c_prospectlevel (code,label,sortorder) values ('PL_HIGH', 'Eleve', 4);
alter table llx_societe add column fk_prospectlevel varchar(12) after fournisseur;

View File

@ -0,0 +1,28 @@
-- ===================================================================
-- Copyright (C) 2008 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$
-- ===================================================================
create table llx_c_prospectlevel
(
code varchar(12) PRIMARY KEY,
label varchar(30),
sortorder smallint,
active smallint DEFAULT 1 NOT NULL
) type=innodb;

View File

@ -24,3 +24,5 @@ ALTER TABLE llx_societe ADD UNIQUE uk_societe_code_client(code_client);
ALTER TABLE llx_societe ADD INDEX idx_societe_user_creat(fk_user_creat);
ALTER TABLE llx_societe ADD INDEX idx_societe_user_modif(fk_user_modif);
--ALTER TABLE llx_societe ADD FOREIGN KEY fk_prospectlevel llx_c_prospectlevel(code);

View File

@ -51,13 +51,14 @@ create table llx_societe
tva_intra varchar(20), -- tva
capital real, -- capital de la société
description text, --
fk_stcomm tinyint DEFAULT 0, -- commercial statut
fk_stcomm smallint DEFAULT 0, -- commercial statut
note text, --
services tinyint DEFAULT 0, --
prefix_comm varchar(5), -- prefix commercial
client tinyint DEFAULT 0, -- client 0/1/2
fournisseur tinyint DEFAULT 0, -- fournisseur 0/1
supplier_account varchar(32), -- compte client chez un fournisseur
fk_prospectlevel varchar(12), -- prospect level (in llx_c_prospectlevel)
customer_bad tinyint DEFAULT 0, -- mauvais payeur 0/1
customer_rate real DEFAULT 0, -- taux fiabilié client (0 à 1)
supplier_rate real DEFAULT 0, -- taux fiabilié fournisseur (0 à 1)