/** * Setting Useing languares * */ public function actionLanguares($typelang = NULL) { if (!empty($typelang)) { // Yii::app()->session['sess_lang'] = strtolower($typelang); $_SESSION["sess_lang"] = strtolower($typelang); lbLangUser::model()->updateLang(Yii::app()->user->id, $typelang); $this->redirect(Yii::app()->request->urlReferrer); } else { $this->render('languages'); } }
<?php /* @var $this LbInvoiceController */ /* @var $model LbInvoice */ /* @var $quotationModel LbQuotation */ if (isset(Yii::app()->user->id)) { $lang = lbLangUser::model()->getLangName(Yii::app()->user->id); } if ($lang != "") { Yii::app()->language = $lang; $_SESSION["sess_lang"] = strtolower($lang); } $m = $this->module->id; $canAdd = BasicPermission::model()->checkModules($m, 'add'); $canList = BasicPermission::model()->checkModules($m, 'list'); $canView = BasicPermission::model()->checkModules($m, 'view'); $canAddQuotation = BasicPermission::model()->checkModules('lbQuotation', 'add'); $canListQuotation = BasicPermission::model()->checkModules('lbQuotation', 'list'); $canAddPayment = BasicPermission::model()->checkModules('lbPayment', 'add'); if (!$canView) { echo "Have no permission to see this record"; return; } $status = '("' . LbInvoice::LB_INVOICE_STATUS_CODE_DRAFT . '","' . LbInvoice::LB_INVOICE_STATUS_CODE_OPEN . '","' . LbInvoice::LB_INVOICE_STATUS_CODE_OVERDUE . '")'; $count_invoice = LbInvoice::model()->getInvoiceByStatus($status); $count_invoice = $count_invoice->totalItemCount; $count_quotation = LbQuotation::model()->getQuotationByStatus('("' . LbQuotation::LB_QUOTATION_STATUS_CODE_DRAFT . '","' . LbQuotation::LB_QUOTATION_STATUS_CODE_SENT . '","' . LbQuotation::LB_QUOTATION_STATUS_CODE_APPROVED . '")'); $count_quotation = $count_quotation->totalItemCount; // Buttons echo '<div id="lb-container-header">'; echo '<div class="lb-header-right" style="margin-left: -10px"><h4>' . Yii::t("lang", "Invoice Dashboard") . '</h4></div>';
<?php /* @var $this AccountInvitationController */ /* @var $model AccountInvitation */ /* @var $form CActiveForm */ $linx_app_account_subscriptions = AccountSubscription::model()->findSubscriptions(Yii::app()->user->id); $model_langguage = lbLangUser::model(); $langgage['en'] = 'English'; $langgage['vi'] = 'Tiếng Việt'; ?> <div class="form"> <?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'issue-form', 'htmlOptions' => array('class' => 'well', 'onsubmit' => "checkEmail();"), 'enableClientValidation' => true, 'clientOptions' => array('validateOnSubmit' => true))); // list of projects user created // can only invite to own project //$active_projects = array(0 => '') + Project::model()->getProjectsCreatedBy(Yii::app()->user->id, 'datasourceArray'); ?> <?php echo CHtml::errorSummary($model); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <fieldset> <?php echo $form->dropDownListRow($model, 'account_invitation_subscription_id', $linx_app_account_subscriptions, array('options' => array(Yii::app()->user->linx_app_selected_subscription => array('selected' => true)))); ?>
/** * Get list items * array returned consists of array(list_item_name_code => list_item_name, ...) * @param $list_code * @param bool $dropdown_array_source * @return array */ public function updateLang($user_id, $lang) { $model = $this->find('lb_user_id=' . $user_id . ' AND invite_id=0'); if (isset($model)) { $model->lb_language_name = $lang; $model->update(); } else { $model = new lbLangUser(); $model->lb_language_name = $lang; $model->lb_user_id = $user_id; $model->insert(); } }
public function actionAccept($id, $key) { // must not be logged in user if (!Yii::app()->user->isGuest) { $this->redirect(array('site/page', 'view' => 'must_log_out')); } $model = $this->loadModel($id); // must match both id and random key if (!$model) { echo "Hi. Somehow this invitation is missing or removed. Please contact the person who invited you."; return; } if ($model->account_invitation_rand_key != $key) { echo "Hi there. Looks like your invitation is no longer valid. Please contact the person who invited you."; return; } if ($model->account_invitation_status == 1) { echo "Looks like you already accepted this invitation."; return; } $account = new Account(); // SUBMISSION PROCESS // Get account invitation record that has this unique key // 1. Update invitation status to accepted // 2. Create new account for this user // 3. Put this user under team member of the master account if (isset($_POST['Account']['account_password'])) { $model->account_invitation_status = 1; if ($model->save()) { $account->account_email = $model->account_invitation_to_email; $account->account_password = $_POST['Account']['account_password']; $account->account_status = ACCOUNT_STATUS_ACTIVATED; if ($account->save()) { // create account profile $accountProfile = new AccountProfile(); $accountProfile->account_id = $account->account_id; $accountProfile->account_profile_surname = $_POST['AccountProfile']['account_profile_surname']; $accountProfile->account_profile_given_name = $_POST['AccountProfile']['account_profile_given_name']; $accountProfile->account_profile_preferred_display_name = $accountProfile->account_profile_given_name . ' ' . $accountProfile->account_profile_surname; $lang = lbLangUser::model()->find('lb_user_id = ' . $id . ' AND invite_id = 1'); $lang = lbLangUser::model()->find('lb_user_id = ' . $id . ' AND invite_id = 1'); if ($lang) { lbLangUser::model()->updateLang($account->account_id, $lang['lb_language_name']); //Xoa record languge co invite=1; $lang->delete(); //insert } if ($accountProfile->save()) { //Save language // create team member record $teamMember = new AccountTeamMember(); $teamMember->accepting_invitation = true; $teamMember->master_account_id = $model->account_invitation_master_id; $teamMember->member_account_id = $account->account_id; $teamMember->account_subscription_id = $model->account_invitation_subscription_id; $teamMember->is_active = AccountTeamMember::ACCOUNT_TEAM_MEMBER_IS_ACTIVE; if ($model->account_invitation_type == AccountInvitation::ACCOUNT_INVITATION_TYPE_CUSTOMER) { $teamMember->is_customer = ACCOUNT_TEAM_MEMBER_IS_CUSTOMER; } else { $teamMember->is_customer = 0; } if ($teamMember->save()) { //$companyContact = // create project member record if any if ($model->account_invitation_project > 0) { $projectMember = new ProjectMember(); $projectMember->project_id = $model->account_invitation_project; $projectMember->account_id = $account->account_id; $projectMember->project_member_start_date = date('Y-m-d H:i:s'); $projectMember->project_member_is_manager = PROJECT_MEMBER_IS_NOT_MANAGER; $projectMember->accepting_invitation = true; $projectMember->save(); } $this->redirect(array('site/page', 'view' => 'account_activated')); } } } } } // SHOW VIEW // show acceptance form, where user has to enter password $this->render('accept', array('model' => $model, 'account' => $account)); }