Ejemplo n.º 1
0
 public function pagartrabajadorAction()
 {
     //Variables BBDD
     $sid = new Container('base');
     $db_name = $sid->offsetGet('dbNombre');
     $this->dbAdapter = $this->getServiceLocator()->get($db_name);
     //Cargamos Clases
     $egt = new EgresoTrabajadorTable($this->dbAdapter);
     $egr = new EgresoTable($this->dbAdapter);
     $fop = new FondosTable($this->dbAdapter);
     //Obtenemos Datos
     $lista = $this->request->getPost();
     $lista['user_create'] = $sid->offsetGet('id_usuario');
     $lista['destino'] = $lista['trabajador'];
     //Quitamos formato a Montos
     $lista['montototal'] = str_replace(".", "", $lista['montototal']);
     $lista['leysocial'] = str_replace(".", "", $lista['leysocial']);
     $lista['sueldo'] = str_replace(".", "", $lista['sueldo']);
     //Registramos Egreso
     $lista['id_egreso'] = $egr->nuevoEgreso($lista);
     //Restamos monto de Fondo Origen
     $fop->restaFondo($this->dbAdapter, $lista['id_fondo'], $lista['montototal']);
     //Insertamos en tabla Egreso Trabajador
     $egt->nuevoEgresoTrabajador($lista);
     //Enviamos a la Vista
     $descripcion = "Se ha registrado correctamente el egreso";
     $result = new JsonModel(array('desc' => $descripcion));
     return $result;
 }
Ejemplo n.º 2
0
 public function guardarseguroAction()
 {
     //Obtenemos datos post
     $lista = $this->request->getPost();
     //Conectamos a BBDD
     $sid = new Container('base');
     $db_name = $sid->offsetGet('dbNombre');
     $lista['user_create'] = $sid->offsetGet('id_usuario');
     $this->dbAdapter = $this->getServiceLocator()->get($db_name);
     $seg = new SeguroTable($this->dbAdapter);
     $cob = new CobroTable($this->dbAdapter);
     $egr = new EgresoTable($this->dbAdapter);
     //Quitamos puntos al monto
     $lista['valor_prima'] = str_replace(".", "", $lista['valor_prima']);
     $lista['montototal'] = $lista['valor_prima'];
     // Validamos si es Insert o Update
     if ($lista['id_pk'] > 0) {
         $seg->actualizarSeguro($lista);
         $desc = "Edición de Seguros exitosa";
     } else {
         //Insertamos en Tablas de Egreso y Seguro
         $lista['foto'] = $lista['url_poliza'];
         $lista['id_egreso'] = $egr->nuevoEgreso($lista);
         $seg->nuevoSeguro($lista);
         //Si existen Cuotas se ingresan como Cobros Pendientes
         if ($lista['cuotas'] > 1) {
             for ($i = 1; $i < $lista['cuotas']; $i++) {
                 //Agregamos datos al array
                 $lista['valor'] = $lista['valor_prima'];
                 $lista['cuota'] = $i + 1;
                 $lista['fecha_cobro'] = date("Y/m/d", strtotime(date("Y/m/d") . " +{$i} month"));
                 $lista['desc'] = $lista['cuota'] . "/" . $lista['cuotas'];
                 $cob->nuevoCobro($lista);
                 $desc = 'Seguro ingresado exitosamente, se agregan ' . $lista['cuotas'] . ' cobros mensuales';
             }
         }
     }
     $lista = $seg->getDatos();
     $result = new JsonModel(array('status' => 'ok', 'descripcion' => $desc, 'seg' => $id_pk));
     return $result;
 }