* Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 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, see . */ /** * \file htdocs/comm/prospect/fiche.php * \ingroup prospect * \brief Page de la fiche prospect */ require_once("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/comm/prospect/class/prospect.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php"); if ($conf->adherent->enabled) require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); $langs->load('companies'); $langs->load('projects'); $langs->load('propal'); // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe', $socid, '&societe'); /* * Actions */ if ($_GET["action"] == 'cstc') { $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"]; $sql .= " WHERE rowid = ".$_GET["socid"]; $db->query($sql); } // set prospect level if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer) { $societe = new Societe($db); $societe->fetch($_GET["socid"]); $societe->fk_prospectlevel=$_POST['prospect_level_id']; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_prospectlevel='".$_POST['prospect_level_id']; $sql.= "' WHERE rowid='".$_GET["socid"]."'"; $result = $db->query($sql); if (! $result) dol_print_error($result); } /********************************************************************************* * * Mode fiche * *********************************************************************************/ llxHeader(); $now = dol_now(); $form=new Form($db); $formcompany=new FormCompany($db); if ($socid > 0) { $actionstatic=new ActionComm($db); $societe = new Prospect($db, $socid); $result = $societe->fetch($socid); if ($result < 0) { dol_print_error($db); exit; } /* * Affichage onglets */ $head = societe_prepare_head($societe); dol_fiche_head($head, 'prospect', $langs->trans("ThirdParty"),0,'company'); print ''; print '\n"; print '"; print "
'; print ''; print ''; // Address print '"; // Zip / Town print ''; print ''; // Country print ''; // Phone print ''; print ''; // EMail print ''; // Web print '"; // Level of prospect print '"; print ''; // Multiprice level if ($conf->global->PRODUIT_MULTIPRICES) { print '"; print ''; } // Status print ''; print ''; // Module Adherent if ($conf->adherent->enabled) { $langs->load("members"); $langs->load("users"); print ''; print ''; print "\n"; } print '
'.$langs->trans("ThirdPartyName").''; $societe->next_prev_filter="te.client in (2,3)"; print $form->showrefnav($societe,'socid','',($user->societe_id?0:1),'rowid','nom','',''); print '
'.$langs->trans("Address").''; dol_print_address($societe->address,'gmap','thirdparty',$societe->id); print "
'.$langs->trans('Zip').' / '.$langs->trans("Town").''.$societe->cp.(($societe->cp && $societe->ville)?' / ':'').$societe->ville.'
'.$langs->trans("Country").''; $img=picto_from_langcode($societe->country_code); if ($societe->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$societe->country,$langs->trans("CountryIsInEEC"),1,0); else print ($img?$img.' ':'').$societe->country; print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->country_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->country_code).'
'.$langs->trans('EMail').''.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'
'.$langs->trans("Web")."url\">$societe->url
'; print ''; print '
'; print $langs->trans('ProspectLevelShort'); print ''; if (($_GET['action'] != 'editlevel') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetLevel'),1).'
'; print '
'; if ($_GET['action'] == 'editlevel') { $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$societe->id,$societe->fk_prospectlevel,'prospect_level_id',1); } else { print $societe->getLibLevel(); //$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none'); } print "
'; print '
'; print $langs->trans("PriceLevel"); print ''; if ($user->rights->societe->creer) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print '
'.$societe->price_level."
'.$langs->trans("StatusProsp").''.$societe->getLibProspStatut(4).''; if ($societe->stcomm_id != -1) print ''.img_action(0,-1).''; if ($societe->stcomm_id != 0) print ''.img_action(0,0).''; if ($societe->stcomm_id != 1) print ''.img_action(0,1).''; if ($societe->stcomm_id != 2) print ''.img_action(0,2).''; if ($societe->stcomm_id != 3) print ''.img_action(0,3).''; print '
'.$langs->trans("LinkedToDolibarrMember").''; $adh=new Adherent($db); $result=$adh->fetch('','',$societe->id); if ($result > 0) { $adh->ref=$adh->getFullName($langs); print $adh->getNomUrl(1); } else { print $langs->trans("UserNotLinkedToMember"); } print '
'; print "
'; // Nbre max d'elements des petites listes $MAXLIST=5; $tableaushown=0; // Lien recap print ''; print ''; print ''; print ''; print '
'; print '
'.$langs->trans("Summary").''.$langs->trans("ShowProspectPreview").'
'; print '
'; /* * Last proposals */ if ($conf->propal->enabled && $user->rights->propale->lire) { $propal_static=new Propal($db); $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; $sql.= " p.datep as dp, p.fin_validite as datelimite,"; $sql.= " c.label as statut, c.id as statutid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."propal as p"; $sql.= ", ".MAIN_DB_PREFIX."c_propalst as c"; $sql.= " WHERE p.fk_soc = s.rowid"; $sql.= " AND p.fk_statut = c.id"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND s.rowid = ".$societe->id; $sql.= " ORDER BY p.datep DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $i = 0; $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print "\n"; print "\n"; print "\n"; $i++; } $db->free(); if ($num > 0) print "
'; print ''; print '
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')'.img_picto($langs->trans("Statistics"),'stats').'
propalid\">"; print img_object($langs->trans("ShowPropal"),"propal"); print " ".$objp->ref."\n"; if ($db->jdate($objp->dp) < ($now - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1) { print " ".img_warning(); } print "".dol_print_date($db->jdate($objp->dp),"day")."".price($objp->total_ht)."".$propal_static->LibStatut($objp->fk_statut,5)."
"; } else { dol_print_error($db); } } print "
\n"; dol_fiche_end(); /* * Barre d'action */ print '
'; if ($conf->propal->enabled && $user->rights->propale->creer) { print ''.$langs->trans("AddProp").''; } // Add action if ($conf->agenda->enabled && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { if ($user->rights->agenda->myactions->create) { print ''.$langs->trans("AddAction").''; } else { print ''.$langs->trans("AddAction").''; } } print '
'; print '
'; if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) { print '
'; // List of contacts show_contacts($conf,$langs,$db,$societe,$_SERVER["PHP_SELF"].'?socid='.$societe->id); } if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) { print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); // List of todo actions show_actions_todo($conf,$langs,$db,$societe); // List of done actions show_actions_done($conf,$langs,$db,$societe); } } llxFooter(); $db->close(); ?>