public function index($module = array())
{
$this->load->model('cart_module/Cart_model');
// load the cart model
$this->lang->load('cart_module/cart_module');
$this->user->restrict('Module.CartModule');
if (!empty($module)) {
$title = isset($module['title']) ? $module['title'] : $this->lang->line('_text_title');
$this->template->setTitle('Module: ' . $title);
$this->template->setHeading('Module: ' . $title);
$this->template->setButton($this->lang->line('button_save'), array('class' => 'btn btn-primary', 'onclick' => '$(\'#edit-form\').submit();'));
$this->template->setButton($this->lang->line('button_save_close'), array('class' => 'btn btn-default', 'onclick' => 'saveClose();'));
$this->template->setButton($this->lang->line('button_icon_back'), array('class' => 'btn btn-default', 'href' => site_url('extensions')));
$this->template->setScriptTag(assets_url('js/jquery-sortable.js'), 'jquery-sortable-js');
if ($this->input->post() and $this->_updateModule() === TRUE) {
if ($this->input->post('save_close') === '1') {
redirect('extensions');
}
redirect('extensions/edit/module/cart_module');
}
$ext_data = array();
if (!empty($module['ext_data']) and is_array($module['ext_data'])) {
$ext_data = $module['ext_data'];
}
if (isset($ext_data['show_cart_images'])) {
$data['show_cart_images'] = $ext_data['show_cart_images'];
} else {
$data['show_cart_images'] = $this->input->post('show_cart_images');
}
if (isset($ext_data['fixed_cart'])) {
$data['fixed_cart'] = $ext_data['fixed_cart'];
} else {
if ($this->input->post('fixed_cart')) {
$data['fixed_cart'] = $this->input->post('fixed_cart');
} else {
$data['fixed_cart'] = '1';
}
}
if (isset($ext_data['fixed_top_offset'])) {
$data['fixed_top_offset'] = $ext_data['fixed_top_offset'];
} else {
if ($this->input->post('fixed_top_offset')) {
$data['fixed_top_offset'] = $this->input->post('fixed_top_offset');
} else {
$data['fixed_top_offset'] = '250';
}
}
if (isset($ext_data['fixed_bottom_offset'])) {
$data['fixed_bottom_offset'] = $ext_data['fixed_bottom_offset'];
} else {
if ($this->input->post('fixed_bottom_offset')) {
$data['fixed_bottom_offset'] = $this->input->post('fixed_bottom_offset');
} else {
$data['fixed_bottom_offset'] = '120';
}
}
if (isset($ext_data['cart_images_h'])) {
$data['cart_images_h'] = $ext_data['cart_images_h'];
} else {
$data['cart_images_h'] = $this->input->post('cart_images_h');
}
if (isset($ext_data['cart_images_w'])) {
$data['cart_images_w'] = $ext_data['cart_images_w'];
} else {
$data['cart_images_w'] = $this->input->post('cart_images_w');
}
if ($this->input->post('cart_totals')) {
$cart_totals = $ext_data['cart_totals'];
} else {
$cart_totals = $this->Cart_model->getTotals(array('filter_status' => '0'));
}
$data['cart_totals'] = array();
foreach ($cart_totals as $key => $result) {
$data['cart_totals'][] = array('priority' => isset($result['priority']) ? $result['priority'] : $key, 'name' => $result['name'], 'title' => $result['title'], 'admin_title' => $result['admin_title'], 'status' => $result['status']);
}
return $this->load->view('cart_module/admin_cart_module', $data, TRUE);
}
}