* Copyright (C) 2004-2008 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. */ /** \file htdocs/compta/fiche.php \ingroup compta \brief Page de fiche compta \version $Id$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); $langs->load("companies"); if ($conf->facture->enabled) $langs->load("bills"); if ($conf->projet->enabled) $langs->load("projects"); // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe',$socid,''); /* * Recherche * */ if ($mode == 'search') { if ($mode-search == 'soc') { $sql = "SELECT s.rowid 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->rowid; } $db->free(); } if ($user->societe_id > 0) { $socid = $user->societe_id; } } /* * Mode fiche */ llxHeader(); $facturestatic=new Facture($db); $contactstatic = new Contact($db); $form = new Form($db); if ($socid > 0) { $societe = new Societe($db); $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; if ($societe->id <= 0) { dolibarr_print_error($db,$societe->error); } /* * Affichage onglets */ $head = societe_prepare_head($societe); dolibarr_fiche_head($head, 'compta', $langs->trans("ThirdParty")); print ''; print '\n"; print '"; print "
'; print ''; print ''; // Prefix print ''; if ($societe->client) { print ''; print ''; print ''; print ''; print ''; print ''; } if ($societe->fournisseur) { print ''; print ''; print ''; print ''; print ''; print ''; } print '"; print ''; print ''; // Country print ''; print ''; print '"; // Assujeti � TVA ou pas print ''; print ''; print ''; // TVA Intra print ''; if ($societe->client == 1) { // Remise permanente print ''; print ''; // R�ductions (Remises-Ristournes-Rabbais) print ''; print ''; print ''; } print "
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Prefix").''; print ($societe->prefix_comm?$societe->prefix_comm:' '); print '
'.$langs->trans("CustomerCode"). ''. $societe->code_client . '
'.$langs->trans("CustomerAccountancyCode").''.$societe->code_compta.'
'.$langs->trans("SupplierCode"). ''. $societe->code_fournisseur . '
'.$langs->trans("SupplierAccountancyCode").''.$societe->code_compta_fournisseur.'
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'.$langs->trans('Zip').''.$societe->cp.''.$langs->trans('Town').''.$societe->ville.'
'.$langs->trans('Country').''; if ($societe->isInEEC()) print $form->textwithhelp($societe->pays,$langs->trans("CountryIsInEEC"),1,0); print '
'.$langs->trans("Phone").''.dolibarr_print_phone($societe->tel,$societe->pays_code).' '.$langs->trans("Fax").''.dolibarr_print_phone($societe->fax,$societe->pays_code).' 
'.$langs->trans("Web")."url\" target=\"_blank\">$societe->url 
'.$langs->trans('VATIsUsed').''; print yn($societe->tva_assuj); print '
'.$langs->trans('VATIntraVeryShort').''; print $societe->tva_intra; print '
'; print '
'; print $langs->trans("CustomerRelativeDiscountShort"); print ''; if (!$user->societe_id > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print '
'.($societe->remise_client?price2num($societe->remise_client,'MT').'%':$langs->trans("DiscountNone")).'
'; print ''; print '
'; print $langs->trans("CustomerAbsoluteDiscountShort"); print ''; if (!$user->societe_id > 0) { print ''.img_edit($langs->trans("Modify")).''; } print '
'; print '
'; $amount_discount=$societe->getAvailableDiscounts(); if ($amount_discount < 0) dolibarr_print_error($db,$societe->error); if ($amount_discount > 0) print price($amount_discount).' '.$langs->trans("Currency".$conf->monnaie); else print $langs->trans("DiscountNone"); print '
"; print "
'; // Nbre max d'�l�ments des petites listes $MAXLIST=5; $tableaushown=1; // Lien recap print ''; print ''; print ''; print ''; print '
'; print '
'.$langs->trans("Summary").''.$langs->trans("ShowAccountancyPreview").'
'; print '
'; /** * Dernieres factures */ if ($conf->facture->enabled && $user->rights->facture->lire) { $facturestatic = new Facture($db); print ''; $sql = 'SELECT f.rowid as facid, f.facnumber, f.type, f.amount, f.total, f.total_ttc'; $sql.= ', '.$db->pdate("f.datef").' as df, f.paye as paye, f.fk_statut as statut'; $sql.= ', s.nom, s.rowid as socid'; $sql.= ', sum(pf.amount) as am'; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON f.rowid=pf.fk_facture'; $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; $sql.= ' GROUP BY f.rowid'; $sql.= " ORDER BY f.datef DESC, f.datec DESC"; $resql=$db->query($sql); if ($resql) { $var=true; $num = $db->num_rows($resql); $i = 0; if ($num > 0) { $tableaushown=1; print ''; print ''; print ''; } while ($i < $num && $i < $MAXLIST) { $objp = $db->fetch_object($resql); $var=!$var; print ""; print ''; if ($objp->df > 0) { print "\n"; } else { print "\n"; } print "\n"; print '\n"; print "\n"; $i++; } $db->free($resql); } else { dolibarr_print_error($db); } print "
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' ('.$num.')
'; $facturestatic->id=$objp->facid; $facturestatic->ref=$objp->facnumber; $facturestatic->type=$objp->type; print $facturestatic->getNomUrl(1); print '".dolibarr_print_date($objp->df)."!!!".price($objp->total_ttc)."'.($facturestatic->LibStatut($objp->paye,$objp->statut,5,$objp->am))."
"; } /* * Derniers projets associes */ 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) { $tableaushown=1; 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.')
'.img_object($langs->trans("ShowProject"),"project")." ".$obj->title.'".dolibarr_print_date($obj->do,"day") ."
"; } 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) { $langs->load("trips"); print "id&action=create\">".$langs->trans("AddTrip").""; } } if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) { print ''.$langs->trans("AddAction").''; } if ($user->rights->societe->contact->creer) { print "".$langs->trans("AddContact").""; } print '
'; print "
\n"; /* * * Liste des contacts * */ print_titre($langs->trans("ContactsForCompany")); print ''; print ''; print ''; print ''; print ""; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) { print ''; } print ""; $sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note"; $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p"; $sql.= " WHERE p.fk_soc = ".$societe->id; $sql.= " ORDER by p.datec"; $result = $db->query($sql); $i = 0 ; $num = $db->num_rows($result); $var=1; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print ""; print ''; print ''; print ''; print ''; print ''; print ''; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) { print ''; } print "\n"; $i++; $tag = !$tag; } print "
'.$langs->trans("Name").''.$langs->trans("Poste").''.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").'  
'; print ''.img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.' '; if (trim($obj->note)) { print '
'.nl2br(trim($obj->note)); } print '
'.$obj->poste.' '; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) print ''; print $obj->phone; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) print ''; if ($obj->phone) print dol_phone_link($obj->phone); print ''; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) print ''; print $obj->fax; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) print ''; print ''; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) print ''; print $obj->email; if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) print ''; print ' '; if ($user->rights->societe->contact->creer) { print "rowid."\">"; print img_edit(); print ''; } else print ' '; print ''; print img_object($langs->trans("Rendez-Vous"),"action"); print '
"; print "
"; /* * Listes des actions a faire */ show_actions_todo($conf,$langs,$db,$societe); /* * Listes des actions effectuees */ show_actions_done($conf,$langs,$db,$societe); } else { dolibarr_print_error($db,'Bad value for socid parameter'); } $db->close(); llxFooter('$Date$ - $Revision$'); ?>