public function borraegresoAction() { //Conectamos con BBDD $sid = new Container('base'); $db_name = $sid->offsetGet('dbNombre'); $this->dbAdapter = $this->getServiceLocator()->get($db_name); //Obtenemos ID desde POST $data = $this->getRequest()->getPost(); //Instancias $descuota = ""; $egr = new EgresoTable($this->dbAdapter); $cob = new CobroTable($this->dbAdapter); $fon = new FondosTable($this->dbAdapter); $monto = 0; //Consultamos si existen cuotas para el egreso $egreso = $egr->getDatosId($data['id']); //Validamos que ya no ha sido eliminados if (count($egreso) < 1) { //Retornamos a la vista $result = new JsonModel(array('status' => 'nok', 'desc' => "Egreso ya se eliminó")); return $result; } $monto += $egreso[0]['monto']; if ($egreso[0]['cuotas'] == 'si') { $suma_cuotas = $cob->getSumaCuotas($this->dbAdapter, $data['id']); $monto += $suma_cuotas[0]['monto']; $cob->borraEgreso($data['id']); $descuota = "como también sus cuotas"; } //Eliminamos egreso $egr->borraEgreso($data['id']); //Sumamos monto de egreso y cuotas al fondo $fon->sumaFondo($this->dbAdapter, $egreso[0]['id_fondo'], $monto); $fondo = $fon->getFondoId($egreso[0]['id_fondo']); //Retornamos a la vista $result = new JsonModel(array('desc' => "Se ha eliminado egreso exitosamente, Su sumaron \$" . number_format($monto, "0", ".", ".") . " pesos al " . $fondo[0]['nombre'])); 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; }