From 316516a41c7967ef1a6c5c89d4a555de000dfa34 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 25 Jan 2005 12:23:20 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/societe/commerciaux.php | 241 +++++++++++++++++++++++++++++++++ 1 file changed, 241 insertions(+) create mode 100644 htdocs/societe/commerciaux.php diff --git a/htdocs/societe/commerciaux.php b/htdocs/societe/commerciaux.php new file mode 100644 index 00000000000..01ceec35b0d --- /dev/null +++ b/htdocs/societe/commerciaux.php @@ -0,0 +1,241 @@ + + * + * 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/societe/commerciaux.php + \ingroup societe + \brief Page d'affectations des commerciaux aux societes + \version $Revision$ +*/ + +require("./pre.inc.php"); + +$user->getrights(); + +$langs->load("companies"); +$langs->load("customers"); +$langs->load("suppliers"); + +/* + * Sécurité accés client + */ + +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +if($_GET["socid"] && $_GET["commid"]) +{ + if ($user->rights->societe->creer) + { + $soc = new Societe($db); + $soc->id = $_GET["socid"]; + $soc->fetch($_GET["socid"]); + $soc->add_commercial($user, $_GET["commid"]); + + Header("Location: commerciaux.php?socid=".$soc->id); + } + else + { + Header("Location: commerciaux.php?socid=".$_GET["socid"]); + } +} + +if($_GET["socid"] && $_GET["delcommid"]) +{ + if ($user->rights->societe->creer) + { + $soc = new Societe($db); + $soc->id = $_GET["socid"]; + $soc->fetch($_GET["socid"]); + $soc->del_commercial($user, $_GET["delcommid"]); + + Header("Location: commerciaux.php?socid=".$soc->id); + } + else + { + Header("Location: commerciaux.php?socid=".$_GET["socid"]); + } +} + +llxHeader(); + +if($_GET["socid"]) +{ + + $soc = new Societe($db); + $soc->id = $_GET["socid"]; + $soc->fetch($_GET["socid"]); + + + $head[0][0] = DOL_URL_ROOT.'/soc.php?socid='.$soc->id; + $head[0][1] = $langs->trans("Company"); + $h = 1; + + $head[$h][0] = 'lien.php?socid='.$soc->id; + $head[$h][1] = 'Lien'; + $h++; + + $head[$h][0] = 'commerciaux.php?socid='.$soc->id; + $head[$h][1] = 'Commerciaux'; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$soc->id; + $head[$h][1] = $langs->trans("Note"); + $h++; + + dolibarr_fiche_head($head, 2, $soc->nom); + + /* + * Fiche société en mode visu + */ + + print ''; + print ''; + + print '"; + + print ''; + + + print ''; + + print ''; + + if ($soc->parent > 0) + { + $socm = new Societe($db); + $socm->fetch($soc->parent); + + print ''; + } + + /* ********** */ + + $sql = "SELECT u.rowid, u.name, u.firstname"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " , ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql .= " WHERE sc.fk_soc =".$soc->id; + $sql .= " AND sc.fk_user = u.rowid"; + $sql .= " ORDER BY u.name ASC "; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + + while ($i < $num) + { + $obj = $db->fetch_object(); + + print ''."\n"; + $i++; + } + + print "
'.$langs->trans('Name').''.$soc->nom.'
'.$langs->trans('Address')."".nl2br($soc->adresse)."
".$soc->cp." ".$soc->ville." ".$soc->pays."
'.$langs->trans('Phone').''.dolibarr_print_phone($soc->tel).'
'; + print $langs->trans('Code client').''; + print $soc->code_client; + if ($soc->check_codeclient() <> 0) + { + print "Code incorrect"; + } + print '
'.$langs->trans('Web').''; + if ($soc->url) { print 'http://'.$soc->url.''; } + print '
Maison mère'.$socm->nom_url.' ('.$socm->code_client.')
'.$socm->ville.'
Commercial'; + print stripslashes($obj->firstname)." " .stripslashes($obj->name)."\n"; + print ' '; + print ''; + print img_delete(); + print '
"; + $db->free(); + } + else + { + dolibarr_print_error($db); + } + + + print ''; + print "
\n"; + + + + if ($user->rights->societe->creer) + { + /* + * Liste + * + */ + + $title=$langs->trans("Liste des utilisateurs"); + + $sql = "SELECT u.rowid, u.name, u.firstname"; + $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; + $sql .= " ORDER BY u.name ASC "; + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; + + print_titre($title); + + // Lignes des titres + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + + while ($i < $num) + { + $obj = $db->fetch_object(); + $var=!$var; + print "\n"; + print ''; + + print ''."\n"; + $i++; + } + + print "
'.$langs->trans("Nom").' 
"; + print stripslashes($obj->firstname)." " .stripslashes($obj->name)."Sélectionner
"; + $db->free(); + } + else + { + dolibarr_print_error($db); + } + } + +} + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>