From 2282eaed405043d68f74c21eff0ea3382238ae3c Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 3 Dec 2004 13:32:34 +0000 Subject: [PATCH] Nouveau fichier --- htdocs/telephonie/facture/check.php | 203 ++++++++++++++++++ htdocs/telephonie/facture/liste.php | 167 ++++++++++++++ htdocs/telephonie/facture/stats.php | 125 +++++++++++ .../sql/llx_telephonie_import_cdr.sql | 34 +++ 4 files changed, 529 insertions(+) create mode 100644 htdocs/telephonie/facture/check.php create mode 100644 htdocs/telephonie/facture/liste.php create mode 100644 htdocs/telephonie/facture/stats.php create mode 100644 htdocs/telephonie/sql/llx_telephonie_import_cdr.sql diff --git a/htdocs/telephonie/facture/check.php b/htdocs/telephonie/facture/check.php new file mode 100644 index 00000000000..84f67f3f9cd --- /dev/null +++ b/htdocs/telephonie/facture/check.php @@ -0,0 +1,203 @@ + + * + * 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"); + + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; +$sortfield = $_GET["sortfield"]; + +llxHeader(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +if ($sortorder == "") { + $sortorder="DESC"; +} +if ($sortfield == "") { + $sortfield="f.date"; +} + +if ($page == -1) { $page = 0 ; } + + + +/* + * Mode Liste + * + * + * + */ + +$sql = "SELECT distinct(client), sum(montant) "; +$sql .= " FROM stragex"; + +if ($_GET["search_ligne"]) +{ + $sql .= " WHERE f.ligne LIKE '%".$_GET["search_ligne"]."%'"; +} +$sql .= " GROUP BY client"; +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + print_barre_liste("Vérification avant facturation", $page, "check.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print ''; + print "\n"; + + $var=True; + $total = 0; + while ($i < $num) + { + $row = $db->fetch_row($i); + $var=!$var; + $total = $total + $row[1]; + print "\n"; + + print '\n"; + } + else + { + print "Erreur"; + } + + print '\n"; + + print '";; + + /* Remise LMN */ + print ''; + + print '\n"; + } + else + { + print "Erreur"; + } + + print '\n"; + } + else + { + print 'Client non facturé'; + } + + } + else + { + print dolibarr_print_phone($row[0]); + print ''; + print ''; + } + + print "\n"; + $i++; + } + + print ''; + print "\n"; + + print ''; + + print "
Ligne'; + print 'ClientClient facturéMontantRemise LMNRIB'; + print 'Email
"; + + $ligne = new LigneTel($db); + if ($ligne->fetch($row[0]) == 1) + { + + print ' '; + + print ''; + print img_file(); + + print ' '; + + print dolibarr_print_phone($row[0])."'; + + $client = new Societe($db); + + if ($client->fetch($ligne->client_id)) + { + print $client->nom."'; + + if ($ligne->facturable) + { + + $clientf = new Societe($db); + if ($clientf->fetch($ligne->client_facture_id)) + { + print ''; + print $clientf->nom."'.price($row[1])."'.$ligne->remise.' %'; + + if ($ligne->mode_paiement == 'pre') + { + if ($clientf->verif_rib()) + { + print 'ok'; + } + else + { + print "Alerte RIB"; + } + } + else + { + print 'Virement'; + } + print "-'; + + $cfs = $ligne->get_contact_facture(); + + if (sizeof($cfs)) + { + print $cfs[0]; + } + else + { + print "Alerte Emails"; + } + print " Ligne inconnue 
 Total HT'.price($total).' 
 Total TTC'.price($total*1.196).' 
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/facture/liste.php b/htdocs/telephonie/facture/liste.php new file mode 100644 index 00000000000..420faafb663 --- /dev/null +++ b/htdocs/telephonie/facture/liste.php @@ -0,0 +1,167 @@ + + * + * 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"); + + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; +$sortfield = $_GET["sortfield"]; + +llxHeader(); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +if ($sortorder == "") { + $sortorder="DESC"; +} +if ($sortfield == "") { + $sortfield="f.date"; +} + +/* + * Recherche + * + * + */ + +if ($page == -1) { $page = 0 ; } + +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +/* + * Mode Liste + * + * + * + */ + +$sql = "SELECT f.rowid, f.date, f.ligne, f.fourn_montant, f.cout_vente, f.cout_vente_remise, f.gain, f.fk_facture"; +$sql .= " ,s.nom, s.idp"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as f"; +$sql .= " , ".MAIN_DB_PREFIX."societe as s"; +$sql .= " , ".MAIN_DB_PREFIX."telephonie_societe_ligne as l"; + +$sql .= " WHERE s.idp = l.fk_soc_facture AND l.rowid = f.fk_ligne"; + +if ($_GET["search_ligne"]) +{ + $sql .= " AND f.ligne LIKE '%".$_GET["search_ligne"]."%'"; +} + +if ($_GET["search_client"]) +{ + $sql .= " AND s.nom LIKE '%".$_GET["search_client"]."%'"; +} + +$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset); + +$result = $db->query($sql); +if ($result) +{ + $num = $db->num_rows(); + $i = 0; + + print_barre_liste("Factures", $page, "liste.php", "", $sortfield, $sortorder, '', $num); + + print ''; + print ''; + print_liste_field_titre("Client","liste.php","s.nom"); + + print_liste_field_titre("Ligne","liste.php","l.ligne"); + print ''; + print ''; + print "\n"; + + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + + $var=True; + + $ligne = new LigneTel($db); + + while ($i < min($num,$conf->liste_limit)) + { + $obj = $db->fetch_object($i); + $var=!$var; + + print ""; + + print '\n"; + print '\n"; + print '\n"; + print '\n"; + print '\n"; + + print '\n"; + print '\n"; + print "\n"; + $i++; + } + print "
DateMontant HTCoût fournisseur HT'; + print 'GainFacture
    
'; + print img_file(); + print ' '; + + print ''.$obj->nom."'.dolibarr_print_phone($obj->ligne)."'.$obj->date."'.sprintf("%01.4f",$obj->cout_vente_remise)."'.sprintf("%01.4f",$obj->fourn_montant)."'; + if ($obj->gain < 0 && $obj->cout_vente_remise) + { + print ''; + print sprintf("%01.4f",$obj->gain); + print ""; + } + else + { + print sprintf("%01.4f",$obj->gain); + } + print "'.$obj->fk_facture."
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/facture/stats.php b/htdocs/telephonie/facture/stats.php new file mode 100644 index 00000000000..758bf6852a3 --- /dev/null +++ b/htdocs/telephonie/facture/stats.php @@ -0,0 +1,125 @@ + + * + * 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"); + +$page = $_GET["page"]; +$sortorder = $_GET["sortorder"]; + +if (!$user->rights->telephonie->lire) + accessforbidden(); + +llxHeader('','Telephonie'); + +/* + * Sécurité accés client + */ +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} + +/* + * Mode Liste + * + * + * + */ + +print ''; + +print ''; + + +print ''; + +print '
'; + + +$sql = "SELECT date_format(f.datef,'%Y%m'), sum(f.total_ttc)"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture as tf"; +$sql .= " , ".MAIN_DB_PREFIX."facture as f"; + +$sql .= " WHERE tf.fk_facture = f.rowid"; +$sql .= " GROUP BY date_format(f.datef,'%Y%m')"; + +if ($db->query($sql)) +{ + $num = $db->num_rows(); + $i = 0; + $ligne = new LigneTel($db); + + print ''; + print ''; + print "\n"; + $var=True; + + while ($i < $num) + { + $row = $db->fetch_row($i); + $var=!$var; + + print ""; + print "\n"; + print "\n"; + print "\n"; + $i++; + } + print "
FacturesNb
".$row[0]."".$row[1]."
"; + $db->free(); +} +else +{ + print $db->error() . ' ' . $sql; +} + + + + +print '
'; + + + +print '
'; +/* + * + * + */ + + + + + +/* + * + * + */ + + +print '
'; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/telephonie/sql/llx_telephonie_import_cdr.sql b/htdocs/telephonie/sql/llx_telephonie_import_cdr.sql new file mode 100644 index 00000000000..6c32b7017d1 --- /dev/null +++ b/htdocs/telephonie/sql/llx_telephonie_import_cdr.sql @@ -0,0 +1,34 @@ +-- ======================================================================== +-- Copyright (C) 2004 Rodolphe Quiedeville +-- +-- 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$ +-- +-- ======================================================================== + +create table llx_telephonie_import_cdr ( + ligne int, + client varchar(255), + date varchar(255), + heure varchar(255), + num varchar(255), + dest varchar(255), + dureetext varchar(255), + tarif varchar(255), + montant real, + duree integer +)type=innodb;