shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

activity.php (4522B)


      1 <?php
      2 class ControllerExtensionDashboardActivity extends Controller {
      3 	private $error = array();
      4 
      5 	public function index() {
      6 		$this->load->language('extension/dashboard/activity');
      7 
      8 		$this->document->setTitle($this->language->get('heading_title'));
      9 
     10 		$this->load->model('setting/setting');
     11 
     12 		if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
     13 			$this->model_setting_setting->editSetting('dashboard_activity', $this->request->post);
     14 
     15 			$this->session->data['success'] = $this->language->get('text_success');
     16 
     17 			$this->response->redirect($this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true));
     18 		}
     19 
     20 		if (isset($this->error['warning'])) {
     21 			$data['error_warning'] = $this->error['warning'];
     22 		} else {
     23 			$data['error_warning'] = ''; 
     24 		}
     25 
     26 		$data['breadcrumbs'] = array();
     27 
     28 		$data['breadcrumbs'][] = array(
     29 			'text' => $this->language->get('text_home'),
     30 			'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'], true)
     31 		);
     32 
     33 		$data['breadcrumbs'][] = array(
     34 			'text' => $this->language->get('text_extension'),
     35 			'href' => $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true)
     36 		);
     37 
     38 		$data['breadcrumbs'][] = array(
     39 			'text' => $this->language->get('heading_title'),
     40 			'href' => $this->url->link('extension/dashboard/activity', 'user_token=' . $this->session->data['user_token'], true)
     41 		);
     42 
     43 		$data['action'] = $this->url->link('extension/dashboard/activity', 'user_token=' . $this->session->data['user_token'], true);
     44 
     45 		$data['cancel'] = $this->url->link('marketplace/extension', 'user_token=' . $this->session->data['user_token'] . '&type=dashboard', true);
     46 
     47 		if (isset($this->request->post['dashboard_activity_width'])) {
     48 			$data['dashboard_activity_width'] = $this->request->post['dashboard_activity_width'];
     49 		} else {
     50 			$data['dashboard_activity_width'] = $this->config->get('dashboard_activity_width');
     51 		}
     52 		
     53 		$data['columns'] = array();
     54 		
     55 		for ($i = 3; $i <= 12; $i++) {
     56 			$data['columns'][] = $i;
     57 		}
     58 		
     59 		if (isset($this->request->post['dashboard_activity_status'])) {
     60 			$data['dashboard_activity_status'] = $this->request->post['dashboard_activity_status'];
     61 		} else {
     62 			$data['dashboard_activity_status'] = $this->config->get('dashboard_activity_status');
     63 		}
     64 
     65 		if (isset($this->request->post['dashboard_activity_sort_order'])) {
     66 			$data['dashboard_activity_sort_order'] = $this->request->post['dashboard_activity_sort_order'];
     67 		} else {
     68 			$data['dashboard_activity_sort_order'] = $this->config->get('dashboard_activity_sort_order');
     69 		}
     70 
     71 		$data['header'] = $this->load->controller('common/header');
     72 		$data['column_left'] = $this->load->controller('common/column_left');
     73 		$data['footer'] = $this->load->controller('common/footer');
     74 
     75 		$this->response->setOutput($this->load->view('extension/dashboard/activity_form', $data));
     76 	}
     77 
     78 	protected function validate() {
     79 		if (!$this->user->hasPermission('modify', 'extension/dashboard/activity')) {
     80 			$this->error['warning'] = $this->language->get('error_permission');
     81 		}
     82 
     83 		return !$this->error;
     84 	}
     85 	
     86 	public function dashboard() {
     87 		$this->load->language('extension/dashboard/activity');
     88 
     89 		$data['user_token'] = $this->session->data['user_token'];
     90 
     91 		$data['activities'] = array();
     92 
     93 		$this->load->model('extension/dashboard/activity');
     94 
     95 		$results = $this->model_extension_dashboard_activity->getActivities();
     96 
     97 		foreach ($results as $result) {
     98 			$comment = vsprintf($this->language->get('text_activity_' . $result['key']), json_decode($result['data'], true));
     99 
    100 			$find = array(
    101 				'customer_id=',
    102 				'order_id=',
    103 				'return_id='
    104 			);
    105 
    106 			$replace = array(
    107 				$this->url->link('customer/customer/edit', 'user_token=' . $this->session->data['user_token'] . '&customer_id=', true),
    108 				$this->url->link('sale/order/info', 'user_token=' . $this->session->data['user_token'] . '&order_id=', true),
    109 				$this->url->link('sale/return/edit', 'user_token=' . $this->session->data['user_token'] . '&return_id=', true)
    110 			);
    111 
    112 			$data['activities'][] = array(
    113 				'comment'    => str_replace($find, $replace, $comment),
    114 				'date_added' => date($this->language->get('datetime_format'), strtotime($result['date_added']))
    115 			);
    116 		}
    117 
    118 		return $this->load->view('extension/dashboard/activity_info', $data);
    119 	}
    120 }