Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 1884 |
|
0.00% |
0 / 66 |
CRAP | n/a |
0 / 0 |
|
| cuenta_banco_mov_options | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| cuenta_banco_mov_list_sql | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
240 | |||
| cuenta_banco_mov_verifica_options | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| cuenta_banco_mov_verifica_list_sql | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
12 | |||
| arreglaLinksPendientes | |
0.00% |
0 / 146 |
|
0.00% |
0 / 1 |
1640 | |||
| links_pendientes | |
0.00% |
0 / 46 |
|
0.00% |
0 / 1 |
210 | |||
| hazLabeldeDocto | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
110 | |||
| tablapadre | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
42 | |||
| leeaCuenta | |
0.00% |
0 / 229 |
|
0.00% |
0 / 1 |
26406 | |||
| TablaparaLinkManual | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
110 | |||
| obtenOnHandCuentasT | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
90 | |||
| registraMovimientoDivisa | |
0.00% |
0 / 31 |
|
0.00% |
0 / 1 |
90 | |||
| registraBrainAviso | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
12 | |||
| revisaTipodeCambio | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
240 | |||
| extraeTCdeXE | |
0.00% |
0 / 54 |
|
0.00% |
0 / 1 |
1122 | |||
| actualizaTCenDB | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
72 | |||
| obtenCuentasTToolbar | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
42 | |||
| cancelaVale | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| obtenCuentaTMovIDOriginal | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| arrayAppOrigen | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| arrayLinkOrigen | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| arrayTablasCatalogos | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| arrayTipoFactura | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| arrayTipoFigura | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| arrayTipoWarning | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| array_movimiento_divisa_warning_tipo | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| arrayTipoCashNota | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| array_bodega_tipo_cash_nota | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 | |||
| arrayLinkVale | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
20 | |||
| arrayUltimoMovimiento | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| borraDocumentoPagos | |
0.00% |
0 / 33 |
|
0.00% |
0 / 1 |
156 | |||
| borraDocumentoPago | |
0.00% |
0 / 273 |
|
0.00% |
0 / 1 |
4692 | |||
| buscaClientesconNombreParecido | |
0.00% |
0 / 19 |
|
0.00% |
0 / 1 |
132 | |||
| marcaCerradoDocumento | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |||
| marcaAbiertoDocumento | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
30 | |||
| debeCerrarDocumento | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
56 | |||
| estatusDocumento | |
0.00% |
0 / 29 |
|
0.00% |
0 / 1 |
506 | |||
| esCuentaTde | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| tiendaIDdeCtaT | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| propdeCtaT | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| numRefLink | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| preparaDiccionarioDatosBanco | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
56 | |||
| preparaDiccionarioDatosBancoGastos | |
0.00% |
0 / 25 |
|
0.00% |
0 / 1 |
342 | |||
| linksdeTodoalBancoLinksVale | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| linksdeTodoalBanco | |
0.00% |
0 / 39 |
|
0.00% |
0 / 1 |
72 | |||
| debeFlashearTab | |
0.00% |
0 / 22 |
|
0.00% |
0 / 1 |
182 | |||
| camposyTablasNormalizadas | |
0.00% |
0 / 26 |
|
0.00% |
0 / 1 |
42 | |||
| leer_banco_cuenta_poner_deposito_ND | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
42 | |||
| leer_banco_cuenta_no_aparece_depositar_en | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
42 | |||
| leer_origen_destino_especial | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
42 | |||
| leer_bodegas_no_existencia | |
0.00% |
0 / 30 |
|
0.00% |
0 / 1 |
42 | |||
| doSelectCatDoc | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
56 | |||
| haz_retraso_si_tabla_vacia | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |||
| revisaMoneda | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| revisaTipoFactura | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| revisaTipoCashNota | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
12 | |||
| revisaCamposCFDI33 | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
42 | |||
| revisaActivoCatalogo | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
20 | |||
| brtbNotificaciones | |
0.00% |
0 / 128 |
|
0.00% |
0 / 1 |
2162 | |||
| delivered_pending_cheques | |
0.00% |
0 / 60 |
|
0.00% |
0 / 1 |
462 | |||
| delivered_rechazados | |
0.00% |
0 / 32 |
|
0.00% |
0 / 1 |
90 | |||
| obtenSQLlinksdeTodoalBanco | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
56 | |||
| obten_tc_live | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| inicializa_catalogos_globales | |
0.00% |
0 / 44 |
|
0.00% |
0 / 1 |
240 | |||
| estado_cuenta_cliente | |
0.00% |
0 / 154 |
|
0.00% |
0 / 1 |
650 | |||
| init_estado_cuenta_cliente | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * cuenta_banco_mov_options() |
| 5 | * Trae <option >...</option> de cuentas de banco puede el usuario accesar |
| 6 | * @param string $h e,a permiso de editar otro leer de leer |
| 7 | * @param null|false $selected que opcion esta preseleccionada |
| 8 | * @param bool $todas Muestra todas las cuentas sin importar qué |
| 9 | * @param string $moneda_id moneda de las cuentas bancarias: 1 = Pesos, 2 = USD |
| 10 | * @param array|null $b_id array de cuentas a elegir //era banco |
| 11 | * @param bool $conChina Agrega o no los bancos de china |
| 12 | * @param null|true $select |
| 13 | * @param bool $linkalBanco |
| 14 | * @param bool|string $sinRony Agrega o no la cuenta de Rony (ahora agrega o no las cuentas Privadas) |
| 15 | * @return |
| 16 | */ |
| 17 | function cuenta_banco_mov_options(string $h='r', bool|null $selected=false, bool $todas=false, string $moneda_id='1', array $b_id=null, bool $conChina=false, bool|null $select=true, bool $linkalBanco=false, bool|string $sinRony=false) { |
| 18 | // return ia_SqlOptions( cuenta_banco_mov_list_sql($h,$todas,$moneda_id),$selected); |
| 19 | |
| 20 | //echo cuenta_banco_mov_list_sql($h,$todas,$moneda_id,$b_id,$conChina,$select,$linkalBanco); |
| 21 | if($select) |
| 22 | return ia_OptionsSetData( ia_sqlArray( cuenta_banco_mov_list_sql($h,$todas,$moneda_id,$b_id,$conChina,$select,$linkalBanco, $sinRony),'banco_cuenta_id'),$selected); |
| 23 | else |
| 24 | { |
| 25 | //return ia_sqlArray(cuenta_banco_mov_list_sql($h,$todas,$moneda_id,$b_id,$conChina,$select),'banco_cuenta_id'); |
| 26 | return ia_sqlArrayIndx(cuenta_banco_mov_list_sql($h,$todas,$moneda_id,$b_id,$conChina,$select,$linkalBanco, $sinRony)); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * cuenta_banco_mov_list_sql() |
| 32 | * Sql con cuentas de banco puede usar el usuario segun $h para estado de cuenta principal |
| 33 | * @param string $h $h e,a permiso de editar otro leer de leer |
| 34 | * @param mixed $b_id array de cuentas a elegir //era banco |
| 35 | * @param bool $conChina Agrega o no los bancos de china |
| 36 | * @param mixed $select |
| 37 | * @param bool $linkalBanco |
| 38 | * @param bool|string $sinRony Agrega o no la cuenta de Rony |
| 39 | *@return sql con banco_cuenta_id, nombre de la cuenta unicamente las que puede ver el usuario para movimientos del estado de cuenta principal |
| 40 | */ |
| 41 | function cuenta_banco_mov_list_sql($h, $todas=false, $moneda_id='1', $b_id=null, $conChina=false, $select=true, $linkalBanco=false,bool|string $sinRony=false, string $order_by = " bc.nombre ASC ") { |
| 42 | |
| 43 | if($conChina) |
| 44 | $conChina = usuarioTipoRony($_SESSION['usuario_id']) ? " (bc.banco_china='Si') " : " (bc.banco_china='Si' AND u.puede_banco_china='Si') "; |
| 45 | else |
| 46 | $conChina = " bc.banco_china='No' "; |
| 47 | if(usuarioTipoRony($_SESSION['usuario_id']) || $todas) //Abusado aqui con el usuario tipo Rony. |
| 48 | { |
| 49 | //$puede=" FORCE INDEX (con_china) JOIN iac_usr u ON u.iac_usr_id = $_SESSION[usuario_id] WHERE bc.vale='Active' "; |
| 50 | $puede=" FORCE INDEX (con_china) WHERE bc.vale='Active' "; |
| 51 | //$puede .= " AND ( $conChina OR $_SESSION[usuario_id]=1 ) "; |
| 52 | if(!$todas) |
| 53 | $puede .= " AND ( $conChina ) "; |
| 54 | } |
| 55 | else{ |
| 56 | if($linkalBanco) |
| 57 | $puede = " WHERE bc.vale='Active' "; |
| 58 | else |
| 59 | $puede=" FORCE INDEX (con_china) |
| 60 | JOIN banco_cuenta_mov_plantilla bcu ON bc.banco_cuenta_id=bcu.banco_cuenta_id |
| 61 | JOIN plantilla p ON bcu.plantilla_id=p.plantilla_id |
| 62 | JOIN iac_usr u ON u.plantilla_id=p.plantilla_id |
| 63 | WHERE bc.vale='Active' AND bcu.puede<>'Nada' AND iac_usr_id=".strit($_SESSION['usuario_id'])." AND ( $conChina ) "; |
| 64 | /** |
| 65 | if($linkalBanco) |
| 66 | $cualPermiso = " bcu.puede IN ('L/O', 'R/W') "; //CREO que hace falta L/R link and read. R/W tiene implicito el link. OJO VCA 26-SEP-2020 aquí continúas. comentar y no usar por el momento puedeCuentaBancaria(). |
| 67 | else |
| 68 | $cualPermiso = " bcu.puede<>'Nada' "; |
| 69 | |
| 70 | $puede=" FORCE INDEX (con_china) |
| 71 | JOIN banco_cuenta_mov_plantilla bcu ON bc.banco_cuenta_id=bcu.banco_cuenta_id |
| 72 | JOIN plantilla p ON bcu.plantilla_id=p.plantilla_id |
| 73 | JOIN iac_usr u ON u.plantilla_id=p.plantilla_id |
| 74 | WHERE bc.vale='Active' AND $cualPermiso AND iac_usr_id=".strit($_SESSION['usuario_id'])." AND ( $conChina ) "; |
| 75 | * * **/ |
| 76 | } |
| 77 | if($moneda_id == 0) |
| 78 | $moneda_id = ""; |
| 79 | else |
| 80 | $moneda_id = " AND bc.moneda_id='$moneda_id' "; |
| 81 | |
| 82 | if(empty($b_id)) |
| 83 | $b_id = ""; |
| 84 | else |
| 85 | { |
| 86 | if(is_array($b_id)) |
| 87 | { |
| 88 | $b_idTmp = ''; |
| 89 | foreach($b_id as $k=>$v) |
| 90 | $b_idTmp .= "'$v',"; |
| 91 | $b_idTmp = substr($b_idTmp,0,-1); |
| 92 | //$b_id = " AND bc.banco_id IN ($b_idTmp) "; |
| 93 | $b_id = " AND bc.banco_cuenta_id IN ($b_idTmp) "; |
| 94 | } |
| 95 | else |
| 96 | $b_id = " AND bc.banco_cuenta_id='$b_id' "; |
| 97 | //$b_id = " AND bc.banco_id='$b_id' "; |
| 98 | } |
| 99 | |
| 100 | if($sinRony === false) |
| 101 | $sinRony = ""; |
| 102 | else if($sinRony === true) |
| 103 | $sinRony = " AND bc.tipo_inversion_empresa_privada NOT IN ('privada') "; // VCA 27 Marzo 2023: ocupo el campo tipo_inversion_empresa_privada=empresa para saber si la cuenta es de Rony o no. |
| 104 | else if($sinRony === 'SOLORONY') |
| 105 | $sinRony = " AND bc.tipo_inversion_empresa_privada IN ('privada') "; |
| 106 | |
| 107 | |
| 108 | $autocompleteTag = ""; |
| 109 | if(!$select) |
| 110 | $autocompleteTag = " ,bc.nombre as label, bc.nombre as value "; |
| 111 | //echo "SELECT /* vitex.php banco_cuenta_mov_list_sql */ bc.banco_cuenta_id, bc.nombre,banco_id FROM banco_cuenta bc $puede ORDER BY bc.orden, bc.nombre"; |
| 112 | $sql = "SELECT /* vitex.php banco_cuenta_mov_list_sql */ |
| 113 | bc.banco_cuenta_id, |
| 114 | bc.nombre, |
| 115 | bc.banco_id as banco, |
| 116 | bc.banco_id , |
| 117 | bc.moneda_id, |
| 118 | bc.numero, |
| 119 | bc.empresa_id, |
| 120 | bc.banco_china, |
| 121 | bc.tipo_inversion_empresa_privada |
| 122 | $autocompleteTag |
| 123 | FROM banco_cuenta bc $puede $moneda_id $b_id $sinRony ORDER BY /* bc.orden, */ $order_by"; |
| 124 | |
| 125 | |
| 126 | return $sql; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * cuenta_banco_mov_verifica_options() |
| 131 | * |
| 132 | * @param string $h $h e,a permiso de editar otro leer de leer |
| 133 | * @param mixed $selected |
| 134 | * @return |
| 135 | */ |
| 136 | function cuenta_banco_mov_verifica_options($h,$selected,$todas=false,$moneda_id='1') { |
| 137 | return ia_SqlOptions( cuenta_banco_mov_verifica_list_sql($h,$todas,$moneda_id),$selected); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * cuenta_banco_mov_verifica_list_sql() |
| 142 | * Sql con cuentas de banco puede usar el usuario segun $h para verificar estado de cuenta |
| 143 | * @param string $h $h e,a permiso de editar otro leer de leer |
| 144 | * @return string Sql con cuentas de banco puede usar el usuario segun $h para verificar estado de cuenta |
| 145 | */ |
| 146 | function cuenta_banco_mov_verifica_list_sql($h,$todas=false,$moneda_id='1') { |
| 147 | if(usuarioTipoRony($_SESSION['usuario_id'])) |
| 148 | $puede=" WHERE bc.vale='Active' "; |
| 149 | //elseif($h=='e' || $h=='a') // editar |
| 150 | //$puede=" JOIN mov_verificado_plantilla bcu ON bc.banco_cuenta_id=bcu.banco_cuenta_id JOIN plantilla p ON bcu.plantilla_id=p.plantilla_id JOIN iac_usr u ON u.plantilla_id=p.plantilla_id WHERE bcu.puede ='R/W' AND iac_usr_id=".strit($_SESSION['usuario_id']); |
| 151 | else // consultar |
| 152 | $puede=" JOIN mov_verificado_plantilla bcu ON bc.banco_cuenta_id=bcu.banco_cuenta_id JOIN plantilla p ON bcu.plantilla_id=p.plantilla_id JOIN iac_usr u ON u.plantilla_id=p.plantilla_id WHERE bc.vale='Active' AND bcu.puede<>'Nada' AND iac_usr_id=".strit($_SESSION['usuario_id']); |
| 153 | |
| 154 | if($moneda_id == 0) |
| 155 | $moneda_id = ""; |
| 156 | else |
| 157 | $moneda_id = " AND bc.moneda_id='$moneda_id' "; |
| 158 | |
| 159 | $sql2return = "SELECT /* vitex.php cuenta_banco_mov_verifica_list_sql */ bc.banco_cuenta_id, bc.nombre,banco_id , bc.moneda_id, bc.numero, bc.empresa_id, bc.banco_china |
| 160 | FROM banco_cuenta bc $puede $moneda_id ORDER BY bc.orden, bc.nombre"; |
| 161 | |
| 162 | //echo "<br/>$sql2return<br/>"; |
| 163 | |
| 164 | return $sql2return; |
| 165 | } |
| 166 | |
| 167 | function arreglaLinksPendientes($origenLPA="") |
| 168 | { |
| 169 | global $gIAsql; |
| 170 | |
| 171 | $gIAsql['trace'] = true; |
| 172 | |
| 173 | $arrTablas = array(array('tabla'=>'deuda_pago','tipo'=>'egreso'), array('tabla'=>'cheque_pago','tipo'=>'ingreso'), |
| 174 | array('tabla'=>'pagare_pago','tipo'=>'ingreso') ); |
| 175 | if(VALE_PAGO_MULTIPLE) { |
| 176 | $arrTablas[] = ['tabla'=>'vale_pago','tipo'=>'ingreso']; |
| 177 | |
| 178 | }else { |
| 179 | $arrTablas[] = array('tabla'=>'vale','tipo'=>'ingreso'); |
| 180 | } |
| 181 | |
| 182 | $fechaLPA = date("Y-m-d H:i:s"); |
| 183 | $campoBancoCuenta = ''; |
| 184 | $campoQuantity = 'quantity'; //Por los vales en donde usamos quantity_recibido; |
| 185 | |
| 186 | $usuario = $_SESSION['usuario']; |
| 187 | |
| 188 | foreach($arrTablas as $k=>$vTabla) |
| 189 | { |
| 190 | $tablaPcLP = $vTabla['tabla']; |
| 191 | $tipoPcLP = $vTabla['tipo']; |
| 192 | |
| 193 | if($tablaPcLP == 'vale') |
| 194 | $campoQuantity = 'quantity_recibido'; |
| 195 | |
| 196 | $campoBancoCuenta = 'banco_cuenta_id'; |
| 197 | |
| 198 | $sqlLP = "SELECT * FROM $tablaPcLP WHERE $campoBancoCuenta != 0 AND (banco_cuenta_mov_link_id = 'pendiente')"; // OR banco_cuenta_mov_link_id = '' |
| 199 | //echo "$sqlLP<br/>"; |
| 200 | $arrPcLP = ia_sqlArrayIndx($sqlLP); |
| 201 | |
| 202 | |
| 203 | |
| 204 | if(is_array($arrPcLP)) foreach($arrPcLP as $kPcLP=>$vPcLP) |
| 205 | { |
| 206 | //echo "$vTabla[tipo]<br/>"; |
| 207 | //echo print_r($arrPcLP, true); |
| 208 | $usuario = $vPcLP['alta_por']; |
| 209 | $sql = array(); |
| 210 | $tienda_idPcLP = array_key_exists('tienda_id',$vPcLP) ? $vPcLP['tienda_id'] : '0'; |
| 211 | $fechaPcLP = array_key_exists('deposit_fecha',$vPcLP) ? $vPcLP['deposit_fecha'] : $vPcLP['fecha']; |
| 212 | $fechaPcLP = date('Y-m-d', strtotime($fechaPcLP)); |
| 213 | $banco_cuenta_idPcLP = $vPcLP[$campoBancoCuenta]; |
| 214 | $ide_percentPcLP = $vPcLP['ide_percent']; |
| 215 | $importe_originalPcLP = $vPcLP['quantity_total']; |
| 216 | |
| 217 | $bcm_id = ''; |
| 218 | $link_num_ref = ''; |
| 219 | $referencia = ''; |
| 220 | |
| 221 | //Para datos de la factura |
| 222 | $lb_ide_amountPcLP = array_key_exists('ide_amount',$vPcLP) ? $vPcLP['ide_amount'] : ''; |
| 223 | $lb_ivacobradox100PcLP = array_key_exists('ivacobradox100',$vPcLP) ? $vPcLP['ivacobradox100'] : ''; |
| 224 | $lb_ivacobradototalPcLP = array_key_exists('ivacobradototal',$vPcLP) ? $vPcLP['ivacobradototal'] : ''; |
| 225 | $lb_numCashNotaPcLP = array_key_exists('cash_nota_num',$vPcLP) ? $vPcLP['cash_nota_num'] : ''; |
| 226 | $lb_tienda_idPcLP = $tienda_idPcLP; |
| 227 | $lb_clientePcLP = array_key_exists('cliente',$vPcLP) ? $vPcLP['cliente'] : ''; |
| 228 | $lb_tipoFacturaPcLP = array_key_exists('factura',$vPcLP) ? $vPcLP['factura'] : ''; |
| 229 | $lb_numFacturaPcLP = array_key_exists('factura_numero',$vPcLP) ? $vPcLP['factura_numero'] : ''; |
| 230 | $lb_empresa_idPcLP = array_key_exists('empresa_id',$vPcLP) ? $vPcLP['empresa_id'] : ''; |
| 231 | $lb_tipo_cash_notaPcLP = array_key_exists('tipo_cash_nota',$vPcLP) ? $vPcLP['tipo_cash_nota'] : ''; |
| 232 | $lb_cobra_ivaPcLP = array_key_exists('cobra_iva',$vPcLP) ? $vPcLP['cobra_iva'] : ''; |
| 233 | $lb_iva_incluidoPcLP = array_key_exists('iva_incluido',$vPcLP) ? $vPcLP['iva_incluido'] : ''; |
| 234 | $lb_cash_num_cobro_ivaPcLP = array_key_exists('cash_num_cobro_iva',$vPcLP) ? $vPcLP['cash_num_cobro_iva'] : ''; |
| 235 | |
| 236 | |
| 237 | if($tipoPcLP == 'ingreso') |
| 238 | { |
| 239 | $withdrawalPcLP = 0.00; |
| 240 | $depositPcLP = $vPcLP['deposit_total']; |
| 241 | } |
| 242 | else |
| 243 | { |
| 244 | $withdrawalPcLP = $vPcLP['deposit_total']; |
| 245 | $depositPcLP = 0.00; |
| 246 | } |
| 247 | |
| 248 | $arrInfoLink= SolicitaLinkBancario( |
| 249 | array('link'=>$vPcLP[$tablaPcLP.'_id'] |
| 250 | ,'link_to'=>$tablaPcLP |
| 251 | ,'tienda_id'=>$tienda_idPcLP |
| 252 | ,'withdrawal'=>$withdrawalPcLP |
| 253 | ,'deposit'=>$depositPcLP |
| 254 | ,'cash'=>0 |
| 255 | ,'monto_acta'=>$importe_originalPcLP |
| 256 | ,'fecha'=>$fechaPcLP |
| 257 | ,'banco_mov_tipo_id'=>'' |
| 258 | ,'banco_cuenta_id'=>$banco_cuenta_idPcLP |
| 259 | ,'idex100'=>$ide_percentPcLP |
| 260 | ,'idetotal'=>$lb_ide_amountPcLP |
| 261 | ,'factura'=>$lb_tipoFacturaPcLP |
| 262 | ,'ivacobradox100'=>$lb_ivacobradox100PcLP |
| 263 | ,'ivacobradototal'=>$lb_ivacobradototalPcLP |
| 264 | ,'empresa_id'=>$lb_empresa_idPcLP |
| 265 | ,'factura_numero'=>$lb_numFacturaPcLP |
| 266 | ,'cash_nota_num'=>$lb_numCashNotaPcLP |
| 267 | ,'cliente'=>$lb_clientePcLP |
| 268 | ,'tipo_cash_nota'=>$lb_tipo_cash_notaPcLP |
| 269 | ,'cobra_iva'=>$lb_cobra_ivaPcLP |
| 270 | ,'cash_num_cobro_iva'=>$lb_cash_num_cobro_ivaPcLP |
| 271 | ,'iva_incluido'=>$lb_iva_incluidoPcLP) |
| 272 | ,$usuario); |
| 273 | |
| 274 | $updateFields = ''; |
| 275 | |
| 276 | if( array_key_exists('link_id',$arrInfoLink) && $arrInfoLink['link_id']===FALSE) |
| 277 | { |
| 278 | $vPcLP['banco_cuenta_mov_link_id']='pendiente'; |
| 279 | $vPcLP['comentario'] .= "<li>LPA($fechaLPA): ". $arrInfoLink['mensaje']; |
| 280 | |
| 281 | } |
| 282 | elseif(array_key_exists('link_id',$arrInfoLink)) |
| 283 | { |
| 284 | $vPcLP['comentario'] = "Tenía LINK PENDIENTE, se arregló el $fechaLPA al $origenLPA."; |
| 285 | $vPcLP['banco_cuenta_mov_link_id']=$arrInfoLink['link_id']; |
| 286 | $updateFields = ", deposit_fecha = '$arrInfoLink[deposit_fecha]' "; |
| 287 | |
| 288 | $bcm_id = $arrInfoLink['bcm_id']; |
| 289 | $link_num_ref = $arrInfoLink['ref_num']; |
| 290 | $referencia = $arrInfoLink['referencia']; |
| 291 | } |
| 292 | //Update del aCuenta |
| 293 | $sql[] = "UPDATE $tablaPcLP SET |
| 294 | banco_cuenta_mov_link_id = '$vPcLP[banco_cuenta_mov_link_id]', |
| 295 | numero_referencia = '$link_num_ref', |
| 296 | referencia = '$referencia', |
| 297 | comentario = '$vPcLP[comentario]', |
| 298 | ultimo_cambio = '$fechaLPA', |
| 299 | ultimo_cambio_por = '$usuario', |
| 300 | fecha_capturado = '$fechaLPA', |
| 301 | $updateFields |
| 302 | WHERE ".$tablaPcLP.'_id'." = '".$vPcLP[$tablaPcLP.'_id']."'"; |
| 303 | |
| 304 | //Insert del contramovimiento en cuentaT. |
| 305 | |
| 306 | if( array_key_exists('link_id',$arrInfoLink) && $arrInfoLink['link_id']!=FALSE) |
| 307 | { |
| 308 | // Leemos el primer movimiento en cuentaT. |
| 309 | |
| 310 | $arrcuentaT = ia_singleton("SELECT * FROM cuentat_mov WHERE origen_mov_id = '".$vPcLP[$tablaPcLP.'_id']."'"); |
| 311 | |
| 312 | if(is_array($arrcuentaT)){ |
| 313 | |
| 314 | $cuentaT_mov_id=ia_guid(); |
| 315 | $comentario="LINK BANCARIO, DEL " . $arrcuentaT['remarks'] ."<br/>REFERENCIA: <strong>$arrInfoLink[ref_num]</strong>."; |
| 316 | $ctaTMovIDOriginal = $arrcuentaT['cuentaT_mov_id']; |
| 317 | $appOrigen = $arrcuentaT['app_origen']; |
| 318 | |
| 319 | $sql[]="UPDATE cuentat_mov SET contra_mov_id='$cuentaT_mov_id' WHERE cuentaT_mov_id='$ctaTMovIDOriginal'"; |
| 320 | |
| 321 | |
| 322 | if($tipoPcLP == 'ingreso') |
| 323 | { |
| 324 | $sql[]="INSERT INTO cuentat_mov( |
| 325 | cuentaT_mov_id |
| 326 | ,cuentaT_id |
| 327 | ,fecha |
| 328 | ,cuentaT_tipo_mov_id |
| 329 | ,egreso |
| 330 | ,quantity_total |
| 331 | ,moneda_id |
| 332 | ,tipo_cambio |
| 333 | ,banco_cuenta_id |
| 334 | ,referencia |
| 335 | ,remarks |
| 336 | ,banco_cuenta_mov_link_id |
| 337 | ,alta_por |
| 338 | ,ultimo_cambio_por |
| 339 | ,esta_en |
| 340 | ,alta_db |
| 341 | ,ultimo_cambio |
| 342 | ,tipo |
| 343 | ,origen_mov_id |
| 344 | ,contra_mov_id |
| 345 | ,app_origen) |
| 346 | VALUES( |
| 347 | '$cuentaT_mov_id' |
| 348 | ,'$arrcuentaT[cuentaT_id]' |
| 349 | ,'$fechaLPA' |
| 350 | ,".stritc($vPcLP['metodo_pago_id']) |
| 351 | .stritc($vPcLP[$campoQuantity]) |
| 352 | .stritc($vPcLP['quantity_total']) |
| 353 | .stritc($vPcLP['moneda_id']) |
| 354 | .stritc($vPcLP['tipo_cambio']) |
| 355 | .stritc($vPcLP[$campoBancoCuenta]) |
| 356 | .stritc(array_key_exists('referencia',$vPcLP) ? $vPcLP['referencia'] : '') |
| 357 | .stritc($comentario) |
| 358 | .stritc($arrInfoLink['link_id']) |
| 359 | .stritc($usuario) |
| 360 | .stritc($usuario) |
| 361 | ."'done' |
| 362 | ,'$fechaLPA' |
| 363 | ,'$fechaLPA' |
| 364 | ,'Egreso' |
| 365 | ,'$ctaTMovIDOriginal' |
| 366 | ,'$ctaTMovIDOriginal' |
| 367 | ,'$appOrigen')"; |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | $sql[]="INSERT INTO cuentat_mov( |
| 372 | cuentaT_mov_id |
| 373 | ,cuentaT_id |
| 374 | ,fecha |
| 375 | ,cuentaT_tipo_mov_id |
| 376 | ,monto |
| 377 | ,quantity_total |
| 378 | ,moneda_id |
| 379 | ,tipo_cambio |
| 380 | ,banco_cuenta_id |
| 381 | ,referencia |
| 382 | ,remarks |
| 383 | ,banco_cuenta_mov_link_id |
| 384 | ,alta_por |
| 385 | ,ultimo_cambio_por |
| 386 | ,esta_en |
| 387 | ,alta_db |
| 388 | ,ultimo_cambio |
| 389 | ,tipo |
| 390 | ,origen_mov_id |
| 391 | ,contra_mov_id |
| 392 | ,app_origen) |
| 393 | VALUES( |
| 394 | '$cuentaT_mov_id' |
| 395 | ,'$arrcuentaT[cuentaT_id]' |
| 396 | ,'$fechaLPA' |
| 397 | ,".stritc($vPcLP['metodo_pago_id']) |
| 398 | .stritc($vPcLP[$campoQuantity]) |
| 399 | .stritc($vPcLP['quantity_total']) |
| 400 | .stritc($vPcLP['moneda_id']) |
| 401 | .stritc($vPcLP['tipo_cambio']) |
| 402 | .stritc($vPcLP[$campoBancoCuenta]) |
| 403 | .stritc(array_key_exists('referencia',$vPcLP) ? $vPcLP['referencia'] : '') |
| 404 | .stritc($comentario) |
| 405 | .stritc($arrInfoLink['link_id']) |
| 406 | .stritc($usuario) |
| 407 | .stritc($usuario) |
| 408 | ."'done' |
| 409 | ,'$fechaLPA' |
| 410 | ,'$fechaLPA' |
| 411 | ,'Ingreso' |
| 412 | ,'$ctaTMovIDOriginal' |
| 413 | ,'$ctaTMovIDOriginal' |
| 414 | ,'$appOrigen')"; |
| 415 | } |
| 416 | } |
| 417 | generayGuardaaCuentasdeBancoMov($bcm_id); |
| 418 | } |
| 419 | if(ia_transaction($sql)) |
| 420 | { |
| 421 | ia_errores_a_dime(); |
| 422 | |
| 423 | if($gIAsql['trace']) |
| 424 | ia_errores_a_dime("sql_trace=".print_r($gIAsql['sql_trace'],true)); |
| 425 | } |
| 426 | |
| 427 | //echo "<pre>".print_r($sql, true)."</pre>"; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | //Aquí arreglamos los links pendientes de transferencias bancarias. |
| 432 | $sqlLP = "SELECT * FROM banco_cuenta_trans_pend"; |
| 433 | $arrPcLP = ia_sqlArrayIndx($sqlLP); |
| 434 | |
| 435 | if(is_array($arrPcLP)) foreach($arrPcLP as $kPcLP=>$vPcLP) |
| 436 | { |
| 437 | //Primero buscamos el movimiento original. Haremos una función mejor. |
| 438 | $usuario = $vPcLP['alta_por']; |
| 439 | $vPcLP['origen_fecha'] = date('Y-m-d', strtotime($vPcLP['origen_fecha'])); |
| 440 | $vPcLP['destino_fecha'] = date('Y-m-d', strtotime($vPcLP['destino_fecha'])); |
| 441 | $sqlo = "SELECT banco_cuenta_mov_id FROM banco_cuenta_mov WHERE banco_cuenta_id = '$vPcLP[origen_banco_cuenta_id]' AND link_vale NOT IN ('BL', 'LT', 'STOP') AND withdrawal = $vPcLP[monto] AND fecha LIKE '$vPcLP[origen_fecha]%' ORDER BY alta_db ASC LIMIT 1"; |
| 442 | //echo "<pre>$sqlo</pre>"; |
| 443 | $bcmo_id = ia_singleread($sqlo); |
| 444 | |
| 445 | $link_exitoso = false; |
| 446 | |
| 447 | if(!empty($bcmo_id) && strlen($bcmo_id) == 32) //Sí encontramos el primero, ahora solicitamos el link bancario. |
| 448 | { |
| 449 | //Solicitamos el link bancario. Si no es existoso, entonces lo ponemos pendiente. |
| 450 | $arrInfoLink = SolicitaLinkBancario( |
| 451 | array('link'=>$bcmo_id |
| 452 | ,'link_to'=>'banco_cuenta_mov' |
| 453 | ,'tienda_id'=>0 |
| 454 | ,'withdrawal'=>0 |
| 455 | ,'deposit'=>$vPcLP['monto'] |
| 456 | ,'cash'=>0 |
| 457 | ,'monto_acta'=>$vPcLP['monto'] |
| 458 | ,'fecha'=>$vPcLP['destino_fecha'] |
| 459 | ,'banco_mov_tipo_id'=>'5' |
| 460 | ,'banco_cuenta_id'=>$vPcLP['destino_banco_cuenta_id'] |
| 461 | ,'idex100'=>0.00) |
| 462 | ,$usuario); |
| 463 | //echo "<pre>".print_r($arrInfoLink,true)."</pre>"; |
| 464 | if(!empty($arrInfoLink['link_id'])) |
| 465 | { |
| 466 | $link_exitoso = true; |
| 467 | $bcm_id = $arrInfoLink['bcm_id']; |
| 468 | } |
| 469 | else |
| 470 | { |
| 471 | $link_exitoso = false; |
| 472 | $link_detalle = $arrInfoLink['mensaje']; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | if($link_exitoso) |
| 477 | { |
| 478 | //$refo = empty($vPcLP['referencia']) ? "TRANSFERENCIA A ".ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$vPcLP[destino_banco_cuenta_id]'") : $vPcLP['referencia']; |
| 479 | //$refd = empty($vPcLP['referencia']) ? "TRANSFERENCIA DESDE ".ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$vPcLP[origen_banco_cuenta_id]'") : $BancoT->referencia; |
| 480 | $ctaBancariaDestino = ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$vPcLP[destino_banco_cuenta_id]'"); |
| 481 | $ctaBancariaOrigen = ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$vPcLP[origen_banco_cuenta_id]'"); |
| 482 | |
| 483 | $bcmoID = "&banco_cuenta_mov_id=$bcmo_id"; |
| 484 | $bcmID = "&banco_cuenta_mov_id=$bcm_id"; |
| 485 | |
| 486 | $refo = "<br/>LINK A <a title='$ctaBancariaDestino' href='../cobranza/edocta.php?ACC=CB&ECO=SI&banco_cuenta_id=$vPcLP[destino_banco_cuenta_id]$bcmID' target='_blank'><strong>$ctaBancariaDestino</strong></a>"; |
| 487 | $refd = "<br/>LINK DESDE <a title='$ctaBancariaOrigen' href='../cobranza/edocta.php?ACC=CB&ECO=SI&banco_cuenta_id=$vPcLP[origen_banco_cuenta_id]$bcmoID' target='_blank'><strong>$ctaBancariaOrigen</strong></a>"; |
| 488 | |
| 489 | $refo = addslashes($refo); |
| 490 | $refd = addslashes($refd); |
| 491 | |
| 492 | $sql[] = "UPDATE banco_cuenta_mov SET |
| 493 | usado = '$vPcLP[monto]', |
| 494 | link_vale = 'LT', |
| 495 | puede_editar = 'No', |
| 496 | banco_mov_tipo_id = '18', |
| 497 | remarks = '$refo', |
| 498 | ultimo_cambio = CURRENT_TIMESTAMP, |
| 499 | ultimo_cambio_por = '$usuario' WHERE banco_cuenta_mov_id = '$bcmo_id' LIMIT 1"; |
| 500 | $sql[] = "UPDATE banco_cuenta_mov SET remarks = '$refd', banco_mov_tipo_id = '18', ultimo_cambio = CURRENT_TIMESTAMP, ultimo_cambio_por = '$usuario' WHERE banco_cuenta_mov_id = '$bcm_id' LIMIT 1"; |
| 501 | $sql[] = "DELETE FROM banco_cuenta_trans_pend WHERE banco_cuenta_trans_pend_id = '$vPcLP[banco_cuenta_trans_pend_id]' LIMIT 1"; |
| 502 | $sql[] = "UPDATE banco_cuenta_trans SET |
| 503 | activo='Si', |
| 504 | puede_borrar='No', |
| 505 | status='COMPLETA', |
| 506 | banco_cuenta_mov_link_id='$arrInfoLink[link_id]', |
| 507 | numero_referencia='$arrInfoLink[ref_num]', |
| 508 | remarks='$refd', |
| 509 | fecha_capturado = CURRENT_TIMESTAMP |
| 510 | WHERE banco_cuenta_mov_link_id = '$vPcLP[banco_cuenta_trans_pend_id]'"; |
| 511 | |
| 512 | } |
| 513 | else |
| 514 | { |
| 515 | $sql[] = "UPDATE banco_cuenta_trans_pend SET ultimo_cambio = CURRENT_TIMESTAMP, ultimo_cambio_por = '$usuario' WHERE banco_cuenta_trans_pend_id = '$vPcLP[banco_cuenta_trans_pend_id]' LIMIT 1"; |
| 516 | } |
| 517 | //echo "<pre>".print_r($sql,true)."</pre>"; |
| 518 | |
| 519 | if(ia_transaction($sql)) |
| 520 | { |
| 521 | ia_errores_a_dime(); |
| 522 | |
| 523 | if($gIAsql['trace']) |
| 524 | ia_errores_a_dime("sql_trace=".print_r($gIAsql['sql_trace'],true)); |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | |
| 529 | } |
| 530 | |
| 531 | function links_pendientes($andWhere='',$orderby='') |
| 532 | { |
| 533 | $usuario = $_SESSION['usuario']; |
| 534 | $su = usuarioTipoRony($_SESSION['usuario_id']) ? true:false; |
| 535 | $usuario_id = $_SESSION['usuario_id']; |
| 536 | if($su) |
| 537 | $where = "AND banco_cuenta_id != '' AND banco_cuenta_mov_link_id = 'pendiente'"; |
| 538 | else |
| 539 | $where = "AND banco_cuenta_id != '' AND banco_cuenta_mov_link_id = 'pendiente' AND alta_por = '$usuario'"; |
| 540 | |
| 541 | $arr=array(); |
| 542 | $sql="(SELECT cheque_pago_id AS id, cheque_id AS docto_id, '' AS docto, 'cheque' AS tipo, fecha, quantity, quantity_total, deposit_total, banco_cuenta_id, comentario AS comentario, alta_por as usuario, moneda_id as moneda, tipo_cambio as TC FROM cheque_pago WHERE banco_cuenta_id != '' AND banco_cuenta_mov_link_id = 'pendiente' $where) |
| 543 | UNION (SELECT pagare_pago_id AS id, pagare_id AS docto_id, '' AS docto, 'pagare' AS tipo, fecha, quantity, quantity_total, deposit_total, banco_cuenta_id, comentario AS comentario, alta_por as usuario, moneda_id as moneda, tipo_cambio as TC FROM pagare_pago WHERE banco_cuenta_id != '' AND banco_cuenta_mov_link_id = 'pendiente' $where) |
| 544 | UNION (SELECT vale_id AS id, vale_id AS docto_id, '' AS docto, 'vale' AS tipo, fecha, quantity_recibido as quantity, quantity_total, deposit_total, banco_cuenta_id, comentario AS comentario, alta_por as usuario, moneda_id as moneda, tipo_cambio as TC FROM vale WHERE banco_cuenta_id != '' AND banco_cuenta_mov_link_id = 'pendiente' $where) |
| 545 | UNION (SELECT deuda_pago_id AS id, deuda_id AS docto_id, '' AS docto, 'deuda' AS tipo, fecha, quantity, quantity_total, deposit_total, banco_cuenta_id, comentario AS comentario, alta_por as usuario, moneda_id as moneda, tipo_cambio as TC FROM deuda_pago WHERE banco_cuenta_id != '' AND banco_cuenta_mov_link_id = 'pendiente' $where) |
| 546 | UNION (SELECT banco_cuenta_trans_pend_id AS id, origen_banco_cuenta_id AS docto_id, '' AS docto, 'banco_cuenta_mov' AS tipo, alta_db AS fecha, monto AS quantity, monto AS quantity_total, monto AS deposit_total, destino_banco_cuenta_id AS banco_cuenta_id, referencia AS comentario, alta_por as usuario, '' AS moneda, '1.00' AS TC FROM banco_cuenta_trans_pend) ORDER BY tipo, fecha"; |
| 547 | $lps=ia_sqlArray($sql,'id'); |
| 548 | if($lps) foreach($lps as $k=>$d) { |
| 549 | $id=$k; |
| 550 | $arr[$id]=array('id'=>$k,'docto'=>'','tipo'=>"<a title='Ir al documento' href='../backoffice/$d[tipo].php?iah=e&id=$d[docto_id]' target='_blank'>$d[tipo]</a>" |
| 551 | ,'fecha'=>$d['fecha'], 'quantity'=>$d['quantity'],'quantity_total'=>$d['quantity_total'] |
| 552 | ,'deposit_total'=>$d['deposit_total'],'banco_cuenta_id'=>$d['banco_cuenta_id'],'comentario'=>$d['comentario'] |
| 553 | ,'usuario'=>$d['usuario'],'moneda'=>$d['moneda'],'TC'=>$d['TC'] |
| 554 | ); |
| 555 | switch ($d['tipo']) |
| 556 | { |
| 557 | case 'cheque': |
| 558 | $arr[$id]['docto']=leeaCuenta('cheque_pago', $id, '', '', 'label', true); |
| 559 | break; |
| 560 | |
| 561 | case 'pagare': |
| 562 | $arr[$id]['docto']=leeaCuenta('pagare_pago', $id, '', '', 'label', true); |
| 563 | break; |
| 564 | |
| 565 | case 'deuda': |
| 566 | $arr[$id]['docto']=leeaCuenta('deuda_pago', $id, '', '', 'label', true); |
| 567 | break; |
| 568 | |
| 569 | case 'vale': |
| 570 | if(VALE_PAGO_MULTIPLE) { |
| 571 | $arr[$id]['docto']=leeaCuenta('vale_pago', $id, '', '', 'label', true); |
| 572 | } else { |
| 573 | $arr[$id]['docto']=leeaCuenta('vale', $id, '', '', 'label', true); |
| 574 | } |
| 575 | break; |
| 576 | |
| 577 | case 'banco_cuenta_mov': |
| 578 | $bco = ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$d[docto_id]'"); |
| 579 | $bcd = ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$d[banco_cuenta_id]'"); |
| 580 | |
| 581 | $pbco = puedeCuentaBancaria('',$d['docto_id'],'R/O'); |
| 582 | $pbcd = puedeCuentaBancaria('',$d['banco_cuenta_id'],'R/O'); |
| 583 | |
| 584 | if($pbco['puede']) |
| 585 | $lbco = "<a title='$bco' href='../cobranza/edocta.php?ACC=CB&ECO=SI&banco_cuenta_id=$d[docto_id]' target='_blank'>$bco</a>"; |
| 586 | else |
| 587 | $lbco = "$bco"; |
| 588 | |
| 589 | if($pbcd['puede']) |
| 590 | $lbcd = "<a title='$bcd' href='../cobranza/edocta.php?ACC=CB&ECO=SI&banco_cuenta_id=$d[banco_cuenta_id]' target='_blank'>$bcd</a>"; |
| 591 | else |
| 592 | $lbcd = "$bcd"; |
| 593 | |
| 594 | $arr[$id]['docto']="TRANSFERENCIA DE <strong>$lbco</strong> A <strong>$lbcd</strong> POR <strong>$ ".echonf($d['quantity'],true)."</strong>"; |
| 595 | $arr[$id]['tipo']="Transferencia Bancaria"; |
| 596 | break; |
| 597 | |
| 598 | default: |
| 599 | $arr[$id]['docto']='Sin información.'; |
| 600 | break; |
| 601 | } |
| 602 | } |
| 603 | return $arr; |
| 604 | } |
| 605 | |
| 606 | function hazLabeldeDocto($acta_arr, $padre=false) |
| 607 | { |
| 608 | $label = ''; |
| 609 | $label .= $acta_arr['actapadre_tiendaclv'] != '' ? $acta_arr['actapadre_tiendaclv'].', ' : ''; |
| 610 | $label .= $acta_arr['acta_desc'] != '' ? $acta_arr['acta_desc'].'' : ' '; |
| 611 | $label .= $acta_arr['actapadre_number'] != '' ? ':'.$acta_arr['actapadre_number'].', ' : ', '; |
| 612 | if($padre) |
| 613 | $label .= $acta_arr['actapadre_quantity'] != '' ? '$'.number_format($acta_arr['actapadre_quantity'], 2, '.', ',') : ''; |
| 614 | else |
| 615 | $label .= $acta_arr['acta_quantity'] != '' ? '<strong>$'.number_format($acta_arr['acta_quantity'], 2, '.', ',').'</strong>' : ''; |
| 616 | $label .= '.'; |
| 617 | $label .= $acta_arr['actapadre_nombre'] != '' ? '<br>'.$acta_arr['actapadre_nombre'] : ''; |
| 618 | $label .= $acta_arr['actapadre_nombre_cheque'] != '' ? '<br>'.'Cheque a nombre de: ' . BoldaString($acta_arr['actapadre_nombre_cheque']) : ''; |
| 619 | $label .= $acta_arr['acta_ctaTmov'] != '' ? '<br>'.$acta_arr['acta_ctaTmov'] : ''; |
| 620 | |
| 621 | return $label; |
| 622 | } |
| 623 | |
| 624 | function tablapadre($tablahija) |
| 625 | { |
| 626 | switch($tablahija) |
| 627 | { case 'cuentat_mov': case 'banco_cuenta_mov': case 'fiduciario_reembolso': case 'vale'://VCA 28-ene-2021 vale_pago case 'vale': |
| 628 | return $tablahija; |
| 629 | break; |
| 630 | |
| 631 | default: |
| 632 | $arr = explode("_", $tablahija); |
| 633 | return $arr[0]; |
| 634 | break; |
| 635 | } |
| 636 | |
| 637 | } |
| 638 | |
| 639 | function leeaCuenta($link_to, $lid, $bcml_id='', $tienda_id='', $return='arr', $monto_padre=false) |
| 640 | { |
| 641 | $acta_arr_def = array ( "acta_numero" => "", |
| 642 | "acta_fecha" => "", |
| 643 | "acta_quantity" => 0.00, |
| 644 | "acta_alta_por" => "", |
| 645 | "acta_moneda" => "", |
| 646 | "acta_tipo_cambio" => 0.00, |
| 647 | "acta_desc" => "", |
| 648 | "acta_comentario" => "", |
| 649 | "acta_id" => "", |
| 650 | "acta_ctaTmov" => "", |
| 651 | "actapadre_nombre" => "", |
| 652 | "actapadre_nombre_cheque" => "", |
| 653 | "actapadre_fecha" => "", |
| 654 | "actapadre_tienda" => "", |
| 655 | "actapadre_tiendaclv" => "", |
| 656 | "actapadre_remarks" => "", |
| 657 | "actapadre_number" => "", |
| 658 | "actapadre_quantity" => 0.00, |
| 659 | "actapadre_total_payments" => 0.00, |
| 660 | "actapadre_moneda" => "", |
| 661 | "actapadre_id" => "", |
| 662 | "actapadre" => "", |
| 663 | "acta_cuentat_id" => "", |
| 664 | "acta_banco_cuenta_id" => "", |
| 665 | "acta_deposit_total" => 0.00, |
| 666 | "acta_app_origen" => "", |
| 667 | "remarks" => "", |
| 668 | "acta_quantity_total" => 0.00,); |
| 669 | |
| 670 | if(empty($link_to) || empty($lid)) |
| 671 | return $acta_arr_def; |
| 672 | |
| 673 | $acta_id = $lid; |
| 674 | $acta_tbl = $link_to; |
| 675 | $acta_id_nombre = $acta_tbl . '_id'; |
| 676 | $actapadre_tbl = tablapadre($acta_tbl); |
| 677 | $actapadre_id_nombre = $actapadre_tbl . '_id'; |
| 678 | $actapadre_id = ''; |
| 679 | |
| 680 | //Leer el a cuenta y su padre son comunes. Excepto para vales. Ahí no nos interesan los acuentas, sólo el padre. |
| 681 | $sql = "SELECT * FROM $acta_tbl WHERE $acta_id_nombre = ". strit($acta_id); |
| 682 | $acta_arr = ia_singleton($sql); |
| 683 | |
| 684 | //echo "<pre>sql: $sql<br>acta_arr: ".print_r($acta_arr, true)."</pre>"; |
| 685 | |
| 686 | if(empty($acta_arr)) |
| 687 | if($link_to=='cuentat_mov') |
| 688 | $acta_arr = ia_singleton("SELECT * FROM cuentat_a_banco WHERE banco_cuenta_mov_link_id = ". strit($bcml_id)); |
| 689 | |
| 690 | if(empty($acta_arr)) |
| 691 | return false; |
| 692 | //print_r($acta_arr); |
| 693 | //echo "<br/>".$acta_tbl; |
| 694 | $acta_arr_def['actapadre'] = $actapadre_tbl; |
| 695 | |
| 696 | |
| 697 | //JOSE toma el control 28-ene-2021 |
| 698 | |
| 699 | if($acta_tbl == 'vale' || $acta_tbl == 'VALE') |
| 700 | { |
| 701 | $actapadre_arr = $acta_arr; |
| 702 | $actapadre_id = array_key_exists($acta_tbl.'_id',$acta_arr) ? $acta_arr[$acta_tbl.'_id'] : 'N/A'; |
| 703 | } |
| 704 | else |
| 705 | { |
| 706 | $actapadre_id = array_key_exists($actapadre_id_nombre,$acta_arr) ? $acta_arr[$actapadre_id_nombre] : 'N/A'; |
| 707 | $sql = "SELECT * FROM $actapadre_tbl WHERE $actapadre_id_nombre = ". strit($actapadre_id); |
| 708 | $actapadre_arr = ia_singleton($sql); |
| 709 | } |
| 710 | |
| 711 | // echo "<pre><br>: ".print_r($acta_arr_def, true)."</pre>"; |
| 712 | // echo "<pre>sql: $sql<br>actapadre_arr: ".print_r($actapadre_arr, true)."</pre>"; |
| 713 | |
| 714 | //Llenamos los datos del a cuenta. Estos son comunes a todos. |
| 715 | |
| 716 | $acta_arr_def['acta_fecha'] = array_key_exists('fecha',$acta_arr) ? ia_htmlentities(date('d-m-Y', strtotime($acta_arr['fecha']))) : ''; |
| 717 | |
| 718 | //Monto que afectó a la Cuenta T |
| 719 | if(array_key_exists('quantity_ctat',$acta_arr)) |
| 720 | $acta_arr_def['acta_quantity'] = ia_htmlentities($acta_arr['quantity_ctat']); |
| 721 | elseif(array_key_exists('quantity',$acta_arr)) |
| 722 | $acta_arr_def['acta_quantity'] = ia_htmlentities($acta_arr['quantity']); |
| 723 | elseif(array_key_exists('monto',$acta_arr) && !empty($acta_arr['monto'])) |
| 724 | $acta_arr_def['acta_quantity'] = ia_htmlentities($acta_arr['monto']); |
| 725 | |
| 726 | //Monto Total, monto bruto, sin tomar en cuenta comisiones |
| 727 | if(array_key_exists('quantity_total',$acta_arr)) |
| 728 | $acta_arr_def['acta_quantity_total'] = ia_htmlentities($acta_arr['quantity_total']); |
| 729 | else |
| 730 | $acta_arr_def['acta_quantity_total'] = $acta_arr_def['acta_quantity']; |
| 731 | |
| 732 | //Monto del depósito |
| 733 | if(array_key_exists('deposit_total',$acta_arr)) |
| 734 | $acta_arr_def['acta_deposit_total'] = ia_htmlentities($acta_arr['deposit_total']); |
| 735 | elseif(array_key_exists('deposit',$acta_arr)) |
| 736 | { |
| 737 | if($acta_arr['deposit'] > 0) |
| 738 | $acta_arr_def['acta_deposit_total'] = ia_htmlentities($acta_arr['deposit']); |
| 739 | else |
| 740 | $acta_arr_def['acta_deposit_total'] = ia_htmlentities($acta_arr['withdrawal']); |
| 741 | } |
| 742 | |
| 743 | //Monto |
| 744 | if($link_to == 'cuentat_mov') |
| 745 | { |
| 746 | if($acta_arr['tipo'] == 'Egreso') |
| 747 | $acta_arr_def['acta_quantity'] = ia_htmlentities($acta_arr['egreso']); |
| 748 | else |
| 749 | $acta_arr_def['acta_quantity'] = ia_htmlentities($acta_arr['monto']); |
| 750 | $actapadre_tbl = ''; //Rony pidió que se quitara el 29-12-2015 $actapadre_tbl = 'LINK DE CUENTA T' |
| 751 | } |
| 752 | elseif($link_to == 'banco_cuenta_mov') |
| 753 | { |
| 754 | $acta_arr_def['acta_quantity'] = ia_htmlentities($acta_arr['withdrawal']); |
| 755 | $acta_arr_def['acta_deposit_total'] = $acta_arr_def['acta_quantity_total'] = $acta_arr_def['acta_quantity']; |
| 756 | $actapadre_tbl = 'TRANSFERENCIA ENTRE CUENTAS'; |
| 757 | } |
| 758 | |
| 759 | $acta_arr_def['acta_alta_por'] = array_key_exists('alta_por',$acta_arr) ? ia_htmlentities($acta_arr['alta_por']) : 'N/A'; |
| 760 | $acta_arr_def['acta_moneda'] = array_key_exists('moneda_id',$acta_arr) ? ia_htmlentities(ia_singleread("SELECT moneda FROM moneda WHERE moneda_id = ". strit($acta_arr['moneda_id']))) : 'N/A'; |
| 761 | $acta_arr_def['acta_tipo_cambio'] = array_key_exists('tipo_cambio',$acta_arr) ? ia_htmlentities($acta_arr['tipo_cambio']) : 'N/A'; |
| 762 | $acta_arr_def['acta_desc'] = strtoupper($actapadre_tbl); |
| 763 | $acta_arr_def['acta_id'] = $acta_id; |
| 764 | |
| 765 | $acta_arr_def['acta_app_origen'] = array_key_exists('app_origen',$acta_arr) ? ia_htmlentities($acta_arr['app_origen']) : 'N/A'; |
| 766 | |
| 767 | if($link_to === 'cheque_pago' || $link_to === 'pagare_pago' || (VALE_PAGO_MULTIPLE && $link_to === 'vale_pago')) |
| 768 | $acta_arr_def['acta_numero'] = array_key_exists('numero',$acta_arr) ? 'A CUENTA # '.ia_htmlentities($acta_arr['numero']) : ''; |
| 769 | |
| 770 | if($link_to == 'banco_cuenta_mov') |
| 771 | $acta_arr_def['acta_moneda'] = ''; |
| 772 | |
| 773 | // JJ 29-01-2021 |
| 774 | // Aata comentario otiginal |
| 775 | /* if(array_key_exists('comentario',$acta_arr)) |
| 776 | $acta_arr_def['acta_comentario'] = ia_htmlentities($acta_arr['comentario']); |
| 777 | else if(array_key_exists('remarks',$acta_arr)) |
| 778 | $acta_arr_def['acta_comentario'] = ia_htmlentities($acta_arr['remarks']); */ |
| 779 | if(array_key_exists('comentario',$acta_arr)) { |
| 780 | $comentario = ''; |
| 781 | if ($link_to === 'cheque_pago') { |
| 782 | $comentario = "<a href='../backoffice/cheque.php?iah=e&id=$actapadre_arr[cheque_id]'>Ir al Cheque #$actapadre_arr[numero]</a>"; |
| 783 | } elseif ($link_to === 'pagare_pago') { |
| 784 | $comentario = "<a href='../backoffice/pagare.php?iah=e&id=$actapadre_arr[pagare_id]'>Ir al Pagaré #$actapadre_arr[numero]</a>"; |
| 785 | } elseif ($link_to === 'vale_pago' || $link_to === 'vale') { //VCA Compatibilidad con el vale anterior. |
| 786 | $comentario = "<a href='../backoffice/vale.php?iah=e&id=$actapadre_arr[vale_id]'>Ir al Vale #$actapadre_arr[vale_number]</a>"; |
| 787 | } else { |
| 788 | $comentario = ia_htmlentities($acta_arr['comentario']); |
| 789 | } |
| 790 | $acta_arr_def['acta_comentario'] = $comentario; |
| 791 | } elseif (array_key_exists('remarks',$acta_arr)) { |
| 792 | $comentario = ''; |
| 793 | if ($link_to === 'cheque_pago') { |
| 794 | $comentario = "<a href='../backoffice/cheque.php?iah=e&id=$actapadre_arr[cheque_id]'>Ir al Cheque #$actapadre_arr[numero]</a>"; |
| 795 | } elseif ($link_to === 'pagare_pago') { |
| 796 | $comentario = "<a href='../backoffice/pagare.php?iah=e&id=$actapadre_arr[pagare_id]'>Ir al Pagaré #$actapadre_arr[numero]</a>"; |
| 797 | } elseif ($link_to === 'vale_pago' || $link_to === 'vale') { //VCA Compatibilidad con el vale anterior. |
| 798 | $comentario = "<a href='../backoffice/vale.php?iah=e&id=$actapadre_arr[vale_id]'>Ir al Vale #$actapadre_arr[vale_number]</a>"; |
| 799 | } else { |
| 800 | $comentario = ia_htmlentities(isset($acta_arr['comentario']) ? $acta_arr['comentario'] : ''); |
| 801 | } |
| 802 | $acta_arr_def['acta_comentario'] = $comentario; |
| 803 | } |
| 804 | |
| 805 | |
| 806 | if($link_to == 'banco_cuenta_mov') |
| 807 | $acta_arr_def['acta_comentario'] = $acta_arr['remarks']; |
| 808 | |
| 809 | if($actapadre_id == '' || $actapadre_id == NULL) |
| 810 | $acta_tbl = 'link_manual'; |
| 811 | |
| 812 | switch($acta_tbl) |
| 813 | { |
| 814 | case 'cheque_pago': |
| 815 | |
| 816 | //Vamos a calcular el nombre en el Cheque. |
| 817 | if(array_key_exists('cliente_id',$actapadre_arr)) if($actapadre_arr['cliente_id'] != '') |
| 818 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cliente_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = ". strit($actapadre_arr['cliente_id']))) : 'N/A'; |
| 819 | else if($actapadre_arr['cliente_proveedor_id'] != '') |
| 820 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cliente_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = ". strit($actapadre_arr['cliente_id']))) : 'N/A'; |
| 821 | else if($actapadre_arr['nombre'] != '') //El campo nombre está vacío, entonces hay que buscar al cliente o proveedor. |
| 822 | $acta_arr_def['actapadre_nombre'] = array_key_exists('nombre',$actapadre_arr) ? ia_htmlentities($actapadre_arr['nombre']) : 'N/A'; |
| 823 | else |
| 824 | $acta_arr_def['actapadre_nombre'] = 'Este cheque no tiene asociado ningún Cliente o Proveedor, ni tiene establecido un nombre.'; |
| 825 | |
| 826 | if(array_key_exists('name_on_check',$actapadre_arr) && $actapadre_arr['name_on_check'] != 'Same as client') |
| 827 | $acta_arr_def['actapadre_nombre_cheque'] = array_key_exists('nombre',$actapadre_arr) ? ia_htmlentities($actapadre_arr['nombre']) : 'N/A'; |
| 828 | |
| 829 | //Vamos a llenar los datos del padre. |
| 830 | $acta_arr_def['actapadre_fecha'] = array_key_exists('original_date',$actapadre_arr) ? ia_htmlentities(date('d-m-Y', strtotime($actapadre_arr['original_date']))) : ''; |
| 831 | $acta_arr_def['actapadre_tienda'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 832 | $acta_arr_def['actapadre_tiendaclv'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 833 | $acta_arr_def['actapadre_remarks'] = array_key_exists('remarks',$actapadre_arr) ? ia_htmlentities($actapadre_arr['remarks']) : 'N/A'; |
| 834 | $acta_arr_def['actapadre_number'] = array_key_exists('numero',$actapadre_arr) ? ia_htmlentities($actapadre_arr['numero']) : 'N/A'; |
| 835 | $acta_arr_def['actapadre_quantity'] = array_key_exists('quantity',$actapadre_arr) ? ia_htmlentities($actapadre_arr['quantity']) : 'N/A'; |
| 836 | $acta_arr_def['actapadre_total_payments'] = array_key_exists('total_payments',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_payments']) : 'N/A'; |
| 837 | $acta_arr_def['actapadre_id'] = array_key_exists($actapadre_id_nombre,$actapadre_arr) ? ia_htmlentities($actapadre_arr[$actapadre_id_nombre]) : 'N/A'; |
| 838 | $acta_arr_def['actapadre_moneda'] = array_key_exists('moneda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT moneda FROM moneda WHERE moneda_id = ". strit($actapadre_arr['moneda_id']))) : 'N/A'; |
| 839 | |
| 840 | $acta_arr_def['acta_app_origen'] = 'A Cuenta Cheque'; |
| 841 | |
| 842 | //Extra para saber si hay un registro en la cuentaT |
| 843 | |
| 844 | $ctaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE banco_cuenta_mov_link_id = ". strit($acta_id)); |
| 845 | if($ctaT_arr) //Sí hay un movimiento en la cuentaT con el ID del a cuenta. |
| 846 | { |
| 847 | $acta_arr_def['acta_ctaTmov'] .= 'Movimiento registrado en Cuenta T de <b>' . propdeCtaT($ctaT_arr['cuentaT_id'],'usuario',true) . '</b>'; |
| 848 | } |
| 849 | |
| 850 | break; |
| 851 | |
| 852 | case 'nota_pago': |
| 853 | |
| 854 | |
| 855 | //Vamos a calcular el nombre en el Cheque. |
| 856 | if(array_key_exists('cliente_id',$actapadre_arr)) if($actapadre_arr['cliente_id'] != '') |
| 857 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cliente_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = ". strit($actapadre_arr['cliente_id']))) : 'N/A'; |
| 858 | else |
| 859 | $acta_arr_def['actapadre_nombre'] = 'Esta nota no tiene asociado ningún Cliente o Proveedor, ni tiene establecido un nombre.'; |
| 860 | |
| 861 | //Vamos a llenar los datos del padre. |
| 862 | $acta_arr_def['actapadre_fecha'] = array_key_exists('fecha',$actapadre_arr) ? ia_htmlentities(date('d-m-Y', strtotime($actapadre_arr['fecha']))) : ''; |
| 863 | $acta_arr_def['actapadre_tienda'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 864 | $acta_arr_def['actapadre_tiendaclv'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 865 | $acta_arr_def['actapadre_remarks'] = array_key_exists('remarks',$actapadre_arr) ? ia_htmlentities($actapadre_arr['remarks']) : 'N/A'; |
| 866 | $acta_arr_def['actapadre_number'] = array_key_exists('nota_number',$actapadre_arr) ? ia_htmlentities($actapadre_arr['nota_number']) : 'N/A'; |
| 867 | $acta_arr_def['actapadre_quantity'] = array_key_exists('total_quantity',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_quantity']) : 'N/A'; |
| 868 | $acta_arr_def['actapadre_total_payments'] = array_key_exists('total_payments',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_payments']) : 'N/A'; |
| 869 | $acta_arr_def['actapadre_id'] = array_key_exists($actapadre_id_nombre,$actapadre_arr) ? ia_htmlentities($actapadre_arr[$actapadre_id_nombre]) : 'N/A'; |
| 870 | |
| 871 | $ctaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE banco_cuenta_mov_link_id = ". strit($acta_id)); |
| 872 | if($ctaT_arr) //Si hay un movimiento en la cuentaT con el ID del a cuenta. |
| 873 | { |
| 874 | $acta_arr_def['actapadre_remarks'] .= '<br>Movimiento registrado en Cuenta T de <b>' . propdeCtaT($ctaT_arr['cuentaT_id'],'usuario',true). '</b>'; |
| 875 | } |
| 876 | |
| 877 | break; |
| 878 | |
| 879 | case 'pagare_pago': |
| 880 | |
| 881 | //Vamos a calcular el nombre en el Cheque. |
| 882 | if(array_key_exists('cliente_id',$actapadre_arr)) if($actapadre_arr['cliente_id'] != '') |
| 883 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cliente_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = ". strit($actapadre_arr['cliente_id']))) : 'N/A'; |
| 884 | else |
| 885 | $acta_arr_def['actapadre_nombre'] = 'Este pagaré no tiene asociado ningún Cliente o Proveedor, ni tiene establecido un nombre.'; |
| 886 | |
| 887 | //Vamos a llenar los datos del padre. |
| 888 | $acta_arr_def['actapadre_fecha'] = array_key_exists('fecha',$actapadre_arr) ? ia_htmlentities(date('d-m-Y', strtotime($actapadre_arr['fecha']))) : ''; |
| 889 | $acta_arr_def['actapadre_tienda'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 890 | $acta_arr_def['actapadre_tiendaclv'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 891 | $acta_arr_def['actapadre_remarks'] = array_key_exists('remarks',$actapadre_arr) ? ia_htmlentities($actapadre_arr['remarks']) : 'N/A'; |
| 892 | $acta_arr_def['actapadre_number'] = array_key_exists('numero',$actapadre_arr) ? ia_htmlentities($actapadre_arr['numero']) : 'N/A'; |
| 893 | $acta_arr_def['actapadre_quantity'] = array_key_exists('quantity',$actapadre_arr) ? ia_htmlentities($actapadre_arr['quantity']) : 'N/A'; |
| 894 | $acta_arr_def['actapadre_total_payments'] = array_key_exists('total_payments',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_payments']) : 'N/A'; |
| 895 | $acta_arr_def['actapadre_id'] = array_key_exists($actapadre_id_nombre,$actapadre_arr) ? ia_htmlentities($actapadre_arr[$actapadre_id_nombre]) : 'N/A'; |
| 896 | $acta_arr_def['actapadre_moneda'] = array_key_exists('moneda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT moneda FROM moneda WHERE moneda_id = ". strit($actapadre_arr['moneda_id']))) : 'N/A'; |
| 897 | |
| 898 | $acta_arr_def['acta_app_origen'] = 'A Cuenta Pagare'; |
| 899 | |
| 900 | $ctaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE banco_cuenta_mov_link_id = ". strit($acta_id)); |
| 901 | if($ctaT_arr) //Si hay un movimiento en la cuentaT con el ID del a cuenta. |
| 902 | { |
| 903 | $acta_arr_def['actapadre_remarks'] .= '<br>Movimiento registrado en Cuenta T de <b>' . propdeCtaT($ctaT_arr['cuentaT_id'],'usuario',true) . '</b>'; |
| 904 | } |
| 905 | |
| 906 | break; |
| 907 | |
| 908 | case 'link_manual': |
| 909 | $acta_arr_def['actapadre_nombre'] = array_key_exists('acta_comentario',$actapadre_arr) ? $acta_arr_def['acta_comentario'] : 'N/A'; |
| 910 | $acta_arr_def['actapadre_tienda'] = ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($tienda_id))); |
| 911 | $acta_arr_def['actapadre_tiendaclv'] = ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($tienda_id))); |
| 912 | break; |
| 913 | |
| 914 | case 'cuentat_mov': |
| 915 | |
| 916 | //Vamos a leer datos de la CuentaT. |
| 917 | if(array_key_exists('app_origen',$acta_arr) && $acta_arr['app_origen'] == 'Link Tarjetas de Credito') |
| 918 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cuentaT_id',$acta_arr) ? 'Link Tarjetas de Crédito por parte de <b>' . propdeCtaT($acta_arr['cuentaT_id'],'usuario',true) . '</b>' : 'N/A'; |
| 919 | else |
| 920 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cuentaT_id',$acta_arr) ? 'Depósito de <b>' . propdeCtaT($acta_arr['cuentaT_id'],'usuario',true) . '</b>' : 'N/A'; //Rony pidió el cambio el 29-12-2015 |
| 921 | //$acta_arr_def['actapadre_nombre'] .= array_key_exists('cuentaT_tipo_mov_id',$acta_arr) ? '<br>Tipo de depósito: <b>' . ia_htmlentities(ia_singleread("SELECT tipo FROM banco_mov_tipo WHERE banco_mov_tipo_id = ". strit($acta_arr['cuentaT_tipo_mov_id']))) . '</b>' : 'N/A'; |
| 922 | $acta_arr_def['actapadre_nombre'] .= (array_key_exists('tipo_cambio',$acta_arr) && is_numeric($acta_arr['tipo_cambio']) && $acta_arr['tipo_cambio'] > 1) ? '<br/>Tipo de Cambio: <b>'. echonf($acta_arr['tipo_cambio'], true).'</b>' : ''; |
| 923 | $acta_arr_def['acta_cuentat_id'] = array_key_exists('cuentaT_id',$acta_arr) ? $acta_arr['cuentaT_id']:null; |
| 924 | $acta_arr_def['acta_app_origen'] = 'Link de CuentaT'; |
| 925 | |
| 926 | $link_arr = ia_singleton("SELECT * FROM cuentat_a_banco WHERE banco_cuenta_mov_link_id = ". strit($acta_arr['banco_cuenta_mov_link_id'])); |
| 927 | |
| 928 | // exit; |
| 929 | //VCA 9-Nov-2023 Agrego el texto en dolares |
| 930 | $moneda_banco_id=ia_singleread("SELECT moneda_id FROM banco_cuenta WHERE banco_cuenta_id = ". strit($acta_arr['banco_cuenta_id'])); |
| 931 | |
| 932 | if($moneda_banco_id == 2 /*&& $acta_arr['afecta_cuentat'] ?? 'SI' == 'NO' && $acta_arr['factura'] ?? '' == 'DEVOLUCION'*/){ |
| 933 | $acta_arr_def['acta_moneda'] = 'USD'; |
| 934 | } |
| 935 | // echo "<pre><br>: ".print_r($acta_arr_def, true)."</pre>"; |
| 936 | |
| 937 | |
| 938 | $acta_arr_def['acta_id'] = array_key_exists('cuentat_a_banco_mov_id',$link_arr) ? $link_arr['cuentat_a_banco_mov_id']:null; |
| 939 | break; |
| 940 | |
| 941 | case 'vale_pago': |
| 942 | //Vamos a calcular el nombre en el Vale. |
| 943 | if(array_key_exists('cliente_id',$actapadre_arr)) if($actapadre_arr['cliente_id'] != '') |
| 944 | $acta_arr_def['actapadre_nombre'] = array_key_exists('cliente_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = ". strit($actapadre_arr['cliente_id']))) : 'N/A'; |
| 945 | else |
| 946 | $acta_arr_def['actapadre_nombre'] = 'Este vale no tiene asociado ningún Cliente o Proveedor, ni tiene establecido un nombre.'; |
| 947 | |
| 948 | //Vamos a llenar los datos del padre. |
| 949 | $acta_arr_def['actapadre_fecha'] = array_key_exists('fecha',$actapadre_arr) ? ia_htmlentities(date('d-m-Y', strtotime($actapadre_arr['fecha']))) : ''; |
| 950 | $acta_arr_def['actapadre_tienda'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 951 | $acta_arr_def['actapadre_tiendaclv'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 952 | $acta_arr_def['actapadre_remarks'] = array_key_exists('remarks',$actapadre_arr) ? ia_htmlentities($actapadre_arr['remarks']) : 'N/A'; |
| 953 | $acta_arr_def['actapadre_number'] = array_key_exists('vale_number',$actapadre_arr) ? ia_htmlentities($actapadre_arr['vale_number']) : 'N/A'; |
| 954 | $acta_arr_def['actapadre_quantity'] = array_key_exists('quantity',$actapadre_arr) ? ia_htmlentities($actapadre_arr['quantity']) : 'N/A'; |
| 955 | $acta_arr_def['actapadre_total_payments'] = array_key_exists('total_payments',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_payments']) : 'N/A'; |
| 956 | $acta_arr_def['actapadre_id'] = array_key_exists($actapadre_id_nombre,$actapadre_arr) ? ia_htmlentities($actapadre_arr[$actapadre_id_nombre]) : 'N/A'; |
| 957 | $acta_arr_def['actapadre_moneda'] = array_key_exists('moneda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT moneda FROM moneda WHERE moneda_id = ". strit($actapadre_arr['moneda_id']))) : 'N/A'; |
| 958 | |
| 959 | $acta_arr_def['acta_app_origen'] = 'A Cuenta Vale'; |
| 960 | |
| 961 | $ctaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE banco_cuenta_mov_link_id = ". strit($acta_id)); |
| 962 | if($ctaT_arr) //Si hay un movimiento en la cuentaT con el ID del a cuenta. |
| 963 | { |
| 964 | $acta_arr_def['actapadre_remarks'] .= '<br>Movimiento registrado en Cuenta T de <b>' . propdeCtaT($ctaT_arr['cuentaT_id'],'usuario',true) . '</b>'; |
| 965 | } |
| 966 | break; |
| 967 | |
| 968 | case 'vale': |
| 969 | |
| 970 | //Vamos a calcular el nombre en el Cheque. |
| 971 | //print_r($actapadre_arr); |
| 972 | if(array_key_exists('cliente_id',$actapadre_arr) && !empty($actapadre_arr['cliente_id'])) |
| 973 | $acta_arr_def['actapadre_nombre'] = ia_htmlentities(ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = ". strit($actapadre_arr['cliente_id']))); |
| 974 | elseif(array_key_exists('cliente',$actapadre_arr) && !empty($actapadre_arr['cliente'])) |
| 975 | $acta_arr_def['actapadre_nombre'] = ia_htmlentities($actapadre_arr['cliente']).(($actapadre_arr['cliente_de_paso'] == '1') ? ' <strong>(DE PASO)</strong>' : ''); |
| 976 | else |
| 977 | $acta_arr_def['actapadre_nombre'] = 'Este vale no tiene asociado ningún Cliente, ni tiene establecido un nombre.'; |
| 978 | |
| 979 | //Vamos a llenar los datos del padre. |
| 980 | $acta_arr_def['actapadre_fecha'] = array_key_exists('fecha',$actapadre_arr) ? ia_htmlentities(date('d-m-Y', strtotime($actapadre_arr['fecha']))) : ''; |
| 981 | $acta_arr_def['actapadre_tienda'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 982 | $acta_arr_def['actapadre_tiendaclv'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 983 | $acta_arr_def['actapadre_remarks'] = array_key_exists('remarks',$actapadre_arr) ? ia_htmlentities($actapadre_arr['remarks']) : 'N/A'; |
| 984 | $acta_arr_def['actapadre_number'] = array_key_exists('vale_number',$actapadre_arr) ? ia_htmlentities($actapadre_arr['vale_number']) : 'N/A'; |
| 985 | $acta_arr_def['actapadre_quantity'] = array_key_exists('quantity',$actapadre_arr) ? ia_htmlentities($actapadre_arr['quantity']) : 'N/A'; |
| 986 | $acta_arr_def['actapadre_total_payments'] = array_key_exists('total_payments',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_payments']) : 'N/A'; |
| 987 | $acta_arr_def['actapadre_id'] = array_key_exists($actapadre_id_nombre,$actapadre_arr) ? ia_htmlentities($actapadre_arr[$actapadre_id_nombre]) : 'N/A'; |
| 988 | |
| 989 | $acta_arr_def['acta_app_origen'] = 'Vale'; |
| 990 | |
| 991 | $ctaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE banco_cuenta_mov_link_id = ". strit($acta_id)); |
| 992 | if($ctaT_arr) //Si hay un movimiento en la cuentaT con el ID del a cuenta. |
| 993 | { |
| 994 | $acta_arr_def['actapadre_remarks'] .= '<br>Movimiento registrado en Cuenta T de <b>' . propdeCtaT($ctaT_arr['cuentaT_id'],'usuario',true) . '</b>'; |
| 995 | } |
| 996 | |
| 997 | break; |
| 998 | |
| 999 | case 'deuda_pago': |
| 1000 | |
| 1001 | //Vamos a calcular el nombre en el Cheque. |
| 1002 | if(array_key_exists('acreedor',$actapadre_arr)) |
| 1003 | $acta_arr_def['actapadre_nombre'] = empty($actapadre_arr['acreedor']) ? 'N/A' : $actapadre_arr['acreedor']; |
| 1004 | |
| 1005 | if(array_key_exists('concepto',$actapadre_arr)) |
| 1006 | { |
| 1007 | $acta_arr_def['actapadre_nombre'] = empty($acta_arr_def['actapadre_nombre']) ? $actapadre_arr['concepto'] : $acta_arr_def['actapadre_nombre'] . '<br/>' . $actapadre_arr['concepto']; |
| 1008 | } |
| 1009 | //Vamos a llenar los datos del padre. |
| 1010 | $acta_arr_def['actapadre_fecha'] = array_key_exists('fecha',$actapadre_arr) ? ia_htmlentities(date('d-m-Y', strtotime($actapadre_arr['fecha']))) : ''; |
| 1011 | $acta_arr_def['actapadre_tienda'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT tienda FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 1012 | $acta_arr_def['actapadre_tiendaclv'] = array_key_exists('tienda_id',$actapadre_arr) ? ia_htmlentities(ia_singleread("SELECT clave FROM tienda WHERE tienda_id = ". strit($actapadre_arr['tienda_id']))) : 'N/A'; |
| 1013 | $acta_arr_def['actapadre_remarks'] = array_key_exists('remarks',$actapadre_arr) ? ia_htmlentities($actapadre_arr['remarks']) : 'N/A'; |
| 1014 | $acta_arr_def['actapadre_number'] = array_key_exists('numero_deuda',$actapadre_arr) ? ia_htmlentities($actapadre_arr['numero_deuda']) : 'N/A'; |
| 1015 | $acta_arr_def['actapadre_quantity'] = array_key_exists('quantity',$actapadre_arr) ? ia_htmlentities($actapadre_arr['quantity']) : 'N/A'; |
| 1016 | $acta_arr_def['actapadre_total_payments'] = array_key_exists('total_payments',$actapadre_arr) ? ia_htmlentities($actapadre_arr['total_payments']) : 'N/A'; |
| 1017 | $acta_arr_def['actapadre_id'] = array_key_exists($actapadre_id_nombre,$actapadre_arr) ? ia_htmlentities($actapadre_arr[$actapadre_id_nombre]) : 'N/A'; |
| 1018 | |
| 1019 | //Extra para saber si hay un registro en la cuentaT |
| 1020 | |
| 1021 | $ctaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE banco_cuenta_mov_link_id = ". strit($acta_id)); |
| 1022 | if($ctaT_arr) //Sí hay un movimiento en la cuentaT con el ID del a cuenta. |
| 1023 | { |
| 1024 | $acta_arr_def['acta_ctaTmov'] .= 'Movimiento registrado en Cuenta T de <b>' . propdeCtaT($ctaT_arr['cuentaT_id'],'usuario',true) . '</b>'; |
| 1025 | } |
| 1026 | |
| 1027 | break; |
| 1028 | |
| 1029 | case 'banco_cuenta_mov': |
| 1030 | |
| 1031 | //Vamos a leer datos de la CuentaT. |
| 1032 | $acta_arr_def['actapadre_nombre'] = array_key_exists('banco_cuenta_id',$acta_arr) ? 'Transferencia desde <b>' . ia_singleread("SELECT nombre FROM banco_cuenta WHERE banco_cuenta_id = '$acta_arr[banco_cuenta_id]'") . '</b>' : 'N/A'; |
| 1033 | //$acta_arr_def['actapadre_nombre'] .= array_key_exists('fecha',$acta_arr) ? '<br>El <b>' . ia_htmlentities(get_date_spanish(strtotime($acta_arr['fecha']))) . '</b>' : 'N/A'; |
| 1034 | $link_arr = ia_singleton("SELECT * FROM banco_cuenta_mov_link WHERE banco_cuenta_mov_link_id = ". strit($bcml_id)); |
| 1035 | $acta_arr_def['actapadre_nombre'] .= array_key_exists('link_el',$link_arr) ? '<br>El <b>' . ia_htmlentities(get_date_spanish(strtotime($link_arr['link_el']))) . '</b> a las <b>' . date('H:i:s', strtotime($link_arr['link_el'])). '</b>' : ''; |
| 1036 | $acta_arr_def['actapadre_nombre'] .= array_key_exists('link_por',$link_arr) ? '<br>Por <b>' . ia_htmlentities($link_arr['link_por']) . '</b>' : ''; |
| 1037 | $acta_arr_def['acta_banco_cuenta_id'] = array_key_exists('banco_cuenta_id',$acta_arr) ? $acta_arr['banco_cuenta_id']:null; |
| 1038 | $acta_arr_def['acta_app_origen'] = "Link Cuentas Propias"; |
| 1039 | break; |
| 1040 | |
| 1041 | case 'fiduciario_reembolso': |
| 1042 | |
| 1043 | //Vamos a leer datos de la CuentaT. |
| 1044 | $acta_arr_def['actapadre_nombre'] = "REEMBOLSO DE FIDUCIARIO"; |
| 1045 | |
| 1046 | $bcm_arr = ia_singleton("SELECT * FROM banco_cuenta_mov WHERE banco_cuenta_mov_id = ". strit($acta_arr['banco_cuenta_mov_id'])); |
| 1047 | |
| 1048 | $acta_arr_def['acta_banco_cuenta_id'] = array_key_exists('banco_cuenta_id',$bcm_arr) ? $bcm_arr['banco_cuenta_id']:null; |
| 1049 | $acta_arr_def['acta_deposit_total'] = array_key_exists('deposit',$bcm_arr) ? $bcm_arr['deposit']:null; |
| 1050 | $acta_arr_def['acta_quantity'] = array_key_exists('deposit',$bcm_arr) ? $bcm_arr['deposit']:null; |
| 1051 | $acta_arr_def['acta_quantity_total'] = array_key_exists('deposit',$bcm_arr) ? $bcm_arr['deposit']:null; |
| 1052 | $acta_arr_def['remarks'] = array_key_exists('remarks',$bcm_arr) ? $bcm_arr['remarks']:null; |
| 1053 | $acta_arr_def['acta_app_origen'] = "Reembolso de Fiducario"; |
| 1054 | break; |
| 1055 | |
| 1056 | } |
| 1057 | |
| 1058 | if($return=='label') |
| 1059 | return hazLabeldeDocto($acta_arr_def, $monto_padre); |
| 1060 | else |
| 1061 | return $acta_arr_def; |
| 1062 | } |
| 1063 | |
| 1064 | function TablaparaLinkManual($lm_docto) |
| 1065 | { |
| 1066 | $arr_tlm = array ( "acta_tabla" => "", |
| 1067 | "acta_comentarios" => ""); |
| 1068 | if($lm_docto == '') |
| 1069 | return $arr_tlm; |
| 1070 | |
| 1071 | switch ($lm_docto) |
| 1072 | { |
| 1073 | case 'cash': |
| 1074 | $arr_tlm["acta_tabla"] = 'cash_pago'; |
| 1075 | //$arr_tlm["acta_comentarios"] = 'Pago de un CASH. '; |
| 1076 | break; |
| 1077 | |
| 1078 | case 'nota': |
| 1079 | $arr_tlm["acta_tabla"] = 'nota_pago'; |
| 1080 | break; |
| 1081 | |
| 1082 | case 'pagare': |
| 1083 | $arr_tlm["acta_tabla"] = 'pagare_pago'; |
| 1084 | break; |
| 1085 | |
| 1086 | case 'cheque': |
| 1087 | $arr_tlm["acta_tabla"] = 'cheque_pago'; |
| 1088 | break; |
| 1089 | |
| 1090 | case 'vale': |
| 1091 | if(VALE_PAGO_MULTIPLE) { |
| 1092 | $arr_tlm["acta_tabla"] = 'vale_pago'; |
| 1093 | break; |
| 1094 | } |
| 1095 | |
| 1096 | case 'deuda': |
| 1097 | $arr_tlm["acta_tabla"] = 'deuda_pago'; |
| 1098 | break; |
| 1099 | |
| 1100 | default: |
| 1101 | $arr_tlm["acta_tabla"] = 'nota_pago'; |
| 1102 | $arr_tlm["acta_comentarios"] = 'No se estableció documento. '; |
| 1103 | break; |
| 1104 | } |
| 1105 | |
| 1106 | return $arr_tlm; |
| 1107 | } |
| 1108 | |
| 1109 | function obtenOnHandCuentasT($cuentaTID='') |
| 1110 | { |
| 1111 | global $gAppRelate; |
| 1112 | |
| 1113 | $todas = false; |
| 1114 | if(empty($cuentaTID)) |
| 1115 | $todas = true; |
| 1116 | |
| 1117 | $arr_ctasTPuede = ''; |
| 1118 | if($todas) |
| 1119 | $arr_ctasTPuede = cuentasTPuede('', 'ver_saldo_y_movimientos'); |
| 1120 | else |
| 1121 | $arr_ctasTPuede = puedeCuentaT($cuentaTID,'','ver_saldo_y_movimientos'); |
| 1122 | |
| 1123 | if($arr_ctasTPuede === false || $arr_ctasTPuede === "''") |
| 1124 | return false; |
| 1125 | |
| 1126 | if(!$todas) |
| 1127 | $arr_ctasTPuede = "'$cuentaTID'"; |
| 1128 | |
| 1129 | $ctatTPref = $gAppRelate->cuentat_prefereida('', 'ver_saldo_y_movimientos'); |
| 1130 | $ctatTPref = !empty($ctatTPref)?"'$ctatTPref',":""; |
| 1131 | |
| 1132 | $sqlOnHand = "SELECT cuentaT_id, usuario, on_hand_mx, on_hand_usd, transfering_mx, transfering_usd FROM cuentat WHERE vale='Active' AND cuentaT_id IN ($arr_ctasTPuede) ORDER BY FIELD(cuentaT_id, $ctatTPref $arr_ctasTPuede) ASC, cuentaT_id"; |
| 1133 | |
| 1134 | //die($sqlOnHand); |
| 1135 | |
| 1136 | $arr_ctasTSaldo = ia_sqlArrayIndx($sqlOnHand); |
| 1137 | |
| 1138 | if(empty($arr_ctasTSaldo) || !is_array($arr_ctasTSaldo)) |
| 1139 | return false; |
| 1140 | |
| 1141 | return $arr_ctasTSaldo; |
| 1142 | } |
| 1143 | |
| 1144 | function registraMovimientoDivisa($descripcion='', $tc_mov='', $doSQL = 'SI', $tc_over=0.00, $cliente_id='', $cliente_nombre='', $doc_id='', $doc_origen='') |
| 1145 | { |
| 1146 | $warning='NO'; |
| 1147 | if(empty($descripcion) || empty($tc_mov)) |
| 1148 | return false; |
| 1149 | |
| 1150 | global $gIAParametros; |
| 1151 | |
| 1152 | $descripcion = str_replace('<li>','',$descripcion); |
| 1153 | |
| 1154 | $revisa = revisaTipodeCambio($tc_mov, false, $tc_over); |
| 1155 | switch($revisa){ |
| 1156 | case 'W': |
| 1157 | $warning='SI'; |
| 1158 | break; |
| 1159 | case 'L': |
| 1160 | $warning='PE'; |
| 1161 | break; |
| 1162 | default: |
| 1163 | $warning='NO'; |
| 1164 | break; |
| 1165 | } |
| 1166 | |
| 1167 | $tc_Sistema = $gIAParametros['tc'] < $tc_over ? $tc_over : $gIAParametros['tc']; |
| 1168 | |
| 1169 | $arr_MovDivisa = array(); |
| 1170 | $arr_MovDivisa['movimiento_divisa_id'] = ia_guid(); |
| 1171 | $arr_MovDivisa['descripcion'] = $descripcion; |
| 1172 | $arr_MovDivisa['tc_sistema'] = $tc_Sistema; |
| 1173 | $arr_MovDivisa['tc_movimiento'] = $tc_mov; |
| 1174 | $arr_MovDivisa['warning'] = $warning; |
| 1175 | $arr_MovDivisa['warning_status'] = $warning=='NO'?'No Aplica':'Por revisar'; |
| 1176 | $arr_MovDivisa['alta_db'] = $now = date('Y-m-d H:i:s'); |
| 1177 | $arr_MovDivisa['alta_por'] = $_SESSION['usuario']; |
| 1178 | $arr_MovDivisa['cliente_id'] = $cliente_id; |
| 1179 | $arr_MovDivisa['cliente'] = $cliente_nombre; |
| 1180 | $arr_MovDivisa['doc_id'] = $doc_id; |
| 1181 | $arr_MovDivisa['doc_origen'] = $doc_origen; |
| 1182 | |
| 1183 | //if($warning && !usuarioTipoRony($_SESSION['usuario_id'])) |
| 1184 | //registraBrainAviso($descripcion." - <a target='_blank' href='../backoffice/movimiento_divisa_list.php?movimiento_divisa_id=$arr_MovDivisa[movimiento_divisa_id]' data-movimiento_divisa_id='$arr_MovDivisa[movimiento_divisa_id]'><strong>Tipo de Cambio con Warning.</strong></a>", $now); |
| 1185 | |
| 1186 | $sql=ia_insert('movimiento_divisa',$arr_MovDivisa); |
| 1187 | |
| 1188 | if($doSQL == 'SI') |
| 1189 | { |
| 1190 | ia_query($sql); |
| 1191 | ia_errores_a_dime('','','registraMovimientoDivisa'); |
| 1192 | @actualizaConteoMovimientosDivisa(); |
| 1193 | } |
| 1194 | else |
| 1195 | return $sql; |
| 1196 | } |
| 1197 | |
| 1198 | function registraBrainAviso($mensaje='', $now='', $tema='', $subtema='', $tipo='Especial') |
| 1199 | { |
| 1200 | if(empty($mensaje)) |
| 1201 | return false; |
| 1202 | |
| 1203 | if(empty($now)) |
| 1204 | $now = date('Y-m-d H:i:s'); |
| 1205 | |
| 1206 | $arr_BrainAviso = array(); |
| 1207 | $arr_BrainAviso['brain_avisos_id'] = ia_guid(); |
| 1208 | $arr_BrainAviso['por_quien'] = $_SESSION['usuario']; |
| 1209 | $arr_BrainAviso['mensaje'] = $mensaje; |
| 1210 | $arr_BrainAviso['revisado'] = 'Por revisar'; |
| 1211 | $arr_BrainAviso['alta_db'] = $now = date('Y-m-d H:i:s'); |
| 1212 | $arr_BrainAviso['tema'] = $tema; |
| 1213 | $arr_BrainAviso['subtema'] = $subtema; |
| 1214 | $arr_BrainAviso['tipo'] = $tipo; |
| 1215 | |
| 1216 | $sql=ia_insert('brain_avisos',$arr_BrainAviso); |
| 1217 | ia_query($sql); |
| 1218 | ia_errores_a_dime('','','registraBrainAviso'); |
| 1219 | } |
| 1220 | |
| 1221 | /** |
| 1222 | * revisaTipodeCambio() |
| 1223 | * Revisa el tipo de cambio y contesta si está bien, hay warning o está fuera de rango. |
| 1224 | * @param float $tc tipo de cambio de la operación |
| 1225 | * @return string OK=bien. W=Warning. L=Fuera del Limite. |
| 1226 | */ |
| 1227 | function revisaTipodeCambio($tc=0, $byPass=false, $tc_over = 0.00, $ret_warning = false) |
| 1228 | { |
| 1229 | global $gIAParametros; |
| 1230 | $eval = 'OK'; //Tipo de Cambio dentro de los parámetros. OK. WU=Warning arriba. LU=Limite arriba. WD=Warning abajo. LD=Limite abajo. |
| 1231 | |
| 1232 | $tc_Sistema = $gIAParametros['tc'] < $tc_over ? $tc_over : $gIAParametros['tc']; |
| 1233 | |
| 1234 | $tc_Sistema = $byPass && $tc_over > 1 ? $tc_over : $tc_Sistema; |
| 1235 | $byPass = $byPass && $tc_over > 1 || ($byPass && usuarioTipoRony() && !$ret_warning) ? $byPass : false; |
| 1236 | // echo "<li>tc_Sistema: ".$tc_Sistema; |
| 1237 | // echo "<li>tc_over: ".$tc_over; |
| 1238 | // echo "<li>tc: ".$tc; |
| 1239 | $tc_WU = $tc_Sistema + ($gIAParametros['puntos_warning_arriba'] / 100); |
| 1240 | $tc_LU = $tc_Sistema + ($gIAParametros['puntos_limite_arriba'] / 100); |
| 1241 | $tc_WD = $tc_Sistema - ($gIAParametros['puntos_warning_abajo'] / 100); |
| 1242 | $tc_LD = $tc_Sistema - ($gIAParametros['puntos_limite_abajo'] / 100); |
| 1243 | |
| 1244 | if($byPass && usuarioTipoRony($_SESSION['usuario_id'])) |
| 1245 | return $eval = 'OK'; |
| 1246 | |
| 1247 | if($tc<$tc_LD || $tc>$tc_LU) |
| 1248 | return $eval = 'L'; |
| 1249 | |
| 1250 | if($tc<=$tc_WD || $tc>=$tc_WU) |
| 1251 | return $eval = 'W'; |
| 1252 | |
| 1253 | return $eval = 'OK'; |
| 1254 | } |
| 1255 | |
| 1256 | function extraeTCdeXE($manual=false, $debug=false, $api="currencylayer.com") //$api="currencylayer.com" |
| 1257 | { |
| 1258 | //echo "$_SERVER[SERVER_NAME]"; |
| 1259 | global $gIAParametros; |
| 1260 | |
| 1261 | //$debug = false; |
| 1262 | //$debug = true; |
| 1263 | |
| 1264 | if($_SERVER['SERVER_NAME'] != 't420sata.dyndns-free.com' && $_SERVER['SERVER_NAME'] != 't550gris.dyndns-free.com' && $_SERVER['SERVER_NAME'] != 't550gris' && $_SERVER['SERVER_NAME'] != '192.168.1.40' && $_SERVER['SERVER_NAME'] != 'RONY' && ($_SERVER['SERVER_NAME'] != 'vinuxito11' || !$debug)) |
| 1265 | return false; |
| 1266 | |
| 1267 | // echo "<pre>_SERVER".print_r($_SERVER, true)."</pre>"; |
| 1268 | // |
| 1269 | // die(); |
| 1270 | |
| 1271 | //Revisamos si la función está activa o no. |
| 1272 | if(!$manual && $gIAParametros['actualiza_desde_xecom'] != 'Si') |
| 1273 | { |
| 1274 | if($debug) |
| 1275 | echo 'Actualización automática INACTIVA.<br/>'; |
| 1276 | return false; |
| 1277 | } |
| 1278 | //Revisamos si es sábado o domingo y si debemos actualizar o no. |
| 1279 | $diaSemana = date('N'); |
| 1280 | if(!$manual && ($diaSemana==6 && $gIAParametros['actualiza_desde_xecom_en_sabado'] != 'Si') || ($diaSemana==7 && $gIAParametros['actualiza_desde_xecom_en_domingo'] != 'Si')) |
| 1281 | { |
| 1282 | if($debug) |
| 1283 | echo 'Es sábado o domingo y no debemos actualizar.<br/>'; |
| 1284 | return false; |
| 1285 | } |
| 1286 | //Revisamos si estamos en hora de actualización |
| 1287 | $horaActual = (int) date('Gis'); |
| 1288 | $horaInicial = (int) str_replace(':','',$gIAParametros['hora_inicial_actualiza_desde_xecom']); |
| 1289 | $horaFinal = (int) str_replace(':','',$gIAParametros['hora_final_actualiza_desde_xecom']); |
| 1290 | |
| 1291 | if(!$manual && ($horaActual < $horaInicial || $horaActual > $horaFinal)) |
| 1292 | { |
| 1293 | if($debug) |
| 1294 | echo 'Fuera de horario.<br/>'; |
| 1295 | return false; |
| 1296 | } |
| 1297 | |
| 1298 | $tcUltimaActualizacion = ia_singleread("SELECT alta_db FROM tc_log ORDER BY alta_db DESC LIMIT 1"); |
| 1299 | |
| 1300 | if(!$manual && (diferenciadeTiempo($tcUltimaActualizacion,'','minutos') < $gIAParametros['tiempo_para_actualizar_tc_desde_xecom']*60)) |
| 1301 | { |
| 1302 | if($debug) |
| 1303 | echo "No ha pasado el tiempo man:$manual deb:$debug<br/>"; |
| 1304 | return false; |
| 1305 | } |
| 1306 | $tcXE = 0.00; |
| 1307 | |
| 1308 | if($api == "currencylayer.com") { |
| 1309 | $url = "http://apilayer.net/api/live?access_key=1a788acee0d6bf9d5b1307541c1f587e¤cies=USD,MXN&format=1"; |
| 1310 | |
| 1311 | $agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.12 Safari/537.36 OPR/56.0.3051.0 (Edition developer)'; |
| 1312 | |
| 1313 | |
| 1314 | $ch1 = curl_init(); |
| 1315 | curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); |
| 1316 | curl_setopt($ch1, CURLOPT_VERBOSE, true); |
| 1317 | curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true); |
| 1318 | curl_setopt($ch1, CURLOPT_USERAGENT, $agent); |
| 1319 | curl_setopt($ch1, CURLOPT_URL, $url); |
| 1320 | $clayer = curl_exec($ch1); |
| 1321 | curl_close($ch1); |
| 1322 | |
| 1323 | $clayer = json_decode($clayer); |
| 1324 | |
| 1325 | //echo "<pre>".print_r($clayer, true)."</pre>"; |
| 1326 | |
| 1327 | if ($clayer != null && $clayer->success < 1) { |
| 1328 | $tcXE = 0.00; |
| 1329 | actualizaTCenDB(false, 0.00, '', $manual); |
| 1330 | } else { |
| 1331 | $tcXE = $clayer->quotes->USDMXN; |
| 1332 | $tsXE = date("Y-m-d H:i:s", $clayer->timestamp); |
| 1333 | actualizaTCenDB(true, $tcXE, $tsXE, $manual, $api); |
| 1334 | } |
| 1335 | } |
| 1336 | elseif($api == "alphavantage"){ |
| 1337 | $url = 'https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=MXN&apikey=9RPF6JQGVLJLOJ43'; |
| 1338 | $json = file_get_contents($url); |
| 1339 | |
| 1340 | $alphavantage = json_decode($json, true); |
| 1341 | |
| 1342 | if(array_key_exists("Realtime Currency Exchange Rate", $alphavantage) && array_key_exists("5. Exchange Rate", $alphavantage["Realtime Currency Exchange Rate"]) && !empty($alphavantage["Realtime Currency Exchange Rate"]["5. Exchange Rate"])){ |
| 1343 | |
| 1344 | $tcXE = $alphavantage["Realtime Currency Exchange Rate"]["5. Exchange Rate"]; |
| 1345 | $tsXE = date("Y-m-d H:i:s", strtotime($alphavantage["Realtime Currency Exchange Rate"]["6. Last Refreshed"])); |
| 1346 | actualizaTCenDB(true, $tcXE, $tsXE, $manual, $api); |
| 1347 | |
| 1348 | } else { |
| 1349 | $tcXE = 0.00; |
| 1350 | actualizaTCenDB(false, 0.00, '', $manual); |
| 1351 | } |
| 1352 | |
| 1353 | if($debug){ |
| 1354 | echo "<pre>".print_r($alphavantage, true)."</pre>"; |
| 1355 | } |
| 1356 | |
| 1357 | } |
| 1358 | |
| 1359 | if($debug) |
| 1360 | echo "$tcXE<br/>"; |
| 1361 | return $tcXE; |
| 1362 | } |
| 1363 | |
| 1364 | function actualizaTCenDB($success=false, $tcXE=0.00, $tsXE='', $manual=false, $prov='xe.com') |
| 1365 | { |
| 1366 | if($success && $tcXE==0.00) |
| 1367 | return false; |
| 1368 | |
| 1369 | global $gIAParametros; |
| 1370 | |
| 1371 | if($manual) |
| 1372 | $nombreApp = $_SESSION['usuario']; |
| 1373 | else |
| 1374 | $nombreApp = 'actualizaTCenDB'; |
| 1375 | |
| 1376 | $arr_tc = array(); |
| 1377 | $arr_tc['tc_log_id'] = ia_guid(); |
| 1378 | $arr_tc['tc'] = $tcXE; |
| 1379 | $arr_tc['origen'] = strtoupper($prov); |
| 1380 | $arr_tc['origen_ts'] = $tsXE; |
| 1381 | $arr_tc['remarks'] = $success?'TC actualizado con éxito de '.$arr_tc['origen']:'Error al leer el patrón para actualizar el TC de '.$arr_tc['origen']; |
| 1382 | $arr_tc['exitoso'] = $success; |
| 1383 | $arr_tc['alta_db'] = $now = date('Y-m-d H:i:s'); |
| 1384 | $arr_tc['alta_por'] = $nombreApp; |
| 1385 | |
| 1386 | $sqlTC = array(); |
| 1387 | $sqlTC[] = ia_insert('tc_log',$arr_tc); |
| 1388 | if($success) |
| 1389 | { |
| 1390 | $sqlTC[] = "UPDATE moneda SET tc='$tcXE', ultimo_cambio='$now', ultimo_cambio_por='$nombreApp' WHERE moneda_id=2"; |
| 1391 | $sqlTC[] = "UPDATE iac_parametros SET tc='$tcXE'"; |
| 1392 | } |
| 1393 | |
| 1394 | if(!$success && $gIAParametros['avisa_brain_si_hay_error_en_actualiza_desde_xecom'] == 'Si') |
| 1395 | { |
| 1396 | registraBrainAviso("<a target='_blank' href='../backoffice/tc_log.php?tc_log_id=$arr_tc[tc_log_id]'><strong>ERROR al actualizar el Tipo de Cambio desde CURRENCYLAYER.COM. Dia y hora: $now.</strong></a>", $now); |
| 1397 | } |
| 1398 | ia_transaction($sqlTC); |
| 1399 | ia_errores_a_dime('','',$nombreApp); |
| 1400 | |
| 1401 | obtenCatalogo('tc', true); |
| 1402 | return true; |
| 1403 | } |
| 1404 | |
| 1405 | function obtenCuentasTToolbar() |
| 1406 | { |
| 1407 | $ctasTSaldoHTML = ''; |
| 1408 | |
| 1409 | $ctasTSaldo = obtenOnHandCuentasT(); |
| 1410 | if(is_array($ctasTSaldo) && !empty($ctasTSaldo)) |
| 1411 | { |
| 1412 | $ctasTSaldoHTML = "<div id='cuentasTToolbar' style='background-color: #ffffff;'>"; |
| 1413 | $ctasTSaldoHTML .= "<table id='tablectasTSaldo' style='width: 280px;'>"; |
| 1414 | $ctasTSaldoHTML .= "<tr><td colspan='2' class='tbctasTSaldo'><a href='../backoffice/cuentat_mov.php?cuentat=".$ctasTSaldo[0]['usuario']."' target='_blank'><strong>".$ctasTSaldo[0]['usuario']."</strong></a></td></tr><tr><td class='tbPESOS'>".echonf($ctasTSaldo[0]['on_hand_mx'],true)."</td><td class='tbUSD'>".echonf($ctasTSaldo[0]['on_hand_usd'],true)."</td></tr>"; |
| 1415 | $ctasTSaldoHTML .= "</table>"; |
| 1416 | if(sizeof($ctasTSaldo)>1) |
| 1417 | { |
| 1418 | $ctasTSaldoHTML .= "<a id='amuestraMasCuentasTToolbar' href='javascript:void(0);' onclick='muestraMasCuentasTToolbar(true);'><strong>Mostrar más Cuentas T </strong><img style='width: 16px !important; height: 16px !important;' src='../img/add.png' alt='Mostrar más Cuentas T' title='Mostrar más Cuentas T' /></a>"; |
| 1419 | $ctasTSaldoHTML .= "<a id='aocultaMasCuentasTToolbar' href='javascript:void(0);' onclick='muestraMasCuentasTToolbar(false);' style='display:none;' ><strong>Ocultar las Cuentas T </strong><img style='width: 16px !important; height: 16px !important;' src='../img/delete.png' alt='Ocultar las Cuentas T' title='Ocultar las Cuentas T' /></a>"; |
| 1420 | $ctasTSaldoHTML .= "<div id='divctasTSaldoMas' style='position: fixed; z-index:1001; display: none; overflow-x: hidden; overflow-y: scroll; height: 510px; background-color: #ffffff;'>"; |
| 1421 | $ctasTSaldoHTML .= "<hr/><a href='../backoffice/cuenta_t.php' target='_blank' title='Resumen de todas las Cuentas T'><strong>Resumen de todas las Cuentas T</strong></a><hr/>"; |
| 1422 | $ctasTSaldoHTML .= "<a href='../backoffice/cuentat_mov.php' target='_blank' title='Movimientos de todas las Cuentas T'><strong>Mov. de todas las Cuentas T</strong></a><hr/>"; |
| 1423 | $ctasTSaldoHTML .= "<table id='tablectasTSaldoMas' style='width: 280px;'>"; |
| 1424 | foreach($ctasTSaldo as $k=>$ctaT) |
| 1425 | if($k>0) |
| 1426 | $ctasTSaldoHTML .= "<tr><td colspan='2' class='tbctasTSaldo'><a href='../backoffice/cuentat_mov.php?cuentat=".$ctaT['usuario']."' target='_blank'><strong>".$ctaT['usuario']."</strong></a></td></tr><tr><td class='tbPESOS'>".echonf($ctaT['on_hand_mx'],true)."</td><td class='tbUSD'>".echonf($ctaT['on_hand_usd'],true)."</td></tr>"; |
| 1427 | $ctasTSaldoHTML .= "</table></div>"; |
| 1428 | } |
| 1429 | $ctasTSaldoHTML .= "</div>"; |
| 1430 | } |
| 1431 | else |
| 1432 | $ctasTSaldoHTML = ''; |
| 1433 | |
| 1434 | return $ctasTSaldoHTML; |
| 1435 | } |
| 1436 | |
| 1437 | function cancelaVale($valeID='') |
| 1438 | { |
| 1439 | if(empty($valeID)) |
| 1440 | return false; |
| 1441 | |
| 1442 | $vale=new app_vale(); |
| 1443 | $vale->id=$valeID; |
| 1444 | $vale->values=$vale->enDB=$vale->read_sql($valeID,'r'); |
| 1445 | |
| 1446 | if(!is_array($vale->enDB) || empty($vale->enDB)) |
| 1447 | return false; |
| 1448 | |
| 1449 | $vale->cancelaVale = 'SI'; |
| 1450 | $vale->update(); |
| 1451 | } |
| 1452 | |
| 1453 | function obtenCuentaTMovIDOriginal($origenID) |
| 1454 | { |
| 1455 | if(empty($origenID)) |
| 1456 | return false; |
| 1457 | |
| 1458 | $commentSQL = " /** obtenCuentaTMovIDOriginal **/"; |
| 1459 | $sql = "SELECT $commentSQL cuentaT_mov_id FROM cuentat_mov WHERE origen_mov_id = ".strit($origenID)." ORDER BY alta_db DESC"; |
| 1460 | |
| 1461 | $ID = ia_singleread($sql); |
| 1462 | |
| 1463 | if(!empty($ID)) |
| 1464 | return $ID; |
| 1465 | else |
| 1466 | return false; |
| 1467 | } |
| 1468 | |
| 1469 | function arrayAppOrigen($select = false) |
| 1470 | { |
| 1471 | $arrAppOrigen = array ( 'Ingreso Directo' => 'Ingreso Directo', |
| 1472 | 'Gasto Cuenta T' => 'Gasto Cuenta T', |
| 1473 | 'A Cuenta Cheque' => 'A Cuenta Cheque', |
| 1474 | 'A Cuenta Compra' => 'A Cuenta Compra', |
| 1475 | 'A Cuenta Pagare' => 'A Cuenta Pagare', |
| 1476 | 'Cheque Delivered' => 'Cheque Delivered', |
| 1477 | 'Pagare Delivered' => 'Pagare Delivered', |
| 1478 | 'Vale' => 'Vale', |
| 1479 | 'Link Directo al Banco' => 'Link Directo al Banco', |
| 1480 | 'Link Directo a China' => 'Link Directo a China', |
| 1481 | 'Transfer Cuenta T' => 'Transfer Cuenta T', |
| 1482 | 'Ajuste Cuenta T' => 'Ajuste Cuenta T', |
| 1483 | 'Gasto Tienda' => 'Gasto Tienda', |
| 1484 | 'Gasto Proveedor' => 'Gasto Proveedor', |
| 1485 | 'Link Tarjetas de Credito' => 'Link Tarjetas de Credito', |
| 1486 | 'Vale Aplicado' => 'Vale Aplicado'); |
| 1487 | if($select) |
| 1488 | { |
| 1489 | foreach($arrAppOrigen as $k=>$v) |
| 1490 | { |
| 1491 | $arrAppOrigenIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v,'real_data'=>$v); |
| 1492 | } |
| 1493 | return $arrAppOrigenIndex; |
| 1494 | } |
| 1495 | return $arrAppOrigen; |
| 1496 | } |
| 1497 | |
| 1498 | function arrayLinkOrigen($select = false) |
| 1499 | { |
| 1500 | $arrLinkOrigen = array ( 'cuentat_mov' => 'Cuenta T', |
| 1501 | 'banco_cuenta_mov' => 'Cuenta Bancaria', |
| 1502 | 'cheque_pago' => 'Cheque', |
| 1503 | 'pagare_pago' => 'Pagare', |
| 1504 | 'vale' => 'Vale', |
| 1505 | 'vale_pago' => 'Vale'); |
| 1506 | |
| 1507 | if($select) |
| 1508 | { |
| 1509 | foreach($arrLinkOrigen as $k=>$v) |
| 1510 | { |
| 1511 | $arrLinkOrigenIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v); |
| 1512 | } |
| 1513 | return $arrLinkOrigenIndex; |
| 1514 | } |
| 1515 | return $arrLinkOrigen; |
| 1516 | } |
| 1517 | |
| 1518 | function arrayTablasCatalogos() |
| 1519 | { |
| 1520 | $arrTablasCatalogos = array( 'banco' => array('banco_id','clave'), |
| 1521 | 'banco_cuenta' => array('banco_cuenta_id','nombre'), |
| 1522 | 'banco_mov_tipo' => array('banco_mov_tipo_id','tipo'), |
| 1523 | 'cliente' => array('cliente_id','nombre'), |
| 1524 | 'cuentat' => array('cuentaT_id','usuario'), |
| 1525 | 'empresa' => array('empresa_id','empresa'), |
| 1526 | 'moneda' => array('moneda_id','moneda'), |
| 1527 | 'tienda' => array('tienda_id','clave'), |
| 1528 | 'categoria_gasto' => array('categoria_gasto_id','nombre'), |
| 1529 | 'metodo_pago_id' => array('metodo_pago_id','tipo'), |
| 1530 | 'categoria' => array('categoria_id','categoria'), |
| 1531 | 'plantilla_cuentat_gasto' => array('plantilla_cuentat_gasto_id','nombre'),); |
| 1532 | return $arrTablasCatalogos; |
| 1533 | } |
| 1534 | |
| 1535 | function arrayTipoFactura($select = false) |
| 1536 | { |
| 1537 | $arrTipoFactura = array ( 'MST' => 'MST', |
| 1538 | 'FACTURA' => 'FACTURA', |
| 1539 | 'FACTURA PENDIENTE' => 'FACTURA PENDIENTE', |
| 1540 | 'NUESTRO' => 'NUESTRO', |
| 1541 | 'DEVOLUCION' => 'DEVOLUCION', |
| 1542 | 'ESPECIAL' => 'ESPECIAL', |
| 1543 | 'ASIMILADOS' => 'ASIMILADOS', |
| 1544 | ); |
| 1545 | if($select) |
| 1546 | { |
| 1547 | foreach($arrTipoFactura as $k=>$v) |
| 1548 | { |
| 1549 | $arrTipoFacturaIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v); |
| 1550 | } |
| 1551 | return $arrTipoFacturaIndex; |
| 1552 | } |
| 1553 | return $arrTipoFactura; |
| 1554 | } |
| 1555 | |
| 1556 | function arrayTipoFigura($select = false) |
| 1557 | { |
| 1558 | $arrTipoFigura = array ( '01' => 'Operador', |
| 1559 | '02' => 'Propietario', |
| 1560 | '03' => 'Arrendador', |
| 1561 | '04' => 'Notificado', |
| 1562 | ); |
| 1563 | if($select) |
| 1564 | { |
| 1565 | foreach($arrTipoFigura as $k=>$v) |
| 1566 | { |
| 1567 | $arrTipoFiguraIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v); |
| 1568 | } |
| 1569 | return $arrTipoFiguraIndex; |
| 1570 | } |
| 1571 | return $arrTipoFigura; |
| 1572 | } |
| 1573 | |
| 1574 | function arrayTipoWarning($select = false) |
| 1575 | { |
| 1576 | $arrTipoFactura = array ( 'No Aplica' => 'Sin Warning', |
| 1577 | 'Por revisar' => 'Revisar', |
| 1578 | 'Revisado' => 'Autorizado' ); |
| 1579 | if($select) |
| 1580 | { |
| 1581 | foreach($arrTipoFactura as $k=>$v) |
| 1582 | { |
| 1583 | $arrTipoFacturaIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$k,'real_data'=>$k); |
| 1584 | } |
| 1585 | return $arrTipoFacturaIndex; |
| 1586 | } |
| 1587 | return $arrTipoFactura; |
| 1588 | } |
| 1589 | |
| 1590 | function array_movimiento_divisa_warning_tipo($select = false) |
| 1591 | { |
| 1592 | $arrTipoFactura = array ( 'NO' => 'Sin Warning', |
| 1593 | 'SI' => 'Warning', |
| 1594 | 'PE' => 'Warning Rony', |
| 1595 | 'TU' => 'Warning revisada', |
| 1596 | 'TUR' => 'Warning Rony revisada', ); |
| 1597 | |
| 1598 | |
| 1599 | if($select) |
| 1600 | { |
| 1601 | foreach($arrTipoFactura as $k=>$v) |
| 1602 | { |
| 1603 | $arrTipoFacturaIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$k,'real_data'=>$k); |
| 1604 | } |
| 1605 | return $arrTipoFacturaIndex; |
| 1606 | } |
| 1607 | return $arrTipoFactura; |
| 1608 | } |
| 1609 | |
| 1610 | function arrayTipoCashNota($select = false) |
| 1611 | { |
| 1612 | $arrTipoCashNota = array ( 'CASH' => 'CASH', |
| 1613 | 'NOTA' => 'NOTA', |
| 1614 | 'OTRO' => 'OTRO'); |
| 1615 | if($select) |
| 1616 | { |
| 1617 | foreach($arrTipoCashNota as $k=>$v) |
| 1618 | { |
| 1619 | $arrTipoCashNotaIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v); |
| 1620 | } |
| 1621 | return $arrTipoCashNotaIndex; |
| 1622 | } |
| 1623 | return $arrTipoCashNota; |
| 1624 | } |
| 1625 | |
| 1626 | function array_bodega_tipo_cash_nota($select = false) |
| 1627 | { |
| 1628 | $arr_bodega_tipo_cash_nota = array ( |
| 1629 | 'CASH' => 'CASH', |
| 1630 | 'NOTA' => 'NOTA', |
| 1631 | 'PIÑA' => 'PIÑA', |
| 1632 | 'OTRO' => 'OTRO'); |
| 1633 | if($select) |
| 1634 | { |
| 1635 | $arr_bodega_tipo_cash_nota_index = array(); |
| 1636 | foreach($arr_bodega_tipo_cash_nota as $k=>$v) |
| 1637 | { |
| 1638 | $arr_bodega_tipo_cash_nota_index[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v); |
| 1639 | } |
| 1640 | return $arr_bodega_tipo_cash_nota_index; |
| 1641 | } |
| 1642 | return $arr_bodega_tipo_cash_nota; |
| 1643 | } |
| 1644 | |
| 1645 | function arrayLinkVale($select = false) |
| 1646 | { |
| 1647 | $arrLinkVale = array ( |
| 1648 | 'ND' => array('value'=>'ND','class'=>''), |
| 1649 | 'Q' => array('value'=>'Q','class'=>''), |
| 1650 | 'LP' => array('value'=>'LP','class'=>''), |
| 1651 | 'LT' => array('value'=>'LT','class'=>''), |
| 1652 | 'SBC' => array('value'=>'SBC','class'=>''), |
| 1653 | 'RJ' => array('value'=>'RJ','class'=>''), |
| 1654 | 'SYS' => array('value'=>'SYS','class'=>''), |
| 1655 | 'PEND' => array('value'=>'PEND','class'=>''), |
| 1656 | 'INC' => array('value'=>'INC','class'=>''), |
| 1657 | 'NA' => array('value'=>'NA','class'=>''), |
| 1658 | 'ERROR' => array('value'=>'ERROR','class'=>'option_ROJO'), |
| 1659 | 'DEV' => array('value'=>'DEV','class'=>''), |
| 1660 | 'STOP' => array('value'=>'STOP','class'=>'option_ROJO'), |
| 1661 | 'CORRECTED' => array('value'=>'CORRECTED','class'=>''), |
| 1662 | 'COMMENTS' => array('value'=>'COMMENTS','class'=>'option_NEON'), |
| 1663 | 'NEW' => array('value'=>'NEW','class'=>''), |
| 1664 | 'RONY' => array('value'=>'RONY','class'=>'option_NEON'), |
| 1665 | 'AA' => array('value'=>'AA','class'=>'option_NEON'), |
| 1666 | 'APP' => array('value'=>'APP','class'=>''), |
| 1667 | 'BLOCKED' => array('value'=>'BLOCKED','class'=>'option_ROJO'), |
| 1668 | 'CONTRACT' => array('value'=>'CONTRACT','class'=>'option_NEON'), |
| 1669 | 'RETORNO' => array('value'=>'RETORNO','class'=>'option_NEON'), |
| 1670 | 'GARANTIA' => array('value'=>'GARANTIA','class'=>'option_NEON'), |
| 1671 | 'NAVIERA' => array('value'=>'NAVIERA','class'=>'option_NEON'), |
| 1672 | 'HOLD' => array('value'=>'HOLD','class'=>'option_ROJO'), |
| 1673 | 'RETAIN' => array('value'=>'RETAIN','class'=>'option_ROJO'), |
| 1674 | 'FID' => array('value'=>'FID','class'=>''), |
| 1675 | 'INV' => array('value'=>'INV','class'=>'')); |
| 1676 | |
| 1677 | $arrLinkValeIndex = array(); |
| 1678 | |
| 1679 | if($select) |
| 1680 | { |
| 1681 | foreach($arrLinkVale as $k=>$v) |
| 1682 | { |
| 1683 | $arrLinkValeIndex[] = array(0=>$k,1=>$v['value'],'label'=>$v['value'],'value'=>$v['value'],'class'=>$v['class']); |
| 1684 | } |
| 1685 | return $arrLinkValeIndex; |
| 1686 | } |
| 1687 | |
| 1688 | |
| 1689 | foreach($arrLinkVale as $k=>$v) |
| 1690 | { |
| 1691 | $arrLinkValeIndex[$k] = $v['value']; |
| 1692 | } |
| 1693 | return $arrLinkValeIndex; |
| 1694 | |
| 1695 | } |
| 1696 | |
| 1697 | function arrayUltimoMovimiento($select = false) |
| 1698 | { |
| 1699 | $arrUltimoMovimiento = array ( 'ALTA' => 'ALTA', |
| 1700 | 'BORRADO' => 'BORRADO', |
| 1701 | 'FECHA' => 'FECHA', |
| 1702 | 'QUANTITY' => 'QUANTITY'); |
| 1703 | if($select) |
| 1704 | { |
| 1705 | foreach($arrUltimoMovimiento as $k=>$v) |
| 1706 | { |
| 1707 | $arrUltimoMovimientoIndex[] = array(0=>$k,1=>$v,'label'=>$v,'value'=>$v); |
| 1708 | } |
| 1709 | return $arrUltimoMovimientoIndex; |
| 1710 | } |
| 1711 | return $arrUltimoMovimiento; |
| 1712 | } |
| 1713 | |
| 1714 | /** |
| 1715 | * borraDocumentoPagos() |
| 1716 | * Borra todos los a cuentas de un documento. |
| 1717 | * |
| 1718 | * @param mixed $documento = 'cheque', 'pagare' |
| 1719 | * @param mixed $documentoID = '' ID de 32 caracteres. |
| 1720 | * @param mixed $ajustaCuentaT = 'NO' Bandera para saber si ajusta cuenta T o no. |
| 1721 | * @return |
| 1722 | */ |
| 1723 | function borraDocumentoPagos($documento = 'cheque', $documentoID = '', $ajustaCuentaT = 'NO') |
| 1724 | { |
| 1725 | global $gIAsql; |
| 1726 | $gIAsql['trace'] = true; |
| 1727 | |
| 1728 | if(empty($documentoID)) |
| 1729 | return false; |
| 1730 | |
| 1731 | $pk_field = $documento.'_id'; |
| 1732 | |
| 1733 | |
| 1734 | // a cuenta de que cheque,pagare,... |
| 1735 | $cat=$documento; |
| 1736 | $collection['base_table']=$documento; |
| 1737 | $collection['pk_campo']=$pk_field; |
| 1738 | $collection['collection']=$collection['base_table']; |
| 1739 | |
| 1740 | $usuario = $_SESSION['usuario']; |
| 1741 | $now = date('Y-m-d H:i:s'); |
| 1742 | |
| 1743 | |
| 1744 | $qtyEs='quantity'; |
| 1745 | |
| 1746 | |
| 1747 | |
| 1748 | $itemID=$documentoID; |
| 1749 | // obten el item |
| 1750 | $item=ia_singleton("SELECT * FROM $collection[base_table] WHERE $collection[pk_campo]=".strit($itemID)); |
| 1751 | if(empty($item)) |
| 1752 | { |
| 1753 | //return false; |
| 1754 | } |
| 1755 | |
| 1756 | $cliente=''; |
| 1757 | $sql=array(); |
| 1758 | |
| 1759 | $cliente_id=$item['cliente_id']; |
| 1760 | if(empty($cliente_id)) $cliente_id=$item['cliente_proveedor_id']; |
| 1761 | if($cliente_id==0) |
| 1762 | $cliente=$item['name_on_check']; |
| 1763 | |
| 1764 | if($cliente_id>0) |
| 1765 | $cliente=ia_singleread("SELECT nombre FROM cliente WHERE cliente_id=".strit($cliente_id)); |
| 1766 | $cliente=ia_htmlentities($cliente); |
| 1767 | |
| 1768 | |
| 1769 | $dpsql = "SELECT * FROM ".$documento."_pago WHERE ".$documento."_id=".strit($itemID)." ORDER BY alta_db ASC"; |
| 1770 | $documentoPagos = ia_sqlArrayIndx($dpsql); |
| 1771 | |
| 1772 | if(is_array($documentoPagos)) foreach($documentoPagos as $k=>$vdocPago) |
| 1773 | { |
| 1774 | $pagoID=$vdocPago[$documento."_pago_id"]; |
| 1775 | $tsql=borraDocumentoPago($documento, $pagoID, $ajustaCuentaT, 'NO'); |
| 1776 | if(!empty($tsql)) |
| 1777 | foreach($tsql as $qs) |
| 1778 | $sql[]=$qs; |
| 1779 | } |
| 1780 | |
| 1781 | if(!empty($sql)) |
| 1782 | if(ia_transaction($sql)) |
| 1783 | ia_errores_a_dime(); |
| 1784 | return true; |
| 1785 | } |
| 1786 | |
| 1787 | /** |
| 1788 | * Borra un a cuenta de un documento. |
| 1789 | * |
| 1790 | * @param mixed $documento = 'cheque', 'pagare' |
| 1791 | * @param mixed $documentoPagoID = '' ID de 32 caracteres. |
| 1792 | * @param mixed $ajustaCuentaT = 'NO' Bandera para saber si ajusta cuenta T o no. |
| 1793 | * @return |
| 1794 | */ |
| 1795 | function borraDocumentoPago($documento = 'cheque', $documentoPagoID = '', $ajustaCuentaT = 'NO', $do = 'SI', $razon_cancelacion = ""): bool|array |
| 1796 | { |
| 1797 | global $gIAsql; |
| 1798 | $gIAsql['sql_trace'] = true; |
| 1799 | |
| 1800 | if(empty($documentoPagoID)) |
| 1801 | return false; |
| 1802 | |
| 1803 | $pk_field = $documento.'_id'; |
| 1804 | |
| 1805 | $now = date('Y-m-d H:i:s'); |
| 1806 | $usuario = $_SESSION['usuario']; |
| 1807 | |
| 1808 | $sql=array(); |
| 1809 | $commentSQL = " /** borraDocumentoPago **/"; |
| 1810 | |
| 1811 | // a cuenta de que cheque,pagare,... |
| 1812 | $cat=$documento; |
| 1813 | $collection['base_table']=$documento; |
| 1814 | $collection['pk_campo']=$pk_field; |
| 1815 | $collection['collection']=$collection['base_table']; |
| 1816 | |
| 1817 | $qtyEs='quantity'; |
| 1818 | $sufijo_pago = $documento === 'vale' ? '_uso' : '_pago'; |
| 1819 | $doc_pago_tabla = strtolower($documento.$sufijo_pago); |
| 1820 | |
| 1821 | $dpsql = "SELECT $commentSQL * FROM ".$documento.$sufijo_pago." WHERE ".$documento.$sufijo_pago."_id=".strit($documentoPagoID); |
| 1822 | $documentoPago = ia_singleton($dpsql); |
| 1823 | if(empty($documentoPago)) |
| 1824 | return false; |
| 1825 | |
| 1826 | $itemID=$documentoPago[$documento."_id"]; |
| 1827 | |
| 1828 | $cuentaT_mov_ori_id=$documentoPago["cuenta_t_mov_id"]; |
| 1829 | |
| 1830 | $cuentat_mov_id_field = $documento === 'vale' ? "contra_mov_id" : "cuentaT_mov_id"; |
| 1831 | |
| 1832 | $vs_doc = $documentoPago['vs_doc'] ?? $documento; |
| 1833 | $vs_doc = strtolower($vs_doc); |
| 1834 | |
| 1835 | $sql_cuentat = "SELECT * FROM cuentat_mov WHERE $cuentat_mov_id_field = '$cuentaT_mov_ori_id'"; |
| 1836 | //echo "<li>$sql_cuentat"; |
| 1837 | $cuentaT_arr = ia_singleton("$sql_cuentat"); |
| 1838 | $cuentaT_mov_ori_contra_id = $cuentaT_arr['contra_mov_id']; |
| 1839 | |
| 1840 | // echo "<pre>cuentaT_arr" . print_r($cuentaT_arr, true) . "</pre>"; |
| 1841 | // echo "<pre>documentoPago" . print_r($documentoPago, true) . "</pre>"; |
| 1842 | |
| 1843 | $app_origen = $cuentaT_arr['app_origen'] ?? ucfirst($collection['base_table']); |
| 1844 | |
| 1845 | if(empty($cuentaT_arr)) |
| 1846 | return false; |
| 1847 | |
| 1848 | if(empty($cuentaT_mov_ori_id)) |
| 1849 | return false; |
| 1850 | |
| 1851 | // obten el item |
| 1852 | $item=ia_singleton("SELECT $commentSQL * FROM $collection[base_table] WHERE $collection[pk_campo]=".strit($itemID)); |
| 1853 | /** |
| 1854 | if(empty($item)) |
| 1855 | { |
| 1856 | //return false; |
| 1857 | } |
| 1858 | * **/ |
| 1859 | |
| 1860 | $cliente=''; |
| 1861 | if (empty($item['cliente_id']) and !empty($item['cliente'])){ |
| 1862 | $cliente = $item['cliente']; |
| 1863 | } else { |
| 1864 | $cliente_id=$item['cliente_id']; |
| 1865 | if(empty($cliente_id)) $cliente_id=$item['cliente_proveedor_id']; |
| 1866 | if($cliente_id==0) |
| 1867 | $cliente=$item['name_on_check']; |
| 1868 | |
| 1869 | if($cliente_id>0) |
| 1870 | $cliente=ia_singleread("SELECT $commentSQL nombre FROM cliente WHERE cliente_id=".strit($cliente_id)); |
| 1871 | $cliente=ia_htmlentities($cliente); |
| 1872 | } |
| 1873 | |
| 1874 | // obten el pago |
| 1875 | $pago=$documentoPago; |
| 1876 | |
| 1877 | $pago_log_id = ia_guid(); |
| 1878 | $cuentaT_mov_canc_id=ia_guid(); |
| 1879 | |
| 1880 | $monto_afecta_cheque=-$pago['quantity']; |
| 1881 | $catID=tablaid($collection['base_table']); |
| 1882 | |
| 1883 | if(empty($catID)) |
| 1884 | if($cat=='cheque') |
| 1885 | $catID=1000; |
| 1886 | elseif($cat=='pagare') |
| 1887 | $catID=1001; |
| 1888 | elseif($cat=='vale') |
| 1889 | $catID=1002; |
| 1890 | elseif($cat=='nota') |
| 1891 | $catID=1003; |
| 1892 | |
| 1893 | $monedaacta_txt=$pago['moneda_id']==1?' PESOS':''; |
| 1894 | $monedadocto_txt=$item['moneda_id']==1?' PESOS':''; |
| 1895 | |
| 1896 | $monedaacta_txt=$pago['moneda_id']==1?' PESOS':''; |
| 1897 | $monedadocto_txt=$item['moneda_id']==1?' PESOS':''; |
| 1898 | |
| 1899 | $moneda_signo_acta=$pago['moneda_id']==1?'$':'USD'; |
| 1900 | $moneda_signo_docto=$item['moneda_id']==1?'$':'USD'; |
| 1901 | |
| 1902 | $monto_acta_txt = $monto_acta_link_txt = ""; |
| 1903 | |
| 1904 | if($monedadocto_txt == '') |
| 1905 | $class = 'txt_color_USD'; |
| 1906 | else |
| 1907 | $class = 'txt_color_PESOS'; |
| 1908 | |
| 1909 | if($monedaacta_txt == '') |
| 1910 | $class_acta = 'txt_color_USD'; |
| 1911 | else |
| 1912 | $class_acta = 'txt_color_PESOS'; |
| 1913 | |
| 1914 | |
| 1915 | if($pago['moneda_id']!=$item['moneda_id']) |
| 1916 | { |
| 1917 | $monto_acta_txt = "POR <strong class=\"$class\">$moneda_signo_docto ".echonf(abs($monto_afecta_cheque),true)."$monedadocto_txt</strong>"; |
| 1918 | $monto_acta_link_txt = "POR <strong class=\"$monedaacta_txt\">$moneda_signo_acta " .echonf(abs(-$pago['deposit_total']),true)."$monedaacta_txt (<strong class=\"$class\">$moneda_signo_docto> ".echonf(abs($monto_afecta_cheque),true)."$monedadocto_txt</strong>)</strong>"; |
| 1919 | } |
| 1920 | else |
| 1921 | { |
| 1922 | $monto_acta_txt = "POR <strong class=\"$monedaacta_txt\">$moneda_signo_acta " .echonf(abs($monto_afecta_cheque),true). "$monedaacta_txt</strong>"; |
| 1923 | $monto_acta_link_txt = "POR <strong class=\"$monedaacta_txt\">$moneda_signo_acta " .echonf(abs(-$pago['deposit_total']),true). "$monedaacta_txt</strong>"; |
| 1924 | } |
| 1925 | |
| 1926 | // dd_($collection['base_table']); |
| 1927 | |
| 1928 | $field_number = $collection['base_table'] == 'vale' ? 'vale_number' : 'numero'; |
| 1929 | $in = array_key_exists($field_number,$item) ? $item[$field_number] : $item[$field_number]; |
| 1930 | $aDoc = "<a title='Abrir el $collection[base_table]' href='../backoffice/$collection[base_table].php?iah=e&id=$itemID' target='_blank'><strong>".strtoupper($collection['base_table'])." # $in</strong></a>"; |
| 1931 | |
| 1932 | $note = $comentario = "<li>SE ELIMINA EL <strong><em>A CUENTA</em></strong> $monto_acta_txt DEL <strong>***</strong>$aDoc, " |
| 1933 | ."CLIENTE: <strong>".$cliente."</strong>, <strong class=\"$class\">$moneda_signo_docto " |
| 1934 | .echonf($item['quantity'],true)."$monedadocto_txt</strong><strong>***</strong>.". |
| 1935 | "<br /><br /><span class=\"txt_080em\">USUARIO RESPONSABLE: </span><strong>$usuario</strong>."; |
| 1936 | |
| 1937 | $comentariopl = "<li>SE ROMPE LINK $monto_acta_link_txt DEL <strong><em>A CUENTA</em></strong> $monto_acta_txt DEL <strong>***</strong>$aDoc, " |
| 1938 | ."CLIENTE: <strong>".$cliente."</strong>, <strong class=\"$class\">$moneda_signo_docto " |
| 1939 | .echonf($item['quantity'],true)."$monedadocto_txt</strong>***.". |
| 1940 | "<br /><br/><span class=\"txt_080em\">USUARIO RESPONSABLE: </span>"; |
| 1941 | |
| 1942 | |
| 1943 | $metodo_pago = ''; // VCA. |
| 1944 | $banco_cuenta_mov_id = array_key_exists( 'banco_cuenta_mov_link_id',$pago) ? $pago['banco_cuenta_mov_link_id'] : null; |
| 1945 | $pago['banco_cuenta_mov_link_id'] = ''; //VCA: Para activar el trigger de saldo de cuenta T. |
| 1946 | $tienda_id = empty($pago['tienda_id']) ? $item['tienda_id'] : $pago['tienda_id']; |
| 1947 | |
| 1948 | $cuentaT_mov_link_ori_id = ""; |
| 1949 | |
| 1950 | /**Arreglo del totalpayments y saldo en cheques y pagares **/ |
| 1951 | $tpsql = "SELECT /** Calculo total_payments **/ IF(ISNULL(SUM($qtyEs)),0,SUM($qtyEs)) FROM ".$documento."_pago WHERE $collection[pk_campo]=".strit($itemID)." AND ".$documento."_pago_id<>".strit($documentoPagoID); |
| 1952 | |
| 1953 | $doc_total_payments = ia_singleread($tpsql); |
| 1954 | |
| 1955 | $tuvoLink = false; |
| 1956 | |
| 1957 | if( !empty($banco_cuenta_mov_id ) && $banco_cuenta_mov_id != 'pendiente' && $banco_cuenta_mov_id != 'roto' ) |
| 1958 | { |
| 1959 | //VCA |
| 1960 | $accion='RompeLink'; |
| 1961 | $sinJSON=true; |
| 1962 | // regresa true si pudo false si no pudo |
| 1963 | $tuvoLink=RompeLinkBancario($banco_cuenta_mov_id ,$usuario,addslashes($comentariopl), $note, false); |
| 1964 | if(is_array($tuvoLink) && !empty($tuvoLink) && array_key_exists('sql', $tuvoLink) && is_array($tuvoLink['sql'])) |
| 1965 | { |
| 1966 | foreach($tuvoLink['sql'] as $v) |
| 1967 | $sql[] = $v; |
| 1968 | } |
| 1969 | |
| 1970 | //echo "tuvoLink: <pre>".print_r($tuvoLink, true)."</pre>"; |
| 1971 | |
| 1972 | // ** // ia_query("DELETE FROM $collection[base_table]_pago WHERE $collection[base_table]_pago_id=".strit($documentoPagoID)." LIMIT 1"); |
| 1973 | $sql[]="DELETE $commentSQL FROM $collection[base_table]_pago WHERE $collection[base_table]_pago_id=".strit($documentoPagoID)." LIMIT 1"; |
| 1974 | // ** // ia_query("UPDATE $collection[base_table] SET total_payments=total_payments+$monto_afecta_cheque, paid='0', paid_when=NULL WHERE $collection[pk_campo]=".strit($itemID )." LIMIT 1"); |
| 1975 | $autorizado=$item['autorizado']=='Si'?true:false; |
| 1976 | $ultimo_mov=""; |
| 1977 | |
| 1978 | //VCA bitácora de verificaciones. 24-11-2020 |
| 1979 | //if($autorizado && !is_array($tuvoLink) && empty($tuvoLink)) |
| 1980 | //$ultimo_mov=",ultimo_movimiento='A CUENTA BORRADO', desautorizado_el='$now', autorizado='No', autorizado_el=NULL"; |
| 1981 | //$ultimo_mov=", desautorizado_el='$now', autorizado='No', autorizado_el=NULL"; |
| 1982 | //VCA bitácora de verificaciones. 24-11-2020 |
| 1983 | //OJO VCA aquí empieza el 25-11-2020 |
| 1984 | //JJ validacion para definicion de campo de cuantat_mov_id, en vale tiene otro nombre |
| 1985 | $campoCuantaTMovId = trim($collection['base_table']) == 'vale' ? 'cuenta_t_mov_id': 'cuentat_mov_id'; |
| 1986 | $saldos = "total_payments=$doc_total_payments,"; |
| 1987 | if (trim($collection['base_table']) == 'vale') { |
| 1988 | //VCA 01-Jun-2021 Rony pidió que cuando se borre un vale_pago y el vale quede en cero, se ponga aplicado. Sólo él puede revivirlo, agregando un vale_pago solamente. |
| 1989 | $extra_aplicado = ""; |
| 1990 | if($item['saldo'] - $pago['quantity'] <= 0) |
| 1991 | $extra_aplicado = " aplicado = 1, paid = 1, "; |
| 1992 | $saldos = "quantity = quantity - $pago[quantity], saldo = saldo - $pago[quantity]," . $extra_aplicado; |
| 1993 | } |
| 1994 | |
| 1995 | $sql[]="UPDATE $commentSQL $collection[base_table] SET |
| 1996 | $saldos |
| 1997 | paid='0', |
| 1998 | paid_when=NULL, |
| 1999 | ultimo_cambio='$now', |
| 2000 | ultimo_cambio_por='$usuario', |
| 2001 | puede_borrar='Si', |
| 2002 | $campoCuantaTMovId='$cuentaT_mov_canc_id' |
| 2003 | $ultimo_mov |
| 2004 | WHERE $collection[pk_campo]=".strit($itemID)." LIMIT 1"; |
| 2005 | |
| 2006 | //if($ajustaCuentaT == 'SI') //Si tiene link bancario, se ajusta la cuenta T forzosamente. Estoy seguro de que después querrá lo contrario. |
| 2007 | //{ |
| 2008 | $ajustaCuentaT = 'SI'; |
| 2009 | |
| 2010 | $contra_mov_id = ''; |
| 2011 | |
| 2012 | if(is_array($tuvoLink) && $tuvoLink != false) |
| 2013 | { |
| 2014 | //$cuentaT_arr = ia_singleton("SELECT $commentSQL /** Link ya roto **/ * FROM cuentat_mov WHERE cuentaT_mov_id = '$tuvoLink[link_roto_id]'"); |
| 2015 | $cuentaT_arr = $tuvoLink['arr_cuentat_mov']; |
| 2016 | //$cuentaT_mov_ori_id = $tuvoLink['cuentat_mov']; |
| 2017 | $cuentaT_mov_link_ori_id = $tuvoLink['link_ori_id']; |
| 2018 | //De volada actualizo el movimiento de cuenta t original y lo marco como que si tiene contraparte. |
| 2019 | // ** // ia_query("UPDATE cuentat_mov SET activo='No' WHERE cuentaT_mov_id='$tuvoLink[cuentat_mov]'"); |
| 2020 | $sql[]="UPDATE $commentSQL /** Link ya roto **/ cuentat_mov |
| 2021 | SET activo='No', banco_cuenta_mov_link_id='$cuentaT_mov_ori_id', origen_mov_id = '$pago_log_id' |
| 2022 | WHERE cuentaT_mov_id='$cuentaT_mov_ori_id' OR contra_mov_id='$cuentaT_mov_ori_id'"; |
| 2023 | //Aqui falta el original. |
| 2024 | // // // // // // // // // // // |
| 2025 | $contra_mov_id = $tuvoLink['link_roto_id']; |
| 2026 | //generayGuardaaCuentasdeBancoMov($tuvoLink['banco_cuenta_mov_id']); |
| 2027 | } |
| 2028 | else |
| 2029 | { |
| 2030 | $cuentaT_arr = ia_singleton("SELECT * FROM cuentat_mov WHERE origen_mov_id = '$documentoPagoID' ORDER BY alta_db ASC"); |
| 2031 | } |
| 2032 | |
| 2033 | //De volada actualizo el movimiento de cuenta t original y lo marco como que si tiene contraparte. |
| 2034 | // ** // ia_query("UPDATE cuentat_mov SET contra_mov_id='$cuentaT_mov_canc_id', activo='No' WHERE cuentaT_mov_id='$cuentaT_arr[cuentaT_mov_id]'"); |
| 2035 | $sql[]="UPDATE cuentat_mov SET contra_mov_id='$cuentaT_mov_canc_id', activo='No', banco_cuenta_mov_link_id='$cuentaT_mov_ori_id' WHERE cuentaT_mov_id='$cuentaT_arr[cuentaT_mov_id]'"; |
| 2036 | |
| 2037 | $cuentaT_arr['origen_mov_id'] = $cuentaT_arr['cuentaT_mov_id']; |
| 2038 | $dateTmp = new DateTime($cuentaT_arr['alta_db']); |
| 2039 | $dateTmp->modify('+1 second'); |
| 2040 | $now=$dateTmp->format('Y-m-d H:i:s'); |
| 2041 | |
| 2042 | if(empty($cuentaT_arr)) |
| 2043 | { |
| 2044 | $cuentaT_arr['cuentaT_id']=$pago['cuentaT_id']; |
| 2045 | $cuentaT_arr['cuentaT_tipo_mov_id']=$pago['metodo_pago_id']; |
| 2046 | $cuentaT_arr['app_origen']=ucfirst($collection['base_table']); |
| 2047 | } |
| 2048 | |
| 2049 | $pago['comentario']=$comentario."<li>".$pago['comentario']; |
| 2050 | $sql[]="INSERT $commentSQL INTO cuentat_mov (cuentaT_mov_id,cuentaT_id,fecha |
| 2051 | ,cuentaT_tipo_mov_id |
| 2052 | ,egreso,quantity_total,moneda_id,tipo_cambio |
| 2053 | ,banco_cuenta_id,referencia,remarks |
| 2054 | ,banco_cuenta_mov_link_id |
| 2055 | ,alta_por,esta_en,alta_db,tipo,origen_mov_id,app_origen,fecha_deposito,deposit_total,contra_mov_id,activo,tienda_id) |
| 2056 | VALUES(".stritc($cuentaT_mov_canc_id).stritc($cuentaT_arr['cuentaT_id'])."'$now'," |
| 2057 | .stritc($cuentaT_arr['cuentaT_tipo_mov_id']) |
| 2058 | .stritc($pago['quantity_ctat']).stritc($pago['quantity_total']).stritc($pago['moneda_id']).stritc($pago['tipo_cambio']) |
| 2059 | .stritc($pago['banco_cuenta_id']).stritc($pago['referencia']).stritc($pago['comentario']) |
| 2060 | //.stritc($pago['banco_cuenta_mov_link_id']) |
| 2061 | .stritc($cuentaT_mov_ori_id) |
| 2062 | .stritc($usuario)."'done','$now','Egreso'," |
| 2063 | .stritc($cuentaT_arr['origen_mov_id']) |
| 2064 | .stritc($cuentaT_arr['app_origen']) |
| 2065 | .stritc($pago["deposit_fecha"]) |
| 2066 | .stritc($pago['deposit_total']) |
| 2067 | .stritc($contra_mov_id)."'No', ".strit($tienda_id)." )"; |
| 2068 | // ** //ia_query($sql); |
| 2069 | //} |
| 2070 | |
| 2071 | //HAck porque no doy cómo poner este uuid desde la funcion rompelinkbancario |
| 2072 | $sql[]="UPDATE cuentat_mov SET banco_cuenta_mov_link_id='$cuentaT_mov_ori_id' WHERE cuentaT_mov_id='$contra_mov_id'"; |
| 2073 | // ** //ia_query($sql); |
| 2074 | } |
| 2075 | else if($doc_pago_tabla !== 'vale_uso') |
| 2076 | { |
| 2077 | // ** // ia_query("DELETE FROM $collection[base_table]_pago WHERE $collection[base_table]_pago_id=".strit($documentoPagoID)." LIMIT 1"); |
| 2078 | $sql[]="DELETE $commentSQL FROM $collection[base_table]_pago WHERE $collection[base_table]_pago_id=".strit($documentoPagoID)." LIMIT 1"; |
| 2079 | // ** // ia_query("UPDATE $collection[base_table] SET total_payments=total_payments+$monto_afecta_cheque, paid='0', paid_when=NULL WHERE $collection[pk_campo]=".strit($itemID )." LIMIT 1"); |
| 2080 | //$total_payments=ia_singleread("SELECT SUM(quantity) FROM cheuqe_pago WHERE cheqie_id=IDDELDOC"); |
| 2081 | |
| 2082 | //VCA bitácora de verificaciones. 24-11-2020 |
| 2083 | //ultimo_movimiento='A CUENTA BORRADO', |
| 2084 | // autorizado='No', |
| 2085 | // autorizado_el=NULL, |
| 2086 | // desautorizado_el='$now', |
| 2087 | //$campoCuantaTMovId = trim($collection['base_table']) == 'vale' ? 'cuenta_t_mov_id': 'cuentat_mov_id'; |
| 2088 | $campoCuantaTMovId = trim($collection['base_table']) == 'vale' ? ", cuenta_t_mov_id = '$cuentaT_mov_canc_id'": ''; |
| 2089 | $saldos = "total_payments=$doc_total_payments,"; |
| 2090 | if (trim($collection['base_table']) == 'vale') { |
| 2091 | //VCA 01-Jun-2021 Rony pidió que cuando se borre un vale_pago y el vale quede en cero, se ponga aplicado. Sólo él puede revivirlo, agregando un vale_pago solamente. |
| 2092 | $extra_aplicado = ""; |
| 2093 | if($item['saldo'] - $pago['quantity'] <= 0) |
| 2094 | $extra_aplicado = " aplicado = 1, paid = 1, "; |
| 2095 | $saldos = "quantity = quantity - $pago[quantity], saldo = saldo - $pago[quantity]," . $extra_aplicado; |
| 2096 | } |
| 2097 | $sql[]="UPDATE $commentSQL $collection[base_table] SET |
| 2098 | $saldos |
| 2099 | paid='0', |
| 2100 | paid_when=NULL, |
| 2101 | ultimo_cambio='$now', |
| 2102 | ultimo_cambio_por='$usuario', |
| 2103 | puede_borrar='Si' $campoCuantaTMovId |
| 2104 | WHERE $collection[pk_campo]=".strit($itemID )." LIMIT 1"; |
| 2105 | |
| 2106 | $razon_cancelacion = empty($razon_cancelacion)?'':"<br/><br/><span class=\"txt_080em\">MOTIVO DE CANCELACIÓN:</span> <span class=\"remarks_por_usuario motivo_cancelacion\">" . $razon_cancelacion . "</span>"; |
| 2107 | $comentario_original = empty($pago['comentario'])?$razon_cancelacion:"$razon_cancelacion<hr class=\"dashed_red\"/><span class=\"txt_080em\">REMARKS ORIGINALES:</span> <span class=\"remarks_por_usuario\">" . $pago['comentario'] . "</span>"; |
| 2108 | |
| 2109 | if(!empty($pago['vs_doc']) && !empty($pago['vs_doc_key'])) |
| 2110 | { |
| 2111 | $pago['comentario']=$comentario.$comentario_original;//"<li>".$pago['comentario']; |
| 2112 | $ajustaCuentaT = 'NO'; |
| 2113 | } |
| 2114 | else |
| 2115 | { |
| 2116 | $pago['comentario']=$comentario.$comentario_original.($ajustaCuentaT=="NO" ? "<br><br><span class='sin_ajustar_cuentat'>SIN AJUSTAR CUENTA T.</span>":"<br><br><span class='con_ajustar_cuentat'>SE AJUSTÓ CUENTA T.</span>");//"<li>".$pago['comentario']; |
| 2117 | } |
| 2118 | |
| 2119 | if($ajustaCuentaT=='NO') |
| 2120 | { |
| 2121 | /*$activo_txt=""; |
| 2122 | $activo="Si";*/ |
| 2123 | $activo_txt=", activo='No'"; |
| 2124 | $activo="No"; |
| 2125 | } |
| 2126 | else |
| 2127 | { |
| 2128 | $activo_txt=", activo='No'"; |
| 2129 | $activo="No"; |
| 2130 | } |
| 2131 | |
| 2132 | $cuentaT_sql = "SELECT * FROM cuentat_mov WHERE origen_mov_id = '$documentoPagoID'"; |
| 2133 | |
| 2134 | //echo "<li>$cuentaT_sql"; //VCA OJO, ARREGLAR cuenta_t_mov_id de los vale_pago importados. Arreglado por José 20-02-2021 |
| 2135 | |
| 2136 | $cuentaT_arr = ia_singleton($cuentaT_sql); |
| 2137 | |
| 2138 | //$cuentaT_mov_ori_id = $cuentaT_arr['cuentaT_mov_id']; |
| 2139 | //De volada actualizo el movimiento de cuenta t original y lo marco como que si tiene contraparte. |
| 2140 | // ** // ia_query("UPDATE cuentat_mov SET contra_mov_id='$cuentaT_mov_canc_id', activo='No' WHERE cuentaT_mov_id='$cuentaT_arr[cuentaT_mov_id]'"); |
| 2141 | $sql[]="UPDATE $commentSQL cuentat_mov SET banco_cuenta_mov_link_id='$cuentaT_mov_ori_id', contra_mov_id='$cuentaT_mov_canc_id' $activo_txt WHERE cuentaT_mov_id='$cuentaT_arr[cuentaT_mov_id]'"; |
| 2142 | |
| 2143 | $cuentaT_arr['origen_mov_id'] = $cuentaT_arr['cuentaT_mov_id']; |
| 2144 | |
| 2145 | if(empty($cuentaT_arr)) |
| 2146 | { |
| 2147 | $cuentaT_arr['cuentaT_id']=$pago['cuentaT_id']; |
| 2148 | $cuentaT_arr['cuentaT_tipo_mov_id']=$pago['metodo_pago_id']; |
| 2149 | $cuentaT_arr['app_origen']=ucfirst($collection['base_table']); |
| 2150 | } |
| 2151 | |
| 2152 | //VCA 17-09-2021 El contramovimiento en compra es ingreso. No había sucedido antes. |
| 2153 | $tipo_cuentat_mov = 'Egreso'; |
| 2154 | $monto_cuentat_mov = 0.00; |
| 2155 | $egreso_cuentat_mov = $ajustaCuentaT=='SI' ? $pago['quantity_ctat']: 0.00; |
| 2156 | if($documento == 'compra') { |
| 2157 | $tipo_cuentat_mov = 'Ingreso'; |
| 2158 | $monto_cuentat_mov = $ajustaCuentaT=='SI' ? $egreso_cuentat_mov : 0.00; |
| 2159 | $egreso_cuentat_mov = 0.00; |
| 2160 | } |
| 2161 | $sql[]="INSERT INTO cuentat_mov (cuentaT_mov_id,cuentaT_id,fecha |
| 2162 | ,cuentaT_tipo_mov_id |
| 2163 | ,egreso,monto,quantity_total,moneda_id,tipo_cambio |
| 2164 | ,banco_cuenta_id,referencia,remarks |
| 2165 | ,banco_cuenta_mov_link_id |
| 2166 | ,alta_por,esta_en,alta_db,tipo,origen_mov_id,app_origen,contra_mov_id,fecha_deposito,deposit_total,activo,tienda_id) |
| 2167 | VALUES(".stritc($cuentaT_mov_canc_id).stritc($cuentaT_arr['cuentaT_id'])."'$now'," |
| 2168 | .stritc($cuentaT_arr['cuentaT_tipo_mov_id']) |
| 2169 | .stritc($egreso_cuentat_mov) |
| 2170 | .stritc($monto_cuentat_mov) |
| 2171 | .stritc($pago['quantity_total']) |
| 2172 | .stritc($pago['moneda_id']) |
| 2173 | .stritc($pago['tipo_cambio']) |
| 2174 | .stritc($pago['banco_cuenta_id']) |
| 2175 | .stritc($pago['referencia']) |
| 2176 | .stritc($pago['comentario']) |
| 2177 | .stritc($cuentaT_mov_ori_id) |
| 2178 | .stritc($usuario) |
| 2179 | ."'done','$now'," |
| 2180 | .stritc($tipo_cuentat_mov) |
| 2181 | .stritc($cuentaT_arr['origen_mov_id']) |
| 2182 | .stritc($cuentaT_arr['app_origen']) |
| 2183 | .stritc($cuentaT_arr['origen_mov_id']) |
| 2184 | .stritc($pago["deposit_fecha"]) |
| 2185 | .stritc($pago['deposit_total']) |
| 2186 | .stritc($activo) |
| 2187 | .strit($tienda_id).")"; |
| 2188 | // ** // ia_query($sql); |
| 2189 | |
| 2190 | // ** // ia_query($sql); |
| 2191 | } |
| 2192 | |
| 2193 | if($doc_pago_tabla !== 'vale_uso') { |
| 2194 | $sql[] = "INSERT INTO kv_record_log(collection_id,record_id,usuario,note,kv_accion_log_id,alta_db) VALUES(" |
| 2195 | . stritc($catID) . stritc($itemID) . stritc($usuario) . stritc($note) . "11,NOW())"; |
| 2196 | |
| 2197 | //Insertamos un registro en bitacora de a cuentas. |
| 2198 | // if(empty($pago['comentario'])) |
| 2199 | // $pago['comentario']=$comentario.$pago['comentario']; |
| 2200 | // if($ajustaCuentaT == 'SI') |
| 2201 | // $pago["comentario"] .= "<br/>SE AJUSTÓ CUENTA T."; |
| 2202 | $sql[] = "INSERT INTO $collection[base_table]_pago_log ( |
| 2203 | $collection[base_table]_pago_log_id, |
| 2204 | $collection[base_table]_pago_id, |
| 2205 | $collection[collection]_id, |
| 2206 | fecha_borrado, |
| 2207 | fecha, |
| 2208 | quantity, |
| 2209 | quantity_total, |
| 2210 | deposit_total, |
| 2211 | ide_percent, |
| 2212 | ide_amount, |
| 2213 | tarjeta_percent, |
| 2214 | tarjeta_amount, |
| 2215 | moneda_id, |
| 2216 | tipo_cambio, |
| 2217 | metodo_pago_id, |
| 2218 | banco_cuenta_id, |
| 2219 | banco_cuenta_mov_link_id, |
| 2220 | referencia, |
| 2221 | comentario, |
| 2222 | ultimo_cambio_por, |
| 2223 | alta_por, |
| 2224 | cuentaT_id, |
| 2225 | deposit_fecha, |
| 2226 | numero, |
| 2227 | comision_amount, |
| 2228 | comision_percent, |
| 2229 | ultimo_cambio, |
| 2230 | factura, |
| 2231 | ivacobradox100, |
| 2232 | ivacobradototal, |
| 2233 | empresa_id, |
| 2234 | factura_numero, |
| 2235 | cash_nota_num, |
| 2236 | cliente, |
| 2237 | tipo_cash_nota, |
| 2238 | cobra_iva, |
| 2239 | tienda_id, |
| 2240 | numero_referencia, |
| 2241 | cuenta_t_mov_id) |
| 2242 | VALUES(" . |
| 2243 | stritc($pago_log_id) . |
| 2244 | stritc($pago["$collection[base_table]_pago_id"]) . |
| 2245 | stritc($pago["$collection[base_table]_id"]) . |
| 2246 | stritc($now) . |
| 2247 | stritc($pago["fecha"]) . |
| 2248 | stritc($pago["quantity"]) . |
| 2249 | stritc($pago["quantity_total"]) . |
| 2250 | stritc($pago["deposit_total"]) . |
| 2251 | stritc($pago["ide_percent"]) . |
| 2252 | stritc($pago["ide_amount"]) . |
| 2253 | stritc($pago["tarjeta_percent"]) . |
| 2254 | stritc($pago["tarjeta_amount"]) . |
| 2255 | stritc($pago["moneda_id"]) . |
| 2256 | stritc($pago["tipo_cambio"]) . |
| 2257 | stritc($pago["metodo_pago_id"]) . |
| 2258 | stritc($pago["banco_cuenta_id"]) . |
| 2259 | stritc($pago["banco_cuenta_mov_link_id"]) . |
| 2260 | stritc($pago["referencia"]) . |
| 2261 | "'" . addslashes($pago["comentario"]) . "'," . |
| 2262 | stritc($usuario) . |
| 2263 | stritc($usuario) . |
| 2264 | stritc($pago["cuentaT_id"]) . |
| 2265 | stritc($pago["deposit_fecha"]) . |
| 2266 | stritc($pago['numero']) . |
| 2267 | stritc($pago['comision_amount']) . |
| 2268 | stritc($pago['comision_percent']) . |
| 2269 | stritc($now) . |
| 2270 | stritc($pago['factura']) . |
| 2271 | stritc($pago['ivacobradox100']) . |
| 2272 | stritc($pago['ivacobradototal']) . |
| 2273 | stritc($pago['empresa_id']) . |
| 2274 | stritc($pago['factura_numero']) . |
| 2275 | stritc($pago['cash_nota_num']) . |
| 2276 | stritc($pago['cliente']) . |
| 2277 | stritc($pago['tipo_cash_nota']) . |
| 2278 | stritc($pago['cobra_iva']) . |
| 2279 | stritc($pago['tienda_id']) . |
| 2280 | stritc($pago['numero_referencia']) . |
| 2281 | strit($cuentaT_mov_canc_id) . ")"; |
| 2282 | // ** // ia_query($sql); |
| 2283 | } |
| 2284 | //@TODO: si es pago via sustituye. Revisar origen y contra id |
| 2285 | if(!empty($pago['vs_doc']) && !empty($pago['vs_doc_key'])) |
| 2286 | { |
| 2287 | $vs_doc=strtolower($pago['vs_doc']); |
| 2288 | $pago['vs_pago_key'] = $doc_pago_tabla == 'vale_uso' ? $pago['vale_uso_id'] : $pago['vs_pago_key']; |
| 2289 | $vsDoc=ia_singleton("SELECT * FROM $vs_doc WHERE $vs_doc"."_id=".strit($pago['vs_doc_key']) ); |
| 2290 | $vsPago=ia_singleton("SELECT * FROM $vs_doc"."_uso WHERE $vs_doc"."_uso_id=".strit($pago['vs_pago_key']) ); |
| 2291 | //echo print_r($vsPago,true); |
| 2292 | |
| 2293 | // echo "<pre>vsDoc" . print_r($vsDoc, true) . "</pre>"; |
| 2294 | // echo "<pre>vsPago" . print_r($vsPago, true) . "</pre>"; |
| 2295 | |
| 2296 | //echo "SELECT * FROM $vs_doc"."_uso WHERE $vs_doc"."_uso_id=".strit($pago['vs_pago_key']); |
| 2297 | |
| 2298 | $vsPagoLog = $vsPago; |
| 2299 | $vsPagoLog['alta_por']=$usuario; |
| 2300 | $vsPagoLog['fecha_borrado']=$now; |
| 2301 | $vsPagoLog['comentario']=$comentario; |
| 2302 | $vsPagoLog['vale_uso_log_id']=ia_guid(); |
| 2303 | $vsPagoLog['cuenta_t_mov_id']=$cuentaT_mov_canc_id; |
| 2304 | $sql[] = ia_insert($vs_doc.'_uso_log',$vsPagoLog); |
| 2305 | // ** // ia_query($sql); |
| 2306 | $aplicado = ''; |
| 2307 | $update_origen_id = ''; |
| 2308 | if($vs_doc == 'vale') { |
| 2309 | $aplicado = ',aplicado=0'; |
| 2310 | $update_origen_id = ' ,origen_mov_id = ' . strit($pago['vs_doc_key']); |
| 2311 | } |
| 2312 | |
| 2313 | // ** // ia_query("UPDATE $vs_doc SET total_payments=total_payments-".strit($pago['quantity_total']).",paid=0, paid_when=NULL $aplicado WHERE $vs_doc"."_id=".strit($pago['vs_doc_key'])." LIMIT 1" ); |
| 2314 | //$total_payments=ia_singleread("SELECT SUM(quantity) FROM cheuqe_pago WHERE cheqie_id=IDDELDOC"); |
| 2315 | |
| 2316 | /**Arreglo del totalpayments y saldo en cheques y pagares **/ |
| 2317 | $tpsql = "SELECT /**Calculo total_payments **/ IF(isnull(SUM($qtyEs)),0,SUM($qtyEs)) FROM ".$vs_doc."_uso WHERE $vs_doc"."_id=".strit($pago['vs_doc_key'])." AND ".$vs_doc."_uso_id<>".strit($pago['vs_pago_key']); |
| 2318 | // echo "<li>".$tpsql; |
| 2319 | $doc_total_payments = ia_singleread($tpsql); |
| 2320 | |
| 2321 | $sql[]="UPDATE $vs_doc SET total_payments=$doc_total_payments,paid=0, paid_when=NULL $aplicado WHERE $vs_doc"."_id=".strit($pago['vs_doc_key'])." LIMIT 1"; |
| 2322 | // ** // ia_query("DELETE FROM $vs_doc"."_uso WHERE $vs_doc"."_uso_id=".strit($pago['vs_pago_key'])." LIMIT 1" ); |
| 2323 | $sql[]="DELETE FROM $vs_doc"."_uso WHERE $vs_doc"."_uso_id=".strit($pago['vs_pago_key'])." LIMIT 1"; |
| 2324 | |
| 2325 | $comentario = addslashes($comentario); |
| 2326 | $sql[]="UPDATE cuentat_mov SET activo = 'No', remarks = CONCAT('$comentario',remarks) $update_origen_id WHERE origen_mov_id = '$documentoPagoID' OR cuentaT_mov_id = '$cuentaT_mov_ori_id'"; |
| 2327 | |
| 2328 | // Agregamos otro log para el vale que se uso para sustituir. |
| 2329 | $cat_id=32; //tablaid($this->parentClass); // El id de la tabla vale en el catálogo de tablas: tablas |
| 2330 | |
| 2331 | $cat_accion = 15; //Sustituye |
| 2332 | $now = date('Y-m-d H:i:s'); |
| 2333 | |
| 2334 | $sql[]="INSERT INTO kv_record_log(collection_id,record_id,usuario,note,kv_accion_log_id,alta_db) VALUES(" |
| 2335 | .stritc($cat_id).stritc($pago['vs_doc_key']).stritc($usuario).stritc($note).stritc($cat_accion).strit($now).")"; |
| 2336 | // echo "<pre>sql" . print_r($sql, true) . "</pre>"; |
| 2337 | //echo "$sql"; |
| 2338 | |
| 2339 | // ** // ia_query($sql); |
| 2340 | } |
| 2341 | |
| 2342 | //FIX: VCA 14-07-2020 para que el movimiento en cuentat tenga el origen igual al contra. |
| 2343 | // $sql[] = "UPDATE /** FIX: contra=origen **/ cuentat_mov SET origen_mov_id='$cuentaT_mov_ori_id' WHERE cuentat_mov_id='$cuentaT_mov_ori_contra_id'"; |
| 2344 | |
| 2345 | |
| 2346 | actualizaSaldosACuentas($sql,null,$documento,$itemID,$documentoPagoID); |
| 2347 | if($do=='SI') |
| 2348 | { |
| 2349 | |
| 2350 | if(ia_transaction($sql)) { |
| 2351 | ia_errores_a_dime('','','',true); |
| 2352 | return false; |
| 2353 | } |
| 2354 | if(is_array($tuvoLink) && $tuvoLink != false) |
| 2355 | generayGuardaaCuentasdeBancoMov($tuvoLink['banco_cuenta_mov_id'], false, true, false, true); |
| 2356 | return true; |
| 2357 | } |
| 2358 | else |
| 2359 | return $sql; |
| 2360 | |
| 2361 | } |
| 2362 | |
| 2363 | function buscaClientesconNombreParecido($nombreCliente='', $campo='nombre', $tabla='cliente') |
| 2364 | { |
| 2365 | if(empty($nombreCliente)) |
| 2366 | return false; |
| 2367 | |
| 2368 | $onombreCliente = $nombreCliente = quitaespaciosintermedios($nombreCliente); |
| 2369 | |
| 2370 | $tmpNC = explode(" ",$nombreCliente); |
| 2371 | |
| 2372 | $cuantasPalabras = 0; |
| 2373 | if(sizeof($tmpNC)>1 && is_array($tmpNC) && !empty($tmpNC)) foreach($tmpNC as $k=>$v) |
| 2374 | { |
| 2375 | if(strlen($v) > 2) |
| 2376 | { |
| 2377 | $tmpNC[$k] = substr($v,0,2) . '%'; |
| 2378 | $cuantasPalabras++; |
| 2379 | } |
| 2380 | else |
| 2381 | unset($tmpNC[$k]); |
| 2382 | } |
| 2383 | |
| 2384 | if($cuantasPalabras>1) |
| 2385 | $nombreCliente = implode(' ',$tmpNC); |
| 2386 | else |
| 2387 | $nombreCliente = ''; |
| 2388 | |
| 2389 | //Hay que revisar siempre la busqueda identica. |
| 2390 | $clientesql = "SELECT $campo FROM $tabla WHERE $campo LIKE '$nombreCliente' OR $campo LIKE '$onombreCliente'"; |
| 2391 | $arr_cliEncontrados = ia_sqlArrayIndx($clientesql); |
| 2392 | //echo "<pre>".print_r($arr_cliEncontrados,true)."</pre>"; |
| 2393 | $txt_cliEncontrados = ''; |
| 2394 | |
| 2395 | if(is_array($arr_cliEncontrados) && sizeof($arr_cliEncontrados) > 0) foreach($arr_cliEncontrados as $k=>$v) |
| 2396 | { |
| 2397 | //echo "<pre>".print_r($v,true)."</pre>"; |
| 2398 | $txt_cliEncontrados.="<li><strong>$v[nombre]</strong>"; |
| 2399 | } |
| 2400 | |
| 2401 | return $txt_cliEncontrados; |
| 2402 | } |
| 2403 | |
| 2404 | function marcaCerradoDocumento($doc, $doc_id, $do='SI') |
| 2405 | { |
| 2406 | |
| 2407 | if(empty($doc) || empty($doc_id)) |
| 2408 | return false; |
| 2409 | //VCA está provocando deadlock por el trigger que actualiza el saldo |
| 2410 | $sql = array(); |
| 2411 | $sql[] = "SET @TRIGGER_DISABLED = 1;"; |
| 2412 | $sql[] = "UPDATE /*marcacerradoDocumento*/ $doc SET abierto_por = '', abierto_el = null WHERE ".$doc."_id = '$doc_id'"; |
| 2413 | $sql[] = "SET @TRIGGER_DISABLED = 0;"; |
| 2414 | |
| 2415 | //ia_query("INSERT INTO dime (script,dime,usuario) VALUES ('sql".ia_guid()."',".strit($sql).",".strit($_SESSION['usuario']).")"); |
| 2416 | |
| 2417 | if($do=='SI') |
| 2418 | { |
| 2419 | if(ia_transaction($sql)) |
| 2420 | return false; |
| 2421 | else |
| 2422 | return true; |
| 2423 | } |
| 2424 | else |
| 2425 | return $sql[1]; |
| 2426 | } |
| 2427 | |
| 2428 | function marcaAbiertoDocumento($doc, $doc_id, $usuario = '') |
| 2429 | { |
| 2430 | |
| 2431 | if(empty($doc) || empty($doc_id)) |
| 2432 | return false; |
| 2433 | |
| 2434 | $now = date('Y-m-d H:i:s'); |
| 2435 | |
| 2436 | if(empty($usuario)) |
| 2437 | $usuario = $_SESSION['usuario']; |
| 2438 | |
| 2439 | |
| 2440 | $sql = array(); |
| 2441 | $sql[] = "SET @TRIGGER_DISABLED = 1;"; |
| 2442 | |
| 2443 | $sql[] = "UPDATE /*marcaabiertoDocumento*/ $doc SET abierto_por = '$usuario', abierto_el = '$now' WHERE ".$doc."_id = '$doc_id'"; |
| 2444 | // echo "MI POENE"; |
| 2445 | // echo "<pre>".print_r($sql, true)."</pre>"; |
| 2446 | // die(); |
| 2447 | // |
| 2448 | $sql[] = "SET @TRIGGER_DISABLED = 0;"; |
| 2449 | |
| 2450 | if(ia_transaction($sql)) |
| 2451 | return false; |
| 2452 | |
| 2453 | return true; |
| 2454 | |
| 2455 | } |
| 2456 | |
| 2457 | function debeCerrarDocumento($doc, $doc_id, $usuario = '') |
| 2458 | { |
| 2459 | global $gIAParametros; |
| 2460 | |
| 2461 | if(empty($doc) || empty($doc_id)) |
| 2462 | return false; |
| 2463 | |
| 2464 | if(empty($usuario)) |
| 2465 | $usuario = $_SESSION['usuario']; |
| 2466 | |
| 2467 | $doc_abierto = ia_singleton("SELECT /*debeCerrarDocumento*/ abierto_el, abierto_por FROM $doc WHERE ".$doc."_id = '$doc_id'"); |
| 2468 | |
| 2469 | if(empty($doc_abierto) || !is_array($doc_abierto)) |
| 2470 | return false; |
| 2471 | |
| 2472 | if((diferenciadeTiempo($doc_abierto['abierto_el'],'','minutos') >= $gIAParametros['tiempo_para_cerrar_documento'])) |
| 2473 | return true; |
| 2474 | |
| 2475 | return false; |
| 2476 | } |
| 2477 | |
| 2478 | function estatusDocumento($doc, $doc_id) |
| 2479 | { |
| 2480 | global $gIAParametros; |
| 2481 | |
| 2482 | if(empty($doc) || empty($doc_id)) |
| 2483 | return false; |
| 2484 | |
| 2485 | if(empty($usuario)) |
| 2486 | $usuario = $_SESSION['usuario']; |
| 2487 | |
| 2488 | $doc_abierto = ia_singleton("SELECT /*estatusDocumento*/ abierto_el, abierto_por, puede_borrar, alta_db, autorizado_el, autorizado, bloqueado_el FROM $doc WHERE ".$doc."_id = '$doc_id'"); |
| 2489 | |
| 2490 | |
| 2491 | if(empty($doc_abierto) || !is_array($doc_abierto)) { |
| 2492 | $doc_abierto['status'] = 'NO EXISTE'; |
| 2493 | return $doc_abierto; |
| 2494 | } |
| 2495 | |
| 2496 | $autorizado = $doc_abierto['autorizado'] == 'Si' ? true:false; |
| 2497 | $puede_borrar = $doc_abierto['puede_borrar'] == 'Si' ? true:false; |
| 2498 | $puede_borrar_tiempo = diferenciadeTiempo($doc_abierto['alta_db'],'','minutos') <= $gIAParametros['tiempo_para_borrar_documento'] ? true:false; |
| 2499 | |
| 2500 | $bloqueado_el = !empty($doc_abierto['bloqueado_el']) ? strtotime($doc_abierto['bloqueado_el']) : -1; |
| 2501 | $autorizado_el = !empty($doc_abierto['autorizado_el']) ? strtotime($doc_abierto['autorizado_el']) : -1; |
| 2502 | $abierto_el = !empty($doc_abierto['abierto_el']) ? strtotime($doc_abierto['abierto_el']) : -1; |
| 2503 | $abierto_por = $doc_abierto['abierto_por']; |
| 2504 | $se_bloqueo_autorizo_mientras_abierto = false; |
| 2505 | |
| 2506 | $doc_abierto['lolz'] = array("bloqueado_el" => $bloqueado_el, |
| 2507 | "autorizado_el" => $autorizado_el, |
| 2508 | "abierto_el" => $abierto_el, |
| 2509 | "abierto_por" => $abierto_por); |
| 2510 | |
| 2511 | if($abierto_el > -1 && !empty($abierto_por) && |
| 2512 | ($autorizado_el > -1 && ($abierto_el < $autorizado_el) || |
| 2513 | $bloqueado_el > -1 && ($abierto_el < $bloqueado_el))) |
| 2514 | $se_bloqueo_autorizo_mientras_abierto = true; |
| 2515 | // $puede_borrar_tiempo = $puede_borrar ? $puede_borrar_tiempo : $puede_borrar; |
| 2516 | |
| 2517 | // $dif_autorizado = -1; $dif_abierto = -1; |
| 2518 | // |
| 2519 | // if($autorizado || !$puede_borrar)// || !$puede_borrar_tiempo) |
| 2520 | // $dif_autorizado = diferenciadeTiempo($doc_abierto['autorizado_el'],'','minutos'); |
| 2521 | // |
| 2522 | // if(!empty($doc_abierto['abierto_por']) || !empty($doc_abierto['abierto_el']) ) |
| 2523 | // $dif_abierto = diferenciadeTiempo($doc_abierto['abierto_el'],'','minutos'); |
| 2524 | // |
| 2525 | // if($dif_autorizado > 0 && $dif_abierto > 0 && $dif_autorizado <= $dif_abierto){ |
| 2526 | // $se_bloqueo_autorizo_mientras_abierto = true; |
| 2527 | // } |
| 2528 | |
| 2529 | |
| 2530 | // echo "dif_autorizado: $dif_autorizado, dif_abierto: $dif_abierto, autorizado: $autorizado, puede_borrar: $puede_borrar, puede_borrar_tiempo: $puede_borrar_tiempo, se_bloqueo_autorizo_mientras_abierto: $se_bloqueo_autorizo_mientras_abierto"; |
| 2531 | |
| 2532 | if($se_bloqueo_autorizo_mientras_abierto){ |
| 2533 | $doc_abierto['status'] = 'RECARGAR'; |
| 2534 | } |
| 2535 | else { |
| 2536 | if (!empty($doc_abierto['abierto_por']) || !empty($doc_abierto['abierto_el']) ) { |
| 2537 | if ((diferenciadeTiempo($doc_abierto['abierto_el'], '', 'minutos') >= $gIAParametros['tiempo_para_cerrar_documento'])) |
| 2538 | $doc_abierto['status'] = 'EXPIRADO'; |
| 2539 | else { |
| 2540 | |
| 2541 | $doc_abierto['status'] = 'ABIERTO'; |
| 2542 | |
| 2543 | } |
| 2544 | } else |
| 2545 | $doc_abierto['status'] = 'CERRADO'; |
| 2546 | } |
| 2547 | // ia_query("INSERT INTO dime (script,dime,usuario) VALUES ('estatusDocumento".ia_guid()."',".strit(print_r($doc_abierto, true). "dif_autorizado: $dif_autorizado, dif_abierto: $dif_abierto, autorizado: $autorizado, puede_borrar: $puede_borrar, puede_borrar_tiempo: $puede_borrar_tiempo").",".strit($_SESSION['usuario']).")"); |
| 2548 | |
| 2549 | return $doc_abierto; |
| 2550 | } |
| 2551 | |
| 2552 | |
| 2553 | function esCuentaTde($cuentaTID='') |
| 2554 | { |
| 2555 | if(empty($cuentaTID)) |
| 2556 | return null; |
| 2557 | |
| 2558 | return strtolower(ia_singleread("SELECT es_de FROM cuentat WHERE cuentaT_id=".strit($cuentaTID))); |
| 2559 | } |
| 2560 | |
| 2561 | function tiendaIDdeCtaT($cuentaTID='') |
| 2562 | { |
| 2563 | if(empty($cuentaTID)) |
| 2564 | return null; |
| 2565 | |
| 2566 | return ia_singleread("SELECT tienda_id FROM cuentat WHERE cuentaT_id=".strit($cuentaTID)); |
| 2567 | } |
| 2568 | |
| 2569 | function propdeCtaT($cuentaTID='',$prop='es_de',$upper=false) |
| 2570 | { |
| 2571 | if(empty($cuentaTID)) |
| 2572 | return null; |
| 2573 | |
| 2574 | $enDB = ia_singleton("SELECT * FROM cuentat WHERE cuentaT_id=".strit($cuentaTID)); |
| 2575 | //echo "<pre>".print_r($enDB, true)."</pre>"; die(); |
| 2576 | $str2func=$upper?"strtoupper":"strtolower"; |
| 2577 | return array_key_exists($prop,$enDB) ? $str2func($enDB[$prop]):null; |
| 2578 | } |
| 2579 | |
| 2580 | function numRefLink() |
| 2581 | { |
| 2582 | /*$guid = strtoupper(ia_guid()); |
| 2583 | $guid = substr($guid,-9); |
| 2584 | |
| 2585 | $guid = date('z').$guid; |
| 2586 | return $guid;*/ |
| 2587 | $ano = date('y'); |
| 2588 | $dia = date('z'); |
| 2589 | |
| 2590 | $base = $ano.$dia; |
| 2591 | $cons = ia_singleread("select iac_seq('$base')"); |
| 2592 | |
| 2593 | return (string) $dia.$cons; |
| 2594 | } |
| 2595 | |
| 2596 | |
| 2597 | function preparaDiccionarioDatosBanco() |
| 2598 | { |
| 2599 | |
| 2600 | $arrKW = array( 'Deposito'=>array(), |
| 2601 | 'Retiro'=>array()); |
| 2602 | |
| 2603 | $arrKWTemp = ia_sqlArrayIndx("SELECT * FROM banco_diccionario_dato WHERE activo='Si' ORDER BY orden ASC"); |
| 2604 | //$arrKW['Retiro'] = ia_sqlArrayIndx("SELECT * FROM banco_diccionario_dato WHERE es='Retiro' AND activo='Si'"); |
| 2605 | |
| 2606 | foreach($arrKWTemp as $k => &$kw2F) |
| 2607 | { |
| 2608 | if(array_key_exists('palabra_clave', $kw2F) && !empty($kw2F['palabra_clave'])) |
| 2609 | { |
| 2610 | $tmpkW = explode(',',$kw2F['palabra_clave']); |
| 2611 | if(is_array($tmpkW)) foreach($tmpkW as $i=>$kw) $tmpkW[$i] = trim($kw); |
| 2612 | $kw2F['palabra_clave'] = $tmpkW; |
| 2613 | } |
| 2614 | |
| 2615 | if($kw2F['es'] == 'Deposito') |
| 2616 | $arrKW['Deposito'][] = $kw2F; |
| 2617 | else |
| 2618 | $arrKW['Retiro'][] = $kw2F; |
| 2619 | } |
| 2620 | |
| 2621 | return $arrKW; |
| 2622 | } |
| 2623 | |
| 2624 | function preparaDiccionarioDatosBancoGastos($resalta_palabras = false) |
| 2625 | { |
| 2626 | |
| 2627 | $arrKW = array( |
| 2628 | 'si_buscar'=>array(), |
| 2629 | 'no_buscar'=>array()); |
| 2630 | |
| 2631 | $rp_txt = ""; |
| 2632 | if($resalta_palabras) |
| 2633 | $rp_txt = " AND resalta_palabras = 'Si' "; |
| 2634 | |
| 2635 | $arrKWTemp = ia_sqlArrayIndx("SELECT * FROM banco_gasto_diccionario_dato WHERE activo='Si' $rp_txt"); |
| 2636 | //$arrKW['Retiro'] = ia_sqlArrayIndx("SELECT * FROM banco_diccionario_dato WHERE es='Retiro' AND activo='Si'"); |
| 2637 | |
| 2638 | foreach($arrKWTemp as $k => &$kw2F) |
| 2639 | { |
| 2640 | if(array_key_exists('palabra_clave', $kw2F) && !empty($kw2F['palabra_clave'])) |
| 2641 | { |
| 2642 | $tmpkW = explode(',',$kw2F['palabra_clave']); |
| 2643 | if(is_array($tmpkW)) foreach($tmpkW as $i=>$kw) $tmpkW[$i] = ltrim(trim($kw)); |
| 2644 | $kw2F['palabra_clave'] = $tmpkW; |
| 2645 | $kw2F['palabra_clave_rp'] = implode(' ',$tmpkW); |
| 2646 | } |
| 2647 | |
| 2648 | if(array_key_exists('beneficiario', $kw2F) && !empty($kw2F['beneficiario'])) |
| 2649 | { |
| 2650 | $tmpkW = explode(',',$kw2F['beneficiario']); |
| 2651 | if(is_array($tmpkW)) foreach($tmpkW as $i=>$kw) $tmpkW[$i] = ltrim(trim($kw)); |
| 2652 | $kw2F['beneficiario'] = $tmpkW; |
| 2653 | } |
| 2654 | |
| 2655 | if(array_key_exists('subtitulo', $kw2F) && !empty($kw2F['subtitulo'])) |
| 2656 | { |
| 2657 | $tmpkW = explode(',',$kw2F['subtitulo']); |
| 2658 | if(is_array($tmpkW)) foreach($tmpkW as $i=>$kw) $tmpkW[$i] = ltrim(trim($kw)); |
| 2659 | $kw2F['subtitulo'] = $tmpkW; |
| 2660 | } |
| 2661 | |
| 2662 | if($kw2F['buscar_repetidos'] == 'Si') |
| 2663 | $arrKW['si_buscar'][] = $kw2F; |
| 2664 | else { |
| 2665 | if(!$resalta_palabras) |
| 2666 | $arrKW['no_buscar'][] = $kw2F; |
| 2667 | else |
| 2668 | $arrKW['no_buscar'][$kw2F['banco_gasto_diccionario_dato_id']] = $kw2F; |
| 2669 | } |
| 2670 | } |
| 2671 | |
| 2672 | return !$resalta_palabras ? $arrKW : $arrKW['no_buscar']; |
| 2673 | } |
| 2674 | |
| 2675 | function linksdeTodoalBancoLinksVale($valePagoWhere = "", $valeWhere = "", $orderby = "", $limit = "" ) { |
| 2676 | $valeWhere = empty($valeWhere) ? " WHERE " : $valeWhere . " AND "; |
| 2677 | $valePagoWhere = empty($valePagoWhere) ? " WHERE " : $valePagoWhere . " AND "; |
| 2678 | |
| 2679 | $sql = trim(" |
| 2680 | ( SELECT d.vale_id AS link_id |
| 2681 | ,d.banco_cuenta_mov_link_id |
| 2682 | ,d.origen |
| 2683 | ,d.vale_id AS doc_id |
| 2684 | ,d.cuentaT_id |
| 2685 | ,d.tienda_id |
| 2686 | ,d.fecha |
| 2687 | ,d.banco_cuenta_id |
| 2688 | ,d.metodo_pago_id AS cuentaT_tipo_mov_id |
| 2689 | ,d.deposit_total AS deposit_total |
| 2690 | ,d.quantity_total AS quantity_total |
| 2691 | ,d.ide_amount |
| 2692 | ,d.ide_percent |
| 2693 | ,d.quantity_total AS egreso |
| 2694 | ,0.00 AS monto |
| 2695 | ,d.tipo_cash_nota |
| 2696 | ,d.cash_nota_num |
| 2697 | ,d.deposit_fecha |
| 2698 | ,d.deposit_cliente AS cliente |
| 2699 | ,d.factura |
| 2700 | ,d.factura_numero |
| 2701 | ,d.iva_incluido AS iva_incluido |
| 2702 | ,d.ivacobradox100 |
| 2703 | ,if((d.iva_incluido = 'SI'),0.00,d.ivacobradototal) AS ivarealmentecobrado |
| 2704 | ,if((d.iva_incluido = 'NO'),0.00,d.ivacobradototal) AS ivacobradototal |
| 2705 | ,d.alta_db |
| 2706 | ,d.alta_por |
| 2707 | ,d.numero_referencia AS numero_referencia |
| 2708 | ,d.cash_num_cobro_iva |
| 2709 | ,d.empresa_id |
| 2710 | ,d.remarks |
| 2711 | ,'NO' AS puede_borrar |
| 2712 | ,if((d.cancelado = 1),'No','Si') AS activo |
| 2713 | ,afecta_cuentat AS afecta_cuentat |
| 2714 | ,d.comments AS comments |
| 2715 | ,d.autorizado AS autorizado |
| 2716 | ,d.rechazado AS rechazado |
| 2717 | ,d.revisado AS revisado |
| 2718 | ,d.autorizado_el AS autorizado_el |
| 2719 | ,d.autorizado_por AS autorizado_por |
| 2720 | ,d.MetodoPago AS MetodoPago |
| 2721 | ,d.FormaPago AS FormaPago |
| 2722 | ,d.UsoCFDI AS UsoCFDI |
| 2723 | ,d.iva_revisado AS iva_revisado |
| 2724 | ,d.iva_revisado_por AS iva_revisado_por |
| 2725 | ,d.iva_revisado_el AS iva_revisado_el |
| 2726 | ,d.ultimo_cambio |
| 2727 | ,d.ultimo_cambio_por |
| 2728 | ,d.cliente_rfc |
| 2729 | ,d.referencia |
| 2730 | ,d.cuenta_t_mov_id AS origen_mov_id |
| 2731 | ,'NO' AS factura_directa |
| 2732 | ,d.recibido_moneda_id AS moneda_id |
| 2733 | FROM vale d $valeWhere (d.banco_cuenta_id > 0 and d.banco_cuenta_mov_link_id <> '') $orderby $limit ) "); |
| 2734 | |
| 2735 | if(VALE_PAGO_MULTIPLE) { |
| 2736 | $sql .= trim("\r\n |
| 2737 | UNION ALL |
| 2738 | ( SELECT g.vale_pago_id AS link_id |
| 2739 | ,g.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 2740 | ,g.origen AS origen |
| 2741 | ,g.vale_id AS doc_id |
| 2742 | ,g.cuentaT_id AS cuentaT_id |
| 2743 | ,g.tienda_id AS tienda_id |
| 2744 | ,g.fecha AS fecha |
| 2745 | ,g.banco_cuenta_id AS banco_cuenta_id |
| 2746 | ,g.metodo_pago_id AS cuentaT_tipo_mov_id |
| 2747 | ,g.deposit_total AS deposit_total |
| 2748 | ,g.quantity_total AS quantity_total |
| 2749 | ,g.ide_amount AS ide_amount |
| 2750 | ,g.ide_percent AS ide_percent |
| 2751 | ,g.quantity_ctat AS egreso |
| 2752 | ,0.00 AS monto |
| 2753 | ,g.tipo_cash_nota AS tipo_cash_nota |
| 2754 | ,g.cash_nota_num AS cash_nota_num |
| 2755 | ,g.deposit_fecha AS deposit_fecha |
| 2756 | ,g.cliente AS cliente |
| 2757 | ,g.factura AS factura |
| 2758 | ,g.factura_numero AS factura_numero |
| 2759 | ,g.iva_incluido AS iva_incluido |
| 2760 | ,g.ivacobradox100 AS ivacobradox100 |
| 2761 | ,if((g.iva_incluido = 'SI'),0.00,g.ivacobradototal) AS ivarealmentecobrado |
| 2762 | ,if((g.iva_incluido = 'NO'),0.00,g.ivacobradototal) AS ivacobradototal |
| 2763 | ,g.alta_db AS alta_db |
| 2764 | ,g.alta_por AS alta_por |
| 2765 | ,g.numero_referencia AS numero_referencia |
| 2766 | ,g.cash_num_cobro_iva AS cash_num_cobro_iva |
| 2767 | ,g.empresa_id AS empresa_id |
| 2768 | ,g.comentario AS remarks |
| 2769 | ,g.puede_borrar AS puede_borrar |
| 2770 | ,g.activo AS activo |
| 2771 | ,afecta_cuentat AS afecta_cuentat |
| 2772 | ,g.comments AS comments |
| 2773 | ,g.autorizado AS autorizado |
| 2774 | ,g.rechazado AS rechazado |
| 2775 | ,g.revisado AS revisado |
| 2776 | ,g.autorizado_el AS autorizado_el |
| 2777 | ,g.autorizado_por AS autorizado_por |
| 2778 | ,g.MetodoPago AS MetodoPago |
| 2779 | ,g.FormaPago AS FormaPago |
| 2780 | ,g.UsoCFDI AS UsoCFDI |
| 2781 | ,g.iva_revisado AS iva_revisado |
| 2782 | ,g.iva_revisado_por AS iva_revisado_por |
| 2783 | ,g.iva_revisado_el AS iva_revisado_el |
| 2784 | ,g.ultimo_cambio AS ultimo_cambio |
| 2785 | ,g.ultimo_cambio_por AS ultimo_cambio_por |
| 2786 | ,g.cliente_rfc AS cliente_rfc |
| 2787 | ,g.referencia AS referencia |
| 2788 | ,g.cuenta_t_mov_id AS origen_mov_id |
| 2789 | ,'NO' AS factura_directa |
| 2790 | ,g.moneda_id AS moneda_id |
| 2791 | FROM vale_pago g $valePagoWhere (g.banco_cuenta_id > 0 and g.banco_cuenta_mov_link_id <> '') $orderby $limit )"); |
| 2792 | } |
| 2793 | |
| 2794 | return $sql; |
| 2795 | } |
| 2796 | |
| 2797 | function linksdeTodoalBanco($andWhere='',$orderby='',$origen='',&$sumasGridServer=array()) |
| 2798 | { |
| 2799 | global $gIAsql, $gIAParametros; |
| 2800 | |
| 2801 | if(!empty($andWhere)) |
| 2802 | { |
| 2803 | if(strpos($andWhere, " AND (") == 0) |
| 2804 | $andWhere = substr($andWhere,5); |
| 2805 | |
| 2806 | //$andWhere = str_replace('(fecha','(c.fecha',$andWhere); |
| 2807 | |
| 2808 | $andWhere = " WHERE $andWhere "; |
| 2809 | } |
| 2810 | |
| 2811 | $chequeWhere = $andWhere; |
| 2812 | $chequeWhere = str_replace('cuentaT_tipo_mov_id','metodo_pago_id',$chequeWhere); |
| 2813 | $chequeWhere = str_replace('remarks','comentario',$chequeWhere); |
| 2814 | if($origen == "CANCELADOS") |
| 2815 | $chequeWhere = str_replace('egreso','quantity_ctat',$chequeWhere); |
| 2816 | else |
| 2817 | $chequeWhere = str_replace('egreso','quantity_total',$chequeWhere); |
| 2818 | //$chequeWhere = str_replace("afecta_cuentat='No'",'1=0',$chequeWhere); |
| 2819 | |
| 2820 | $valeWhere = $chequeWhere; |
| 2821 | $valeWhere = str_replace("activo='Si' AND",'',$valeWhere); |
| 2822 | $valeWhere = str_replace("activo='No' AND",'',$valeWhere); |
| 2823 | $valeWhere = str_replace("cliente","deposit_cliente",$valeWhere); |
| 2824 | $valeWhere = str_replace("quantity_ctat","quantity_total",$valeWhere); |
| 2825 | |
| 2826 | //$valePagoWhere = $valeWhere; // VALE_PAGO_MULTIPLE @TODO |
| 2827 | |
| 2828 | $sqllimit = $sumasGridServer['sqllimit']; |
| 2829 | $limit = $sumasGridServer['finallimit']; |
| 2830 | $orderby = $sumasGridServer['finalorderby']; |
| 2831 | $groupby = $sumasGridServer['finalgroupby']; |
| 2832 | |
| 2833 | $tablaOriginal = "links_al_banco_schema"; |
| 2834 | $sql = obtenSQLlinksdeTodoalBanco($origen, $andWhere, $chequeWhere, $valeWhere, $limit, $orderby, $groupby, $tablaOriginal, $sumasGridServer['ianoLimitinSub']); |
| 2835 | |
| 2836 | //VCA sumasGridServer |
| 2837 | //Para la suma tengo que preparar el subquery que simula la vista. |
| 2838 | |
| 2839 | //."\r\nsumasGridServer: $colSums".addslashes(print_r($sumasGridServer, true))."')"); |
| 2840 | |
| 2841 | |
| 2842 | $COUNTsql = "SELECT /** linksdeTodoalBanco **/ COUNT(*) FROM ( ". $sql . " ) AS COUNT_TMP "; |
| 2843 | |
| 2844 | $sumasGridServer['total_records'] = ia_singleread($COUNTsql); |
| 2845 | |
| 2846 | $sumasGridServer['tablaOriginal'] = $tablaOriginal; |
| 2847 | $sumasGridServer['demasiadasLineasGrid'] = "NO"; |
| 2848 | |
| 2849 | $tempTable4Sum = "aa_tmp".ia_guid(); |
| 2850 | $arrsqlData = array('tempTable4Sum'=>$tempTable4Sum, 'sql' => $sql, 'func'=>"linksdeTodoalBanco", 'sumasGridServer'=>$sumasGridServer); |
| 2851 | |
| 2852 | $arrLinksTodo = array(); |
| 2853 | |
| 2854 | if($sumasGridServer['total_records'] > $gIAParametros['numero_maximo_renglones_grid'] && $sumasGridServer['orGridTrigger'] == "NO" && $sumasGridServer['iaGridInicial'] == "NO") |
| 2855 | { |
| 2856 | $sumasGridServer['demasiadasLineasGrid'] = 'SI'; |
| 2857 | $arrsqlData['sumasGridServer']['demasiadasLineasGrid'] = 'SI'; |
| 2858 | $arrsqlData = json_encode($arrsqlData); |
| 2859 | |
| 2860 | async_guardaConsulta($arrsqlData); |
| 2861 | } |
| 2862 | else |
| 2863 | { |
| 2864 | $arrsqlData = json_encode($arrsqlData); |
| 2865 | guardaConsulta(json_decode($arrsqlData)); |
| 2866 | $sqllimit = $sumasGridServer['ianoLimitinSub'] ? "" : $sqllimit; |
| 2867 | //$sumasGridServer['total_records'] = ia_singleread("SELECT COUNT(*) FROM $tempTable4Sum"); |
| 2868 | $arrLinksTodo = ia_sqlArrayIndx("SELECT * FROM $tempTable4Sum $sqllimit"); |
| 2869 | |
| 2870 | } |
| 2871 | |
| 2872 | $sumasGridServer['iactbl'] = $sumasGridServer['iasumFuncTable'] = $tempTable4Sum; |
| 2873 | /** |
| 2874 | $myFile = "linksdeTodoalBanco.txt"; |
| 2875 | $fh = fopen($myFile, 'w') or die("can't open file"); |
| 2876 | $bleh = "\r\n\r\narrsqlData<pre>".print_r(json_decode($arrsqlData), true)."</pre>"; |
| 2877 | $bleh .= "\r\n\r\narrLinksTodo<pre>".print_r($arrLinksTodo, true)."</pre>"; |
| 2878 | $bleh .= "\r\n\r\nsumasGridServer<pre>".print_r($sumasGridServer, true)."</pre>"; |
| 2879 | fwrite($fh, $bleh); |
| 2880 | fclose($fh); |
| 2881 | **/ |
| 2882 | |
| 2883 | return $arrLinksTodo; |
| 2884 | |
| 2885 | } |
| 2886 | |
| 2887 | function debeFlashearTab($depEn=array()) |
| 2888 | { |
| 2889 | global $gIAParametros; |
| 2890 | |
| 2891 | $debeFlashear = true; |
| 2892 | |
| 2893 | if($gIAParametros['flashear_tab_actualizar_bancos']=='No') |
| 2894 | return $debeFlashear = false; |
| 2895 | |
| 2896 | $now = new DateTime(); |
| 2897 | $dbaIni = new DateTime($gIAParametros['hora_inicio_actualizar_bancos']); |
| 2898 | $dbaFin = new DateTime($gIAParametros['hora_fin_actualizar_bancos']); |
| 2899 | |
| 2900 | if ($now < $dbaIni || $now > $dbaFin) |
| 2901 | return $debeFlashear = false; |
| 2902 | |
| 2903 | $day = strtolower($now->format('D')); |
| 2904 | $diasSemana = array( |
| 2905 | array("mon",false), |
| 2906 | array("tue",false), |
| 2907 | array("wed",false), |
| 2908 | array("thu",false), |
| 2909 | array("fri",false), |
| 2910 | array("sat",false), |
| 2911 | array("sun",false) |
| 2912 | ); |
| 2913 | $dbaSemana = $gIAParametros['dias_actualizar_bancos']; |
| 2914 | for($i=0;$i<strlen($dbaSemana);$i++){ |
| 2915 | $diasSemana[$i][1]=$dbaSemana[$i]=="1"?true:false; |
| 2916 | $day=$day==$diasSemana[$i][0]?$i:$day; |
| 2917 | } |
| 2918 | |
| 2919 | if(!$diasSemana[$day][1]) |
| 2920 | return $debeFlashear = false; |
| 2921 | |
| 2922 | |
| 2923 | if(!empty($depEn)) |
| 2924 | foreach($depEn as $fila) |
| 2925 | foreach($fila as $d){ |
| 2926 | $debeFlashear = array_key_exists('do_flash_tab', $d) ? $d['do_flash_tab'] : false; |
| 2927 | if($debeFlashear) |
| 2928 | break; |
| 2929 | } |
| 2930 | return $debeFlashear; |
| 2931 | |
| 2932 | } |
| 2933 | |
| 2934 | function camposyTablasNormalizadas($origen='a_cuentas') |
| 2935 | { |
| 2936 | $tn = array(); |
| 2937 | $prefix = ''; |
| 2938 | $arrCTN = array(); |
| 2939 | |
| 2940 | switch($origen) |
| 2941 | { |
| 2942 | case 'links_al_banco': |
| 2943 | $tn[]='POZO'; |
| 2944 | break; |
| 2945 | |
| 2946 | case 'a_cuentas': |
| 2947 | $tn['cheque_pago'] = |
| 2948 | array( 'doc_pago_id' => 'cp.cheque_pago_id', |
| 2949 | 'doc_id' => 'cp.cheque_id', |
| 2950 | 'fecha_borrado' => '^1=0', |
| 2951 | 'doc_quantity' => 'ch.quantity', |
| 2952 | 'doc_moneda' => 'ch.moneda_id', |
| 2953 | 'doc_numero' => 'ch.numero', |
| 2954 | 'doc_saldo' => 'cp.saldo', |
| 2955 | 'quantity' => 'cp.quantity', |
| 2956 | 'moneda_id' => 'cp.moneda_id', |
| 2957 | 'cliente_id' => 'ch.cliente_id', |
| 2958 | 'doc_cliente' => 'cli.nombre',); |
| 2959 | |
| 2960 | $tn['pagare_pago'] = |
| 2961 | array( 'doc_pago_id' => 'cp.pagare_pago_id', |
| 2962 | 'doc_id' => 'cp.pagare_id', |
| 2963 | 'fecha_borrado' => '^1=0', |
| 2964 | 'doc_quantity' => 'ch.quantity', |
| 2965 | 'doc_moneda' => 'ch.moneda_id', |
| 2966 | 'doc_numero' => 'ch.numero', |
| 2967 | 'doc_saldo' => 'cp.saldo', |
| 2968 | 'quantity' => 'cp.quantity', |
| 2969 | 'moneda_id' => 'cp.moneda_id', |
| 2970 | 'cliente_id' => 'ch.cliente_id', |
| 2971 | 'doc_cliente' => 'cli.nombre',); |
| 2972 | |
| 2973 | $tn['cheque_pago_log'] = |
| 2974 | array( 'doc_pago_id' => 'cp.cheque_pago_log_id', |
| 2975 | 'doc_id' => 'cp.cheque_id', |
| 2976 | 'cuenta_t_mov_id' => '^1=0', |
| 2977 | 'vs_doc' => '^1=0', |
| 2978 | 'vs_doc_key' => '^1=0', |
| 2979 | 'vs_pago_key' => '^1=0', |
| 2980 | 'puede_borrar' => '^1=0', |
| 2981 | 'quantity_ctat' => '^1=0', |
| 2982 | 'deposit_fecha' => '^1=0', |
| 2983 | 'comision_percent' => '^1=0', |
| 2984 | 'comision_amount' => '^1=0', |
| 2985 | 'factura' => '^1=0', |
| 2986 | 'ivacobradox100' => '^1=0', |
| 2987 | 'ivacobradototal' => '^1=0', |
| 2988 | 'empresa_id' => '^1=0', |
| 2989 | 'factura_numero' => '^1=0', |
| 2990 | 'cash_nota_num' => '^1=0', |
| 2991 | 'cliente' => '^1=0', |
| 2992 | 'tipo_cash_nota' => '^1=0', |
| 2993 | 'cobra_iva' => '^1=0', |
| 2994 | 'iva_incluido' => '^1=0', |
| 2995 | 'numero_referencia' => '^1=0', |
| 2996 | 'cash_num_cobro_iva' => '^1=0', |
| 2997 | 'cliente_rfc' => '^1=0', |
| 2998 | 'doc_quantity' => 'ch.quantity', |
| 2999 | 'doc_moneda' => 'ch.moneda_id', |
| 3000 | 'doc_numero' => 'ch.numero', |
| 3001 | 'doc_saldo' => 'cp.saldo', |
| 3002 | 'activo' => '*No', |
| 3003 | 'origen' => '*Cheque', |
| 3004 | 'quantity' => 'cp.quantity', |
| 3005 | 'moneda_id' => 'cp.moneda_id', |
| 3006 | 'cliente_id' => 'ch.cliente_id', |
| 3007 | 'doc_cliente' => 'cli.nombre'); |
| 3008 | |
| 3009 | $tn['pagare_pago_log'] = |
| 3010 | array( 'doc_pago_id' => 'cp.pagare_pago_log_id', |
| 3011 | 'doc_id' => 'cp.pagare_id', |
| 3012 | 'cuenta_t_mov_id' => '^1=0', |
| 3013 | 'vs_doc' => '^1=0', |
| 3014 | 'vs_doc_key' => '^1=0', |
| 3015 | 'vs_pago_key' => '^1=0', |
| 3016 | 'puede_borrar' => '^1=0', |
| 3017 | 'quantity_ctat' => '^1=0', |
| 3018 | 'deposit_fecha' => '^1=0', |
| 3019 | 'comision_percent' => '^1=0', |
| 3020 | 'comision_amount' => '^1=0', |
| 3021 | 'factura' => '^1=0', |
| 3022 | 'ivacobradox100' => '^1=0', |
| 3023 | 'ivacobradototal' => '^1=0', |
| 3024 | 'empresa_id' => '^1=0', |
| 3025 | 'factura_numero' => '^1=0', |
| 3026 | 'cash_nota_num' => '^1=0', |
| 3027 | 'cliente' => '^1=0', |
| 3028 | 'tipo_cash_nota' => '^1=0', |
| 3029 | 'cobra_iva' => '^1=0', |
| 3030 | 'iva_incluido' => '^1=0', |
| 3031 | 'numero_referencia' => '^1=0', |
| 3032 | 'cash_num_cobro_iva' => '^1=0', |
| 3033 | 'cliente_rfc' => '^1=0', |
| 3034 | 'doc_quantity' => 'ch.quantity', |
| 3035 | 'doc_moneda' => 'ch.moneda_id', |
| 3036 | 'doc_numero' => 'ch.numero', |
| 3037 | 'doc_saldo' => 'cp.saldo', |
| 3038 | 'activo' => '*No', |
| 3039 | 'origen' => '*Pagare', |
| 3040 | 'quantity' => 'cp.quantity', |
| 3041 | 'moneda_id' => 'cp.moneda_id', |
| 3042 | 'cliente_id' => 'ch.cliente_id', |
| 3043 | 'doc_cliente' => 'cli.nombre',); |
| 3044 | |
| 3045 | $tn['vale'] = |
| 3046 | array( 'doc_pago_id' => 'cp.vale_id', |
| 3047 | 'doc_id' => 'cp.vale_id', |
| 3048 | 'fecha_borrado' => '^1=0', |
| 3049 | 'moneda_id' => 'recibido_moneda_id', |
| 3050 | 'vs_doc' => '^1=0', |
| 3051 | 'vs_doc_key' => '^1=0', |
| 3052 | 'vs_pago_key' => '^1=0', |
| 3053 | 'puede_borrar' => '^1=0', |
| 3054 | 'quantity_ctat' => 'quantity_recibido', |
| 3055 | 'numero' => '^1=0', |
| 3056 | 'cuentaT_deliveredto_id' => 'cp.dinero_en_cuentaT_id', |
| 3057 | 'doc_quantity' => 'cp.quantity', |
| 3058 | 'doc_moneda' => 'cp.moneda_id', |
| 3059 | 'doc_numero' => 'cp.vale_number', |
| 3060 | 'doc_saldo' => '(cp.quantity - cp.total_payments)', |
| 3061 | 'activo' =>"if((cp.cancelado = 1),'No','Si')", |
| 3062 | 'quantity' => '^1=0', |
| 3063 | 'origen_cuentat_id' => '^1=0', |
| 3064 | 'cliente_id' => 'cp.cliente_id', |
| 3065 | 'doc_cliente' => 'cli.nombre',); |
| 3066 | |
| 3067 | $tn['vale_pago'] = |
| 3068 | array( 'doc_pago_id' => 'cp.vale_pago_id', |
| 3069 | 'doc_id' => 'cp.vale_id', |
| 3070 | 'fecha_borrado' => '^1=0', |
| 3071 | 'doc_quantity' => 'ch.quantity', |
| 3072 | 'doc_moneda' => 'ch.moneda_id', |
| 3073 | 'doc_numero' => 'ch.vale_number', |
| 3074 | 'doc_saldo' => 'cp.saldo', |
| 3075 | 'quantity' => 'cp.quantity', |
| 3076 | 'moneda_id' => 'cp.moneda_id', |
| 3077 | 'cliente_id' => 'ch.cliente_id', |
| 3078 | 'doc_cliente' => 'cli.nombre',); |
| 3079 | |
| 3080 | $tn['vale_pago_log'] = |
| 3081 | array( 'doc_pago_id' => 'cp.vale_pago_log_id', |
| 3082 | 'doc_id' => 'cp.vale_id', |
| 3083 | 'cuenta_t_mov_id' => '^1=0', |
| 3084 | 'vs_doc' => '^1=0', |
| 3085 | 'vs_doc_key' => '^1=0', |
| 3086 | 'vs_pago_key' => '^1=0', |
| 3087 | 'puede_borrar' => '^1=0', |
| 3088 | 'quantity_ctat' => '^1=0', |
| 3089 | 'deposit_fecha' => '^1=0', |
| 3090 | 'comision_percent' => '^1=0', |
| 3091 | 'comision_amount' => '^1=0', |
| 3092 | 'factura' => '^1=0', |
| 3093 | 'ivacobradox100' => '^1=0', |
| 3094 | 'ivacobradototal' => '^1=0', |
| 3095 | 'empresa_id' => '^1=0', |
| 3096 | 'factura_numero' => '^1=0', |
| 3097 | 'cash_nota_num' => '^1=0', |
| 3098 | 'cliente' => '^1=0', |
| 3099 | 'tipo_cash_nota' => '^1=0', |
| 3100 | 'cobra_iva' => '^1=0', |
| 3101 | 'iva_incluido' => '^1=0', |
| 3102 | 'numero_referencia' => '^1=0', |
| 3103 | 'cash_num_cobro_iva' => '^1=0', |
| 3104 | 'cliente_rfc' => '^1=0', |
| 3105 | 'doc_quantity' => 'ch.quantity', |
| 3106 | 'doc_moneda' => 'ch.moneda_id', |
| 3107 | 'doc_numero' => 'ch.vale_number', |
| 3108 | 'doc_saldo' => 'cp.saldo', |
| 3109 | 'activo' => '*No', |
| 3110 | 'origen' => '*Cheque', |
| 3111 | 'quantity' => 'cp.quantity', |
| 3112 | 'moneda_id' => 'cp.moneda_id', |
| 3113 | 'cliente_id' => 'ch.cliente_id', |
| 3114 | 'doc_cliente' => 'cli.nombre'); |
| 3115 | |
| 3116 | $prefix = 'cp`.`'; |
| 3117 | |
| 3118 | break; |
| 3119 | |
| 3120 | case 'cuentat_mov': |
| 3121 | $tn['cuentat_mov'] = |
| 3122 | array( 'cuentaT_mov_id' => 'c.cuentaT_mov_id', |
| 3123 | 'cuentaT_id' => 'c.cuentaT_id', |
| 3124 | 'fecha' => 'c.fecha', |
| 3125 | 'moneda_id' => 'c.moneda_id', |
| 3126 | 'alta_por' => 'c.alta_por', |
| 3127 | 'tipo_cambio' => 'c.tipo_cambio', |
| 3128 | 'cuentaT_tipo_mov_id' => 'c.cuentaT_tipo_mov_id', |
| 3129 | 'app_origen' => 'c.app_origen', |
| 3130 | 'monto' => 'c.monto', |
| 3131 | 'egreso' => 'c.egreso', |
| 3132 | 'saldo_corriente_mxp' => 'c.saldo_corriente_mxp', |
| 3133 | 'tienda_id' => 'c.tienda_id', |
| 3134 | 'remarks' => 'c.remarks', |
| 3135 | 'alta_db' => 'c.alta_db', |
| 3136 | 'banco_cuenta_id' => 'c.banco_cuenta_id', |
| 3137 | 'referencia' => 'c.referencia', |
| 3138 | 'quantity_total' => 'c.quantity_total', |
| 3139 | 'link_por' => 'c.link_por', |
| 3140 | 'link_el' => 'c.link_el', |
| 3141 | 'fecha_deposito' => 'bcm.fecha', |
| 3142 | 'idex100' => 'bcm.idex100', |
| 3143 | 'idetotal' => 'bcm.idetotal', |
| 3144 | 'tipo_cash_nota' => 'bcm.tipo_cash_nota', |
| 3145 | 'cash_nota_num' => 'bcm.cash_nota_num', |
| 3146 | 'cliente' => 'bcm.cliente', |
| 3147 | 'factura' => 'bcm.factura', |
| 3148 | 'cash_num_cobro_iva' => 'bcm.cash_num_cobro_iva', |
| 3149 | 'ivacobradox100' => 'bcm.ivacobradox100', |
| 3150 | 'ivacobradototal' => 'bcm.ivacobradototal', |
| 3151 | 'factura_numero' => 'bcm.factura_numero', |
| 3152 | 'activo' => 'c.activo', |
| 3153 | 'saldo_corriente_usd' => 'c.saldo_corriente_usd', |
| 3154 | 'deposit_total' => 'c.deposit_total', |
| 3155 | 'origen_mov_id' => 'c.origen_mov_id', |
| 3156 | 'contra_mov_id' => 'c.contra_mov_id', |
| 3157 | 'tipo' => 'c.tipo', |
| 3158 | |
| 3159 | ); |
| 3160 | $prefix = 'c`.`'; |
| 3161 | |
| 3162 | break; |
| 3163 | |
| 3164 | case 'clientes_saldos': |
| 3165 | $tn['clientes_saldos'] = |
| 3166 | array( |
| 3167 | 'doc_mas_antiguo' => 'MIN(doc_mas_antiguo)', |
| 3168 | 'saldo_cheques_pesos' => 'SUM(saldo_cheques_pesos)', |
| 3169 | 'saldo_cheques_usd' => 'SUM(saldo_cheques_usd)', |
| 3170 | 'saldo_pagares_pesos' => 'SUM(saldo_pagares_pesos)', |
| 3171 | 'saldo_pagares_usd' => 'SUM(saldo_pagares_usd)', |
| 3172 | 'saldo_vales_pesos' => 'SUM(saldo_vales_pesos)', |
| 3173 | 'saldo_vales_usd' => 'SUM(saldo_vales_usd)', |
| 3174 | 'saldo_total_ventas_pesos' => 'SUM(saldo_total_ventas_pesos)', |
| 3175 | 'saldo_total_ventas_usd' => 'SUM(saldo_total_ventas_usd)', |
| 3176 | 'cheque_mas_antiguo' => 'MIN(cheque_mas_antiguo)', |
| 3177 | 'pagare_mas_antiguo' => 'MIN(pagare_mas_antiguo)', |
| 3178 | 'vale_mas_antiguo' => 'MIN(vale_mas_antiguo)', |
| 3179 | 'ultima_liquidacion' => 'MAX(ultima_liquidacion)', |
| 3180 | 'ultima_compra' => 'MAX(ultima_compra)', |
| 3181 | 'ultimo_pago' => 'MAX(ultimo_pago)', |
| 3182 | 'cuantos_cheques' => 'SUM(cuantos_cheques)', |
| 3183 | 'cuantos_pagares' => 'SUM(cuantos_pagares)', |
| 3184 | 'cuantos_vales' => 'SUM(cuantos_vales)', |
| 3185 | ); |
| 3186 | $prefix = ''; |
| 3187 | |
| 3188 | break; |
| 3189 | |
| 3190 | default: |
| 3191 | |
| 3192 | break; |
| 3193 | } |
| 3194 | $arrCTN[0]=$tn; |
| 3195 | $arrCTN[1]=$prefix; |
| 3196 | |
| 3197 | return $arrCTN; |
| 3198 | |
| 3199 | } |
| 3200 | |
| 3201 | //VCA 30-11-2020 banco_cuenta_poner_deposito_ND |
| 3202 | function leer_banco_cuenta_poner_deposito_ND(){ |
| 3203 | |
| 3204 | $ret_arr_cuentas=array( "txt_cuenta_poner_deposito_ND" => "", |
| 3205 | "div_cuenta_poner_deposito_ND" => "", |
| 3206 | "div_cuenta_no_poner_deposito_ND" => ""); |
| 3207 | |
| 3208 | $txt_cuenta_poner_deposito_ND=""; |
| 3209 | $div_cuenta_poner_deposito_ND=""; |
| 3210 | $div_cuenta_no_poner_deposito_ND=""; |
| 3211 | |
| 3212 | //CODIGO PARA PERMISOS POR USUARIO |
| 3213 | $cpnd_sql = "SELECT banco_cuenta_poner_deposito_ND FROM iac_parametros WHERE iac_parametros_id = '1'"; |
| 3214 | $cpnd_csv = ia_singleread($cpnd_sql); |
| 3215 | |
| 3216 | //echo "<li>$cpnd_csv"; |
| 3217 | |
| 3218 | $cpnd_array = explode(",", $cpnd_csv); |
| 3219 | |
| 3220 | //echo "<pre>cpnd_array" . print_r($cpnd_array, true) . "</pre>"; |
| 3221 | |
| 3222 | if(is_array($cpnd_array) && !empty($cpnd_array)) { |
| 3223 | $cpnd_in = "banco_cuenta_id IN ('" . join("','", $cpnd_array) . "')"; |
| 3224 | $cpnd_not_in = "banco_cuenta_id NOT IN ('" . join("','", $cpnd_array) . "')"; |
| 3225 | } |
| 3226 | else { |
| 3227 | $cpnd_in = "banco_cuenta_id = -1"; |
| 3228 | $cpnd_not_in = "banco_cuenta_id > 0"; |
| 3229 | } |
| 3230 | |
| 3231 | $cpnd_fin_sql = "SELECT banco_cuenta_id, nombre FROM banco_cuenta WHERE vale='Active' AND $cpnd_in ORDER BY 2"; |
| 3232 | |
| 3233 | // $cpnd_fin_arr tiene las cuentas que sí tienen sus depositos en ND. |
| 3234 | $cpnd_fin_arr = ia_sqlArrayIndx($cpnd_fin_sql); |
| 3235 | |
| 3236 | $cpnd_sin_sql = "SELECT banco_cuenta_id, nombre FROM banco_cuenta WHERE vale='Active' AND $cpnd_not_in ORDER BY 2"; |
| 3237 | |
| 3238 | // $cpnd_sin_arr tiene las cuentas que no tienen sus depositos en ND. |
| 3239 | $cpnd_sin_arr = ia_sqlArrayIndx($cpnd_sin_sql); |
| 3240 | |
| 3241 | //echo "<pre>fin" . print_r($cpnd_fin_arr, true) . "</pre>"; |
| 3242 | //echo "<pre>sin" . print_r($cpnd_sin_arr, true) . "</pre>"; |
| 3243 | |
| 3244 | // if(!is_array($cpnd_fin_arr) || empty($cpnd_fin_arr)) |
| 3245 | // return $ret_arr_cuentas; |
| 3246 | |
| 3247 | // echo "<li>$cpnd_fin_sql"; |
| 3248 | // echo "<li>$cpnd_sin_sql"; |
| 3249 | |
| 3250 | |
| 3251 | |
| 3252 | foreach($cpnd_fin_arr as $k=>$v) |
| 3253 | { |
| 3254 | $cuenta=$v['nombre']; |
| 3255 | $txt_cuenta_poner_deposito_ND.=" $cuenta,"; |
| 3256 | $div_cuenta_poner_deposito_ND.='<div id="'.$v['banco_cuenta_id'].'" data-banco_cuenta_id="'.$v['banco_cuenta_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" onclick="quita_cuenta('.$v['banco_cuenta_id'].',_poner_deposito_ND);"> <img src="../img/delete.png" width="14" height="14" alt="Dejar de poner depósitos en ND." title="Dejar de poner depósitos en ND." /></a> </div>'; |
| 3257 | |
| 3258 | } |
| 3259 | |
| 3260 | if(!empty($txt_cuenta_poner_deposito_ND)) |
| 3261 | $txt_cuenta_poner_deposito_ND = substr_replace($txt_cuenta_poner_deposito_ND,"",-1); |
| 3262 | |
| 3263 | foreach($cpnd_sin_arr as $k=>$v) |
| 3264 | { |
| 3265 | $cuenta=$v['nombre']; |
| 3266 | $div_cuenta_no_poner_deposito_ND.='<div id="'.$v['banco_cuenta_id'].'" data-banco_cuenta_id="'.$v['banco_cuenta_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" onclick="agrega_cuenta('.$v['banco_cuenta_id'].',_poner_deposito_ND);"> <img src="../img/add.png" width="14" height="14" alt="Poner depósitos en ND." title="Poner depósitos en ND." /></a> </div>'; |
| 3267 | } |
| 3268 | |
| 3269 | $div_cuenta_poner_deposito_ND='<div id="vale_cuenta_poner_deposito_ND" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= CUENTAS CON DEPOSITOS EN ND =-</strong><hr/><br/>'.$div_cuenta_poner_deposito_ND.'</div>'; |
| 3270 | $div_cuenta_no_poner_deposito_ND='<div id="vale_cuenta_no_poner_deposito_ND" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= CUENTAS SIN DEPOSITOS EN ND =-</strong><hr/><br/>'.$div_cuenta_no_poner_deposito_ND.'</div>'; |
| 3271 | |
| 3272 | $ret_arr_cuentas=array( "txt_cuenta_poner_deposito_ND" => "$txt_cuenta_poner_deposito_ND", |
| 3273 | "div_cuenta_poner_deposito_ND" => "$div_cuenta_poner_deposito_ND", |
| 3274 | "div_cuenta_no_poner_deposito_ND" => "$div_cuenta_no_poner_deposito_ND"); |
| 3275 | |
| 3276 | return $ret_arr_cuentas; |
| 3277 | } |
| 3278 | |
| 3279 | //VCA 12-12-2020 banco_cuenta_no_aparece_depositar_en |
| 3280 | function leer_banco_cuenta_no_aparece_depositar_en(){ |
| 3281 | |
| 3282 | $ret_arr_cuentas=array( "txt_cuenta_no_aparece_depositar_en" => "", |
| 3283 | "div_cuenta_no_aparece_depositar_en" => "", |
| 3284 | "div_cuenta_aparece_depositar_en" => ""); |
| 3285 | |
| 3286 | $txt_cuenta_no_aparece_depositar_en=""; |
| 3287 | $div_cuenta_no_aparece_depositar_en=""; |
| 3288 | $div_cuenta_aparece_depositar_en=""; |
| 3289 | |
| 3290 | //CODIGO PARA PERMISOS POR USUARIO |
| 3291 | $cpnd_sql = "SELECT banco_cuenta_no_aparece_depositar_en FROM iac_parametros WHERE iac_parametros_id = '1'"; |
| 3292 | $cpnd_csv = ia_singleread($cpnd_sql); |
| 3293 | |
| 3294 | //echo "<li>$cpnd_csv"; |
| 3295 | |
| 3296 | $cpnd_array = explode(",", $cpnd_csv); |
| 3297 | |
| 3298 | //echo "<pre>cpnd_array" . print_r($cpnd_array, true) . "</pre>"; |
| 3299 | |
| 3300 | if(is_array($cpnd_array) && !empty($cpnd_array)) { |
| 3301 | $cpnd_in = "banco_cuenta_id IN ('" . join("','", $cpnd_array) . "')"; |
| 3302 | $cpnd_not_in = "banco_cuenta_id NOT IN ('" . join("','", $cpnd_array) . "')"; |
| 3303 | } |
| 3304 | else { |
| 3305 | $cpnd_in = "banco_cuenta_id = -1"; |
| 3306 | $cpnd_not_in = "banco_cuenta_id > 0"; |
| 3307 | } |
| 3308 | |
| 3309 | $cpnd_fin_sql = "SELECT banco_cuenta_id, nombre FROM banco_cuenta WHERE vale='Active' AND $cpnd_in ORDER BY 2"; |
| 3310 | |
| 3311 | // $cpnd_fin_arr tiene las cuentas que sí tienen sus depositos en ND. |
| 3312 | $cpnd_fin_arr = ia_sqlArrayIndx($cpnd_fin_sql); |
| 3313 | |
| 3314 | $cpnd_sin_sql = "SELECT banco_cuenta_id, nombre FROM banco_cuenta WHERE vale='Active' AND $cpnd_not_in ORDER BY 2"; |
| 3315 | |
| 3316 | // $cpnd_sin_arr tiene las cuentas que no tienen sus depositos en ND. |
| 3317 | $cpnd_sin_arr = ia_sqlArrayIndx($cpnd_sin_sql); |
| 3318 | |
| 3319 | //echo "<pre>fin" . print_r($cpnd_fin_arr, true) . "</pre>"; |
| 3320 | //echo "<pre>sin" . print_r($cpnd_sin_arr, true) . "</pre>"; |
| 3321 | |
| 3322 | // if(!is_array($cpnd_fin_arr) || empty($cpnd_fin_arr)) |
| 3323 | // return $ret_arr_cuentas; |
| 3324 | |
| 3325 | // echo "<li>$cpnd_fin_sql"; |
| 3326 | // echo "<li>$cpnd_sin_sql"; |
| 3327 | |
| 3328 | |
| 3329 | |
| 3330 | foreach($cpnd_fin_arr as $k=>$v) |
| 3331 | { |
| 3332 | $cuenta=$v['nombre']; |
| 3333 | $txt_cuenta_no_aparece_depositar_en.=" $cuenta,"; |
| 3334 | $div_cuenta_no_aparece_depositar_en.='<div id="'.$v['banco_cuenta_id'].'" data-banco_cuenta_id="'.$v['banco_cuenta_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" onclick="quita_cuenta('.$v['banco_cuenta_id'].',_no_aparece_depositar_en);"> <img src="../img/delete.png" width="14" height="14" alt="Dejar de poner depósitos en ND." title="Dejar de poner depósitos en ND." /></a> </div>'; |
| 3335 | |
| 3336 | } |
| 3337 | |
| 3338 | if(!empty($txt_cuenta_no_aparece_depositar_en)) |
| 3339 | $txt_cuenta_no_aparece_depositar_en = substr_replace($txt_cuenta_no_aparece_depositar_en,"",-1); |
| 3340 | |
| 3341 | foreach($cpnd_sin_arr as $k=>$v) |
| 3342 | { |
| 3343 | $cuenta=$v['nombre']; |
| 3344 | $div_cuenta_aparece_depositar_en.='<div id="'.$v['banco_cuenta_id'].'" data-banco_cuenta_id="'.$v['banco_cuenta_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" onclick="agrega_cuenta('.$v['banco_cuenta_id'].',_no_aparece_depositar_en);"> <img src="../img/add.png" width="14" height="14" alt="Poner depósitos en ND." title="Poner depósitos en ND." /></a> </div>'; |
| 3345 | } |
| 3346 | |
| 3347 | $div_cuenta_no_aparece_depositar_en='<div id="vale_cuenta_no_aparece_depositar_en" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= CUENTAS NO APARECEN EN DEPOSITA EN =-</strong><hr/><br/>'.$div_cuenta_no_aparece_depositar_en.'</div>'; |
| 3348 | $div_cuenta_aparece_depositar_en='<div id="vale_cuenta_aparece_depositar_en" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= CUENTAS APARECEN EN DEPOSITA EN =-</strong><hr/><br/>'.$div_cuenta_aparece_depositar_en.'</div>'; |
| 3349 | |
| 3350 | $ret_arr_cuentas=array( "txt_cuenta_no_aparece_depositar_en" => "$txt_cuenta_no_aparece_depositar_en", |
| 3351 | "div_cuenta_no_aparece_depositar_en" => "$div_cuenta_no_aparece_depositar_en", |
| 3352 | "div_cuenta_aparece_depositar_en" => "$div_cuenta_aparece_depositar_en"); |
| 3353 | |
| 3354 | return $ret_arr_cuentas; |
| 3355 | } |
| 3356 | //VCA 12-12-2020 puede_bodega_destinos_especiales |
| 3357 | function leer_origen_destino_especial(){ |
| 3358 | |
| 3359 | $ret_arr_cuentas=array( "txt_requiere_autorizacion_origen_destino_especial" => "", |
| 3360 | "div_requiere_autorizacion_origen_destino_especial" => "", |
| 3361 | "div_no_requiere_autorizacion_origen_destino_especial" => ""); |
| 3362 | |
| 3363 | $txt_requiere_autorizacion_origen_destino_especial=""; |
| 3364 | $div_requiere_autorizacion_origen_destino_especial=""; |
| 3365 | $div_no_requiere_autorizacion_origen_destino_especial=""; |
| 3366 | |
| 3367 | //CODIGO PARA PERMISOS POR USUARIO |
| 3368 | $cpnd_sql = "SELECT origen_destino_especial FROM iac_parametros WHERE iac_parametros_id = '1'"; |
| 3369 | $cpnd_csv = ia_singleread($cpnd_sql); |
| 3370 | |
| 3371 | //echo "<li>$cpnd_csv"; |
| 3372 | |
| 3373 | $cpnd_array = explode(",", $cpnd_csv); |
| 3374 | |
| 3375 | //echo "<pre>cpnd_array" . print_r($cpnd_array, true) . "</pre>"; |
| 3376 | |
| 3377 | if(is_array($cpnd_array) && !empty($cpnd_array)) { |
| 3378 | $cpnd_in = "origen_bodega_id IN ('" . join("','", $cpnd_array) . "')"; |
| 3379 | $cpnd_not_in = "origen_bodega_id NOT IN ('" . join("','", $cpnd_array) . "')"; |
| 3380 | } |
| 3381 | else { |
| 3382 | $cpnd_in = "origen_bodega_id = 'ABCXYZ'"; |
| 3383 | $cpnd_not_in = "origen_bodega_id <> ''"; |
| 3384 | } |
| 3385 | |
| 3386 | $cpnd_fin_sql = "SELECT origen_bodega_id, clave, clave as nombre FROM origen_bodega WHERE es <> 'CLIENTE' and activo = 'Si' AND $cpnd_in ORDER BY 2"; |
| 3387 | |
| 3388 | // $cpnd_fin_arr tiene las cuentas que sí tienen sus depositos en ND. |
| 3389 | $cpnd_fin_arr = ia_sqlArrayIndx($cpnd_fin_sql); |
| 3390 | |
| 3391 | $cpnd_sin_sql = "SELECT origen_bodega_id, clave, clave as nombre FROM origen_bodega WHERE es <> 'CLIENTE' and activo = 'Si' AND $cpnd_not_in ORDER BY 2"; |
| 3392 | |
| 3393 | // $cpnd_sin_arr tiene las cuentas que no tienen sus depositos en ND. |
| 3394 | $cpnd_sin_arr = ia_sqlArrayIndx($cpnd_sin_sql); |
| 3395 | |
| 3396 | //echo "<pre>fin" . print_r($cpnd_fin_arr, true) . "</pre>"; |
| 3397 | //echo "<pre>sin" . print_r($cpnd_sin_arr, true) . "</pre>"; |
| 3398 | |
| 3399 | // if(!is_array($cpnd_fin_arr) || empty($cpnd_fin_arr)) |
| 3400 | // return $ret_arr_cuentas; |
| 3401 | |
| 3402 | // echo "<li>$cpnd_fin_sql"; |
| 3403 | // echo "<li>$cpnd_sin_sql"; |
| 3404 | |
| 3405 | |
| 3406 | |
| 3407 | foreach($cpnd_fin_arr as $k=>$v) |
| 3408 | { |
| 3409 | $cuenta=$v['nombre']; |
| 3410 | $txt_requiere_autorizacion_origen_destino_especial.=" $cuenta,"; |
| 3411 | $div_requiere_autorizacion_origen_destino_especial.='<div id="'.$v['origen_bodega_id'].'" data-origen_bodega_id="'.$v['origen_bodega_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" id="'.$v['origen_bodega_id'].'" onclick="quita_origen_destino_especial(this.id,_origen_destino_especial);"> <img src="../img/delete.png" width="14" height="14" alt="Dejar de poner depósitos en ND." title="Dejar de poner depósitos en ND." /></a> </div>'; |
| 3412 | |
| 3413 | } |
| 3414 | |
| 3415 | if(!empty($txt_requiere_autorizacion_origen_destino_especial)) |
| 3416 | $txt_requiere_autorizacion_origen_destino_especial = substr_replace($txt_requiere_autorizacion_origen_destino_especial,"",-1); |
| 3417 | |
| 3418 | foreach($cpnd_sin_arr as $k=>$v) |
| 3419 | { |
| 3420 | $cuenta=$v['nombre']; |
| 3421 | $div_no_requiere_autorizacion_origen_destino_especial.='<div id="'.$v['origen_bodega_id'].'" data-origen_bodega_id="'.$v['origen_bodega_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" id="'.$v['origen_bodega_id'].'" onclick="agrega_origen_destino_especial(this.id,_origen_destino_especial);"> <img src="../img/add.png" width="14" height="14" alt="Pedir Autorización" title="Pedir Autorización" /></a> </div>'; |
| 3422 | } |
| 3423 | |
| 3424 | $div_requiere_autorizacion_origen_destino_especial='<div id="vale_requiere_autorizacion_origen_destino_especial" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= REQUIEREN AUTORIZACIÓN =-</strong><hr/><br/>'.$div_requiere_autorizacion_origen_destino_especial.'</div>'; |
| 3425 | $div_no_requiere_autorizacion_origen_destino_especial='<div id="vale_no_requiere_autorizacion_origen_destino_especial" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= NO REQUIEREN AUTORIZACIÓN =-</strong><hr/><br/>'.$div_no_requiere_autorizacion_origen_destino_especial.'</div>'; |
| 3426 | |
| 3427 | $ret_arr_cuentas=array( "txt_requiere_autorizacion_origen_destino_especial" => "$txt_requiere_autorizacion_origen_destino_especial", |
| 3428 | "div_requiere_autorizacion_origen_destino_especial" => "$div_requiere_autorizacion_origen_destino_especial", |
| 3429 | "div_no_requiere_autorizacion_origen_destino_especial" => "$div_no_requiere_autorizacion_origen_destino_especial"); |
| 3430 | |
| 3431 | return $ret_arr_cuentas; |
| 3432 | } |
| 3433 | //VCA 12-12-2020 puede_bodega_destinos_especiales |
| 3434 | function leer_bodegas_no_existencia(){ |
| 3435 | |
| 3436 | $ret_arr_cuentas=array( |
| 3437 | "txt_no_aparece_bodegas_no_existencia" => "", |
| 3438 | "div_no_aparece_bodegas_no_existencia" => "", |
| 3439 | "div_si_aparece_bodegas_no_existencia" => ""); |
| 3440 | |
| 3441 | $txt_no_aparece_bodegas_no_existencia=""; |
| 3442 | $div_no_aparece_bodegas_no_existencia=""; |
| 3443 | $div_si_aparece_bodegas_no_existencia=""; |
| 3444 | |
| 3445 | //CODIGO PARA PERMISOS POR USUARIO |
| 3446 | $cpnd_sql = "SELECT bodegas_no_existencia FROM iac_parametros WHERE iac_parametros_id = '1'"; |
| 3447 | $cpnd_csv = ia_singleread($cpnd_sql); |
| 3448 | |
| 3449 | //echo "<li>$cpnd_csv"; |
| 3450 | |
| 3451 | $cpnd_array = explode(",", $cpnd_csv); |
| 3452 | |
| 3453 | //echo "<pre>cpnd_array" . print_r($cpnd_array, true) . "</pre>"; |
| 3454 | |
| 3455 | if(is_array($cpnd_array) && !empty($cpnd_array)) { |
| 3456 | $cpnd_in = "bodega_id IN ('" . join("','", $cpnd_array) . "')"; |
| 3457 | $cpnd_not_in = "bodega_id NOT IN ('" . join("','", $cpnd_array) . "')"; |
| 3458 | } |
| 3459 | else { |
| 3460 | $cpnd_in = "bodega_id = 'ABCXYZ'"; |
| 3461 | $cpnd_not_in = "bodega_id <> ''"; |
| 3462 | } |
| 3463 | |
| 3464 | $cpnd_fin_sql = "SELECT bodega_id, bodega, CONCAT(bodega, IF(label <> '', CONCAT(' (', label, ')'), '')) as nombre FROM bodega WHERE activo = 'Si' AND $cpnd_in ORDER BY 2"; |
| 3465 | |
| 3466 | // $cpnd_fin_arr tiene las cuentas que sí tienen sus depositos en ND. |
| 3467 | $cpnd_fin_arr = ia_sqlArrayIndx($cpnd_fin_sql); |
| 3468 | |
| 3469 | $cpnd_sin_sql = "SELECT bodega_id, bodega, CONCAT(bodega, IF(label <> '', CONCAT(' (', label, ')'), '')) as nombre FROM bodega WHERE activo = 'Si' AND $cpnd_not_in ORDER BY 2"; |
| 3470 | |
| 3471 | // $cpnd_sin_arr tiene las cuentas que no tienen sus depositos en ND. |
| 3472 | $cpnd_sin_arr = ia_sqlArrayIndx($cpnd_sin_sql); |
| 3473 | |
| 3474 | //echo "<pre>fin" . print_r($cpnd_fin_arr, true) . "</pre>"; |
| 3475 | //echo "<pre>sin" . print_r($cpnd_sin_arr, true) . "</pre>"; |
| 3476 | |
| 3477 | // if(!is_array($cpnd_fin_arr) || empty($cpnd_fin_arr)) |
| 3478 | // return $ret_arr_cuentas; |
| 3479 | |
| 3480 | // echo "<li>$cpnd_fin_sql"; |
| 3481 | // echo "<li>$cpnd_sin_sql"; |
| 3482 | |
| 3483 | |
| 3484 | |
| 3485 | foreach($cpnd_fin_arr as $k=>$v) |
| 3486 | { |
| 3487 | $cuenta=$v['nombre']; |
| 3488 | $txt_no_aparece_bodegas_no_existencia.=" $cuenta,"; |
| 3489 | $div_no_aparece_bodegas_no_existencia.='<div id="'.$v['bodega_id'].'" data-bodega_id="'.$v['bodega_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" id="'.$v['bodega_id'].'" onclick="quita_bodegas_no_existencia(this.id,_bodegas_no_existencia);"> <img src="../img/delete.png" width="14" height="14" alt="Dejar de poner depósitos en ND." title="Dejar de poner depósitos en ND." /></a> </div>'; |
| 3490 | |
| 3491 | } |
| 3492 | |
| 3493 | if(!empty($txt_no_aparece_bodegas_no_existencia)) |
| 3494 | $txt_no_aparece_bodegas_no_existencia = substr_replace($txt_no_aparece_bodegas_no_existencia,"",-1); |
| 3495 | |
| 3496 | foreach($cpnd_sin_arr as $k=>$v) |
| 3497 | { |
| 3498 | $cuenta=$v['nombre']; |
| 3499 | $div_si_aparece_bodegas_no_existencia.='<div id="'.$v['bodega_id'].'" data-bodega_id="'.$v['bodega_id'].'" data-nombre="'.$cuenta.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding: 5;"><strong>'.$cuenta.'</strong><a href="javascript:void(0);" id="'.$v['bodega_id'].'" onclick="agrega_bodegas_no_existencia(this.id,_bodegas_no_existencia);"> <img src="../img/add.png" width="14" height="14" alt="Pedir Autorización" title="Pedir Autorización" /></a> </div>'; |
| 3500 | } |
| 3501 | |
| 3502 | $div_no_aparece_bodegas_no_existencia='<div id="vale_no_aparece_bodegas_no_existencia" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= NO APARECEN =-</strong><hr/><br/>'.$div_no_aparece_bodegas_no_existencia.'</div>'; |
| 3503 | $div_si_aparece_bodegas_no_existencia='<div id="vale_si_aparece_bodegas_no_existencia" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= SÍ APARECEN =-</strong><hr/><br/>'.$div_si_aparece_bodegas_no_existencia.'</div>'; |
| 3504 | |
| 3505 | $ret_arr_cuentas=array( "txt_no_aparece_bodegas_no_existencia" => "$txt_no_aparece_bodegas_no_existencia", |
| 3506 | "div_no_aparece_bodegas_no_existencia" => "$div_no_aparece_bodegas_no_existencia", |
| 3507 | "div_si_aparece_bodegas_no_existencia" => "$div_si_aparece_bodegas_no_existencia"); |
| 3508 | |
| 3509 | return $ret_arr_cuentas; |
| 3510 | } |
| 3511 | |
| 3512 | function doSelectCatDoc($table, $catDoc, $label = 'Ir a categoría') |
| 3513 | { |
| 3514 | |
| 3515 | $retSel=""; |
| 3516 | if(empty($table)) |
| 3517 | return $retSel; |
| 3518 | |
| 3519 | $xtraSql= usuarioTipoRony() ? " WHERE 1 ":" WHERE para_quien<>'RONY' "; |
| 3520 | |
| 3521 | $arrCat = ia_sqlArray("SELECT * FROM categoria $xtraSql AND activo='Si' ORDER BY categoria_id", "categoria_id"); |
| 3522 | $retSel="<div id='divirCat' style='margin-top: px;'> |
| 3523 | $label: <select id='irDocCat' class='ui-front'>"; |
| 3524 | |
| 3525 | $cheque_dd = param('CDD', 'ALL'); |
| 3526 | $cheque_dd = !empty($cheque_dd) ? $cheque_dd : 'NO'; |
| 3527 | if($cheque_dd == 'SI') |
| 3528 | $table = "cheque_dd"; |
| 3529 | $cheque_dd = "&CDD=$cheque_dd"; |
| 3530 | |
| 3531 | //VCA Cheque DD |
| 3532 | // if(property_exists($this, "CDD") || $this instanceof app_cheque_dd) |
| 3533 | // $paramAdd.="&CDD=$this->CDD"; |
| 3534 | |
| 3535 | foreach($arrCat as $k=>$v) |
| 3536 | $retSel.="<option value='$table.php?cat=$k$cheque_dd' style='color:blue' ".($k==$catDoc?"selected='selected'":"")." >$v[categoria]</option>"; |
| 3537 | |
| 3538 | $retSel.="</select></div>"; |
| 3539 | |
| 3540 | return $retSel; |
| 3541 | } |
| 3542 | |
| 3543 | /** |
| 3544 | * Para esperar a que se llene el cache y mandarlo. |
| 3545 | * |
| 3546 | * @param string $tabla |
| 3547 | * @param int $segundos |
| 3548 | * @param int $cuantas_veces |
| 3549 | * @param bool $force |
| 3550 | */ |
| 3551 | function haz_retraso_si_tabla_vacia($tabla = "", $segundos = 1, $cuantas_veces = 5, $force = false) |
| 3552 | { |
| 3553 | if(empty($tabla)) |
| 3554 | return; |
| 3555 | |
| 3556 | $veces = 0; |
| 3557 | $cuantas_veces = $force ? 10 : $cuantas_veces; |
| 3558 | do{ |
| 3559 | //$tabla_vacia = ia_singleread("SELECT COUNT(*) FROM $tabla"); |
| 3560 | $tabla_vacia = ia_singleread("SELECT /** haz_retraso_si_tabla_vacia $tabla **/ table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'vitex' AND TABLE_NAME='$tabla'"); |
| 3561 | if(!$tabla_vacia) |
| 3562 | sleep($segundos); |
| 3563 | }while(!$tabla_vacia && $veces++ < $cuantas_veces); |
| 3564 | |
| 3565 | return; |
| 3566 | } |
| 3567 | |
| 3568 | function revisaMoneda($moneda = '1') |
| 3569 | { |
| 3570 | $arrMonedasValidas = json_decode(obtenCatalogo('moneda_id')); |
| 3571 | $encontrado = false; |
| 3572 | |
| 3573 | foreach($arrMonedasValidas as $k=>$v) |
| 3574 | if(gettype($v) === "object" && $v->moneda_id == $moneda) |
| 3575 | $encontrado = true; |
| 3576 | |
| 3577 | return $encontrado; |
| 3578 | } |
| 3579 | |
| 3580 | function revisaTipoFactura($factura = 'MST') |
| 3581 | { |
| 3582 | $arrTipoFacturaValidas = arrayTipoFactura(); |
| 3583 | $encontrado = false; |
| 3584 | |
| 3585 | foreach($arrTipoFacturaValidas as $k=>$v) |
| 3586 | if($v == $factura) |
| 3587 | $encontrado = true; |
| 3588 | |
| 3589 | return $encontrado; |
| 3590 | } |
| 3591 | |
| 3592 | function revisaTipoCashNota($tipo = 'CASH') |
| 3593 | { |
| 3594 | $arrTipoCashNotaValidas = arrayTipoCashNota(); |
| 3595 | $encontrado = false; |
| 3596 | |
| 3597 | //return array_key_exists($tipo, $arrTipoCashNotaValidas); |
| 3598 | |
| 3599 | foreach($arrTipoCashNotaValidas as $k=>$v) |
| 3600 | { |
| 3601 | //echo "v: $v, tipo: $tipo\r\n"; |
| 3602 | if($v == $tipo) |
| 3603 | $encontrado = true; |
| 3604 | } |
| 3605 | |
| 3606 | return $encontrado; |
| 3607 | } |
| 3608 | |
| 3609 | function revisaCamposCFDI33($valor = '', $campo = '') |
| 3610 | { |
| 3611 | $encontrado = false; |
| 3612 | |
| 3613 | if(empty($valor) || empty($campo)) |
| 3614 | return $encontrado; |
| 3615 | |
| 3616 | $campo = strtolower($campo); |
| 3617 | |
| 3618 | $arrValidos = json_decode(obtenCatalogo($campo)); |
| 3619 | |
| 3620 | foreach($arrValidos as $k=>$v) |
| 3621 | if(gettype($v) === "object" && $v->value == $valor) |
| 3622 | $encontrado = true; |
| 3623 | |
| 3624 | return $encontrado; |
| 3625 | } |
| 3626 | |
| 3627 | function revisaActivoCatalogo($tabla='', $campo_id='', $valor_id='', $campo_activo='') |
| 3628 | { |
| 3629 | if($campo_activo=="vale"){ |
| 3630 | return ia_singleread("SELECT IF($campo_activo='Active',true,false) AS activo FROM $tabla WHERE $campo_id='$valor_id'"); |
| 3631 | }else if($campo_activo=="activo"){ |
| 3632 | return ia_singleread("SELECT IF($campo_activo='Si',true,false) AS activo FROM $tabla WHERE $campo_id='$valor_id'"); |
| 3633 | }else if($campo_activo==''){ |
| 3634 | return ia_singleread("SELECT IF($campo_id!='',true,false) AS activo FROM $tabla WHERE $campo_id='$valor_id'"); |
| 3635 | } |
| 3636 | |
| 3637 | } |
| 3638 | |
| 3639 | function brtbNotificaciones($table='', $app = null) |
| 3640 | { |
| 3641 | $html = ''; |
| 3642 | |
| 3643 | switch($table) |
| 3644 | { |
| 3645 | case 'fiduciario_list': |
| 3646 | $html = |
| 3647 | '<table style="width:100%;"><tr> |
| 3648 | <td style="border:0px; vertical-align: bottom; font-size: 35px;"> |
| 3649 | <div id="fidExp" style="display:none;"> |
| 3650 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'4\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3651 | <span class="txt_color_orange blink" alt="Fiduciarios Expirados" title="Fiduciarios Expirados" ></span></a></div> |
| 3652 | </td> |
| 3653 | <td style="border:0px; vertical-align: bottom; font-size: 28px;"> |
| 3654 | <div id="fidExpUrg" style="display:none; float:left;"> |
| 3655 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'6\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3656 | <span class="txt_bold_brightred blink" alt="Fiduciarios Expirados Atrasados" title="Fiduciarios Expirados Atrasados" ></span></a></div> |
| 3657 | </td> |
| 3658 | <td style="border:0px; vertical-align: bottom; font-size: 35px;"> |
| 3659 | <div id="fidExpSol" style="display:none;"> |
| 3660 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'5\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3661 | <span class="txt_bold_blue blink" alt="Fiduciarios Expirados con Solicitud de Reembolso" title="Fiduciarios Expirados con Solicitud de Reembolso" ></span></a></div> |
| 3662 | </td> |
| 3663 | <td style="border:0px; vertical-align: bottom; font-size: 28px;"> |
| 3664 | <div id="fidExpSolUrg" style="display:none;"> |
| 3665 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'7\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3666 | <span class="txt_color_USD bold blink" alt="Fiduciarios Expirados con Solicitud de Reembolso Atrasada" title="Fiduciarios Expirados sin Link" ></span></a></div> |
| 3667 | </td> |
| 3668 | <td style="border:0px;"><div id="fidMod" style="display:none;"> |
| 3669 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'1\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3670 | <img id="fidModImg" src="../img/50-lock-red.gif" width="50" height="50" alt="Fiduciarios con Link sin revisar" title="Fiduciarios con Link sin revisar"/></a></div> |
| 3671 | </td> |
| 3672 | <td style="border:0px;"><div id="fidErr" style="display:none;"> |
| 3673 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'2\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3674 | <img id="fidModImg" src="../img/48-error.gif" width="48" height="48" alt="Fiduciarios con Error" title="Fiduciarios con Error"/></a></div> |
| 3675 | </td> |
| 3676 | <td style="border:0px;"><div id="fidCap" style="display:none;"> |
| 3677 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'3\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3678 | <img id="fidModImg" src="../img/42-edit.gif" width="42" height="42" alt="Fiduciarios sin Capturar" title="Fiduciarios sin Capturar"/></a></div> |
| 3679 | </td> |
| 3680 | </tr></table>'; |
| 3681 | break; |
| 3682 | |
| 3683 | case 'fiduciario_contenedor_list': |
| 3684 | $html = |
| 3685 | '<table style="width:100%;"><tr> |
| 3686 | <td style="border:0px; vertical-align: bottom; font-size: 35px;"> |
| 3687 | <div id="fidExp" style="display:none;"> |
| 3688 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'4\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3689 | <span class="txt_color_orange blink" alt="Contenedores de Fiduciarios Expirados" title="Contenedores de Fiduciarios Expirados" ></span></a></div> |
| 3690 | </td> |
| 3691 | <td style="border:0px; vertical-align: bottom; font-size: 28px;"> |
| 3692 | <div id="fidExpUrg" style="display:none; float:left;"> |
| 3693 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'6\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3694 | <span class="txt_bold_brightred blink" alt="Contenedores de Fiduciarios Expirados Atrasados" title="Contenedores de Fiduciarios Expirados Atrasados" ></span></a></div> |
| 3695 | </td> |
| 3696 | <td style="border:0px; vertical-align: bottom; font-size: 35px;"><div id="fidExpSol" style="display:none;"> |
| 3697 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'5\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3698 | <span class="txt_bold_blue blink" alt="Contenedores de Fiduciarios Expirados con Solicitud de Reembolso" title="Contenedores de Fiduciarios Expirados con Solicitud de Reembolso" ></span></a></div> |
| 3699 | </td> |
| 3700 | <td style="border:0px; vertical-align: bottom; font-size: 28px;"><div id="fidExpSolUrg" style="display:none;"> |
| 3701 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'7\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3702 | <span class="txt_color_USD bold blink" alt="Contenedores de Fiduciarios Expirados sin Link" title="Contenedores de Fiduciarios Expirados con Solicitud de Reembolso Atrasada" ></span></a></div> |
| 3703 | </td> |
| 3704 | <td style="border:0px;"><div id="fidMod" style="display:none;"> |
| 3705 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'1\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3706 | <img id="fidModImg" src="../img/50-lock-red.gif" width="50" height="50" alt="Contenedores de Fiduciarios Modificados" title="Contenedores de Fiduciarios Modificados"/></a></div> |
| 3707 | </td> |
| 3708 | <td style="border:0px;"><div id="fidErr" style="display:none;"> |
| 3709 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'2\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3710 | <img id="fidModImg" src="../img/48-error.gif" width="48" height="48" alt="Contenedores de Fiduciarios con Error" title="Contenedores de Fiduciarios con Error"/></a></div> |
| 3711 | </td> |
| 3712 | <td style="border:0px;"><div id="fidCap" style="display:none;"></div></td> |
| 3713 | </tr></table>'; |
| 3714 | break; |
| 3715 | |
| 3716 | case 'inversion_list': |
| 3717 | $html = |
| 3718 | '<table style="width:100%;"><tr> |
| 3719 | <td style="border:0px; vertical-align: bottom; font-size: 35px;"> |
| 3720 | <div id="fidExp" style="display:none;"> |
| 3721 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'4\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3722 | <span class="txt_color_orange blink" alt="Inversiones por vencer" title="Inversiones por vencer" ></span></a></div> |
| 3723 | </td> |
| 3724 | <td style="border:0px; vertical-align: bottom; font-size: 28px;"> |
| 3725 | <div id="fidExpUrg" style="display:none; float:left;"> |
| 3726 | <a class="brtb" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'6\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3727 | <span class="txt_bold_brightred blink" alt="Inversiones vencidas" title="Inversiones vencidas" ></span></a></div> |
| 3728 | </td> |
| 3729 | <td style="border:0px;"><div id="fidMod" style="display:none;"> |
| 3730 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'1\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3731 | <img id="linksTodayImg" src="../img/32-inversion-modificada.gif" width="32" height="32" alt="Inversiones con Link sin revisar" title="Inversiones con Link sin revisar"/></a></div> |
| 3732 | </td> |
| 3733 | <td style="border:0px;"><div id="fidErr" style="display:none;"> |
| 3734 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'2\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3735 | <img id="fidModImg" src="../img/48-error.gif" width="48" height="48" alt="Inversiones con Error" title="Inversiones con Error"/></a></div> |
| 3736 | </td> |
| 3737 | <td style="border:0px;"><div id="fidCap" style="display:none;"> |
| 3738 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'3\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3739 | <img id="fidModImg" src="../img/42-edit.gif" width="42" height="42" alt="Inversiones sin Capturar" title="Inversiones sin Capturar"/></a></div> |
| 3740 | </td> |
| 3741 | <td style="border:0px;"><div id="OrderCols" style="display:block;"> |
| 3742 | <a href="javascript:void(0);" onclick="if(c_cols_order === 1 ) c_cols_order = 0; else c_cols_order = 1; cambiaOrdenCols(c_cols_order);"> |
| 3743 | <img id="fidModImg" src="../img/32-interes.png" width="32" height="32" alt="Mostrar Tasa de Interés y Banco" title="Mostrar Tasa de Interés y Banco"/></a></div> |
| 3744 | </td> |
| 3745 | </tr></table>'; |
| 3746 | break; |
| 3747 | |
| 3748 | case 'todo_a_banco_list': |
| 3749 | $html = |
| 3750 | '<table style="width:100%;"><tr> |
| 3751 | <td style="border:0px;"><div id="linksToday" style="display:block;"> |
| 3752 | <a id="aLinksToday" href="javascript:void(0);" onclick="linksDeHoy(\'mesactual\');" > |
| 3753 | <img id="linksTodayImg" src="../img/32-calendario.png" height="32" alt="Movimientos del Mes" title="Movimientos del Mes"/><br /></a></div> |
| 3754 | </td> |
| 3755 | <td style="border:0px;"><div id="OrderCols" style="display:block;"> |
| 3756 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(0);"> |
| 3757 | <img id="linksTodayImg" src="../img/48-default-doc.png" width="48" height="48" alt="Cambiar Vista: Original" title="Cambiar Vista: Original"/></a></div> |
| 3758 | </td> |
| 3759 | <td style="border:0px;"><div id="OrderCols" style="display:block;"> |
| 3760 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(1);"> |
| 3761 | <img id="linksTodayImg" src="../img/48-switch.png" width="48" height="48" alt="Cambiar Vista: Primero Comments" title="Cambiar Vista: Primero Comments"/></a></div> |
| 3762 | </td> |
| 3763 | <td style="border:0px;"><div id="OrderCols" style="display:block;"> |
| 3764 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(2);"> |
| 3765 | <img id="linksTodayImg" src="../img/40-IVA.png" width="48" height="48" alt="Cambiar Vista: IVA" title="Cambiar Vista: Primero IVA"/></a></div> |
| 3766 | </td> |
| 3767 | <td style="border:0px;"><div id="OrderCols" style="display:block;"> |
| 3768 | <a id="gotoLinks" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'18\'); ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);" > |
| 3769 | <img id="linksTodayImg" src="../img/48_links_sin_propias.png" width="48" height="48" alt="Sin afectar CuentaT y sin Propias" title="Sin afectar CuentaT y sin Propias"/></a></div> |
| 3770 | </td> |
| 3771 | <td style="border:0px;"><div id="OrderCols" style="display:block;"> |
| 3772 | <a id="gotoInversiones" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'SI\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'19\'); ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);" > |
| 3773 | <img id="linksTodayImg" src="../img/32-inversiones.png" width="48" height="48" alt="Inversiones" title="Inversiones"/></a></div> |
| 3774 | </td> |
| 3775 | </tr></table>'; |
| 3776 | break; |
| 3777 | |
| 3778 | case 'doctos': |
| 3779 | $html = |
| 3780 | '<table style="width:100%;"><tr> |
| 3781 | <td style="border:0px;"><div id="SinAutorizar" style="display:block;"> |
| 3782 | <a href="javascript:void(0);" onclick="doctosSinAutorizar();" > |
| 3783 | <img id="doctosSinAutorizar" src="../img/48-approve-docs.gif" height="42" width="42" alt="Movimientos sin Autorizar" title="Movimientos sin Autorizar"/></a></div> |
| 3784 | </td> |
| 3785 | </tr></table>'; |
| 3786 | break; |
| 3787 | |
| 3788 | case 'cheque': |
| 3789 | $cheque_dd = param('CDD', 'ALL'); |
| 3790 | $cheque_dd = !empty($cheque_dd) ? $cheque_dd : 'NO'; |
| 3791 | if($cheque_dd != 'NO') |
| 3792 | $html = |
| 3793 | '<table style="width:100%;"><tr> |
| 3794 | <td style="border:0px;"><div id="DDSinPagar" style="display:block; min-width: 60px;"> |
| 3795 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'3\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3796 | <img id="DDSinPagar" src="../img/32_dd_not_paid.png" height="42" width="42" alt="Delivered Directo Sin Pagar" |
| 3797 | title="Delivered Directo Sin Pagar"/></a></div> |
| 3798 | </td> |
| 3799 | <td style="border:0px;"><div id="DDPagados" style="display:block; min-width: 60px;"> |
| 3800 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'4\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3801 | <img id="DDPagados" src="../img/32_dd_paid.png" height="42" width="42" alt="Delivered Directo Pagados" |
| 3802 | title="Delivered Directo Pagados"/></a></div> |
| 3803 | </td> |
| 3804 | <td style="border:0px;"><div id="DD" style="display:block; min-width: 60px;"> |
| 3805 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'5\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3806 | <img id="DD" src="../img/32_dd_all.png" height="42" width="42" alt="Delivered Directo Todos" |
| 3807 | title="Delivered Directo"/></a></div> |
| 3808 | </td> |
| 3809 | <td style="border:0px;"> |
| 3810 | <div id="ctatGastoNoAuto" style="display:block;"> |
| 3811 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'6\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3812 | <img id="fidModImg" src="../img/64xg_astos.png" width="42" height="42" alt="Gastos" title="Gastos"/> |
| 3813 | </a> |
| 3814 | </div> |
| 3815 | </td> |
| 3816 | <td style="border:0px;"> |
| 3817 | <div id="ctatGastoPend" style="display:block;"> |
| 3818 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'7\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3819 | <img id="fidModImg" src="../img/64xn_ota.png" width="40" height="40" alt="Notas" title="Notas"/> |
| 3820 | </a> |
| 3821 | </div> |
| 3822 | </td> |
| 3823 | <td style="border:0px;"> |
| 3824 | <div id="ctatGastoImp" style="display:block;"> |
| 3825 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'8\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3826 | <img id="fidModImg" src="../img/64xn_ada.png" width="40" height="40" alt="Sin tipo" title="Sin tipo"/> |
| 3827 | </a> |
| 3828 | </div> |
| 3829 | </td> |
| 3830 | </tr></table>'; |
| 3831 | break; |
| 3832 | |
| 3833 | case 'cuentat_gasto_list': |
| 3834 | $html = |
| 3835 | '<table style="width:100%;"><tr> |
| 3836 | <td style="border:0px;"><div id="" style="display:block;"> |
| 3837 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(0);" ><img id="width_toolbar_col_chooser" src="../img/32-default-doc.png" width="32" height="32" alt="Cambiar Vista: Original" title="Cambiar Vista: Original"/></a> |
| 3838 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(1);" ><img id="width_toolbar_col_chooser" src="../img/48_supervisor.png" width="32" height="32" alt="Cambiar Vista: Asignación/Supervisión" title="Cambiar Vista: Asignación/Supervisión"/></a></div> |
| 3839 | </td> |
| 3840 | <td style="border:0px;"><div id="ctatGastoNoAuto" style="display:block;"> |
| 3841 | <a style="text-decoration: none; min-width: 100px;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'4\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3842 | <img id="fidModImg" src="../img/42-revise.png" width="42" height="42" alt="No Rechazados, No Autorizados" title="No Rechazados, No Autorizados"/></a></div> |
| 3843 | </td> |
| 3844 | <td style="border:0px;"><div id="ctatGastoPend" style="display:block;"> |
| 3845 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'5\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3846 | <img id="fidModImg" src="../img/40-letrap-carne.png" width="40" height="40" alt="Pendientes" title="Pendientes"/> |
| 3847 | <span class="bold txt21px" style="color:#e100b5;" alt="Pendientes" title="Pendientes" > </span></a></div> |
| 3848 | </td> |
| 3849 | <td style="border:0px;"><div id="ctatGastoImp" style="display:block;"> |
| 3850 | <a style="text-decoration: none; min-width: 100px;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'6\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3851 | <img id="fidModImg" src="../img/40-letrai-verde.png" width="40" height="40" alt="Importantes" title="Importantes"/> |
| 3852 | <span class="bold txt21px" style="color:#000000;" alt="Importantes" title="Importantes" > </span></a></div> |
| 3853 | </td> |
| 3854 | </tr></table>'; |
| 3855 | break; |
| 3856 | |
| 3857 | case 'factura_list': |
| 3858 | $html = |
| 3859 | '<table style="width:100%;"> |
| 3860 | <tr> |
| 3861 | <td style="border:0px;" id="canceladas_sin_revision"> |
| 3862 | <div style="display:block;"> |
| 3863 | <a href="javascript:void(0);" onclick="cols_order_fedault==0 ? cols_order_fedault = 1: cols_order_fedault = 0; cambiaOrdenCols(cols_order_fedault)"> |
| 3864 | <img id="fidModImg" src="../img/cancelados.png" height="60" width="60" alt="Mostrar Cancelados" style="width: 30px !important;height: 30px !important" |
| 3865 | title="Mostrar datos de cancelación"/> |
| 3866 | </a> |
| 3867 | </div> |
| 3868 | </td> |
| 3869 | <td style="border:0px;" id="canceladas_con_revision"> |
| 3870 | </td> |
| 3871 | </tr> |
| 3872 | </table>'; |
| 3873 | break; |
| 3874 | |
| 3875 | case 'clientes_saldos': |
| 3876 | $html = |
| 3877 | '<table style="width:100%;"><tr> |
| 3878 | <td style="border:0px;"><div id="clientes_con_saldo" style="display:block;"> |
| 3879 | <a href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'1\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3880 | <img id="fidModImg" src="../img/40_clientes_con_saldo_cat1_2.png" height="60" width="60" alt="Mostrar Clientes con Saldo" style="width: 30px !important;height: 30px !important" |
| 3881 | title="Mostrar Clientes con Saldo"/></a></div> |
| 3882 | </td> |
| 3883 | <td style="border:0px;"><div id="clientes_sin_saldo" style="display:block;"> |
| 3884 | <a href="javascript:void(0);" onclick="$gridParams.postData.sidx = $gridParams.sortname = \'ultima_compra\'; $gridParams.postData.sord = $gridParams.sortorder = \'desc\'; limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'2\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3885 | <img id="fidModImg" src="../img/40_clientes_sin_saldo_cat1_2.png" height="60" width="60" alt="Mostrar Clientes sin Saldo" style="width: 30px !important;height: 30px !important" |
| 3886 | title="Mostrar Clientes sin Saldo"/></a></div> |
| 3887 | </td> |
| 3888 | <td style="border:0px;"> |
| 3889 | <img src="../img/25-blank.png" /> |
| 3890 | </td> |
| 3891 | <td style="border:0px;"><div id="cli_doc_mas_antiguo" style="display:block;"> |
| 3892 | <a style="text-decoration: none; min-width: 100px;" href="javascript:void(0);" onclick="gridhandler.setGridParam({sortorder:\'asc\'}).jqGrid(\'sortGrid\', \'doc_mas_antiguo\', true);"> |
| 3893 | <img id="fidModImg" src="../img/40_doc_mas_antiguo.png" width="42" height="42" alt="Ordenar por Documento más antiguo" title="Ordenar por Documento más antiguo" style="width: 30px !important;height: 30px !important"/></a></div> |
| 3894 | </td> |
| 3895 | <td style="border:0px;"><div id="mayor_saldo_pesos" style="display:block;"> |
| 3896 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="gridhandler.setGridParam({sortorder:\'desc\'}).jqGrid(\'sortGrid\', \'saldo_cheques_pesos\', true);" > |
| 3897 | <img id="fidModImg" src="../img/40_mayor_saldo_pesos.png" width="40" height="40" alt="Ordenar por Mayor Saldo Cheques Pesos" title="Ordenar por Mayor Saldo Cheques Pesos" style="width: 30px !important;height: 30px !important"/></a></div> |
| 3898 | </td> |
| 3899 | <td style="border:0px;"><div id="mayor_saldo_usd" style="display:block;"> |
| 3900 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="gridhandler.setGridParam({sortorder:\'desc\'}).jqGrid(\'sortGrid\', \'saldo_pagares_usd\', true);" > |
| 3901 | <img id="fidModImg" src="../img/40_mayor_saldo_usd.png" width="40" height="40" alt="Ordenar por Mayor Saldo Pagarés USD" title="Ordenar por Mayor Saldo Pagarés USD" style="width: 30px !important;height: 30px !important"/></a></div> |
| 3902 | </td> |
| 3903 | <td style="border:0px;"><div id="mayor_saldo_vales_pesos" style="display:block;"> |
| 3904 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="gridhandler.setGridParam({sortorder:\'desc\'}).jqGrid(\'sortGrid\', \'saldo_vales_pesos\', true);" > |
| 3905 | <img id="fidModImg" src="../img/40_mayor_saldo_vales_pesos.png" width="40" height="40" alt="Ordenar por Mayor Saldo Vales Pesos" title="Ordenar por Mayor Saldo Vales Pesos" style="width: 30px !important;height: 30px !important"/></a></div> |
| 3906 | </td> |
| 3907 | <td style="border:0px;"><div id="mayor_saldo_vales_usd" style="display:block;"> |
| 3908 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="gridhandler.setGridParam({sortorder:\'desc\'}).jqGrid(\'sortGrid\', \'saldo_vales_usd\', true);" > |
| 3909 | <img id="fidModImg" src="../img/40_mayor_saldo_vales_usd.png" width="40" height="40" alt="Ordenar por Mayor Saldo Vales USD" title="Ordenar por Mayor Saldo Vales USD" style="width: 30px !important;height: 30px !important"/></a></div> |
| 3910 | </td> |
| 3911 | |
| 3912 | </tr></table>'; |
| 3913 | break; |
| 3914 | |
| 3915 | case 'gastos_banco_list': |
| 3916 | $editCont = param('ecc','No'); |
| 3917 | $html = |
| 3918 | '<table style="width:100%;"><tr> |
| 3919 | <td style="border:0px;"><div id="" style="display:block;"> |
| 3920 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(0);" ><img id="width_toolbar_col_chooser" src="../img/32-default-doc.png" width="32" height="32" alt="Cambiar Vista: Original" title="Cambiar Vista: Original"/></a> |
| 3921 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(1);" ><img id="width_toolbar_col_chooser" src="../img/32-switch.png" width="32" height="32" alt="Cambiar Vista: Primero Comments" title="Cambiar Vista: Primero Comments"/></a> |
| 3922 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(2);" ><img id="width_toolbar_col_chooser" src="../img/32-switch-1.png" width="32" height="32" alt="Cambiar Vista: Comments, Remarks, Referencia" title="Cambiar Vista: Comments, Remarks, Referencia"/></a> |
| 3923 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(3);" ><img id="width_toolbar_col_chooser" src="../img/32-contabilidad.png" width="32" height="32" alt="Cambiar Vista: Póliza Contable" title="Cambiar Vista: Póliza Contable"/></a> |
| 3924 | <div style="clear:both;"></div> |
| 3925 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(4);" ><img id="width_toolbar_col_chooser" src="../img/32-categorias.png" width="32" height="32" alt="Cambiar Vista: Categorías de Gastos" title="Cambiar Vista: Categorías de Gastos"/></a> |
| 3926 | <a href="javascript:void(0);" onclick="cambiaOrdenCols(5);" ><img id="width_toolbar_col_chooser" src="../img/48_supervisor.png" width="32" height="32" alt="Cambiar Vista: Asignación/Supervisión" title="Cambiar Vista: Asignación/Supervisión"/></a>'. |
| 3927 | (usuarioTipoRony() ? |
| 3928 | '<a href="withdrawals_de_banco_list.php?ecc='.($editCont=='No' ? 'Si' : 'No').'"> |
| 3929 | <img id="width_toolbar_col_chooser" src="../img/editar.png" width="32" height="32" alt="'.($editCont=='No' ? 'Activar' : 'Desactivar').' Plantillas para llenar Remarks" title="'.($editCont=='No' ? 'Activar' : 'Desctivar').' Plantillas para llenar Remarks"/></a>' : '') |
| 3930 | |
| 3931 | .'</div> |
| 3932 | </td> |
| 3933 | <td style="border:0px;"><div id="withdrawalsPend" style="display:block;"> |
| 3934 | <a style="text-decoration: none;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'1\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3935 | <img id="fidModImg" src="../img/40-letrap-carne.png" width="40" height="40" alt="Pendientes" title="Pendientes"/> |
| 3936 | <span class="bold txt18pxfr" style="color:#e100b5;" alt="Pendientes" title="Pendientes" > <br/> </span></a></div> |
| 3937 | </td> |
| 3938 | <td style="border:0px;"><div id="withdrawalsImp" style="display:block;"> |
| 3939 | <a style="text-decoration: none; min-width: 100px;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'2\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3940 | <img id="fidModImg" src="../img/40-letrai-verde.png" width="40" height="40" alt="Importantes" title="Importantes"/> |
| 3941 | <span class="bold txt18pxfr" style="color:#000000;" alt="Importantes" title="Importantes" > <br/> </span></a></div> |
| 3942 | </td> |
| 3943 | '. |
| 3944 | (esRevisor() ? |
| 3945 | '<td style="border:0px;"> |
| 3946 | <div id="asignaciones" style="float: left; border-radius: 25px; border: 1px solid darkorange; overflow: hidden; background: darkorange; padding: 5px; width: 26px; height: 29px;display: flex;align-items: center; font-size: 16px;"> |
| 3947 | <a class="brtb" href="javascript:void(0);" title="Mis Asignaciones"> |
| 3948 | ⛿A |
| 3949 | </a> |
| 3950 | </div> |
| 3951 | </td>' : '') |
| 3952 | |
| 3953 | .'<td style="border:0px;"><div id="withdrawalsRep" style="display:block;"> |
| 3954 | <a style="text-decoration: none; min-width: 100px;" href="javascript:void(0);" onclick="limpiaBusquedaRapida(\'NO\'); $(\'#macro_sel\').selectize()[0].selectize.setValue(\'3\'); setTimeout(function(){ejecutaBusquedaRapida(\'SI\');setTimeout(function(){limpiaBusquedaRapida(\'NO\');},200);},10);" > |
| 3955 | <img id="fidModImg" src="../img/40-letrar-rojo.png" width="40" height="40" alt="Repetidos" title="Repetidos"/> |
| 3956 | <span class="txt_bold_red txt18pxfr" style="color:#000000;" alt="Repetidos" title="Repetidos" > <br/> </span></a></div> |
| 3957 | </td> |
| 3958 | </tr></table>'; |
| 3959 | break; |
| 3960 | |
| 3961 | case 'nota_bodega': |
| 3962 | $bodegasPuedeConsultar = (new PermisosBodega())->bodegasPuedeConsultarMovimientos(); |
| 3963 | case 'nota_bodega_verificacion': |
| 3964 | // dd_($app->es_salidas_para_tiendas); |
| 3965 | global $gPermisosbodega; |
| 3966 | $permisoBodega = $gPermisosbodega; |
| 3967 | if(empty($bodegasPuedeConsultar) || param('sin_verificar') === 'si') |
| 3968 | $bodegasPuedeConsultar = $permisoBodega->bodegasPuedeConsultarVerificarMovimientos(); |
| 3969 | |
| 3970 | $bodegas = $permisoBodega->getBodegasActivas(); |
| 3971 | if ($app->es_salidas_para_tiendas??false) { |
| 3972 | $tienda_id = param('tienda_id'); |
| 3973 | $origen_id = param('origen_id'); |
| 3974 | if (empty($origen_id)) |
| 3975 | $origen_id = ia_singleread("SELECT origen_bodega_id FROM origen_bodega WHERE es = 'TIENDA' AND tienda_id = " . strit($tienda_id)); |
| 3976 | |
| 3977 | $bodegas_para_tienda = ia_sqlVector("SELECT distinct bodega_id FROM nota_bodega WHERE (origen_id = ".strit($origen_id).")"); |
| 3978 | $bodegas_consultar_tienda = []; |
| 3979 | foreach ($bodegas_para_tienda as $bodega_id) |
| 3980 | $bodegas_consultar_tienda[$bodega_id] = $bodegas[$bodega_id]; |
| 3981 | |
| 3982 | $bodegasPuedeConsultar = $bodegas_consultar_tienda; |
| 3983 | } |
| 3984 | |
| 3985 | // dd_($bodegasPuedeConsultar); |
| 3986 | |
| 3987 | $bodega_id = param('bodega_id'); |
| 3988 | if (empty($bodega_id)) { |
| 3989 | $bodega_id = $origen_id = param('origen_id_salida',param('origen_id_traslado')); |
| 3990 | /*if (!empty($origen_id)) |
| 3991 | $bodega_id = OrigenBodega::_getById($origen_id)['bodega_id'];*/ |
| 3992 | } else { |
| 3993 | $origen_id = OrigenBodega::_getBy(['es' => 'BODEGA', 'bodega_id' => $bodega_id])['origen_bodega_id']??''; |
| 3994 | } |
| 3995 | // $bodegas = json_decode(obtenCatalogo('bodega', false), true); // @TODO pero en PERMISOS BODEGA QUE? |
| 3996 | // $bodegas = []; |
| 3997 | /*if ($table == 'nota_bodega') |
| 3998 | $bodegas = (new PermisosBodega())->bodegasPuedeConsultarMovimientos(''); |
| 3999 | elseif ($table == 'nota_bodega_verificacion') |
| 4000 | $bodegas = (new PermisosBodega())->bodegasPuedeConsultarVerificarMovimientos('');*/ |
| 4001 | |
| 4002 | // $bodegas = $permisoBodega->getBodegasActivas(); // $bodegasPuede; // |
| 4003 | // $bodegasPuedeConsultar = $permisoBodega->bodegasPuedeConsultarMovimientos(); |
| 4004 | $bodegasPuedeConsultar_keys = array_keys($bodegasPuedeConsultar); |
| 4005 | $bodegas_y_grupos = json_decode(obtenCatalogo('origen_bodega_grupo_2', true), true); |
| 4006 | // dd_($bodegas_y_grupos); |
| 4007 | |
| 4008 | /* |
| 4009 | $grupos = array_filter($bodegas_y_grupos, function ($v, $k) { |
| 4010 | return strcasecmp($v['es'], 'GRUPO BODEGA') == 0; |
| 4011 | }, ARRAY_FILTER_USE_BOTH);*/ |
| 4012 | |
| 4013 | // $bodegas_y_grupos = array_merge($grupos, $bodegas); |
| 4014 | // dd_($bodegas_y_grupos); |
| 4015 | |
| 4016 | // dd_($bodega_id, $bodegas_y_grupos); |
| 4017 | |
| 4018 | if(empty($bodegasPuedeConsultar)) |
| 4019 | break; |
| 4020 | // dd_($bodegas); |
| 4021 | // $select = array2Select($bodegas, 'bodega_id', 'bodega', null ,'bodega_id', 'TODAS', false, true, [], [], null, false); |
| 4022 | if(count($bodegas_y_grupos) === 1) |
| 4023 | $select = "<select class='notSelectize' id='bodega_id'>"; |
| 4024 | else |
| 4025 | $select = "<select class='notSelectize' id='bodega_id'><option value=''>TODAS</option>"; |
| 4026 | |
| 4027 | $usuarioTipoRony = usuarioTipoRony(); |
| 4028 | $usuarioSupervisor = usuarioSupervisaBodega(); |
| 4029 | foreach ($bodegas_y_grupos as $bodega) { |
| 4030 | $id = $bodega['origen_bodega_id']; |
| 4031 | $bodega_id_self = $bodega['bodega_id'] ?? ''; |
| 4032 | |
| 4033 | if (!$usuarioSupervisor && !in_array($bodega_id_self, $bodegasPuedeConsultar_keys)) |
| 4034 | continue; |
| 4035 | |
| 4036 | $selected = ''; |
| 4037 | if ($id == $origen_id) |
| 4038 | $selected = 'selected="true"'; |
| 4039 | |
| 4040 | $color = "color:".($bodegas[$bodega_id_self]['color']??'000'); |
| 4041 | $select.="<option value='$id' data-bodega_id='$bodega_id_self' style='$color; font-weight: bold' $selected>".($bodega['bodega']??$bodega['label'] )."</option>"; |
| 4042 | // color:$bodega[color]; |
| 4043 | } |
| 4044 | |
| 4045 | $select.="</select>"; |
| 4046 | $match = param('match'); |
| 4047 | $checked = ""; |
| 4048 | $class_active_match= ""; |
| 4049 | if ($match == 'No'||$match == 'NO' ||$match == 'no') { |
| 4050 | $checked = "checked"; |
| 4051 | $class_active_match= "box_top_toolbar_danger_active"; |
| 4052 | } |
| 4053 | $soloSinMatch = $table === 'nota_bodega_verificacion' ? |
| 4054 | "<div id='div_orden_original'> |
| 4055 | <img id='fidModImg' src='../img/16-error.png' class='box_top_toolbar_danger $class_active_match box_top_toolbar' height='60' width='60' alt='O' style='width: 30px !important;height: 30px !important' title='SOLO SIN MATCH' onclick='$(\"#soloDiferentes\").click()'> |
| 4056 | <input type='checkbox' name='soloDiferentes' id='soloDiferentes' value='1' style='display: none' $checked> |
| 4057 | </div>" |
| 4058 | : |
| 4059 | ''; |
| 4060 | $div_a_destino =""; |
| 4061 | if (str_contains($_SERVER['REQUEST_URI'] ?? '', 'traslados.php')) { |
| 4062 | $destinos = obtenCatalogo('origen_bodega'); |
| 4063 | $destinos = json_decode($destinos, true); |
| 4064 | $destinos_bodegas = array_values(array_filter($destinos, function ($destino) { |
| 4065 | return ($destino['es'] == 'BODEGA'); |
| 4066 | })); |
| 4067 | $select_destinos = array2Select($destinos_bodegas, 'origen_id', 'label', param('destino_id_traslado'), |
| 4068 | isSelectize: false, identifier: 'select-origen_bodega_id', label:'TODAS'); |
| 4069 | $div_a_destino = "A $select_destinos"; |
| 4070 | } |
| 4071 | |
| 4072 | |
| 4073 | |
| 4074 | if (str_contains($_SERVER['REQUEST_URI'] ?? '', 'salidas_a_tienda_list.php')) { |
| 4075 | $tienda_id = param('tienda_id'); |
| 4076 | |
| 4077 | if (!empty($tienda_id)) { |
| 4078 | $origen_bodega_id = ia_singleread("SELECT origen_bodega_id FROM origen_bodega WHERE es = 'TIENDA' AND tienda_id = '$tienda_id'"); |
| 4079 | } else |
| 4080 | $origen_bodega_id = param('origen_id'); |
| 4081 | |
| 4082 | $destinos = json_decode(obtenCatalogo('origen_bodega'), true); |
| 4083 | if(usuarioSupervisaBodega()) |
| 4084 | $destinos_tiendas = array_values(array_filter($destinos, function ($destino) { |
| 4085 | return $destino['es'] === 'TIENDA'; |
| 4086 | })); |
| 4087 | else { |
| 4088 | $destinosValidos = array_flip(PermisosBodegaCRUD::getConsultaSalidasTienda_origen_id()); |
| 4089 | $destinos_tiendas = array_values(array_filter($destinos, function ($destino) use($destinosValidos) { |
| 4090 | return array_key_exists($destino['origen_bodega_id'], $destinosValidos); |
| 4091 | })); |
| 4092 | } |
| 4093 | |
| 4094 | $div_a_destino = "A " . |
| 4095 | array2Select($destinos_tiendas, 'origen_id', 'label', $origen_bodega_id, |
| 4096 | isSelectize: false, identifier: 'select-origen_bodega_id'); |
| 4097 | } |
| 4098 | |
| 4099 | $label = 'BODEGA'; |
| 4100 | $tienda_id = param('tienda_id'); |
| 4101 | if (!empty($tienda_id)) |
| 4102 | $label = 'ORIGEN'; |
| 4103 | |
| 4104 | $toolBar = new ToolBar(false); |
| 4105 | $toolBar->setModule('nota_bodega'); |
| 4106 | $toolBar->preparaData(); |
| 4107 | $html_toolbar = array( |
| 4108 | 'element' => 'div_toolbar_nota_bodega', |
| 4109 | 'view' => (string)$toolBar->render(null, true) |
| 4110 | ); |
| 4111 | |
| 4112 | |
| 4113 | $html = |
| 4114 | "<table style='width:100%;'> |
| 4115 | <tr> |
| 4116 | <td style='border:0px;'> |
| 4117 | <div style='display: flex;justify-content: center;align-items: center;'> |
| 4118 | $label: $select |
| 4119 | $div_a_destino |
| 4120 | </div> |
| 4121 | </td> |
| 4122 | </tr> |
| 4123 | <tr> |
| 4124 | <td style='display:flex;justify-content: space-around; border: 0px;'> |
| 4125 | $soloSinMatch |
| 4126 | <div id='div_toolbar_nota_bodega'> |
| 4127 | $html_toolbar[view] |
| 4128 | </div> |
| 4129 | </td> |
| 4130 | </tr> |
| 4131 | </table>"; |
| 4132 | break; |
| 4133 | case 'color': |
| 4134 | $productos = obtenCatalogo('producto_general', false); |
| 4135 | // $select = array2Select($productos, 'producto_general_id', 'label', null ,'select_producto_general_id', 'TODOS', isSelectize: false); |
| 4136 | $html = |
| 4137 | "<script> |
| 4138 | var productos_generales = $productos; |
| 4139 | </script> |
| 4140 | <table style='width:100%;'> |
| 4141 | <tr> |
| 4142 | <td style='border:0px;'> |
| 4143 | <div style='display: flex;justify-content: center;align-items: center;'> |
| 4144 | Producto: <input type='text' name='select_producto_general_id' id='select_producto_general_id'> |
| 4145 | </div> |
| 4146 | </td> |
| 4147 | </tr> |
| 4148 | </table>"; |
| 4149 | break; |
| 4150 | case 'solicitud_carta_porte': |
| 4151 | $html = |
| 4152 | "<table style='width:100%;'> |
| 4153 | <tr> |
| 4154 | <td style='border:0px;'> |
| 4155 | <div id='canceladas_sin_revision' style='display:block;'> |
| 4156 | <a href='javascript:void(0);' onclick='mostrarTodas()'> |
| 4157 | <img id='fidModImg' src='../img/32-doc-azul.png' height='60' width='60' alt='Mostrar Canceladas' style='width: 30px !important;height: 30px !important' title='Mostrar Todas las Solicitudes'> |
| 4158 | </a> |
| 4159 | </div> |
| 4160 | </td> |
| 4161 | <td style='border:0px;'> |
| 4162 | <div id='canceladas_sin_revision' style='display:block;'> |
| 4163 | <a href='javascript:void(0);' onclick='mostrarCanceladas()'> |
| 4164 | <img id='fidModImg' src='../img/cancelados.png' height='60' width='60' alt='Mostrar Canceladas' style='width: 30px !important;height: 30px !important' title='Mostrar Solicitudes Caceladas'> |
| 4165 | </a> |
| 4166 | </div> |
| 4167 | </td> |
| 4168 | </tr> |
| 4169 | </table>"; |
| 4170 | break; |
| 4171 | |
| 4172 | case 'ayudantes': |
| 4173 | $pedido_por = param('pedido_por', 'No'); |
| 4174 | $html = |
| 4175 | "<table style='width:100%;'> |
| 4176 | <tr> |
| 4177 | <td style='border:0px;'> |
| 4178 | <div style='display:block;'> |
| 4179 | <a href='../bodega/ayudantes_list.php?pedido_por=$pedido_por'> |
| 4180 | <img src='../img/origen_ayudantes.png' height='60' width='60' alt='POR ORIGEN' style='width: 30px !important;height: 30px !important; margin-top: 5px;' title='Mostrar por Origen'> |
| 4181 | </a> |
| 4182 | </div> |
| 4183 | </td> |
| 4184 | <td style='border:0px;'> |
| 4185 | <div style='display:block;'> |
| 4186 | <a href='../backoffice/ayudantes.php?pedido_por=$pedido_por'> |
| 4187 | <img src='../img/ayudante_origenes.png' height='60' width='80' alt='POR AYUDANTE' style='width: 40px !important;height: 40px !important' title='Mostrar por Ayudante'> |
| 4188 | </a> |
| 4189 | </div> |
| 4190 | </td> |
| 4191 | </tr> |
| 4192 | </table>"; |
| 4193 | break; |
| 4194 | case 'pedido': |
| 4195 | $toolBar = new ToolBar(false); |
| 4196 | $toolBar->setModule('pedido'); |
| 4197 | $toolBar->preparaData(); |
| 4198 | $html_toolbar = array( |
| 4199 | 'element' => 'div_toolbar_pedidos', |
| 4200 | 'view' => (string)$toolBar->render() |
| 4201 | ); |
| 4202 | $html = |
| 4203 | "<div id='div_toolbar_pedidos'>$html_toolbar[view]</div>"; |
| 4204 | break; |
| 4205 | case 'ajuste': |
| 4206 | $toolBar = new ToolBar(false); |
| 4207 | $toolBar->setModule('ajuste'); |
| 4208 | $toolBar->preparaData(); |
| 4209 | $html_toolbar = array( |
| 4210 | 'element' => 'div_toolbar_ajustes', |
| 4211 | 'view' => (string)$toolBar->render() |
| 4212 | ); |
| 4213 | $html = |
| 4214 | "<div id='div_toolbar_ajustes'>$html_toolbar[view]</div>"; |
| 4215 | break; |
| 4216 | } |
| 4217 | |
| 4218 | return $html; |
| 4219 | } |
| 4220 | |
| 4221 | function delivered_pending_cheques($andWhere='',$orderby='',$usr_id=null,$contOnly=false,$brains=false) { |
| 4222 | global $gAppRelate; |
| 4223 | $cuentasT=ia_sqlArray("SELECT cuentaT_id,usuario FROM cuentat",'cuentaT_id'); |
| 4224 | $bancos=ia_sqlArray("SELECT ".SQL_CACHE." banco_id,clave FROM banco",'banco_id'); |
| 4225 | $tienda=ia_sqlArray("SELECT ".SQL_CACHE." tienda_id,clave FROM tienda",'tienda_id'); |
| 4226 | $usuarios=ia_sqlArray("SELECT iac_usr_id,nick FROM iac_usr",'iac_usr_id'); |
| 4227 | $clientes=array(); |
| 4228 | |
| 4229 | if(empty($usr_id)) |
| 4230 | $usr_id=$_SESSION['usuario_id']; |
| 4231 | |
| 4232 | if($brains ) // || $_SESSION['su']; |
| 4233 | $where=''; |
| 4234 | else { |
| 4235 | $fieldInfo=array(); |
| 4236 | |
| 4237 | /** |
| 4238 | $tmp=ia_sqlArray( $gAppRelate->cuentat_options_sql($usr_id),"cuentat_id"); |
| 4239 | $in=''; |
| 4240 | if(!empty($tmp)) foreach($tmp as $k=>$d) |
| 4241 | $in.=",$k"; |
| 4242 | $in=substr($in,1); |
| 4243 | if(empty($in)) |
| 4244 | $where = "AND c.cuentaT_deliveredto_id=-1"; |
| 4245 | else |
| 4246 | $where = "AND c.cuentaT_deliveredto_id IN ($in)"; |
| 4247 | **/ |
| 4248 | $where = "AND ( c.cuentaT_deliveredto_id IN (". cuentasTPuede('','aceptar_delivered_cheques') .") OR c.cuentaT_transferto_id IN (". cuentasTPuede('','aceptar_delivered_cheques') .") )"; |
| 4249 | } |
| 4250 | if($contOnly) |
| 4251 | $fields='COUNT(*) as hay,'; |
| 4252 | else |
| 4253 | $fields="c.cheque_id,c.cliente_id,c.cliente_proveedor_id,c.name_on_check,c.nombre,c.quantity,c.moneda_id,c.banco_id,c.numero,c.cuentaT_deliveredto_id,c.tienda_id |
| 4254 | ,d.delivered_id,usuario_deliveres_id,cuentaT_deliversFrom_id,d.delivered"; |
| 4255 | |
| 4256 | $sql="SELECT $fields |
| 4257 | FROM cheque c LEFT OUTER JOIN delivered d ON c.cheque_id=d.document AND d.document_type='cheque' AND d.delivered_status='Waiting' AND d.cuentaT_to_id=c.cuentaT_deliveredto_id |
| 4258 | WHERE /*c.paid=0 AND*/ c.accepted='Waiting' $where $andWhere $orderby |
| 4259 | "; |
| 4260 | |
| 4261 | //ia_query("INSERT INTO dime (script,dime) VALUES ('123',".strit($sql).")"); |
| 4262 | |
| 4263 | //die($sql); |
| 4264 | if($contOnly) |
| 4265 | return ia_singleread($sql); |
| 4266 | |
| 4267 | $pending=ia_sqlArray($sql,'cheque_id'); |
| 4268 | |
| 4269 | if($pending) { |
| 4270 | foreach($pending as $k=>$d) { |
| 4271 | $arr[$k]['cheque_id']=$k; |
| 4272 | |
| 4273 | /* |
| 4274 | if(array_key_exists($d['cuentaT_deliveredto_id'],$cuentasT)) |
| 4275 | $arr[$k]['cuentaT_deliveredto_id']=$cuentasT[ $d['cuentaT_deliveredto_id']]['usuario']; |
| 4276 | else |
| 4277 | $arr[$k]['cuentaT_deliveredto_id']=$d['cuentaT_deliveredto_id']; |
| 4278 | $arr[$k]['delivered']=$d['delivered']; |
| 4279 | */ |
| 4280 | $nombre=array_key_exists('nombre',$d) ? $d['nombre'] : ''; |
| 4281 | $arr[$k]['cliente']=''; |
| 4282 | $arr[$k]['nombre']=$nombre; |
| 4283 | if(!empty($d['cliente_proveedor_id'])) { |
| 4284 | if(!array_key_exists($d['cliente_proveedor_id'],$clientes)) |
| 4285 | $clientes[$d['cliente_id']]=ia_singleread("SELECT nombre FROM cliente WHERE cliente_id=".strit($d['cliente_proveedor_id'])); |
| 4286 | $arr[$k]['cliente']=$clientes[$d['cliente_proveedor_id']]; |
| 4287 | } |
| 4288 | if(!empty($d['cliente_id'])) { |
| 4289 | if(!array_key_exists($d['cliente_id'],$clientes)) |
| 4290 | $clientes[$d['cliente_id']]=ia_singleread("SELECT nombre FROM cliente WHERE cliente_id=".strit($d['cliente_id'])); |
| 4291 | $arr[$k]['cliente']=$clientes[$d['cliente_id']]; |
| 4292 | } |
| 4293 | if( empty($nombre) ) { |
| 4294 | $d['nombre']=$arr[$k]['cliente']; |
| 4295 | } |
| 4296 | |
| 4297 | if($d['moneda_id']==2) { |
| 4298 | $arr[$k]['quantity_mxp']=0.00; |
| 4299 | $arr[$k]['quantity_usd']=$d['quantity']; |
| 4300 | } else { |
| 4301 | $arr[$k]['quantity_mxp']=$d['quantity']; |
| 4302 | if($d['quantity']==0) |
| 4303 | $arr[$k]['quantity_mxp']=0.00; |
| 4304 | $arr[$k]['quantity_usd']=0.00; |
| 4305 | } |
| 4306 | |
| 4307 | //$arr[$k]['moneda_id'] = "$d[moneda_id]"; |
| 4308 | $arr[$k]['moneda_id'] = $d['moneda_id']==1 ? 'MXP' : 'USD'; |
| 4309 | |
| 4310 | if(array_key_exists($d['banco_id'],$bancos)) |
| 4311 | $arr[$k]['banco_id']=$bancos[ $d['banco_id']]['clave']; |
| 4312 | else |
| 4313 | $arr[$k]['banco_id']=$d['banco_id']; |
| 4314 | |
| 4315 | $arr[$k]['numero']=$d['numero']; |
| 4316 | if(array_key_exists($d['tienda_id'],$tienda)) |
| 4317 | $arr[$k]['tienda_id']=$tienda[ $d['tienda_id']]['clave']; |
| 4318 | else |
| 4319 | $arr[$k]['tienda_id']=$d['tienda_id']; |
| 4320 | |
| 4321 | if(array_key_exists($d['usuario_deliveres_id'],$usuarios)) |
| 4322 | $arr[$k]['usuario_deliveres_id']=$usuarios[ $d['usuario_deliveres_id']]['nick']; |
| 4323 | else |
| 4324 | $arr[$k]['usuario_deliveres_id']=$d['usuario_deliveres_id']; |
| 4325 | |
| 4326 | if(array_key_exists($d['cuentaT_deliversFrom_id'],$cuentasT)) |
| 4327 | $arr[$k]['cuentaT_deliversFrom_id']=$cuentasT[ $d['cuentaT_deliversFrom_id']]['usuario']; |
| 4328 | else |
| 4329 | $arr[$k]['cuentaT_deliversFrom_id']=$d['cuentaT_deliversFrom_id']; |
| 4330 | |
| 4331 | $arr[$k]['delivered']=$d['delivered']; |
| 4332 | |
| 4333 | if(array_key_exists($d['cuentaT_deliveredto_id'],$cuentasT)) |
| 4334 | $arr[$k]['cuentaT_deliveredto_id']=$cuentasT[ $d['cuentaT_deliveredto_id']]['usuario']; |
| 4335 | else |
| 4336 | $arr[$k]['cuentaT_deliveredto_id']=$d['cuentaT_deliveredto_id']; |
| 4337 | |
| 4338 | $arr[$k]['delivered_id']=$d['delivered_id']; |
| 4339 | |
| 4340 | } |
| 4341 | } else { |
| 4342 | $arr = array(); |
| 4343 | } |
| 4344 | return $arr; |
| 4345 | } |
| 4346 | |
| 4347 | function delivered_rechazados($andWhere='',$orderby='',$usr_id=null,$contOnly=false,$brains=false) { |
| 4348 | $cuentasT=ia_sqlArray("SELECT cuentaT_id,usuario FROM cuentat",'cuentaT_id'); |
| 4349 | $usuarios=ia_sqlArray("SELECT iac_usr_id,nick FROM iac_usr",'iac_usr_id'); |
| 4350 | $cheque=new app_cheque(); |
| 4351 | $pagare=new app_pagare(); |
| 4352 | |
| 4353 | $where=''; |
| 4354 | if(empty($usr_id)) { |
| 4355 | $usr_id=$_SESSION['usuario_id']; |
| 4356 | } |
| 4357 | $where=' AND usuario_deliveres_id='.strit($usr_id); |
| 4358 | |
| 4359 | $arr=array(); |
| 4360 | $sql="SELECT /* delivered_rechazados */ delivered_id,document_type,document ,cuentaT_to_id,usuario_accepts_id,accepted, delivered,usuario_deliveres_id,cuentaT_deliversFrom_id FROM delivered WHERE delivered_status='Rejected' AND revisado='Por revisar' $where $andWhere $orderby "; |
| 4361 | //echo "<li>sql in func=$sql</li>"; |
| 4362 | $rechazados=ia_sqlArray($sql,'delivered_id'); |
| 4363 | if($rechazados) foreach($rechazados as $k=>$d) { |
| 4364 | $id=$k; |
| 4365 | $arr[$id]=array('delivered_id'=>$k,'rejected_document'=>'','document_type'=>"<a title='Ir al documento' href='$d[document_type].php?iah=e&id=$d[document]' target='_blank'>$d[document_type]</a>" |
| 4366 | ,'rejected_by'=>$d['usuario_accepts_id'], 'rejected_el'=>$d['accepted'],'cuentat_rejects'=>$d['cuentaT_to_id'] |
| 4367 | ,'delivered_by'=>$d['usuario_deliveres_id'],'cuentat_deliveres'=>$d['cuentaT_deliversFrom_id'],'delivered_el'=>$d['delivered'] |
| 4368 | ,'document'=>$d['document'] |
| 4369 | ); |
| 4370 | if($d['document_type']=='cheque') { |
| 4371 | $cheque->id=$d['document']; |
| 4372 | $cheque->enDB=$cheque->read_sql($d['document'],'r'); |
| 4373 | $arr[$id]['rejected_document']=$cheque->label_record_summary(); |
| 4374 | } else { |
| 4375 | $pagare->id=$d['document']; |
| 4376 | $pagare->enDB=$pagare->read_sql($d['document'],'r'); |
| 4377 | $arr[$id]['rejected_document']=$pagare->label_record_summary(); |
| 4378 | } |
| 4379 | if(array_key_exists($d['usuario_accepts_id'],$usuarios)) |
| 4380 | $arr[$id]['rejected_by']=$usuarios[$d['usuario_accepts_id']]['nick']; |
| 4381 | if(array_key_exists($d['usuario_deliveres_id'],$usuarios)) |
| 4382 | $arr[$id]['delivered_by']=$usuarios[$d['usuario_deliveres_id']]['nick']; |
| 4383 | |
| 4384 | if(array_key_exists($d['cuentaT_to_id'],$cuentasT)) |
| 4385 | $arr[$id]['cuentat_rejects']=$cuentasT[$d['cuentaT_to_id']]['usuario']; |
| 4386 | if(array_key_exists($d['cuentaT_deliversFrom_id'],$cuentasT)) |
| 4387 | $arr[$id]['cuentat_deliveres']=$cuentasT[$d['cuentaT_deliversFrom_id']]['usuario']; |
| 4388 | } |
| 4389 | return $arr; |
| 4390 | } |
| 4391 | |
| 4392 | function obtenSQLlinksdeTodoalBanco($origen = "", $andWhere = "", $chequeWhere = "", $valeWhere = "", $limit = "", |
| 4393 | $orderby= "", $groupby = "", &$tabla_original = "", $ianoLimitinSub='NO') |
| 4394 | { |
| 4395 | $sql = ""; |
| 4396 | |
| 4397 | $subLimit = $ianoLimitinSub == "SI" ? "" : $limit; |
| 4398 | |
| 4399 | switch($origen) |
| 4400 | { |
| 4401 | case 'FACTURA': |
| 4402 | $sql = "( SELECT a.cuentat_a_banco_mov_id AS link_id |
| 4403 | ,a.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4404 | ,a.origen AS origen |
| 4405 | ,a.cuentaT_id AS cuentaT_id |
| 4406 | ,a.tienda_id AS tienda_id |
| 4407 | ,a.fecha AS fecha |
| 4408 | ,a.cliente AS cliente |
| 4409 | ,a.cliente_rfc AS cliente_rfc |
| 4410 | ,a.empresa_id AS empresa_id |
| 4411 | ,a.egreso AS egreso |
| 4412 | ,a.monto AS monto |
| 4413 | ,a.factura AS factura |
| 4414 | ,a.factura_numero AS factura_numero |
| 4415 | ,a.banco_cuenta_id AS banco_cuenta_id |
| 4416 | ,a.deposit_total AS deposit_total |
| 4417 | ,a.deposit_fecha AS deposit_fecha |
| 4418 | ,a.referencia AS referencia |
| 4419 | ,a.MetodoPago AS MetodoPago |
| 4420 | ,a.FormaPago AS FormaPago |
| 4421 | ,a.UsoCFDI AS UsoCFDI |
| 4422 | ,a.iva_incluido AS iva_incluido |
| 4423 | ,a.ivacobradox100 AS ivacobradox100 |
| 4424 | ,if((a.iva_incluido = 'SI'),0.00,a.ivacobradototal) AS ivarealmentecobrado |
| 4425 | ,if((a.iva_incluido = 'NO'),0.00,a.ivacobradototal) AS ivacobradototal |
| 4426 | ,a.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4427 | ,a.remarks AS remarks |
| 4428 | ,a.numero_referencia AS numero_referencia |
| 4429 | ,a.alta_db AS alta_db |
| 4430 | ,a.alta_por AS alta_por |
| 4431 | ,a.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4432 | ,a.quantity_total AS quantity_total |
| 4433 | ,a.ide_amount AS ide_amount |
| 4434 | ,a.ide_percent AS ide_percent |
| 4435 | ,a.tipo_cash_nota AS tipo_cash_nota |
| 4436 | ,a.cash_nota_num AS cash_nota_num |
| 4437 | ,a.puede_borrar AS puede_borrar |
| 4438 | ,a.activo AS activo |
| 4439 | ,a.comments AS comments |
| 4440 | ,a.ultimo_cambio AS ultimo_cambio |
| 4441 | ,a.ultimo_cambio_por AS ultimo_cambio_por |
| 4442 | FROM cuentat_a_banco a $andWhere $orderby $limit ) |
| 4443 | UNION ALL |
| 4444 | ( SELECT b.cheque_pago_id AS link_id |
| 4445 | ,b.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4446 | ,b.origen AS origen |
| 4447 | ,b.cuentaT_id AS cuentaT_id |
| 4448 | ,b.tienda_id AS tienda_id |
| 4449 | ,b.fecha AS fecha |
| 4450 | ,b.cliente AS cliente |
| 4451 | ,b.cliente_rfc AS cliente_rfc |
| 4452 | ,b.empresa_id AS empresa_id |
| 4453 | ,b.quantity_ctat AS egreso |
| 4454 | ,0.00 AS monto |
| 4455 | ,b.factura AS factura |
| 4456 | ,b.factura_numero AS factura_numero |
| 4457 | ,b.banco_cuenta_id AS banco_cuenta_id |
| 4458 | ,b.deposit_total AS deposit_total |
| 4459 | ,b.deposit_fecha AS deposit_fecha |
| 4460 | ,b.referencia AS referencia |
| 4461 | ,b.MetodoPago AS MetodoPago |
| 4462 | ,b.FormaPago AS FormaPago |
| 4463 | ,b.UsoCFDI AS UsoCFDI |
| 4464 | ,b.iva_incluido AS iva_incluido |
| 4465 | ,b.ivacobradox100 AS ivacobradox100 |
| 4466 | ,if((b.iva_incluido = 'SI'),0.00,b.ivacobradototal) AS ivarealmentecobrado |
| 4467 | ,if((b.iva_incluido = 'NO'),0.00,b.ivacobradototal) AS ivacobradototal |
| 4468 | ,b.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4469 | ,b.comentario AS remarks |
| 4470 | ,b.numero_referencia AS numero_referencia |
| 4471 | ,b.alta_db AS alta_db |
| 4472 | ,b.alta_por AS alta_por |
| 4473 | ,b.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4474 | ,b.deposit_total AS quantity_total |
| 4475 | ,b.ide_amount AS ide_amount |
| 4476 | ,b.ide_percent AS ide_percent |
| 4477 | ,b.tipo_cash_nota AS tipo_cash_nota |
| 4478 | ,b.cash_nota_num AS cash_nota_num |
| 4479 | ,b.puede_borrar AS puede_borrar |
| 4480 | ,b.activo AS activo |
| 4481 | ,b.comments AS comments |
| 4482 | ,b.ultimo_cambio AS ultimo_cambio |
| 4483 | ,b.ultimo_cambio_por AS ultimo_cambio_por |
| 4484 | |
| 4485 | FROM cheque_pago b $chequeWhere $orderby $limit ) |
| 4486 | UNION ALL |
| 4487 | ( SELECT c.pagare_pago_id AS link_id |
| 4488 | ,c.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4489 | ,c.origen AS origen |
| 4490 | ,c.cuentaT_id AS cuentaT_id |
| 4491 | ,c.tienda_id AS tienda_id |
| 4492 | ,c.fecha AS fecha |
| 4493 | ,c.cliente AS cliente |
| 4494 | ,c.cliente_rfc AS cliente_rfc |
| 4495 | ,c.empresa_id AS empresa_id |
| 4496 | ,c.quantity_ctat AS egreso |
| 4497 | ,0.00 AS monto |
| 4498 | ,c.factura AS factura |
| 4499 | ,c.factura_numero AS factura_numero |
| 4500 | ,c.banco_cuenta_id AS banco_cuenta_id |
| 4501 | ,c.deposit_total AS deposit_total |
| 4502 | ,c.deposit_fecha AS deposit_fecha |
| 4503 | ,c.referencia AS referencia |
| 4504 | ,c.MetodoPago AS MetodoPago |
| 4505 | ,c.FormaPago AS FormaPago |
| 4506 | ,c.UsoCFDI AS UsoCFDI |
| 4507 | ,c.iva_incluido AS iva_incluido |
| 4508 | ,c.ivacobradox100 AS ivacobradox100 |
| 4509 | ,if((c.iva_incluido = 'SI'),0.00,c.ivacobradototal) AS ivarealmentecobrado |
| 4510 | ,if((c.iva_incluido = 'NO'),0.00,c.ivacobradototal) AS ivacobradototal |
| 4511 | ,c.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4512 | ,c.comentario AS remarks |
| 4513 | ,c.numero_referencia AS numero_referencia |
| 4514 | ,c.alta_db AS alta_db |
| 4515 | ,c.alta_por AS alta_por |
| 4516 | ,c.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4517 | ,c.deposit_total AS quantity_total |
| 4518 | ,c.ide_amount AS ide_amount |
| 4519 | ,c.ide_percent AS ide_percent |
| 4520 | ,c.tipo_cash_nota AS tipo_cash_nota |
| 4521 | ,c.cash_nota_num AS cash_nota_num |
| 4522 | ,c.puede_borrar AS puede_borrar |
| 4523 | ,c.activo AS activo |
| 4524 | ,c.comments AS comments |
| 4525 | ,c.ultimo_cambio AS ultimo_cambio |
| 4526 | ,c.ultimo_cambio_por AS ultimo_cambio_por |
| 4527 | |
| 4528 | FROM pagare_pago c $chequeWhere $orderby $limit ) $orderby $limit"; |
| 4529 | |
| 4530 | // VALE_PAGO_MULTIPLE duda y vale? |
| 4531 | break; |
| 4532 | |
| 4533 | case "LINKS": |
| 4534 | $linksWhere = $andWhere; |
| 4535 | $andWhere = empty($andWhere) ? " WHERE " : $andWhere . " AND "; |
| 4536 | $chequeWhere = empty($chequeWhere) ? " WHERE " : $chequeWhere . " AND "; |
| 4537 | |
| 4538 | $sql = "( SELECT a.cuentat_a_banco_mov_id AS link_id |
| 4539 | ,a.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4540 | ,a.origen AS origen |
| 4541 | ,a.cuentat_a_banco_mov_id AS doc_id |
| 4542 | ,a.cuentaT_id AS cuentaT_id |
| 4543 | ,a.tienda_id AS tienda_id |
| 4544 | ,a.fecha AS fecha |
| 4545 | ,a.banco_cuenta_id AS banco_cuenta_id |
| 4546 | ,a.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4547 | ,a.deposit_total AS deposit_total |
| 4548 | ,a.quantity_total AS quantity_total |
| 4549 | ,a.ide_amount AS ide_amount |
| 4550 | ,a.ide_percent AS ide_percent |
| 4551 | ,a.egreso AS egreso |
| 4552 | ,a.monto AS monto |
| 4553 | ,a.tipo_cash_nota AS tipo_cash_nota |
| 4554 | ,a.cash_nota_num AS cash_nota_num |
| 4555 | ,a.deposit_fecha AS deposit_fecha |
| 4556 | ,a.cliente AS cliente |
| 4557 | ,a.factura AS factura |
| 4558 | ,a.factura_numero AS factura_numero |
| 4559 | ,a.iva_incluido AS iva_incluido |
| 4560 | ,a.ivacobradox100 AS ivacobradox100 |
| 4561 | ,if((a.iva_incluido = 'SI'),0.00,a.ivacobradototal) AS ivarealmentecobrado |
| 4562 | ,if((a.iva_incluido = 'NO'),0.00,a.ivacobradototal) AS ivacobradototal |
| 4563 | ,a.alta_db AS alta_db |
| 4564 | ,a.alta_por AS alta_por |
| 4565 | ,a.numero_referencia AS numero_referencia |
| 4566 | ,a.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4567 | ,a.empresa_id AS empresa_id |
| 4568 | ,a.remarks AS remarks |
| 4569 | ,a.puede_borrar AS puede_borrar |
| 4570 | ,a.activo AS activo |
| 4571 | ,a.afecta_cuentat AS afecta_cuentat |
| 4572 | ,a.comments AS comments |
| 4573 | ,a.autorizado AS autorizado |
| 4574 | ,a.rechazado AS rechazado |
| 4575 | ,a.revisado AS revisado |
| 4576 | ,a.autorizado_el AS autorizado_el |
| 4577 | ,a.autorizado_por AS autorizado_por |
| 4578 | ,a.MetodoPago AS MetodoPago |
| 4579 | ,a.FormaPago AS FormaPago |
| 4580 | ,a.UsoCFDI AS UsoCFDI |
| 4581 | ,a.iva_revisado AS iva_revisado |
| 4582 | ,a.iva_revisado_por AS iva_revisado_por |
| 4583 | ,a.iva_revisado_el AS iva_revisado_el |
| 4584 | ,a.ultimo_cambio AS ultimo_cambio |
| 4585 | ,a.ultimo_cambio_por AS ultimo_cambio_por |
| 4586 | ,a.cliente_rfc AS cliente_rfc |
| 4587 | ,a.referencia AS referencia |
| 4588 | ,a.origen_mov_id AS origen_mov_id |
| 4589 | ,a.factura_directa AS factura_directa |
| 4590 | ,a.moneda_id AS moneda_id |
| 4591 | FROM cuentat_a_banco a $andWhere (a.banco_cuenta_id > 0 AND a.banco_cuenta_mov_link_id <> '' ) $orderby $subLimit ) |
| 4592 | UNION ALL |
| 4593 | ( SELECT b.cheque_pago_id AS link_id |
| 4594 | ,b.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4595 | ,b.origen AS origen |
| 4596 | ,b.cheque_id AS doc_id |
| 4597 | ,b.cuentaT_id AS cuentaT_id |
| 4598 | ,b.tienda_id AS tienda_id |
| 4599 | ,b.fecha AS fecha |
| 4600 | ,b.banco_cuenta_id AS banco_cuenta_id |
| 4601 | ,b.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4602 | ,b.deposit_total AS deposit_total |
| 4603 | ,b.quantity_total AS quantity_total |
| 4604 | ,b.ide_amount AS ide_amount |
| 4605 | ,b.ide_percent AS ide_percent |
| 4606 | ,b.quantity_ctat AS egreso |
| 4607 | ,0.00 AS monto |
| 4608 | ,b.tipo_cash_nota AS tipo_cash_nota |
| 4609 | ,b.cash_nota_num AS cash_nota_num |
| 4610 | ,b.deposit_fecha AS deposit_fecha |
| 4611 | ,b.cliente AS cliente |
| 4612 | ,b.factura AS factura |
| 4613 | ,b.factura_numero AS factura_numero |
| 4614 | ,b.iva_incluido AS iva_incluido |
| 4615 | ,b.ivacobradox100 AS ivacobradox100 |
| 4616 | ,if((b.iva_incluido = 'SI'),0.00,b.ivacobradototal) AS ivarealmentecobrado |
| 4617 | ,if((b.iva_incluido = 'NO'),0.00,b.ivacobradototal) AS ivacobradototal |
| 4618 | ,b.alta_db AS alta_db |
| 4619 | ,b.alta_por AS alta_por |
| 4620 | ,b.numero_referencia AS numero_referencia |
| 4621 | ,b.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4622 | ,b.empresa_id AS empresa_id |
| 4623 | ,b.comentario AS remarks |
| 4624 | ,b.puede_borrar AS puede_borrar |
| 4625 | ,b.activo AS activo |
| 4626 | ,afecta_cuentat AS afecta_cuentat |
| 4627 | ,b.comments AS comments |
| 4628 | ,b.autorizado AS autorizado |
| 4629 | ,b.rechazado AS rechazado |
| 4630 | ,b.revisado AS revisado |
| 4631 | ,b.autorizado_el AS autorizado_el |
| 4632 | ,b.autorizado_por AS autorizado_por |
| 4633 | ,b.MetodoPago AS MetodoPago |
| 4634 | ,b.FormaPago AS FormaPago |
| 4635 | ,b.UsoCFDI AS UsoCFDI |
| 4636 | ,b.iva_revisado AS iva_revisado |
| 4637 | ,b.iva_revisado_por AS iva_revisado_por |
| 4638 | ,b.iva_revisado_el AS iva_revisado_el |
| 4639 | ,b.ultimo_cambio AS ultimo_cambio |
| 4640 | ,b.ultimo_cambio_por AS ultimo_cambio_por |
| 4641 | ,b.cliente_rfc AS cliente_rfc |
| 4642 | ,b.referencia AS referencia |
| 4643 | ,b.cuenta_t_mov_id AS origen_mov_id |
| 4644 | ,'NO' AS factura_directa |
| 4645 | ,b.moneda_id AS moneda_id |
| 4646 | FROM cheque_pago b $chequeWhere (b.banco_cuenta_id > 0 AND b.banco_cuenta_mov_link_id <> '') $orderby $subLimit ) |
| 4647 | UNION ALL |
| 4648 | ( SELECT c.pagare_pago_id AS link_id |
| 4649 | ,c.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4650 | ,c.origen AS origen |
| 4651 | ,c.pagare_id AS doc_id |
| 4652 | ,c.cuentaT_id AS cuentaT_id |
| 4653 | ,c.tienda_id AS tienda_id |
| 4654 | ,c.fecha AS fecha |
| 4655 | ,c.banco_cuenta_id AS banco_cuenta_id |
| 4656 | ,c.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4657 | ,c.deposit_total AS deposit_total |
| 4658 | ,c.quantity_total AS quantity_total |
| 4659 | ,c.ide_amount AS ide_amount |
| 4660 | ,c.ide_percent AS ide_percent |
| 4661 | ,c.quantity_ctat AS egreso |
| 4662 | ,0.00 AS monto |
| 4663 | ,c.tipo_cash_nota AS tipo_cash_nota |
| 4664 | ,c.cash_nota_num AS cash_nota_num |
| 4665 | ,c.deposit_fecha AS deposit_fecha |
| 4666 | ,c.cliente AS cliente |
| 4667 | ,c.factura AS factura |
| 4668 | ,c.factura_numero AS factura_numero |
| 4669 | ,c.iva_incluido AS iva_incluido |
| 4670 | ,c.ivacobradox100 AS ivacobradox100 |
| 4671 | ,if((c.iva_incluido = 'SI'),0.00,c.ivacobradototal) AS ivarealmentecobrado |
| 4672 | ,if((c.iva_incluido = 'NO'),0.00,c.ivacobradototal) AS ivacobradototal |
| 4673 | ,c.alta_db AS alta_db |
| 4674 | ,c.alta_por AS alta_por |
| 4675 | ,c.numero_referencia AS numero_referencia |
| 4676 | ,c.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4677 | ,c.empresa_id AS empresa_id |
| 4678 | ,c.comentario AS remarks |
| 4679 | ,c.puede_borrar AS puede_borrar |
| 4680 | ,c.activo AS activo |
| 4681 | ,afecta_cuentat AS afecta_cuentat |
| 4682 | ,c.comments AS comments |
| 4683 | ,c.autorizado AS autorizado |
| 4684 | ,c.rechazado AS rechazado |
| 4685 | ,c.revisado AS revisado |
| 4686 | ,c.autorizado_el AS autorizado_el |
| 4687 | ,c.autorizado_por AS autorizado_por |
| 4688 | ,c.MetodoPago AS MetodoPago |
| 4689 | ,c.FormaPago AS FormaPago |
| 4690 | ,c.UsoCFDI AS UsoCFDI |
| 4691 | ,c.iva_revisado AS iva_revisado |
| 4692 | ,c.iva_revisado_por AS iva_revisado_por |
| 4693 | ,c.iva_revisado_el AS iva_revisado_el |
| 4694 | ,c.ultimo_cambio AS ultimo_cambio |
| 4695 | ,c.ultimo_cambio_por AS ultimo_cambio_por |
| 4696 | ,c.cliente_rfc AS cliente_rfc |
| 4697 | ,c.referencia AS referencia |
| 4698 | ,c.cuenta_t_mov_id AS origen_mov_id |
| 4699 | ,'NO' AS factura_directa |
| 4700 | ,c.moneda_id AS moneda_id |
| 4701 | from pagare_pago c $chequeWhere (c.banco_cuenta_id > 0 and c.banco_cuenta_mov_link_id <> '') $orderby $subLimit ) |
| 4702 | UNION ALL |
| 4703 | ".linksdeTodoalBancoLinksVale($chequeWhere,$valeWhere,$orderby,$subLimit)." |
| 4704 | UNION ALL |
| 4705 | ( SELECT e.cuentat_a_banco_tc_mov_id AS link_id |
| 4706 | ,e.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4707 | ,e.origen AS origen |
| 4708 | ,e.cuentat_a_banco_tc_mov_id AS doc_id |
| 4709 | ,e.cuentaT_id AS cuentaT_id |
| 4710 | ,e.tienda_id AS tienda_id |
| 4711 | ,e.fecha AS fecha |
| 4712 | ,e.banco_cuenta_id AS banco_cuenta_id |
| 4713 | ,e.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4714 | ,e.deposit_total AS deposit_total |
| 4715 | ,e.quantity_total AS quantity_total |
| 4716 | ,e.ide_amount AS ide_amount |
| 4717 | ,e.ide_percent AS ide_percent |
| 4718 | ,e.egreso AS egreso |
| 4719 | ,e.monto AS monto |
| 4720 | ,e.tipo_cash_nota AS tipo_cash_nota |
| 4721 | ,e.cash_nota_num AS cash_nota_num |
| 4722 | ,e.deposit_fecha AS deposit_fecha |
| 4723 | ,e.cliente AS cliente |
| 4724 | ,e.factura AS factura |
| 4725 | ,e.factura_numero AS factura_numero |
| 4726 | ,e.iva_incluido AS iva_incluido |
| 4727 | ,e.ivacobradox100 AS ivacobradox100 |
| 4728 | ,if((e.iva_incluido = 'SI'),0.00,e.ivacobradototal) AS ivarealmentecobrado |
| 4729 | ,if((e.iva_incluido = 'NO'),0.00,e.ivacobradototal) AS ivacobradototal |
| 4730 | ,e.alta_db AS alta_db |
| 4731 | ,e.alta_por AS alta_por |
| 4732 | ,e.numero_referencia AS numero_referencia |
| 4733 | ,e.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4734 | ,e.empresa_id AS empresa_id |
| 4735 | ,e.remarks AS remarks |
| 4736 | ,e.puede_borrar AS puede_borrar |
| 4737 | ,e.activo AS activo |
| 4738 | ,e.afecta_cuentat AS afecta_cuentat |
| 4739 | ,e.comments AS comments |
| 4740 | ,e.autorizado AS autorizado |
| 4741 | ,e.rechazado AS rechazado |
| 4742 | ,e.revisado AS revisado |
| 4743 | ,e.autorizado_el AS autorizado_el |
| 4744 | ,e.autorizado_por AS autorizado_por |
| 4745 | ,e.MetodoPago AS MetodoPago |
| 4746 | ,e.FormaPago AS FormaPago |
| 4747 | ,e.UsoCFDI AS UsoCFDI |
| 4748 | ,e.iva_revisado AS iva_revisado |
| 4749 | ,e.iva_revisado_por AS iva_revisado_por |
| 4750 | ,e.iva_revisado_el AS iva_revisado_el |
| 4751 | ,e.ultimo_cambio AS ultimo_cambio |
| 4752 | ,e.ultimo_cambio_por AS ultimo_cambio_por |
| 4753 | ,e.cliente_rfc AS cliente_rfc |
| 4754 | ,e.referencia AS referencia |
| 4755 | ,e.origen_mov_id AS origen_mov_id |
| 4756 | ,e.factura_directa AS factura_directa |
| 4757 | ,e.moneda_id AS moneda_id |
| 4758 | FROM cuentat_a_banco_tc e $linksWhere $orderby $subLimit ) |
| 4759 | UNION ALL |
| 4760 | ( SELECT f.banco_cuenta_trans_id AS link_id |
| 4761 | ,f.banco_cuenta_mov_link_id AS banco_cuenta_mov_link_id |
| 4762 | ,f.origen AS origen |
| 4763 | ,f.banco_cuenta_trans_id AS doc_id |
| 4764 | ,f.cuentaT_id AS cuentaT_id |
| 4765 | ,f.tienda_id AS tienda_id |
| 4766 | ,f.fecha AS fecha |
| 4767 | ,f.banco_cuenta_id AS banco_cuenta_id |
| 4768 | ,f.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4769 | ,f.deposit_total AS deposit_total |
| 4770 | ,f.quantity_total AS quantity_total |
| 4771 | ,f.ide_amount AS ide_amount |
| 4772 | ,f.ide_percent AS ide_percent |
| 4773 | ,f.egreso AS egreso |
| 4774 | ,f.monto AS monto |
| 4775 | ,f.tipo_cash_nota AS tipo_cash_nota |
| 4776 | ,f.cash_nota_num AS cash_nota_num |
| 4777 | ,f.deposit_fecha AS deposit_fecha |
| 4778 | ,f.cliente AS cliente |
| 4779 | ,f.factura AS factura |
| 4780 | ,f.factura_numero AS factura_numero |
| 4781 | ,f.iva_incluido AS iva_incluido |
| 4782 | ,f.ivacobradox100 AS ivacobradox100 |
| 4783 | ,if((f.iva_incluido = 'SI'),0.00,f.ivacobradototal) AS ivarealmentecobrado |
| 4784 | ,if((f.iva_incluido = 'NO'),0.00,f.ivacobradototal) AS ivacobradototal |
| 4785 | ,f.alta_db AS alta_db |
| 4786 | ,f.alta_por AS alta_por |
| 4787 | ,f.numero_referencia AS numero_referencia |
| 4788 | ,f.cash_num_cobro_iva AS cash_num_cobro_iva |
| 4789 | ,f.empresa_id AS empresa_id |
| 4790 | ,f.remarks AS remarks |
| 4791 | ,f.puede_borrar AS puede_borrar |
| 4792 | ,f.activo AS activo |
| 4793 | ,f.afecta_cuentat AS afecta_cuentat |
| 4794 | ,f.comments AS comments |
| 4795 | ,f.autorizado AS autorizado |
| 4796 | ,f.rechazado AS rechazado |
| 4797 | ,f.revisado AS revisado |
| 4798 | ,f.autorizado_el AS autorizado_el |
| 4799 | ,f.autorizado_por AS autorizado_por |
| 4800 | ,f.MetodoPago AS MetodoPago |
| 4801 | ,f.FormaPago AS FormaPago |
| 4802 | ,f.UsoCFDI AS UsoCFDI |
| 4803 | ,f.iva_revisado AS iva_revisado |
| 4804 | ,f.iva_revisado_por AS iva_revisado_por |
| 4805 | ,f.iva_revisado_el AS iva_revisado_el |
| 4806 | ,f.ultimo_cambio AS ultimo_cambio |
| 4807 | ,f.ultimo_cambio_por AS ultimo_cambio_por |
| 4808 | ,f.cliente_rfc AS cliente_rfc |
| 4809 | ,f.referencia AS referencia |
| 4810 | ,f.origen_mov_id AS origen_mov_id |
| 4811 | ,f.factura_directa AS factura_directa |
| 4812 | ,f.moneda_id AS moneda_id |
| 4813 | from banco_cuenta_trans f $linksWhere $orderby $subLimit ) $orderby $limit "; |
| 4814 | |
| 4815 | $tabla_original = "links_al_banco_schema"; |
| 4816 | break; |
| 4817 | |
| 4818 | case "CANCELADOS": |
| 4819 | $sql = " |
| 4820 | ( SELECT a.cuentat_a_banco_mov_id AS link_id |
| 4821 | ,'' AS banco_cuenta_mov_link_id |
| 4822 | ,a.origen AS origen |
| 4823 | ,a.cuentat_a_banco_mov_id AS doc_id |
| 4824 | ,a.cuentaT_id AS cuentaT_id |
| 4825 | ,a.tienda_id AS tienda_id |
| 4826 | ,a.alta_por AS alta_por |
| 4827 | ,a.alta_db AS alta_db |
| 4828 | ,a.fecha AS fecha |
| 4829 | ,a.egreso AS egreso |
| 4830 | ,a.monto AS monto |
| 4831 | ,a.remarks AS remarks |
| 4832 | ,a.banco_cuenta_id AS banco_cuenta_id |
| 4833 | ,a.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4834 | ,a.numero_referencia AS numero_referencia |
| 4835 | ,a.quantity_total AS quantity_total |
| 4836 | ,a.ide_amount AS ide_amount |
| 4837 | ,a.ide_percent AS ide_percent |
| 4838 | ,a.deposit_fecha AS deposit_fecha |
| 4839 | ,a.activo AS activo |
| 4840 | from cuentat_a_banco a $andWhere $orderby $limit ) |
| 4841 | UNION ALL |
| 4842 | ( SELECT b.cheque_pago_log_id AS link_id |
| 4843 | ,'' AS banco_cuenta_mov_link_id |
| 4844 | ,b.origen AS origen |
| 4845 | ,b.cheque_id AS doc_id |
| 4846 | ,b.cuentaT_id AS cuentaT_id |
| 4847 | ,b.tienda_id AS tienda_id |
| 4848 | ,b.alta_por AS alta_por |
| 4849 | ,b.alta_db AS alta_db |
| 4850 | ,b.fecha AS fecha |
| 4851 | ,b.quantity_total AS egreso |
| 4852 | ,0.00 AS monto |
| 4853 | ,b.comentario AS remarks |
| 4854 | ,b.banco_cuenta_id AS banco_cuenta_id |
| 4855 | ,b.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4856 | ,b.numero_referencia AS numero_referencia |
| 4857 | ,b.quantity_total AS quantity_total |
| 4858 | ,b.ide_amount AS ide_amount |
| 4859 | ,b.ide_percent AS ide_percent |
| 4860 | ,b.deposit_fecha AS deposit_fecha |
| 4861 | ,b.activo AS activo |
| 4862 | from cheque_pago_log b $chequeWhere AND b.banco_cuenta_id > 0 $orderby $limit ) |
| 4863 | UNION ALL |
| 4864 | ( SELECT c.pagare_pago_log_id AS link_id |
| 4865 | ,'' AS banco_cuenta_mov_link_id |
| 4866 | ,c.origen AS origen |
| 4867 | ,c.pagare_id AS doc_id |
| 4868 | ,c.cuentaT_id AS cuentaT_id |
| 4869 | ,c.tienda_id AS tienda_id |
| 4870 | ,c.alta_por AS alta_por |
| 4871 | ,c.alta_db AS alta_db |
| 4872 | ,c.fecha AS fecha |
| 4873 | ,c.quantity_total AS egreso |
| 4874 | ,0.00 AS monto |
| 4875 | ,c.comentario AS remarks |
| 4876 | ,c.banco_cuenta_id AS banco_cuenta_id |
| 4877 | ,c.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4878 | ,c.numero_referencia AS numero_referencia |
| 4879 | ,c.quantity_total AS quantity_total |
| 4880 | ,c.ide_amount AS ide_amount |
| 4881 | ,c.ide_percent AS ide_percent |
| 4882 | ,c.deposit_fecha AS deposit_fecha |
| 4883 | ,c.activo AS activo |
| 4884 | from pagare_pago_log c $chequeWhere AND c.banco_cuenta_id > 0 $orderby $limit ) |
| 4885 | UNION ALL |
| 4886 | ( SELECT d.vale_id AS link_id |
| 4887 | ,'' AS banco_cuenta_mov_link_id |
| 4888 | ,d.origen |
| 4889 | ,d.vale_id AS doc_id |
| 4890 | ,d.cuentaT_id |
| 4891 | ,d.tienda_id |
| 4892 | ,d.alta_por |
| 4893 | ,d.alta_db |
| 4894 | ,d.fecha |
| 4895 | ,d.quantity_total AS egreso |
| 4896 | ,0.00 AS monto |
| 4897 | ,d.remarks |
| 4898 | ,d.banco_cuenta_id |
| 4899 | ,d.metodo_pago_id AS cuentaT_tipo_mov_id |
| 4900 | ,d.numero_referencia AS numero_referencia |
| 4901 | ,d.quantity_total AS quantity_total |
| 4902 | ,d.ide_amount |
| 4903 | ,d.ide_percent |
| 4904 | ,d.deposit_fecha |
| 4905 | ,if((d.cancelado = 1),'No','Si') AS activo |
| 4906 | from vale d $valeWhere AND (d.cancelado=1 && d.banco_cuenta_id > 0) $orderby $limit ) |
| 4907 | UNION ALL |
| 4908 | ( SELECT e.cuentat_a_banco_tc_mov_id AS link_id |
| 4909 | ,'' AS banco_cuenta_mov_link_id |
| 4910 | ,e.origen AS origen |
| 4911 | ,e.cuentat_a_banco_tc_mov_id AS doc_id |
| 4912 | ,e.cuentaT_id AS cuentaT_id |
| 4913 | ,e.tienda_id AS tienda_id |
| 4914 | ,e.alta_por AS alta_por |
| 4915 | ,e.alta_db AS alta_db |
| 4916 | ,e.fecha AS fecha |
| 4917 | ,e.egreso AS egreso |
| 4918 | ,e.monto AS monto |
| 4919 | ,e.remarks AS remarks |
| 4920 | ,e.banco_cuenta_id AS banco_cuenta_id |
| 4921 | ,e.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4922 | ,e.numero_referencia AS numero_referencia |
| 4923 | ,e.quantity_total AS quantity_total |
| 4924 | ,e.ide_amount AS ide_amount |
| 4925 | ,e.ide_percent AS ide_percent |
| 4926 | ,e.deposit_fecha AS deposit_fecha |
| 4927 | ,e.activo AS activo |
| 4928 | from cuentat_a_banco_tc e $andWhere $orderby $limit ) |
| 4929 | UNION ALL |
| 4930 | ( SELECT f.banco_cuenta_trans_id AS link_id |
| 4931 | ,'' AS banco_cuenta_mov_link_id |
| 4932 | ,f.origen AS origen |
| 4933 | ,f.banco_cuenta_trans_id AS doc_id |
| 4934 | ,f.cuentaT_id AS cuentaT_id |
| 4935 | ,f.tienda_id AS tienda_id |
| 4936 | ,f.alta_por AS alta_por |
| 4937 | ,f.alta_db AS alta_db |
| 4938 | ,f.fecha AS fecha |
| 4939 | ,f.egreso AS egreso |
| 4940 | ,f.monto AS monto |
| 4941 | ,f.remarks AS remarks |
| 4942 | ,f.banco_cuenta_id AS banco_cuenta_id |
| 4943 | ,f.cuentaT_tipo_mov_id AS cuentaT_tipo_mov_id |
| 4944 | ,f.numero_referencia AS numero_referencia |
| 4945 | ,f.quantity_total AS quantity_total |
| 4946 | ,f.ide_amount AS ide_amount |
| 4947 | ,f.ide_percent AS ide_percent |
| 4948 | ,f.deposit_fecha AS deposit_fecha |
| 4949 | ,f.activo AS activo |
| 4950 | from banco_cuenta_trans f $andWhere $orderby $limit ) $orderby $limit "; |
| 4951 | break; |
| 4952 | } |
| 4953 | |
| 4954 | return $sql; |
| 4955 | } |
| 4956 | |
| 4957 | function obten_tc_live() |
| 4958 | { |
| 4959 | global $gIAParametros; |
| 4960 | |
| 4961 | $tc = array(); |
| 4962 | $live = 'Error'; |
| 4963 | |
| 4964 | $tcUltimaActualizacion = ia_singleread("SELECT MAX(alta_db) FROM tc_log"); |
| 4965 | if(diferenciadeTiempo($tcUltimaActualizacion,'','minutos') > $gIAParametros['tiempo_para_actualizar_tc_desde_xecom']*60) |
| 4966 | { |
| 4967 | if(!extraeTCdeXE(false)) { |
| 4968 | $live = 'Error'; |
| 4969 | } |
| 4970 | else{ |
| 4971 | $live = 'OK'; |
| 4972 | } |
| 4973 | |
| 4974 | } |
| 4975 | else |
| 4976 | $live = 'OK'; |
| 4977 | |
| 4978 | $tc = json_decode(obtenCatalogo('tc')); |
| 4979 | $tc->tc = echonf($tc->tc, true, 4, ""); |
| 4980 | $tc->alta_db = mysqlTimestamp2display($tc->alta_db); |
| 4981 | $tc->live = $live; |
| 4982 | |
| 4983 | return $tc; |
| 4984 | } |
| 4985 | |
| 4986 | function inicializa_catalogos_globales(){ |
| 4987 | |
| 4988 | global $gIAParametros; |
| 4989 | |
| 4990 | $g_cat_producto_general = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('producto_general'))); |
| 4991 | $g_cat_origen_bodega = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('origen_bodega'))); |
| 4992 | $g_cat_grupo = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('grupo'))); |
| 4993 | $g_cat_bodega = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('bodega'))); |
| 4994 | $g_cat_bodega2grupo = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('bodega2grupo'))); |
| 4995 | $g_cat_tienda = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('tienda'))); |
| 4996 | $g_cat_color_alfabetico = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('color_alfabetico'))); |
| 4997 | $g_cat_color_alfabetico_desc = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('color_alfabetico_desc'))); |
| 4998 | $g_cat_color = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('color'))); |
| 4999 | $g_cat_bodegas_y_grupos = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('bodegas_y_grupos'))); |
| 5000 | $g_cat_empresa = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('empresa'))); |
| 5001 | |
| 5002 | $g_cat_ayudantes = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('bodega_ayudantes'))); |
| 5003 | $g_cat_ayudantes_donde = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('bodega_ayudantes_donde'))); |
| 5004 | $g_cat_encargados = trim(preg_replace('/[\t\n\r\s]+/', ' ', obtenCatalogo('bodega_encargados'))); |
| 5005 | |
| 5006 | $es_Rony = $_SESSION['usuario_id'] == '1' || $_SESSION['usuario_id'] == 1; |
| 5007 | $es_usuario_tipoRony = usuarioTipoRony(); |
| 5008 | $es_Rony_js = $es_Rony ? 'true': 'false'; |
| 5009 | $es_usuario_tipoRony_js = $es_usuario_tipoRony ? 'true': 'false'; |
| 5010 | |
| 5011 | $tiendas_bodegas_para_usuario = obtenCatalogo('bodegas_tiendas_por_usuario', extraId: $_SESSION['usuario_id']); |
| 5012 | $g_cat_bodega_usuario_session = $tiendas_bodegas_para_usuario['bodegas']; |
| 5013 | $g_cat_tienda_usuario_session = $tiendas_bodegas_para_usuario['tiendas']; |
| 5014 | $tiendas_bodegas_para_usuario = json_encode(['tiendas' => json_decode($g_cat_tienda_usuario_session, true), 'bodegas' => json_decode($g_cat_bodega_usuario_session, true)]); |
| 5015 | |
| 5016 | $puede_consultar_todas_las_bodegas = puedePermisoUsuario(nombrePermiso: "puede_solo_consultar_bodegas")? 'true' : 'false'; |
| 5017 | $puede_ver_salidas_a_todas_las_tiendas = puedePermisoUsuario(nombrePermiso: "puede_ver_traslados")? 'true' : 'false'; |
| 5018 | |
| 5019 | // Notificacion CartaPorte |
| 5020 | $usuarios_para_notificap_cp = ia_sqlVector("SELECT iac_usr_id FROM iac_usr WHERE notificar_nuevas_cartas_porte = 'Si'"); |
| 5021 | $notificar_cp = in_array($_SESSION['usuario_id'], $usuarios_para_notificap_cp); |
| 5022 | if ($_SESSION['usuario_id']===1 || $_SESSION['usuario_id']==='1') |
| 5023 | $notificar_cp = false; |
| 5024 | |
| 5025 | $notificar_cp_js = json_encode($notificar_cp); |
| 5026 | |
| 5027 | $g_usuarios_pueden_pedir = ia_sqlVector("SELECT /*usuarios_pueden_pedir*/ iac_usr_id FROM permiso_usuario WHERE permiso_nombre = 'puede_reporte_ventas' AND puede= 'Pedir'"); |
| 5028 | $g_usuarios_pueden_pedir_js = json_encode($g_usuarios_pueden_pedir); |
| 5029 | $g_usuario_puede_pedir = usuarioTipoRony()?true: in_array($_SESSION['usuario_id'], $g_usuarios_pueden_pedir); |
| 5030 | $g_usuario_puede_pedir_js = var_export($g_usuario_puede_pedir, true); |
| 5031 | |
| 5032 | global $toolBarColor; |
| 5033 | $tool_bar_color = jsit($toolBarColor); |
| 5034 | static $outPutAgain = true; |
| 5035 | $tmpTipoRony = usuarioTipoRony() ? 'true' : 'false'; |
| 5036 | $puede_consultar_permisos = usuarioTipoRony() || Permisador::puede_consultar_permisos() !== 'Nada' ? 'true' : 'false'; |
| 5037 | $puede_prohibir_colores= usuarioTipoRony() || Permisador::puede('puede_prohibir_colores', 'No', $user_id ?? $_SESSION['usuario_id'])!=='No' ? 'true' : 'false'; |
| 5038 | |
| 5039 | $tipo_cambio = $gIAParametros['tc']; |
| 5040 | |
| 5041 | |
| 5042 | if($outPutAgain) |
| 5043 | echo <<<CATALOGOS_GLOBALES |
| 5044 | <script> |
| 5045 | /**CATALOGOS GLOBALES*/ |
| 5046 | \$vitex_globales['consultar_permisos'] = $puede_consultar_permisos, |
| 5047 | \$vitex_globales['puede_prohibir_colores'] = $puede_prohibir_colores, |
| 5048 | \$vitex_globales['toolBarColor'] = $tool_bar_color, |
| 5049 | \$vitex_globales['g_cat_producto_general'] = $g_cat_producto_general, |
| 5050 | \$vitex_globales['g_cat_origen_bodega'] = $g_cat_origen_bodega, |
| 5051 | \$vitex_globales['g_cat_grupo'] = $g_cat_grupo, |
| 5052 | \$vitex_globales['g_cat_bodega'] = $g_cat_bodega, |
| 5053 | \$vitex_globales['g_cat_bodega2grupo'] = $g_cat_bodega2grupo, |
| 5054 | \$vitex_globales['g_cat_tienda'] = $g_cat_tienda, |
| 5055 | \$vitex_globales['g_cat_bodegas_y_grupos'] = $g_cat_bodegas_y_grupos, |
| 5056 | \$vitex_globales['g_cat_color'] = $g_cat_color, |
| 5057 | \$vitex_globales['g_cat_color_alfabetico_desc'] = $g_cat_color_alfabetico_desc, |
| 5058 | \$vitex_globales['g_cat_color_alfabetico'] = $g_cat_color_alfabetico; |
| 5059 | \$vitex_globales['g_cat_empresa'] = $g_cat_empresa; |
| 5060 | \$vitex_globales['g_cat_tiendas_bodegas_para_usuario'] = $tiendas_bodegas_para_usuario; |
| 5061 | \$vitex_globales['g_cat_bodega_para_usuario'] = $g_cat_bodega_usuario_session; |
| 5062 | \$vitex_globales['g_cat_tienda_para_usuario'] = $g_cat_tienda_usuario_session; |
| 5063 | \$vitex_globales['g_cat_ayudantes'] = $g_cat_ayudantes; |
| 5064 | \$vitex_globales['g_cat_ayudantes_donde'] = $g_cat_ayudantes_donde; |
| 5065 | \$vitex_globales['g_cat_encargados'] = $g_cat_encargados; |
| 5066 | \$vitex_globales['g_usuarios_pueden_pedir'] = $g_usuarios_pueden_pedir_js; |
| 5067 | |
| 5068 | /**PERMISOS GLOBALES*/ |
| 5069 | \$vitex_globales['puede_consultar_todas_las_bodegas'] = $puede_consultar_todas_las_bodegas; |
| 5070 | \$vitex_globales['puede_ver_salidas_a_todas_las_tiendas'] = $puede_ver_salidas_a_todas_las_tiendas; |
| 5071 | |
| 5072 | /**VARS GLOBALES*/ |
| 5073 | \$vitex_globales['es_Rony'] = $es_Rony_js; |
| 5074 | \$vitex_globales['es_usuario_tipoRony'] = $es_usuario_tipoRony_js; |
| 5075 | \$vitex_globales['g_usuario_puede_pedir'] = $g_usuario_puede_pedir_js; |
| 5076 | \$vitex_globales['tipo_rony'] = $tmpTipoRony; |
| 5077 | \$vitex_globales['nick'] = '$_SESSION[usuario]'; |
| 5078 | \$vitex_globales['iac_usr_id'] = '$_SESSION[usuario_id]'; |
| 5079 | \$vitex_globales['iac_parametros'] = {}; |
| 5080 | \$vitex_globales['dialog_banco_cuenta_opener'] = {}; |
| 5081 | \$vitex_globales['dialog_banco_cuenta_opener'].segundos_abierto_dialog_banco_cuenta_opener_ori = 15; |
| 5082 | |
| 5083 | |
| 5084 | const es_Rony = $es_Rony_js, |
| 5085 | es_usuario_tipoRony = $es_usuario_tipoRony_js, |
| 5086 | puede_consultar_todas_las_bodegas = $puede_consultar_todas_las_bodegas, |
| 5087 | puede_ver_salidas_a_todas_las_tiendas = $puede_ver_salidas_a_todas_las_tiendas, |
| 5088 | g_usuario_puede_pedir = $g_usuario_puede_pedir_js |
| 5089 | ; |
| 5090 | |
| 5091 | /**Permisos Notificaciones*/ |
| 5092 | notificar_carta_porte = $notificar_cp_js; |
| 5093 | |
| 5094 | </script> |
| 5095 | CATALOGOS_GLOBALES; |
| 5096 | $outPutAgain = false; |
| 5097 | ob_flush(); |
| 5098 | flush(); |
| 5099 | } |
| 5100 | |
| 5101 | function estado_cuenta_cliente($cliente_id, $iacc = 'ia_case'): string |
| 5102 | { |
| 5103 | |
| 5104 | global $gIAParametros; |
| 5105 | |
| 5106 | $tolerancia_pesos = $gIAParametros['tolerancia_pago_documentos_pesos']; |
| 5107 | $tolerancia_usd = $gIAParametros['tolerancia_pago_documentos_usd']; |
| 5108 | |
| 5109 | $sql_nombre_cliente = "SELECT nombre FROM cliente WHERE cliente_id = " . strit($cliente_id); |
| 5110 | |
| 5111 | $sql_saldo_cheques_pesos = "SELECT |
| 5112 | SUM(CASE WHEN paid = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_pesos, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_cheques_pesos |
| 5113 | FROM cheque WHERE tipo NOT IN ('NOTA', 'GASTO') AND moneda_id = 1 AND cliente_id = " . strit($cliente_id); |
| 5114 | |
| 5115 | $sql_saldo_notas_pesos = "SELECT |
| 5116 | SUM(CASE WHEN paid = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_pesos, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_notas_pesos |
| 5117 | FROM cheque WHERE tipo IN ('NOTA', 'GASTO') AND moneda_id = 1 AND cliente_id = " . strit($cliente_id); |
| 5118 | |
| 5119 | $sql_saldo_cheques_usd = "SELECT |
| 5120 | SUM(CASE WHEN paid = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_usd, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_cheques_usd |
| 5121 | FROM cheque WHERE tipo NOT IN ('NOTA', 'GASTO') AND moneda_id = 2 AND cliente_id = " . strit($cliente_id); |
| 5122 | |
| 5123 | $sql_saldo_notas_usd = "SELECT |
| 5124 | SUM(CASE WHEN paid = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_usd, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_cheques_usd |
| 5125 | FROM cheque WHERE tipo IN ('NOTA', 'GASTO') AND moneda_id = 2 AND cliente_id = " . strit($cliente_id); |
| 5126 | |
| 5127 | $sql_saldo_pagares_pesos = "SELECT |
| 5128 | SUM(CASE WHEN paid = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_pesos, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_pagares_pesos |
| 5129 | FROM pagare WHERE moneda_id = 1 AND cliente_id = " . strit($cliente_id); |
| 5130 | |
| 5131 | $sql_saldo_pagares_usd = "SELECT |
| 5132 | SUM(CASE WHEN paid = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_usd, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_pagares_usd |
| 5133 | FROM pagare WHERE moneda_id = 2 AND cliente_id = " . strit($cliente_id); |
| 5134 | |
| 5135 | $sql_saldo_vales_pesos = "SELECT |
| 5136 | SUM(CASE WHEN paid = 0 AND aplicado = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_pesos, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_vales_pesos |
| 5137 | FROM vale WHERE anticipo_container = 0 AND moneda_id = 1 AND cliente_id = " . strit($cliente_id); |
| 5138 | |
| 5139 | $sql_saldo_vales_usd = "SELECT |
| 5140 | SUM(CASE WHEN paid = 0 AND aplicado = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_usd, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_vales_usd |
| 5141 | FROM vale WHERE anticipo_container = 0 AND moneda_id = 2 AND cliente_id = " . strit($cliente_id); |
| 5142 | |
| 5143 | $sql_saldo_vales_anticipo_container_pesos = "SELECT |
| 5144 | SUM(CASE WHEN paid = 0 AND aplicado = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_pesos, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_vales_pesos |
| 5145 | FROM vale WHERE anticipo_container = 1 AND moneda_id = 1 AND cliente_id = " . strit($cliente_id); |
| 5146 | |
| 5147 | $sql_saldo_vales_anticipo_container_usd = "SELECT |
| 5148 | SUM(CASE WHEN paid = 0 AND aplicado = 0 THEN IF(ABS(quantity - total_payments) < $tolerancia_usd, 0.00, IF(quantity - total_payments < 0, 0.00, quantity - total_payments)) END) saldo_vales_usd |
| 5149 | FROM vale WHERE anticipo_container = 1 AND moneda_id = 2 AND cliente_id = " . strit($cliente_id); |
| 5150 | |
| 5151 | |
| 5152 | $sql_cheques_pesos = "SELECT cheque_id as id, |
| 5153 | quantity - total_payments as quantity, 'PESOS' as moneda, 'cheque' as doc, numero, 'l Cheque' as nombre, quantity as ori_quantity, IF(new_date IS NULL, original_date, new_date) as fecha, tipo |
| 5154 | FROM cheque WHERE tipo NOT IN ('NOTA', 'GASTO') AND paid = 0 AND moneda_id = 1 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_pesos ORDER BY IF(new_date IS NULL, original_date, new_date) ASC, quantity ASC, alta_db ASC"; |
| 5155 | |
| 5156 | $sql_notas_pesos = "SELECT cheque_id as id, |
| 5157 | quantity - total_payments as quantity, 'PESOS' as moneda, 'cheque' as doc, numero, ' la Nota' as nombre, quantity as ori_quantity, IF(new_date IS NULL, original_date, new_date) as fecha, tipo |
| 5158 | FROM cheque WHERE tipo IN ('NOTA', 'GASTO') AND paid = 0 AND moneda_id = 1 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_pesos ORDER BY IF(new_date IS NULL, original_date, new_date) ASC, quantity ASC, alta_db ASC"; |
| 5159 | |
| 5160 | $sql_pagares_pesos = "SELECT pagare_id as id, |
| 5161 | quantity - total_payments as quantity, 'PESOS' as moneda, 'pagare' as doc, numero, 'l Pagaré' as nombre, quantity as ori_quantity, original_date as fecha, 'PAGARE' as tipo |
| 5162 | FROM pagare WHERE paid = 0 AND moneda_id = 1 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_pesos ORDER BY original_date ASC, quantity ASC, alta_db ASC"; |
| 5163 | |
| 5164 | $sql_vales_pesos = "SELECT vale_id as id, |
| 5165 | quantity - total_payments as quantity, 'PESOS' as moneda, 'vale' as doc, vale_number as numero, 'l Vale' as nombre, quantity as ori_quantity, alta_db as fecha, 'VALE' as tipo |
| 5166 | FROM vale WHERE anticipo_container = 0 AND paid = 0 AND aplicado = 0 AND moneda_id = 1 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_pesos ORDER BY alta_db DESC"; |
| 5167 | |
| 5168 | $sql_vales_anticipo_container_pesos = "SELECT vale_id as id, |
| 5169 | quantity - total_payments as quantity, 'PESOS' as moneda, 'vale' as doc, vale_number as numero, 'l Vale' as nombre, quantity as ori_quantity, alta_db as fecha, 'ANTICIPO CONTAINER' as tipo |
| 5170 | FROM vale WHERE anticipo_container = 1 AND paid = 0 AND aplicado = 0 AND moneda_id = 1 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_pesos ORDER BY alta_db DESC"; |
| 5171 | |
| 5172 | $sql_cheques_usd = "SELECT cheque_id as id, |
| 5173 | quantity - total_payments as quantity, 'USD' as moneda, 'cheque' as doc, numero, 'l Cheque' as nombre, quantity as ori_quantity, IF(new_date IS NULL, original_date, new_date) as fecha, tipo |
| 5174 | FROM cheque WHERE tipo NOT IN ('NOTA', 'GASTO') AND paid = 0 AND moneda_id = 2 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_usd ORDER BY IF(new_date IS NULL, original_date, new_date) ASC, quantity ASC, alta_db ASC"; |
| 5175 | |
| 5176 | $sql_notas_usd = "SELECT cheque_id as id, |
| 5177 | quantity - total_payments as quantity, 'USD' as moneda, 'cheque' as doc, numero, ' la Nota' as nombre, quantity as ori_quantity, IF(new_date IS NULL, original_date, new_date) as fecha, tipo |
| 5178 | FROM cheque WHERE tipo IN ('NOTA', 'GASTO') AND paid = 0 AND moneda_id = 2 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_usd ORDER BY IF(new_date IS NULL, original_date, new_date) ASC, quantity ASC, alta_db ASC"; |
| 5179 | |
| 5180 | $sql_pagares_usd = "SELECT pagare_id as id, |
| 5181 | quantity - total_payments as quantity, 'USD' as moneda, 'pagare' as doc, numero, 'l Pagaré' as nombre, quantity as ori_quantity, original_date as fecha, 'PAGARE' as tipo |
| 5182 | FROM pagare WHERE paid = 0 AND moneda_id = 2 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_usd ORDER BY original_date ASC, quantity ASC, alta_db ASC"; |
| 5183 | |
| 5184 | $sql_vales_usd = "SELECT vale_id as id, |
| 5185 | quantity - total_payments as quantity, 'USD' as moneda, 'vale' as doc, vale_number as numero, 'l Vale' as nombre, quantity as ori_quantity, alta_db as fecha, 'VALE' as tipo |
| 5186 | FROM vale WHERE anticipo_container = 0 AND paid = 0 AND aplicado = 0 AND moneda_id = 2 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_usd ORDER BY alta_db DESC"; |
| 5187 | |
| 5188 | $sql_vales_anticipo_container_usd = "SELECT vale_id as id, |
| 5189 | quantity - total_payments as quantity, 'USD' as moneda, 'vale' as doc, vale_number as numero, 'l Vale' as nombre, quantity as ori_quantity, alta_db as fecha, 'ANTICIPO CONTAINER' as tipo |
| 5190 | FROM vale WHERE anticipo_container = 1 AND paid = 0 AND aplicado = 0 AND moneda_id = 2 AND cliente_id = '$cliente_id' AND ABS(quantity - total_payments) > $tolerancia_usd ORDER BY alta_db DESC"; |
| 5191 | |
| 5192 | $nombre_cliente = strtoupper(ia_singleread($sql_nombre_cliente) ?? ""); |
| 5193 | $saldo_cheques_pesos = ia_singleread($sql_saldo_cheques_pesos); |
| 5194 | $saldo_cheques_usd = ia_singleread($sql_saldo_cheques_usd); |
| 5195 | $saldo_pagares_pesos = ia_singleread($sql_saldo_pagares_pesos); |
| 5196 | $saldo_pagares_usd = ia_singleread($sql_saldo_pagares_usd); |
| 5197 | $saldo_vales_pesos = ia_singleread($sql_saldo_vales_pesos); |
| 5198 | $saldo_vales_usd = ia_singleread($sql_saldo_vales_usd); |
| 5199 | $saldo_vales_anticipo_container_pesos = ia_singleread($sql_saldo_vales_anticipo_container_pesos); |
| 5200 | $saldo_vales_anticipo_container_usd = ia_singleread($sql_saldo_vales_anticipo_container_usd); |
| 5201 | $saldo_notas_pesos = ia_singleread($sql_saldo_notas_pesos); |
| 5202 | $saldo_notas_usd = ia_singleread($sql_saldo_notas_usd); |
| 5203 | $arr_cheques_pesos = ia_sqlArrayIndx($sql_cheques_pesos); |
| 5204 | $arr_cheques_usd = ia_sqlArrayIndx($sql_cheques_usd); |
| 5205 | $arr_pagares_pesos = ia_sqlArrayIndx($sql_pagares_pesos); |
| 5206 | $arr_pagares_usd = ia_sqlArrayIndx($sql_pagares_usd); |
| 5207 | $arr_vales_pesos = ia_sqlArrayIndx($sql_vales_pesos); |
| 5208 | $arr_vales_usd = ia_sqlArrayIndx($sql_vales_usd); |
| 5209 | $arr_vales_anticipo_container_pesos = ia_sqlArrayIndx($sql_vales_anticipo_container_pesos); |
| 5210 | $arr_vales_anticipo_container_usd = ia_sqlArrayIndx($sql_vales_anticipo_container_usd); |
| 5211 | $arr_notas_pesos = ia_sqlArrayIndx($sql_notas_pesos); |
| 5212 | $arr_notas_usd = ia_sqlArrayIndx($sql_notas_usd); |
| 5213 | |
| 5214 | |
| 5215 | /*echo "<pre>$sql_saldo_cheques_pesos" . print_r($saldo_cheques_pesos, true) . "</pre>"; |
| 5216 | echo "<pre>$sql_saldo_cheques_usd" . print_r($saldo_cheques_usd, true) . "</pre>"; |
| 5217 | echo "<pre>$sql_cheques_pesos" . print_r($arr_cheques_pesos, true) . "</pre>"; |
| 5218 | echo "<pre>$sql_cheques_usd" . print_r($arr_cheques_usd, true) . "</pre>"; |
| 5219 | echo "<pre>$sql_saldo_pagares_pesos" . print_r($saldo_pagares_pesos, true) . "</pre>"; |
| 5220 | echo "<pre>$sql_saldo_pagares_usd" . print_r($saldo_pagares_usd, true) . "</pre>"; |
| 5221 | echo "<pre>$sql_pagares_pesos" . print_r($arr_pagares_pesos, true) . "</pre>"; |
| 5222 | echo "<pre>$sql_pagares_usd" . print_r($arr_pagares_usd, true) . "</pre>"; |
| 5223 | echo "<pre>$sql_saldo_vales_pesos" . print_r($saldo_vales_pesos, true) . "</pre>"; |
| 5224 | echo "<pre>$sql_saldo_vales_usd" . print_r($saldo_vales_usd, true) . "</pre>"; |
| 5225 | echo "<pre>$sql_vales_pesos" . print_r($arr_vales_pesos, true) . "</pre>"; |
| 5226 | echo "<pre>$sql_vales_usd" . print_r($arr_vales_usd, true) . "</pre>";*/ |
| 5227 | |
| 5228 | $saldo_pesos = $saldo_cheques_pesos + $saldo_notas_pesos + $saldo_pagares_pesos - $saldo_vales_pesos; |
| 5229 | $saldo_usd = $saldo_cheques_usd + $saldo_notas_usd + $saldo_pagares_usd - $saldo_vales_usd; |
| 5230 | |
| 5231 | $saldo_pesos_hidden = $saldo_pesos != 0 ? "block" : "none;"; |
| 5232 | $saldo_usd_hidden = $saldo_usd != 0 ? "block" : "none;"; |
| 5233 | $txt_saldo_pesos = "<table id='doctos_saldo_pesos' style='display: $saldo_pesos_hidden'><tr><td style='min-width: 150px;'><span class='bold lbl_doc_pesos'>SALDO PESOS</span></td><td style='min-width: 180px;' class='txt_right_aligned'><span class='bold lbl_doc_pesos' style='font-size: 1.35em;'>" . echonf($saldo_pesos, true) . "</span></td></tr></table>"; |
| 5234 | $txt_saldo_usd = "<table id='doctos_saldo_usd' style='display: $saldo_usd_hidden'><tr><td style='min-width: 150px;'><span class='bold lbl_doc_usd'>SALDO USD</span></td><td style='min-width: 180px;' class='txt_right_aligned'><span class='bold lbl_doc_usd' style='font-size: 1.35em;'>" . echonf($saldo_usd, true) . "</span></td></tr></table>"; |
| 5235 | |
| 5236 | $arr_mons = array('cuantos' => 0, 'PESOS' => 0, 'USD' => 0); |
| 5237 | $arr_docs = array('notas_pesos' => array('mon' => 'PESOS'), 'notas_usd' => array('mon' => 'USD'), 'cheques_pesos' => array('mon' => 'PESOS'), 'cheques_usd' => array('mon' => 'USD'), 'pagares_pesos' => array('mon' => 'PESOS'), 'pagares_usd' => array('mon' => 'USD'), 'vales_pesos' => array('mon' => 'PESOS', 'signo' => '-'), 'vales_usd' => array('mon' => 'USD', 'signo' => '-'), 'vales_anticipo_container_pesos' => array('mon' => 'PESOS', 'lb' => 'vales_pesos', 'signo' => '-'), 'vales_anticipo_container_usd' => array('mon' => 'USD', 'lb' => 'vales_usd', 'signo' => '-')); |
| 5238 | $arr_todos = array(); |
| 5239 | $arr_lineas = array(); |
| 5240 | |
| 5241 | $max_height = $iacc == 'app_clientes_saldos' ? "1000px" : "160px"; |
| 5242 | |
| 5243 | $rows_max = 0; |
| 5244 | $linea = 0; |
| 5245 | $clb = ''; |
| 5246 | $totales = false; |
| 5247 | $width_wrapper = 0; |
| 5248 | $cww = 0; |
| 5249 | |
| 5250 | $flex_new_line = "<div style='flex-basis: 100%; height: 0; width: 100%;'> </div>"; |
| 5251 | foreach ($arr_docs as $doc => $mon) { |
| 5252 | $lb = array_key_exists('lb', $mon) ? $mon['lb'] : ''; |
| 5253 | if ($lb != $clb) { |
| 5254 | $linea++; |
| 5255 | $width_wrapper = $cww = 0; |
| 5256 | $rows_max = 0; |
| 5257 | $totales = false; |
| 5258 | } |
| 5259 | $clb = $lb; |
| 5260 | $c_docs = "arr_" . $doc; |
| 5261 | if (!empty($$c_docs)) { |
| 5262 | $arr_todos[$doc] = $$c_docs; |
| 5263 | $arr_lineas[$linea]['rows_max'] = $rows_max = max(sizeof($$c_docs), $rows_max); |
| 5264 | $arr_mons[$mon['mon']]++; |
| 5265 | $arr_mons['cuantos']++; |
| 5266 | $arr_todos[$doc]['cuantos'] = sizeof($$c_docs); |
| 5267 | $arr_todos[$doc]['linea'] = $linea; |
| 5268 | $arr_todos[$doc]['signo'] = $mon['signo'] ?? ''; |
| 5269 | $arr_todos[$doc]['suma'] = doOperation('SUM', $arr_todos[$doc], 'quantity', false, false); |
| 5270 | $arr_todos[$doc]['lb'] = strtoupper(TableHelper::dashesToCamelCase($mon['lb'] ?? $doc)); |
| 5271 | $totales = $linea > 0 || ($arr_mons['PESOS'] > 0 && $arr_mons['USD'] > 0); |
| 5272 | $cww += $linea == 0 ? 255 : 390; |
| 5273 | $arr_todos[$doc]['moneda'] = strtolower($mon['mon']); |
| 5274 | $arr_lineas[$linea]['docs'][$doc] = $arr_todos[$doc]; |
| 5275 | $arr_lineas[$linea]['width'] = $width_wrapper = max($cww, $width_wrapper); |
| 5276 | $arr_lineas[$linea]['calc_totales'] = $totales; |
| 5277 | |
| 5278 | } |
| 5279 | |
| 5280 | |
| 5281 | } |
| 5282 | // echo "<pre>arr_todos" . print_r($arr_todos, true) . "</pre>"; |
| 5283 | // echo "<pre>$totales " . !$totales . print_r($arr_mons, true) . "</pre>"; |
| 5284 | $html = "<div class='dved' id='saldo_cliente_tabla' style='display:none; position:absolute; background: #ffffff; width:fit-content; white-space: nowrap; margin-top: 15px; padding: 0.5em; border:2px outset #cacaca; border-radius: 10px 10px 10px 10px; z-index: 995;'> |
| 5285 | <div id='saldo_cliente_tabla_toolbar' style='display: none; position: absolute; background: #ffffff; width:fit-content; white-space: nowrap; margin-top: -32px; padding: 0.2em; border:2px outset whitesmoke; border-radius: 5px 5px 5px 5px; z-index: 994;'></div> |
| 5286 | <div id='saldo_cliente_tabla_maximize' style='display: block; float:right; background: #ffffff; width:fit-content; white-space: nowrap; margin-top: -30px; padding: 0.1em; border:2px outset whitesmoke; border-radius: 5px 5px 5px 5px; z-index: 994;'> |
| 5287 | |
| 5288 | <a class='tooltip_toolbar_wohtml' title='Restaurar' onclick='restaurar_saldo();'><i class='fa-icon fa-solid fa-window-restore txt_1_2em'></i></a> |
| 5289 | |
| 5290 | </div> |
| 5291 | <div style='margin-top: -20px;'> </div> |
| 5292 | <div style='margin-top: 0.4em;margin-bottom: 0.4em;padding-left: 0.5em; display: none;' id='saldo_cliente_nombre' class='bg_blue_pesos txt19px'>$nombre_cliente</div>"; |
| 5293 | |
| 5294 | $txt_totales = array(); |
| 5295 | $linea = -1; |
| 5296 | if(!empty($arr_todos)){ |
| 5297 | |
| 5298 | $txt_saldo_pesos = ""; |
| 5299 | $txt_saldo_usd = ""; |
| 5300 | foreach ($arr_lineas as $linea => $_line_data) { |
| 5301 | $txt_totales[$linea] = ""; |
| 5302 | foreach ($_line_data['docs'] as $_tipo => $_docs) { |
| 5303 | |
| 5304 | if ($_line_data['calc_totales']) { |
| 5305 | |
| 5306 | $txt_totales[$linea] .= "<table id='doctos_saldos_" . $_tipo . "' style='display: block;'>"; //($linea > -1 ? $div_line_close : ''); |
| 5307 | |
| 5308 | $txt_totales[$linea] .= "<tr><td style='min-width: 150px;'><span class='bold lbl_doc_" . $_docs['moneda'] . "'>" . $_docs['lb'] . "</span></td><td style='min-width: 180px;' class='txt_right_aligned'><span class='bold lbl_doc_" . $_docs['moneda'] . "' style='font-size: 1.35em;'>" . $_docs['signo'] . echonf($_docs['suma'], true) . "</span></td></tr>"; |
| 5309 | |
| 5310 | $txt_totales[$linea] .= "</table>"; |
| 5311 | |
| 5312 | $arr_lineas[$linea]['totales'] = $txt_totales[$linea]; |
| 5313 | } |
| 5314 | else { |
| 5315 | $saldo_pesos = $saldo_cheques_pesos + $saldo_notas_pesos + $saldo_pagares_pesos - $saldo_vales_pesos; |
| 5316 | $saldo_usd = $saldo_cheques_usd + $saldo_notas_usd + $saldo_pagares_usd - $saldo_vales_usd; |
| 5317 | |
| 5318 | $saldo_pesos_hidden = $saldo_pesos != 0 ? "block" : "none;"; |
| 5319 | $saldo_usd_hidden = $saldo_usd != 0 ? "block" : "none;"; |
| 5320 | $txt_saldo_pesos = "<table id='doctos_saldo_pesos' style='display: $saldo_pesos_hidden'><tr><td style='min-width: 150px;'><span class='bold lbl_doc_pesos'>SALDO PESOS</span></td><td style='min-width: 180px;' class='txt_right_aligned'><span class='bold lbl_doc_pesos' style='font-size: 1.35em;'>" . echonf($saldo_pesos, true) . "</span></td></tr></table>"; |
| 5321 | $txt_saldo_usd = "<table id='doctos_saldo_usd' style='display: $saldo_usd_hidden'><tr><td style='min-width: 150px;'><span class='bold lbl_doc_usd'>SALDO USD</span></td><td style='min-width: 180px;' class='txt_right_aligned'><span class='bold lbl_doc_usd' style='font-size: 1.35em;'>" . echonf($saldo_usd, true) . "</span></td></tr></table>"; |
| 5322 | |
| 5323 | $arr_lineas[$linea]['totales'] = $txt_saldo_pesos . $txt_saldo_usd; |
| 5324 | } |
| 5325 | } |
| 5326 | } |
| 5327 | |
| 5328 | // $txt_saldo_pesos = $txt_totales; |
| 5329 | |
| 5330 | |
| 5331 | // echo "<pre>arr_todos" . print_r($arr_todos, true) . "</pre>"; |
| 5332 | // echo "<pre>$totales " . !$totales . print_r($txt_totales, true) . "</pre>"; |
| 5333 | // echo "<pre>arr_lineas " . print_r($arr_lineas, true) . "</pre>"; |
| 5334 | |
| 5335 | //echo ia_htmlentities($div_line_close); |
| 5336 | // $linea = -1; |
| 5337 | |
| 5338 | $c_line_html = []; |
| 5339 | foreach ($arr_lineas as $linea => $_line_data) { |
| 5340 | $c_line_html = []; |
| 5341 | $c_line_html[] = $div_line = "<div style='width:" . $_line_data['width'] . "px; max-height:$max_height; overflow-y: auto; clear: both; display: flex; flex-flow: row wrap; justify-content: space-evenly;' id='doctos_detalle_" . $linea . "' >"; |
| 5342 | |
| 5343 | if($linea > 0) |
| 5344 | $c_line_html[] = "<div style='width:" . $_line_data['width'] . "px; margin: 20px; '><hr style='border-color: #747474;'/></div>"; |
| 5345 | |
| 5346 | foreach ($_line_data['docs'] as $_tipo => $_doc) { |
| 5347 | // echo "<pre>_doc" . print_r($_doc, true) . "</pre>"; |
| 5348 | |
| 5349 | $c_doc_div = ""; |
| 5350 | $_mon = ""; |
| 5351 | $cuantos_docs = $_doc['cuantos']; |
| 5352 | $signo = $_doc['signo'] ?? ""; |
| 5353 | // $c_doc_div = $div_line; |
| 5354 | |
| 5355 | |
| 5356 | for ($i = 0; $i < $_line_data['rows_max']; $i++) { |
| 5357 | if (array_key_exists($i, $_doc)) { |
| 5358 | $_mon = strtolower($_doc[$i]['moneda']); |
| 5359 | |
| 5360 | $txt_saldo = $_doc[$i]['ori_quantity'] != $_doc[$i]['quantity'] ? ", qty original $ " . echonf($_doc[$i]['ori_quantity'], true) . ", saldo $ " . echonf($_doc[$i]['quantity'], true) : ""; |
| 5361 | |
| 5362 | $c_doc_div .= "<tr><td style='padding-right:1em; padding-left:1em;' class='txt_0_9em txt_bold_black txt_centered'>" . ia_htmlentities(mysqlDate2display(substr($_doc[$i]['fecha'], 0, 10))) . "</td><td class='txt_right_aligned bold tooltip_toolbar_wohtml' title='Ir a" . $_doc[$i]['nombre'] . " #" . $_doc[$i]['numero'] . "$txt_saldo' class='' >" . |
| 5363 | "<a href='../backoffice/" . $_doc[$i]['doc'] . ".php?iah=e&id=" . $_doc[$i]['id'] . "' target='_blank' style='text-decoration: none;'><span class='bold lbl_doc_$_mon txt_1em'>$signo " . echonf($_doc[$i]['quantity'], true) . "</span></a></td></tr>"; |
| 5364 | |
| 5365 | // $arr_todos[$_tipo]['suma'] += $_doc[$i]['quantity']; |
| 5366 | } else |
| 5367 | $c_doc_div .= "<tr><td colspan='2'> </td></tr>"; |
| 5368 | } |
| 5369 | $c_thead = "<div class='' style='padding-left: 5px;padding-right: 5px;' id='div_doc_$_mon'><table id='tabla_doc_$_mon'><thead><tr><th colspan='2'>" . TableHelper::dashesToCamelCase($_tipo) . " (" . $cuantos_docs . ")</th></tr></thead><tbody>"; |
| 5370 | // $c_doc_div .= "<tr><td><hr/></td></tr>"; |
| 5371 | $saldo_doc = "saldo_" . $_tipo; |
| 5372 | $c_doc_div .= "</tbody>"; |
| 5373 | // echo "<pre>_doc" . print_r($_doc, true) . "</pre>"; |
| 5374 | |
| 5375 | if($_doc['cuantos'] > 1) |
| 5376 | $c_doc_div .= "<tfoot><tr><td colspan='2' class='txt_right_aligned bold lbl_doc_$_mon' style='cursor: auto;'>$signo " . echonf($$saldo_doc, true) . "</td></tr></tfoot>"; |
| 5377 | |
| 5378 | $c_doc_div .= "</table></div>"; |
| 5379 | $c_doc_div = $c_thead . $c_doc_div; |
| 5380 | $c_line_html[] = $c_doc_div; |
| 5381 | |
| 5382 | } |
| 5383 | $div_line_close = "</div>$flex_new_line<div style='clear: both; margin-top: 5px; margin-bottom: 15px;' class='txt_1_1em' id='doctos_saldo_" . $linea . "' >" . $_line_data['totales'] . "</div>"; |
| 5384 | $c_line_html[] = $div_line_close; |
| 5385 | |
| 5386 | |
| 5387 | $html .= implode($c_line_html); |
| 5388 | // $html .= '</div>'; |
| 5389 | } |
| 5390 | } |
| 5391 | |
| 5392 | |
| 5393 | $usuario = $_SESSION['usuario']; |
| 5394 | $now = date('Y-m-d H:i:s'); |
| 5395 | $por = "por $usuario, el " . mysqlDateTime2display($now, true); |
| 5396 | |
| 5397 | if(!sizeof($arr_lineas)) |
| 5398 | $flex_new_line = "<div style='width: 100%;'><table id='doctos_saldo_pesos' style=''><tr><td style='min-width: 150px;'><span class='bold lbl_doc_pesos'>SALDO</span></td><td style='min-width: 180px;' class='txt_right_aligned'><span class='bold lbl_doc_pesos' style='font-size: 1.35em;'>" . echonf(0.00, true) . "</span></td></tr></table></div><div style='clear: both; height: 0; width: 100%;'> </div>"; |
| 5399 | $html .= "$flex_new_line<div style='margin-top: 0px; text-align: right;' class='txt_0_7em bold'><span id='saldo_cliente_por' style='display: block;'>$por</span></div></div>"; |
| 5400 | |
| 5401 | // echo "<pre>$arr_lineas" . print_r($arr_lineas, true) . "</pre>"; |
| 5402 | return $html; |
| 5403 | } |
| 5404 | |
| 5405 | function init_estado_cuenta_cliente($fileName = '', $detachinsertAfter = 'div_remarks', $doDetach = 'true', $cliente_id = '74867af2fe609f5c11ed2998a6dec652'): void |
| 5406 | { |
| 5407 | echo "<div id='dialog_estado_cuenta_cliente'>" . estado_cuenta_cliente($cliente_id) . "</div>"; |
| 5408 | |
| 5409 | global $gIAParametros; |
| 5410 | |
| 5411 | $segundos_abierto_edo_cta_cliente = $gIAParametros['segundos_abierto_edo_cta_cliente']; |
| 5412 | $segundos_abierto_edo_cta_cliente_activo = $gIAParametros['segundos_abierto_edo_cta_cliente_activo']; |
| 5413 | $tipo_cambio = $gIAParametros['tc']; |
| 5414 | $tolerancia_pago_documentos_pesos = $gIAParametros['tolerancia_pago_documentos_pesos']; |
| 5415 | $tolerancia_pago_documentos_usd = $gIAParametros['tolerancia_pago_documentos_usd']; |
| 5416 | |
| 5417 | $fileName = empty($fileName) ? $fileName = "estado cuenta " . ia_singleread("SELECT nombre FROM cliente WHERE cliente_id = " . strit($cliente_id)) . " " . date("Ymd_Gis") : $fileName; |
| 5418 | $fileName = sanitizeFileName($fileName); |
| 5419 | |
| 5420 | echo <<< JSCODE |
| 5421 | <script> |
| 5422 | var cliente_saldo_exporter, prev_selected_row_id = ''; |
| 5423 | \$vitex_globales['iac_parametros']['segundos_abierto_edo_cta_cliente_ori'] = $segundos_abierto_edo_cta_cliente; |
| 5424 | \$vitex_globales['iac_parametros']['segundos_abierto_edo_cta_cliente'] = -1; |
| 5425 | \$vitex_globales['iac_parametros']['segundos_abierto_edo_cta_cliente_activo'] ='$segundos_abierto_edo_cta_cliente_activo'; |
| 5426 | \$vitex_globales['iac_parametros']['tc'] = $tipo_cambio; |
| 5427 | \$vitex_globales['iac_parametros']['tolerancia_pago_documentos_usd'] = $tolerancia_pago_documentos_usd; |
| 5428 | \$vitex_globales['iac_parametros']['tolerancia_pago_documentos_pesos'] = $tolerancia_pago_documentos_pesos; |
| 5429 | |
| 5430 | $(function() { |
| 5431 | vx_asyncFunction(function(){ |
| 5432 | do_init_estado_cuenta_cliente(); |
| 5433 | $('#div_categoria_id').css('z-index', '996'); |
| 5434 | } , 0, this); |
| 5435 | }); |
| 5436 | |
| 5437 | function do_init_estado_cuenta_cliente() { |
| 5438 | |
| 5439 | let \$saldo_cliente_tabla = $("#saldo_cliente_tabla"); |
| 5440 | let _config = { |
| 5441 | |
| 5442 | 'query_selector':'#saldo_cliente_tabla', |
| 5443 | 'query_selector4pdf_table':'', |
| 5444 | 'query_selector_wrapper':'#saldo_cliente_tabla', |
| 5445 | 'image_copy_alert_element':'#doctos_detalle', |
| 5446 | 'pre_func': pre_func, |
| 5447 | 'post_func': post_func, |
| 5448 | 'hideOnCopy': false, |
| 5449 | 'cliente_nombre_ocultar': true, |
| 5450 | 'fileName': '$fileName', |
| 5451 | 'wrapper_width': \$saldo_cliente_tabla.css('width'), |
| 5452 | 'new_window_url': "backoffice/cliente_saldo.php", |
| 5453 | 'new_window_field': 'cliente_id', |
| 5454 | 'new_window_value': '$cliente_id', |
| 5455 | }; |
| 5456 | let doDetach = $doDetach; |
| 5457 | cliente_saldo_exporter = new canvas_exporter(_config); |
| 5458 | |
| 5459 | if(doDetach) |
| 5460 | \$saldo_cliente_tabla.detach().insertAfter('#$detachinsertAfter').show(); |
| 5461 | $("#saldo_cliente_tabla_toolbar").append(cliente_saldo_exporter.toolBar("#saldo_cliente_tabla",{},"cliente_saldo_exporter")).show(); |
| 5462 | colapsar_saldo(); |
| 5463 | |
| 5464 | } |
| 5465 | |
| 5466 | function pre_func(){ |
| 5467 | cliente_saldo_exporter.config.wrapper_width = !$("div[id^='doctos_detalle']").is(":visible"); |
| 5468 | cliente_saldo_exporter.config.era_colapsado = !$("div[id^='doctos_detalle']").is(":visible"); |
| 5469 | expandir_saldo(); $("#saldo_cliente_tabla_maximize").hide(); $("#saldo_cliente_nombre").show(); |
| 5470 | } |
| 5471 | |
| 5472 | function post_func(){ |
| 5473 | restaurar_saldo(); $("#saldo_cliente_tabla_maximize").show(); |
| 5474 | if(cliente_saldo_exporter.config.cliente_nombre_ocultar) |
| 5475 | $("#saldo_cliente_nombre").hide(); |
| 5476 | if(cliente_saldo_exporter.config.era_colapsado) |
| 5477 | colapsar_saldo(); |
| 5478 | } |
| 5479 | |
| 5480 | function colapsar_saldo(){ |
| 5481 | if(!$doDetach) |
| 5482 | return; |
| 5483 | cliente_saldo_exporter.config.colapsado = true; |
| 5484 | // $("#saldo_cliente_tabla").css('width','fit-content'); |
| 5485 | $("div[id^='doctos_detalle']").css('max-height', '160px'); |
| 5486 | $("div[id^='doctos_detalle']").hide(); |
| 5487 | } |
| 5488 | function restaurar_saldo(){ |
| 5489 | |
| 5490 | if(!cliente_saldo_exporter.config.colapsado){ |
| 5491 | colapsar_saldo(); |
| 5492 | return; |
| 5493 | } |
| 5494 | |
| 5495 | let mh = $("div[id^='doctos_detalle']").css('max-height'); |
| 5496 | if(mh !== '160px') |
| 5497 | $("div[id^='doctos_detalle']").css('max-height', '160px'); |
| 5498 | else |
| 5499 | $("div[id^='doctos_detalle']").css('max-height', 'unset'); |
| 5500 | |
| 5501 | |
| 5502 | cliente_saldo_exporter.config.colapsado = false; |
| 5503 | $("div[id^='doctos_detalle']").show(); |
| 5504 | |
| 5505 | $("#saldo_cliente_tabla").css('width','max-content'); |
| 5506 | cliente_saldo_exporter.config.wrapper_width = $("#saldo_cliente_tabla").css('width'); |
| 5507 | cliente_saldo_exporter.config.wrapper_height = $("#saldo_cliente_tabla").css('height'); |
| 5508 | } |
| 5509 | function expandir_saldo(){ |
| 5510 | cliente_saldo_exporter.config.colapsado = false; |
| 5511 | $("#saldo_cliente_tabla").css('width','max-content'); |
| 5512 | cliente_saldo_exporter.config.wrapper_width = $("#saldo_cliente_tabla").css('width'); |
| 5513 | $("div[id^='doctos_detalle']").css('max-height', 'unset'); |
| 5514 | cliente_saldo_exporter.config.wrapper_height = $("#saldo_cliente_tabla").css('height'); |
| 5515 | $("div[id^='doctos_detalle']").show(); |
| 5516 | } |
| 5517 | |
| 5518 | function actualiza_estado_cuenta_cliente(cliente_id = '', callback = null){ |
| 5519 | if(!cliente_id.length){ |
| 5520 | cliente_id = $("#cliente_id").val(); |
| 5521 | if(!cliente_id.length) |
| 5522 | return; |
| 5523 | } |
| 5524 | |
| 5525 | $.ajax({ |
| 5526 | url: "ajax/cliente_acciones.php", |
| 5527 | dataType: "json", |
| 5528 | data: { |
| 5529 | cliente_id: cliente_id, |
| 5530 | accion: 'estado_cuenta_cliente', |
| 5531 | iacc: $("#iacc").val(), |
| 5532 | }, |
| 5533 | beforeSend: function(jqXHR, settings){ |
| 5534 | return true; |
| 5535 | } |
| 5536 | }).done(function(data){ |
| 5537 | if(data.Status != 'OK') return; |
| 5538 | |
| 5539 | |
| 5540 | $("#saldo_cliente_tabla").replaceWith($(data.estado_cuenta_cliente_html)); |
| 5541 | do_init_estado_cuenta_cliente(); |
| 5542 | // $("#saldo_cliente_tabla").find("#saldo_cliente_nombre").replaceWith($(data.estado_cuenta_cliente_html).find("#saldo_cliente_nombre")); |
| 5543 | // $("#saldo_cliente_tabla").find("#doctos_saldo").replaceWith($(data.estado_cuenta_cliente_html).find("#doctos_saldo_pesos")); |
| 5544 | // // $("#saldo_cliente_tabla").find("#doctos_saldo_usd").replaceWith($(data.estado_cuenta_cliente_html).find("#doctos_saldo_usd")); |
| 5545 | // $("#saldo_cliente_tabla").find("#saldo_cliente_por").replaceWith($(data.estado_cuenta_cliente_html).find("#saldo_cliente_por")); |
| 5546 | // |
| 5547 | if(cliente_saldo_exporter.config.colapsado) |
| 5548 | colapsar_saldo(); |
| 5549 | |
| 5550 | if(typeof callback === 'function') |
| 5551 | callback(); |
| 5552 | // $('#saldo_cliente_tabla').replaceWith(data.estado_cuenta_cliente_html); |
| 5553 | }); |
| 5554 | } |
| 5555 | </script> |
| 5556 | JSCODE; |
| 5557 | |
| 5558 | echo <<< NUEVOESTADOCUENTA |
| 5559 | <script> |
| 5560 | function generaEstadoCuenta(id, tipo = 'dialog', cliente_id ='') { |
| 5561 | let rowData = gridhandler.jqGrid('getRowData',id); |
| 5562 | cliente_id = !cliente_id.length ? rowData['cliente_id'] : cliente_id; |
| 5563 | |
| 5564 | actualiza_estado_cuenta_cliente(cliente_id, function(){ |
| 5565 | |
| 5566 | let \$saldo_cliente_tabla = $("#saldo_cliente_tabla"); |
| 5567 | |
| 5568 | cliente_saldo_exporter.config.image_copy_alert_element_pos = 'left bottom'; |
| 5569 | cliente_saldo_exporter.config.image_copy_alert_element = "#iaHome"; |
| 5570 | cliente_saldo_exporter.config.fileName = "ESTADO DE CUENTA " + \$saldo_cliente_tabla.find("#saldo_cliente_nombre").text(); |
| 5571 | |
| 5572 | \$saldo_cliente_tabla.show(); |
| 5573 | |
| 5574 | switch(tipo){ |
| 5575 | |
| 5576 | case 'imprimir': |
| 5577 | |
| 5578 | cliente_saldo_exporter.print("#saldo_cliente_tabla"); |
| 5579 | \$saldo_cliente_tabla.hide(); |
| 5580 | break; |
| 5581 | |
| 5582 | case 'jpg_copia': |
| 5583 | |
| 5584 | cliente_saldo_exporter.imageCopy("#saldo_cliente_tabla"); |
| 5585 | \$saldo_cliente_tabla.hide(); |
| 5586 | break; |
| 5587 | |
| 5588 | case 'jpg_guarda': |
| 5589 | |
| 5590 | cliente_saldo_exporter.imageSave("#saldo_cliente_tabla"); |
| 5591 | \$saldo_cliente_tabla.hide(); |
| 5592 | break; |
| 5593 | |
| 5594 | case 'dialog': |
| 5595 | |
| 5596 | let \$dialog_estado_cuenta_cliente = $("#dialog_estado_cuenta_cliente"); |
| 5597 | // console.log("prev_selected_row_id", prev_selected_row_id); |
| 5598 | // console.log("id", id); |
| 5599 | if(prev_selected_row_id === id && \$dialog_estado_cuenta_cliente.data('uiDialog') && \$dialog_estado_cuenta_cliente.dialog('isOpen')){ |
| 5600 | \$dialog_estado_cuenta_cliente.dialog('close'); |
| 5601 | break; |
| 5602 | } |
| 5603 | if(\$dialog_estado_cuenta_cliente.data('uiDialog') && \$dialog_estado_cuenta_cliente.dialog('isOpen')){ |
| 5604 | \$dialog_estado_cuenta_cliente.dialog('close'); |
| 5605 | |
| 5606 | } |
| 5607 | clearInterval(\$vitex_globales['iac_parametros'].interval_set); |
| 5608 | iacParam_initTimer(); |
| 5609 | restaurar_saldo(); |
| 5610 | |
| 5611 | prev_selected_row_id = id; |
| 5612 | |
| 5613 | $("#saldo_cliente_nombre").show(); |
| 5614 | $("#saldo_cliente_tabla_maximize").hide(); |
| 5615 | cliente_saldo_exporter.config.wrapper_width = \$saldo_cliente_tabla.css('width'); |
| 5616 | cliente_saldo_exporter.config.wrapper_height = \$saldo_cliente_tabla.css('height'); |
| 5617 | |
| 5618 | |
| 5619 | \$dialog_estado_cuenta_cliente.dialog({ |
| 5620 | width: vx_utils.parseInt(cliente_saldo_exporter.config.wrapper_width) + 50, |
| 5621 | height: vx_utils.parseInt(cliente_saldo_exporter.config.wrapper_height) + 100, |
| 5622 | title: $("#saldo_cliente_nombre").text() + " <span style='float: right;' id='timer_segundos_abierto_edo_cta_cliente'>"+\$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_ori+" seg.</span></h4>", |
| 5623 | open: function() { |
| 5624 | if(\$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_activo == 'Si'){ |
| 5625 | vx_asyncFunction(function(){ |
| 5626 | clearInterval(\$vitex_globales['iac_parametros'].interval_set); |
| 5627 | \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente = \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_ori; |
| 5628 | iacParam_initTimer(); |
| 5629 | }, 0, this); |
| 5630 | } |
| 5631 | vx_asyncFunction(function(){ |
| 5632 | expandir_saldo(); |
| 5633 | }, 0, this); |
| 5634 | vx_asyncFunction(function(){ |
| 5635 | $("#dialog_estado_cuenta_cliente").dialog( "option", "width", vx_utils.parseInt(cliente_saldo_exporter.config.wrapper_width) + 50); |
| 5636 | $("#dialog_estado_cuenta_cliente").dialog( "option", "height", vx_utils.parseInt(cliente_saldo_exporter.config.wrapper_height) + 100); |
| 5637 | }, 0, this); |
| 5638 | |
| 5639 | vx_asyncFunction(function(){ |
| 5640 | inicializa_ui_tooltip('#saldo_cliente_tabla .tooltip_toolbar_wohtml', 'ui_tooltip_box_top_toolbar_numero_compra_vacios', { my: 'left+20 top-50', at: 'left top+20' }, 30000); |
| 5641 | }, 0, this); |
| 5642 | }, |
| 5643 | close(){ |
| 5644 | clearInterval(\$vitex_globales['iac_parametros'].interval_set); |
| 5645 | \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente = \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_ori; |
| 5646 | $(this).dialog('destroy'); |
| 5647 | } |
| 5648 | }); |
| 5649 | break; |
| 5650 | |
| 5651 | case 'new_win': |
| 5652 | let url = getUrlBase("backoffice/cliente_saldo.php?cliente_id=" + cliente_id); |
| 5653 | |
| 5654 | window.open(url); |
| 5655 | |
| 5656 | break; |
| 5657 | } |
| 5658 | }); |
| 5659 | } |
| 5660 | |
| 5661 | |
| 5662 | function iacParam_initTimer() { |
| 5663 | if(\$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_ori == 0 || \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_activo == 'No') |
| 5664 | return; |
| 5665 | |
| 5666 | \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente = \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_ori; |
| 5667 | var \$dialog = $("#dialog_estado_cuenta_cliente"); |
| 5668 | \$vitex_globales['iac_parametros'].interval_set = setInterval(function () { |
| 5669 | \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente = \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente-1; |
| 5670 | if (\$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente === 0) { |
| 5671 | clearInterval(\$vitex_globales['iac_parametros'].interval_set); |
| 5672 | \$dialog.dialog('close'); |
| 5673 | \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente = \$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente_ori; |
| 5674 | } |
| 5675 | $("#timer_segundos_abierto_edo_cta_cliente").text((\$vitex_globales['iac_parametros'].segundos_abierto_edo_cta_cliente+" seg.")); |
| 5676 | }, 1000); |
| 5677 | } |
| 5678 | </script> |
| 5679 | NUEVOESTADOCUENTA; |
| 5680 | } |