Ejemplo n.º 1
0
 private function send()
 {
     $this->load->file('application/modules/site/index/form/email_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_Site_Email(TRUE);
     try {
         if (!$frm_data->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $Email = $frm_data->getEmail();
         $oBus = Helper_Site_Mail::sendEmail($Email);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message($oBus->message());
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('email', $frm_data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
Ejemplo n.º 2
0
 private function updatePassword()
 {
     $this->load->file('application/modules/app/layout/layout_password_data.php');
     $resAjax = new Response_Ajax();
     $data = new Data_App_Layout_Password(TRUE);
     try {
         if (!$data->isValid()) {
             throw new Exception('Complete correctamente todos los campos');
         }
         $id_user = Helper_App_Session::getUserId();
         $oBus = Business_App_User::checkPassword($id_user, $data->password_current);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $data_isValid = $oBus->data();
         $isValid = $data_isValid['isValid'];
         if (!$isValid) {
             throw new Exception('Contraseña incorrecta.');
         }
         $oBus2 = Business_App_User::updatePassword($id_user, $data->password_new);
         if (!$oBus2->isSuccess()) {
             throw new Exception($oBus2->message());
         }
         $data_changed = $oBus2->data();
         $changed = $data_changed['changed'];
         if (!$changed) {
             throw new Exception("No fue posible cambiar la contraseña");
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message("Contraseña cambiada con éxito.");
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('change_password', $data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
 private function saveAcount()
 {
     $this->load->file('application/modules/app/user_settings/form/user_settings_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_App_User_Settings(TRUE);
     try {
         if (!$this->permission->update) {
             throw new Exception('No tiene permisos para editar/actualizar');
         }
         if (!$frm_data->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $ePerson = $frm_data->getPersonEntity();
         $eUser = $frm_data->getUserEntity();
         $eUserProfile = $frm_data->getUserProfileEntity();
         $eUserProfile_CompanyBranches = $frm_data->getUserProfile_CompanyBranchEntity();
         $oBus = Business_App_User_Settings::saveAcount($ePerson, $eUser, $eUserProfile, $eUserProfile_CompanyBranches);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message($oBus->message());
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('acount', $frm_data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
Ejemplo n.º 4
0
 private function changePassword()
 {
     $this->load->file('application/forms/app/login_change_password_form.php');
     $resAjax = new Response_Ajax();
     $oBus = new Response_Business();
     $frmChangePassword = new Form_App_Login_Change_Password(TRUE);
     try {
         if (!$frmChangePassword->isValid()) {
             throw new Exception('Complete Correctamente los campo');
         }
         $oBus = Business_App_Token::inactivarUserToken(Helper_Encrypt::decode($frmChangePassword->id_user), 'id_user');
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $oBus = Business_App_User::updatePassword(Helper_Encrypt::decode($frmChangePassword->id_user), $frmChangePassword->new_password);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message($oBus->message());
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('changePassword', $frmChangePassword->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
 private function saveProfilePermission()
 {
     $this->load->file('application/modules/app/security_profile/form/permissions_form.php');
     $resAjax = new Response_Ajax();
     $frmData = new Form_App_Profile_Permission(TRUE);
     try {
         if (!empty($frmData->id_profile) && !$this->permission->update_permission) {
             throw new Exception('No tiene permisos para editar');
         }
         if (!$frmData->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $eProfilesPermissions = $frmData->getProfilePermissionEntities();
         $oBus = Business_App_Profile::saveProfilePermission($frmData->id_profile, $eProfilesPermissions);
         $resAjax->isSuccess($oBus->isSuccess());
         $resAjax->message($oBus->message());
     } catch (Exception $e) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($e->getMessage());
         $resAjax->form('permission', $frmData->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
 private function loadBinnacle()
 {
     $this->load->file('application/modules/app/security_binnacle/form/binnacle_form.php');
     $resAjax = new Response_Ajax();
     $id_binnacle = $this->input->post('id_binnacle');
     $oBus = Business_App_Binnacle::loadBinnacle($id_binnacle);
     $data = $oBus->data();
     /* @var $eUserLog eUserLog */
     $eUserLog = $data['eUserLog'];
     $eUser = $data['eUser'];
     $frm_data = new Form_App_Security_Binnacle();
     $frm_data->setBinnacleEntity($eUserLog);
     $frm_data->setUserEntity($eUser);
     $resAjax->isSuccess($oBus->isSuccess());
     $resAjax->message($oBus->message());
     $resAjax->form('binnacle', $frm_data->toArray());
     echo $resAjax->toJsonEncode();
 }
 private function saveParam()
 {
     $this->load->file('application/modules/app/system_setting_param/form/setting_param_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_App_System_Setting_Param(TRUE);
     $logo = 'logo';
     $id_system = Helper_Config::getSystemId();
     try {
         if (!$this->permission->update) {
             throw new Exception('No tiene permisos para editar/actualizar');
         }
         if (!$frm_data->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         if (!isset($_FILES[$logo])) {
             $oBusUploadLogo = Business_App_Configuration_System::uploadLogo($id_system, $logo);
             if (!$oBusUploadLogo->isSuccess()) {
                 throw new Exception($oBusUploadLogo->message());
             }
         }
         $oBusLoadLogo = Business_App_Configuration_System::loadLogo($id_system);
         if (!$oBusLoadLogo->isSuccess()) {
             throw new Exception($oBusLoadLogo->message());
         }
         $dataLogo = $oBusLoadLogo->data();
         $eConfigurationSystem = $frm_data->getConfigurationSystemEntity();
         $eConfigurationSystem->id = $id_system;
         $eConfigurationSystem->logo = $dataLogo['uri'];
         $frm_data->logo = $eConfigurationSystem->logo;
         $oBus = Business_App_Configuration_System::saveConfigurationSystem($eConfigurationSystem);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message($oBus->message());
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
     }
     $resAjax->form('setting', $frm_data->toArray());
     echo $resAjax->toJsonEncode();
 }
 private function saveCompanyBranch()
 {
     $this->load->file('application/modules/app/utility_company_and_company_branch/form/company_branch_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_App_Company_Branch(TRUE);
     try {
         if (!$this->permission->update_branch) {
             throw new Exception('No tiene permisos para editar/actualizar');
         }
         if (!$frm_data->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $eCompanyBranch = $frm_data->getCompanyBranchEntity();
         $eCompanyBranch->id_company = Helper_App_Session::getCompanyId();
         $oBus = Business_App_Company_Branch::saveCompanyBranch($eCompanyBranch);
         if (!$oBus->isSuccess()) {
             throw new Exception($oBus->message());
         }
         $resAjax->isSuccess(TRUE);
         $resAjax->message($oBus->message());
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('company_branch', $frm_data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
Ejemplo n.º 9
0
 private function loadFile()
 {
     $texto = '';
     $dir = $this->input->post('path');
     $root = BASEPATH . "../application/logs" . (empty($dir) ? '/' : "/{$dir}");
     $path = $root;
     $resAjax = new Response_Ajax();
     if (file_exists($path) && $dir != '.' && $dir != '..' && !is_dir($path)) {
         $fp = fopen($path, 'r');
         //leemos el archivo
         $texto = fread($fp, filesize($path));
         $name = basename($path);
         $size = filesize($path);
         /*bytes*/
         $size_file = Helper_File::round_size($size, 2);
         //transformamos los saltos de linea en etiquetas <br>
         //$texto = nl2br($texto);
         /*$search  = array("\r\n", "\r", "\n", " ");
           $replace = array("<br/>", "<br/>", "<br/>", "&nbsp;");
           $texto = str_replace($search, $replace, $texto);*/
         $resAjax->isSuccess(TRUE);
         $resAjax->message('');
     } else {
         $resAjax->isSuccess(FALSE);
         $resAjax->message('Error de Archivo');
     }
     $resAjax->form('file', array('text' => print_r($texto, TRUE), 'name' => $name, 'path' => $dir, 'size' => $size_file));
     echo $resAjax->toJsonEncode();
 }
Ejemplo n.º 10
0
 private function saveRol()
 {
     $this->load->file('application/modules/app/security_rol/form/rol_form.php');
     $resAjax = new Response_Ajax();
     $frmRol = new Form_App_Security_Rol(TRUE);
     try {
         if (empty($frmRol->id_rol) && !$this->permission->create) {
             throw new Exception('No tiene permisos para guardar');
         }
         if (!empty($frmRol->id_rol) && !$this->permission->update) {
             throw new Exception('No tiene permisos para editar');
         }
         if (!$frmRol->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $eRol = $frmRol->getRolEntity();
         $eRolesModules = $frmRol->getRolModuleEntities();
         $oBus = Business_App_Rol::saveRolModule($eRol, $eRolesModules);
         $resAjax->isSuccess($oBus->isSuccess());
         $resAjax->message($oBus->message());
     } catch (Exception $e) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($e->getMessage());
         $resAjax->form('rol', $frmRol->toArray());
     }
     echo $resAjax->toJsonEncode();
 }
Ejemplo n.º 11
0
 private function saveUser()
 {
     $this->load->file('application/modules/app/user_profile/form/user_form.php');
     $resAjax = new Response_Ajax();
     $frm_data = new Form_App_User(TRUE);
     try {
         if (!$this->permission->update) {
             throw new Exception('No tiene permisos para editar/actualizar');
         }
         if (!$frm_data->isValid()) {
             throw new Exception('Debe ingresar la información en todos los campos');
         }
         $oBus = Business_App_User::loadUser(Helper_App_Session::getUserId());
         $data = $oBus->data();
         $eUser = $data['eUser'];
         $oBus = Business_App_User::login($eUser->username, $frm_data->password_current);
         if (!$oBus->isSuccess()) {
             throw new Exception('Contraseña Incorrecta');
         }
         $oBus = Business_App_User::updatePassword($eUser->id, $frm_data->password_new_repeat);
         $resAjax->isSuccess(TRUE);
         $resAjax->message('Contraseña Actualizada');
     } catch (Exception $ex) {
         $resAjax->isSuccess(FALSE);
         $resAjax->message($ex->getMessage());
         $resAjax->form('user', $frm_data->toArray());
     }
     echo $resAjax->toJsonEncode();
 }