public function insertarFacturas($opcion) { $con = Yii::app()->dbvsseaint; $trans = $con->beginTransaction(); $objEmpData = new EMPRESA(); /* * **VARIBLES DE SESION****** */ $emp_id = Yii::app()->getSession()->get('emp_id', FALSE); $est_id = Yii::app()->getSession()->get('est_id', FALSE); $pemi_id = Yii::app()->getSession()->get('pemi_id', FALSE); try { $cabFact = $this->buscarFacturas($opcion); $empresaEnt = $objEmpData->buscarDataEmpresa($emp_id, $est_id, $pemi_id); //recuperar info deL Contribuyente $codDoc = '01'; //Documento Factura for ($i = 0; $i < sizeof($cabFact); $i++) { $this->InsertarCabFactura($con, $cabFact, $empresaEnt, $codDoc, $i); $idCab = $con->getLastInsertID($con->dbname . '.NubeFactura'); $detFact = $this->buscarDetFacturas($cabFact[$i]['TIP_NOF'], $cabFact[$i]['NUM_NOF']); $this->InsertarDetFactura($con, $cabFact[$i]['POR_IVA'], $detFact, $idCab); $this->InsertarFacturaDatoAdicional($con, $i, $cabFact, $idCab); } $trans->commit(); $con->active = false; $this->actualizaErpCabFactura($cabFact); echo "ERP Actualizado"; return true; } catch (Exception $e) { $trans->rollback(); $con->active = false; throw $e; return false; } }
if (!$trabajoReparacion->insertar()) { $error = "No se pudo registrar la reparacion del auto."; $con->rollback(); break; } } if ($error == "") { if ($estado == "activo") { $pago = new PAGO($con); $pagado = floatval($pago->buscarXReparacionTotal($idreparacion)); if ($total > $pagado) { $estado = "activo falta pago"; } } if (strpos($estado, 'fin') !== false) { $empresa = new EMPRESA($con); $resultado["ot"] = $empresa->obtenerOT($empresasession); } if (!$reparacion->modificarTotal($idreparacion, $total, $estado)) { $error = "No se pudo registrar la reparacion del auto."; $con->rollback(); } else { $accesorioReparacion = new ACCESORIO_REPARACION($con); $accesorioReparacion->eliminar($idreparacion); for ($i = 0; $i < count($accesorio); $i++) { $accesorioReparacion = new ACCESORIO_REPARACION($con); $accesorioReparacion->contructor($idreparacion, $accesorio[$i]); if (!$accesorioReparacion->insertar()) { $error = "No se pudo registrar la reparacion del auto."; $con->rollback(); break;
public function authenticate() { /*$users=array( // username => password 'demo'=>'demo', 'admin'=>'admin', );*/ /*if(!isset($users[$this->username])) $this->errorCode=self::ERROR_USERNAME_INVALID; elseif($users[$this->username]!==$this->password) $this->errorCode=self::ERROR_PASSWORD_INVALID; else $this->errorCode=self::ERROR_NONE; return !$this->errorCode;*/ //echo $this->username; $empresa = new EMPRESA(); $rol = new ROL(); $session = Yii::app()->getSession(); $user = USUARIO::model()->find('LOWER(USU_NOMBRE)=?', array(strtolower($this->username))); $session->add('isuser', FALSE); if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif (md5($this->password) !== $user->USU_PASSWORD) { //Validacion Clave con MD5 $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { //yii::app()->user->_id; $this->_id = $user->USU_ID; $this->_username = $user->USU_NOMBRE; $session->add('isuser', TRUE); $session->add('user_id', $user->USU_ID); $session->add('user_name', $user->USU_NOMBRE); //$this->setState('CORREO', $user->CORREO); //PARA USAR LAS VARIABLES DE SESSION //yii::app()->user->CORREO; //yii::app()->user->getState('CORREO'); //Yii::app()->getSession()->get('user_name', FALSE); //INFORMACION EMPRESAS //$emp=$empresa->mostrarEmpresas($user->USU_ID); $emp_id = Yii::app()->params['EmpID']; //'1'; $est_id = Yii::app()->params['EstID']; //'1'; $pemi_id = Yii::app()->params['PemiID']; //'1'; $data = $empresa->buscarDataEmpresa($emp_id, $est_id, $pemi_id); $tipoUser = $rol->buscarTipoUser($user->USU_ID); //VSValidador::putMessageLogFile(Yii::app()->params['EmpID']); $session->add('emp_id', $emp_id); $session->add('est_id', $est_id); $session->add('pemi_id', $pemi_id); $session->add('Ruc', $data['Ruc']); $session->add('RazonSocial', $data['RazonSocial']); $session->add('NombreComercial', $data['NombreComercial']); $session->add('DireccionMatriz', $data['DireccionMatriz']); $session->add('DireccionSucursal', $data['DireccionSucursal']); $session->add('ContribuyenteEspecial', $data['ContribuyenteEspecial']); $session->add('ObligadoContabilidad', $data['ObligadoContabilidad']); $session->add('CorreoConta', $data['CorreoConta']); //Asignacion de Ambiente Pruebas o Produccion $ambiente = $empresa->buscarAmbienteEmp($data['EMP_ID'], $data['Ambiente']); $session->add('Recepcion', trim($ambiente['Recepcion'])); //Aceptacion Comprobantes $session->add('Autorizacion', trim($ambiente['Autorizacion'])); //Autorizacion Comprobantes $session->add('RecepcionLote', trim($ambiente['RecepcionLote'])); //RecepcionLote Comprobantes $session->add('UsuarioErp', $tipoUser['UsuarioErp']); $session->add('RolId', $tipoUser['ROL_ID']); $session->add('RolNombre', $tipoUser['ROL_NOMBRE']); $this->errorCode = self::ERROR_NONE; } $session->close(); return $this->errorCode == self::ERROR_NONE; }
$proceso = $_POST["proceso"]; $con = new CONN("taller1", "wdigital"); if (!$con->estado) { $error = "No se pudo establecer conexion. Intente nuevamente."; $reponse = array("error" => $error, "result" => $resultado); echo $_GET['callback'] . json_encode($reponse); return; } if ($personalsession == null || $empresasession == null) { $error = "Error Session"; $reponse = array("error" => $error, "result" => $resultado); echo $_GET['callback'] . json_encode($reponse); return; } if ($proceso == "datosempresa") { $empresa = new EMPRESA($con); $resultado = $empresa->buscarXID($empresasession); } if ($proceso == "morosos") { $reparacion = new REPARACION($con); $text = $_POST['text']; $de = $_POST['de']; $hasta = $_POST['hasta']; if (!$Herramienta->validar("texto y entero", $text)) { $error = "<p>El criterio de busqueda no puede tener caracteres especiales.</p>"; } else { $resultado = $reparacion->buscarMoroso($text, $de, $hasta, $empresasession); } } if ($proceso == "Movimiento") { $pago = new PAGO($con);
if (strlen(rz) === 0) { $error .= "<p>La razon social no puede estar vacía.</p>"; } if (!$Herramienta->validar("texto y entero", rz)) { $error .= "<p>La razon social no puede tener caracteres especiales.</p>"; } if (!$Herramienta->validar("texto y entero", direccion)) { $error .= "<p>El dirección no puede tener caracteres especiales.</p>"; } if (!$Herramienta->validar("texto y entero", telefono)) { $error .= "<p>El telefono no puede tener caracteres especiales.</p>"; } if (!$Herramienta->validar("texto y entero", autorizacion)) { $error .= "<p>La autorizacion no puede tener caracteres especiales.</p>"; } $empresa = new EMPRESA($con); /*$aux=str_replace('/', '-', $fechadosificacion); $fecha_finDosificacion = strtotime ( '+6 month' ,strtotime ($aux)) ; $fecha_finDosificacion = date ( 'j/m/Y' , $fecha_finDosificacion ); $fecha_finDosificacion = strlen($fecha_finDosificacion)==9?"0$fecha_finDosificacion":$fecha_finDosificacion; */ if ($error == "") { $resultado = $empresa->contructor($empresasession, $nombre, $rz, $logo, $aniversario, 0, $nit, $direccion, 0, $fechadosificacion, $llave, $autorizacion, $telefono, $fecha_finDosificacion, 0, $correo); if (!$empresa->modificar($empresasession)) { $error = "No se pudieron actualizar los datos de la empresa. Intenete nuevamente."; } else { $resultado = $fecha_finDosificacion; } } } $reponse = array("error" => $error, "result" => $resultado); echo $_GET['callback'] . json_encode($reponse);
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return EMPRESA the loaded model * @throws CHttpException */ public function loadModel($id) { $model = EMPRESA::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }