public function agregarBoleta($nroSerie, $nroBol, $idCliente, $idEmpleado, $Total) { $resultado = array('valor' => 1, 'message' => 'Su solicitud ha sido procesada correctamente.'); $Boleta = new Boleta(); $Boleta->nroSerie = $nroSerie; $Boleta->nroBol = $nroBol; $Boleta->idCliente = $idCliente; $Boleta->idEmpleado = $idEmpleado; $Boleta->Total = $Total; if (!$Boleta->save()) { $resultado = array('valor' => 0, 'message' => 'No hemos podido realizar su solicitud, intentelo nuevamente'); } return $resultado; }
public function save() { $post = $this->_post(NULL, TRUE); try { if (is_array($post)) { $entidad = NomEntidadTable::getInstance()->find($post['entidad_id']); if (!$entidad) { //Si la entidad no existe devuelvo un error $msg = "Entidad no encontrada."; return $this->_jsonResponse(array("msg" => $msg), 404, $msg); } $proveedor = NomProveedorTable::getInstance()->find($post['proveedor_id']); if (!$proveedor) { //Si la entidad no existe devuelvo un error $msg = "Proveedor no encontrado."; return $this->_jsonResponse(array("msg" => $msg), 404, $msg); } if ($post['id']) { $boleta = $this->_getTable()->find($post['id']); if (!$boleta) { //Si la boleta no existe devuelvo un error $msg = "Boleta no encontrada."; return $this->_jsonResponse(array("msg" => $msg), 404, $msg); } } else { $boleta = new Boleta(); } $boleta->fromArray($post, false); $boleta->set('Entidad', $entidad); $boleta->set('Proveedor', $proveedor); $boleta->save(); //Creating security log $this->load->library('appunto-auth/appunto_auth'); $this->appunto_auth->create_security_log(1, "Asignando/Actualizando tabla " . $this->_model . "[id:" . $boleta->id . "]"); //End security log $this->_jsonResponse($boleta->toArray()); } } catch (Exception $exc) { log_message('error', $exc->getMessage()); log_message('error', $exc->getTraceAsString()); //Creating security log $this->load->library('appunto-auth/appunto_auth'); $this->appunto_auth->create_security_log(0, "Error creando/actualizando tabla " . $this->_model); //End security log $this->_jsonResponse(array("msg" => "Ha ocurrido un error mientras se intentaba guardar una boleta."), 500); } }