* Copyright (C) 2004 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$ * */ require("./pre.inc.php"); $user->getrights('banque'); $langs->load("compta"); /* * Sécurité accés client */ if ($user->societe_id > 0) { $action = ''; $socidp = $user->societe_id; } llxHeader("","Accueil Compta"); /* * */ if ($action == 'add_bookmark') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id; if (! $db->query($sql) ) { print $db->error(); } $sql = "INSERT INTO ".MAIN_DB_PREFIX."bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");"; if (! $db->query($sql) ) { print $db->error(); } } if ($action == 'del_bookmark') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bookmark WHERE rowid=$bid"; $result = $db->query($sql); } /* * * */ print_titre("Espace comptabilité"); print ''; print ''; print '
'; /* * */ print '
'; print ''; print ""; print ''; print "'; print "
Rechercher une facture
"; print 'Num. :  
"; if ($conf->facture->enabled) { /* * Factures brouillons */ $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s WHERE s.idp = f.fk_soc AND f.fk_statut = 0"; if ($socidp) { $sql .= " AND f.fk_soc = $socidp"; } if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num) { print ''; print ''; print ''; $var = True; while ($i < $num) { $obj = $db->fetch_object( $i); $var=!$var; print ''; print ''; $i++; } print "
Factures brouillons
'.img_file().' '; print ''.$obj->facnumber.''.$obj->nom.'

"; } } else { print $sql; } } if ($conf->compta->enabled) { /* * Charges a payer * */ if ($user->societe_id == 0) { $sql = "SELECT c.amount, cc.libelle"; $sql .= " FROM ".MAIN_DB_PREFIX."chargesociales as c, ".MAIN_DB_PREFIX."c_chargesociales as cc"; $sql .= " WHERE c.fk_type = cc.id AND c.paye=0"; if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { print ''; print ''; print ''; $i = 0; $var = True; while ($i < $num) { $obj = $db->fetch_object( $i); $var = !$var; print ""; print ''; print ''; print ''; $i++; } print '
Charges à payer
'.$obj->libelle.''.price($obj->amount).'

'; } } else { print $db->error(); } } } /* * Bookmark * */ $sql = "SELECT s.idp, s.nom,b.rowid as bid"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."bookmark as b"; $sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id; $sql .= " ORDER BY lower(s.nom) ASC"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num) { print ''; print "\n"; $var = True; while ($i < $num) { $obj = $db->fetch_object( $i); $var = !$var; print ""; print ''; print ''; print ''; $i++; } print '
Bookmark
'.$obj->nom.''; print 'Supprimer
'; } } /* * * */ print '
'; /* * Commandes à facturer */ if ($user->comm > 0 && $conf->commercial->enabled ) { $langs->load("orders"); $sql = "SELECT p.rowid, p.ref, s.nom, s.idp FROM ".MAIN_DB_PREFIX."commande as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut >= 1 AND p.facture = 0"; if ($socidp) { $sql .= " AND p.fk_soc = $socidp"; } if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { $i = 0; print ''; print ""; print ''; $var = True; while ($i < $num) { $var=!$var; $obj = $db->fetch_object($i); print ""; print ''; $i++; } print "
'.$langs->trans("OrdersToBill").'
rowid\">".img_file().""; print " rowid\">$obj->ref'.$obj->nom.'

"; } } } if ($conf->facture->enabled) { /* * Factures impayées * */ $sql = "SELECT f.facnumber, f.rowid, s.nom, s.idp, f.total_ttc, sum(pf.amount) as am"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture"; $sql .= " WHERE s.idp = f.fk_soc AND f.paye = 0 AND f.fk_statut = 1"; if ($socidp) { $sql .= " AND f.fk_soc = $socidp"; } $sql .= " GROUP BY f.facnumber"; if ( $db->query($sql) ) { $num = $db->num_rows(); $i = 0; if ($num) { print ''; print ''; $var = True; $total = $totalam = 0; while ($i < $num) { $obj = $db->fetch_object( $i); $var=!$var; print ''; print ''; print ''; print ''; $total += $obj->total_ttc; $totalam += $obj->am; $i++; } $var=!$var; print ''; print "
Factures clients impayéesMontant TTCReçu
'.img_file().''; print ' '.$obj->facnumber.''.$obj->nom.''.price($obj->total_ttc).''.price($obj->am).'
Reste à encaisser : '.price($total-$totalam).''.price($total).''.price($totalam).'

"; } $db->free(); } else { print $sql; } } $result = 0; if ( $result ) { print ''; print ''; print "\n"; $var = True; $i = 0; while ($i < $db->num_rows() ) { $obj = $db->fetch_object($i); $var=!$var; print ""; $i++; } $db->free(); print "
Actions à faire
".strftime("%d %b %Y",$obj->da)."$obj->libelle $obj->label

"; } else { print $db->error(); } if ($conf->facture->enabled) { /* * Factures a payer * */ if ($user->societe_id == 0) { $sql = "SELECT ff.rowid, ff.facnumber, ff.libelle, ff.total_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as ff"; $sql .= " WHERE ff.paye=0"; if ( $db->query($sql) ) { $num = $db->num_rows(); if ($num) { print ''; print ''; print "\n"; $i = 0; $var = True; $total = $totalam = 0; while ($i < $num) { $obj = $db->fetch_object( $i); $var = !$var; print ''; print ''; print ''; print ''; $total += $obj->total_ttc; $totalam += $obj->am; $i++; } $var=!$var; print ''; print '
Factures fournisseurs à payerMontant TTC
'.img_file().''; print ' '.$obj->facnumber.''.$obj->libelle.''.price($obj->total_ttc).'
Reste à payer : '.price($total-$totalam).''.price($total).'

'; } } else { print $db->error(); } } } print '
'; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>