From 7d066004793437ff9c624628331bd52090f52139 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 28 Feb 2005 15:19:57 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/compta/recap-client.php | 259 +++++++++++++++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 htdocs/compta/recap-client.php diff --git a/htdocs/compta/recap-client.php b/htdocs/compta/recap-client.php new file mode 100644 index 00000000000..959848f3831 --- /dev/null +++ b/htdocs/compta/recap-client.php @@ -0,0 +1,259 @@ + + * 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("../facture.class.php"); + +$langs->load("companies"); +if ($conf->facture->enabled) $langs->load("bills"); + +/* + * Sécurité accés client + */ +$socid = $_GET["socid"]; +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + +$user->getrights('facture'); + +llxHeader(); + +/* + * + * 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"); + $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"); + $hselected=$h; + $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++; + } + + 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 '
'; + + 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("Phone").''.$societe->tel.' Fax'.$societe->fax.' 
'.$langs->trans("ProfIdSiren").''.$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 "
\n"; + + print ''; + + + 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"; + $sql .= " , 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 ''; + print ''; + print ''; + print ''; + } + + while ($i < $num) + { + $objp = $db->fetch_object(); + $facs[$i] = $objp->facid; + $i++; + } + $db->free(); + + + $solde = 0; + + for ($i = 0 ; $i < $num ; $i++) + { + $var=!$var; + + $fac = new Facture($db); + $fac->fetch($facs[$i]); + + print ""; + + print "\n"; + print "\n"; + + print '\n"; + $solde = $solde + $fac->total_ttc; + + print ''; + print '\n"; + print "\n"; + + + $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, p.amount, p.statut"; + + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; + $sql .= ", ".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql .= " WHERE pf.fk_paiement = p.rowid"; + $sql .= " AND pf.fk_facture = ".$fac->id; + + $result = $db->query($sql); + + if ($result) + { + $nump = $db->num_rows(); + $j = 0; + + while ($j < $nump) + { + $objp = $db->fetch_object(); + //$var=!$var; + print ""; + print '\n"; + print ''; + print "\n"; + print ''; + $solde = $solde - $objp->amount; + print '\n"; + print ''; + + $j++; + } + } + } + } + else + { + dolibarr_print_error($db); + } + print "
 '.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Solde").'
".dolibarr_print_date($fac->date)."facid\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.number_format($fac->total_ttc, 2, ',', ' ')." '.number_format($solde, 2, ',', ' ')."
'.dolibarr_print_date($objp->dp)."'.img_file().' Paiement '.$objp->rowid.' '.price($objp->amount).''.number_format($solde, 2, ',', ' ')."
"; + } +} +else +{ + print "Erreur"; +} +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?>