<?php
class ControllerModulestockreport extends Controller {
	private $error = array(); 
	
	public function index() {   
		$this->language->load('module/stockreport');

		$this->document->setTitle($this->language->get('heading_title'));
		
		$this->load->model('module/stockreport');
		$this->load->model('catalog/product');
				
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
		
			$this->model_module_stockreport->setSetting($this->request->post);		
			
		  $this->session->data['success'] = $this->language->get('text_success');
						
		  $this->redirect($this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'));
		}
				
		$this->data['heading_title'] = $this->language->get('heading_title');
		

		
		

	
		$this->data['text_enabled'] = $this->language->get('text_enabled');
		$this->data['text_disabled'] = $this->language->get('text_disabled');
		


		
		
		$this->data['button_save'] = $this->language->get('button_save');
	
  		$this->data['breadcrumbs'] = array();

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('text_home'),
			'href'      => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => false
   		);

   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('text_module'),
			'href'      => $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
		
   		$this->data['breadcrumbs'][] = array(
       		'text'      => $this->language->get('heading_title'),
			'href'      => $this->url->link('module/stockreport', 'token=' . $this->session->data['token'], 'SSL'),
      		'separator' => ' :: '
   		);
		
		$this->data['action'] = $this->url->link('module/stockreport', 'token=' . $this->session->data['token'], 'SSL');
		
		$this->data['cancel'] = $this->url->link('extension/module', 'token=' . $this->session->data['token'], 'SSL');
		
		$this->data['modules'] = array();
		

		 

		 
		
		$this->template = 'module/stockreport.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);
				
		$this->response->setOutput($this->render());
	}
	
	public function install() {
       $this->load->model('module/stockreport');
       $this->model_module_stockreport->createTable(); 
 
       $this->load->model('setting/setting');
       $this->model_setting_setting->editSetting('stockreport', array('stockreport_status'=>1));
   }
   
   public function uninstall() {
        $this->load->model('module/stockreport');
        $this->model_module_stockreport->deleteTable();
         
        $this->load->model('setting/setting');
        $this->model_setting_setting->editSetting('stockreport', array('stockreport_status'=>0));
    }
	
	protected function validate() {
		if (!$this->user->hasPermission('modify', 'module/stockreport')) {
			$this->error['warning'] = $this->language->get('error_permission');
		}
					
		if (!$this->error) {
			return true;
		} else {
			return false;
		}	
	}
}
?>