Skip to content

Commit

Permalink
first fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoyigi committed Aug 14, 2014
1 parent 2fe692b commit 7e50056
Show file tree
Hide file tree
Showing 901 changed files with 24,069 additions and 5,815 deletions.
2 changes: 1 addition & 1 deletion application/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
| This indicates a fresh installation or upgrade. (BETA)
|
*/
$config['ti_setup'] = '';
$config['ti_setup'] = 'installed';

/* End of file config.php */
/* Location: ./application/config/config.php */
8 changes: 4 additions & 4 deletions application/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
$active_record = TRUE;

$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$db['default']['username'] = 'root';
$db['default']['password'] = 'rack080d';
$db['default']['database'] = 'tastyinstall';
$db['default']['dbdriver'] = 'mysqli';
$db['default']['dbprefix'] = 'ti_';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = FALSE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
Expand Down
5 changes: 4 additions & 1 deletion application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
$route['maintenance'] = 'main/maintenance';
$route['home'] = 'main/home';
$route['contact'] = 'main/contact';
$route['local'] = 'main/local';
$route['menus/(:any)'] = 'main/menus';
$route['menus'] = 'main/menus';
$route['locations'] = 'main/local/locations';
$route['local/(:any)'] = 'main/local';
$route['local'] = 'main/local';
$route['local/reviews'] = 'main/local/reviews';
$route['checkout'] = 'main/checkout';
$route['checkout/success'] = 'main/checkout/success';
$route['account'] = 'main/account';
Expand Down
23 changes: 22 additions & 1 deletion application/controllers/admin/countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public function __construct() {
$this->load->library('user');
$this->load->library('pagination');
$this->load->model('Countries_model');
$this->load->model('Image_tool_model');
}

public function index() {
Expand Down Expand Up @@ -82,6 +83,8 @@ public function index() {
$data['countries'][] = array(
'country_id' => $result['country_id'],
'name' => $result['country_name'],
'iso_code_2' => $result['iso_code_2'],
'flag' => (!empty($result['flag'])) ? $this->Image_tool_model->resize($result['flag']) : $this->Image_tool_model->resize('data/flags/no_flag.png'),
'status' => ($result['status'] === '1') ? 'Enabled' : 'Disabled',
'edit' => site_url(ADMIN_URI.'/countries/edit?id=' . $result['country_id'])
);
Expand Down Expand Up @@ -153,7 +156,22 @@ public function edit() {
$data['iso_code_3'] = $country_info['iso_code_3'];
$data['format'] = $country_info['format'];
$data['status'] = $country_info['status'];

$data['no_photo'] = $this->Image_tool_model->resize('data/flags/no_flag.png');

if ($this->input->post('flag')) {
$data['flag']['path'] = $this->Image_tool_model->resize($this->input->post('flag'));
$data['flag']['name'] = basename($this->input->post('flag'));
$data['flag']['input'] = $this->input->post('flag');
} else if (!empty($country_info['flag'])) {
$data['flag']['path'] = $this->Image_tool_model->resize($country_info['flag']);
$data['flag']['name'] = basename($country_info['flag']);
$data['flag']['input'] = $country_info['flag'];
} else {
$data['flag']['path'] = $this->Image_tool_model->resize('data/flags/no_flag.png');
$data['flag']['name'] = 'no_flag.png';
$data['flag']['input'] = 'data/flags/no_flag.png';
}

if ($this->input->post() AND $this->_addCountry() === TRUE) {
if ($this->input->post('save_close') !== '1' AND is_numeric($this->input->post('insert_id'))) {
redirect(ADMIN_URI.'/countries/edit?id='. $this->input->post('insert_id'));
Expand Down Expand Up @@ -188,6 +206,7 @@ public function _addCountry() {
$add['country_name'] = $this->input->post('country_name');
$add['iso_code_2'] = $this->input->post('iso_code_2');
$add['iso_code_3'] = $this->input->post('iso_code_3');
$add['flag'] = $this->input->post('flag');
$add['format'] = $this->input->post('format');
$add['status'] = $this->input->post('status');

Expand All @@ -213,6 +232,7 @@ public function _updateCountry() {
$update['country_name'] = $this->input->post('country_name');
$update['iso_code_2'] = $this->input->post('iso_code_2');
$update['iso_code_3'] = $this->input->post('iso_code_3');
$update['flag'] = $this->input->post('flag');
$update['format'] = $this->input->post('format');
$update['status'] = $this->input->post('status');

Expand Down Expand Up @@ -245,6 +265,7 @@ public function validateForm() {
$this->form_validation->set_rules('country_name', 'Country', 'xss_clean|trim|required|min_length[2]|max_length[128]');
$this->form_validation->set_rules('iso_code_2', 'ISO Code 2', 'xss_clean|trim|required|exact_length[2]');
$this->form_validation->set_rules('iso_code_3', 'ISO Code 3', 'xss_clean|trim|required|exact_length[3]');
$this->form_validation->set_rules('flag', 'Flag', 'xss_clean|trim|required');
$this->form_validation->set_rules('format', 'Format', 'xss_clean|trim|min_length[2]');
$this->form_validation->set_rules('status', 'Status', 'xss_clean|trim|required|integer');

Expand Down
157 changes: 125 additions & 32 deletions application/controllers/admin/coupons.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function index() {
$data['sort_code'] = site_url(ADMIN_URI.'/coupons'.$url.'sort_by=code&order_by='.$order_by);
$data['sort_type'] = site_url(ADMIN_URI.'/coupons'.$url.'sort_by=type&order_by='.$order_by);
$data['sort_discount'] = site_url(ADMIN_URI.'/coupons'.$url.'sort_by=discount&order_by='.$order_by);
$data['sort_validity'] = site_url(ADMIN_URI.'/coupons'.$url.'sort_by=validity&order_by='.$order_by);

$data['coupons'] = array();
$results = $this->Coupons_model->getList($filter);
Expand All @@ -94,6 +95,7 @@ public function index() {
'type' => ($result['type'] === 'P') ? 'Percentage' : 'Fixed Amount',
'discount' => ($result['type'] === 'P') ? round($result['discount']) .'%' : $result['discount'],
'min_total' => $result['min_total'],
'validity' => ucwords($result['validity']),
'description' => $result['description'],
'status' => ($result['status'] === '1') ? 'Enabled' : 'Disabled',
'edit' => site_url(ADMIN_URI.'/coupons/edit?id=' . $result['coupon_id'])
Expand Down Expand Up @@ -152,7 +154,15 @@ public function edit() {
$coupon_id = 0;
$data['action'] = site_url(ADMIN_URI.'/coupons/edit');
}


if ($this->input->post('validity')) {
$validity = $this->input->post('validity');
} else if (!empty($coupon_info['validity'])) {
$validity = $coupon_info['validity'];
} else {
$validity = 'forever';
}

$title = (isset($coupon_info['name'])) ? $coupon_info['name'] : 'New';
$this->template->setTitle('Coupon: '. $title);
$this->template->setHeading('Coupon: '. $title);
Expand All @@ -167,27 +177,44 @@ public function edit() {
$data['code'] = $coupon_info['code'];
$data['type'] = $coupon_info['type'];
$data['discount'] = substr($coupon_info['discount'], 0, strripos($coupon_info['discount'], '.'));
$data['min_total'] = $coupon_info['min_total'];
$data['min_total'] = substr($coupon_info['min_total'], 0, strripos($coupon_info['min_total'], '.'));
$data['redemptions'] = $coupon_info['redemptions'];
$data['customer_redemptions'] = $coupon_info['customer_redemptions'];
$data['description'] = $coupon_info['description'];
$data['start_date'] = (isset($coupon_info['start_date']) AND $coupon_info['start_date'] !== '0000-00-00') ? mdate('%d-%m-%Y', strtotime($coupon_info['start_date'])) : '';
$data['end_date'] = (isset($coupon_info['end_date']) AND $coupon_info['end_date'] !== '0000-00-00') ? mdate('%d-%m-%Y', strtotime($coupon_info['end_date'])) : '';
$data['validity'] = $validity;
$data['fixed_date'] = (empty($coupon_info['fixed_date']) OR $coupon_info['fixed_date'] === '0000-00-00') ? '' : mdate('%d-%m-%Y', strtotime($coupon_info['fixed_date']));
$data['fixed_from_time'] = (empty($coupon_info['fixed_from_time']) OR $coupon_info['fixed_from_time'] === '00:00:00') ? '' : mdate('%h:%i %a', strtotime($coupon_info['fixed_from_time']));
$data['fixed_to_time'] = (empty($coupon_info['fixed_to_time']) OR $coupon_info['fixed_to_time'] === '00:00:00') ? '' : mdate('%h:%i %a', strtotime($coupon_info['fixed_to_time']));
$data['period_start_date'] = (empty($coupon_info['period_start_date']) OR $coupon_info['period_start_date'] === '0000-00-00') ? '' : mdate('%d-%m-%Y', strtotime($coupon_info['period_start_date']));
$data['period_end_date'] = (empty($coupon_info['period_end_date']) OR $coupon_info['period_end_date'] === '0000-00-00') ? '' : mdate('%d-%m-%Y', strtotime($coupon_info['period_end_date']));
$data['recurring_every'] = (empty($coupon_info['recurring_every'])) ? array() : explode(', ', $coupon_info['recurring_every']);
$data['recurring_from_time'] = (empty($coupon_info['recurring_from_time']) OR $coupon_info['recurring_from_time'] === '00:00:00') ? '' : mdate('%h:%i %a', strtotime($coupon_info['recurring_from_time']));
$data['recurring_to_time'] = (empty($coupon_info['recurring_to_time']) OR $coupon_info['recurring_to_time'] === '00:00:00') ? '' : mdate('%h:%i %a', strtotime($coupon_info['recurring_to_time']));
$data['date_added'] = $coupon_info['date_added'];
$data['status'] = $coupon_info['status'];

$data['weekdays'] = array('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');

$data['fixed_time'] = '24hours';
if (isset($coupon_info['fixed_from_time'], $coupon_info['fixed_to_time']) AND ($coupon_info['fixed_from_time'] !== '00:00:00' AND $coupon_info['fixed_to_time'] !== '23:59:00')) {
$data['fixed_time'] = 'custom';
}

$data['recurring_time'] = '24hours';
if (isset($coupon_info['recurring_from_time'], $coupon_info['recurring_to_time']) AND ($coupon_info['recurring_from_time'] !== '00:00:00' AND $coupon_info['recurring_to_time'] !== '23:59:00')) {
$data['recurring_time'] = 'custom';
}

$data['coupon_histories'] = array();
$coupon_histories = $this->Coupons_model->getCouponHistories($coupon_id);
foreach ($coupon_histories as $coupon_history) {
$data['coupon_histories'][] = array(
'coupon_history_id' => $coupon_history['coupon_history_id'],
'order_id' => $coupon_history['order_id'],
'customer_name' => $coupon_history['first_name'] .' '. $coupon_history['last_name'],
'code' => $coupon_history['code'],
'amount' => $coupon_history['amount'],
'used' => $coupon_history['used'],
'used_url' => site_url(ADMIN_URI.'/coupons/edit?id='. $coupon_id .'&customer_id='. $coupon_history['customer_id']),
'date_used' => mdate('%d %M %y', strtotime($coupon_history['date_used']))
'date_used' => mdate('%d %M %y', strtotime($coupon_history['date_used'])),
'view' => site_url(ADMIN_URI.'/orders/edit?id='. $coupon_history['order_id'])
);
}

Expand Down Expand Up @@ -222,18 +249,38 @@ public function _addCoupon() {
} else if ( ! is_numeric($this->input->get('id')) AND $this->validateForm() === TRUE) {
$add = array();

$add['name'] = $this->input->post('name');
$add['code'] = str_replace(' ', '', $this->input->post('code'));
$add['type'] = $this->input->post('type');
$add['discount'] = $this->input->post('discount');
$add['min_total'] = $this->input->post('min_total');
$add['redemptions'] = $this->input->post('redemptions');
$add['customer_redemptions'] = $this->input->post('customer_redemptions');
$add['description'] = $this->input->post('description');
$add['start_date'] = $this->input->post('start_date');
$add['end_date'] = $this->input->post('end_date');
$add['status'] = $this->input->post('status');
$add['name'] = $this->input->post('name');
$add['code'] = str_replace(' ', '', $this->input->post('code'));
$add['type'] = $this->input->post('type');
$add['discount'] = $this->input->post('discount');
$add['min_total'] = $this->input->post('min_total');
$add['redemptions'] = $this->input->post('redemptions');
$add['customer_redemptions'] = $this->input->post('customer_redemptions');
$add['description'] = $this->input->post('description');
$add['validity'] = $this->input->post('validity');
$validity_times = $this->input->post('validity_times');
$add['fixed_date'] = $validity_times['fixed_date'];
$add['period_start_date'] = $validity_times['period_start_date'];
$add['period_end_date'] = $validity_times['period_end_date'];
$add['recurring_every'] = $validity_times['recurring_every'];
$add['status'] = $this->input->post('status');

if ($this->input->post('fixed_time') !== '24hours') {
$add['fixed_from_time'] = $validity_times['fixed_from_time'];
$add['fixed_to_time'] = $validity_times['fixed_to_time'];
} else {
$add['fixed_from_time'] = '12:00 AM';
$add['fixed_to_time'] = '11:59 PM';
}

if ($this->input->post('recurring_time') !== '24hours') {
$add['recurring_from_time'] = $validity_times['recurring_from_time'];
$add['recurring_to_time'] = $validity_times['recurring_to_time'];
} else {
$add['recurring_from_time'] = '12:00 AM';
$add['recurring_to_time'] = '11:59 PM';
}

if ($_POST['insert_id'] = $this->Coupons_model->addCoupon($add)) {
$this->session->set_flashdata('alert', '<p class="alert-success">Coupon added sucessfully.</p>');
} else {
Expand All @@ -251,19 +298,39 @@ public function _updateCoupon() {
} else if (is_numeric($this->input->get('id')) AND $this->validateForm() === TRUE) {
$update = array();

$update['coupon_id'] = $this->input->get('id');
$update['name'] = $this->input->post('name');
$update['code'] = str_replace(' ', '', $this->input->post('code'));
$update['type'] = $this->input->post('type');
$update['discount'] = $this->input->post('discount');
$update['min_total'] = $this->input->post('min_total');
$update['redemptions'] = $this->input->post('redemptions');
$update['coupon_id'] = $this->input->get('id');
$update['name'] = $this->input->post('name');
$update['code'] = str_replace(' ', '', $this->input->post('code'));
$update['type'] = $this->input->post('type');
$update['discount'] = $this->input->post('discount');
$update['min_total'] = $this->input->post('min_total');
$update['redemptions'] = $this->input->post('redemptions');
$update['customer_redemptions'] = $this->input->post('customer_redemptions');
$update['description'] = $this->input->post('description');
$update['start_date'] = $this->input->post('start_date');
$update['end_date'] = $this->input->post('end_date');
$update['status'] = $this->input->post('status');
$update['description'] = $this->input->post('description');
$update['validity'] = $this->input->post('validity');
$validity_times = $this->input->post('validity_times');
$update['fixed_date'] = $validity_times['fixed_date'];
$update['period_start_date'] = $validity_times['period_start_date'];
$update['period_end_date'] = $validity_times['period_end_date'];
$update['recurring_every'] = $validity_times['recurring_every'];
$update['status'] = $this->input->post('status');

if ($this->input->post('fixed_time') !== '24hours') {
$update['fixed_from_time'] = $validity_times['fixed_from_time'];
$update['fixed_to_time'] = $validity_times['fixed_to_time'];
} else {
$update['fixed_from_time'] = '12:00 AM';
$update['fixed_to_time'] = '11:59 PM';
}

if ($this->input->post('recurring_time') !== '24hours') {
$update['recurring_from_time'] = $validity_times['recurring_from_time'];
$update['recurring_to_time'] = $validity_times['recurring_to_time'];
} else {
$update['recurring_from_time'] = '12:00 AM';
$update['recurring_to_time'] = '11:59 PM';
}

if ($this->Coupons_model->updateCoupon($update)) {
$this->session->set_flashdata('alert', '<p class="alert-success">Coupon updated sucessfully.</p>');
} else {
Expand Down Expand Up @@ -302,8 +369,34 @@ public function validateForm() {
$this->form_validation->set_rules('redemptions', 'Redemptions', 'xss_clean|trim|integer');
$this->form_validation->set_rules('customer_redemptions', 'Customer Redemptions', 'xss_clean|trim|integer');
$this->form_validation->set_rules('description', 'Description', 'xss_clean|trim|min_length[2]|max_length[1028]');
$this->form_validation->set_rules('start_date', 'Start Date', 'xss_clean|trim|valid_date');
$this->form_validation->set_rules('end_date', 'End Date', 'xss_clean|trim|valid_date');
$this->form_validation->set_rules('validity', 'Validity', 'xss_clean|trim|required');

if ($this->input->post('validity') === 'fixed') {
$this->form_validation->set_rules('validity_times[fixed_date]', 'Fixed date', 'xss_clean|trim|required|valid_date');
$this->form_validation->set_rules('fixed_time', 'Fixed time', 'xss_clean|trim|required');

if ($this->input->post('fixed_time') !== '24hours') {
$this->form_validation->set_rules('validity_times[fixed_from_time]', 'Fixed from time', 'xss_clean|trim|required|valid_time');
$this->form_validation->set_rules('validity_times[fixed_to_time]', 'Fixed to time', 'xss_clean|trim|required|valid_time');
}
} else if ($this->input->post('validity') === 'period') {
$this->form_validation->set_rules('validity_times[period_start_date]', 'Period start date', 'xss_clean|trim|required|valid_date');
$this->form_validation->set_rules('validity_times[period_end_date]', 'Period end date', 'xss_clean|trim|required|valid_date');
} else if ($this->input->post('validity') === 'recurring') {
$this->form_validation->set_rules('validity_times[recurring_every]', 'Recurring every', 'xss_clean|trim|required');
if (isset($_POST['validity_times']['recurring_every'])) {
foreach ($_POST['validity_times']['recurring_every'] as $key => $value) {
$this->form_validation->set_rules('validity_times[recurring_every]['.$key.']', 'Recurring every', 'xss_clean|required');
}
}

$this->form_validation->set_rules('recurring_time', 'Recurring time', 'xss_clean|trim|required');
if ($this->input->post('recurring_time') !== '24hours') {
$this->form_validation->set_rules('validity_times[recurring_from_time]', 'Recurring from time', 'xss_clean|trim|required|valid_time');
$this->form_validation->set_rules('validity_times[recurring_to_time]', 'Recurring to time', 'xss_clean|trim|required|valid_time');
}
}

$this->form_validation->set_rules('status', 'Status', 'xss_clean|trim|required|integer');

if ($this->form_validation->run() === TRUE) {
Expand Down
17 changes: 9 additions & 8 deletions application/controllers/admin/customers.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,20 +337,21 @@ public function edit() {
public function autocomplete() {
$json = array();

if ($this->input->get('customer_name')) {
$filter = array(
'customer_name' => urldecode($this->input->get('customer_name'))
);
if ($this->input->get('term') OR $this->input->get('customer_id')) {
$filter['customer_name'] = $this->input->get('term');
$filter['customer_id'] = $this->input->get('customer_id');

$results = $this->Customers_model->getAutoComplete($filter);

if ($results) {
foreach ($results as $result) {
$json[] = array(
'customer_id' => $result['customer_id'],
'customer_name' => $result['first_name'] .' '. $result['last_name']
$json['results'][] = array(
'id' => $result['customer_id'],
'text' => utf8_encode($result['first_name'] .' '. $result['last_name'])
);
}
} else {
$json['results'] = array('id' => '0', 'text' => 'No Matches Found');
}
}

Expand Down Expand Up @@ -467,7 +468,7 @@ public function validateForm($customer_email = FALSE) {
$this->form_validation->set_rules('address['.$key.'][address_1]', '['.$key.'] Address 1', 'xss_clean|trim|required|min_length[3]|max_length[128]');
$this->form_validation->set_rules('address['.$key.'][city]', '['.$key.'] City', 'xss_clean|trim|required|min_length[2]|max_length[128]');
$this->form_validation->set_rules('address['.$key.'][postcode]', '['.$key.'] Postcode', 'xss_clean|trim|required|min_length[2]|max_length[10]');
$this->form_validation->set_rules('address['.$key.'][country_id]', '['.$key.'] Country', 'xss_clean|trim|required|integer');
$this->form_validation->set_rules('address['.$key.'][country]', '['.$key.'] Country', 'xss_clean|trim|required|integer');
}
}

Expand Down
Loading

0 comments on commit 7e50056

Please sign in to comment.