* Copyright (C) 2004-2005 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$ * */ /** \file htdocs/compta/fiche.php \ingroup compta \brief Page de fiche compta \version $Revision$ */ require("./pre.inc.php"); require("../contact.class.php"); require("../actioncomm.class.php"); require("../facture.class.php"); $langs->load("companies"); if ($conf->facture->enabled) $langs->load("bills"); if ($conf->projet->enabled) $langs->load("projects"); /* * Sécurité accés client */ $socid = $_GET["socid"]; if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } $user->getrights('facture'); llxHeader(); if ($action=='add_action') { /* * Vient de actioncomm.php * */ $actioncomm = new ActionComm($db); $actioncomm->date = $date; $actioncomm->type = $actionid; $actioncomm->contact = $contactid; $actioncomm->societe = $socid; $actioncomm->note = $note; $actioncomm->add($user); $societe = new Societe($db); $societe->fetch($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,'". $user->login ."')"; $result = $db->query($sql); } /* TODO RODO if ($action == 'stcomm') { if ($stcommid <> 'null' && $stcommid <> $oldstcomm) { $sql = "INSERT INTO socstatutlog (datel, fk_soc, fk_statut, author) "; $sql .= " VALUES ('$dateaction',$socid,$stcommid,'" . $user->login . "')"; $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(); $socid = $obj->idp; } $db->free(); } if ($user->societe_id > 0) { $socid = $user->societe_id; } } /* * * Mode fiche * */ if ($socid > 0) { $societe = new Societe($db); $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.idp > $socid ORDER BY idp ASC LIMIT 1"; /* * Affichage onglets */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Company"); $h++; if ($societe->client==1) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Customer"); $h++; } if ($societe->client==2) { $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$societe->id; $head[$h][1] = $langs->trans("Prospect"); $h++; } if ($societe->fournisseur) { $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Supplier"); $h++; } if ($conf->compta->enabled) { $langs->load("compta"); $hselected=$h; $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Accountancy"); $h++; $head[$h][0] = DOL_URL_ROOT.'/compta/recap-client.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Recap"); $h++; } $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Note"); $h++; if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Documents"); $h++; } $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Notifications"); $h++; if ($user->societe_id == 0) { $head[$h][0] = DOL_URL_ROOT."/index.php?socidp=$societe->id&action=add_bookmark"; $head[$h][1] = 'Bookmark'; $head[$h][2] = 'image'; } dolibarr_fiche_head($head, $hselected, $societe->nom); /* * */ print "\n"; print '\n"; print '"; print "
'; print ''; print ''; print '"; print ''; print ''; print ''; print '"; print ''; print '"; print ''; print '"; print "
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'.$langs->trans('Zip').' / '.$langs->trans('Town').''.$societe->cp." ".$societe->ville.'
'.$langs->trans('Country').''.$societe->pays.'
'.$langs->trans("Phone").''.$societe->tel.' Fax'.$societe->fax.' 
'.$langs->trans("Web")."url\">$societe->url 
'.$langs->transcountry("ProfId1",$societe->pays_code).''.$societe->siren.' '.$langs->trans("Prefix").''; if ($societe->prefix_comm) { print $societe->prefix_comm; } print "
Code compta'.$societe->code_compta.''.$langs->trans("CustomerCode").''; print $societe->code_client; print "
"; print "
"; /* * */ print "
'; // Nbre max d'éléments des petites listes $MAXLIST=5; /* * Dernieres factures */ if ($conf->facture->enabled && $user->rights->facture->lire) { print ''; $sql = "SELECT s.nom, s.idp, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df, f.paye as paye, f.fk_statut as statut, f.rowid as facid "; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql .= " WHERE f.fk_soc = s.idp AND s.idp = ".$societe->id; $sql .= " ORDER BY f.datef DESC"; if ( $db->query($sql) ) { $var=true; $num = $db->num_rows(); $i = 0; if ($num > 0) { print ""; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object(); $var=!$var; print ""; print "\n"; if ($objp->df > 0 ) { print "\n"; } else { print "\n"; } print "\n"; $fac = new Facture($db); print "\n"; print "\n"; $i++; } $db->free(); } else { dolibarr_print_error($db); } print "
'.$langs->trans("LastBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' ('.$num.')
facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$objp->facnumber."".dolibarr_print_date($objp->df)."!!!".number_format($objp->amount, 2, ',', ' ')."".($fac->LibStatut($objp->paye,$objp->statut))."
"; } /* * Derniers projets associés */ if ($conf->projet->enabled) { print ''; $sql = "SELECT p.rowid,p.title,p.ref,".$db->pdate("p.dateo")." as do"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; $sql .= " WHERE p.fk_soc = $societe->id"; $sql .= " ORDER by p.dateo"; if ( $db->query($sql) ) { $var=true; $i = 0 ; $num = $db->num_rows(); if ($num > 0) { print ""; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $obj = $db->fetch_object(); $var = !$var; print ""; print ''; print ""; $i++; } $db->free(); } else { dolibarr_print_error($db); } print "
'.$langs->trans("LastProjects",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllProjects").' ('.$num.')
'.$obj->title.'".strftime("%d %b %Y", $obj->do) ."
"; } print "
\n"; /* * Barre d'actions * */ print '
'; if ($user->societe_id == 0) { // Si société cliente ou prospect, on affiche bouton "Créer facture client" if ($societe->client != 0 && $conf->facture->enabled && $user->rights->facture->creer) { $langs->load("bills"); print "id\">".$langs->trans("AddBill").""; } if ($conf->deplacement->enabled) { print "id&action=create\">".$langs->trans("AddTrip").""; } } print '
'; print "
\n"; /* * * */ 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 ""; 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(); $var=1; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print ""; print ''; print ''; print ''; print ''; print ''; print ''; print ''; print "\n"; $i++; $tag = !$tag; } print "
'.$langs->trans("Firstname").' '.$langs->trans("Lastname").''.$langs->trans("Poste").''.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").'".$langs->trans("AddContact")." 
'; print ''.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.' '; if (trim($obj->note)) { print '
'.nl2br(trim($obj->note)); } print '
'.$obj->poste.' '.$obj->phone.' '.$obj->fax.' '.$obj->email.' '; print "idp\">"; print img_edit(); print ''; print img_object($langs->trans("Rendez-Vous"),"action"); print '

"; /* * Listes des actions effectuées */ print ''; print ''; $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 "; $sql .= " ORDER BY a.datea DESC, a.id DESC"; if ( $db->query($sql) ) { $i = 0 ; $num = $db->num_rows(); while ($i < $num) { $var = !$var; $obj = $db->fetch_object(); 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 ''; print ''; } else { print ''.img_object($langs->trans("ShowTask"),"task").' '.$obj->libelle.''; } /* * Contact pour cette action * */ if ($obj->fk_contact) { $contact = new Contact($db); $contact->fetch($obj->fk_contact); print ''; } else { print ''; } /* */ print ''; print "\n"; $i++; } $db->free(); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsDone").'
|" .strftime("%Y",$obj->da)."|" .strftime("%b",$obj->da)."" .strftime("%d",$obj->da)."" .strftime("%H:%M",$obj->da)." '; if ($obj->propalrowid) { print ''.img_object($langs->trans("ShowTask"),"task").' '.$obj->libelle.''.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.' '.$obj->code.'
"; /* * * Notes sur la societe * */ if ($societe->note) { print ''; print ""; print "
".nl2br($societe->note)."
"; } /* * * * */ } } else { print "Erreur"; } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>