From b0c0933eb5fd17ed40fda024e3143753e2299c88 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Mon, 20 Jun 2005 12:35:05 +0000 Subject: [PATCH] Nouveau fichier --- .../telephonie/script/lignes-sans-conso.php | 144 ++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 htdocs/telephonie/script/lignes-sans-conso.php diff --git a/htdocs/telephonie/script/lignes-sans-conso.php b/htdocs/telephonie/script/lignes-sans-conso.php new file mode 100644 index 00000000000..fa4a581bde6 --- /dev/null +++ b/htdocs/telephonie/script/lignes-sans-conso.php @@ -0,0 +1,144 @@ + + * + * 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$ + * + * + * Script de facturation + * Emets les factures compta en partant des factures téléphonique + * + */ + +/** + \file htdocs/telephonie/script/facturation-emission.php + \ingroup telephonie + \brief Emission des factures + \version $Revision$ +*/ + + +require ("../../master.inc.php"); + +$opt = getopt("l:c:"); + +$limit = $opt['l']; +$optcontrat = $opt['c']; +/* +if (strlen($limit) == 0 && strlen($optcontrat) == 0) +{ + print "Usage :\n php facturation-emission.php -l \n"; + exit; +} +*/ +require_once (DOL_DOCUMENT_ROOT."/facture.class.php"); +require_once (DOL_DOCUMENT_ROOT."/societe.class.php"); +require_once (DOL_DOCUMENT_ROOT."/paiement.class.php"); +require_once (DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php"); +require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); +require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php"); +require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php"); + + +$error = 0; + +$datetime = time(); +$datetimeprev = $datetime; // Date du prélèvement + +$date = strftime("%d%h%Y%Hh%Mm%S",$datetime); + +$user = new User($db, 1); + +$month = strftime("%m", $datetime); +$year = strftime("%Y", $datetime); + +if ($month == 1) +{ + $month = "12"; + $year = $year - 1; +} +else +{ + $month = substr("00".($month - 1), -2) ; +} + +/* + * Lecture du batch + * + */ +$lignes = 0; +$sql = "SELECT ligne FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne"; +$sql .= " WHERE statut = 3"; + +$resql = $db->query($sql); + +if ( $resql ) +{ + $num = $db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $row = $db->fetch_row($resql); + + $sqla = "SELECT count(*)"; + $sqla .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; + $sqla .= " WHERE ligne = '".$row[0]."'"; + $sqla .= " AND date_format(date,'%Y%m') ='".$year.$month."'"; + + $resqla = $db->query($sqla); + + if ( $resqla ) + { + + $rowa = $db->fetch_row($resqla); + + if ($rowa[0] == 0) + { + + + $sqlb = "SELECT max(date)"; + $sqlb .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; + $sqlb .= " WHERE ligne = '".$row[0]."'"; + + $resqlb = $db->query($sqlb); + + if ( $resqlb ) + { + $rowb = $db->fetch_row($resqlb); + } + + + print $row[0]." ".$rowb[0]."\n"; + $lignes++; + } + } + + $i++; + } + + $db->free($resql); +} +else +{ + $error = 1; + dolibarr_syslog("Erreur ".$error); +} + +$db->close(); + +?>