public function seguroAction() { //Conectamos a BBDD $sid = new Container('base'); $db_name = $sid->offsetGet('dbNombre'); $id_db = $sid->offsetGet('id_db'); $this->dbAdapter = $this->getServiceLocator()->get($db_name); //Tablas y formularios $seg = new SeguroTable($this->dbAdapter); $fon = new FondosTable($this->dbAdapter); $cob = new CobroTable($this->dbAdapter); $tegr = new TipoEgresoTable($this->dbAdapter); $prov = new ProveedorTable($this->dbAdapter); $form = new SeguroForm("form"); //Obtenemos Datos $seguros = $seg->getDatos(); $fondo = $fon->getFondoOper(); $tipo_egreso = $tegr->getTipoNombre("Seguros y Otros"); $proveedores = $prov->getProveedoresCombo($this->dbAdapter); //Cargamos form con datos para el egreso $form->get('origen')->setAttribute('value', $fondo[0]['id']); $form->get('id_tipo_egreso')->setAttribute('value', $tipo_egreso[0]['id']); $form->get('id_proveedor')->setAttribute('options', $proveedores); //Construimos tabla de Seguros $tabla = ""; $ruta = '/files/db/' . $id_db . '/admin/infocom/seguro/'; for ($i = 0; $i < count($seguros); $i++) { if ($seguros[$i]['estado'] == '1') { $estado = "Activo"; } else { $estado = "Finalizado"; } $pf = strtotime($seguros[$i]['vigenciafin']); $mostrarF = date("d-M-Y", $pf); $prox_cuota = $cob->getCobroIdEgreso($seguros[$i]['id_egreso']); $tabla = $tabla . "<tr>\r\n <td align='left'>" . $seguros[$i]['poliza'] . "</td>\r\n <td align='left'>" . $seguros[$i]['riesgo'] . "</td>\r\n <td align='left'>\$ " . number_format($seguros[$i]['valor_prima'], "0", ".", ".") . "</td>\r\n <td align='left'>" . $prox_cuota[0]['cuota'] . "/" . $seguros[$i]['cuotas'] . "</td>\r\n <td align='left'>" . $mostrarF . "</td>\r\n <td align='left'>" . $estado . "</td>\r\n <td align='left'><a target='_blank' href='" . $ruta . $seguros[$i]['url_poliza'] . "'><i class='fa fa-file'></i></td>\r\n </tr>"; } $result = new JsonModel(array('status' => 'ok', 'tabla' => $tabla)); $result->setTerminal(true); return $result; }
public function guardarfondoresAction() { //Obtenemos datos post $lista = $this->request->getPost(); // Actualizamos datos en la tabla $sid = new Container('base'); $db_name = $sid->offsetGet('dbNombre'); $this->dbAdapter = $this->getServiceLocator()->get($db_name); $cuenta = new FondosTable($this->dbAdapter); //Quitamos formato RUT $lista['rut'] = explode("-", $lista['rut']); $lista['dv'] = $lista['rut'][1]; $lista['rut'] = str_replace(".", "", $lista['rut'][0]); //Quitamos . de saldo $lista['saldo'] = str_replace('.', '', $lista['saldo']); // Validamos si es Insert o Update if ($lista['id_pk'] > 0) { $cuenta->guardarFondo($lista['id_pk'], $lista); $descripcion = "Edición de Fondo de Reserva exitosa"; } else { $cuenta->nuevoFondo($lista); $descripcion = "Fondo de Reserva creado exitosamente en el sistema"; } $result = new JsonModel(array('status' => 'ok', 'descripcion' => $descripcion)); return $result; }
public function editaractivoAction() { //Conectamos con BBDD $sid = new Container('base'); $db_name = $sid->offsetGet('dbNombre'); $this->dbAdapter = $this->getServiceLocator()->get($db_name); //Obtenemos datos POST $data = $this->getRequest()->getPost(); //Instancias $invt = new InventarioTable($this->dbAdapter); $fond = new FondosTable($this->dbAdapter); $prov = new ProveedorTable($this->dbAdapter); $form = new ActivoForm("form"); if ($data['id_pk'] > 0) { //Guardamos en BBDD $invt->editarActivo($data['id_pk'], $data); //Retornamos a la vista $descripcion = 'Cambios guardados exitosamente'; $result = new JsonModel(array('status' => 'ok', 'descripcion' => $descripcion)); $result->setTerminal(true); return $result; } //Obtenemos activo con id $activo = $invt->getActivoId($data['id']); //Obtenemos datos de combos $fondo = $fond->getFondoId($activo[0]['id_fondo']); $combo = array($fondo[0]['id'] => $fondo[0]['nombre']); //Cargamos combo proveedor if ($activo[0]['area_responsable'] == "proveedor") { $proveedores = $prov->getProveedoresCombo($this->dbAdapter); $form->get('responsable')->setAttribute('options', $proveedores); $value = array_search($activo[0]['responsable'], $proveedores); $form->get('responsable')->setAttribute('value', $value); } //Cargamos codigo interno del inventario $activo[0]['codigo_interno'] = "10" . $activo[0]['id'] * 2; //Cargamos formulario $form->get('id_pk')->setAttribute('value', $activo[0]['id']); $form->get('nombre')->setAttribute('value', $activo[0]['nombre']); $form->get('id_fondo')->setAttribute('options', $combo); $form->get('valor')->setAttribute('value', $activo[0]['valor']); $form->get('cantidad')->setAttribute('value', $activo[0]['cantidad']); $form->get('area_responsable')->setAttribute('value', $activo[0]['area_responsable']); $form->get('estado')->setAttribute('value', $activo[0]['estado']); $form->get('factura')->setAttribute('value', $activo[0]['factura']); $form->get('fecha')->setAttribute('value', $activo[0]['fecha']); $form->get('send')->setAttribute('value', "Editar activo"); $form->get('marca')->setAttribute('value', $activo[0]['marca']); $form->get('modelo')->setAttribute('value', $activo[0]['modelo']); $form->get('nmro_serie')->setAttribute('value', $activo[0]['nmro_serie']); $form->get('ubicacion')->setAttribute('value', $activo[0]['ubicacion']); $form->get('observacion')->setAttribute('value', $activo[0]['observacion']); //Retornamos a la vista $result = new ViewModel(array('form' => $form, 'activo' => $activo)); $result->setTerminal(true); return $result; }