Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 241 |
|
0.00% |
0 / 2 |
CRAP | n/a |
0 / 0 |
|
| mergeCtaTMovs | |
0.00% |
0 / 151 |
|
0.00% |
0 / 1 |
4160 | |||
| mergeCtaTMovs4Async | |
0.00% |
0 / 90 |
|
0.00% |
0 / 1 |
2970 | |||
| 1 | <?php |
| 2 | function mergeCtaTMovs($andWhere='',$orderby='',&$sumasGridServer=array()) |
| 3 | { |
| 4 | @ini_set('memory_limit', '1024M'); |
| 5 | global $gIAParametros; |
| 6 | global $gSqlClass; |
| 7 | |
| 8 | |
| 9 | $vx_marca_de_banco = false; |
| 10 | $vx_marca_de_banco = true; |
| 11 | if($vx_marca_de_banco) { |
| 12 | //Marca de banco |
| 13 | $start = microtime(true); |
| 14 | $u = $_SESSION['usuario']; |
| 15 | $time_elapsed_secs = microtime(true) - $start; |
| 16 | $bleh = "\r\n\r\nini: $time_elapsed_secs"; |
| 17 | //Marca de banco |
| 18 | } |
| 19 | |
| 20 | $orderbysplit = explode("/**#LIMIT#**/", $orderby); |
| 21 | $limit = $limitsql = array_key_exists(1, $orderbysplit) ? $orderbysplit[1] : ''; |
| 22 | |
| 23 | if(strlen($limit)) |
| 24 | { |
| 25 | $limit = vx_trim(str_replace("LIMIT","",$limit)); |
| 26 | $limitsplit = explode(",",$limit); |
| 27 | } |
| 28 | |
| 29 | if(array_key_exists('iaGridInicial', $sumasGridServer) && $sumasGridServer['iaGridInicial'] == 'NO') |
| 30 | { |
| 31 | $orderby = $orderbysplit[0]; |
| 32 | } |
| 33 | |
| 34 | if(!empty($andWhere)) |
| 35 | { |
| 36 | if(strpos($andWhere, " AND (") === 0) |
| 37 | $andWhere = substr($andWhere,5); |
| 38 | |
| 39 | $andWhere = str_replace("cuentat_mov.",'',$andWhere); |
| 40 | $andWhere = str_replace("`cuentat_mov`.",'',$andWhere); |
| 41 | |
| 42 | /** Aqui reemplazo los campos ambiguos **/ |
| 43 | $cyTN_arr = camposyTablasNormalizadas('cuentat_mov'); |
| 44 | $patterns = array_keys($cyTN_arr[0]['cuentat_mov']); |
| 45 | $replacements = array_values($cyTN_arr[0]['cuentat_mov']); |
| 46 | |
| 47 | foreach($patterns as $k=>$v) |
| 48 | $patterns[$k] = "/\\b$v\\b/"; |
| 49 | |
| 50 | $andWhere = preg_replace($patterns,$replacements,$andWhere); |
| 51 | $orderby = preg_replace($patterns,$replacements,$orderby); |
| 52 | |
| 53 | /** ** ** **/ |
| 54 | $andWhere = " $andWhere AND "; |
| 55 | |
| 56 | //Fix |
| 57 | $andWhere = str_replace("`",'',$andWhere); |
| 58 | |
| 59 | //ia_query("INSERT INTO dime (script,dime) VALUES ('sql',".strit($tmp."-".$andWhere).")"); |
| 60 | } |
| 61 | |
| 62 | //Hacemos los inserts. |
| 63 | $insertInto = "INSERT /** INSERTA CUENTAT_MOV **/ INTO cuentat_mov_tmp(cuentaT_mov_id,cuentaT_id,fecha,moneda_id,alta_por,cuentaT_tipo_mov_id,app_origen,monto,egreso,tipo_cambio,saldo_corriente_mxp,tienda_id,remarks,json_file_attachments,alta_db,banco_cuenta_id,referencia,quantity_total,link_por,link_el,fecha_deposito,idex100,idetotal,tipo_cash_nota,cash_nota_num,cliente,factura,cash_num_cobro_iva,ivacobradox100,ivacobradototal,factura_numero,activo,saldo_corriente_usd,deposit_total,afecta_cuentat,origen_mov_id,contra_mov_id,banco_cuenta_mov_link_id,tipo,marked,solo_rony)"; |
| 64 | |
| 65 | $insertador = new \iac\inc\sql\IacSQLMultipleInsert($gSqlClass, $insertInto, '', 100000, true); |
| 66 | |
| 67 | if($vx_marca_de_banco) { |
| 68 | ////Marca de banco |
| 69 | $time_elapsed_secs = microtime(true) - $start; |
| 70 | $bleh .= "\r\n\r\nIacSQLMultipleInsert: $time_elapsed_secs"; |
| 71 | } |
| 72 | |
| 73 | $index = " /*#*#*/ FORCE INDEX (consul_movs) /*#*#*/ "; |
| 74 | //$index_1 = " /*#*#*/ USE INDEX (consul_movs_1) /*#*#*/ "; |
| 75 | |
| 76 | $sql = "SELECT |
| 77 | c.cuentaT_mov_id, |
| 78 | c.cuentaT_id, |
| 79 | c.fecha, |
| 80 | c.moneda_id, |
| 81 | c.alta_por, |
| 82 | c.cuentaT_tipo_mov_id, |
| 83 | c.app_origen, |
| 84 | c.monto, |
| 85 | c.egreso, |
| 86 | c.tipo_cambio, |
| 87 | c.saldo_corriente_mxp, |
| 88 | c.tienda_id, |
| 89 | c.remarks, |
| 90 | c.json_file_attachments, |
| 91 | c.alta_db, |
| 92 | c.banco_cuenta_id, |
| 93 | c.referencia, |
| 94 | c.quantity_total, |
| 95 | bcl.link_por, |
| 96 | bcl.link_el, |
| 97 | c.fecha_deposito, |
| 98 | bcm.idex100, |
| 99 | bcm.idetotal, |
| 100 | bcm.tipo_cash_nota, |
| 101 | bcm.cash_nota_num, |
| 102 | bcm.cliente, |
| 103 | bcm.factura, |
| 104 | bcm.cash_num_cobro_iva, |
| 105 | bcm.ivacobradox100, |
| 106 | bcm.ivacobradototal, |
| 107 | bcm.factura_numero, |
| 108 | c.activo, |
| 109 | c.saldo_corriente_usd, |
| 110 | c.deposit_total, |
| 111 | IF(c.monto=0 AND c.egreso=0,'No','Si') AS afecta_cuentat, |
| 112 | c.origen_mov_id, |
| 113 | c.contra_mov_id, |
| 114 | c.banco_cuenta_mov_link_id, |
| 115 | c.tipo, |
| 116 | '' as marked, |
| 117 | c.solo_rony |
| 118 | FROM cuentat_mov AS c $index |
| 119 | LEFT OUTER JOIN banco_cuenta_mov_link AS bcl ON c.banco_cuenta_mov_link_id = bcl.banco_cuenta_mov_link_id |
| 120 | LEFT JOIN banco_cuenta_mov AS bcm ON bcl.banco_cuenta_mov_id = bcm.banco_cuenta_mov_id"; |
| 121 | |
| 122 | $tomorrow = date("Y-m-d", strtotime('tomorrow'))." 23:59:59"; |
| 123 | $lastyear = date("Y")."-01-01 00:00:00"; |
| 124 | |
| 125 | $andWhere = empty($andWhere) ? "c.fecha BETWEEN '$lastyear' and '$tomorrow' AND " : $andWhere; |
| 126 | //$andWhere = " WHERE $andWhere c.cuentaT_id IN (".cuentasTPuede('','ver_saldo_y_movimientos').")"; |
| 127 | //VCA 15-09-2021 nuevo permiso para ver saldo y movimientos. |
| 128 | $andWhere = " WHERE $andWhere c.cuentaT_id IN (".cuentasTPuede('','puede_ver_cuentat').")"; |
| 129 | |
| 130 | $sql1 = "SELECT d.fecha |
| 131 | FROM cuentat_mov as d |
| 132 | WHERE d.cuentaT_mov_id IN |
| 133 | (SELECT c.contra_mov_id FROM cuentat_mov AS c |
| 134 | $andWhere ORDER BY c.alta_db ASC) ORDER BY d.alta_db ASC LIMIT 1"; |
| 135 | |
| 136 | $lastyear = ia_singleread($sql1); |
| 137 | $lastyear = empty($lastyear) ? date("Y-m-d")." 00:00:00" : date("Y-m-d", strtotime($lastyear))." 00:00:00"; |
| 138 | |
| 139 | if(strpos($lastyear, '2015') !== false) |
| 140 | $lastyear = date("Y")."-01-01 00:00:00"; |
| 141 | |
| 142 | |
| 143 | |
| 144 | $ori_arr=ia_sqlArray($sql.$andWhere.$orderby,'cuentaT_mov_id'); |
| 145 | |
| 146 | if($vx_marca_de_banco) { |
| 147 | //Marca de banco |
| 148 | $time_elapsed_secs = microtime(true) - $start; |
| 149 | $bleh .= "\r\n\r\nori_arr: $time_elapsed_secs"; |
| 150 | } |
| 151 | reset($ori_arr); |
| 152 | $first_key = key($ori_arr); // First element's key |
| 153 | $tomorrow = date("Y-m-d", strtotime($ori_arr[$first_key]['fecha'] ?? $tomorrow))." 23:59:59"; |
| 154 | |
| 155 | |
| 156 | $andWhere1 = " WHERE c.fecha BETWEEN '$lastyear' and '$tomorrow' AND c.contra_mov_id <> '' ORDER BY c.alta_db DESC"; |
| 157 | |
| 158 | //$big_arr es el array que tiene todos los movimientos de cuentat_mov sin discriminar; es un cache para encontrar los contramov_id con la funcion array_key_exists(). |
| 159 | |
| 160 | $big_arr=ia_sqlArray($sql.$andWhere1,'cuentaT_mov_id'); |
| 161 | if($vx_marca_de_banco) { |
| 162 | //Marca de banco |
| 163 | $time_elapsed_secs = microtime(true) - $start; |
| 164 | $bleh .= "\r\n\r\nbig_arr: $time_elapsed_secs"; |
| 165 | } |
| 166 | |
| 167 | $fin_arr = array(); |
| 168 | |
| 169 | foreach($ori_arr as $k => &$v) |
| 170 | { |
| 171 | if($v['marked'] != 'SI') |
| 172 | { |
| 173 | $contra_mov_id = $v['contra_mov_id']; |
| 174 | $cuentat_mov_id = $v['cuentaT_mov_id']; |
| 175 | //if(!empty($contra_mov_id)) |
| 176 | if(!empty($contra_mov_id) && array_key_exists($contra_mov_id, $big_arr) && $big_arr[$contra_mov_id]['marked'] != 'Si'){ |
| 177 | //Revisar las fechas para revisar cuál es más reciente. |
| 178 | $mov1 = $v; |
| 179 | $mov2 = array_key_exists($contra_mov_id, $big_arr) ? $big_arr[$contra_mov_id] : $v; |
| 180 | |
| 181 | |
| 182 | if ($v['activo'] == 'Si' || |
| 183 | ($v['cuentaT_tipo_mov_id'] == 2 && $v['app_origen'] != 'Link Directo al Banco') /** Depósitos que no sean links directos al banco */ || |
| 184 | $v['app_origen'] == 'Vale Aplicado' |
| 185 | ){ |
| 186 | if (strtotime($mov1['alta_db']) > strtotime($mov2['alta_db'])) { |
| 187 | $mov_padre = $mov1; |
| 188 | $mov_hijo = $mov2; |
| 189 | } else { |
| 190 | $mov_padre = $mov2; |
| 191 | $mov_hijo = $mov1; |
| 192 | } |
| 193 | |
| 194 | $mov_combinado = $mov_padre; |
| 195 | if(empty($mov_combinado['banco_cuenta_mov_link_id']) && !empty($mov_hijo['banco_cuenta_mov_link_id'])) |
| 196 | $mov_combinado['banco_cuenta_mov_link_id'] = $mov_hijo['banco_cuenta_mov_link_id']; |
| 197 | |
| 198 | /** Debug por si un movimiento está dando lata. */ |
| 199 | /*if($v['cuentaT_mov_id']=="74867af2fe608ea411eb5a9a0801a0a1") { |
| 200 | echo "\r\n\r\n<pre>mov_combinado apenas".print_r($mov_combinado, true)."</pre>"; |
| 201 | }*/ |
| 202 | |
| 203 | //Rony quiere la fecha d-m-Y H:i:s |
| 204 | if ($mov_hijo['afecta_cuentat'] == 'No' || $mov_combinado['afecta_cuentat'] == 'No') |
| 205 | $mov_combinado['afecta_cuentat'] = 'No'; |
| 206 | |
| 207 | if ($mov_combinado['afecta_cuentat'] == 'No') |
| 208 | $txt_class = 'grid_ctat_gasto_attreq'; |
| 209 | elseif ($mov_combinado['tipo'] == 'Ingreso') |
| 210 | $txt_class = 'grid_ctat_mov_ingreso'; |
| 211 | else |
| 212 | $txt_class = 'grid_ctat_mov_egreso'; |
| 213 | |
| 214 | $fecha_combinado = date('d-M-y H:i:s', strtotime($mov_combinado['fecha'])); //date('d', $sttPadre) . '-' . get_date_spanish($sttPadre, true, 'month_mini') . '-' . date('Y', $sttPadre) . " " . date('H:m:s',$sttPadre); |
| 215 | $fecha_hijo = date('d-M-y H:i:s', strtotime($mov_hijo['fecha'])); //date('d', $sttHijo) . '-' . get_date_spanish($sttHijo, true, 'month_mini') . '-' . date('Y', $sttHijo) . " " . date('H:m:s',$sttPadre); |
| 216 | |
| 217 | if ($mov_combinado['tipo'] == 'Ingreso') { |
| 218 | $mov_combinado['egreso'] = $mov_hijo['egreso']; |
| 219 | $mov_combinado['remarks'] = "<div style=\"min-width: 455px; width: 455px;\" class=\"$txt_class border_black\"><strong>$fecha_combinado</strong>:<br/>$mov_combinado[remarks]</div><div class=\"grid_ctat_mov_egreso border_black\"><strong>$fecha_hijo</strong>:<br/>$mov_hijo[remarks]</div>"; |
| 220 | |
| 221 | } else { |
| 222 | $mov_combinado['origen_mov_id'] = $mov_hijo['origen_mov_id']; |
| 223 | $mov_combinado['monto'] = $mov_hijo['monto']; |
| 224 | $mov_combinado['remarks'] = "<div style=\"min-width: 455px; width: 455px;\" class=\"$txt_class border_black\"><strong>$fecha_combinado</strong>:<br/>$mov_combinado[remarks]</div><div class=\"grid_ctat_mov_ingreso border_black\"><strong>$fecha_hijo</strong>:<br/>$mov_hijo[remarks]</div>"; |
| 225 | |
| 226 | } |
| 227 | |
| 228 | if (!empty($mov_combinado['banco_cuenta_id']) && !empty($mov_combinado['link_por']) && !empty($mov_combinado['link_el'])) { |
| 229 | $mov_combinado['monto'] = $mov_combinado['monto'] == 0 ? $mov_combinado['egreso'] : $mov_combinado['monto']; |
| 230 | } |
| 231 | |
| 232 | $mov_combinado['saldo_corriente_mxp'] = $mov_padre['saldo_corriente_mxp']; |
| 233 | $mov_combinado['saldo_corriente_usd'] = $mov_padre['saldo_corriente_usd']; |
| 234 | |
| 235 | //$mov_combinado['contra_mov_id'] = $mov_hijo['contra_mov_id']; |
| 236 | |
| 237 | if($mov_combinado['activo'] == 'No'){ |
| 238 | if(!empty($mov_combinado['banco_cuenta_mov_link_id'])) |
| 239 | $mov_combinado['contra_mov_id'] = $mov_combinado['banco_cuenta_mov_link_id']; |
| 240 | } |
| 241 | else{ |
| 242 | if(!empty($mov_combinado['banco_cuenta_mov_link_id'])) |
| 243 | $mov_combinado['contra_mov_id'] = $mov_padre['contra_mov_id']; |
| 244 | } |
| 245 | //$mov_combinado['contra_mov_id'] = $mov_combinado['activo'] == 'No' && !empty($mov_combinado['banco_cuenta_mov_link_id']) ? $mov_combinado['banco_cuenta_mov_link_id'] : $mov_hijo['contra_mov_id']; |
| 246 | |
| 247 | //$mov_combinado['marked'] = $v['marked'] = 'SI'; |
| 248 | |
| 249 | /** Debug por si un movimiento está dando lata. */ |
| 250 | /*if($v['cuentaT_mov_id']=="74867af2fe608ea411eb5a9a0801a0a1") { |
| 251 | echo "\r\n\r\n<pre>mov_combinado marked".print_r($mov_combinado, true)."</pre>"; |
| 252 | }*/ |
| 253 | |
| 254 | $v['marked'] = 'SI'; |
| 255 | |
| 256 | if (array_key_exists($contra_mov_id, $ori_arr)) |
| 257 | $ori_arr[$contra_mov_id]['marked'] = 'SI'; |
| 258 | |
| 259 | if (array_key_exists($contra_mov_id, $big_arr)) |
| 260 | $big_arr[$contra_mov_id]['marked'] = 'SI'; |
| 261 | |
| 262 | //Es un caso especial. Sólo hay un movimiento con monto y egreso = 0. Es meramente informativo, pero fastidia el flujo. |
| 263 | if($v['app_origen'] == 'Vale Aplicado' && $v['activo'] == 'No') |
| 264 | { |
| 265 | //El movimiento que viene en cero es el culpable. Dejamos su contra_mov_id en blanco. Cuando llegue su contramovimiento, se lo actualizamos. |
| 266 | if($v['monto'] == 0 && $v['egreso'] == 0) { |
| 267 | $mov_combinado['egreso'] = $mov_hijo['monto']; |
| 268 | $mov_combinado['monto'] = $mov_hijo['monto']; |
| 269 | $mov_combinado['contra_mov_id'] = !empty($mov_combinado['banco_cuenta_mov_link_id']) ? $mov_combinado['contra_mov_id'] : ""; |
| 270 | /*$lolz = "<pre>mov_padre:" . print_r($mov_padre, true) . "</pre>"; |
| 271 | $lolz .= "<pre>mov_hijo:" . print_r($mov_hijo, true) . "</pre>"; |
| 272 | $mov_combinado['remarks'] = "LOLZ =( $lolz<br>" . $mov_combinado['remarks'];*/ |
| 273 | $big_arr[$contra_mov_id]['marked'] = !empty($mov_combinado['banco_cuenta_mov_link_id']) ? $big_arr[$contra_mov_id]['marked'] : 'NO'; |
| 274 | $mov_combinado['afecta_cuentat'] = 'Si'; |
| 275 | $mov_combinado['moneda_id'] = $mov_hijo['moneda_id']; |
| 276 | } |
| 277 | else{ |
| 278 | /*$lolz = "<pre>fin_arr[mov_combinado['contra_mov_id']]:" . print_r($fin_arr[$mov_combinado['contra_mov_id']], true) . "</pre>"; |
| 279 | $lolz .= "<pre>mov_combinado:" . print_r($mov_combinado, true) . "</pre>"; |
| 280 | $mov_combinado['remarks'] = "LOLZ =P $lolz<br>" . $mov_combinado['remarks'];*/ |
| 281 | if(array_key_exists($mov_combinado['contra_mov_id'], $fin_arr) && $fin_arr[$mov_combinado['contra_mov_id']]['contra_mov_id'] == "") |
| 282 | { |
| 283 | $fin_arr[$mov_combinado['contra_mov_id']]['contra_mov_id'] = $mov_combinado['cuentaT_mov_id']; |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | $ori_arr[$cuentat_mov_id]['marked'] = 'SI'; |
| 289 | |
| 290 | if($mov_combinado['solo_rony'] === 'Si' && !usuarioTipoRony()) |
| 291 | $mov_combinado['remarks'] = ''; |
| 292 | |
| 293 | $fin_arr[$mov_combinado['cuentaT_mov_id']] = $mov_combinado; |
| 294 | |
| 295 | |
| 296 | /** Debug para encontrar un movimiento específico que dé lata */ |
| 297 | /* |
| 298 | if($v['cuentaT_mov_id']=="74867af2fe608ea411eb5a9a0801a0a1") |
| 299 | { |
| 300 | echo "\r\n\r\n<pre>mov_combinado".print_r($mov_combinado, true)."</pre>"; |
| 301 | echo "\r\n\r\n<pre>v".print_r($v, true)."</pre>"; |
| 302 | echo "\r\n\r\n<pre>mov1".print_r($mov1, true)."</pre>"; |
| 303 | echo "\r\n\r\n<pre>mov2".print_r($mov2, true)."</pre>"; |
| 304 | echo "\r\n\r\n<pre>mov_padre".print_r($mov_padre, true)."</pre>"; |
| 305 | echo "\r\n\r\n<pre>mov_hijo".print_r($mov_hijo, true)."</pre>"; |
| 306 | }*/ |
| 307 | |
| 308 | |
| 309 | |
| 310 | } else//los cancelados |
| 311 | { |
| 312 | //solo necesitamos el id del contramovimiento. lo dejamos así para futuras expansiones. |
| 313 | //echo "\r\n\r\n<pre>v".print_r($v, true)."</pre>"; |
| 314 | $fin_arr[$v['cuentaT_mov_id']]=$v; |
| 315 | } |
| 316 | } |
| 317 | else { |
| 318 | $ori_arr[$cuentat_mov_id]['marked'] = 'SI'; |
| 319 | |
| 320 | if($v['solo_rony'] === 'Si' && !usuarioTipoRony()) |
| 321 | $v['remarks'] = ''; |
| 322 | |
| 323 | $fin_arr[$v['cuentaT_mov_id']]=$v; |
| 324 | } |
| 325 | //$insertador->valuesArray($cm); |
| 326 | } |
| 327 | } |
| 328 | if($vx_marca_de_banco) { |
| 329 | //Marca de banco |
| 330 | $time_elapsed_secs = microtime(true) - $start; |
| 331 | $bleh .= "\r\n\r\nfin de merge: $time_elapsed_secs"; |
| 332 | } |
| 333 | |
| 334 | |
| 335 | foreach($fin_arr as $cm) |
| 336 | { |
| 337 | $insertador->valuesArray($cm); |
| 338 | } |
| 339 | |
| 340 | if($vx_marca_de_banco) { |
| 341 | //Marca de banco |
| 342 | $time_elapsed_secs = microtime(true) - $start; |
| 343 | $bleh .= "\r\n\r\nforeach insertador: $time_elapsed_secs"; |
| 344 | } |
| 345 | |
| 346 | $sql1 = array(); |
| 347 | $sql1[] = "CREATE TABLE IF NOT EXISTS cuentat_mov_tmp LIKE cuentat_mov_schema"; |
| 348 | $sql1[] = "TRUNCATE TABLE cuentat_mov_tmp"; |
| 349 | |
| 350 | if($vx_marca_de_banco) { |
| 351 | //Marca de banco |
| 352 | $time_elapsed_secs = microtime(true) - $start; |
| 353 | $bleh .= "\r\n\r\nALTER ia_transaction: $time_elapsed_secs"; |
| 354 | } |
| 355 | |
| 356 | $insertador->insertNow(); |
| 357 | $tmpsql = $insertador->get_allValues(); |
| 358 | $sql1 = (is_array($tmpsql) && !empty($tmpsql)) ? array_merge($sql1, $tmpsql) : $sql1; |
| 359 | |
| 360 | ia_transaction($sql1); |
| 361 | |
| 362 | if($vx_marca_de_banco) { |
| 363 | //Marca de banco |
| 364 | $time_elapsed_secs = microtime(true) - $start; |
| 365 | $bleh .= "\r\n\r\ninsertNow: $time_elapsed_secs"; |
| 366 | } |
| 367 | |
| 368 | if($vx_marca_de_banco) { |
| 369 | //Marca de banco |
| 370 | $time_elapsed_secs = microtime(true) - $start; |
| 371 | //echo "time_elapsed_secs: $time_elapsed_secs"; |
| 372 | $bleh .= "\r\n\r\ntime_elapsed_secs:$time_elapsed_secs"; |
| 373 | //$bleh .= "\r\n\r\n<pre>FINAL_F".print_r($fin_arr, true)."</pre>"; |
| 374 | $bleh .= "\r\n\r\nori_arr: $sql $andWhere $orderby"; |
| 375 | $bleh .= "\r\n\r\nbig_arr: $sql $andWhere1 $orderby"; |
| 376 | $bleh .= "\r\n\r\n<pre>sql1" . print_r($insertador, true) . "</pre>"; |
| 377 | //$bleh .= "\r\n\r\n<pre>fin_arr".print_r($fin_arr, true)."</pre>"; |
| 378 | |
| 379 | global $gWebDir; |
| 380 | $myFile = "C:\\wamp\\www\\$gWebDir\\backoffice\\txt\\$u-mergeCtaTMovsInsertador.txt"; |
| 381 | $fh = fopen($myFile, 'w+') or die("can't open file"); |
| 382 | |
| 383 | fwrite($fh, $bleh); |
| 384 | fclose($fh); |
| 385 | } |
| 386 | |
| 387 | if(strlen($limit)) { |
| 388 | |
| 389 | $sumasGridServer['rows'] = $limitsplit[1]; |
| 390 | $sumasGridServer['total_records'] = sizeof($fin_arr); |
| 391 | $fin_arr = array_splice($fin_arr, $limitsplit[0], $limitsplit[1]); |
| 392 | } |
| 393 | else{ |
| 394 | $sumasGridServer['rows'] = $limit; |
| 395 | $sumasGridServer['total_records'] = sizeof($fin_arr); |
| 396 | } |
| 397 | |
| 398 | $sumasGridServer['iaarr_md5_solosumas'] = "cuentat_mov_tmp"; |
| 399 | |
| 400 | ia_errores_a_dime(); |
| 401 | return array_values($fin_arr); |
| 402 | } |
| 403 | |
| 404 | function mergeCtaTMovs4Async($andWhere='',$orderby='ORDER BY fecha DESC, alta_db desc') |
| 405 | { |
| 406 | @ini_set('max_execution_time',0); |
| 407 | @ini_set('memory_limit', '1024M'); |
| 408 | global $gIAParametros; |
| 409 | global $gSqlClass; |
| 410 | leeParametrosVitex(true); |
| 411 | |
| 412 | $vx_marca_de_banco = false; |
| 413 | //$vx_marca_de_banco = true; |
| 414 | if($vx_marca_de_banco) { |
| 415 | //Marca de banco |
| 416 | $start = microtime(true); |
| 417 | $u = $_SESSION['usuario']; |
| 418 | $time_elapsed_secs = microtime(true) - $start; |
| 419 | |
| 420 | $bleh = "\r\n\r\nini: $time_elapsed_secs"; |
| 421 | //Marca de banco |
| 422 | } |
| 423 | $sqlComment = __FUNCTION__; |
| 424 | //Hacemos los inserts. |
| 425 | $insertInto = "INSERT /* $sqlComment */ INTO cuentat_mov_live(cuentaT_mov_id,cuentaT_id,fecha,moneda_id,alta_por,cuentaT_tipo_mov_id,app_origen,monto,egreso,tipo_cambio,saldo_corriente_mxp,tienda_id,remarks,json_file_attachments,alta_db,banco_cuenta_id,referencia,quantity_total,link_por,link_el,fecha_deposito,idex100,idetotal,tipo_cash_nota,cash_nota_num,cliente,factura,cash_num_cobro_iva,ivacobradox100,ivacobradototal,factura_numero,activo,saldo_corriente_usd,deposit_total,afecta_cuentat,origen_mov_id,contra_mov_id,banco_cuenta_mov_link_id,tipo,marked,solo_rony)"; |
| 426 | |
| 427 | $insertador = new \iac\inc\sql\IacSQLMultipleInsert($gSqlClass, $insertInto, '', 200000, true); |
| 428 | |
| 429 | if($vx_marca_de_banco) { |
| 430 | ////Marca de banco |
| 431 | $time_elapsed_secs = microtime(true) - $start; |
| 432 | $bleh .= "\r\n\r\nIacSQLMultipleInsert: $time_elapsed_secs"; |
| 433 | } |
| 434 | |
| 435 | $index = " /*#*#*/ FORCE INDEX (consul_movs) /*#*#*/ "; |
| 436 | |
| 437 | $sql = "SELECT /* $sqlComment */ |
| 438 | c.cuentaT_mov_id, |
| 439 | c.cuentaT_id, |
| 440 | c.fecha, |
| 441 | c.moneda_id, |
| 442 | c.alta_por, |
| 443 | c.cuentaT_tipo_mov_id, |
| 444 | c.app_origen, |
| 445 | c.monto, |
| 446 | c.egreso, |
| 447 | c.tipo_cambio, |
| 448 | c.saldo_corriente_mxp, |
| 449 | c.tienda_id, |
| 450 | c.remarks, |
| 451 | c.json_file_attachments, |
| 452 | c.alta_db, |
| 453 | c.banco_cuenta_id, |
| 454 | c.referencia, |
| 455 | c.quantity_total, |
| 456 | bcl.link_por, |
| 457 | bcl.link_el, |
| 458 | c.fecha_deposito, |
| 459 | bcm.idex100, |
| 460 | bcm.idetotal, |
| 461 | bcm.tipo_cash_nota, |
| 462 | bcm.cash_nota_num, |
| 463 | bcm.cliente, |
| 464 | bcm.factura, |
| 465 | bcm.cash_num_cobro_iva, |
| 466 | bcm.ivacobradox100, |
| 467 | bcm.ivacobradototal, |
| 468 | bcm.factura_numero, |
| 469 | c.activo, |
| 470 | c.saldo_corriente_usd, |
| 471 | c.deposit_total, |
| 472 | IF(c.monto=0 AND c.egreso=0,'No','Si') AS afecta_cuentat, |
| 473 | c.origen_mov_id, |
| 474 | c.contra_mov_id, |
| 475 | c.banco_cuenta_mov_link_id, |
| 476 | c.tipo, |
| 477 | '' as marked, |
| 478 | c.solo_rony |
| 479 | FROM cuentat_mov AS c $index |
| 480 | LEFT OUTER JOIN banco_cuenta_mov_link AS bcl ON c.banco_cuenta_mov_link_id = bcl.banco_cuenta_mov_link_id |
| 481 | LEFT JOIN banco_cuenta_mov AS bcm ON bcl.banco_cuenta_mov_id = bcm.banco_cuenta_mov_id"; |
| 482 | |
| 483 | $manana = date("Y-m-d", strtotime('tomorrow'))." 23:59:59"; |
| 484 | |
| 485 | $meses_cache_cuentat_mov = $gIAParametros['meses_cache_cuentat_mov'] ?? 3; |
| 486 | |
| 487 | $hace2meses = date("Y-m", strtotime("-$meses_cache_cuentat_mov months"))."-01 00:00:00"; |
| 488 | |
| 489 | //$lastyear = date("Y-m", strtotime("-3 months"))."-01 00:00:00"; |
| 490 | |
| 491 | //$andWhere1 = " WHERE c.fecha BETWEEN '$lastyear' and '$manana' AND c.contra_mov_id <> '' "; |
| 492 | |
| 493 | $andWhere = empty($andWhere) ? " WHERE c.fecha BETWEEN '$hace2meses' AND '$manana' " : $andWhere; |
| 494 | |
| 495 | //$lastyear = date("Y-m", strtotime("-12 months"))."-01 00:00:00"; |
| 496 | //$sql_fecha_min = "SELECT /* $sqlComment */ MIN(fecha) FROM cuentat_mov $andWhere AND c.activo = 'NO' AND contra_mov_id <> ''"; |
| 497 | $sql_fecha_min = "SELECT MIN(fecha) FROM cuentat_mov WHERE cuentaT_mov_id IN(SELECT c.contra_mov_id FROM cuentat_mov c $andWhere AND c.activo = 'NO' AND contra_mov_id <> '' $orderby)"; |
| 498 | $lastyear = ia_singleread($sql_fecha_min); |
| 499 | if($vx_marca_de_banco) { |
| 500 | //Marca de banco |
| 501 | $time_elapsed_secs = microtime(true) - $start; |
| 502 | $bleh .= "\r\n\r\n$lastyear last_year: $time_elapsed_secs"; |
| 503 | } |
| 504 | |
| 505 | //echo "<li>$lastyear : $sql_fecha_min"; |
| 506 | |
| 507 | if(!empty($lastyear) && $lastyear < $hace2meses){ |
| 508 | $lastyear = date("Y-m", strtotime($lastyear))."-01 00:00:00"; |
| 509 | } |
| 510 | |
| 511 | if(empty($lastyear)) |
| 512 | $lastyear = date("Y-m", strtotime("-3 months"))."-01 00:00:00"; |
| 513 | |
| 514 | |
| 515 | //$andWhere1 = " WHERE c.fecha BETWEEN '$hace3meses' AND '$manana' AND c.contra_mov_id <> ''"; |
| 516 | $andWhere1 = " WHERE c.fecha BETWEEN '$lastyear' and '$manana' AND c.contra_mov_id <> '' "; |
| 517 | |
| 518 | $sql_big_arr = $sql.$andWhere1.$orderby; |
| 519 | |
| 520 | $andWhere = " WHERE c.fecha BETWEEN '$lastyear' AND '$manana' "; |
| 521 | |
| 522 | $sql_ori_arr = $sql.$andWhere.$orderby; |
| 523 | //echo "<li>$lastyear : $sql_ori_arr"; |
| 524 | |
| 525 | $ori_arr = ia_sqlArray($sql . $andWhere . $orderby, 'cuentaT_mov_id'); |
| 526 | if($vx_marca_de_banco) { |
| 527 | //Marca de banco |
| 528 | $time_elapsed_secs = microtime(true) - $start; |
| 529 | $bleh .= "\r\n\r\nori_arr: $time_elapsed_secs"; |
| 530 | } |
| 531 | |
| 532 | //$big_arr es el array que tiene todos los movimientos de cuentat_mov sin discriminar; es un cache para encontrar los contramov_id con la funcion array_key_exists(). |
| 533 | $big_arr=array();//ia_sqlArray($sql.$andWhere1.$orderby,'cuentaT_mov_id'); |
| 534 | if($vx_marca_de_banco) { |
| 535 | //Marca de banco |
| 536 | $time_elapsed_secs = microtime(true) - $start; |
| 537 | $bleh .= "\r\n\r\nbig_arr: $time_elapsed_secs"; |
| 538 | } |
| 539 | |
| 540 | |
| 541 | $fin_arr = array(); |
| 542 | |
| 543 | foreach($ori_arr as $k => &$v) |
| 544 | { |
| 545 | if($v['marked'] != 'SI') |
| 546 | { |
| 547 | $contra_mov_id = $v['contra_mov_id']; |
| 548 | $cuentat_mov_id = $v['cuentaT_mov_id']; |
| 549 | //if(!empty($contra_mov_id)) |
| 550 | if(!empty($contra_mov_id) && array_key_exists($contra_mov_id, $ori_arr) && $ori_arr[$contra_mov_id]['marked'] != 'Si'){ |
| 551 | //Revisar las fechas para revisar cuál es más reciente. |
| 552 | $mov1 = $v; |
| 553 | $mov2 = array_key_exists($contra_mov_id, $ori_arr) ? $ori_arr[$contra_mov_id] : $v; |
| 554 | |
| 555 | |
| 556 | if ($v['activo'] == 'Si' || |
| 557 | ($v['cuentaT_tipo_mov_id'] == 2 && $v['app_origen'] != 'Link Directo al Banco') /** Depósitos que no sean links directos al banco */ || |
| 558 | $v['app_origen'] == 'Vale Aplicado' |
| 559 | ){ |
| 560 | if (strtotime($mov1['alta_db']) > strtotime($mov2['alta_db'])) { |
| 561 | $mov_padre = $mov1; |
| 562 | $mov_hijo = $mov2; |
| 563 | } else { |
| 564 | $mov_padre = $mov2; |
| 565 | $mov_hijo = $mov1; |
| 566 | } |
| 567 | |
| 568 | $mov_combinado = $mov_padre; |
| 569 | if(empty($mov_combinado['banco_cuenta_mov_link_id']) && !empty($mov_hijo['banco_cuenta_mov_link_id'])) |
| 570 | $mov_combinado['banco_cuenta_mov_link_id'] = $mov_hijo['banco_cuenta_mov_link_id']; |
| 571 | |
| 572 | /** Debug por si un movimiento está dando lata. */ |
| 573 | /*if($v['cuentaT_mov_id']=="74867af2fe608ea411eb5a9a0801a0a1") { |
| 574 | echo "\r\n\r\n<pre>mov_combinado apenas".print_r($mov_combinado, true)."</pre>"; |
| 575 | }*/ |
| 576 | |
| 577 | //Rony quiere la fecha d-m-Y H:i:s |
| 578 | if ($mov_hijo['afecta_cuentat'] == 'No' || $mov_combinado['afecta_cuentat'] == 'No') |
| 579 | $mov_combinado['afecta_cuentat'] = 'No'; |
| 580 | |
| 581 | if ($mov_combinado['afecta_cuentat'] == 'No') |
| 582 | $txt_class = 'grid_ctat_gasto_attreq'; |
| 583 | elseif ($mov_combinado['tipo'] == 'Ingreso') |
| 584 | $txt_class = 'grid_ctat_mov_ingreso'; |
| 585 | else |
| 586 | $txt_class = 'grid_ctat_mov_egreso'; |
| 587 | |
| 588 | $fecha_combinado = date('d-M-y H:i:s', strtotime($mov_combinado['fecha'])); //date('d', $sttPadre) . '-' . get_date_spanish($sttPadre, true, 'month_mini') . '-' . date('Y', $sttPadre) . " " . date('H:m:s',$sttPadre); |
| 589 | $fecha_hijo = date('d-M-y H:i:s', strtotime($mov_hijo['fecha'])); //date('d', $sttHijo) . '-' . get_date_spanish($sttHijo, true, 'month_mini') . '-' . date('Y', $sttHijo) . " " . date('H:m:s',$sttPadre); |
| 590 | |
| 591 | if ($mov_combinado['tipo'] == 'Ingreso') { |
| 592 | $mov_combinado['egreso'] = $mov_hijo['egreso']; |
| 593 | $mov_combinado['remarks'] = "<div style=\"min-width: 455px; width: 455px;\" class=\"$txt_class border_black\"><strong>$fecha_combinado</strong>:<br/>$mov_combinado[remarks]</div><div class=\"grid_ctat_mov_egreso border_black\"><strong>$fecha_hijo</strong>:<br/>$mov_hijo[remarks]</div>"; |
| 594 | |
| 595 | } else { |
| 596 | $mov_combinado['origen_mov_id'] = $mov_hijo['origen_mov_id']; |
| 597 | $mov_combinado['monto'] = $mov_hijo['monto']; |
| 598 | $mov_combinado['remarks'] = "<div style=\"min-width: 455px; width: 455px;\" class=\"$txt_class border_black\"><strong>$fecha_combinado</strong>:<br/>$mov_combinado[remarks]</div><div class=\"grid_ctat_mov_ingreso border_black\"><strong>$fecha_hijo</strong>:<br/>$mov_hijo[remarks]</div>"; |
| 599 | |
| 600 | } |
| 601 | |
| 602 | if (!empty($mov_combinado['banco_cuenta_id']) && !empty($mov_combinado['link_por']) && !empty($mov_combinado['link_el'])) { |
| 603 | $mov_combinado['monto'] = $mov_combinado['monto'] == 0 ? $mov_combinado['egreso'] : $mov_combinado['monto']; |
| 604 | } |
| 605 | |
| 606 | $mov_combinado['saldo_corriente_mxp'] = $mov_padre['saldo_corriente_mxp']; |
| 607 | $mov_combinado['saldo_corriente_usd'] = $mov_padre['saldo_corriente_usd']; |
| 608 | |
| 609 | //$mov_combinado['contra_mov_id'] = $mov_hijo['contra_mov_id']; |
| 610 | |
| 611 | if($mov_combinado['activo'] == 'No'){ |
| 612 | if(!empty($mov_combinado['banco_cuenta_mov_link_id'])) |
| 613 | $mov_combinado['contra_mov_id'] = $mov_combinado['banco_cuenta_mov_link_id']; |
| 614 | } |
| 615 | else{ |
| 616 | if(!empty($mov_combinado['banco_cuenta_mov_link_id'])) |
| 617 | $mov_combinado['contra_mov_id'] = $mov_padre['contra_mov_id']; |
| 618 | } |
| 619 | //$mov_combinado['contra_mov_id'] = $mov_combinado['activo'] == 'No' && !empty($mov_combinado['banco_cuenta_mov_link_id']) ? $mov_combinado['banco_cuenta_mov_link_id'] : $mov_hijo['contra_mov_id']; |
| 620 | |
| 621 | //$mov_combinado['marked'] = $v['marked'] = 'SI'; |
| 622 | |
| 623 | /** Debug por si un movimiento está dando lata. */ |
| 624 | /*if($v['cuentaT_mov_id']=="74867af2fe608ea411eb5a9a0801a0a1") { |
| 625 | echo "\r\n\r\n<pre>mov_combinado marked".print_r($mov_combinado, true)."</pre>"; |
| 626 | }*/ |
| 627 | |
| 628 | $v['marked'] = 'SI'; |
| 629 | |
| 630 | if (array_key_exists($contra_mov_id, $ori_arr)) |
| 631 | $ori_arr[$contra_mov_id]['marked'] = 'SI'; |
| 632 | |
| 633 | if (array_key_exists($contra_mov_id, $ori_arr)) |
| 634 | $ori_arr[$contra_mov_id]['marked'] = 'SI'; |
| 635 | |
| 636 | //Es un caso especial. Sólo hay un movimiento con monto y egreso = 0. Es meramente informativo, pero fastidia el flujo. |
| 637 | if($v['app_origen'] == 'Vale Aplicado' && $v['activo'] == 'No') |
| 638 | { |
| 639 | //El movimiento que viene en cero es el culpable. Dejamos su contra_mov_id en blanco. Cuando llegue su contramovimiento, se lo actualizamos. |
| 640 | if($v['monto'] == 0 && $v['egreso'] == 0) { |
| 641 | $mov_combinado['egreso'] = $mov_hijo['monto']; |
| 642 | $mov_combinado['monto'] = $mov_hijo['monto']; |
| 643 | $mov_combinado['contra_mov_id'] = !empty($mov_combinado['banco_cuenta_mov_link_id']) ? $mov_combinado['contra_mov_id'] : ""; |
| 644 | /*$lolz = "<pre>mov_padre:" . print_r($mov_padre, true) . "</pre>"; |
| 645 | $lolz .= "<pre>mov_hijo:" . print_r($mov_hijo, true) . "</pre>"; |
| 646 | $mov_combinado['remarks'] = "LOLZ =( $lolz<br>" . $mov_combinado['remarks'];*/ |
| 647 | $ori_arr[$contra_mov_id]['marked'] = !empty($mov_combinado['banco_cuenta_mov_link_id']) ? $ori_arr[$contra_mov_id]['marked'] : 'NO'; |
| 648 | $mov_combinado['afecta_cuentat'] = 'Si'; |
| 649 | $mov_combinado['moneda_id'] = $mov_hijo['moneda_id']; |
| 650 | } |
| 651 | else{ |
| 652 | /*$lolz = "<pre>fin_arr[mov_combinado['contra_mov_id']]:" . print_r($fin_arr[$mov_combinado['contra_mov_id']], true) . "</pre>"; |
| 653 | $lolz .= "<pre>mov_combinado:" . print_r($mov_combinado, true) . "</pre>"; |
| 654 | $mov_combinado['remarks'] = "LOLZ =P $lolz<br>" . $mov_combinado['remarks'];*/ |
| 655 | if(array_key_exists($mov_combinado['contra_mov_id'], $fin_arr) && $fin_arr[$mov_combinado['contra_mov_id']]['contra_mov_id'] == "") |
| 656 | { |
| 657 | $fin_arr[$mov_combinado['contra_mov_id']]['contra_mov_id'] = $mov_combinado['cuentaT_mov_id']; |
| 658 | } |
| 659 | } |
| 660 | } |
| 661 | |
| 662 | $ori_arr[$cuentat_mov_id]['marked'] = 'SI'; |
| 663 | |
| 664 | $fin_arr[$mov_combinado['cuentaT_mov_id']] = $mov_combinado; |
| 665 | |
| 666 | |
| 667 | /** Debug para encontrar un movimiento específico que dé lata */ |
| 668 | /* |
| 669 | if($v['cuentaT_mov_id']=="74867af2fe608ea411eb5a9a0801a0a1") |
| 670 | { |
| 671 | echo "\r\n\r\n<pre>mov_combinado".print_r($mov_combinado, true)."</pre>"; |
| 672 | echo "\r\n\r\n<pre>v".print_r($v, true)."</pre>"; |
| 673 | echo "\r\n\r\n<pre>mov1".print_r($mov1, true)."</pre>"; |
| 674 | echo "\r\n\r\n<pre>mov2".print_r($mov2, true)."</pre>"; |
| 675 | echo "\r\n\r\n<pre>mov_padre".print_r($mov_padre, true)."</pre>"; |
| 676 | echo "\r\n\r\n<pre>mov_hijo".print_r($mov_hijo, true)."</pre>"; |
| 677 | }*/ |
| 678 | |
| 679 | |
| 680 | |
| 681 | } else//los cancelados |
| 682 | { |
| 683 | //solo necesitamos el id del contramovimiento. lo dejamos así para futuras expansiones. |
| 684 | //echo "\r\n\r\n<pre>v".print_r($v, true)."</pre>"; |
| 685 | $fin_arr[$v['cuentaT_mov_id']]=$v; |
| 686 | } |
| 687 | } |
| 688 | else { |
| 689 | $fin_arr[$v['cuentaT_mov_id']]=$v; |
| 690 | } |
| 691 | //$insertador->valuesArray($cm); |
| 692 | } |
| 693 | } |
| 694 | if($vx_marca_de_banco) { |
| 695 | //Marca de banco |
| 696 | $time_elapsed_secs = microtime(true) - $start; |
| 697 | $bleh .= "\r\n\r\nfin de merge: $time_elapsed_secs"; |
| 698 | } |
| 699 | |
| 700 | foreach($fin_arr as $cm) |
| 701 | { |
| 702 | $insertador->valuesArray($cm); |
| 703 | } |
| 704 | |
| 705 | if($vx_marca_de_banco) { |
| 706 | //Marca de banco |
| 707 | $time_elapsed_secs = microtime(true) - $start; |
| 708 | $bleh .= "\r\n\r\nforeach insertador: $time_elapsed_secs"; |
| 709 | } |
| 710 | |
| 711 | $sql1 = array(); |
| 712 | $sql1[] = "CREATE TABLE IF NOT EXISTS cuentat_mov_live LIKE cuentat_mov_schema"; |
| 713 | $sql1[] = "TRUNCATE TABLE cuentat_mov_live"; |
| 714 | //$sql1[] = "ALTER TABLE cuentat_mov_live DROP INDEX consul_movs"; |
| 715 | |
| 716 | //ia_transaction($sql1); |
| 717 | |
| 718 | if($vx_marca_de_banco) { |
| 719 | //Marca de banco |
| 720 | $time_elapsed_secs = microtime(true) - $start; |
| 721 | $bleh .= "\r\n\r\nALTER ia_transaction: $time_elapsed_secs"; |
| 722 | } |
| 723 | |
| 724 | $insertador->insertNow(); |
| 725 | $tmpsql = $insertador->get_allValues(); |
| 726 | $sql1 = (is_array($tmpsql) && !empty($tmpsql)) ? array_merge($sql1, $tmpsql) : $sql1; |
| 727 | |
| 728 | ia_transaction($sql1); |
| 729 | |
| 730 | if($vx_marca_de_banco) { |
| 731 | //Marca de banco |
| 732 | $time_elapsed_secs = microtime(true) - $start; |
| 733 | $bleh .= "\r\n\r\ninsertNow: $time_elapsed_secs"; |
| 734 | } |
| 735 | |
| 736 | if($vx_marca_de_banco) { |
| 737 | //Marca de banco |
| 738 | $time_elapsed_secs = microtime(true) - $start; |
| 739 | //echo "time_elapsed_secs: $time_elapsed_secs"; |
| 740 | $bleh .= "\r\n\r\ntime_elapsed_secs:$time_elapsed_secs"; |
| 741 | //$bleh .= "\r\n\r\n<pre>FINAL_F".print_r($fin_arr, true)."</pre>"; |
| 742 | $bleh .= "\r\n\r\nori_arr: $sql_ori_arr"; |
| 743 | $bleh .= "\r\n\r\nbig_arr: $sql_big_arr"; |
| 744 | $bleh .= "\r\n\r\n<pre>sql1" . print_r($insertador, true) . "</pre>"; |
| 745 | //$bleh .= "\r\n\r\n<pre>fin_arr".print_r($fin_arr, true)."</pre>"; |
| 746 | global $gWebDir; |
| 747 | $myFile = "C:\\wamp\\www\\$gWebDir\\backoffice\\txt\\$u-mergeCtaTMovs4AsyncInsertador.txt"; |
| 748 | $fh = fopen($myFile, 'w+') or die("can't open file"); |
| 749 | fwrite($fh, $bleh); |
| 750 | fclose($fh); |
| 751 | } |
| 752 | |
| 753 | ia_errores_a_dime(); |
| 754 | //Revisar los indices o la llave. |
| 755 | return $fin_arr; |
| 756 | } |