* Copyright (C) 2003 Éric Seigne * Copyright (C) 2004-2006 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'); 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'); // Sécurité accés client $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id > 0) { $action = ''; $socid = $user->societe_id; } if (! $socid) accessforbidden(); /* * Actions */ // Protection restriction commercial if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0) { $sql = "SELECT sc.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_soc = s.idp AND sc.fk_user = ".$user->id." AND s.fournisseur = 1"; if ( $db->query($sql) ) { if ( $db->num_rows() == 0) accessforbidden(); } } /* * 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 */ $head = societe_prepare_head($societe); dolibarr_fiche_head($head, 'supplier', $societe->nom); print ''; print ''; print '
'; print ''; print ''; print ''; if ($societe->fournisseur) { print ''; } print ''; print ''; print ''; print ''; print ''; print '"; // Assujeti à 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").''.$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->trans('VATIsUsed').''; print yn($societe->tva_assuj); print '
'; print '
'; $var=true; $MAXLIST=4; // Lien recap print ''; print ''; print ''; print ''; print '
'; print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; print '
'; /* * Liste des commandes associées */ $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.rowid"; $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?"":$MAXLIST)).''.$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 ''.$orderstatic->LibStatut($obj->fk_statut,5).'

"; } } else { dolibarr_print_error($db); } /* * Liste des factures associées */ $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.' '.dolibarr_trunc($obj->libelle,14).''.dolibarr_print_date($obj->df).''.price($obj->amount).''.$facturestatic->LibStatut($obj->paye,$obj->fk_statut,5).'

'; } } else { dolibarr_print_error($db); } /* * 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 '
'; } 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 ''.$langs->trans("AddAction").''; if ($user->rights->societe->contact->creer) { print "".$langs->trans("AddContact").""; } print '
'; /* * * Liste des contacts * */ $langs->load("companies"); print '
'; print_titre($langs->trans("ContactsForCompany")); 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"; $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 ''; print "\n"; $i++; } print '
'.$langs->trans("Name").''.$langs->trans("Poste").''.$langs->trans("Tel").'".$langs->trans("Fax")."".$langs->trans("EMail")."  
'; 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()."'; print img_object($langs->trans("Rendez-Vous"),"action"); print '
'; print '
'; /* * Listes des actions a faire * */ print_titre($langs->trans("ActionsOnCompany")); print ''; print ''; $sql = "SELECT a.id, a.label, ".$db->pdate("a.datep")." as dp, c.code as acode, c.libelle, u.login, 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 AND a.percent < 100"; $sql .= " ORDER BY a.datep DESC, a.id DESC"; $result=$db->query($sql); if ($result) { $i = 0 ; $num = $db->num_rows($result); $var=true; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($result); print ""; if ($oldyear == strftime("%Y",$obj->dp) ) { print ''; } else { print '\n"; $oldyear = strftime("%Y",$obj->dp); } if ($oldmonth == strftime("%Y%b",$obj->dp) ) { print ''; } else { print '\n"; $oldmonth = strftime("%Y%b",$obj->dp); } print '\n"; print ''; // Picto warning print ''; // Status/Percent print ''; if ($obj->propalrowid) { print ''; } else { print ''; } print ''; // Contact pour cette action if ($obj->fk_contact) { $contact = new Contact($db); $contact->fetch($obj->fk_contact); print ''; } else { print ''; } // Auteur print ''; print "\n"; $i++; } $db->free($result); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsToDoShort").' 
|'.strftime("%Y",$obj->dp)."|' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); else print ' '; print ' '.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''.img_object($langs->trans("ShowAction"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''.$obj->label.''.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.' '.img_object($langs->trans("ShowUser"),"user").' '.$obj->login.'

"; /* * Listes des actions effectuées */ print ''; print ''; $sql = "SELECT a.id, a.label, ".$db->pdate("a.datea")." as da,"; $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; $sql.= " c.code as acode, c.libelle,"; $sql.= " u.login, 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 AND a.percent = 100"; $sql.= " ORDER BY a.datea DESC, a.id DESC"; $result=$db->query($sql); if ($result) { $i = 0 ; $num = $db->num_rows($result); $var=true; while ($i < $num) { $var = !$var; $obj = $db->fetch_object($result); 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"; // Picto print ''; // Espace print ''; // Action print ''; // Objet li print ''; // Libell print ""; // Contact pour cette action if ($obj->fk_contact) { $contact = new Contact($db); $contact->fetch($obj->fk_contact); print ''; } else { print ''; } // Auteur print ''; print "\n"; $i++; } $db->free(); } else { dolibarr_print_error($db); } print "
'.$langs->trans("ActionsDoneShort").'
|'.strftime("%Y",$obj->da)."|'.strftime("%b",$obj->da)."'.strftime("%d",$obj->da)."'.strftime("%H:%M",$obj->da)."  '; print ''.img_object($langs->trans("ShowTask"),"task"); $transcode=$langs->trans("Action".$obj->acode); $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); print $libelle; print ''; print ''; if ($obj->propalrowid) { print ''.img_object($langs->trans("ShowPropal"),"propal"); print $langs->trans("Propal"); print ''; } if ($obj->fk_facture) { print ''.img_object($langs->trans("ShowBill"),"bill"); print $langs->trans("Invoice"); print ''; } else print ' '; print '$obj->label'.img_object($langs->trans("ShowContact"),"contact").' '.$contact->fullname.' '.img_object($langs->trans("ShowUser"),'user').' '.$obj->login.'
"; } else { dolibarr_print_error($db); } $db->close(); llxFooter('$Date$ - $Revision$'); ?>