public function execute()
 {
     try {
         $where = null;
         if (request::getInstance()->hasPost('filter')) {
             $filter = request::getInstance()->getPost('filter');
             if (isset($filter['fecha_fin']) and $filter['fecha_fin'] !== null and $filter['fecha_fin'] !== '' and isset($filter['fecha_inicio']) and $filter['fecha_inicio'] !== null and $filter['fecha_inicio'] !== '') {
                 $where[entradaBodegaTableClass::getNameTable() . '.' . entradaBodegaTableClass::FECHA] = array(date(config::getFormatTimestamp(), strtotime($filter['fecha_inicio'] . ' 00.00.00')), date(config::getFormatTimestamp(), strtotime($filter['fecha_fin'] . ' 23.59.59')));
             }
             //                if (isset($filter['fecha']) and $filter['fecha'] !== null and $filter['fecha'] !== '') {
             //                    $where[entradaBodegaTableClass::FECHA] = $filter['fecha'];
             //                }//close if
             if (isset($filter['empleado']) and $filter['empleado'] !== null and $filter['empleado'] !== '') {
                 $where[entradaBodegaTableClass::EMPLEADO] = $filter['empleado'];
             }
             //close if
             session::getInstance()->setAttribute('entradaFilter', $where);
         } elseif (session::getInstance()->hasAttribute('entradaFilter')) {
             $where = session::getInstance()->getAttribute('entradaFilter');
         }
         //close if
         $fieldsEntrada = array(entradaBodegaTableClass::ID, entradaBodegaTableClass::FECHA, entradaBodegaTableClass::EMPLEADO, entradaBodegaTableClass::ESTADO);
         $fieldsEmpleado = array(empleadoTableClass::NOMBRE);
         $fieldsEmpleado2 = array(empleadoTableClass::NOMBRE, empleadoTableClass::ID);
         $fJoin1 = entradaBodegaTableClass::EMPLEADO;
         $fJoin2 = empleadoTableClass::ID;
         $orderBy = array(entradaBodegaTableClass::ID);
         $fieldsInsumo = array(insumoTableClass::ID, insumoTableClass::NOMBRE);
         $fieldsTipoInsumo = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
         $page = 0;
         if (request::getInstance()->hasGet('page')) {
             $page = request::getInstance()->getGet('page') - 1;
             $page = $page * config::getRowGrid();
         }
         //close if
         $f = array(entradaBodegaTableClass::ID);
         $lines = config::getRowGrid();
         $this->cntPages = entradaBodegaTableClass::getAllCount($f, true, $lines, $where);
         if (request::getInstance()->hasGet('page')) {
             $this->page = request::getInstance()->getGet('page');
         } else {
             $this->page = $page;
         }
         //close if
         $this->objTipoInsumo = tipoInsumoTableClass::getAll($fieldsTipoInsumo, false);
         $this->objInsumo = insumoTableClass::getAll($fieldsInsumo, true);
         $this->objEmpleado = empleadoTableClass::getAll($fieldsEmpleado2, false);
         $this->objEntradaBodega = entradaBodegaTableClass::getAllJoin($fieldsEntrada, $fieldsEmpleado, null, null, $fJoin1, $fJoin2, null, null, null, null, true, $orderBy, 'ASC', config::getRowGrid(), $page, $where);
         log::register(i18n::__('ver', null, 'bodega'), entradaBodegaTableClass::getNameTable());
         $this->defineView('index', 'entradaBodega', session::getInstance()->getFormatOutput());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         $fields = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
         $this->objTipoInsumo = tipoInsumoTableClass::getAll($fields, false);
         $this->defineView('insert', 'insumo', session::getInstance()->getFormatOutput());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         if (request::getInstance()->hasRequest(insumoTableClass::ID)) {
             $fields = array(insumoTableClass::ID, insumoTableClass::NOMBRE, insumoTableClass::FECHA_FABRICACION, insumoTableClass::FECHA_VENCIMIENTO, insumoTableClass::TIPO_INSUMO, insumoTableClass::VALOR, insumoTableClass::CANTIDAD, insumoTableClass::STOCK_MINIMO);
             $where = array(insumoTableClass::ID => request::getInstance()->getRequest(insumoTableClass::ID));
             $fieldsTipo = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
             $this->objTipoInsumo = tipoInsumoTableClass::getAll($fieldsTipo, false);
             $this->objInsumo = insumoTableClass::getAll($fields, false, null, null, null, null, $where);
             $this->defineView('edit', 'insumo', session::getInstance()->getFormatOutput());
         }
         //else {
         //   routing::getInstance()->redirect('insumo', 'index');
         //  }//close if
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         if (request::getInstance()->hasRequest(detalleEntradaBodegaTableClass::ID)) {
             $fields = array(detalleEntradaBodegaTableClass::ID, detalleEntradaBodegaTableClass::ID_ENTRADA, detalleEntradaBodegaTableClass::TIPO_INSUMO, detalleEntradaBodegaTableClass::ID_INSUMO, detalleEntradaBodegaTableClass::CANDITDAD);
             $where = array(detalleEntradaBodegaTableClass::ID => request::getInstance()->getRequest(detalleEntradaBodegaTableClass::ID));
             $fieldsTipo = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
             $fieldsInsumo = array(insumoTableClass::ID, insumoTableClass::NOMBRE);
             $fieldsEntrada = array(entradaBodegaTableClass::ID);
             $this->objTipo = tipoInsumoTableClass::getAll($fieldsTipo, true);
             $this->objEntrada = entradaBodegaTableClass::getAll($fieldsEntrada, true);
             $this->objInsumo = insumoTableClass::getAll($fieldsInsumo, true);
             $this->objDetalleEntrada = detalleEntradaBodegaTableClass::getAll($fields, true, null, null, null, null, $where);
             $this->defineView('edit', 'detalleEntradaBodega', session::getInstance()->getFormatOutput());
         } else {
             routing::getInstance()->redirect('bodega', 'indexDetalleEntrada');
         }
         //close if
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         $where = null;
         if (request::getInstance()->hasPost('filter')) {
             $filter = request::getInstance()->getPost('filter');
             if (isset($filter['nombre']) and $filter['nombre'] !== null and $filter['nombre'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::NOMBRE] = $filter['nombre'];
             }
             //close if
             if (isset($filter['fabricacionInicial']) and $filter['fabricacionInicial'] !== null and $filter['fabricacionInicial'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::FECHA_FABRICACION] = $filter['fabricacionInicial'];
             }
             //close if
             if (isset($filter['VencimientoInicial']) and $filter['VencimientoInicial'] !== null and $filter['VencimientoInicial'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::FECHA_VENCIMIENTO] = $filter['VencimientoInicial'];
             }
             //close if
             if (isset($filter['tipoInsumo']) and $filter['tipoInsumo'] !== null and $filter['tipoInsumo'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::TIPO_INSUMO] = $filter['tipoInsumo'];
             }
             //close if
             if (isset($filter['valor']) and $filter['valor'] !== null and $filter['valor'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::VALOR] = $filter['valor'];
             }
             //close if
             if (isset($filter['cantidad']) and $filter['cantidad'] !== null and $filter['cantidad'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::CANTIDAD] = $filter['cantidad'];
             }
             //close if
             if (isset($filter['stock']) and $filter['stock'] !== null and $filter['stock'] !== '') {
                 $where[insumoTableClass::getNameTable() . '.' . insumoTableClass::STOCK_MINIMO] = $filter['stock'];
             }
             //close if
             session::getInstance()->setAttribute('vacunacionFiltersAInsumo', $where);
         } elseif (session::getInstance()->hasAttribute('vacunacionFiltersAInsumo')) {
             $where = session::getInstance()->getAttribute('vacunacionFiltersAInsumo');
         }
         //close if
         $page = 0;
         if (request::getInstance()->hasGet('page')) {
             $page = request::getInstance()->getGet('page') - 1;
             $page = $page * config::getRowGrid();
         }
         //close if
         $f = array(insumoTableClass::ID);
         $lines = config::getRowGrid();
         $this->cntPages = insumoTableClass::getAllCount($f, true, $lines, $where);
         if (request::getInstance()->hasGet('page')) {
             $this->page = request::getInstance()->getGet('page');
         } else {
             $this->page = $page;
         }
         //close if
         $fieldsTipoInsumo = array(tipoInsumoTableClass::DESCRIPCION);
         $fieldsInsumo = array(insumoTableClass::ID, insumoTableClass::NOMBRE, insumoTableClass::FECHA_FABRICACION, insumoTableClass::FECHA_VENCIMIENTO, insumoTableClass::TIPO_INSUMO, insumoTableClass::VALOR, insumoTableClass::CANTIDAD, insumoTableClass::STOCK_MINIMO);
         $orderBy = array(insumoTableClass::ID);
         $fJoin1 = insumoTableClass::TIPO_INSUMO;
         $fJoin2 = tipoInsumoTableClass::ID;
         $fieldsTipo = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
         $objInsumo = insumoTableClass::getAllJoin($fieldsInsumo, $fieldsTipoInsumo, null, null, $fJoin1, $fJoin2, null, null, null, null, true, $orderBy, 'ASC', config::getRowGrid(), $page, $where);
         foreach ($objInsumo as $key) {
             if ($key->cantidad < $key->stock_minimo and $key->cantidad >= 1) {
                 session::getInstance()->setWarning("El insumo " . $key->nombre_insumo . " " . "esta a punto de agotarse " . "le quedan " . $key->cantidad . " " . "y " . "su cantidad minima es de " . $key->stock_minimo);
             } elseif ($key->cantidad < $key->stock_minimo) {
                 session::getInstance()->setWarning("El insumo " . $key->nombre_insumo . " " . "se ha agotado");
             }
         }
         $this->objTipoInsumo = tipoInsumoTableClass::getAll($fieldsTipo, false);
         $this->objInsumo = insumoTableClass::getAllJoin($fieldsInsumo, $fieldsTipoInsumo, null, null, $fJoin1, $fJoin2, null, null, null, null, true, $orderBy, 'ASC', config::getRowGrid(), $page, $where);
         log::register(i18n::__('ver', null, 'insumo'), insumoTableClass::getNameTable());
         $this->defineView('index', 'insumo', session::getInstance()->getFormatOutput());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         $where = null;
         if (request::getInstance()->hasPost('filter')) {
             $filter = request::getInstance()->getPost('filter');
             if (isset($filter['fecha_fin']) and $filter['fecha_fin'] !== null and $filter['fecha_fin'] !== '' and isset($filter['fecha_inicio']) and $filter['fecha_inicio'] !== null and $filter['fecha_inicio'] !== '') {
                 $where[procesoCompraTableClass::getNameTable() . '.' . procesoCompraTableClass::FECHA_HORA_COMPRA] = array($filter['fecha_inicio'], $filter['fecha_fin']);
                 if (isset($filter['empleado']) and $filter['empleado'] !== null and $filter['empleado'] !== '') {
                     $where[procesoCompraTableClass::EMPLEADO_ID] = $filter['empleado'];
                 }
                 //close if
                 if (isset($filter['proveedor']) and $filter['proveedor'] !== null and $filter['proveedor'] !== '') {
                     $where[procesoCompraTableClass::PROVEEDOR_ID] = $filter['proveedor'];
                 }
                 //close if
             }
             //close if
             session::getInstance()->setAttribute('facturaCompraFilter', $where);
         } elseif (session::getInstance()->hasAttribute('facturaCompraFilter')) {
             $where = session::getInstance()->getAttribute('facturaCompraFilter');
         }
         //close if
         $fieldsEmple = array(empleadoTableClass::ID, empleadoTableClass::NOMBRE);
         $fieldsProve = array(proveedorTableClass::ID, proveedorTableClass::NOMBRE);
         $fieldsFacturaCompra = array(procesoCompraTableClass::ID, procesoCompraTableClass::FECHA_HORA_COMPRA, procesoCompraTableClass::EMPLEADO_ID, procesoCompraTableClass::PROVEEDOR_ID, procesoCompraTableClass::NUMERO, procesoCompraTableClass::ACTIVA);
         $fieldsEmpleado = array(empleadoTableClass::NOMBRE);
         $fieldsProveedor = array(proveedorTableClass::NOMBRE);
         $fJoin1 = procesoCompraTableClass::EMPLEADO_ID;
         $fJoin2 = empleadoTableClass::ID;
         $fJoin3 = procesoCompraTableClass::PROVEEDOR_ID;
         $fJoin4 = proveedorTableClass::ID;
         $orderBy = array(procesoCompraTableClass::FECHA_HORA_COMPRA);
         $fieldsInsumo = array(insumoTableClass::ID, insumoTableClass::NOMBRE);
         $this->objInsumo = insumoTableClass::getAll($fieldsInsumo, true);
         $fieldsEmpleados = array(empleadoTableClass::ID, empleadoTableClass::NOMBRE);
         $this->objEmpleado = empleadoTableClass::getAll($fieldsEmpleados, true);
         $fieldsProveedores = array(proveedorTableClass::ID, proveedorTableClass::NOMBRE);
         $this->objProveedor = proveedorTableClass::getAll($fieldsProveedores, false);
         $fieldsTipoInsumo = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
         $this->objTipoInsumo = tipoInsumoTableClass::getAll($fieldsTipoInsumo, false);
         $page = 0;
         if (request::getInstance()->hasGet('page')) {
             $page = request::getInstance()->getGet('page') - 1;
             $page = $page * config::getRowGrid();
         }
         //close if
         $f = array(procesoCompraTableClass::ID);
         $lines = config::getRowGrid();
         $this->cntPages = procesoCompraTableClass::getAllCount($f, true, $lines, $where);
         if (request::getInstance()->hasGet('page')) {
             $this->page = request::getInstance()->getGet('page');
         } else {
             $this->page = $page;
         }
         //close if
         $this->objProveedor = proveedorTableClass::getAll($fieldsProve, true);
         $this->objEmpleado = empleadoTableClass::getAll($fieldsEmple, true);
         $this->objFacturaCompra = procesoCompraTableClass::getAllJoin($fieldsFacturaCompra, $fieldsEmpleado, $fieldsProveedor, null, $fJoin1, $fJoin2, $fJoin3, $fJoin4, null, null, true, $orderBy, 'ASC', config::getRowGrid(), $page, $where);
         log::register(i18n::__('ver', null, 'facturaCompra'), procesoCompraTableClass::getNameTable());
         $this->defineView('index', 'facturaCompra', session::getInstance()->getFormatOutput());
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }
 public function execute()
 {
     try {
         $where = null;
         //      if (request::getInstance()->hasRequest(entradaBodegaTableClass::ID)) {
         $idEntrada = request::getInstance()->getRequest(detalleEntradaBodegaTableClass::ID);
         $where = null;
         if (request::getInstance()->hasPost('filter')) {
             $filter = request::getInstance()->getPost('filter');
             if (isset($filter['tipoInsumo']) and $filter['tipoInsumo'] !== null and $filter['tipoInsumo'] !== '') {
                 $where[detalleEntradaBodegaTableClass::TIPO_INSUMO] = $filter['tipoInsumo'];
             }
             //close if
             if (isset($filter['Insumo']) and $filter['Insumo'] !== null and $filter['Insumo'] !== '') {
                 $where[detalleEntradaBodegaTableClass::ID_INSUMO] = $filter['Insumo'];
             }
             //close if
             if (isset($filter['cantidad']) and $filter['cantidad'] !== null and $filter['cantidad'] !== '') {
                 $where[detalleEntradaBodegaTableClass::getNameTable() . '.' . detalleEntradaBodegaTableClass::CANDITDAD] = $filter['cantidad'];
             }
             //close if
             $where[detalleEntradaBodegaTableClass::ID_ENTRADA] = $idEntrada;
             session::getInstance()->setAttribute('detalleEntrada', $where);
         } elseif (session::getInstance()->hasAttribute('detalleEntrada')) {
             $where = session::getInstance()->getAttribute('detalleEntrada');
         } else {
             $where = array(detalleEntradaBodegaTableClass::ID_ENTRADA => $idEntrada);
         }
         //close if
         $fieldsEntrada = array(entradaBodegaTableClass::ID, entradaBodegaTableClass::FECHA);
         $fieldsEmpleado = array(empleadoTableClass::NOMBRE);
         $whereEntrada = array(entradaBodegaTableClass::getNameTable() . '.' . entradaBodegaTableClass::ID => $idEntrada);
         $fJoinEntrada1 = entradaBodegaTableClass::EMPLEADO;
         $fJoinEntrada2 = empleadoTableClass::ID;
         $page = 0;
         if (request::getInstance()->hasGet('page')) {
             $page = request::getInstance()->getGet('page') - 1;
             $page = $page * config::getRowGrid();
         }
         //close if
         $f = array(detalleEntradaBodegaTableClass::ID);
         $whereCnt = array(detalleEntradaBodegaTableClass::ID_ENTRADA => $idEntrada);
         $lines = config::getRowGrid();
         $fieldsDetalleEntrada = array(detalleEntradaBodegaTableClass::ID, detalleEntradaBodegaTableClass::CANDITDAD, detalleEntradaBodegaTableClass::ID_ENTRADA);
         $fieldsDetalleInsumo = array(insumoTableClass::NOMBRE);
         $fieldsDetalleTipoInsumo = array(tipoInsumoTableClass::DESCRIPCION);
         $fJoin1 = detalleEntradaBodegaTableClass::ID_INSUMO;
         $fJoin2 = insumoTableClass::ID;
         $fJoin3 = detalleEntradaBodegaTableClass::TIPO_INSUMO;
         $fJoin4 = tipoInsumoTableClass::ID;
         $fieldsInsumo = array(insumoTableClass::ID, insumoTableClass::NOMBRE);
         $fieldsTipoInsumo = array(tipoInsumoTableClass::ID, tipoInsumoTableClass::DESCRIPCION);
         $this->objTipoInsumo = tipoInsumoTableClass::getAll($fieldsTipoInsumo, false);
         $this->objInsumo = insumoTableClass::getAll($fieldsInsumo, true);
         $this->cntPages = detalleEntradaBodegaTableClass::getAllCount($f, true, $lines, $whereCnt);
         $this->objEntrada = entradaBodegaTableClass::getAllJoin($fieldsEntrada, $fieldsEmpleado, null, null, $fJoinEntrada1, $fJoinEntrada2, null, null, null, null, true, null, null, config::getRowGrid(), $page, $whereEntrada);
         $this->objDetalleEntrada = detalleEntradaBodegaTableClass::getAllJoin($fieldsDetalleEntrada, $fieldsDetalleInsumo, $fieldsDetalleTipoInsumo, null, $fJoin1, $fJoin2, $fJoin3, $fJoin4, null, null, false, null, 'ASC', config::getRowGrid(), $page, $where);
         log::register(i18n::__('ver2', null, 'bodega'), detalleEntradaBodegaTableClass::getNameTable());
         $this->defineView('view', 'entradaBodega', session::getInstance()->getFormatOutput());
         //      } else {
         //        session::getInstance()->setError('pailas');
         //        routing::getInstance()->redirect('vacunacion', 'indexVacunacion');
         //      }//close if
     } catch (PDOException $exc) {
         session::getInstance()->setFlash('exc', $exc);
         routing::getInstance()->forward('shfSecurity', 'exception');
     }
 }