diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php new file mode 100644 index 00000000000..41a6de62338 --- /dev/null +++ b/htdocs/comm/prospect/fiche.php @@ -0,0 +1,515 @@ + + * Copyright (C) 2004 Laurent Destailleur + * + * 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$ + * + */ +require("./pre.inc.php"); +require("../../contact.class.php"); +require("../../cactioncomm.class.php"); +require("../../actioncomm.class.php"); + +llxHeader(); +$user->getrights('propale'); +$user->getrights('projet'); + +if ($sortorder == "") { + $sortorder="ASC"; +} +if ($sortfield == "") { + $sortfield="nom"; +} + + +if ($action == 'attribute_prefix') { + $societe = new Societe($db, $socid); + $societe->attribute_prefix($db, $socid); +} + +if ($action == 'recontact') { + $dr = mktime(0, 0, 0, $remonth, $reday, $reyear); + $sql = "INSERT INTO ".MAIN_DB_PREFIX."soc_recontact (fk_soc, datere, author) VALUES ($socid, $dr,'". $GLOBALS["REMOTE_USER"]."')"; + $result = $db->query($sql); +} + +if ($action == 'stcomm') { + if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { + $sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) "; + $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $GLOBALS["REMOTE_USER"] . "')"; + $result = @$db->query($sql); + + if ($result) { + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm=$stcommid WHERE idp=$socid"; + $result = $db->query($sql); + } else { + $errmesg = "ERREUR DE DATE !"; + } + } + + if ($actioncommid) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea, fk_action, fk_soc, fk_user_author) VALUES ('$dateaction',$actioncommid,$socid,'" . $user->id . "')"; + $result = @$db->query($sql); + + if (!$result) { + $errmesg = "ERREUR DE DATE !"; + } + } +} + +/* + * Recherche + * + * + */ +if ($mode == 'search') { + if ($mode-search == 'soc') { + $sql = "SELECT s.idp FROM ".MAIN_DB_PREFIX."societe as s "; + $sql .= " WHERE lower(s.nom) like '%".strtolower($socname)."%'"; + } + + if ( $db->query($sql) ) { + if ( $db->num_rows() == 1) { + $obj = $db->fetch_object(0); + $socid = $obj->idp; + } + $db->free(); + } +} +/* + * + */ +$socid = $_GET["id"]; +/* + * Sécurité si un client essaye d'accéder à une autre fiche que la sienne + */ +if ($user->societe_id > 0) +{ + $socid = $user->societe_id; +} +/********************************************************************************* + * + * Mode fiche + * + * + *********************************************************************************/ +if ($socid > 0) +{ + $societe = new Societe($db, $socid); + $result = $societe->fetch($socid); + + if ($result) + { + + + /* + * + */ + print ''; + + print ""; + + if ($user->societe_id == 0) + { + print ""; + print ""; + + print ""; + print ""; + } + print "
Fiche prospect : $societe->nom
[id\">Documents][id&action=add_bookmark\">Bookmark][id\">Notes][id&action=edit\">Editer]
"; + /* + * + * + */ + print ''; + print '\n"; + print '"; + print "
'; + print ''; + + print ""; + print ""; + print ""; + + print ""; + print ""; + + print ''; + print ''; + + if ($societe->url) + { + print ""; + } + + if ($societe->rubrique) + { + print ""; + } + + print "
Type $societe->typentEffectif$societe->effectif
Téléphone $societe->tel fax$societe->fax 
Ville".nl2br($societe->address)."
$societe->cp $societe->ville
sirensiren\">$societe->siren APE"; + print $societe->ape; + print "
Siret'.$societe->siret.'Capital'.$societe->capital.'
Siteurl\">$societe->url 
Rubrique$societe->rubrique
"; + + /* + * + */ + print "
'; + + /* + * + * Propales + * + */ + $var = true; + print ''; + $sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref, p.remise, ".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id"; + $sql .= " AND s.idp = $societe->id ORDER BY p.datep DESC"; + + if ( $db->query($sql) ) + { + $num = $db->num_rows(); + if ($num >0 ) + { + print ""; + $var=!$var; + } + $i = 0; $now = time(); $lim = 3600 * 24 * 15 ; + while ($i < $num && $i < 2) + { + $objp = $db->fetch_object( $i); + print ""; + print "\n"; + print "\n"; + print "\n"; + $var=!$var; + $i++; + } + $db->free(); + } + + print "
id\">Liste des propales ($num)
propalid\">$objp->ref\n"; + if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 ) + { + print " > 15 jours"; + } + print "".strftime("%d %B %Y",$objp->dp)."".price($objp->price)."$objp->statut
"; + /* + * + * + */ + print "
\n"; + /* + * Barre d'action + * + */ + print '
'; + + if ($conf->propal->enabled && defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE && $user->rights->propale->creer) + { + print ""; + } + else + { + print ''; + } + print ''; + + + print ''; + + if ($conf->projet->enabled && $user->rights->projet->creer) + { + print ''; + } + else + { + print ''; + } + + + + print '
id&action=create\">Créer une proposition---Créer un projet-

'; + + /* + * + * + * + */ + if ($action == 'changevalue') { + print "
"; + print "
id\" method=\"post\">"; + print ""; + print "Cette société est un cabinet de recrutement : "; + print ""; + print ""; + print "
\n"; + } else { + /* + * + * Liste des contacts + * + */ + print ''; + + print ''; + print ''; + print ""; + print ""; + + $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $societe->id ORDER by p.datec"; + $result = $db->query($sql); + $i = 0 ; $num = $db->num_rows(); $tag = True; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var = !$var; + print ""; + + print '"; + print ""; + print ''; + print ''; + print ''; + print "'; + print "\n"; + $i++; + $tag = !$tag; + } + print "
Prénom NomPosteTélFaxEmailid&action=create\">Ajouter
'; + + print ''.$obj->firstname.' '. $obj->name.' '; + + if ($obj->note) + { + print "
".nl2br($obj->note); + } + print "
$obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' "; + print "id\">"; + print img_edit(); + print '
"; + + print "

"; + + /* + * + * Listes des actions a faire + * + */ + print ''; + print ''; + print ''; + print '
Actions à faire [Nouvelle action]
'; + + $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; + $sql .= " WHERE a.fk_soc = $societe->id "; + $sql .= " AND u.rowid = a.fk_user_author"; + $sql .= " AND c.id=a.fk_action AND a.percent < 100"; + $sql .= " ORDER BY a.datea DESC, a.id DESC"; + + if ( $db->query($sql) ) { + print "\n"; + + $i = 0 ; $num = $db->num_rows(); + while ($i < $num) { + $var = !$var; + + $obj = $db->fetch_object( $i); + print ""; + + if ($oldyear == strftime("%Y",$obj->da) ) { + print ''; + } else { + print "\n"; + $oldyear = strftime("%Y",$obj->da); + } + + if ($oldmonth == strftime("%Y%b",$obj->da) ) { + print ''; + } else { + print "\n"; + $oldmonth = strftime("%Y%b",$obj->da); + } + + print "\n"; + print "\n"; + + print ''; + + if ($obj->propalrowid) + { + print ''; + } + else + { + print ''; + } + /* + * Contact pour cette action + * + */ + if ($obj->fk_contact) { + $contact = new Contact($db); + $contact->fetch($obj->fk_contact); + print ''; + } else { + print ''; + } + /* + */ + print ''; + print "\n"; + $i++; + } + print "
|" .strftime("%Y",$obj->da)."|" .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)." '.$obj->libelle.''.$obj->libelle.''.$contact->fullname.' '.$obj->code.'
"; + + $db->free(); + } else { + print $db->error(); + } + print "
"; + + /* + * + * Listes des actions effectuees + * + */ + print ''; + print ''; + print ''; + print '
Actions effectuées
'; + + $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid "; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u "; + $sql .= " WHERE a.fk_soc = $societe->id "; + $sql .= " AND u.rowid = a.fk_user_author"; + $sql .= " AND c.id=a.fk_action AND a.percent = 100"; + $sql .= " ORDER BY a.datea DESC, a.id DESC"; + + if ( $db->query($sql) ) + { + print ''; + + $i = 0 ; + $num = $db->num_rows(); + $oldyear=''; + $oldmonth=''; + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object( $i); + print ""; + + if ($oldyear == strftime("%Y",$obj->da) ) + { + print ''; + } + else + { + print "\n"; + $oldyear = strftime("%Y",$obj->da); + } + + if ($oldmonth == strftime("%Y%b",$obj->da) ) + { + print ''; + } + else + { + print "\n"; + $oldmonth = strftime("%Y%b",$obj->da); + } + + print "\n"; + print "\n"; + + print ''; + + if ($obj->propalrowid) + { + print ''; + } + else + { + print ''; + } + /* + * Contact pour cette action + * + */ + if ($obj->fk_contact) + { + $contact = new Contact($db); + $contact->fetch($obj->fk_contact); + print ''; + } + else + { + print ''; + } + /* + */ + print ''; + print "\n"; + $i++; + } + print "
|" .strftime("%Y",$obj->da)."|" .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)." '.$obj->libelle.''.$obj->libelle.''.$contact->fullname.' '.$obj->code.'
"; + + $db->free(); + } + else + { + print $db->error(); + } + print "
"; + /* + * + * Notes sur la societe + * + */ + if ($societe->note) + { + print ''; + print ""; + print "
".nl2br($societe->note)."
"; + } + /* + * + * + * + */ + + } + } else { + print $db->error() . "
" . $sql; + } +} else { + print "Erreur"; +} +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>