From 909d97cd9acbaaba56c0103a8a370683e905f65a Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 6 Dec 2005 15:30:22 +0000 Subject: [PATCH] Nouveau fichier --- .../tools/verif-contrat-contact-services.php | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 htdocs/telephonie/script/tools/verif-contrat-contact-services.php diff --git a/htdocs/telephonie/script/tools/verif-contrat-contact-services.php b/htdocs/telephonie/script/tools/verif-contrat-contact-services.php new file mode 100644 index 00000000000..87b96e0512a --- /dev/null +++ b/htdocs/telephonie/script/tools/verif-contrat-contact-services.php @@ -0,0 +1,78 @@ + + * + * 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$ + * + * Vérifie que les contrats qui n'ont pas de contact facture correct + * ont au moins un services d'envoi courrier. + * + */ +require ("../../../master.inc.php"); +/* + * + */ + +$sql = "SELECT rowid"; +$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat"; + +$resql = $db->query($sql) ; + +if ( $resql ) +{ + while ($row = $db->fetch_row($resql)) + { + $sqlc = "SELECT count(*)"; + $sqlc .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_contact_facture"; + $sqlc .= " WHERE fk_contrat =".$row[0]; + + $resqlc = $db->query($sqlc) ; + if ( $resqlc ) + { + $rowc = $db->fetch_row($resqlc); + if ($rowc[0] == 0) + { + $sqls = "SELECT count(*)"; + $sqls .= " FROM ".MAIN_DB_PREFIX."telephonie_contrat_service"; + $sqls .= " WHERE fk_contrat =".$row[0]; + $sqls .= " AND fk_service in (1,2);"; + + $resqls = $db->query($sqls) ; + if ( $resqls ) + { + $rows = $db->fetch_row($resqls); + if ($rows[0] == 0) + { + print "Contrat ".$row[0]." sans contact ni envoi courrier\n"; + } + } + } + } + else + { + print $db->error(); + } + + } +} +else +{ + print $db->error(); +} + +$db->close(); +?>