* Copyright (C) 2003 Eric Seigne * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2008 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * \file htdocs/fourn/fiche.php * \ingroup fournisseur, facture * \brief Page de fiche fournisseur * \version $Id$ */ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); $langs->load('suppliers'); $langs->load('products'); $langs->load('bills'); $langs->load('orders'); $langs->load('companies'); $langs->load('commercial'); // Security check $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe',$socid,''); /* * View */ $societe = new Fournisseur($db); $contactstatic = new Contact($db); $form = new Form($db); if ( $societe->fetch($socid) ) { llxHeader('',$langs->trans('SupplierCard')); /* * Affichage onglets */ $head = societe_prepare_head($societe); dol_fiche_head($head, 'supplier', $langs->trans("ThirdParty")); print ''; print ''; print '
'; print ''; print ''; print ''; if ($societe->fournisseur) { print ''; } print ''; print ''; print ''; // Country print ''; // Phone print ''; // Fax print ''; // EMail print ''; // Web print '"; // Assujetti a TVA ou pas print ''; print ''; print ''; print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; print $langs->trans('SupplierCode').''; print $societe->code_fournisseur; if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); print '
'.$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); else print $societe->pays; print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans('EMail').''.dol_print_email($societe->email,0,$societe->id,'AC_EMAIL').'
'.$langs->trans("Web")."".dol_print_url($societe->url)."
'.$langs->trans('VATIsUsed').''; print yn($societe->tva_assuj); print '
'; print '
'; $var=true; $MAXLIST=5; // Lien recap print ''; print ''; print ''; print ''; print '
'; print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; /* * List of products */ if ($conf->produit->enabled || $conf->service->enabled) { $langs->load("products"); print ''; print ''; print '
'.$langs->trans("ProductsAndServices").''; print ''.$langs->trans("All").' ('.$societe->NbProduct().')'; print '
'; } print '
'; /* * Liste des commandes associees */ $orderstatic = new CommandeFournisseur($db); $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$societe->id; $sql.= " ORDER BY p.date_commande DESC"; $sql.= " ".$db->plimit($MAXLIST); $resql=$db->query($sql); if ($resql) { $i = 0 ; $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; } while ($i < $num && $i <= $MAXLIST) { $obj = $db->fetch_object($resql); $var=!$var; print ""; print ''; print ''; print ''; print ''; $i++; } $db->free($resql); if ($num > 0) { print "
'; print ''; print '
'.$langs->trans("LastOrders",($num<$MAXLIST?$num:$MAXLIST)).''.$langs->trans("AllOrders").' ('.$num.')
'; print '
'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.''; if ($obj->dc) { print dol_print_date($obj->dc,'day'); } else { print "-"; } print ''.$orderstatic->LibStatut($obj->fk_statut,5).'
"; } } else { dol_print_error($db); } /* * Liste des factures associees */ $MAXLIST=5; $langs->load('bills'); $facturestatic = new FactureFournisseur($db); $sql = 'SELECT p.rowid,p.libelle,p.facnumber,p.fk_statut,'.$db->pdate('p.datef').' as df, total_ttc as amount, paye'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as p'; $sql.= ' WHERE p.fk_soc = '.$societe->id; $sql.= ' ORDER BY p.datef DESC'; $resql=$db->query($sql); if ($resql) { $i = 0 ; $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; } while ($i < min($num,$MAXLIST)) { $obj = $db->fetch_object($resql); $var=!$var; print ''; print ''; print ''; print ''; print ''; print ''; $i++; } $db->free($resql); if ($num > 0) { print '
'; print '
'.$langs->trans('LastSuppliersBills',($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans('AllBills').' ('.$num.')
'; print '
'; print ''; print img_object($langs->trans('ShowBill'),'bill').' '.$obj->facnumber.' '.dol_trunc($obj->libelle,14).''.dol_print_date($obj->df,'day').''.price($obj->amount).''.$facturestatic->LibStatut($obj->paye,$obj->fk_statut,5).'
'; } } else { dol_print_error($db); } print '
' . "\n"; print ''; /* * * Barre d'actions * */ print '
'; if ($user->rights->fournisseur->commande->creer) { $langs->load("orders"); print ''.$langs->trans("AddOrder").''; } if ($user->rights->fournisseur->facture->creer) { $langs->load("bills"); print ''.$langs->trans("AddBill").''; } 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 '
'; /* * Liste des contacts */ show_contacts($conf,$langs,$db,$societe); /* * Listes des actions a faire */ show_actions_todo($conf,$langs,$db,$societe); /* * Listes des actions effectuees */ show_actions_done($conf,$langs,$db,$societe); } else { dol_print_error($db); } $db->close(); llxFooter('$Date$ - $Revision$'); ?>