* Copyright (C) 2003 Éric Seigne * 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/fourn/fiche.php \ingroup fournisseur, facture \brief Page de fiche fournisseur \version $Revision$ */ require('./pre.inc.php'); $langs->load('suppliers'); $langs->load('products'); $langs->load('bills'); $langs->load('orders'); $langs->load('companies'); $socid = $_GET['socid']; /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } /* * Mode fiche */ $societe = new Fournisseur($db); if ( $societe->fetch($socid) ) { $addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; $addons[0][1] = $societe->nom; llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons); /* * Affichage onglets */ $h = 0; $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$socid; $head[$h][1] = $langs->trans('Company'); $h++; if ($societe->client==1) { $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid; $head[$h][1] = $langs->trans('Customer'); $h++; } if ($societe->client==2) { $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$socid; $head[$h][1] = $langs->trans('Prospect'); $h++; } if ($societe->fournisseur) { $hselected=$h; $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; $head[$h][1] = $langs->trans('Supplier'); $h++; } if ($conf->compta->enabled) { $langs->load('compta'); $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid; $head[$h][1] = $langs->trans('Accountancy'); $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++; $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$societe->id; $head[$h][1] = $langs->trans("Info"); $h++; dolibarr_fiche_head($head, $hselected, $societe->nom); /* * * */ print ''; print ''; print '
'; print ''; print ''; print ''; /* if ($societe->client) { print ''; } */ if ($societe->fournisseur) { print ''; print ''; print ''; print ''; } print ''; print ''; print ''; print ''; print ''; print '"; print ""; print ''; print ''; // Statut juridique print ''; // Type + Staff $arr = $societe->typent_array($societe->typent_id); $societe->typent= $arr[$societe->typent_id]; print ''; print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; print $langs->trans('CustomerCode').''; print $societe->code_client; if ($societe->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode"); print '
'; print $langs->trans('SupplierCode').''; print $societe->code_fournisseur; if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); print '
'.$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").''.$societe->pays.'
'.$langs->trans("Phone").''.dolibarr_print_phone($societe->tel).' '.$langs->trans("Fax").''.dolibarr_print_phone($societe->fax).' 
'.$langs->trans("Web")."url\">$societe->url 
".$langs->transcountry("ProfId1",$societe->pays_code)."siren."\">".$societe->siren." '.$langs->transcountry('ProfId2',$societe->pays_code).''.$societe->siret.'
'.$langs->transcountry('ProfId3',$societe->pays_code).''.$societe->ape.' 
'.$langs->trans('JuridicalStatus').''.$societe->forme_juridique.'
'.$langs->trans("Type").''.$societe->typent.''.$langs->trans("Staff").''.$societe->effectif.'
'; /* * */ print '
'; $var=true; /* * Liste des produits */ if ($conf->produit->enabled || $conf->service->enabled) { $langs->load("products"); print ''; print ''; print '
'.$langs->trans("ProductsAndServices").''; print ''.$langs->trans("All").' ('.$societe->NbProduct().')'; print '

'; } /* * Liste des commandes associées */ $max=4; $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.rowid"; $sql.= " ".$db->plimit($max); $resql=$db->query($sql); if ($resql) { $i = 0 ; $num = $db->num_rows($resql); if ($num > 0) { print ''; print ''; print ''; } while ($i < $num && $i <= $max) { $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",min($num,$max)).''.$langs->trans("AllOrders").' ('.$num.')
'; print '
'.img_object($langs->trans("ShowOrder"),"order")." ".$obj->ref.''; if ($obj->dc) { print dolibarr_print_date($obj->dc); } else { print "-"; } print '

"; } } else { dolibarr_print_error($db); } /* * Liste des factures associées */ $langs->load('bills'); $max=5; $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 ''; } $facturestatic = new FactureFournisseur($db); while ($i < min($num,$max)) { $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',min($num,$max)).''.$langs->trans('AllBills').' ('.$num.')
'; print '
'; print ''; print img_object($langs->trans('ShowBill'),'bill').' '.$obj->facnumber.' '.dolibarr_trunc($obj->libelle,14).''.dolibarr_print_date($obj->df).''.price($obj->amount).''.$facturestatic->LibStatutShort($obj->paye,$obj->fk_statut).'

'; } } else { dolibarr_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").''; } print '
'; /* * * Liste des contacts * */ $langs->load("companies"); print '
'; print ''; print ''; print ""; if ($user->rights->societe->contact->creer) { print ""; } print ""; $sql = "SELECT p.idp, 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=true; while ($i < $num) { $obj = $db->fetch_object($result); $var = !$var; print ""; print '"; print ""; print ''; print ''; print ''; if ($user->rights->societe->contact->creer) { print ""; } print "\n"; $i++; } print "
'.$langs->trans("Contact").'Poste'.$langs->trans("Tel").'".$langs->trans("Fax")."".$langs->trans("EMail")."".$langs->trans("AddContact")."
'; print ''; print img_object($langs->trans("ShowContact"),"contact"); print ' '.$obj->firstname.' '. $obj->name.' '; if ($obj->note) { print "
".nl2br($obj->note); } print "
$obj->poste '.$obj->phone.' '.$obj->fax.' '.$obj->email.' idp\">".img_edit()."
"; } else { dolibarr_print_error($db); } $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>