<?php
class EducationController extends Controller {
	public $layout = 'column2';

	 public function accessRules() {
        return array(
            array('allow', // dev mode bypass for lesson page
                'actions' => array('lesson'),
                'expression' => 'isset($_GET["dev"])',
            ),
            array('allow', // allow trader user to perform actions
                'actions' => array('Education', 'Books', 'Strategies', 'Tutorials', 'beginnerCourse', 'advancedCourse', 'metatrader', 'Tools', 'lesson'),
                'roles' => array('user6', 'user4', 'user3', 'user2'),
            ),
            array('deny', // deny all users
                'users' => array('*'),
            ),
        );
    }

    public function init() {
        if(Yii::app()->params['styles_type'] == 'new'){
            $this->layout = 'sidebar';
        }
    }
	
	public function actionEducation(){
		$this->pageTitle = Yii::t("main", "708_educ_materials");
        $this->breadcrumbs = array(Yii::t("main", "708_educ_materials"));
		
		$view=new Account();
		$getInfo = $view->GetInfo();
		$model_account=$view->GetAccount(); 
		$allow = (count((array)$model_account) > 0) ? true : false;
	
		if(wlParams::get('officeCode') == 22){		
			if($getInfo->Type == 6 && $getInfo->GroupType == 2){
				$Registration2 = new RegistrationTrader('Corporate');
				$Registration2->initTrader();
				$isFullProfile = $Registration2->isFull();
			}else{
				$Registration = new Registration('Individual');
				$Registration->initIndv();
				$isFullProfile = $Registration->isFull();
			}
		
			 $this->render('educVideosNoor', array('allow'=>$isFullProfile, 'Type'=>$getInfo->Type));
		}else{
			$this->render('educVideos', array('page' => '0', 'allow'=>$allow));
		} 
		
	}
	public function actionTools(){
		$this->pageTitle = Yii::t("education","1_trading_tools");
        $this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","1_trading_tools"));
		
		$view=new Account();
		$model_account=$view->GetAccount(); 
		$allow = (count((array)$model_account) > 0) ? true : false;
		
        $this->render('educVideos', array('page' => '1', 'allow'=>$allow));
	}
	public function actionBeginner(){
		$this->pageTitle = Yii::t("education","2_beginners_course");
		$this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","2_beginners_course"));
		
		$view=new Account();
		$model_account=$view->GetAccount(); 
		$allow = (count((array)$model_account) > 0) ? true : false;
		
        $this->render('educVideos', array('page' => '2', 'allow'=>$allow));
	}
	public function actionTutorials(){
		$this->pageTitle = Yii::t("education","3_mt4_tutorials");
		$this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","3_mt4_tutorials"));
		
		$view=new Account();
		$model_account=$view->GetAccount(); 
		$allow = (count((array)$model_account) > 0) ? true : false;
		
        $this->render('educVideos', array('page' => '3', 'allow'=>$allow));
	}
	public function actionStrategies(){
		$this->pageTitle = Yii::t("education","4_trading_strategies");
		$this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","4_trading_strategies"));
		
		$view=new Account();
		$model_account=$view->GetAccount(); 
		$allow = (count((array)$model_account) > 0) ? true : false;
		
        $this->render('educVideos', array('page' => '4', 'allow'=>$allow));
	}
	public function actionLesson(){
		$this->pageTitle = 'Financial Literacy Course';
		$this->breadcrumbs = array(
			Yii::t("main", "708_educ_materials") => '/education/index.html',
			'Financial Literacy Course',
		);
		$this->render('lesson');
	}

	public function actionBooks(){
		$this->pageTitle = Yii::t("education","5_traders_ebooks");
		$this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","5_traders_ebooks"));
		
		$view=new Account();
		$model_account=$view->GetAccount(); 
		$allow = (count((array)$model_account) > 0) ? true : false;
		
        $this->render('educVideos', array('page' => '5', 'allow'=>$allow));
	}

    public function actionBeginnerCourse(){
        $this->pageTitle = Yii::t("education","28_beginer_course");
        $this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","28_beginer_course"));

        $this->render('educVideoList', array(
            'title' => $this->pageTitle,
            'videos' => [
                ['name' => Yii::t("education","31_word_trading"), 'url' => 'https://www.youtube.com/embed/WZdNLup-s4Y'],
                ['name' => Yii::t("education","31_what_is_forex"), 'url' => 'https://www.youtube.com/embed/n1s_7--QNc4'],
                ['name' => Yii::t("education","31_what_is_cfd"), 'url' => 'https://www.youtube.com/embed/ofzKS142bYA'],
                ['name' => Yii::t("education","31_what_is_commodity"), 'url' => 'https://www.youtube.com/embed/ukSCRm_BQTY'],
                ['name' => Yii::t("education","31_what_is_index"), 'url' => 'https://www.youtube.com/embed/1p4WiJbXTh0'],
                ['name' => Yii::t("education","31_what_is_share"), 'url' => 'https://www.youtube.com/embed/goCm1EZMT_Q'],
                ['name' => Yii::t("education","31_pips_points_ticks"), 'url' => 'https://www.youtube.com/embed/ZEPlMOtU7u8'],
                ['name' => Yii::t("education","31_balance_equity"), 'url' => 'https://www.youtube.com/embed/epwefCXIKM8'],
                ['name' => Yii::t("education","31_bul_and_bear_market"), 'url' => 'https://www.youtube.com/embed/rGo_P5mdq_Q'],
                ['name' => Yii::t("education","31_lots"), 'url' => 'https://www.youtube.com/embed/RDmc32dUrVc'],
                ['name' => Yii::t("education","31_bid_and_ask"), 'url' => 'https://www.youtube.com/embed/MJzud5mM4NM'],
                ['name' => Yii::t("education","31_short_and_long_pos"), 'url' => 'https://www.youtube.com/embed/AL2HI4PsH1I'],
                ['name' => Yii::t("education","31_stop_and_los_profit"), 'url' => 'https://www.youtube.com/embed/BQKDyNwCb-E'],
                ['name' => Yii::t("education","31_pending_orders"), 'url' => 'https://www.youtube.com/embed/LJhffIeLtGk'],
                ['name' => Yii::t("education","31_leverage_margin"), 'url' => 'https://www.youtube.com/embed/be6BjjFSRx8'],
                ['name' => Yii::t("education","31_chart_types"), 'url' => 'https://www.youtube.com/embed/ky24qyXPD60'],
                ['name' => Yii::t("education","31_trading_emotionally"), 'url' => 'https://www.youtube.com/embed/ddSWOSv4jA8'],
                ['name' => Yii::t("education","31_average_down"), 'url' => 'https://www.youtube.com/embed/-jYWmk7iySA'],
                ['name' => Yii::t("education","31_trading_without_risk"), 'url' => 'https://www.youtube.com/embed/m6wgmBXbIvY'],
                ['name' => Yii::t("education","31_not_following_plan"), 'url' => 'https://www.youtube.com/embed/-W2fwb9PlAI'],
            ]
        ));
	}

	public function actionAdvancedCourse(){
        $this->pageTitle = Yii::t("education","29_advanced_course");
        $this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","29_advanced_course"));

        $this->render('educVideoList', array(
            'title' => $this->pageTitle,
            'videos' => [
                ['name' => Yii::t("education","32_fundamental_analysis"), 'url' => 'https://www.youtube.com/embed/vWrQ0p8ZJDA'],
                ['name' => Yii::t("education","32_economic_calendar"), 'url' => 'https://www.youtube.com/embed/QXwrW2VKbrk'],
                ['name' => Yii::t("education","32_how_to_apply_calendar"), 'url' => 'https://www.youtube.com/embed/omjiXjJEWJ8'],
                ['name' => Yii::t("education","32_what_is_technical"), 'url' => 'https://www.youtube.com/embed/w4jUZzORHTY'],
                ['name' => Yii::t("education","32_support_abn"), 'url' => 'https://www.youtube.com/embed/upbk9IZglPo'],
                ['name' => Yii::t("education","32_how_to_find_support"), 'url' => 'https://www.youtube.com/embed/6nXd2ENjk9M'],
                ['name' => Yii::t("education","32_trend"), 'url' => 'https://www.youtube.com/embed/XfsOQcPTlaA'],
                ['name' => Yii::t("education","32_how_to_identify_trends"), 'url' => 'https://www.youtube.com/embed/dT9pGX-UecI'],
                ['name' => Yii::t("education","32_chart_time_frame"), 'url' => 'https://www.youtube.com/embed/QxODHlFG1bw'],
                ['name' => Yii::t("education","32_whats_tech_indicator"), 'url' => 'https://www.youtube.com/embed/Um1rWcNqiZo'],
                ['name' => Yii::t("education","33_moving_average"), 'url' => 'https://www.youtube.com/embed/122lfWxnSB0'],
                ['name' => Yii::t("education","33_how_to_apply_averages"), 'url' => 'https://www.youtube.com/embed/kPNvLkEwWUI'],
                ['name' => Yii::t("education","33_macd"), 'url' => 'https://www.youtube.com/embed/gYqHKbHu-a4'],
                ['name' => Yii::t("education","33_how_to_use_macd"), 'url' => 'https://www.youtube.com/embed/3BJ2QQywu2U'],
                ['name' => Yii::t("education","33_bolling_bands"), 'url' => 'https://www.youtube.com/embed/3cPsDzCIT9c'],
                ['name' => Yii::t("education","34_how_to_apply_bands"), 'url' => 'https://www.youtube.com/embed/cLALDOjGj8Q'],
                ['name' => Yii::t("education","35_rsi"), 'url' => 'https://www.youtube.com/embed/P63uH2OKiuo'],
                ['name' => Yii::t("education","35_how_to_use_rsi"), 'url' => 'https://www.youtube.com/embed/19EEPeN_VT0'],
                ['name' => Yii::t("education","35_cup_and_handle"), 'url' => 'https://www.youtube.com/embed/U7G0A5JE04U'],
                ['name' => Yii::t("education","35_how_to_trade_cup"), 'url' => 'https://www.youtube.com/embed/2u86THw6m9o'],
                ['name' => Yii::t("education","35_asc_and_desc"), 'url' => 'https://www.youtube.com/embed/l6PIM_caNNk'],
                ['name' => Yii::t("education","35_how_to_trade_asc_and_desc"), 'url' => 'https://www.youtube.com/embed/vqIaTc9w39s'],
                ['name' => Yii::t("education","35_rising_and_falling"), 'url' => 'https://www.youtube.com/embed/ETgCGsbDAWo'],
                ['name' => Yii::t("education","35_how_to_trade_rising"), 'url' => 'https://www.youtube.com/embed/VFWX-CrCOuk'],
                ['name' => Yii::t("education","35_triple_to_top"), 'url' => 'https://www.youtube.com/embed/rM8ZOj-bQyM'],
                ['name' => Yii::t("education","35_how_to_trade_triple"), 'url' => 'https://www.youtube.com/embed/nIri7xqybYc'],
                ['name' => Yii::t("education","35_head_and_shoulders"), 'url' => 'https://www.youtube.com/embed/jIH3f51WBp8'],
                ['name' => Yii::t("education","35_how_to_trade_head_and_shoulders"), 'url' => 'https://www.youtube.com/embed/usWXPQpAMq8'],
            ]
        ));
	}

    public function actionMetatrader(){
        $this->pageTitle = Yii::t("education","30_metatrader4");
        $this->breadcrumbs = array(Yii::t("main", "708_educ_materials") => ('/education/index.html'), Yii::t("education","30_metatrader4"));

        $this->render('educVideoList', array(
            'title' => $this->pageTitle,
            'videos' => [
                ['name' => Yii::t("education","36_mt4_terminal_window"), 'url' => 'https://www.youtube.com/embed/n3rAGurYXpU'],
                ['name' => Yii::t("education","36_mt4_opening_order"), 'url' => 'https://www.youtube.com/embed/TYhzrfA4RXY'],
                ['name' => Yii::t("education","36_mt4_creating_pending_order"), 'url' => 'https://www.youtube.com/embed/_p40sml2eiQ'],
                ['name' => Yii::t("education","36_mt4_closing_order"), 'url' => 'https://www.youtube.com/embed/tkwHOJPwxkY'],
                ['name' => Yii::t("education","36_mt4_setting_sl_and_tp"), 'url' => 'https://www.youtube.com/embed/_--T7x0MCKU'],
                ['name' => Yii::t("education","36_mt4_using_trailing_stop"), 'url' => 'https://www.youtube.com/embed/y_bBEnJS2qE'],
                ['name' => Yii::t("education","36_mt4_one_click_trading"), 'url' => 'https://www.youtube.com/embed/l5ny5s4s074'],
                ['name' => Yii::t("education","36_mt4_adding_indicators_to_the_chart"), 'url' => 'https://www.youtube.com/embed/5Vcl3CVmS34'],
            ]
        ));
	}


}
