Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 398 |
|
0.00% |
0 / 36 |
CRAP | n/a |
0 / 0 |
|
| usuarioTipoRony | |
0.00% |
0 / 17 |
|
0.00% |
0 / 1 |
72 | |||
| usuarioSupervisaBodega | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
56 | |||
| usuarioConsultaExistenciaBodega | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| puedeCatDoc | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
| puedeCuentaT | |
0.00% |
0 / 46 |
|
0.00% |
0 / 1 |
992 | |||
| puedeCuentaBancaria | |
0.00% |
0 / 35 |
|
0.00% |
0 / 1 |
306 | |||
| obtenNombredelPermisoenCuentaT | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
12 | |||
| cuentasTPuede | |
0.00% |
0 / 76 |
|
0.00% |
0 / 1 |
1806 | |||
| tienePermisoEnVale | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
42 | |||
| puedeClientes | |
0.00% |
0 / 23 |
|
0.00% |
0 / 1 |
210 | |||
| puedeGastosBanco | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| puedeGastosCuentaT | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |||
| puedeFiduciario | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
42 | |||
| puedeBancosChina | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |||
| puedePermisoUsuario | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
110 | |||
| puedeIngresosDirectosCuentaT | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |||
| leerPermisosVale | |
0.00% |
0 / 31 |
|
0.00% |
0 / 1 |
110 | |||
| cuentas_banco_cuales_puede | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| obtenNickdelUsuario | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getAllParams | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
20 | |||
| leeParametrosVitex | |
0.00% |
0 / 11 |
|
0.00% |
0 / 1 |
12 | |||
| getParametros | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| puedeInversion | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |||
| esRevisor | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| esRevisorBanco | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| puedeRevisarGastosCuentaT | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| puedeRevisarGastosBanco | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| tengoActivaAlertaGastos | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| puedeAdministrarColores | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| puedeConsultarColores | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| puedeAdministrarProductosGenerales | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| puedeConsultarProductosGenerales | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| puedeAdministrarProductosColor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| puedeProhibirColor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| puedeAsignarColor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| puedeConsultarProductosColor | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** @noinspection PhpMissingParamTypeInspection */ |
| 3 | /** @noinspection PhpMissingReturnTypeInspection */ |
| 4 | |
| 5 | function usuarioTipoRony($uid = null, $real_rony = false) { |
| 6 | if(empty($uid)) |
| 7 | $uid = $_SESSION['usuario_id'] ?? "0"; |
| 8 | |
| 9 | if($uid == 1) |
| 10 | return true; |
| 11 | if(empty($uid)) |
| 12 | return false; |
| 13 | |
| 14 | if($uid != 1 && $real_rony) |
| 15 | return false; |
| 16 | |
| 17 | static $prevUid = null; |
| 18 | static $prevPuede = false; |
| 19 | if($prevUid == $uid) { |
| 20 | return $prevPuede; |
| 21 | } |
| 22 | $prevUid = $uid; |
| 23 | $esUsuarioTipoRony = ia_singleread("SELECT usuario_tipo_rony FROM iac_usr WHERE iac_usr_id = " . strit($uid)); |
| 24 | if($esUsuarioTipoRony === 'Si') { //Hay que decidir los usuarios. |
| 25 | $prevPuede = true; |
| 26 | return true; |
| 27 | } |
| 28 | $prevPuede=false; |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | function usuarioSupervisaBodega($uid = null):bool { |
| 33 | if(empty($uid)) |
| 34 | $uid = isset($_SESSION) ? $_SESSION['usuario_id'] : "0"; |
| 35 | if(usuarioTipoRony($uid)) |
| 36 | return true; |
| 37 | if(empty($uid)) |
| 38 | return false; |
| 39 | |
| 40 | static $prevUid = null; |
| 41 | static $prevPuede = false; |
| 42 | if($prevUid == $uid) { |
| 43 | return $prevPuede; |
| 44 | } |
| 45 | $prevUid = $uid; |
| 46 | $function = __FUNCTION__; |
| 47 | if(ia_singleread("SELECT /*$function*/ puede_supervisar_bodega FROM iac_usr WHERE iac_usr_id =" . strit($uid) ) === 'Si') { |
| 48 | $prevPuede = true; |
| 49 | return true; |
| 50 | } |
| 51 | $prevPuede=false; |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | function usuarioConsultaExistenciaBodega($uid = null):bool {return puedePermisoUsuario(nombrePermiso: "puede_consultar_existencia");} |
| 56 | |
| 57 | function puedeCatDoc($catDoc) |
| 58 | { |
| 59 | return !usuarioTipoRony() |
| 60 | && ia_singleread("SELECT para_quien FROM categoria WHERE categoria_id=".strit($catDoc)) === 'RONY' ? |
| 61 | false : |
| 62 | true; |
| 63 | } |
| 64 | |
| 65 | function puedeCuentaT($cuentaTID='', $quienPuedeID='', $quePuede='') |
| 66 | { |
| 67 | global $arr_permisoctasT; |
| 68 | global $arr_ctasT; |
| 69 | global $arr_tiendasPuede; |
| 70 | |
| 71 | $arrTiendasQuePuedeKeys = array('cheque_Editar'=>array('que'=>'cheque','puede'=>'Editar'), |
| 72 | 'cheque_Consultar'=>array('que'=>'cheque','puede'=>'Consultar'), |
| 73 | 'pagare_Editar'=>array('que'=>'pagare','puede'=>'Editar'), |
| 74 | 'pagare_Consultar'=>array('que'=>'pagare','puede'=>'Consultar'), |
| 75 | 'vale_Editar'=>array('que'=>'vale','puede'=>'Editar'), |
| 76 | 'vale_Consultar'=>array('que'=>'vale','puede'=>'Consultar')); |
| 77 | $puede = false; |
| 78 | |
| 79 | if(empty($cuentaTID) || empty($quePuede)) |
| 80 | return false; |
| 81 | |
| 82 | if(empty($quienPuedeID)) |
| 83 | $quienPuedeID = $_SESSION['usuario_id']; |
| 84 | |
| 85 | //OPTIMIZE ANTES del $userProfile pues no se usa |
| 86 | |
| 87 | if(usuarioTipoRony($quienPuedeID)) //Confirmar si el superuser se salta esta verificación. |
| 88 | return true; |
| 89 | // falta cuentasTPuede |
| 90 | //OPTIMIZE SQL static var |
| 91 | // $userProfile = ia_singleton("SELECT /*".__METHOD__." !*/ * FROM iac_usr WHERE iac_usr_id = ".strit($quienPuedeID)); |
| 92 | |
| 93 | |
| 94 | if($arr_permisoctasT == null || $arr_ctasT == null || $arr_tiendasPuede == null) |
| 95 | { |
| 96 | $sql = "SELECT /*puedeCuentaT*/ * FROM permiso_ctat WHERE iac_usr_id = " . strit($quienPuedeID); |
| 97 | $arr_permisoctasT=ia_sqlArray($sql,'cuentaT_id'); |
| 98 | if($arr_permisoctasT === false) |
| 99 | $arr_permisoctasT = []; |
| 100 | $sql = "SELECT /*puedeCuentaT*/ cuentaT_id, poner_delivered_cheques, poner_delivered_pagares, es_de, tienda_id FROM cuentat"; |
| 101 | $arr_ctasT=ia_sqlArray($sql,'cuentaT_id'); |
| 102 | if($arr_ctasT === false) |
| 103 | $arr_ctasT = []; |
| 104 | //CAMBIAPLANTILLATIENDAS |
| 105 | $sql = "SELECT /*puedeCuentaT*/ pc.tienda_id, pc.permiso_cheque, pc.permiso_pagare, pc.permiso_cobranza, t.cuentaT_id |
| 106 | FROM plantilla_cobranza pc |
| 107 | JOIN iac_usr u ON u.plantillatienda_id=pc.plantillatienda_id |
| 108 | JOIN cuentat t ON pc.tienda_id=t.tienda_id |
| 109 | WHERE t.tienda_id > 0 AND u.iac_usr_id= " . strit($quienPuedeID); |
| 110 | $arr_tiendasPuedeTmp=ia_sqlArray($sql,'cuentaT_id'); |
| 111 | |
| 112 | if(is_array($arr_tiendasPuedeTmp)) foreach($arr_tiendasPuedeTmp as $kT => $vT) |
| 113 | { |
| 114 | $arr_tiendasPuede['cheque'][$kT] = []; |
| 115 | $arr_tiendasPuede['pagare'][$kT] = []; |
| 116 | $arr_tiendasPuede['vale'][$kT] = []; |
| 117 | |
| 118 | $arr_tiendasPuede['cheque'][$kT]['Editar'] = $vT['permiso_cheque'] === 'Editar'; |
| 119 | $arr_tiendasPuede['pagare'][$kT]['Editar'] = $vT['permiso_pagare'] === 'Editar'; |
| 120 | $arr_tiendasPuede['vale'][$kT]['Editar'] = $vT['permiso_cobranza'] === 'Editar'; |
| 121 | |
| 122 | $arr_tiendasPuede['cheque'][$kT]['Consultar'] = $vT['permiso_cheque'] === 'Consultar' || $vT['permiso_cheque'] === 'Editar'; |
| 123 | $arr_tiendasPuede['pagare'][$kT]['Consultar'] = $vT['permiso_pagare'] === 'Consultar' || $vT['permiso_pagare'] === 'Editar'; |
| 124 | $arr_tiendasPuede['vale'][$kT]['Consultar'] = $vT['permiso_cobranza'] === 'Consultar' || $vT['permiso_cobranza'] === 'Editar'; |
| 125 | } |
| 126 | |
| 127 | //echo "<pre>".print_r($arr_tiendasPuede, true)."</pre>"; |
| 128 | //echo "<pre>".print_r($arrTiendasQuePuedeKeys, true)."</pre>"; |
| 129 | //echo "<pre>".print_r($arr_ctasT, true)."</pre>"; |
| 130 | |
| 131 | if(is_array($arr_ctasT)) foreach($arr_ctasT as $kctaTID => $vctaT) |
| 132 | { |
| 133 | //echo "<pre>$kctaTID + ".print_r($vctaT, true)."</pre>"; |
| 134 | if(array_key_exists($kctaTID,$arr_permisoctasT)) |
| 135 | { |
| 136 | //echo "<pre>".print_r($arr_permisoctasT[$kctaTID], true)."</pre>"; |
| 137 | if(array_key_exists('poner_delivered_cheques',$arr_permisoctasT[$kctaTID])) |
| 138 | if($vctaT['poner_delivered_cheques'] === 'No') |
| 139 | $arr_permisoctasT[$kctaTID]['poner_delivered_cheques'] = $vctaT['poner_delivered_cheques']; |
| 140 | if(array_key_exists('poner_delivered_pagares',$arr_permisoctasT[$kctaTID])) |
| 141 | if($vctaT['poner_delivered_pagares'] === 'No') |
| 142 | $arr_permisoctasT[$kctaTID]['poner_delivered_pagares'] = $vctaT['poner_delivered_pagares']; |
| 143 | } |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | if(!empty($arr_permisoctasT) && is_array($arr_permisoctasT)) |
| 148 | { |
| 149 | //Metemos la revision de las tiendas 13-06-2014 |
| 150 | if(array_key_exists($quePuede,$arrTiendasQuePuedeKeys)) |
| 151 | { |
| 152 | if(array_key_exists('que', $arrTiendasQuePuedeKeys[$quePuede])) |
| 153 | if(array_key_exists($cuentaTID, $arr_tiendasPuede[$arrTiendasQuePuedeKeys[$quePuede]['que']])) |
| 154 | $puede = $arr_tiendasPuede[$arrTiendasQuePuedeKeys[$quePuede]['que']][$cuentaTID][$arrTiendasQuePuedeKeys[$quePuede]['puede']]; |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | if(array_key_exists($cuentaTID,$arr_permisoctasT)) |
| 159 | if($arr_permisoctasT[$cuentaTID]['acceso'] === 'Si') |
| 160 | if(array_key_exists($quePuede,$arr_permisoctasT[$cuentaTID])) |
| 161 | $puede = $arr_permisoctasT[$cuentaTID][$quePuede] === 'Si' ? true : false; |
| 162 | } |
| 163 | } |
| 164 | else |
| 165 | $puede = false; |
| 166 | |
| 167 | //echo "<pre>".print_r($arr_permisoctasT, true)."</pre>"; |
| 168 | |
| 169 | return $puede; |
| 170 | } |
| 171 | |
| 172 | function puedeCuentaBancaria($quienPuedeID='', $banco_cuenta_id = '', $quePuede='R/W', $todas=false, $EdoCtaOriginal='SI') |
| 173 | { |
| 174 | $arr_cB = []; |
| 175 | |
| 176 | $tablaBCMPlantilla = "banco_cuenta_mov_plantilla"; |
| 177 | if($EdoCtaOriginal != 'SI') |
| 178 | $tablaBCMPlantilla = "mov_verificado_plantilla"; |
| 179 | |
| 180 | if(empty($quienPuedeID)) |
| 181 | $quienPuedeID = $_SESSION['usuario_id']; |
| 182 | |
| 183 | if(empty($banco_cuenta_id)) |
| 184 | $todas = true; |
| 185 | |
| 186 | $where = ''; |
| 187 | |
| 188 | if(!$todas) |
| 189 | { |
| 190 | if(usuarioTipoRony($quienPuedeID)) |
| 191 | $where = " bc.banco_cuenta_id = " . strit($banco_cuenta_id); |
| 192 | else |
| 193 | $where = " AND bc.banco_cuenta_id = " . strit($banco_cuenta_id); |
| 194 | } |
| 195 | else |
| 196 | if(usuarioTipoRony($quienPuedeID)) |
| 197 | $where = "1"; |
| 198 | |
| 199 | if(usuarioTipoRony($quienPuedeID)) |
| 200 | $sql = "SELECT banco_cuenta_id, 'R/W' as puede FROM banco_cuenta bc WHERE /** bc.vale = 'active' **/ $where"; |
| 201 | else |
| 202 | if($quePuede === 'R/W') |
| 203 | /** @noinspection SqlResolve */ |
| 204 | $sql = "SELECT DISTINCT(bc.banco_cuenta_id), puede, bcu.vale FROM $tablaBCMPlantilla bc JOIN iac_usr u ON bc.plantilla_id=u.plantilla_id JOIN banco_cuenta bcu ON bcu.banco_cuenta_id=bc.banco_cuenta_id WHERE bcu.vale='Active' AND u.iac_usr_id=".strit($quienPuedeID)." AND bc.puede=".strit($quePuede).$where; |
| 205 | else { |
| 206 | /** @noinspection SqlResolve */ |
| 207 | $sql = "SELECT DISTINCT(bc.banco_cuenta_id), puede, bcu.vale FROM $tablaBCMPlantilla bc JOIN iac_usr u ON bc.plantilla_id=u.plantilla_id JOIN banco_cuenta bcu ON bcu.banco_cuenta_id=bc.banco_cuenta_id WHERE bcu.vale='Active' AND u.iac_usr_id=" . strit($quienPuedeID) . " AND bc.puede!='Nada'" . $where; |
| 208 | } |
| 209 | |
| 210 | //echo "<pre>$sql</pre>"; |
| 211 | $arr_cB['cB']=ia_sqlArrayIndx($sql); |
| 212 | |
| 213 | //echo "<pre>".print_r($arr_cB, true)."</pre>"; |
| 214 | |
| 215 | if(!empty($arr_cB['cB'])) |
| 216 | { |
| 217 | $arr_cB['puede'] = true; |
| 218 | switch($arr_cB['cB'][0]['puede']) |
| 219 | { |
| 220 | case 'R/W': $arr_cB['quePuede'] = 'Editar'; break; |
| 221 | |
| 222 | case 'R/O': $arr_cB['quePuede'] = 'Consultar'; break; |
| 223 | |
| 224 | case 'A/O': $arr_cB['quePuede'] = 'Capturar'; break; |
| 225 | |
| 226 | case 'D/O': $arr_cB['quePuede'] = 'Eliminar'; break; |
| 227 | |
| 228 | case 'L/O': $arr_cB['quePuede'] = 'Link'; break; //VCA 25-SEP-2020 PLANTILLA DE SOLO LINKS AL BANCO |
| 229 | |
| 230 | case 'Nada': |
| 231 | default: |
| 232 | $arr_cB['puede'] = false; |
| 233 | $arr_cB['quePuede'] = 'Nada'; break; |
| 234 | } |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | $arr_cB['puede'] = false; |
| 239 | $arr_cB['quePuede'] = 'Nada'; |
| 240 | } |
| 241 | return $arr_cB; |
| 242 | |
| 243 | } |
| 244 | |
| 245 | function obtenNombredelPermisoenCuentaT($table='', $fieldName='') |
| 246 | { |
| 247 | if($table=='' || $fieldName=='') |
| 248 | return false; |
| 249 | //echo "<pre>T: $table, F: $fieldName</pre>"; |
| 250 | // if($table== 'compra_pago' || $fieldName === 'compra_pago') |
| 251 | // die("<pre>T: $table, F: $fieldName</pre>"); |
| 252 | $arr_tpctast = []; |
| 253 | $arr_tpctast['cheque']['cuentaT_deliveredto_id'] = 'poner_delivered_cheques'; |
| 254 | $arr_tpctast['cheque']['aceptar_delivered_cheques'] = 'aceptar_delivered_cheques'; |
| 255 | $arr_tpctast['cheque']['cuentaT_transferto_id'] = 'aceptar_delivered_cheques'; |
| 256 | $arr_tpctast['cheque']['origen_cuentat_id'] = 'elegir_cuentat_origen_cheques'; |
| 257 | $arr_tpctast['pagare']['cuentaT_deliveredto_id'] = 'poner_delivered_pagares'; |
| 258 | $arr_tpctast['pagare']['origen_cuentat_id'] = 'elegir_cuentat_origen_pagares'; |
| 259 | $arr_tpctast['pagare']['aceptar_delivered_pagares'] = 'aceptar_delivered_pagares'; |
| 260 | $arr_tpctast['cuentat']['origen_cuentat_id'] = 'poner_delivered_cheques'; //bug en grid de Cheques. |
| 261 | $arr_tpctast['cheque_pago']['cuentaT_id'] = 'abonar_a_cheques'; |
| 262 | $arr_tpctast['pagare_pago']['cuentaT_id'] = 'abonar_a_pagares'; |
| 263 | $arr_tpctast['vale']['cuentaT_id'] = 'emitido_por_en_vales'; |
| 264 | $arr_tpctast['vale_pago']['cuentaT_id'] = 'emitido_por_en_vales'; |
| 265 | $arr_tpctast['iac_usr']['cuentat_preferida_id'] = 'acceso'; |
| 266 | //$arr_tpctast['cuentat']['cuentaT_id'] = 'ver_saldo_y_movimientos'; //bug en grid de cuentat_mov. |
| 267 | //VCA 15-09-2021 nuevo permiso para ver saldo y movimientos. |
| 268 | $arr_tpctast['cuentat']['cuentaT_id'] = 'puede_ver_cuentat'; //bug en grid de cuentat_mov. |
| 269 | |
| 270 | $arr_tpctast['cuentat_mov']['link_cuentat_a_banco'] = 'link_cuentat_a_banco'; //Manual, aquà iacase no manda esta tabla, ni el campo. |
| 271 | $arr_tpctast['deuda_pago']['cuentaT_id'] = 'pagar_deudas'; |
| 272 | $arr_tpctast['gasto_pago']['cuentaT_id'] = 'pagar_gastos'; |
| 273 | //$arr_tpctast['cuentat_ingreso']['cuentaT_id'] = 'acceso'; |
| 274 | |
| 275 | $arr_tpctast['cuentat_ingreso']['cuentaT_id'] = 'ingreso_directo'; |
| 276 | $arr_tpctast['compra_pago']['cuentaT_id'] = 'pagar_compras'; |
| 277 | |
| 278 | return $arr_tpctast[$table][$fieldName]; |
| 279 | } |
| 280 | |
| 281 | function cuentasTPuede($quienPuedeID='', $quePuede='', $formato='csv') |
| 282 | { |
| 283 | global $arr_ctasT; |
| 284 | global $arr_permisoctasT; |
| 285 | global $arr_tiendasPuede; |
| 286 | |
| 287 | $arrTiendasQuePuedeKeys = array('cheque_Editar'=>array('que'=>'cheque','puede'=>'Editar'), |
| 288 | 'cheque_Consultar'=>array('que'=>'cheque','puede'=>'Consultar'), |
| 289 | 'pagare_Editar'=>array('que'=>'pagare','puede'=>'Editar'), |
| 290 | 'pagare_Consultar'=>array('que'=>'pagare','puede'=>'Consultar'), |
| 291 | 'vale_Editar'=>array('que'=>'vale','puede'=>'Editar'), |
| 292 | 'vale_Consultar'=>array('que'=>'vale','puede'=>'Consultar')); |
| 293 | |
| 294 | $arr_ctasTPuede = []; |
| 295 | $csv_ctasTPuede = ''; |
| 296 | |
| 297 | if(empty($quePuede)) |
| 298 | { |
| 299 | if($formato === 'csv') |
| 300 | { |
| 301 | return "''"; |
| 302 | } |
| 303 | else |
| 304 | return $arr_ctasTPuede; |
| 305 | } |
| 306 | |
| 307 | if(empty($quienPuedeID)) |
| 308 | $quienPuedeID = $_SESSION['usuario_id']; |
| 309 | |
| 310 | if($quienPuedeID != $_SESSION['usuario_id']) //Para app_iac_usr |
| 311 | { |
| 312 | $arr_permisoctasT = null; |
| 313 | $arr_ctasT = null; |
| 314 | } |
| 315 | |
| 316 | $userProfile = ia_singleton("SELECT /*".__METHOD__."*/ * FROM iac_usr WHERE iac_usr_id = ".strit($quienPuedeID)); |
| 317 | $usuarioTipoRony = usuarioTipoRony($quienPuedeID); |
| 318 | |
| 319 | |
| 320 | if($arr_permisoctasT == null || $arr_ctasT == null) |
| 321 | { |
| 322 | |
| 323 | $sql = "SELECT /*cuentasTPuede*/ * FROM permiso_ctat WHERE iac_usr_id = " . strit($quienPuedeID); |
| 324 | $arr_permisoctasT = ia_sqlArray($sql,'cuentaT_id'); |
| 325 | |
| 326 | $sql = "SELECT /*cuentasTPuede*/ cuentaT_id, poner_delivered_cheques, poner_delivered_pagares FROM cuentat WHERE last_trasnfer_sent IS NOT NULL ORDER BY cuentaT_id DESC"; |
| 327 | $arr_ctasT=ia_sqlArray($sql,'cuentaT_id'); |
| 328 | //CAMBIAPLANTILLATIENDAS |
| 329 | $sql = "SELECT /*cuentasTPuede*/ pc.tienda_id, pc.permiso_cheque, pc.permiso_pagare, pc.permiso_cobranza, t.cuentaT_id |
| 330 | FROM plantilla_cobranza pc |
| 331 | JOIN iac_usr u ON u.plantillatienda_id=pc.plantillatienda_id |
| 332 | JOIN cuentat t ON pc.tienda_id=t.tienda_id |
| 333 | WHERE t.tienda_id > 0 AND u.iac_usr_id= " . strit($quienPuedeID) . " ORDER BY t.es_de"; |
| 334 | $arr_tiendasPuedeTmp=ia_sqlArray($sql,'cuentaT_id'); |
| 335 | |
| 336 | if(is_array($arr_tiendasPuedeTmp)) foreach($arr_tiendasPuedeTmp as $kT => $vT) |
| 337 | { |
| 338 | $arr_tiendasPuede['cheque'][$kT] = []; |
| 339 | $arr_tiendasPuede['pagare'][$kT] = []; |
| 340 | $arr_tiendasPuede['vale'][$kT] = []; |
| 341 | |
| 342 | $arr_tiendasPuede['cheque'][$kT]['Editar'] = $vT['permiso_cheque'] === 'Editar'; |
| 343 | $arr_tiendasPuede['pagare'][$kT]['Editar'] = $vT['permiso_pagare'] === 'Editar'; |
| 344 | $arr_tiendasPuede['vale'][$kT]['Editar'] = $vT['permiso_cobranza'] === 'Editar'; |
| 345 | |
| 346 | $arr_tiendasPuede['cheque'][$kT]['Consultar'] = $vT['permiso_cheque'] === 'Consultar' || $vT['permiso_cheque'] === 'Editar'; |
| 347 | $arr_tiendasPuede['pagare'][$kT]['Consultar'] = $vT['permiso_pagare'] === 'Consultar' || $vT['permiso_pagare'] === 'Editar'; |
| 348 | $arr_tiendasPuede['vale'][$kT]['Consultar'] = $vT['permiso_cobranza'] === 'Consultar' || $vT['permiso_cobranza'] === 'Editar'; |
| 349 | } |
| 350 | |
| 351 | //echo "<pre>arr_permisoctasT".print_r($arr_permisoctasT, true)."</pre>"; |
| 352 | //echo "<pre>arr_ctasT".print_r($arr_ctasT, true)."</pre>"; |
| 353 | |
| 354 | //Aqui vamos a planchar los permisos de poner_delivered_cheques y poner_delivered_pagares |
| 355 | if(is_array($arr_ctasT)) foreach($arr_ctasT as $kctaTID => $vctaT) |
| 356 | { |
| 357 | //echo "<pre>$kctaTID + ".print_r($vctaT, true)."</pre>"; |
| 358 | if(array_key_exists($kctaTID,$arr_permisoctasT)) |
| 359 | { |
| 360 | |
| 361 | //echo "<pre>".print_r($arr_permisoctasT[$kctaTID], true)."</pre>"; |
| 362 | if(array_key_exists('poner_delivered_cheques',$arr_permisoctasT[$kctaTID])) |
| 363 | if($vctaT['poner_delivered_cheques'] === 'No') |
| 364 | $arr_permisoctasT[$kctaTID]['poner_delivered_cheques'] = $vctaT['poner_delivered_cheques']; |
| 365 | if(array_key_exists('poner_delivered_pagares',$arr_permisoctasT[$kctaTID])) |
| 366 | if($vctaT['poner_delivered_pagares'] === 'No') |
| 367 | $arr_permisoctasT[$kctaTID]['poner_delivered_pagares'] = $vctaT['poner_delivered_pagares']; |
| 368 | } |
| 369 | else if($usuarioTipoRony) |
| 370 | { |
| 371 | $arr_permisoctasT[$kctaTID] = []; |
| 372 | $arr_permisoctasT[$kctaTID]['cuentaT_id'] = $kctaTID; |
| 373 | $arr_permisoctasT[$kctaTID]['poner_delivered_cheques'] = 'Si'; |
| 374 | $arr_permisoctasT[$kctaTID]['poner_delivered_pagares'] = 'Si'; |
| 375 | } |
| 376 | |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | |
| 381 | //Ahora revisamos uno a uno los permisos solicitados. |
| 382 | if(!is_array($quePuede)) |
| 383 | { |
| 384 | $tmp = []; |
| 385 | $tmp[] = $quePuede; |
| 386 | $quePuede = $tmp; |
| 387 | } |
| 388 | |
| 389 | /** |
| 390 | echo "<pre>qP: ".print_r($quePuede,true)."</pre>"; |
| 391 | echo "<pre>pcT: ".print_r($arr_permisoctasT,true)."</pre>"; |
| 392 | echo "<pre>tiendas: ".print_r($arr_tiendasPuede, true)."</pre>"; |
| 393 | **/ |
| 394 | |
| 395 | |
| 396 | $arr_ctaTPuede = []; |
| 397 | if(is_array($arr_permisoctasT)) |
| 398 | foreach($arr_permisoctasT as $kctaTID=>$vctaT) |
| 399 | { |
| 400 | //Usuario Tipo Rony puede todo en todas las Cuentas T. 23/02/2015 |
| 401 | if($usuarioTipoRony) |
| 402 | { |
| 403 | $arr_ctaTPuede[$kctaTID]['cuentaT_id'] = $vctaT['cuentaT_id']; |
| 404 | continue; |
| 405 | } |
| 406 | |
| 407 | foreach($quePuede as $nPermiso) |
| 408 | { |
| 409 | //Metemos la revision de las tiendas 13-06-2014 |
| 410 | if(array_key_exists($nPermiso,$arrTiendasQuePuedeKeys)) |
| 411 | { |
| 412 | if(array_key_exists('que', $arrTiendasQuePuedeKeys[$nPermiso])) |
| 413 | if(array_key_exists($kctaTID, $arr_tiendasPuede[$arrTiendasQuePuedeKeys[$nPermiso]['que']])) |
| 414 | if($arr_tiendasPuede[$arrTiendasQuePuedeKeys[$nPermiso]['que']][$kctaTID][$arrTiendasQuePuedeKeys[$nPermiso]['puede']]) |
| 415 | $arr_ctaTPuede[$kctaTID]['cuentaT_id'] = $vctaT['cuentaT_id']; |
| 416 | } |
| 417 | else |
| 418 | { |
| 419 | if(array_key_exists($nPermiso,$vctaT)) |
| 420 | if($nPermiso != 'poner_delivered_cheques' && $userProfile['cuentat_unica'] === 'Si' && !empty($userProfile['cuentat_preferida_id'])) |
| 421 | { |
| 422 | if($vctaT[$nPermiso] === 'Si' && $kctaTID == $userProfile['cuentat_preferida_id']) |
| 423 | $arr_ctaTPuede[$kctaTID]['cuentaT_id'] = $vctaT['cuentaT_id']; |
| 424 | } |
| 425 | else |
| 426 | if($vctaT[$nPermiso] === 'Si') |
| 427 | $arr_ctaTPuede[$kctaTID]['cuentaT_id'] = $vctaT['cuentaT_id']; |
| 428 | } |
| 429 | } |
| 430 | } |
| 431 | |
| 432 | |
| 433 | //echo "<pre>TIENDAS".print_r($arr_tiendasPuede, true)."</pre>"; |
| 434 | //echo "<pre>TIENDAS KEY".print_r($arrTiendasQuePuedeKeys, true)."</pre>"; |
| 435 | |
| 436 | //echo "<pre>PERMISO".print_r($quePuede, true)."</pre>"; |
| 437 | //echo "<pre>CUENTAT T".print_r($arr_ctaTPuede, true)."</pre>"; |
| 438 | //echo "<pre>".print_r($userProfile, true)."</pre>"; |
| 439 | |
| 440 | //Movemos la cuenta T preferida si existe al primer lugar. |
| 441 | if(sizeof($arr_ctaTPuede) > 1) |
| 442 | arrayMovetoTop($arr_ctaTPuede,$userProfile['cuentat_preferida_id']); |
| 443 | |
| 444 | |
| 445 | //echo "<pre>".print_r($arr_ctaTPuede, true)."</pre>"; |
| 446 | //Llenamos el CSV o el array con las que sà puede. |
| 447 | if(is_array($arr_ctaTPuede)) foreach($arr_ctaTPuede as $k=>$v) |
| 448 | { |
| 449 | if($formato === 'csv') |
| 450 | $csv_ctasTPuede.=stritc($v['cuentaT_id']); |
| 451 | else |
| 452 | $arr_ctasTPuede[$k] = $v['cuentaT_id']; |
| 453 | } |
| 454 | |
| 455 | if($formato === 'csv') |
| 456 | { |
| 457 | if(strlen($csv_ctasTPuede)>0) |
| 458 | $csv_ctasTPuede = substr_replace($csv_ctasTPuede ,"",-1); |
| 459 | else |
| 460 | $csv_ctasTPuede = "''"; |
| 461 | return $csv_ctasTPuede; |
| 462 | } |
| 463 | return $arr_ctasTPuede; |
| 464 | } |
| 465 | |
| 466 | function tienePermisoEnVale($quienTienePermisoID='', $vale_id='') |
| 467 | { |
| 468 | if(empty($vale_id)) |
| 469 | return false; |
| 470 | $method = __FUNCTION__; |
| 471 | $vale = ia_singleton("SELECT /*$method*/ * FROM vale WHERE vale_id=".strit($vale_id)); |
| 472 | //echo "<pre>".print_r($vale, true)."</pre>"; |
| 473 | if(empty($vale)) |
| 474 | return false; |
| 475 | |
| 476 | if(empty($quienTienePermisoID)) |
| 477 | $quienTienePermisoID = $_SESSION['usuario_id']; |
| 478 | |
| 479 | if(usuarioTipoRony($quienTienePermisoID))//== 1 || ia_singleread("SELECT tipo FROM iac_usr WHERE iac_usr_id = ".strit($quienTienePermisoID)) === 'Super user') |
| 480 | return true; |
| 481 | |
| 482 | //$sql = "SELECT * FROM vale_permiso WHERE (iac_usr_id=".strit($quienTienePermisoID)." OR tienda_id IN (SELECT tienda_id FROM usuario_cobranza u WHERE permiso='editar' AND u.iac_usr_id=".strit($quienTienePermisoID).")) AND vale_id = ".strit($vale_id); |
| 483 | //CAMBIAPLANTILLATIENDAS |
| 484 | $sql = "SELECT /*$method*/ * FROM vale_permiso vp WHERE |
| 485 | ( vp.iac_usr_id=".strit($quienTienePermisoID)." OR |
| 486 | vp.tienda_id IN (SELECT tienda_id FROM plantilla_cobranza p JOIN iac_usr u ON u.plantillatienda_id=p.plantillatienda_id WHERE p.permiso_cobranza='Editar' AND u.iac_usr_id=".strit($quienTienePermisoID).") |
| 487 | ) AND vp.vale_id = ".strit($vale_id); |
| 488 | |
| 489 | $arr_VPxU=ia_sqlArray($sql,'vale_permiso_id'); |
| 490 | //echo "<pre>$arr_VPxU</pre>"; |
| 491 | return !empty($arr_VPxU) || puedeCuentaT($vale['cuentaT_id'],$quienTienePermisoID,'emitido_por_en_vales'); |
| 492 | } |
| 493 | |
| 494 | function puedeClientes($quienPuedeID='', $quePuede='leer') |
| 495 | { |
| 496 | if(empty($quienPuedeID)) |
| 497 | $quienPuedeID = $_SESSION['usuario_id']; |
| 498 | |
| 499 | if(empty($quienPuedeID)) |
| 500 | return false; |
| 501 | |
| 502 | $utr = usuarioTipoRony($quienPuedeID); |
| 503 | |
| 504 | if($utr) |
| 505 | return true; |
| 506 | |
| 507 | $puedeClientes=ia_singleread("SELECT puede_clientes FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 508 | |
| 509 | if($puedeClientes === 'No') |
| 510 | return false; |
| 511 | |
| 512 | switch($quePuede){ |
| 513 | case 'leer': |
| 514 | if($puedeClientes === 'Si' || $puedeClientes === 'RO') |
| 515 | return true; |
| 516 | break; |
| 517 | |
| 518 | case 'insertar':case 'editar': |
| 519 | if($puedeClientes === 'Si') |
| 520 | return true; |
| 521 | break; |
| 522 | |
| 523 | case 'borrar': |
| 524 | if($utr) |
| 525 | return true; |
| 526 | else |
| 527 | return false; |
| 528 | |
| 529 | } |
| 530 | //echo "<pre>$quePuede:$puedeClientes</pre>"; |
| 531 | |
| 532 | if($puedeClientes === 'Si') |
| 533 | return true; |
| 534 | else |
| 535 | return false; |
| 536 | } |
| 537 | |
| 538 | function puedeGastosBanco($quienPuedeID='') |
| 539 | { |
| 540 | if(empty($quienPuedeID)) |
| 541 | $quienPuedeID = $_SESSION['usuario_id']; |
| 542 | |
| 543 | if(empty($quienPuedeID)) |
| 544 | return false; |
| 545 | |
| 546 | if(usuarioTipoRony($quienPuedeID)) |
| 547 | return 'Si'; |
| 548 | $method = __FUNCTION__; |
| 549 | return ia_singleread("SELECT /*$method*/ puede_gasto FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 550 | } |
| 551 | |
| 552 | function puedeGastosCuentaT($quienPuedeID='') |
| 553 | { |
| 554 | if(empty($quienPuedeID)) |
| 555 | $quienPuedeID = $_SESSION['usuario_id']; |
| 556 | |
| 557 | if(empty($quienPuedeID)) |
| 558 | return false; |
| 559 | |
| 560 | if(usuarioTipoRony($quienPuedeID)) |
| 561 | return true; |
| 562 | |
| 563 | // dd_("SELECT puede_gasto_ctat FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 564 | |
| 565 | $puede=ia_singleread("SELECT puede_gasto_ctat FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 566 | |
| 567 | if($puede === 'Si') |
| 568 | return true; |
| 569 | else |
| 570 | return false; |
| 571 | } |
| 572 | |
| 573 | function puedeFiduciario($quienPuedeID='') |
| 574 | { |
| 575 | if(empty($quienPuedeID)) |
| 576 | $quienPuedeID = $_SESSION['usuario_id']; |
| 577 | |
| 578 | if(empty($quienPuedeID)) |
| 579 | return false; |
| 580 | |
| 581 | if(usuarioTipoRony($quienPuedeID)) |
| 582 | return true; |
| 583 | |
| 584 | $puede=ia_singleread("SELECT puede_fiduciario FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 585 | |
| 586 | if($puede === 'Si') |
| 587 | return true; |
| 588 | elseif($puede === 'RO') |
| 589 | return 'RO'; |
| 590 | return false; |
| 591 | } |
| 592 | |
| 593 | function puedeBancosChina($quienPuedeID='') |
| 594 | { |
| 595 | if(empty($quienPuedeID)) |
| 596 | $quienPuedeID = $_SESSION['usuario_id']; |
| 597 | |
| 598 | if(empty($quienPuedeID)) |
| 599 | return false; |
| 600 | |
| 601 | if(usuarioTipoRony($quienPuedeID)) |
| 602 | return true; |
| 603 | $method = __FUNCTION__; |
| 604 | $puede=ia_singleread("SELECT /*$method*/ puede_banco_china FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 605 | |
| 606 | if($puede === 'Si') |
| 607 | return true; |
| 608 | else |
| 609 | return false; |
| 610 | } |
| 611 | |
| 612 | /** |
| 613 | * @param string $quienPuedeID |
| 614 | * @param string $nombrePermiso |
| 615 | * @param bool $valorReal |
| 616 | * @return bool|string |
| 617 | */ |
| 618 | function puedePermisoUsuario($quienPuedeID='', $nombrePermiso='', $valorReal = false) |
| 619 | { |
| 620 | if(empty($quienPuedeID)) |
| 621 | $quienPuedeID = $_SESSION['usuario_id'] ?? 0; |
| 622 | |
| 623 | if(empty($quienPuedeID) || empty($nombrePermiso)) |
| 624 | return false; |
| 625 | |
| 626 | if(usuarioTipoRony($quienPuedeID)){ |
| 627 | if(!$valorReal) |
| 628 | return true; |
| 629 | return 'Si'; |
| 630 | } |
| 631 | /* |
| 632 | $supervisorBodegaPuede = [ |
| 633 | 'puede_ser_encargado_bodega' => true, |
| 634 | 'puede_solo_consultar_bodegas' => true, |
| 635 | 'puede_solicitar_traslado_efectivo' => true, |
| 636 | 'puede_ver_modulo_solicitar_traslado_efectivo' => true, |
| 637 | 'puede_ver_traslados_match' => true, |
| 638 | 'puede_origen_huerfano' => true, |
| 639 | 'puede_consultar_existencia' => true, |
| 640 | 'puede_bodega_destinos_especiales' => true, |
| 641 | ]; |
| 642 | if(!empty($supervisorBodegaPuede[$nombrePermiso]) && usuarioSupervisaBodega($quienPuedeID)) { |
| 643 | return $valorReal ? 'Si' : true; |
| 644 | } |
| 645 | */ |
| 646 | static $permiso = []; |
| 647 | if(!isset($permiso[$quienPuedeID])) { |
| 648 | $method = __FUNCTION__; |
| 649 | $permiso[$quienPuedeID] = ia_singleton("SELECT /*$method*/ * FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 650 | } |
| 651 | if(!isset($permiso[$quienPuedeID][$nombrePermiso])) |
| 652 | return $valorReal ? 'No' : false; |
| 653 | return $valorReal ? $permiso[$quienPuedeID][$nombrePermiso] : $permiso[$quienPuedeID][$nombrePermiso] === 'Si'; |
| 654 | } |
| 655 | |
| 656 | function puedeIngresosDirectosCuentaT($quienPuedeID='') |
| 657 | { |
| 658 | if(empty($quienPuedeID)) |
| 659 | $quienPuedeID = $_SESSION['usuario_id']; |
| 660 | |
| 661 | if(empty($quienPuedeID)) |
| 662 | return false; |
| 663 | |
| 664 | if(usuarioTipoRony($quienPuedeID)) |
| 665 | return true; |
| 666 | |
| 667 | $puede=ia_singleread("SELECT puede_ingreso_directo_a_cuentat FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 668 | |
| 669 | if($puede === 'Si') |
| 670 | return true; |
| 671 | else |
| 672 | return false; |
| 673 | } |
| 674 | |
| 675 | /** |
| 676 | * @param $vale_id |
| 677 | * @return array |
| 678 | */ |
| 679 | function leerPermisosVale($vale_id) |
| 680 | { |
| 681 | $arrPermisos=array( "txtPermisosXUsuario" => "", |
| 682 | "divUsuariosconPermiso" => "", |
| 683 | "divUsuariossinPermiso" => ""); |
| 684 | |
| 685 | if(empty($vale_id)) |
| 686 | return $arrPermisos; |
| 687 | |
| 688 | $txtPermisosXUsuario=""; |
| 689 | $divUsuariosconPermiso=""; |
| 690 | $divUsuariossinPermiso=""; |
| 691 | |
| 692 | //CODIGO PARA PERMISOS POR USUARIO |
| 693 | $pxusql = "SELECT * FROM vale_permiso WHERE vale_id = " . strit($vale_id); |
| 694 | $pxuarray = ia_sqlArrayIndx($pxusql); |
| 695 | |
| 696 | $tspsql = "SELECT t.tienda_id, t.clave FROM tienda t WHERE t.tienda_id NOT IN (SELECT v.tienda_id FROM vale_permiso v WHERE v.vale_id = " . strit($vale_id) .")"; |
| 697 | // echo "<li>$tspsql"; |
| 698 | $tsparray = ia_sqlArrayIndx($tspsql); |
| 699 | |
| 700 | $uspsql = "SELECT u.iac_usr_id, u.nick FROM iac_usr u WHERE u.vale='Active' AND u.iac_usr_id NOT IN (SELECT v.iac_usr_id FROM vale_permiso v WHERE v.vale_id = " . strit($vale_id) .")"; |
| 701 | $usparray = ia_sqlArrayIndx($uspsql); |
| 702 | |
| 703 | $tarray = ia_sqlArray("SELECT t.tienda_id, t.clave FROM tienda t",'tienda_id'); |
| 704 | $uarray = ia_sqlArray("SELECT u.iac_usr_id, u.nick FROM iac_usr u WHERE u.vale='Active' ",'iac_usr_id'); |
| 705 | |
| 706 | |
| 707 | if(is_array($pxuarray)) foreach($pxuarray as $v) |
| 708 | { |
| 709 | if(!empty($v['tienda_id'])) |
| 710 | { |
| 711 | $tienda=$tarray[$v['tienda_id']]['clave']; |
| 712 | $txtPermisosXUsuario.=" T-$tienda,"; |
| 713 | $divUsuariosconPermiso.='<div id="'.$v['vale_permiso_id'].'" data-iac_usr_id="" data-tienda_id="'.$v['tienda_id'].'" data-nick="" data-clave="'.$tienda.'" data-vale_id="'.$vale_id.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding:5px"><strong>T-'.$tienda.'</strong><a href="javascript:void(0)" onclick="quitaPermiso('.$v['vale_permiso_id'].')"> <img src="../img/delete.png" width="14" height="14" alt="Quitar Permiso a Tienda." title="Quitar Permiso a Tienda." /></a> </div>'; |
| 714 | } |
| 715 | else |
| 716 | { |
| 717 | $nick=$uarray[$v['iac_usr_id']]['nick']; |
| 718 | $txtPermisosXUsuario.=" $nick,"; |
| 719 | $divUsuariosconPermiso.='<div id="'.$v['vale_permiso_id'].'" data-iac_usr_id="'.$v['iac_usr_id'].'" data-tienda_id="" data-nick="'.$nick.'" data-clave="" data-vale_id="'.$vale_id.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding:5px"><strong>'.$nick.'</strong><a href="javascript:void(0)" onclick="quitaPermiso('.$v['vale_permiso_id'].')"> <img src="../img/delete.png" width="14" height="14" alt="Quitar Permiso a Usuario." title="Quitar Permiso a Usuario." /></a> </div>'; |
| 720 | } |
| 721 | } |
| 722 | if(!empty($txtPermisosXUsuario)) $txtPermisosXUsuario = substr_replace($txtPermisosXUsuario,"",-1); |
| 723 | |
| 724 | if(is_array($tsparray)) foreach($tsparray as $v) |
| 725 | { |
| 726 | $tienda=$tarray[$v['tienda_id']]['clave']; |
| 727 | $divUsuariossinPermiso.='<div id="" data-iac_usr_id="" data-tienda_id="'.$v['tienda_id'].'" data-nick="" data-clave="'.$tienda.'" data-vale_id="'.$vale_id.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding5px;"><strong>T-'.$tienda.'</strong><a href="javascript:void(0)" onclick="daPermisoTienda('.$v['tienda_id'].')"> <img src="../img/add.png" width="14" height="14" alt="Dar Permiso a Tienda." title="Dar Permiso a Tienda." /></a> </div>'; |
| 728 | } |
| 729 | if(is_array($usparray)) foreach($usparray as $v) |
| 730 | { |
| 731 | $nick=$uarray[$v['iac_usr_id']]['nick']; |
| 732 | $divUsuariossinPermiso.='<div id="" data-iac_usr_id="'.$v['iac_usr_id'].'" data-tienda_id="" data-nick="'.$nick.'" data-clave="" data-vale_id="'.$vale_id.'" class="ui-menu ui-widget ui-widget-content ui-corner-all" style="padding:5px"><strong>'.$nick.'</strong><a href="javascript:void(0)" onclick="daPermisoUsuario('.$v['iac_usr_id'].')"> <img src="../img/add.png" width="14" height="14" alt="Dar Permiso a Usuario." title="Dar Permiso a Usuario." /></a> </div>'; |
| 733 | } |
| 734 | |
| 735 | $divUsuariosconPermiso='<div id="valeUsuariosconPermiso" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= USUARIOS Y TIENDAS CON PERMISO =-</strong><hr/><br/>'.$divUsuariosconPermiso.'</div>'; |
| 736 | $divUsuariossinPermiso='<div id="valeUsuariossinPermiso" class="ui-widget ui-widget-header ui-corner-all" style="float: left; width: 49%; text-align:center;"><strong>-= USUARIOS Y TIENDAS SIN PERMISO =-</strong><hr/><br/>'.$divUsuariossinPermiso.'</div>'; |
| 737 | |
| 738 | return ["txtPermisosXUsuario" => $txtPermisosXUsuario, |
| 739 | "divUsuariosconPermiso" => $divUsuariosconPermiso, |
| 740 | "divUsuariossinPermiso" => $divUsuariossinPermiso]; |
| 741 | |
| 742 | } |
| 743 | |
| 744 | function cuentas_banco_cuales_puede($que_puede='consultar') |
| 745 | { |
| 746 | $que_puede = $que_puede === 'consultar'; |
| 747 | $sql = cuenta_banco_mov_list_sql('r',false, false, null, null, false, $que_puede); |
| 748 | return ia_sqlArray($sql,'banco_cuenta_id'); |
| 749 | } |
| 750 | |
| 751 | function obtenNickdelUsuario($uid) |
| 752 | { |
| 753 | return ia_singleread("SELECT nick FROM iac_usr WHERE iac_usr_id = " . strit($uid)); |
| 754 | } |
| 755 | |
| 756 | function getAllParams() |
| 757 | { |
| 758 | $_PARAMS = ($_SERVER["REQUEST_METHOD"] === 'POST') ? $_POST : $_GET; |
| 759 | $params = []; |
| 760 | |
| 761 | foreach($_PARAMS as $key=>$value ) |
| 762 | if(str_contains($key, "remark")) |
| 763 | $params[$key] = $_REQUEST[$key] ?? ""; |
| 764 | else |
| 765 | $params[$key] = param($key); |
| 766 | |
| 767 | return $params; |
| 768 | } |
| 769 | |
| 770 | function leeParametrosVitex($fuerza=false) |
| 771 | { |
| 772 | $method = __METHOD__; |
| 773 | global $gIAParametros; |
| 774 | |
| 775 | if(empty($gIAParametros) || $fuerza) { |
| 776 | $gIAParametros = ia_singleton("SELECT /*$method*/ * FROM iac_parametros"); |
| 777 | |
| 778 | $pxusql = "SELECT/*$method*/ * FROM vale_permiso WHERE vale_id = '1'"; |
| 779 | $gIAParametros['vale_permiso_usuario_inicial'] = ia_sqlArrayIndx($pxusql); |
| 780 | |
| 781 | $permisos_lok_nota_bodega = "SELECT/*$method*/ * FROM parametro WHERE tema = 'nota_bodega' and subtema in ('lock') and is_active = '1' order by alta_db asc"; |
| 782 | $gIAParametros['permisos_lock_nota_bodega'] = ia_sqlArrayIndx($permisos_lok_nota_bodega); |
| 783 | |
| 784 | |
| 785 | $iac_usr_sql = "SELECT /*$method*/ * FROM iac_usr WHERE vale='Active'"; |
| 786 | $gIAParametros['iac_usr'] = ia_sqlArrayIndx($iac_usr_sql); |
| 787 | |
| 788 | $gIAParametros['do_flash_tab'] = false; |
| 789 | $gIAParametros =[...$gIAParametros, |
| 790 | ...ia_sqlKeyValue("SELECT /*$method*/ parametro_id, JSON_UNQUOTE(JSON_EXTRACT(parametros, '$.valor')) FROM parametro")]; |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | |
| 795 | function getParametros() |
| 796 | { |
| 797 | |
| 798 | $query = ia_sqlArrayIndx("SELECT parametro_id, JSON_UNQUOTE(JSON_EXTRACT(parametros, '$.valor')) as valor FROM parametro"); |
| 799 | $params_new_table = []; |
| 800 | foreach ($query as $value) { |
| 801 | $params_new_table[$value['parametro_id']] = $value['valor']; |
| 802 | } |
| 803 | return $params_new_table; |
| 804 | |
| 805 | } |
| 806 | |
| 807 | function puedeInversion($quienPuedeID='') |
| 808 | { |
| 809 | if(empty($quienPuedeID)) |
| 810 | $quienPuedeID = $_SESSION['usuario_id']; |
| 811 | |
| 812 | if(empty($quienPuedeID)) |
| 813 | return false; |
| 814 | |
| 815 | if(usuarioTipoRony($quienPuedeID)) |
| 816 | return true; |
| 817 | |
| 818 | $puede=ia_singleread("SELECT puede_inversion FROM iac_usr WHERE iac_usr_id =".strit($quienPuedeID)); |
| 819 | |
| 820 | if($puede === 'Si') |
| 821 | return true; |
| 822 | else |
| 823 | return false; |
| 824 | } |
| 825 | |
| 826 | /** |
| 827 | * @param string|int|null $user_id |
| 828 | * @return bool |
| 829 | */ |
| 830 | function esRevisor($user_id = null) { |
| 831 | $user_id = ($user_id == null) ? $_SESSION['usuario_id'] : $user_id; |
| 832 | return puedeRevisarGastosCuentaT($user_id); |
| 833 | /* $sql = "SELECT COUNT(*) registros_asignados FROM asignacion WHERE usuario_id = $user_id"; |
| 834 | $registros_asignados = ia_singleread($sql); |
| 835 | if ($registros_asignados > 0) { |
| 836 | return true; |
| 837 | } |
| 838 | return false; */ |
| 839 | } |
| 840 | |
| 841 | /** |
| 842 | * @param null $user_id |
| 843 | * @return bool |
| 844 | */ |
| 845 | function esRevisorBanco($user_id = null) { |
| 846 | $user_id = ($user_id == null) ? $_SESSION['usuario_id'] : $user_id; |
| 847 | return puedeRevisarGastosBanco($user_id); |
| 848 | /* $sql = "SELECT COUNT(*) registros_asignados FROM asignacion WHERE usuario_id = $user_id"; |
| 849 | $registros_asignados = ia_singleread($sql); |
| 850 | if ($registros_asignados > 0) { |
| 851 | return true; |
| 852 | } |
| 853 | return false; */ |
| 854 | } |
| 855 | |
| 856 | /** |
| 857 | * @param null $user_id |
| 858 | * @return bool |
| 859 | */ |
| 860 | function puedeRevisarGastosCuentaT($user_id = null):bool { |
| 861 | $method = __METHOD__; |
| 862 | return ia_singleread( |
| 863 | "SELECT /*$method*/ puede_revisar_gastos_cuentaT |
| 864 | FROM iac_usr |
| 865 | WHERE iac_usr_id = " . strit($user_id == null ? $_SESSION['usuario_id'] : $user_id)) === 'Si'; |
| 866 | // return esRevisor($user_id); |
| 867 | } |
| 868 | |
| 869 | /** |
| 870 | * @param null $user_id |
| 871 | * @return bool |
| 872 | */ |
| 873 | function puedeRevisarGastosBanco($user_id = null) { |
| 874 | if(usuarioTipoRony()) |
| 875 | return true; |
| 876 | $method = __FUNCTION__; |
| 877 | return ia_singleread( |
| 878 | "SELECT /*$method*/ puede_revisar_movimientos_banco |
| 879 | FROM iac_usr |
| 880 | WHERE iac_usr_id = " . strit($user_id == null ? $_SESSION['usuario_id'] : $user_id) |
| 881 | ) === 'Si'; |
| 882 | // return esRevisor($user_id); |
| 883 | } |
| 884 | |
| 885 | |
| 886 | function tengoActivaAlertaGastos($user_id = null) |
| 887 | { |
| 888 | $method = __FUNCTION__; |
| 889 | return ia_singleread( |
| 890 | "SELECT /*$method*/ activa_alerta_gastos |
| 891 | FROM iac_usr |
| 892 | WHERE iac_usr_id = " . strit($user_id == null ? $_SESSION['usuario_id'] : $user_id) |
| 893 | ); |
| 894 | } |
| 895 | |
| 896 | /** |
| 897 | * Altas bajas y cambios a colores de los productos |
| 898 | * |
| 899 | * @param int|string $user_id |
| 900 | * @return bool |
| 901 | */ |
| 902 | function puedeAdministrarColores($user_id = ''):bool { |
| 903 | return puedeAdministrarProductosGenerales($user_id); |
| 904 | } |
| 905 | |
| 906 | /** |
| 907 | * Obtiene el permiso para saber si puede consultar colores de productos (R/O) |
| 908 | * @return bool [true, false], el usuario tiene permiso (true => el usuario tiene permiso, false => el usuario no tiene permiso) |
| 909 | */ |
| 910 | function puedeConsultarColores($user_id = ''):bool |
| 911 | { |
| 912 | return puedeConsultarProductosGenerales($user_id); |
| 913 | } |
| 914 | |
| 915 | /** |
| 916 | * Puede dar de alta, editar y quitar productos generales y sus colores |
| 917 | * |
| 918 | * @param int|string $user_id |
| 919 | * @return bool |
| 920 | */ |
| 921 | function puedeAdministrarProductosGenerales($user_id = ''):bool |
| 922 | { |
| 923 | return usuarioSupervisaBodega() || Permisador::puede('productos', 'Nada', $user_id) === 'R/W'; |
| 924 | } |
| 925 | |
| 926 | /** |
| 927 | * Puede dar de alta, editar y quitar productos generales y sus colores |
| 928 | * |
| 929 | * @param int|string $user_id |
| 930 | * @return bool |
| 931 | */ |
| 932 | function puedeConsultarProductosGenerales($user_id = ''):bool |
| 933 | { |
| 934 | return usuarioSupervisaBodega() || Permisador::puede('productos', 'Nada', $user_id) !== 'Nada'; |
| 935 | } |
| 936 | |
| 937 | /** |
| 938 | * Obtiene el permiso para saber si puede administrar productos_color (c_ud) Cambios a detalles |
| 939 | * @return bool true tiene el permiso, false no lo tiene |
| 940 | */ |
| 941 | function puedeAdministrarProductosColor($user_id = ''):bool |
| 942 | { |
| 943 | return puedeAdministrarProductosGenerales($user_id); |
| 944 | } |
| 945 | |
| 946 | /** |
| 947 | * Obtiene el permiso para saber si puede puede prohibir colores |
| 948 | * @return bool true tiene el permiso, false no lo tiene |
| 949 | */ |
| 950 | function puedeProhibirColor($user_id = null):bool |
| 951 | { |
| 952 | return usuarioTipoRony() || Permisador::puede('puede_prohibir_colores', 'No', $user_id ?? $_SESSION['usuario_id'])!=='No'; |
| 953 | } |
| 954 | function puedeAsignarColor($user_id = null):bool |
| 955 | { |
| 956 | return usuarioTipoRony() || Permisador::puede('puede_asignar_colores', 'No', $user_id ?? $_SESSION['usuario_id'])!=='No' ; |
| 957 | } |
| 958 | |
| 959 | /** |
| 960 | * Obtiene el permiso para saber si puede consultar detalles cambiados a producto color |
| 961 | * @return bool true tiene el permiso, false no lo tiene |
| 962 | */ |
| 963 | function puedeConsultarProductosColor($user_id = ''):bool |
| 964 | { |
| 965 | return puedeConsultarProductosGenerales($user_id); |
| 966 | } |