public function pagargcAction() { //Variables BBDD $sid = new Container('base'); $db_name = $sid->offsetGet('dbNombre'); $this->dbAdapter = $this->getServiceLocator()->get($db_name); //Cargamos Clases $ing = new IngresoTable($this->dbAdapter); $gcu = new GCunidadTable($this->dbAdapter); $mul = new MultaTable($this->dbAdapter); $uni = new UnidadTable($this->dbAdapter); $fon = new FondosTable($this->dbAdapter); $abn = new AbonoTable($this->dbAdapter); //Obtenemos Datos $lista = $this->request->getPost(); $lista['user_create'] = $sid->offsetGet('id_usuario'); $id_uni = $uni->getIdUnidad($lista["origen"]); $lista['monto'] = str_replace(".", "", $lista['monto']); //Insertamos Datos if ($lista['tipo_pago'] == 'total') { if (count($lista['abono']) > 0) { $pagarabono = array_keys($lista['abono']); for ($i = 0; $i < count($pagarabono); $i++) { $abn->UsoAbono($pagarabono[$i]); } } $mul->pagoMultaTotal($this->dbAdapter, $id_uni[0]['id']); $gcu->pagoTotalGasto($this->dbAdapter, $id_uni[0]['id']); } else { if (count($lista['mes']) > 0) { $pagar = array_keys($lista['mes']); for ($i = 0; $i < count($pagar); $i++) { $gcu->pagoParcialGasto($pagar[$i]); } } if (count($lista['multa']) > 0) { $pagarm = array_keys($lista['multa']); for ($i = 0; $i < count($pagarm); $i++) { $mul->pagoMulta($pagarm[$i]); } } if (count($lista['abono']) > 0) { $pagarabono = array_keys($lista['abono']); for ($i = 0; $i < count($pagarabono); $i++) { $abn->UsoAbono($pagarabono[$i]); } } } //Registramos ingreso a la BBDD $ing->nuevoIngreso($lista); //Actualizamos fondo correspondiente $fon->sumaFondo($this->dbAdapter, $lista["id_fondo"], $lista["monto"]); //Enviamos a la Vista $descripcion = "Se ha registrado correctamente el ingreso"; $result = new JsonModel(array('desc' => $descripcion)); return $result; }