| Total Complexity | 97 |
| Total Lines | 1001 |
| Duplicated Lines | 0 % |
| Changes | 9 | ||
| Bugs | 7 | Features | 0 |
Complex classes like informes_fiscales often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use informes_fiscales, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 26 | class informes_fiscales extends rd_controller |
||
| 27 | { |
||
| 28 | public $almacen; |
||
| 29 | public $almacenes; |
||
| 30 | public $almacenes_seleccionados; |
||
| 31 | public $codalmacen; |
||
| 32 | public $fecha_inicio; |
||
| 33 | public $fecha_fin; |
||
| 34 | public $reporte; |
||
| 35 | public $resultados_consolidado; |
||
| 36 | public $resultados_ventas; |
||
| 37 | public $resultados_compras; |
||
| 38 | public $resultados_606; |
||
| 39 | public $resultados_607; |
||
| 40 | public $resultados_608; |
||
| 41 | public $resultados_detalle_ventas; |
||
| 42 | public $resultados_detalle_compras; |
||
| 43 | public $resultados_resumen_ventas; |
||
| 44 | public $resultados_ventas_agente; |
||
| 45 | public $total_resultados_consolidado; |
||
| 46 | public $total_resultados_ventas; |
||
| 47 | public $total_resultados_compras; |
||
| 48 | public $total_resultados_606; |
||
| 49 | public $total_resultados_607; |
||
| 50 | public $total_resultados_608; |
||
| 51 | public $total_resultados_detalle_compras; |
||
| 52 | public $total_resultados_detalle_ventas; |
||
| 53 | public $total_resultados_resumen_ventas; |
||
| 54 | public $total_resultados_ventas_agente; |
||
| 55 | public $total_forma_pago; |
||
| 56 | public $total_forma_pago_dgii; |
||
| 57 | public $sumaVentas; |
||
| 58 | public $sumaVentasPagadas; |
||
| 59 | public $sumaCompras; |
||
| 60 | public $sumaComprasPagadas; |
||
| 61 | public $saldoConsolidado; |
||
| 62 | public $saldoConsolidadoPagadas; |
||
| 63 | public $totalDescuento; |
||
| 64 | public $totalDocumentos; |
||
| 65 | public $totalCantidad; |
||
| 66 | public $totalNeto; |
||
| 67 | public $totalItbis; |
||
| 68 | public $totalMonto; |
||
| 69 | public $archivoXLSX; |
||
| 70 | public $writer; |
||
| 71 | public $archivoXLSXPath; |
||
| 72 | public $documentosDir; |
||
| 73 | public $exportDir; |
||
| 74 | public $publicPath; |
||
| 75 | |||
| 76 | //Variables de Busqueda |
||
| 77 | public $limit; |
||
| 78 | public $offset; |
||
| 79 | public $sort; |
||
| 80 | public $order; |
||
| 81 | public $search; |
||
| 82 | |||
| 83 | public function __construct() |
||
| 84 | { |
||
| 85 | parent::__construct(__CLASS__, 'Informes Fiscales', 'informes', false, true, false); |
||
| 86 | } |
||
| 87 | |||
| 88 | protected function private_core() |
||
| 89 | { |
||
| 90 | parent::private_core(); |
||
| 91 | $this->share_extensions(); |
||
| 92 | $this->almacenes = new almacen(); |
||
|
|
|||
| 93 | $this->init_variables(); |
||
| 94 | $this->crear_carpetas_reportes(); |
||
| 95 | $codalmacen = $this->filter_request_array('codalmacen'); |
||
| 96 | $almacen_defecto = false; |
||
| 97 | if (count($this->almacenes->all())===1) { |
||
| 98 | $almacen_defecto = $this->empresa->codalmacen; |
||
| 99 | } |
||
| 100 | |||
| 101 | $this->codalmacen = ($codalmacen)?$codalmacen:$almacen_defecto; |
||
| 102 | $this->almacenes_seleccionados = (is_array($this->codalmacen))?$this->codalmacen:array($this->codalmacen); |
||
| 103 | |||
| 104 | $this->verificar_tipo_reporte(); |
||
| 105 | } |
||
| 106 | |||
| 107 | public function verificar_tipo_reporte() |
||
| 108 | { |
||
| 109 | $tiporeporte = \filter_input(INPUT_POST, 'tipo-reporte'); |
||
| 110 | $offset = \filter_input(INPUT_GET, 'offset'); |
||
| 111 | $limit = \filter_input(INPUT_GET, 'limit'); |
||
| 112 | $search = \filter_input(INPUT_GET, 'search'); |
||
| 113 | $sort = \filter_input(INPUT_GET, 'sort'); |
||
| 114 | $order = \filter_input(INPUT_GET, 'order'); |
||
| 115 | $this->fecha_inicio = $this->filter_request('inicio'); |
||
| 116 | $this->fecha_fin = $this->filter_request('fin'); |
||
| 117 | $this->offset = $this->confirmarValor($offset,0); |
||
| 118 | $this->limit = $this->confirmarValor($limit,FS_ITEM_LIMIT); |
||
| 119 | $this->search = $this->confirmarValor($search,false); |
||
| 120 | $this->sort = ($sort and $sort!='undefined')?$sort:'fecha, ncf'; |
||
| 121 | $this->order = ($order and $order!='undefined')?$order:'ASC'; |
||
| 122 | if (!empty($tiporeporte)) { |
||
| 123 | $this->reporte = $tiporeporte; |
||
| 124 | $this->mostrar_reporte(); |
||
| 125 | } |
||
| 126 | if (\filter_input(INPUT_GET, 'tabla_reporte')) { |
||
| 127 | $this->datos_reporte(\filter_input(INPUT_GET, 'tabla_reporte'), true); |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 131 | private function mostrar_reporte() |
||
| 132 | { |
||
| 133 | switch ($this->reporte) { |
||
| 134 | case 'reporte-consolidado': |
||
| 135 | $this->consolidado(); |
||
| 136 | break; |
||
| 137 | case 'reporte-ventas': |
||
| 138 | $this->ventas(); |
||
| 139 | break; |
||
| 140 | case 'detalle-ventas-agente': |
||
| 141 | $this->ventas_agente(); |
||
| 142 | break; |
||
| 143 | case 'reporte-compras': |
||
| 144 | $this->compras(); |
||
| 145 | break; |
||
| 146 | case 'detalle-compras': |
||
| 147 | $this->detalle_compras(); |
||
| 148 | break; |
||
| 149 | case 'reporte-606': |
||
| 150 | $this->dgii606(); |
||
| 151 | break; |
||
| 152 | case 'reporte-607': |
||
| 153 | $this->dgii607(); |
||
| 154 | break; |
||
| 155 | case 'reporte-608': |
||
| 156 | $this->dgii608(); |
||
| 157 | break; |
||
| 158 | case 'detalle-ventas': |
||
| 159 | $this->detalle_ventas(); |
||
| 160 | break; |
||
| 161 | case 'resumen-ventas': |
||
| 162 | $this->resumen_ventas(); |
||
| 163 | break; |
||
| 164 | default: |
||
| 165 | break; |
||
| 166 | } |
||
| 167 | } |
||
| 168 | |||
| 169 | private function init_variables() |
||
| 170 | { |
||
| 171 | $this->fecha_inicio = \date('01-m-Y'); |
||
| 172 | $this->fecha_fin = \date('d-m-Y'); |
||
| 173 | $this->reporte = ''; |
||
| 174 | $this->resultados_ventas = ''; |
||
| 175 | $this->resultados_compras = ''; |
||
| 176 | $this->resultados_606 = ''; |
||
| 177 | $this->resultados_607 = ''; |
||
| 178 | $this->resultados_608 = ''; |
||
| 179 | $this->resultados_detalle_compras = ''; |
||
| 180 | $this->resultados_detalle_ventas = ''; |
||
| 181 | $this->resultados_resumen_ventas = ''; |
||
| 182 | $this->resultados_ventas_agente = ''; |
||
| 183 | $this->total_resultados_consolidado = 0; |
||
| 184 | $this->total_resultados_ventas = 0; |
||
| 185 | $this->total_resultados_compras = 0; |
||
| 186 | $this->total_resultados_606 = 0; |
||
| 187 | $this->total_resultados_607 = 0; |
||
| 188 | $this->total_resultados_608 = 0; |
||
| 189 | $this->total_resultados_detalle_compras = 0; |
||
| 190 | $this->total_resultados_detalle_ventas = 0; |
||
| 191 | $this->total_resultados_resumen_ventas = 0; |
||
| 192 | $this->total_resultados_ventas_agente = 0; |
||
| 193 | } |
||
| 194 | |||
| 195 | private function crear_carpetas_reportes() |
||
| 196 | { |
||
| 197 | //Verificamos que exista la carpeta de documentos |
||
| 198 | $basepath = dirname(dirname(dirname(__DIR__))); |
||
| 199 | $this->documentosDir = $basepath . DIRECTORY_SEPARATOR . FS_MYDOCS . 'documentos'; |
||
| 200 | $this->exportDir = $this->documentosDir . DIRECTORY_SEPARATOR . "informes_rd"; |
||
| 201 | $this->publicPath = FS_PATH . FS_MYDOCS . 'documentos' . DIRECTORY_SEPARATOR . 'informes_rd'; |
||
| 202 | |||
| 203 | if (!is_dir($this->documentosDir)) { |
||
| 204 | mkdir($this->documentosDir); |
||
| 205 | } |
||
| 206 | |||
| 207 | if (!is_dir($this->exportDir)) { |
||
| 208 | mkdir($this->exportDir); |
||
| 209 | } |
||
| 210 | } |
||
| 211 | |||
| 212 | public function datos_reporte($reporte, $json = false) |
||
| 213 | { |
||
| 214 | $resultados = array(); |
||
| 215 | $total_informacion = 0; |
||
| 216 | $almacenes = implode("','", $this->almacenes_seleccionados); |
||
| 217 | switch ($reporte) { |
||
| 218 | case "reporte-consolidado": |
||
| 219 | list($resultados, $total_informacion) = $this->reporteConsolidado($almacenes, $json); |
||
| 220 | break; |
||
| 221 | case "reporte-ventas": |
||
| 222 | list($resultados, $total_informacion) = $this->reporteVentas($almacenes, $json); |
||
| 223 | break; |
||
| 224 | case "detalle-ventas-agente": |
||
| 225 | list($resultados, $total_informacion) = $this->reporteVentasAgente($almacenes, $json); |
||
| 226 | break; |
||
| 227 | case "detalle-ventas": |
||
| 228 | list($resultados, $total_informacion) = $this->reporteDetalleVentas($almacenes, $json); |
||
| 229 | break; |
||
| 230 | case "resumen-ventas": |
||
| 231 | list($resultados, $total_informacion) = $this->reporteResumenVentas($almacenes, $json); |
||
| 232 | break; |
||
| 233 | case "reporte-compras": |
||
| 234 | list($resultados, $total_informacion) = $this->reporteCompras($almacenes, $json); |
||
| 235 | break; |
||
| 236 | case "detalle-compras": |
||
| 237 | list($resultados, $total_informacion) = $this->reporteDetalleCompras($almacenes, $json); |
||
| 238 | break; |
||
| 239 | case "reporte-606": |
||
| 240 | list($resultados, $total_informacion) = $this->reporte606($almacenes, $json); |
||
| 241 | break; |
||
| 242 | case "reporte-607": |
||
| 243 | list($resultados, $total_informacion) = $this->reporte607($almacenes, $json); |
||
| 244 | break; |
||
| 245 | case "reporte-608": |
||
| 246 | list($resultados, $total_informacion) = $this->reporte608($almacenes, $json); |
||
| 247 | break; |
||
| 248 | default: |
||
| 249 | break; |
||
| 250 | } |
||
| 251 | if ($json) { |
||
| 252 | $data = array(); |
||
| 253 | $this->template = false; |
||
| 254 | header('Content-Type: application/json'); |
||
| 255 | $data['rows'] = $resultados; |
||
| 256 | $data['total'] = $total_informacion; |
||
| 257 | echo json_encode($data); |
||
| 258 | } else { |
||
| 259 | return $resultados; |
||
| 260 | } |
||
| 261 | } |
||
| 262 | |||
| 263 | public function reporteConsolidado($almacenes, $json) |
||
| 264 | { |
||
| 265 | $total_informacion = 0; |
||
| 266 | $sql_consolidado = "( ". |
||
| 267 | " SELECT 'Venta' as tipo, nv.codalmacen,nv.fecha,f.nombrecliente as nombre, ". |
||
| 268 | " CASE WHEN f.anulada THEN 'Anulado' ELSE 'Activo' END as condicion, ". |
||
| 269 | " CASE WHEN f.pagada THEN 'Si' ELSE 'No' END as pagada, ". |
||
| 270 | " ncf, ". |
||
| 271 | " CASE WHEN f.anulada = TRUE THEN 0 ELSE f.totaliva END as totaliva, ". |
||
| 272 | " CASE WHEN f.anulada = TRUE THEN 0 ELSE f.neto END as neto, ". |
||
| 273 | " CASE WHEN f.anulada = TRUE THEN 0 ELSE f.total END as total ,". |
||
| 274 | " codpago ". |
||
| 275 | " FROM ncf_ventas as nv ". |
||
| 276 | " JOIN facturascli as f ON (f.idfactura = nv.documento) ". |
||
| 277 | " WHERE idempresa = ".$this->empresa->intval($this->empresa->id)." AND nv.fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 278 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin)))." AND nv.codalmacen IN ('".$almacenes."') ". |
||
| 279 | " ) ". |
||
| 280 | " UNION ALL ". |
||
| 281 | " ( ". |
||
| 282 | " SELECT 'Compra' as tipo, codalmacen, fecha, nombre, ". |
||
| 283 | " CASE WHEN anulada THEN 'Anulado' ELSE 'Activo' END as condicion, ". |
||
| 284 | " CASE WHEN pagada THEN 'Si' ELSE 'No' END as pagada, ". |
||
| 285 | " numproveedor as ncf, ". |
||
| 286 | " CASE WHEN anulada = TRUE THEN 0 else totaliva END as totaliva, ". |
||
| 287 | " CASE WHEN anulada = TRUE THEN 0 else neto END as neto, ". |
||
| 288 | " CASE WHEN anulada = TRUE THEN 0 else total END as total, ". |
||
| 289 | " codpago ". |
||
| 290 | " FROM facturasprov ". |
||
| 291 | " WHERE fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 292 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin)))." AND codalmacen IN ('".$almacenes."') ". |
||
| 293 | " ) ". |
||
| 294 | " ORDER BY codalmacen,".$this->sort." ".$this->order; |
||
| 295 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_consolidado." ) as t1;"; |
||
| 296 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 297 | $sql_resumen = "SELECT t1.tipo,sum(CASE WHEN pagada = 'Si' THEN total ELSE 0 END) as total_pagada,sum(total) as total_general FROM (". |
||
| 298 | $sql_consolidado.") as t1 GROUP BY t1.tipo;"; |
||
| 299 | $data_resumen = $this->db->select($sql_resumen); |
||
| 300 | |||
| 301 | $sql_forma_pago = "SELECT codpago, sum(total) as total ". |
||
| 302 | " FROM (". |
||
| 303 | $sql_consolidado.") as t1 WHERE tipo = 'Venta' group by codpago ORDER BY codpago;"; |
||
| 304 | $data_forma_pago = $this->db->select($sql_forma_pago); |
||
| 305 | $this->total_forma_pago = array(); |
||
| 306 | if($data_forma_pago) { |
||
| 307 | foreach($data_forma_pago as $fpago){ |
||
| 308 | $this->total_forma_pago[] = (object) $fpago; |
||
| 309 | } |
||
| 310 | } |
||
| 311 | |||
| 312 | if ($json) { |
||
| 313 | $resultados = $this->db->select_limit($sql_consolidado, $this->limit, $this->offset); |
||
| 314 | } else { |
||
| 315 | $resultados = $this->db->select($sql_consolidado); |
||
| 316 | } |
||
| 317 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 318 | foreach ($data_resumen as $linea) { |
||
| 319 | if ($linea['tipo']=='Venta') { |
||
| 320 | $this->sumaVentasPagadas += $linea['total_pagada']; |
||
| 321 | $this->sumaVentas += $linea['total_general']; |
||
| 322 | } elseif ($linea['tipo']=='Compra') { |
||
| 323 | $this->sumaComprasPagadas += $linea['total_pagada']; |
||
| 324 | $this->sumaCompras += $linea['total_general']; |
||
| 325 | } |
||
| 326 | } |
||
| 327 | |||
| 328 | return array($resultados, $total_informacion); |
||
| 329 | } |
||
| 330 | |||
| 331 | /** |
||
| 332 | * Reporte consolidado de Ventas y Compras |
||
| 333 | */ |
||
| 334 | public function consolidado() |
||
| 335 | { |
||
| 336 | $this->sumaVentas = 0; |
||
| 337 | $this->sumaCompras = 0; |
||
| 338 | $this->saldoConsolidado = 0; |
||
| 339 | $this->sumaVentasPagadas = 0; |
||
| 340 | $this->sumaComprasPagadas = 0; |
||
| 341 | $this->saldoConsolidadoPagadas = 0; |
||
| 342 | $this->resultados_consolidado = $this->datos_reporte($this->reporte); |
||
| 343 | $this->saldoConsolidado = $this->sumaVentas - $this->sumaCompras; |
||
| 344 | $this->saldoConsolidadoPagadas = $this->sumaVentasPagadas - $this->sumaComprasPagadas; |
||
| 345 | |||
| 346 | $this->generar_excel( |
||
| 347 | array('Tipo','Almacén','Fecha','Cliente/Proveedor','Condición','Pagada','NCF','ITBIS','Neto','Total','F. Pago'), |
||
| 348 | $this->resultados_consolidado, |
||
| 349 | array('','','','','','','','','','',''), |
||
| 350 | false, |
||
| 351 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right')), |
||
| 352 | false |
||
| 353 | ); |
||
| 354 | } |
||
| 355 | |||
| 356 | public function reporteDetalleCompras($almacenes, $json) |
||
| 357 | { |
||
| 358 | $total_informacion = 0; |
||
| 359 | $sql_dcompras = "SELECT codalmacen, fecha, numproveedor as ncf, f.idfactura as documento, referencia, descripcion, cantidad, pvpunitario as precio, pvptotal as monto ". |
||
| 360 | " FROM facturasprov as f". |
||
| 361 | " JOIN lineasfacturasprov as fl on (f.idfactura = fl.idfactura)". |
||
| 362 | " WHERE fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 363 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin))). |
||
| 364 | " AND anulada = FALSE ". |
||
| 365 | " AND codalmacen IN ('".$almacenes."') ". |
||
| 366 | " ORDER BY codalmacen,".$this->sort." ".$this->order; |
||
| 367 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_dcompras." ) as t1;"; |
||
| 368 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 369 | $sql_resumen = "SELECT sum(cantidad) as cantidad, ". |
||
| 370 | " sum(monto) as total FROM (". |
||
| 371 | $sql_dcompras.") as t1;"; |
||
| 372 | $data_resumen = $this->db->select($sql_resumen); |
||
| 373 | if ($json) { |
||
| 374 | $resultados = $this->db->select_limit($sql_dcompras, $this->limit, $this->offset); |
||
| 375 | } else { |
||
| 376 | $resultados = $this->db->select($sql_dcompras); |
||
| 377 | $this->totalCantidad += $data_resumen[0]['cantidad']; |
||
| 378 | $this->totalMonto += $data_resumen[0]['total']; |
||
| 379 | } |
||
| 380 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 381 | return array($resultados, $total_informacion); |
||
| 382 | } |
||
| 383 | |||
| 384 | public function detalle_compras() |
||
| 385 | { |
||
| 386 | $this->totalCantidad = 0; |
||
| 387 | $this->totalMonto = 0; |
||
| 388 | $this->resultados_detalle_compras = $this->datos_reporte($this->reporte); |
||
| 389 | $this->total_resultados_detalle_compras = 0; |
||
| 390 | $this->generar_excel( |
||
| 391 | array('Almacén','Fecha','NCF','Documento','Referencia','Descripción','Cantidad','Precio','Monto'), |
||
| 392 | $this->resultados_detalle_compras, |
||
| 393 | array('Total','','','','','',$this->totalCantidad, '', $this->totalMonto), |
||
| 394 | false, |
||
| 395 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right')), |
||
| 396 | false |
||
| 397 | ); |
||
| 398 | } |
||
| 399 | |||
| 400 | public function reporteDetalleVentas($almacenes,$json) |
||
| 401 | { |
||
| 402 | $total_informacion = 0; |
||
| 403 | $sql_detalle = "SELECT codalmacen, fecha, ncf, documento, referencia, descripcion, cantidad, ". |
||
| 404 | "pvpunitario as precio,((pvpunitario*cantidad)*(dtopor/100)) as descuento, pvptotal as monto ". |
||
| 405 | " FROM ncf_ventas ". |
||
| 406 | " JOIN lineasfacturascli on (documento = idfactura)". |
||
| 407 | " WHERE idempresa = ".$this->empresa->intval($this->empresa->id). |
||
| 408 | " AND fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 409 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin))). |
||
| 410 | " AND estado = TRUE ". |
||
| 411 | " AND codalmacen IN ('".$almacenes."') ". |
||
| 412 | " ORDER BY codalmacen,".$this->sort." ".$this->order; |
||
| 413 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_detalle." ) as t1;"; |
||
| 414 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 415 | $sql_resumen = "SELECT sum(cantidad) as total_cantidad, ". |
||
| 416 | "sum(monto) as total_monto FROM (". |
||
| 417 | $sql_detalle.") as t1;"; |
||
| 418 | $data_resumen = $this->db->select($sql_resumen); |
||
| 419 | if ($json) { |
||
| 420 | $resultados = $this->db->select_limit($sql_detalle, $this->limit, $this->offset); |
||
| 421 | } else { |
||
| 422 | $resultados = $this->db->select($sql_detalle); |
||
| 423 | $this->totalCantidad += $data_resumen[0]['total_cantidad']; |
||
| 424 | $this->totalMonto += $data_resumen[0]['total_monto']; |
||
| 425 | } |
||
| 426 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 427 | return array($resultados, $total_informacion); |
||
| 428 | } |
||
| 429 | |||
| 430 | public function detalle_ventas() |
||
| 431 | { |
||
| 432 | $this->totalCantidad = 0; |
||
| 433 | $this->totalMonto = 0; |
||
| 434 | $this->resultados_detalle_ventas = $this->datos_reporte($this->reporte); |
||
| 435 | $this->total_resultados_detalle_ventas = 0; |
||
| 436 | $this->generar_excel( |
||
| 437 | array('Almacén','Fecha','NCF','Documento','Referencia','Descripción','Cantidad','Precio','Descuento','Monto'), |
||
| 438 | $this->resultados_detalle_ventas, |
||
| 439 | array('Total','','','','','',$this->totalCantidad,'', '',$this->totalMonto), |
||
| 440 | false, |
||
| 441 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right')), |
||
| 442 | false |
||
| 443 | ); |
||
| 444 | } |
||
| 445 | |||
| 446 | public function reporteResumenVentas($almacenes, $json) |
||
| 447 | { |
||
| 448 | $total_informacion = 0; |
||
| 449 | $sql_rventas = "SELECT codalmacen, ncf_tipo.tipo_comprobante as tipo_comprobante, ncf_tipo.descripcion as tc_descripcion, ". |
||
| 450 | "referencia, lineasfacturascli.descripcion as descripcion, sum(cantidad) as cantidad, sum(pvptotal) as monto ". |
||
| 451 | " from ncf_ventas ". |
||
| 452 | " join lineasfacturascli on (documento = idfactura) ". |
||
| 453 | " join ncf_tipo on (ncf_ventas.tipo_comprobante = ncf_tipo.tipo_comprobante) ". |
||
| 454 | " where idempresa = ".$this->empresa->intval($this->empresa->id). |
||
| 455 | " AND fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 456 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin))). |
||
| 457 | " AND ncf_ventas.estado = TRUE ". |
||
| 458 | " AND codalmacen IN ('".$almacenes."') ". |
||
| 459 | " GROUP BY codalmacen,ncf_tipo.tipo_comprobante,ncf_tipo.descripcion, referencia, lineasfacturascli.descripcion ". |
||
| 460 | " ORDER BY codalmacen,ncf_tipo.tipo_comprobante"; |
||
| 461 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_rventas." ) as t1;"; |
||
| 462 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 463 | $sql_resumen = "SELECT sum(cantidad) as total_cantidad, ". |
||
| 464 | "sum(monto) as total_monto FROM (". |
||
| 465 | $sql_rventas.") as t1;"; |
||
| 466 | $data_resumen = $this->db->select($sql_resumen); |
||
| 467 | if ($json) { |
||
| 468 | $resultados = $this->db->select_limit($sql_rventas, $this->limit, $this->offset); |
||
| 469 | } else { |
||
| 470 | $resultados = $this->db->select($sql_rventas); |
||
| 471 | $this->totalCantidad += $data_resumen[0]['total_cantidad']; |
||
| 472 | $this->totalMonto += $data_resumen[0]['total_monto']; |
||
| 473 | } |
||
| 474 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 475 | return array($resultados, $total_informacion); |
||
| 476 | } |
||
| 477 | |||
| 478 | public function resumen_ventas() |
||
| 479 | { |
||
| 480 | $this->totalCantidad = 0; |
||
| 481 | $this->totalMonto = 0; |
||
| 482 | $this->resultados_resumen_ventas = $this->datos_reporte($this->reporte); |
||
| 483 | $this->total_resultados_resumen_ventas = 0; |
||
| 484 | $this->generar_excel( |
||
| 485 | array('Almacén','Tipo NCF','Descripción NCF','Referencia','Descripción Artículo','Cantidad','monto'), |
||
| 486 | $this->resultados_resumen_ventas, |
||
| 487 | array('Total','','','','',$this->totalCantidad,$this->totalMonto), |
||
| 488 | false, |
||
| 489 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right')), |
||
| 490 | false |
||
| 491 | ); |
||
| 492 | } |
||
| 493 | |||
| 494 | public function reporteVentas($almacenes, $json) |
||
| 495 | { |
||
| 496 | $total_informacion = 0; |
||
| 497 | $sql_ventas = "SELECT nv.fecha,nv.codalmacen,f.nombrecliente,nv.cifnif,ncf,ncf_modifica,tipo_comprobante, ". |
||
| 498 | " CASE WHEN f.anulada = TRUE THEN 0 ELSE f.neto END as neto, ". |
||
| 499 | " CASE WHEN f.anulada = TRUE THEN 0 ELSE f.totaliva END as totaliva, ". |
||
| 500 | " CASE WHEN f.anulada = TRUE THEN 0 ELSE f.total END as total, ". |
||
| 501 | " CASE WHEN f.anulada THEN 'Anulado' ELSE 'Activo' END as condicion, ". |
||
| 502 | " nv.estado ". |
||
| 503 | //" CASE WHEN length(nv.cifnif)=9 THEN 1 ELSE 2 END as cifnif_tipo ". |
||
| 504 | " FROM ncf_ventas as nv ". |
||
| 505 | " JOIN facturascli as f ON (f.idfactura = nv.documento) ". |
||
| 506 | " WHERE idempresa = ".$this->empresa->intval($this->empresa->id)." AND ". |
||
| 507 | " nv.fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 508 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin))). |
||
| 509 | " AND nv.codalmacen IN ('".$almacenes."') ". |
||
| 510 | " ORDER BY codalmacen,".$this->sort." ".$this->order; |
||
| 511 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_ventas." ) as t1;"; |
||
| 512 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 513 | $sql_resumen = "SELECT sum(CASE WHEN t1.condicion = 'Activo' then neto else 0 end) as neto, ". |
||
| 514 | "sum(CASE WHEN t1.condicion = 'Activo' then totaliva else 0 end) as totaliva,". |
||
| 515 | "sum(CASE WHEN t1.condicion = 'Activo' then total else 0 end) as total FROM (". |
||
| 516 | $sql_ventas.") as t1;"; |
||
| 517 | $data_resumen = $this->db->select($sql_resumen); |
||
| 518 | if ($json) { |
||
| 519 | $resultados = $this->db->select_limit($sql_ventas, $this->limit, $this->offset); |
||
| 520 | } else { |
||
| 521 | $resultados = $this->db->select($sql_ventas); |
||
| 522 | $this->totalNeto += $data_resumen[0]['neto']; |
||
| 523 | $this->totalItbis += $data_resumen[0]['totaliva']; |
||
| 524 | $this->totalMonto += $data_resumen[0]['total']; |
||
| 525 | } |
||
| 526 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 527 | return array($resultados, $total_informacion); |
||
| 528 | } |
||
| 529 | |||
| 530 | public function ventas() |
||
| 531 | { |
||
| 532 | $this->resultados_ventas = array(); |
||
| 533 | $this->totalCantidad = 0; |
||
| 534 | $this->totalDescuento = 0; |
||
| 535 | $this->totalMonto = 0; |
||
| 536 | $this->resultados_ventas = $this->datos_reporte($this->reporte); |
||
| 537 | $this->total_resultados_ventas = 0; |
||
| 538 | $this->generar_excel( |
||
| 539 | array('Fecha','Almacén','Cliente','RNC','NCF','NCF Modifica','Tipo','Base Imp.','Itbis','Total','Condicion','Estado'), |
||
| 540 | $this->resultados_ventas, |
||
| 541 | array('Total','','','','','','',$this->totalNeto,$this->totalItbis,$this->totalMonto,'',''), |
||
| 542 | false, |
||
| 543 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'left'),array('halign'=>'left')), |
||
| 544 | false |
||
| 545 | ); |
||
| 546 | } |
||
| 547 | |||
| 548 | public function reporteVentasAgente($almacenes, $json) |
||
| 549 | { |
||
| 550 | $disabled = array(); |
||
| 551 | if (defined('FS_DISABLED_PLUGINS')) { |
||
| 552 | foreach (explode(',', FS_DISABLED_PLUGINS) as $aux) { |
||
| 553 | $disabled[] = $aux; |
||
| 554 | } |
||
| 555 | } |
||
| 556 | $sql_data_nomina = (in_array('nomina', $GLOBALS['plugins']) and ! in_array('nomina', $disabled)) ? "',' ',a.segundo_apellido'":""; |
||
| 557 | $total_informacion = 0; |
||
| 558 | $sql_ventas_agente = "SELECT fecha,f.codalmacen, f.codagente, concat(a.nombre$sql_data_nomina) as nombre_vendedor, ". |
||
| 559 | " g.nombre as grupo_cliente, f.nombrecliente, f.cifnif, f.direccion, ". |
||
| 560 | " numero2 as ncf, f.idfactura, f.idfacturarect as afecta_a, referencia, lf.descripcion, ". |
||
| 561 | " cantidad, pvpunitario as precio,((pvpunitario*cantidad)*(dtopor/100)) as descuento, pvptotal as monto, ". |
||
| 562 | " fp.descripcion as forma_pago, ". |
||
| 563 | " case when idfacturarect is null then 'VENTA' else 'DEVOLUCION' end as tipo ". |
||
| 564 | " FROM facturascli as f ". |
||
| 565 | " JOIN lineasfacturascli as lf on (f.idfactura = lf.idfactura) ". |
||
| 566 | " JOIN formaspago as fp on (f.codpago = fp.codpago) ". |
||
| 567 | " JOIN agentes as a on (f.codagente = a.codagente) ". |
||
| 568 | " JOIN clientes as c on (f.codcliente = c.codcliente) ". |
||
| 569 | " LEFT JOIN gruposclientes as g on (c.codgrupo = g.codgrupo) ". |
||
| 570 | " WHERE fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 571 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin))). |
||
| 572 | " AND anulada = false AND f.codalmacen IN ('".$almacenes."') ". |
||
| 573 | " ORDER BY codalmacen,".$this->sort." ".$this->order; |
||
| 574 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_ventas_agente." ) as t1;"; |
||
| 575 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 576 | $sql_resumen = "SELECT sum(cantidad) as total_cantidad, sum(descuento) as total_descuento, ". |
||
| 577 | "sum(monto) as total_monto FROM (". |
||
| 578 | $sql_ventas_agente.") as t1;"; |
||
| 579 | $data_resumen = $this->db->select($sql_resumen); |
||
| 580 | if ($json) { |
||
| 581 | $resultados = $this->db->select_limit($sql_ventas_agente, $this->limit, $this->offset); |
||
| 582 | } else { |
||
| 583 | $resultados = $this->db->select($sql_ventas_agente); |
||
| 584 | $this->totalCantidad += $data_resumen[0]['total_cantidad']; |
||
| 585 | $this->totalDescuento += $data_resumen[0]['total_descuento']; |
||
| 586 | $this->totalMonto += $data_resumen[0]['total_monto']; |
||
| 587 | } |
||
| 588 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 589 | return array($resultados, $total_informacion); |
||
| 590 | } |
||
| 591 | |||
| 592 | public function ventas_agente() |
||
| 607 | ); |
||
| 608 | } |
||
| 609 | |||
| 610 | public function reporteCompras($almacenes, $json) |
||
| 641 | } |
||
| 642 | |||
| 643 | public function compras() |
||
| 644 | { |
||
| 645 | $this->resultados_compras = array(); |
||
| 646 | $this->totalNeto = 0; |
||
| 647 | $this->totalItbis = 0; |
||
| 648 | $this->totalMonto = 0; |
||
| 649 | $this->resultados_compras = $this->datos_reporte($this->reporte); |
||
| 650 | $this->total_resultados_compras = 0; |
||
| 651 | $this->generar_excel( |
||
| 652 | array('Fecha','Almacén','Proveedor','RNC','Factura','NCF','Base Imp.','Itbis','Total','Condicion','Anulada'), |
||
| 653 | $this->resultados_compras, |
||
| 654 | array('Total','','','','','',$this->totalNeto,$this->totalItbis,$this->totalMonto,'',''), |
||
| 655 | false, |
||
| 656 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'left'),array('halign'=>'left')), |
||
| 657 | false |
||
| 658 | ); |
||
| 659 | } |
||
| 660 | |||
| 661 | public function reporte606($almacenes, $json) |
||
| 662 | { |
||
| 663 | $total_informacion = 0; |
||
| 664 | $sql_606 = " SELECT fp.cifnif, ". |
||
| 665 | " CASE WHEN length(fp.cifnif)=9 THEN 1 WHEN length(fp.cifnif)=11 THEN 1 ELSE 3 END as tipo_id, ". |
||
| 666 | " concat(ncftc.codigo,' - ',ncftc.descripcion) as descripcion, ". |
||
| 667 | " fp.numproveedor as ncf, fp2.numproveedor as ncf_modifica, ". |
||
| 668 | " concat(extract(year from fp.fecha),lpad(CAST(extract(month from fp.fecha) as char),2,'0'), lpad(CAST(extract(day from fp.fecha) as char),2,'0')) as fecha, ". |
||
| 669 | " concat(extract(year from ca.fecha),lpad(CAST(extract(month from ca.fecha) as char),2,'0'), lpad(CAST(extract(day from ca.fecha) as char),2,'0')) as fechap, ". |
||
| 670 | " CASE WHEN ncfc.total_servicios < 0 THEN ncfc.total_servicios*-1 ELSE ncfc.total_servicios END AS total_servicios, " |
||
| 671 | . " CASE WHEN ncfc.total_bienes < 0 THEN ncfc.total_bienes*-1 ELSE ncfc.total_bienes END AS total_bienes, " |
||
| 672 | . "CASE WHEN fp.coddivisa != 'DOP' AND fp.neto < 0 " |
||
| 673 | . "THEN round(((fp.neto)*-1 / (select tasaconv from divisas as div1 where div1.coddivisa = fp.coddivisa) * 1) / 1 * (select tasaconv from divisas as div2 where div2.coddivisa = 'DOP'),2) " |
||
| 674 | . "WHEN fp.coddivisa != 'DOP' AND fp.neto > 0 " |
||
| 675 | . "THEN round((fp.neto / (select tasaconv from divisas as div1 where div1.coddivisa = fp.coddivisa) * 1) / 1 * (select tasaconv from divisas as div2 where div2.coddivisa = 'DOP'),2) " |
||
| 676 | . "WHEN fp.coddivisa = 'DOP' AND fp.neto < 0 " |
||
| 677 | . " THEN fp.neto*-1 " |
||
| 678 | . "ELSE fp.neto END as totalfacturado, " |
||
| 679 | . "CASE WHEN fp.coddivisa != 'DOP' AND fp.totaliva < 0 " |
||
| 680 | . "THEN round(((fp.totaliva)*-1 / (select tasaconv from divisas as div1 where div1.coddivisa = fp.coddivisa) * 1) / 1 * (select tasaconv from divisas as div2 where div2.coddivisa = 'DOP'),2) " |
||
| 681 | . "WHEN fp.coddivisa != 'DOP' AND fp.totaliva > 0 " |
||
| 682 | . "THEN round((fp.totaliva / (select tasaconv from divisas as div1 where div1.coddivisa = fp.coddivisa) * 1) / 1 * (select tasaconv from divisas as div2 where div2.coddivisa = 'DOP'),2) " |
||
| 683 | . "WHEN fp.coddivisa = 'DOP' AND fp.totaliva < 0 " |
||
| 684 | . " THEN fp.totaliva*-1 " |
||
| 685 | . "ELSE fp.totaliva END as totaliva, " |
||
| 686 | . " 0 as totalivaretenido, 0 as totalivasujeto, 0 as totalivallevadocosto, ". |
||
| 687 | " 0 as totalivaporadelantar, 0 as totalivapercibidocompras, '' as tiporetencionisr, 0 as totalretencionrenta,0 as totalisrpercibidocompra, 0 as totalisc, ". |
||
| 688 | " 0 as totalotrosimpuestos, 0 as totalpropinalegal, CONCAT(ncftpc.codigo,' - ',ncftpc.descripcion) as codpago ". |
||
| 689 | " FROM facturasprov as fp ". |
||
| 690 | " JOIN proveedores as p on (fp.codproveedor = p.codproveedor) ". |
||
| 691 | " left JOIN ncf_compras as ncfc on (fp.idfactura = ncfc.documento) ". |
||
| 692 | " left JOIN ncf_tipo_compras as ncftc on (ncfc.tipo_compra = ncftc.codigo) ". |
||
| 693 | " left JOIN ncf_tipo_pagos_compras as ncftpc on (ncfc.tipo_pago = ncftpc.codigo) ". |
||
| 694 | " left join facturasprov as fp2 on (fp.idfacturarect = fp2.idfactura) ". |
||
| 695 | " left join co_asientos as ca on (fp.idasientop = ca.idasiento AND fp.codejercicio = ca.codejercicio) ". |
||
| 696 | " WHERE fp.fecha between ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_inicio))). |
||
| 697 | " AND ".$this->empresa->var2str(\date("Y-m-d", strtotime($this->fecha_fin))). |
||
| 698 | " AND fp.codalmacen IN ('".$almacenes."') AND fp.anulada = FALSE". |
||
| 699 | " ORDER BY fp.codalmacen,fp.".$this->sort." ".$this->order; |
||
| 700 | $sql_cantidad = "SELECT count(*) as total FROM ( ".$sql_606." ) as t1;"; |
||
| 701 | $data_cantidad = $this->db->select($sql_cantidad); |
||
| 702 | $sql_resumen = "SELECT sum(totaliva) as totaliva, ". |
||
| 703 | " sum(totalfacturado) as totalneto FROM (". |
||
| 704 | $sql_606.") as t1;"; |
||
| 705 | $data_resumen = $this->db->select($sql_resumen); |
||
| 706 | if ($json) { |
||
| 707 | $resultados = $this->db->select_limit($sql_606, $this->limit, $this->offset); |
||
| 708 | } else { |
||
| 709 | $resultados = $this->db->select($sql_606); |
||
| 710 | $this->totalDocumentos += $data_cantidad[0]['total']; |
||
| 711 | $this->totalItbis += $data_resumen[0]['totaliva']; |
||
| 712 | $this->totalNeto += $data_resumen[0]['totalneto']; |
||
| 713 | } |
||
| 714 | $total_informacion+=$data_cantidad[0]['total']; |
||
| 715 | return array($resultados, $total_informacion); |
||
| 716 | } |
||
| 717 | |||
| 718 | public function dgii606() |
||
| 719 | { |
||
| 720 | $this->totalDocumentos = 0; |
||
| 721 | $this->totalNeto = 0; |
||
| 722 | $this->totalItbis = 0; |
||
| 723 | $this->resultados_606 = array(); |
||
| 724 | $this->resultados_606 = $this->datos_reporte($this->reporte); |
||
| 725 | $this->total_resultados_606 = 0; |
||
| 726 | $this->generar_excel( |
||
| 727 | array('RNC/Cédula','Tipo Id','Tipo Compra','NCF','NCF Modifica','Fecha Documento','Fecha Pago','Total Servicios','Total Bienes','Total Facturado','ITBIS Facturado','ITBIS Retenido','ITBIS sujeto a Proporcionalidad (Art. 349)','ITBIS llevado al Costo','ITBIS por Adelantar','ITBIS percibido en compras','Tipo de Retención en ISR','Monto Retencion Renta','ISR Percibido en compras','Impuesto Selectivo al Consumo','Otros Impuestos/Tasas','Monto Propina Legal','Forma de Pago'), |
||
| 728 | $this->resultados_606, |
||
| 729 | false, |
||
| 730 | false, |
||
| 731 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'left')), |
||
| 732 | false |
||
| 733 | ); |
||
| 734 | } |
||
| 735 | |||
| 736 | public function reporte607($almacenes, $json) |
||
| 795 | } |
||
| 796 | |||
| 797 | public function dgii607() |
||
| 798 | { |
||
| 799 | $this->totalDocumentos = 0; |
||
| 800 | $this->totalNeto = 0; |
||
| 801 | $this->totalItbis = 0; |
||
| 802 | $this->resultados_607 = array(); |
||
| 803 | $this->resultados_607 = $this->datos_reporte($this->reporte); |
||
| 804 | $this->total_resultados_607 = 0; |
||
| 805 | $this->generar_excel( |
||
| 806 | array('RNC/Cédula','Tipo Id','NCF','NCF Modifica','Tipo de Ingreso','Fecha Comprobante','Fecha Retención','Monto Facturado','ITBIS Facturado','ITBIS Retenido por Terceros','ITBIS Percibido','Retención Renta por Terceros','ISR Percibido','Impuesto Selectivo al Consumo','Otros Impuestos/Tasas','Monto Propina Legal','Efectivo','Cheque/Transferencia/Depósito','Tarjeta Débito/Crédito','Venta a Crédito','Bonos o Certificados de Regalo','Permuta','Otras Formas de Ventas','Estado','F. Pago'), |
||
| 807 | $this->resultados_607, |
||
| 808 | array('Total',count($this->resultados_607).' Documentos','','','','','','','','','','','','','','','','','','','','','','',''), |
||
| 809 | false, |
||
| 810 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'), |
||
| 811 | array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'), |
||
| 812 | array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'), |
||
| 813 | array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'right'), |
||
| 814 | array('halign'=>'right'),array('halign'=>'right'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'), |
||
| 815 | array('halign'=>'left')), |
||
| 816 | false |
||
| 817 | ); |
||
| 818 | } |
||
| 819 | |||
| 820 | public function reporte608($almacenes, $json) |
||
| 841 | } |
||
| 842 | |||
| 843 | public function dgii608() |
||
| 844 | { |
||
| 845 | $this->totalDocumentos = 0; |
||
| 846 | $this->resultados_608 = array(); |
||
| 847 | $this->resultados_608 = $this->datos_reporte($this->reporte); |
||
| 848 | $this->total_resultados_608 = 0; |
||
| 849 | $this->generar_excel( |
||
| 850 | array('NCF','Fecha','Motivo','Estado'), |
||
| 851 | $this->resultados_608, |
||
| 852 | array('Total',count($this->resultados_608).' Documentos','',''), |
||
| 853 | false, |
||
| 854 | array(array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left'),array('halign'=>'left')), |
||
| 855 | false |
||
| 856 | ); |
||
| 857 | } |
||
| 858 | |||
| 859 | public function facturas_proveedor($desde, $hasta, $codalmacen) |
||
| 860 | { |
||
| 861 | $lista = array(); |
||
| 862 | $sql = "SELECT * FROM facturasprov ". |
||
| 863 | " WHERE codalmacen = ".$this->empresa->var2str($codalmacen). |
||
| 864 | " AND fecha between ".$this->empresa->var2str($desde)." AND ".$this->empresa->var2str($hasta). |
||
| 865 | " ORDER BY fecha, idfactura;"; |
||
| 866 | $data = $this->db->select($sql); |
||
| 867 | if ($data) { |
||
| 868 | foreach ($data as $d) { |
||
| 869 | $item = new factura_proveedor($d); |
||
| 870 | $lista[] = $item; |
||
| 871 | } |
||
| 872 | } |
||
| 873 | return $lista; |
||
| 874 | } |
||
| 875 | |||
| 876 | public function factura_modifica_proveedor($idfactura) |
||
| 877 | { |
||
| 878 | $sql = "SELECT idfactura,numproveedor from facturasprov WHERE idfactura = ".$this->empresa->intval($idfactura); |
||
| 879 | return $this->db->select($sql); |
||
| 880 | } |
||
| 881 | |||
| 882 | /** |
||
| 883 | * |
||
| 884 | * @param type $cabecera |
||
| 885 | * @param type $datos |
||
| 886 | * @param type $pie |
||
| 887 | * @param type $estilo_cab |
||
| 888 | * @param type $estilo_datos |
||
| 889 | * @param type $estilo_pie |
||
| 890 | */ |
||
| 891 | public function generar_excel($cabecera, $datos, $pie, $estilo_cab, $estilo_datos, $estilo_pie) |
||
| 892 | { |
||
| 893 | if ($datos) { |
||
| 894 | //Revisamos que no haya un archivo ya cargado |
||
| 895 | $archivo = str_replace("-", "_", $this->reporte); |
||
| 896 | $this->archivoXLSX = $this->exportDir . DIRECTORY_SEPARATOR . $archivo . "_" . $this->user->nick . ".xlsx"; |
||
| 897 | $this->archivoXLSXPath = $this->publicPath . DIRECTORY_SEPARATOR . $archivo . "_" . $this->user->nick . ".xlsx"; |
||
| 898 | if (file_exists($this->archivoXLSX)) { |
||
| 899 | unlink($this->archivoXLSX); |
||
| 900 | } |
||
| 901 | //Variables para cada parte del excel |
||
| 902 | $estilo_cabecera = ($estilo_cab)?$estilo_cab:array('border'=>'left,right,top,bottom','font-style'=>'bold'); |
||
| 903 | $estilo_cuerpo = ($estilo_datos)?$estilo_datos:array('halign'=>'none'); |
||
| 904 | $estilo_footer = ($estilo_pie)?$estilo_pie:array('border'=>'left,right,top,bottom','font-style'=>'bold','color'=>'#FFFFFF','fill'=>'#000000'); |
||
| 905 | //Inicializamos la clase |
||
| 906 | $this->writer = new XLSXWriter(); |
||
| 907 | $this->writer->setAuthor('FacturaScripts '.\date('Y-m-d H:i:s')); |
||
| 908 | $nombre_hoja = ucfirst(str_replace('-', ' ', $this->reporte)); |
||
| 909 | $this->writer->writeSheetHeader($nombre_hoja, array(), true); |
||
| 910 | $this->writer->writeSheetRow($nombre_hoja, $cabecera, $estilo_cabecera); |
||
| 911 | foreach ($datos as $linea) { |
||
| 912 | $this->writer->writeSheetRow($nombre_hoja, (array) $linea, $estilo_cuerpo); |
||
| 913 | } |
||
| 914 | |||
| 915 | if (!empty($pie)) { |
||
| 916 | $this->writer->writeSheetRow($nombre_hoja, (array) $pie, $estilo_footer); |
||
| 917 | } |
||
| 918 | $this->writer->writeToFile($this->archivoXLSX); |
||
| 919 | } |
||
| 920 | } |
||
| 921 | |||
| 922 | private function share_extensions() |
||
| 923 | { |
||
| 924 | $extensiones = array( |
||
| 925 | array( |
||
| 926 | 'name' => '001_informes_fiscales_js', |
||
| 927 | 'page_from' => __CLASS__, |
||
| 928 | 'page_to' => __CLASS__, |
||
| 929 | 'type' => 'head', |
||
| 930 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/plugins/validator.min.js" type="text/javascript"></script>', |
||
| 931 | 'params' => '' |
||
| 932 | ), |
||
| 933 | array( |
||
| 934 | 'name' => '002_informes_fiscales_js', |
||
| 935 | 'page_from' => __CLASS__, |
||
| 936 | 'page_to' => __CLASS__, |
||
| 937 | 'type' => 'head', |
||
| 938 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/bootstrap-select.min.js" type="text/javascript"></script>', |
||
| 939 | 'params' => '' |
||
| 940 | ), |
||
| 941 | array( |
||
| 942 | 'name' => '003_informes_fiscales_js', |
||
| 943 | 'page_from' => __CLASS__, |
||
| 944 | 'page_to' => __CLASS__, |
||
| 945 | 'type' => 'head', |
||
| 946 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/bootstrap-table.min.js" type="text/javascript"></script>', |
||
| 947 | 'params' => '' |
||
| 948 | ), |
||
| 949 | array( |
||
| 950 | 'name' => '004_informes_fiscales_js', |
||
| 951 | 'page_from' => __CLASS__, |
||
| 952 | 'page_to' => __CLASS__, |
||
| 953 | 'type' => 'head', |
||
| 954 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/locale/bootstrap-table-es-MX.min.js" type="text/javascript"></script>', |
||
| 955 | 'params' => '' |
||
| 956 | ), |
||
| 957 | array( |
||
| 958 | 'name' => '005_informes_fiscales_js', |
||
| 959 | 'page_from' => __CLASS__, |
||
| 960 | 'page_to' => __CLASS__, |
||
| 961 | 'type' => 'head', |
||
| 962 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/plugins/bootstrap-table-filter.min.js" type="text/javascript"></script>', |
||
| 963 | 'params' => '' |
||
| 964 | ), |
||
| 965 | array( |
||
| 966 | 'name' => '006_informes_fiscales_js', |
||
| 967 | 'page_from' => __CLASS__, |
||
| 968 | 'page_to' => __CLASS__, |
||
| 969 | 'type' => 'head', |
||
| 970 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/plugins/bootstrap-table-toolbar.min.js" type="text/javascript"></script>', |
||
| 971 | 'params' => '' |
||
| 972 | ), |
||
| 973 | array( |
||
| 974 | 'name' => '007_informes_fiscales_js', |
||
| 975 | 'page_from' => __CLASS__, |
||
| 976 | 'page_to' => __CLASS__, |
||
| 977 | 'type' => 'head', |
||
| 978 | 'text' => '<script src="' . FS_PATH . 'plugins/republica_dominicana/view/js/plugins/bootstrap-table-mobile.min.js" type="text/javascript"></script>', |
||
| 979 | 'params' => '' |
||
| 980 | ), |
||
| 981 | array( |
||
| 982 | 'name' => '001_informes_fiscales_css', |
||
| 983 | 'page_from' => __CLASS__, |
||
| 984 | 'page_to' => __CLASS__, |
||
| 985 | 'type' => 'head', |
||
| 986 | 'text' => '<link rel="stylesheet" type="text/css" media="screen" href="' . FS_PATH . 'plugins/republica_dominicana/view/css/bootstrap-select.min.css"/>', |
||
| 987 | 'params' => '' |
||
| 988 | ), |
||
| 989 | |||
| 990 | array( |
||
| 991 | 'name' => '002_informes_fiscales_css', |
||
| 992 | 'page_from' => __CLASS__, |
||
| 993 | 'page_to' => __CLASS__, |
||
| 994 | 'type' => 'head', |
||
| 995 | 'text' => '<link rel="stylesheet" type="text/css" media="screen" href="' . FS_PATH . 'plugins/republica_dominicana/view/css/bootstrap-table.min.css"/>', |
||
| 996 | 'params' => '' |
||
| 997 | ), |
||
| 998 | ); |
||
| 999 | |||
| 1000 | foreach ($extensiones as $ext) { |
||
| 1001 | $fext = new fs_extension($ext); |
||
| 1002 | if (!$fext->save()) { |
||
| 1003 | $this->new_error_msg('Imposible guardar los datos de la extensión ' . $ext['name'] . '.'); |
||
| 1004 | } |
||
| 1005 | } |
||
| 1006 | } |
||
| 1007 | |||
| 1008 | /** |
||
| 1009 | * @url http://snippets.khromov.se/convert-comma-separated-values-to-array-in-php/ |
||
| 1010 | * @param $string - Input string to convert to array |
||
| 1011 | * @param string $separator - Separator to separate by (default: ,) |
||
| 1012 | * |
||
| 1013 | * @return array |
||
| 1014 | */ |
||
| 1015 | private function comma_separated_to_array($string, $separator = ',') |
||
| 1027 | } |
||
| 1028 | } |
||
| 1029 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths