Exemplo n.º 1
0
 public function init()
 {
     date_default_timezone_set('Asia/Tel_Aviv');
     //\Yii::$app->language = 'he_il';
     //if ($this->company==null) {
     //    Yii::$app->user->Set('Company', 0);
     //}
     if (!Yii::$app->user->isGuest) {
         \app\helpers\Linet3Helper::SetTheme();
         date_default_timezone_set(Yii::$app->user->getParam('timezone'));
         Yii::$app->language = Yii::$app->user->getParam('language');
         Yii::$app->timezone = Yii::$app->user->getParam('timezone');
         //Yii::$app->theme = Yii::$app->user->getParam('theme');
         if (isset(Yii::$app->session['company'])) {
             $this->company = Yii::$app->session['company'];
             //if(Yii::$app->user->getParam('company')!=0){
             //    $this->company = Yii::$app->user->getParam('company');
             //Yii::$app->session['company']=0;
             //}
         }
     } else {
         //default theme
         //Yii::$app->theme = 'admin4';
     }
     Yii::info("Selected Company ID: " . $this->company);
     if ($this->company == 0) {
         if ($this->id != 'company') {
             //print "'".Yii::$app->controller->id."'";
             $this->redirect(\yii\helpers\BaseUrl::base() . '/company/index');
             Yii::$app->end();
         } else {
             //echo $this->id;
             //Yii::$app->end();
             Yii::$app->db->close();
             Yii::$app->db->dsn = Yii::$app->dbMain->dsn;
             Yii::$app->db->tablePrefix = Yii::$app->dbMain->tablePrefix;
             Yii::$app->db->username = Yii::$app->dbMain->username;
             Yii::$app->db->password = Yii::$app->dbMain->password;
             Yii::$app->db->open();
         }
     } else {
         //hasAccess!
         //$this->company = Company::findByPk($this->company);
         $company = Company::findOne($this->company);
         if ($company !== null) {
             Company::loadComp($company);
         } else {
             $this->redirect(\yii\helpers\BaseUrl::base() . '/company/index');
         }
     }
     //*/
     return parent::init();
 }
Exemplo n.º 2
0
 public function init()
 {
     date_default_timezone_set('Asia/Tel_Aviv');
     if (!\Yii::$app->user->isGuest) {
         \app\helpers\Linet3Helper::SetTheme();
         date_default_timezone_set(\Yii::$app->user->getParam('timezone'));
         \Yii::$app->language = Yii::$app->user->getParam('language');
     }
     if (Yii::$app->params['newInstall']) {
         if ($this->id != 'install') {
             //print "'".Yii::$app->controller->id."'";
             $this->redirect(\yii\helpers\BaseUrl::base() . '/install/index');
             Yii::$app->end();
         }
     } else {
         //include('upgrade.php');
     }
     //Yii::app()->clientScript->registerScriptFile($baseUrl.'/js/yourscript.js');
     return parent::init();
 }