[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 * $Id: retour-traitement.php,v 1.6 2005/11/03 13:16:26 rodolphe Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/telephonie/script/retour-traitement.php,v $ 20 * 21 * Script de traitement des retour de commande 22 */ 23 24 require ("../../master.inc.php"); 25 26 require_once (DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php"); 27 require_once (DOL_DOCUMENT_ROOT."/telephonie/facturetel.class.php"); 28 require_once (DOL_DOCUMENT_ROOT."/telephonie/telephonie-tarif.class.php"); 29 require_once (DOL_DOCUMENT_ROOT."/telephonie/communication.class.php"); 30 require_once (DOL_DOCUMENT_ROOT."/societe.class.php"); 31 require_once (DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php"); 32 33 if ($verbose) dolibarr_syslog("retour-traitement"); 34 35 $user = new User($db, 1); 36 37 $error = 0; 38 39 $sql = "SELECT cli,mode,situation"; 40 $sql .= " , ".$db->pdate(date_mise_service); 41 $sql .= " , ".$db->pdate(date_resiliation).",motif_resiliation,commentaire,rowid "; 42 $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commande_retour "; 43 $sql .= " WHERE traite = 0"; 44 45 if ($db->query($sql)) 46 { 47 $i = 0; 48 $num = $db->num_rows(); 49 50 while ($i < $num) 51 { 52 $row[$i] = $db->fetch_row(); 53 54 $i++; 55 } 56 } 57 58 $n = sizeof($row); 59 60 if ($verbose) dolibarr_syslog($n . " lignes à traiter"); 61 62 for ($i = 0 ; $i < $n ; $i++) 63 { 64 $numero = $row[$i][0]; 65 $mode = $row[$i][1]; 66 $situation = $row[$i][2]; 67 $date_mise_service = $row[$i][3]; 68 $date_resiliation = $row[$i][4]; 69 $motif_resiliation = $row[$i][5]; 70 $commentaire = $row[$i][6]; 71 $rowid = $row[$i][7]; 72 73 $ligne = new LigneTel($db); 74 75 if ($ligne->fetch($numero) == 1) 76 { 77 /* 78 * Activation de la ligne 79 */ 80 81 if ($mode == 'PRESELECTION' && 82 $situation == 'CONFIRME' && 83 $commentaire == 'CONFIRME PAR FT') 84 { 85 86 if ($ligne->statut == 2) 87 { 88 $statut = 3; 89 $datea = $db->idate($date_mise_service); 90 91 if ($db->query("BEGIN")) 92 { 93 $error = 0; 94 95 if ($ligne->set_statut($user, $statut, $datea,'',1) <> 0) 96 { 97 $error++; 98 } 99 100 if (!$error) 101 { 102 /* Tag la ligne comme traitée */ 103 104 $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_commande_retour "; 105 $sql .= " SET traite = 1, date_traitement=now() "; 106 $sql .= " WHERE rowid =".$rowid; 107 108 if (! $db->query($sql)) 109 { 110 dolibarr_syslog("Erreur de traitement de ligne $numero"); 111 $error++; 112 } 113 } 114 115 if ($error == 0) 116 { 117 $db->query("COMMIT"); 118 dolibarr_syslog("COMMIT"); 119 } 120 else 121 { 122 $db->query("ROLLBACK"); 123 dolibarr_syslog("ROLLBACK"); 124 } 125 126 } 127 } 128 else 129 { 130 dolibarr_syslog("Ligne $numero déjà active"); 131 } 132 } 133 /* 134 * Ligne Résiliée 135 */ 136 if ($mode == 'PRESELECTION' && 137 $situation == 'CONFIRME' && 138 $commentaire == 'CPS DESACTIVE PAR FT' && 139 $date_resiliation > 0) 140 { 141 142 if ($ligne->statut == 3) 143 { 144 $statut = 6; 145 $datea = $db->idate($date_resiliation); 146 147 if ($db->query("BEGIN")) 148 { 149 $error = 0; 150 151 if ($ligne->set_statut($user, $statut, $datea,'',1) <> 0) 152 { 153 $error++; 154 } 155 156 if (!$error) 157 { 158 /* Tag la ligne comme traitée */ 159 160 $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_commande_retour "; 161 $sql .= " SET traite = 1, date_traitement=now() "; 162 $sql .= " WHERE rowid =".$rowid; 163 164 if (! $db->query($sql)) 165 { 166 dolibarr_syslog("Erreur de traitement de ligne $numero"); 167 $error++; 168 } 169 } 170 171 if ($error == 0) 172 { 173 $db->query("COMMIT"); 174 dolibarr_syslog("COMMIT"); 175 } 176 else 177 { 178 $db->query("ROLLBACK"); 179 dolibarr_syslog("ROLLBACK"); 180 } 181 } 182 } 183 else 184 { 185 dolibarr_syslog("Ligne $numero déjà active"); 186 } 187 } 188 189 /* 190 * 191 */ 192 /* 193 * Prefixe non géré 194 */ 195 196 if ($mode == 'PREFIXE' && 197 $situation == 'CONFIRME') 198 { 199 if ($db->query("BEGIN")) 200 { 201 $error = 0; 202 203 if (!$error) 204 { 205 /* Tag la ligne comme traitée */ 206 207 $sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_commande_retour "; 208 $sql .= " SET traite = 1, date_traitement=now() "; 209 $sql .= " WHERE rowid =".$rowid; 210 211 if (! $db->query($sql)) 212 { 213 dolibarr_syslog("Erreur de traitement de ligne $numero"); 214 $error++; 215 } 216 } 217 218 if ($error == 0) 219 { 220 $db->query("COMMIT"); 221 dolibarr_syslog("COMMIT"); 222 } 223 else 224 { 225 $db->query("ROLLBACK"); 226 dolibarr_syslog("ROLLBACK"); 227 } 228 229 } 230 } 231 /* 232 * Fin mode PREFIXE 233 * 234 */ 235 } 236 else 237 { 238 print "Ligne inconnue : $numero\n"; 239 } 240 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |