public static function saveAcount(ePerson $ePerson, eUser $eUser, eUserProfile $eUserProfile, $eUserProfile_CompanyBranches) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mPerson Person_Model */ $mPerson =& $MY->mPerson; /* @var $mUser User_Model */ $mUser =& $MY->mUser; /* @var $mUserProfile User_Profile_Model */ $mUserProfile =& $MY->mUserProfile; /* @var $mUserProfileCompanyBranch User_Profile_Company_Branch_Model */ $mUserProfileCompanyBranch =& $MY->mUserProfileCompanyBranch; $oTransaction = new MY_Business(); $oTransaction->begin(); try { if (!Helper_App_Session::isAdminProfile() || !Helper_App_Session::isSuperAdminProfile()) { if (Business_App_Person::isValidDocument($ePerson->document)) { throw new Exception('Documento Invalido, No permitido'); } } $ePersonT = $mPerson->loadByDocument($ePerson->document, $ePerson->id); if (!$ePersonT->isEmpty()) { throw new Exception('Persona Existente'); } $eUserT = $mUser->load($eUser->username, 'username', $eUser->id); if (!$eUserT->isEmpty()) { throw new Exception('Usuario Existente'); } $mPerson->save($ePerson); $mUser->save($eUser); $eUserProfileT = $mUserProfile->loadArray(array('id_user' => $eUser->id, 'id_profile' => $eUserProfile->id_profile)); $eUserProfile->id_user = $eUser->id; $eUserProfile->id = $eUserProfileT->id; $mUserProfile->save($eUserProfile); $mUserProfileCompanyBranch->deleteByUserProfile($eUserProfile->id); if (!empty($eUserProfile_CompanyBranches)) { /* @var $eUserProfileCompanyBranch eUserProfileCompanyBranch */ foreach ($eUserProfile_CompanyBranches as $eUserProfileCompanyBranch) { $eUserProfileCompanyBranch->id_user_profile = $eUserProfile->id; $mUserProfileCompanyBranch->save($eUserProfileCompanyBranch); } } $oTransaction->commit(); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }
public static function saveRolModule(eRol $eRol, $eRolesModules) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mRol Rol_Model */ $mRol =& $MY->mRol; /* @var $mRolModule Rol_Module_Model */ $mRolModule =& $MY->mRolModule; $oTransaction = new MY_Business(); $oTransaction->begin(); try { $isEditable = TRUE; if (!$eRol->isEmpty()) { $eRolT = $mRol->load($eRol->id); if (!Helper_App_Session::isSuperAdminProfile()) { if ($eRolT->isEditable == 0) { throw new Exception("Prohibido editar éste Rol"); } } $isEditable = $eRolT->isEditable == 0; } if ($isEditable) { $mRol->save($eRol); } $mRolModule->deleteByRol($eRol->id); if (!empty($eRolesModules)) { /* @var $eRolModule eRolModule */ foreach ($eRolesModules as $eRolModule) { $eRolModule->id_rol = $eRol->id; $mRolModule->save($eRolModule); } } $oTransaction->commit(); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }
public static function saveCompanyBranch(eCompanyBranch $eCompanyBranch) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mCompanyBranch Company_Branch_Model */ $mCompanyBranch =& $MY->mCompanyBranch; $oTransaction = new MY_Business(); $oTransaction->begin(); try { $mCompanyBranch->save($eCompanyBranch); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); $oTransaction->commit(); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }
public static function savePermission(ePermission $ePermission) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mPermission Permission_Model */ $mPermission =& $MY->mPermission; $oTransaction = new MY_Business(); $oTransaction->begin(); try { $mPermission->save($ePermission); $oTransaction->commit(); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }
public static function savePerson(ePerson $ePerson) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mPerson Person_Model */ $mPerson =& $MY->mPerson; $oTransaction = new MY_Business(); $oTransaction->begin(); try { $ePersonT = $mPerson->load($ePerson->id); if (!Helper_App_Session::isAdminProfile() || !Helper_App_Session::isSuperAdminProfile()) { if (self::isValidDocument($ePerson->document)) { throw new Exception('Documento Invalido: ' + $ePerson->document); } if ($ePersonT->tipo_documento != $ePerson->tipo_documento) { throw new Exception('No tiene permisos para editar el tipo de documento'); } if ($ePersonT->document != $ePerson->document) { throw new Exception('No tiene permisos para editar el documento'); } } $ePersonDocument = $mPerson->loadByDocument($ePerson->document, $ePerson->id); if (!$ePersonDocument->isEmpty()) { throw new Exception('Documento Existente: ' + $ePerson->document); } $mPerson->save($ePerson); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); $oTransaction->commit(); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }
public static function saveOrderModules($eModules) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mModule Module_Model */ $mModule =& $MY->mModule; $oTransaction = new MY_Business(); $oTransaction->begin(); try { if (!empty($eModules)) { foreach ($eModules as $eModule) { $mModule->saveOrder($eModule); } } $oTransaction->commit(); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }
public static function saveProfilePermission($id_profile, $arr_eProfilePermissions) { $oBus = new Response_Business(); $MY =& MY_Controller::get_instance(); /* @var $mProfilePermission Profile_Permission_Model */ $mProfilePermission =& $MY->mProfilePermission; $oTransaction = new MY_Business(); $oTransaction->begin(); try { $mProfilePermission->deleteByProfile($id_profile); /* @var $eProfilePermission eProfilePermission*/ foreach ($arr_eProfilePermissions as $eProfilePermission) { if (!empty($eProfilePermission->id_permission)) { $mProfilePermission->save($eProfilePermission); } } $oTransaction->commit(); $oBus->isSuccess(TRUE); $oBus->message("Guardado exitosamente"); } catch (Exception $e) { $oTransaction->rollback(); $oBus->isSuccess(FALSE); $oBus->message($e->getMessage()); } return $oBus; }