-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller
107 lines (83 loc) · 3.37 KB
/
controller
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/* Note class naming convention */
class ControllerExtensionModuleTimeclock extends Controller {
private $error = array();
public function index() {
/* Load language file. */
$this->load->language('extension/module/timeclock');
$this->document->setTitle($this->language->get('heading_title'));
if (!$this->customer->isLogged()) {
$this->response->redirect($this->url->link('account/login', '', 'SSL'));
}
/* Check if data has been posted back. */
/* To do: Validate the data */
if (($this->request->server['REQUEST_METHOD'] == 'POST') && ($_POST['datestamp']) ) {
$this->load->model('extension/module/timeclock');
$data ['datestamp'] = $this->request->post['datestamp'];
$data ['custID'] = $this->customer->getId();
$this->model_extension_module_timeclock->setPunch($data['custID'],$this->request->post['datestamp']);
$data['success'] = true;
$this->cache->delete('timeclock');
$this->response->redirect($this->url->link('common/home'));
}
/* Load language strings. */
$data['text_edit'] = "edit";
$data['heading_title'] = $this->language->get('heading_title');
// $data['button_save'] = $this->language->get('button_save');
// $data['button_cancel'] = $this->language->get('button_cancel');
/* Loading up some URLS. */
// $data['cancel'] = $this->url->link('extension/extension', 'token=' . $this->session->data['token'], 'SSL');
$data['form_action'] = $this->url->link('extension/module/timeclock');
/* Present error messages to users. */
if (isset($this->error['warning'])) {
$data['error_warning'] = $this->error['warning'];
} else {
$data['error_warning'] = '';
}
/* Initial values for form. */
// if (isset($this->request->post['mymodule_title'])) {
// $data['mymodule_title'] = $this->request->post['mymodule_title'];
// } else {
// $data['mymodule_title'] = $this->config->get('mymodule_title');
// }
// if (isset($this->request->post['mymodule_text'])) {
// $data['mymodule_text'] = $this->request->post['mymodule_text'];
// } else {
// $data['mymodule_text'] = $this->config->get('mymodule_text');
// }
// if (isset($this->request->post['mymodule_status'])) {
// $data['mymodule_status'] = $this->request->post['mymodule_status'];
// } else {
// $data['mymodule_status'] = $this->config->get('mymodule_status');
// }
/* Breadcrumb. */
// $data['breadcrumbs'] = array();
// $data['breadcrumbs'][] = array(
// 'text' => "Home",
// 'href' => $this->url->link('common/home')
// );
// $data['breadcrumbs'][] = array(
// 'text' => "Time Clock",
// 'href' => $this->url->link('extension/module/timeclock')
// );
/* Render some output. */
// $data['header'] = $this->load->controller('common/header');
// $data['column_left'] = $this->load->controller('common/column_left');
// $data['footer'] = $this->load->controller('common/footer');
//if you want it as a route:
// $this->response->setOutput($this->load->view('extension/module/timeclock.tpl', $data));
//if you want it attached to layouts
return $this->load->view('extension/module/timeclock.tpl', $data);
}
/* Check user input. */
private function validate() {
// if (strlen($this->request->post['mymodule_title']) <= 3) {
// $this->error['warning'] = $this->language->get('error_title');
// }
// if ($this->error) {
// return false;
// } else {
// return true;
// }
}
}