<?php
class ControllerCommonColumnLeft extends Controller {
	public function index() {
		if (isset($this->request->get['user_token']) && isset($this->session->data['user_token']) && ($this->request->get['user_token'] == $this->session->data['user_token'])) {
			$this->load->language('common/column_left');

			// Create a 3 level menu array
			// Level 2 can not have children
			
			// Menu
			$data['menus'][] = array(
				'id'       => 'menu-dashboard',
				'icon'	   => 'fa-dashboard',
				'name'	   => $this->language->get('text_dashboard'),
				'href'     => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true),
				'children' => array()
			);
			

                // Opencartvip
                $opencartvip = $this->load->controller('opencartvip/opencartvip/menu');

                if ($opencartvip) {
                    $data['menus'][] = $opencartvip;
                }
            
			// Catalog
			$catalog = array();
			
			if ($this->user->hasPermission('access', 'catalog/category')) {
				$catalog[] = array(
					'name'	   => $this->language->get('text_category'),
					'href'     => $this->url->link('catalog/category', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'catalog/product')) {
				$catalog[] = array(
					'name'	   => $this->language->get('text_product'),
					'href'     => $this->url->link('catalog/product', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
	
			
			
			
			if ($this->user->hasPermission('access', 'catalog/option')) {
				$catalog[] = array(
					'name'	   => $this->language->get('text_option'),
					'href'     => $this->url->link('catalog/option', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'catalog/manufacturer')) {
				$catalog[] = array(
					'name'	   => $this->language->get('text_manufacturer'),
					'href'     => $this->url->link('catalog/manufacturer', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'catalog/download')) {
				$catalog[] = array(
					'name'	   => $this->language->get('text_download'),
					'href'     => $this->url->link('catalog/download', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
		
			
			if ($this->user->hasPermission('access', 'catalog/information')) {		
				$catalog[] = array(
					'name'	   => $this->language->get('text_information'),
					'href'     => $this->url->link('catalog/information', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);					
			}
			
			if ($catalog) {
				$data['menus'][] = array(
					'id'       => 'menu-catalog',
					'icon'	   => 'fa-tags', 
					'name'	   => $this->language->get('text_catalog'),
					'href'     => '',
					'children' => $catalog
				);		
			}

			$this->load->language('extension/reviewpro');
			$reviewpro = array();
			
			if ($this->user->hasPermission('access', 'extension/reviewlist')) {
				$reviewpro[] = array(
						'name'	   => $this->language->get('text_reviewlist'),
						'href'     => $this->url->link('extension/reviewlist', 'user_token=' . $this->session->data['user_token'], true),
						'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'extension/reviewpro')) {
				$reviewpro[] = array(
					'name'	   => "Genel Ayarlar",
					'href'     => $this->url->link('extension/reviewpro', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			
			
			if ($this->user->hasPermission('access', 'extension/reviewprocj')) {
				$reviewpro[] = array(
						'name'	   => $this->language->get('text_reviewprocj'),
						'href'     => $this->url->link('extension/reviewprocj', 'user_token=' . $this->session->data['user_token'], true),
						'children' => array()		
				);
			}
			
			if ($reviewpro) {
				$data['menus'][] = array(
					'id'       => 'menu-reviewpro',
					'icon'	   => 'fa-star', 
					'name'	   => 'Yorumlar',
					'href'     => '',
					'children' => $reviewpro
				);	
			}
				
			// Sales
			$sale = array();
			
			if ($this->user->hasPermission('access', 'sale/order')) {
				$sale[] = array(
					'name'	   => $this->language->get('text_order'),
					'href'     => $this->url->link('sale/order', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			
		
			
			if ($this->user->hasPermission('access', 'sale/return')) {
				$sale[] = array(
					'name'	   => $this->language->get('text_return'),
					'href'     => $this->url->link('sale/return', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			
			
			if ($sale) {
				$data['menus'][] = array(
					'id'       => 'menu-sale',
					'icon'	   => 'fa-shopping-cart', 
					'name'	   => $this->language->get('text_sale'),
					'href'     => '',
					'children' => $sale
				);
			}
			
			// Customer
			$customer = array();
			
			if ($this->user->hasPermission('access', 'customer/customer')) {
				$customer[] = array(
					'name'	   => $this->language->get('text_customer'),
					'href'     => $this->url->link('customer/customer', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			
			if ($this->user->hasPermission('access', 'customer/customer_group')) {
				$customer[] = array(
					'name'	   => $this->language->get('text_customer_group'),
					'href'     => $this->url->link('customer/customer_group', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
				
			if ($this->user->hasPermission('access', 'customer/customer_approval')) {
				$customer[] = array(
					'name'	   => $this->language->get('text_customer_approval'),
					'href'     => $this->url->link('customer/customer_approval', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
						
			if ($this->user->hasPermission('access', 'customer/custom_field')) {		
				$customer[] = array(
					'name'	   => $this->language->get('text_custom_field'),
					'href'     => $this->url->link('customer/custom_field', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			if ($this->user->hasPermission('access', 'marketing/coupon')) {	
				$customer[] = array(
					'name'	   => $this->language->get('text_coupon'),
					'href'     => $this->url->link('marketing/coupon', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			if ($this->user->hasPermission('access', 'marketing/contact')) {
				$customer[] = array(
					'name'	   => $this->language->get('text_contact'),
					'href'     => $this->url->link('marketing/contact', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			if ($customer) {
				$data['menus'][] = array(
					'id'       => 'menu-customer',
					'icon'	   => 'fa-user', 
					'name'	   => $this->language->get('text_customer'),
					'href'     => '',
					'children' => $customer
				);	
			}
			
			// Extension
			$marketplace = array();
	
			
			if ($this->user->hasPermission('access', 'marketplace/installer')) {		
				$marketplace[] = array(
					'name'	   => $this->language->get('text_installer'),
					'href'     => $this->url->link('marketplace/installer', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);					
			}	
				if ($this->user->hasPermission('access', 'marketplace/modification')) {
				$marketplace[] = array(
					'name'	   => $this->language->get('text_modification'),
					'href'     => $this->url->link('marketplace/modification', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			 
			if ($this->user->hasPermission('access', 'marketplace/extension')) {		
			
				$marketplace[] = array(
                    'name'	   => $this->language->get('text_module'),
                    'href'     => $this->url->link('marketplace/extension&type=module', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
				$marketplace[] = array(
                    'name'	   => $this->language->get('text_payment'),
                    'href'     => $this->url->link('marketplace/extension&type=payment', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
				$marketplace[] = array(
                    'name'	   => $this->language->get('text_shipping'),
                    'href'     => $this->url->link('marketplace/extension&type=shipping', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
				$marketplace[] = array(
                    'name'	   => $this->language->get('text_total'),
                    'href'     => $this->url->link('marketplace/extension&type=total', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
				$marketplace[] = array(
                    'name'	   => $this->language->get('text_feed'),
                    'href'     => $this->url->link('marketplace/extension&type=feed', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
				$marketplace[] = array(
                    'name'	   => $this->language->get('text_analytics'),
                    'href'     => $this->url->link('marketplace/extension&type=analytics', 'user_token=' . $this->session->data['user_token'], true),
                    'children' => array()
                );
			}
								
		
		
					
				$marketplace[] = array(
					'name'	   => $this->language->get('<img style="margin-bottom:3px" src="view/image/netgsm/netgsm-icon.png" width="16" height="16"> Netgsm'),
					'href'     => $this->url->link('extension/module/netgsm', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);

      $this->load->model('setting/extension');

      if (!in_array('pro_email', $this->model_setting_extension->getInstalled('module'))) {
        $marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/pro_email/img/icon.png"/> Email Şablonu Yükle',
					'href'     => $this->url->link('extension/extension/module/install', 'extension=pro_email&redir=1&user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
      } else if ($this->user->hasPermission('access', 'module/pro_email')) {
				$marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/pro_email/img/icon.png"/> Email Şablonu',
					'href'     => $this->url->link('module/pro_email', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
      

      if ($this->user->hasPermission('access', 'module/complete_seo')) {
				$marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/seo_package/img/icon.png"/> Seo Paketi',
					'href'     => $this->url->link('module/complete_seo', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
      

      $this->load->model('setting/extension');

      if (!in_array('universal_feed', $this->model_setting_extension->getInstalled('feed'))) {
        $marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/universal_feed/img/icon.png"/> Xml Çıktısı Yükle',
					'href'     => $this->url->link('extension/extension/feed/install', 'extension=universal_feed&redir=1&user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
      } else if ($this->user->hasPermission('access', 'feed/universal_feed')) {
				$marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/universal_feed/img/icon.png"/> XML ÇIKTISI',
					'href'     => $this->url->link('feed/universal_feed', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
      

      $this->load->model('setting/extension');

      if (!in_array('universal_import', $this->model_setting_extension->getInstalled('module'))) {
        $marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/universal_import/img/icon.png"/> XML Entegrasyonunu Kur',
					'href'     => $this->url->link('extension/extension/module/install', 'extension=universal_import&redir=1&user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
      } else if ($this->user->hasPermission('access', 'module/universal_import')) {
				$marketplace[] = array(
					'name'	   => '<img style="vertical-align:top" src="view/universal_import/img/icon.png"/> XML Entegrasyonu',
					'href'     => $this->url->link('module/universal_import', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
      

			/* Abandoned Carts */						
			
		
			if ($this->user->hasPermission('access', 'extension/statistics')) {		
				$marketplace[] = array(
					'name'	   => $this->language->get('text_control_panel'),
					'href'     => $this->url->link('extension/statistics', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);					
			}	
					
			
			
			/* Abandoned Carts */
			if ($marketplace) {					
				$data['menus'][] = array(
					'id'       => 'menu-extension',
					'icon'	   => 'fa-puzzle-piece', 
					'name'	   => $this->language->get('text_extension'),
					'href'     => '',
					'children' => $marketplace
				);		
			}
			
	
	
			
			
		
			
			// System
			$system = array();
			
			if ($this->user->hasPermission('access', 'setting/setting')) {
				$system[] = array(
					'name'	   => $this->language->get('text_setting'),
					'href'     => $this->url->link('setting/store', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
		
			// Users
			$user = array();
			
			if ($this->user->hasPermission('access', 'user/user')) {
				$user[] = array(
					'name'	   => $this->language->get('text_users'),
					'href'     => $this->url->link('user/user', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			
			if ($this->user->hasPermission('access', 'user/user_permission')) {	
				$user[] = array(
					'name'	   => $this->language->get('text_user_group'),
					'href'     => $this->url->link('user/user_permission', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			
			if ($this->user->hasPermission('access', 'user/api')) {		
				$user[] = array(
					'name'	   => $this->language->get('text_api'),
					'href'     => $this->url->link('user/api', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
			
			if ($user) {
				$system[] = array(
					'name'	   => $this->language->get('text_users'),
					'href'     => '',
					'children' => $user		
				);
			}
			
			// Localisation
			$localisation = array();
			
		
			if ($this->user->hasPermission('access', 'localisation/language')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_language'),
					'href'     => $this->url->link('localisation/language', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/currency')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_currency'),
					'href'     => $this->url->link('localisation/currency', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/stock_status')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_stock_status'),
					'href'     => $this->url->link('localisation/stock_status', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/order_status')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_order_status'),
					'href'     => $this->url->link('localisation/order_status', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			// Returns
			$return = array();
			
			if ($this->user->hasPermission('access', 'localisation/return_status')) {
				$return[] = array(
					'name'	   => $this->language->get('text_return_status'),
					'href'     => $this->url->link('localisation/return_status', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/return_action')) {
				$return[] = array(
					'name'	   => $this->language->get('text_return_action'),
					'href'     => $this->url->link('localisation/return_action', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);		
			}
			
			if ($this->user->hasPermission('access', 'localisation/return_reason')) {
				$return[] = array(
					'name'	   => $this->language->get('text_return_reason'),
					'href'     => $this->url->link('localisation/return_reason', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($return) {	
				$localisation[] = array(
					'name'	   => $this->language->get('text_return'),
					'href'     => '',
					'children' => $return		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/country')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_country'),
					'href'     => $this->url->link('localisation/country', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/zone')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_zone'),
					'href'     => $this->url->link('localisation/zone', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/geo_zone')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_geo_zone'),
					'href'     => $this->url->link('localisation/geo_zone', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);
			}
			
			// Tax		
			$tax = array();
			
			if ($this->user->hasPermission('access', 'localisation/tax_class')) {
				$tax[] = array(
					'name'	   => $this->language->get('text_tax_class'),
					'href'     => $this->url->link('localisation/tax_class', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/tax_rate')) {
				$tax[] = array(
					'name'	   => $this->language->get('text_tax_rate'),
					'href'     => $this->url->link('localisation/tax_rate', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);
			}
			
			if ($tax) {	
				$localisation[] = array(
					'name'	   => $this->language->get('text_tax'),
					'href'     => '',
					'children' => $tax		
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/length_class')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_length_class'),
					'href'     => $this->url->link('localisation/length_class', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);
			}
			
			if ($this->user->hasPermission('access', 'localisation/weight_class')) {
				$localisation[] = array(
					'name'	   => $this->language->get('text_weight_class'),
					'href'     => $this->url->link('localisation/weight_class', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);
			}
			
			if ($localisation) {																
				$system[] = array(
					'name'	   => $this->language->get('text_localisation'),
					'href'     => '',
					'children' => $localisation	
				);
			}
			
			// Tools	
			$maintenance = array();
				
			if ($this->user->hasPermission('access', 'tool/backup')) {
				$maintenance[] = array(
					'name'	   => $this->language->get('text_backup'),
					'href'     => $this->url->link('tool/backup', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
					
			if ($this->user->hasPermission('access', 'tool/upload')) {
				$maintenance[] = array(
					'name'	   => $this->language->get('text_upload'),
					'href'     => $this->url->link('tool/upload', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);	
			}
						
			if ($this->user->hasPermission('access', 'tool/log')) {
				$maintenance[] = array(
					'name'	   => $this->language->get('text_log'),
					'href'     => $this->url->link('tool/log', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()		
				);
			}
		
			if ($maintenance) {
				$system[] = array(
					'id'       => 'menu-maintenance',
					'icon'	   => 'fa-cog', 
					'name'	   => $this->language->get('text_maintenance'),
					'href'     => '',
					'children' => $maintenance
				);
			}		
			if ($this->user->hasPermission('access', 'design/layout')) {
				$system[] = array(
					'name'	   => $this->language->get('text_layout'),
					'href'     => $this->url->link('design/layout', 'user_token=' . $this->session->data['user_token'], true),
					'children' => array()
				);	
			}
		
			if ($system) {
				$data['menus'][] = array(
					'id'       => 'menu-system',
					'icon'	   => 'fa-cog', 
					'name'	   => $this->language->get('text_system'),
					'href'     => '',
					'children' => $system
				);
			}
			
			
			
	
			
			return $this->load->view('common/column_left', $data);
		}
	}
}