public function actionUpdateTax($id) { $model = LbTax::model()->findByPk($id); if (isset($_POST['LbTax'])) { $model->attributes = $_POST['LbTax']; $lbtax_arr = $_POST['LbTax']; if (!($tax = LbTax::model()->IsNameTax($lbtax_arr['lb_tax_name'], $id))) { LBApplication::render($this, '_form_update_tax', array('model' => $model, 'error' => 'Tax Name Exist')); } else { if ($model->save()) { $this->redirect($this->createUrl('/' . LBApplication::getCurrentlySelectedSubscription() . '/configuration')); } } } LBApplication::render($this, '_form_update_tax', array('model' => $model, 'error' => '')); }
<?php /* @var $this LbInvoiceController */ /* @var $model LbInvoice */ /* @var $ownCompany LbCustomer */ // header container div echo '<div id="invoice-header-container" class="container-header" style="position: relative">'; //echo $model->lb_vendor_company_id; echo '<div id="logo_wrapper" style="overflow:hidden;text-align: center;">'; // $company = (isset($model->owner) ? $model->lb_vendor_company_id : ''); $folder = 'images/logo/'; // $model=LbVendor::model()->findByPk($id); $company = $model->lb_vd_invoice_company_id; $path = YII::app()->baseUrl . "/images/logo/"; $filename = ''; $file_arr = array_diff(scandir($folder), array('.', '..')); $subcription = LBApplication::getCurrentlySelectedSubscription(); foreach ($file_arr as $key => $file) { $file_name = explode('.', $file); $file_name_arr = explode('_', $file_name[0]); // print_r($file_name_arr); if ($file_name_arr[0] == $subcription && $file_name_arr[1] == $company) { echo "<img src='" . $path . $file . "' style='max-height:120px' />"; } } $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => $this->createUrl('uploadLogo', array('id' => $model->lb_record_primary_key, 'sub_cription' => $subcription, 'company_id' => $company)), 'allowedExtensions' => array("jpeg", "jpg", "gif", "png"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'multiple' => true, 'onComplete' => "js:function(id, fileName, responseJSON){\n \$('#uploadFile .qq-upload-list').html('');\n //\$('#logo_wrapper img').attr('src','" . $path . "'+fileName);\n window,location.reload(true);\n }"))); echo '</div>'; //echo '<h3 id="po-number-container">'.$model->getDisplayPOStatus($model->lb_vendor_status).'</h3>'; echo '<div id="invoice-basic-info-container" style="float: left;width:36%;">'; echo '<h3 id="po-number-container">'; $this->widget('editable.EditableField', array('type' => 'text', 'model' => $model, 'attribute' => 'lb_vd_invoice_no', 'url' => LbVendor::model()->getActionURLNormalized('AjaxUpdateFieldVD'), 'placement' => 'right')); echo '</h3><br />';
public function checkModules($module_name, $per_value, $created_by = false) { $user_id = Yii::app()->user->id; $canAdd = BasicPermission::model()->checkPerModule($module_name, 'add'); $canEditOwn = BasicPermission::model()->checkPerModule($module_name, 'update own'); $canEditAll = BasicPermission::model()->checkPerModule($module_name, 'update all'); $canDeleteOwn = BasicPermission::model()->checkPerModule($module_name, 'delete own'); $canDeleteAll = BasicPermission::model()->checkPerModule($module_name, 'delete all'); $canViewOwn = BasicPermission::model()->checkPerModule($module_name, 'view own'); $canViewAll = BasicPermission::model()->checkPerModule($module_name, 'view all'); $canListOwn = BasicPermission::model()->checkPerModule($module_name, 'list own'); $canListAll = BasicPermission::model()->checkPerModule($module_name, 'list all'); $ownSub = AccountSubscription::model()->checkIsSubscriptionOwner(LBApplication::getCurrentlySelectedSubscription()); $result = false; if ($ownSub) { $result = true; if ($per_value == "list") { $result = FALSE; } } else { if ($per_value == "add") { $result = $canAdd; } else { if ($per_value == "update") { if ($canEditAll) { $result = true; } elseif ($canEditOwn && $user_id == $created_by) { $result = true; } } else { if ($per_value == "delete") { if ($canDeleteAll) { $result = true; } elseif ($canDeleteOwn && $user_id == $created_by) { $result = true; } } else { if ($per_value == "view") { if ($canViewAll) { $result = true; } elseif ($canViewOwn && $user_id == $created_by) { $result = true; } } else { if ($per_value == "list") { $result = -1; if ($canListAll) { $result = false; } else { if ($canListOwn) { $result = Yii::app()->user->id; } } } } } } } } return $result; }
} $linx_app_menu_subscription_items[] = array('label' => $label, 'url' => array('/site/subscription', 'id' => $sub_id), 'visible' => !Yii::app()->user->isGuest); } $linx_app_menu_subscription_items[] = '---'; $linx_app_menu_subscription_items[] = array('label' => '<i class="icon-plus"></i> ' . Yii::t('lang', 'Add Subscription'), 'url' => array('/accountSubscription/create'), 'visible' => $onwSubcrip); $linx_app_menu_subscription_items[] = array('label' => '<i class="icon-plus"></i> ' . Yii::t('lang', 'Manager Subscription'), 'url' => array('/accountSubscription/admin'), 'visible' => $onwSubcrip); } if (isset($_SESSION['sess_lang']) && $_SESSION['sess_lang'] == 'vi') { $select_vn = ' <i class="icon-ok"></i>'; $select_en = ""; } else { $select_en = ' <i class="icon-ok"></i>'; $select_vn = ""; } $ulr_img = CHtml::image(AccountProfile::model()->getProfilePhotoURL(Yii::app()->user->id), '', array('height' => 30, 'width' => 30, 'style' => "margin-right: 5px; height: 30px; border-radius:15px; width: 30px; ")); $this->widget('bootstrap.widgets.TbNavbar', array('brand' => false, 'collapse' => true, 'items' => array(array('class' => 'bootstrap.widgets.TbMenu', 'items' => array()), array('class' => 'bootstrap.widgets.TbMenu', 'encodeLabel' => false, 'htmlOptions' => array('class' => 'pull-right'), 'items' => array(array('label' => $ulr_img . Yii::t('lang', isset(Yii::app()->user->account_profile_short_name) ? Yii::app()->user->account_profile_short_name : 'Actions'), 'url' => '#', 'items' => array(array('label' => '<span>Company</span>', 'url' => '#', 'items' => $linx_app_menu_subscription_items, 'visible' => !Yii::app()->user->isGuest), array('label' => Yii::t('lang', 'Configuration'), 'url' => array('/' . LBApplication::getCurrentlySelectedSubscription() . '/configuration'), 'visible' => $onwSubcrip), array('label' => Yii::t('lang', 'My Account'), 'url' => array('/account/view/' . Yii::app()->user->id), 'visible' => !Yii::app()->user->isGuest), array('label' => Yii::t('lang', 'My Team'), 'url' => array('/' . LBApplication::getCurrentlySelectedSubscription() . '/team'), 'visible' => !Yii::app()->user->isGuest), array('label' => 'Language', 'url' => '#', 'items' => array(array('label' => 'English' . $select_en, 'url' => array('/site/languares', 'typelang' => 'en')), array('label' => 'Tiếng việt' . $select_vn, 'url' => array('/site/languares', 'typelang' => 'vi')))), array('label' => Yii::t('lang', 'Contact'), 'url' => array('/site/contact')), array('label' => Yii::t('lang', 'Logout') . '(' . Yii::app()->user->name . ')', 'url' => array('/' . LBApplication::getCurrentlySelectedSubscription() . '/logout'), 'visible' => !Yii::app()->user->isGuest)), 'visible' => !Yii::app()->user->isGuest), array('label' => "<i class=\"icon-user\"></i> " . Yii::t('lang', 'Login'), 'url' => array('/site/login'), 'visible' => Yii::app()->user->isGuest)))), 'htmlOptions' => array('class' => 'navbar'))); ?> </div> <?php echo $content; ?> <div id="footer"> Copyright © <?php echo date('Y'); ?> , LinxBooks. All Rights Reserved. LinxHQ Pte Ltd<br/> </div><!-- footer --> <div id="contactable"></div>
function getViewModuleURL($controller, $id, $title, $params = null) { // clean the title $title = LBApplication::getURLEncodedString($title); $url = '/' . LBApplication::getCurrentlySelectedSubscription() . '/' . $this->module_name . "/" . $controller . "/{$id}-{$title}"; // add params if available if (is_array($params) && count($params)) { $url .= '?'; foreach ($params as $param_ => $val) { $url .= "{$param_}={$val}&"; } } return array($url); //trigger_error('Not Implemented!', E_USER_WARNING); }
/** * Displays the login page */ public function actionLogin() { $model = new LoginForm(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if (isset($_POST['LoginForm'])) { $model->username = $_POST['LoginForm']['username']; $model->password = $_POST['LoginForm']['password']; $model->rememberMe = 1; // print_r($_POST['LoginForm']); // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { $this->redirect(array('/' . LBApplication::getCurrentlySelectedSubscription() . "/lbInvoice/dashboard")); } //$this->redirect(array("project/index")); // display the login form //LBApplication::renderPartial($this, 'login', array('model'=>$model)); } // if already login, show projects index if (isset(Yii::app()->user->id) && Yii::app()->user->id > 0) { $this->redirect(array('/' . LBApplication::getCurrentlySelectedSubscription() . "/lbInvoice/dashboard")); //$this->redirect(array("project/index")); } // display the login form LBApplication::renderPartial($this, 'login', array('model' => $model)); //$this->render('login',array('model'=>$model)); }
public static function getSubscriptionId() { $subcription_id = LBApplication::getCurrentlySelectedSubscription(); // Truyen tham so subcription_id cua he thong tich hop vao day. return $subcription_id; }
$("#hidden-quotation-customer-id").val(newValue); }', 'onShown' => 'js: function() { var $tip = $(this).data("editableContainer").tip(); var dropdown = $tip.find("select"); $(dropdown).bind("change", function(e){ onChangeCustomerDropdown(e,' . $model->lb_record_primary_key . '); }); }', 'options' => array('sourceCache' => false), 'htmlOptions' => array('id' => 'LbInvoice_quotation_customer_id_' . $model->lb_record_primary_key))); $custoemr_id = 0; $custoemr_name = ""; if ($model->lb_quotation_customer_id) { $custoemr_id = $model->lb_quotation_customer_id; $custoemr_name = str_replace(' ', '-', $model->customer->lb_customer_name); } if ($custoemr_id > 0) { echo ' <a id="user" href="' . $this->createUrl('/' . LBApplication::getCurrentlySelectedSubscription() . '/lbCustomer/' . $model->lb_quotation_customer_id . '-' . $custoemr_name) . '"><i class="icon-search"></i></a>'; } else { echo ' <a id="user"><i class="icon-search"></i></a>'; } ?> </div> </div> <div id="container-quotation-customer-address"> <div class="field-label-left"><?php echo Yii::t('lang', 'Billing Address'); ?> :</div> <div class="field-value-left"> <?php $this->widget('editable.EditableField', array('type' => 'select', 'model' => $model, 'attribute' => 'lb_quotation_customer_address_id', 'emptytext' => 'Choose address', 'url' => $model->getActionURLNormalized('ajaxUpdateField'), 'source' => $this->createUrl('/lbCustomerAddress/default/dropdownJSON', array('allow_add' => YES, 'quotation_id' => $model->lb_record_primary_key)), 'placement' => 'right', 'display' => 'js: function(value, sourceData) {
public function checkHiddenModule($mod_directory) { $user_id = YII::app()->user->id; // Kiểm tra tai khoản admin $ownSub = AccountSubscription::model()->checkIsSubscriptionOwner(LBApplication::getCurrentlySelectedSubscription()); //END $criteria = new CDbCriteria(); $criteria->condition = 'module_directory = "' . $mod_directory . '" AND module_hidden = 1'; $module = $this->getOneRecords($criteria); $basic_account = array(); if ($module) { // Kierm tra user da duoc gan module nay chua $checkModule = false; $basic_account = AccountBasicPermission::model()->findAll('module_id = "' . $module->lb_record_primary_key . '" AND account_id = ' . intval($user_id)); if (count($basic_account) > 0) { $checkModule = true; } // Kiem tra uer da duoc gan role ma co module nay chua $checkModuleRole = false; $role = AccountRoles::model()->findAll('accout_id=' . intval($user_id)); foreach ($role as $roleItem) { $basic_role = RolesBasicPermission::model()->findAll('role_id=' . intval($roleItem->role_id) . ' AND module_id = ' . intval($module->lb_record_primary_key)); if (count($basic_role) > 0) { $checkModuleRole = true; } } } // Kiem tra user co dc xem modules nay ko // $assignModulesUser = AccountBasicPermission::model()->findAll('account_id = '.intval($user_id).' AND module_id='.intval($dataProvider->data->module_id)); if (count($module) > 0 && $ownSub) { return true; } else { if (count($module) > 0 && ($checkModule == true || $checkModuleRole == true)) { return true; } } return false; }
/** * Manages all models. */ public function actionAdmin() { //$model = new AccountTeamMember('search'); //$model->unsetAttributes(); // clear any default values // get team members I'm in charge //$model->master_account_id = Yii::app()->user->id; $subcription = LBApplication::getCurrentlySelectedSubscription(); // CADP for getting list my team members of team that user is the master account of. $memberCADataProvider = AccountTeamMember::model()->getTeamMembers($subcription); // CADP for getting list of members from OTHER teams of which user is NOT the master account of. $otherMemberCADataProvider = AccountTeamMember::model()->getMyOtherTeams(Yii::app()->user->id, $subcription); // CADP for invites to this user $invitesToUserCADataProvider = AccountInvitation::model()->getInvitesToAccount(Yii::app()->user->id); // get master account of people whose teams I'm part of $model2 = new AccountTeamMember('search'); $model2->unsetAttributes(); $model2->member_account_id = Yii::app()->user->id; if (isset($_GET['AccountTeamMember'])) { $model->attributes = $_GET['AccountTeamMember']; } $this->render('admin', array('memberCADataProvider' => $memberCADataProvider, 'otherMemberCADataProvider' => $otherMemberCADataProvider, 'invitesToUserCADataProvider' => $invitesToUserCADataProvider)); }