/** * @param none * @throws none * @returns void */ public function before() { $result = array(); // users need to be logged in to access this controller if (!\Sentry::check()) { $result = array('message' => 'You need to be logged in to access that page.', 'url' => '/admin/login'); // Don't show this message if url is just 'admin' if (\Uri::string() == 'admin/admin/index') { unset($result['message']); } \Session::set('redirect_to', \Uri::admin('current')); } else { if (!\Sentry::user()->is_admin()) { $result = array('message' => 'Access denied. You need to be a member of staff to access that page.', 'url' => '/admin/login'); \Session::set('redirect_to', \Uri::admin('current')); } } if (!empty($result)) { if (\Input::is_ajax()) { \Messages::error('You need to be logged in to complete this action.'); echo \Messages::display('left', false); exit; } else { if (isset($result['message'])) { \Messages::warning($result['message']); } \Response::redirect($result['url']); } } parent::before(); }
public function action_create() { \View::set_global('title', 'Add New User'); if (\Input::post()) { // Validate input parameters $val = \Validation::forge('admin_details_validation'); $val->add('first_name', 'First Name')->add_rule('required')->add_rule('min_length', 2)->add_rule('max_length', 255); $val->add('last_name', 'Last Name')->add_rule('required')->add_rule('min_length', 2)->add_rule('max_length', 255); $val->add('email', 'Email')->add_rule('required')->add_rule('valid_email'); $val->add('password', 'Password')->add_rule('min_length', 8); $val->add('confirm_password', 'Confirm Password')->add_rule('required_with', 'password')->add_rule('match_field', 'password'); $val->add('username', 'Username')->add_rule('required')->add_rule('unique', array('users', 'username', $id)); if ($val->run()) { // Get Input parameters $post_data = \Input::post(); try { $fields = array('username' => $post_data['username'], 'email' => $post_data['email'], 'password' => $post_data['password'], 'metadata' => array('first_name' => $post_data['first_name'], 'last_name' => $post_data['last_name'])); $user_group = $post_data['user_group']; if (empty($post_data['password'])) { unset($fields['password']); } $item = new \Sentry_User((int) $id); $create = $item->create($fields); $user = \Sentry::user($create); // $item->remove_from_group((int)$fields['user_group']); // $item->add_to_group((int)$fields['user_group']); if ($create and $user->add_to_group($user_group)) { // $user_groups = $item->groups(); // if(!empty($user_groups)) // { // // Remove user from all other groups... // foreach($user_groups as $value) // { // $item->remove_from_group((int)$value['id']); // } // } // $item = new \Sentry_User((int)$id); // // ...and add it to selected one // $item->add_to_group((int)$user_group); \Messages::success('User Details Successfully Created.'); \Response::redirect(\Uri::admin('current')); } else { \Messages::error('There was an error while trying to update User details.'); } } catch (Sentry\SentryException $e) { \Messages::error($e->get_message()); } } else { if ($val->error() != array()) { // Show validation errors \Messages::error('<strong>There was an error while trying to update User details</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } \Theme::instance()->set_partial('content', $this->view_dir . 'create'); }
public function action_list($category_id = false, $update_category = false) { $stock_options = \Config::load('stock-option.db'); \View::set_global('title', 'Stock Control'); \View::set_global('update_category', $update_category); // Update if (\Input::post() && isset($_POST['update_stock'])) { $post = \Input::post(); $return_to = is_numeric(\Input::post('return_to')) ? '#' . \Input::post('return_to') : ''; try { foreach ($post['stock_quantity'] as $key => $value) { $attr = Model_Attribute::find_one_by_id($key); $attr->set(array('stock_quantity' => $value)); $attr->save(); } \Messages::success('Stock quantity successfully updated.'); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update stock quantity.</strong>'); // Uncomment lines below to show database errors // $errors = $e->getMessage(); // \Messages::error($errors); \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to); } \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to); } $search = $this->get_search_items($category_id); $items = $search['items']; $group = $search['group']; $pagination = $search['pagination']; $status = $search['status']; \Theme::instance()->set_partial('content', $this->view_dir . 'list')->set('items', $items)->set('group', $group)->set('pagination', $pagination, false)->set('status', $status)->set('options', $stock_options); }
echo \Breadcrumb::create_links(); ?> </div> </div> <div class="row-fluid"> <?php echo \Theme::instance()->view('views/_partials/navigation'); ?> <!-- Main Content Holder --> <div class="content"> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'get')); ?> <!-- Accordions Panel --> <div class="panel"> <div class="panelHeader"> <h4>Orders Reports</h4> </div> <?php // Load reports listing table echo \Theme::instance()->view('views/reports/_orders_listing_table', array('items' => $items), false); ?> </div><!-- EOF Accordions Panel --> <?php echo \Form::close();
/** * Edit product infotabs * * @param $product_id = Product ID * @param $infotab_id = Infotab ID * @param $hotspot_id = Hotspot ID * */ public function action_infotab_edit($produt_id = false, $infotab_id = false, $hotspot_id = false) { // Check for product if (!is_numeric($produt_id)) { \Response::redirect('admin/product/list'); } // Get news item to edit if (!($product = Model_Product::find_one_by_id($produt_id))) { \Response::redirect('admin/product/list'); } // Check for infotab if (!is_numeric($infotab_id)) { \Response::redirect('admin/product/list'); } // Get news item to edit if (!($item = Model_Product_To_Infotabs::find_by_pk($infotab_id))) { \Response::redirect('admin/product/list'); } // Get hotspot is exist if (is_numeric($hotspot_id)) { if (!($hotspot = Model_Infotab_Image::find_by_pk($hotspot_id))) { unset($hotspot); } } if (\Input::post()) { $val = Model_Product_To_Infotabs::validate('update', $item->type); // Upload image and display errors if there are any $image = $this->upload_infotab_image(); if (!$image['exists'] && \Config::get('infotab.image.required', false) && empty($item->images)) { // No previous images and image is not selected and it is required \Messages::error('<strong>There was an error while trying to upload infotab image</strong>'); \Messages::error('You have to select image'); } elseif ($image['errors']) { \Messages::error('<strong>There was an error while trying to upload infotab image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } if ($val->run() && $image['is_valid'] && !(!$image['exists'] && \Config::get('infotab.image.required', false) && empty($item->images))) { /** IMAGES **/ // Get all alt texts to update if there is no image change foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) { if (strpos($image_id, 'new_') === false) { $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, ''))); } } // Save images if new files are submitted if (isset($this->_infotab_image_data)) { foreach ($this->_infotab_image_data as $image_data) { $cover_count = count($item->images); if (strpos($image_data['field'], 'new_') === false) { // Update existing image if (str_replace('image_', '', $image_data['field']) != 0) { $image_id = (int) str_replace('image_', '', $image_data['field']); $cover_count--; $item_images[$image_id] = array('id' => $image_id, 'data' => array('infotab_id' => $item->unique_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, ''))); $this->delete_infotab_image(\Input::post('image_db_' . $image_id, '')); } } else { // Save new image $image_tmp = str_replace('image_new_', '', $image_data['field']); $item_images[0] = array('id' => 0, 'data' => array('infotab_id' => $item->unique_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } } } Model_Infotab::bind_images($item_images); /** END OF IMAGES **/ // Get POST values $insert = \Input::post(); // Prep some values $insert['description'] = trim($insert['description']); $insert['active'] = !empty($insert['description']) ? 1 : 0; $item->set($insert); try { $item->save(); \Messages::success('Infotab successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/product/infotab_list/' . $product->id) : \Uri::admin('current')); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update infotab</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } else { // Delete uploaded images if there is product saving error if (isset($this->_infotab_image_data)) { foreach ($this->_infotab_image_data as $image_data) { $this->delete_infotab_image($image_data['saved_as']); } } if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update infotab</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $item = Model_Product_To_Infotabs::find_by_pk($infotab_id); $theme_partial = \Theme::instance()->set_partial('content', $this->view_dir . 'infotabs_edit_' . strtolower($item->type))->set('product', $product)->set('infotab', $item); if (isset($hotspot)) { $theme_partial->set('hotspot', $hotspot); } }
public function action_update($id = false) { if (!is_numeric($id)) { \Response::redirect('admin/attribute/list'); } // Get news item to edit if (!($item = Model_Attribute::find_one_by_id($id))) { \Response::redirect('admin/attribute/list'); } \View::set_global('title', 'Edit Attribute'); if (\Input::post()) { if (\Input::post('option_title', false)) { \Request::forge('admin/attribute/option/create')->set_method('POST')->execute()->response(); } $val = Model_Attribute::validate('update'); if ($val->run()) { // Get POST values $insert = \Input::post(); $item->set($insert); try { $item->save(); \Messages::success('Attribute successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/attribute/list/') : \Uri::admin('current')); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update attribute</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } else { if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update attribute</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $attribute = Model_Attribute::find_one_by_id($id); \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('attribute', $attribute); }
/** * Update product price * * @access public * @return Response */ public function action_update($id = false) { $flag = true; if (!is_numeric($id)) { \Response::redirect('admin/product/list'); } // Get product item to edit if (!($item = Model_Product::find_one_by_id($id))) { \Response::redirect('admin/product/list'); } // Redirect to attribute group if (\Input::get('attribute_group', false) === false && !empty($item->attributes)) { foreach ($item->attributes as $attr_obj) { if ($attr_obj->attribute_group_id > 0) { \Response::redirect(\Uri::create(\Uri::admin(), array(), array('attribute_group' => $attr_obj->attribute_group_id))); } } } // NRB-Gem: Comment out; Logic does not apply anymore // if(\Input::get('user_group', false) === false) // { // \Response::redirect(\Uri::create(\Uri::admin(), array(), array('user_group' => 3) + \Input::get())); // } \View::set_global('title', 'Edit Product Price'); \View::set_global('quick_menu_save', 'form.main_form'); // Update if (\Input::post()) { $post = \Input::post(); $return_to = is_numeric(\Input::post('return_to')) ? '#' . \Input::post('return_to') : ''; //$val = Model_Attribute::validate(); try { if (isset($post[$post['price_type']])) { foreach ($post[$post['price_type']] as $key => $price) { if ($update_price = Model_Attribute_Price::find_one_by_id($key)) { if (isset($post['active'][$key])) { $update_price->active = $post['active'][$key]; } if (isset($post['product_group_discount_id'][$key])) { $update_price->product_group_discount_id = $post['product_group_discount_id'][$key]; } $update_price->save(); } } } $multiple_images = array(); $image_new = false; foreach ($post['attributes'] as $key => $attribute) { if (!empty($post['delete_items'])) { $delete_items = explode(',', $post['delete_items']); $result1 = \DB::delete('product_attributes')->where('id', 'in', $delete_items)->execute(); $result2 = \DB::delete('product_attribute_price')->where('product_attribute_id', 'in', $delete_items)->execute(); } // Check existing product attribute group $existing_attribute_group = Model_Attribute::find(function ($query) use($post) { $query->where('product_id', $post['product_id']); $query->and_where_open(); $query->where('attribute_group_id', null, \DB::expr('IS NOT NULL')); // $query->and_where('attribute_group_id', '!=' , 0); $query->and_where('attribute_group_id', '!=', $post['attribute_group_id']); $query->and_where_close(); }); //if($existing_attribute_group && $post['attribute_group_id'] != 0) if ($existing_attribute_group) { foreach ($existing_attribute_group as $item) { $delete_attribute = $item->id; $item->delete(); $attribute_option = Model_Attribute_Price::find_one_by_product_attribute_id($delete_attribute); if ($attribute_option) { $attribute_option->delete(); } } } // Update if (isset($post['update_items'][$key])) { // Lightmedia - michael: check if product attribute code is exists on the product if ($this->check_attr_code_exists($id, $post['update_items'][$key], $post['product_code'][$key])) { $flag = false; \Messages::error($post['product_code'][$key] . ' code already used'); continue; } $update = Model_Attribute::find_one_by_id($post['update_items'][$key]); if ($update) { $item_images = array(); $data = array('product_id' => $post['product_id'], 'attribute_group_id' => $post['attribute_group_id'], 'attributes' => $attribute, 'product_code' => $post['product_code'][$key], 'retail_price' => $post['retail_price'][$key], 'sale_price' => $post['sale_price'][$key], 'stock_quantity' => $post['stock_quantity'][$key], 'active' => isset($post['active']) && $post['active'][$key] ? $post['active'][$key] : $post['active_new'][$key]); // Default radio $data['default'] = 0; if (isset($post['default']) && $post['default'] == $key) { $this->reset_default($item->id); $data['default'] = 1; } $update->set($data); $update->save(); $attr_id = $update->id; // Get combinations for multiple images if (isset($post['apply_image']) && isset($post['action'])) { if (in_array($attr_id, $post['action'])) { $multiple_images['action'][$attr_id] = $attr_id; } } if (isset($_FILES['image_new_' . $attr_id])) { // Upload image and display errors if there are any $image = $this->upload_image('image'); if ($image['errors'] && $image['exists']) { \Messages::error('<strong>There was an error while trying to upload product attribute image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } // if($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images))) if ($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false))) { /** IMAGES **/ // Get all alt texts to update if there is no image change foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) { if (strpos($image_id, 'new_') === false) { $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, ''))); if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } } // Save images if new files are submitted if (isset($this->_image_data) && $image['exists'] !== false) { foreach ($this->_image_data as $image_data) { $cover_count = count($update->images); if (strpos($image_data['field'], 'new_') === false) { // Update existing image if (str_replace('image_', '', $image_data['field']) != 0) { $image_id = (int) str_replace('image_', '', $image_data['field']); $cover_count--; $item_images[$image_id] = array('id' => $image_id, 'data' => array('content_id' => $attr_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, ''))); //$this->delete_image(\Input::post('image_db_' . $image_id, '')); } if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } else { // Save new image $image_tmp = str_replace('image_new_', '', $image_data['field']); $image_new = $item_images[0] = array('id' => 0, 'data' => array('content_id' => $attr_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } // Multiple images if (isset($post['apply_image']) && isset($post['action']) && false) { foreach ($post['action'] as $action_value) { if ($action_value == $attr_id) { continue; } $item_images = array(); if ($action_value > 0) { $image_new[0] = array('id' => 0, 'data' => array('content_id' => $action_value, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } } } } } /** END OF IMAGES **/ } } if (isset($post['active_new'][$key])) { //NRB-Gem: insert attributes to existing Products added to Pricing Groups $this->add_attribute_price($post, array('attr_id' => $attr_id, 'key' => $key)); } } } else { if ($this->check_attr_code_exists($post['product_id'], false, $post['product_code_new'][$key])) { $flag = false; \Messages::error($post['product_code_new'][$key] . ' code already used'); continue; } $item_images = array(); $insert = Model_Attribute::forge(array('product_id' => $post['product_id'], 'attribute_group_id' => $post['attribute_group_id'], 'attributes' => $attribute, 'product_code' => $post['product_code_new'][$key], 'retail_price' => $post['retail_price_new'][$key], 'active' => $post['active_new'][$key], 'sale_price' => $post['sale_price_new'][$key], 'stock_quantity' => $post['stock_quantity'][$key])); // Default radio $insert->default = 0; if (isset($post['default']) && $post['default'] == $key) { $this->reset_default($item->id); $insert->default = 1; } $insert->save(); $attr_id = $insert->id; // Get combinations for multiple images if (isset($post['apply_image']) && isset($post['action_new'][$key]) && $post['action_new'][$key] == 1) { $multiple_images['action_new'][$attr_id] = $attr_id; } if (isset($_FILES['_image_new_' . $key])) { // Upload image and display errors if there are any $image = $this->upload_image('image'); if ($image['errors'] && $image['exists']) { \Messages::error('<strong>There was an error while trying to upload product attribute image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } // if($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images))) if ($image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false))) { /** IMAGES **/ // Save images if new files are submitted if (isset($this->_image_data) && $image['exists'] !== false) { foreach ($this->_image_data as $image_data) { $cover_count = 0; // Save new image $image_tmp = str_replace('_image_new_', '', $image_data['field']); $image_new = $item_images[0] = array('id' => 0, 'data' => array('content_id' => $attr_id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('_alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } // Multiple images if (isset($post['apply_image']) && isset($post['action_new']) && false) { foreach ($post['action_new'] as $action_key => $action_value) { if ($action_value == $attr_id) { continue; } $item_images = array(); if ($action_value > 0) { $image_new[0] = array('id' => 0, 'data' => array('content_id' => $action_value, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } if (!empty($item_images)) { Model_Attribute::bind_images($item_images); } } } } } /** END OF IMAGES **/ } } if (isset($post[$post['price_type'] . '_new'][$key])) { //NRB-Gem: insert attributes to existing Products added to Pricing Groups $this->add_attribute_price($post, array('attr_id' => $attr_id, 'key' => $key)); } } } // Update/insert multiple images if (!empty($multiple_images) && !empty($image_new) && isset($image_new['data'])) { $content_id = $image_new['data']['content_id']; if (isset($multiple_images['action']) && !empty($multiple_images['action'])) { foreach ($multiple_images['action'] as $value) { $item_images = array(); if ($content_id == $value) { continue; } $image_new['data']['content_id'] = $value; $item_images[0] = $image_new; Model_Attribute::bind_images($item_images); } } if (isset($multiple_images['action_new']) && !empty($multiple_images['action_new'])) { foreach ($multiple_images['action_new'] as $value) { $item_images = array(); if ($content_id == $value) { continue; } $image_new['data']['content_id'] = $value; $item_images[0] = $image_new; Model_Attribute::bind_images($item_images); } } } if ($flag) { \Messages::success('Product successfully updated.'); } } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update product attributes</strong>'); // Uncomment lines below to show database errors // $errors = $e->getMessage(); // \Messages::error($errors); \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to); } \Response::redirect(\Uri::create(\Uri::admin('current'), array(), \Input::get()) . $return_to); } // Get current product $product = Model_Product::find_one_by_id($id); // Create array for attribute group select $attribute_groups_select = \Attribute\Model_Attribute_Group::fetch_pair('id', 'title', array(), array('0' => '- No Attributes -')); // Set user group for lazy load if (\Input::get('user_group')) { Model_Attribute::set_user_group(); } // Set tier price group for lazy load if (\Input::get('tier_price')) { Model_Attribute::set_tier_price(); } $param = \Input::get(); // Find attributes for current product $items_db = Model_Attribute::find(function ($query) use($id, $param) { $query->select('product_attributes.*'); $query->join('attribute_groups', 'LEFT')->on('attribute_groups.id', '=', 'product_attributes.attribute_group_id'); $query->where('product_id', $id); if (isset($param['attribute_group']) && is_numeric($param['attribute_group'])) { $query->and_where('product_attributes.attribute_group_id', $param['attribute_group']); } $query->order_by('attribute_groups.sort', 'asc'); }, 'id'); // Decode attribute json $combinations_db_arr = $this->decode_attribute_json($items_db); // Find current attribute group $attribute_group = array(); if (\Input::get('attribute_group')) { $attribute_group = \Attribute\Model_Attribute_Group::find_one_by_id(\Input::get('attribute_group')); } // Set vars $combinations = array(); $combinations_data = array(); $combinations_tmp = array(); $attributes_order = array(); $compared = array(); $update_items = array(); $delete_items = ''; // Create attribute combinations if ($attribute_group && $attribute_group->attributes) { $i = 0; foreach ($attribute_group->attributes as $attribute) { $attributes_order[] = $attribute->id; if ($attribute->options) { foreach ($attribute->options as $option) { $combinations[$i][] = $attribute->title . ': ' . $option->title; //$combinations[$i][] = array($attribute->title => $option->title); $combinations_tmp[$i][] = array($attribute->id => $option->id); } } $i++; } // Create combinations from current attributes $combinations = $this->combos($combinations); $combinations_tmp = $this->combos($combinations_tmp); // Sort product atributes from database if ($combinations_db_arr) { $sorted_db_arr = $this->sort_array(array_keys($attribute_group->attributes), $combinations_db_arr); if ($sorted_db_arr) { $compared = $this->compare_array($combinations_tmp, $sorted_db_arr, $combinations_db_arr); } } } // Something crazy if (!empty($compared) && !empty($items_db)) { if (!empty($compared['not_exist_in1'])) { $delete_items = array_keys($compared['not_exist_in1']); $delete_items = implode(',', $delete_items); } if (!empty($compared['exist_id'])) { $update_items = $compared['exist_id']; } } // Sort array asc $combinations_sorted = $this->sort_array_asc($combinations_tmp); foreach ($combinations_sorted as $key => $value) { $combinations_data[$key] = json_encode($value); } // Select user groups $user_groups = \Sentry::group()->all('front'); if (!empty($user_groups)) { $user_groups = \Model_Base::fetch_pair('id', 'name', array(), false, $user_groups); } else { $user_groups = array(); } $price_select = array(3 => 'Sale Price'); $price_select_fields = array(3 => 'sale_price'); // Set default user price type or use selected $price_field = 'sale_price'; if (isset($price_select_fields[\Input::get('special')])) { $price_field = $price_select_fields[\Input::get('special')]; } $listing = true; if (\Input::get('special') == 2 && !\Input::get('tier_price')) { $listing = false; } // Product pricing group if ($item->pricing_group) { $pricing_group = $item->pricing_group->id; } else { $pricing_group = false; } // NRB-Gem: removed logic // Find and select tier price // $tier_price = array(); // if(\Input::get('user_group') && is_numeric(\Input::get('user_group')) && $pricing_group) // { // $tier_price = \Product\Model_Group_Discounts::find(array( // 'where' => array( // 'user_group_id' => \Input::get('user_group'), // 'product_group_id' => $pricing_group, // ), // 'order_by' => array( // 'discount' => 'asc' // ) // )); // } // Reset to empty array if there are no result found by query if (is_null($combinations)) { $combinations = array(); } if (is_null($combinations_data)) { $combinations_data = array(); } $number_of_combinations = count($combinations); // Pagination per page default $per_page = \Input::get('per_page', 'all') == 'all' ? 9999 : \Input::get('per_page'); $show_all = $per_page > $number_of_combinations ? true : false; // Initiate pagination $pagination = \Hybrid\Pagination::make(array('total_items' => count($combinations), 'per_page' => $per_page, 'uri_segment' => null)); // Remove unwanted items, and show only required ones $combinations = array_slice($combinations, $pagination->offset, $pagination->per_page, true); $combinations_data = array_slice($combinations_data, $pagination->offset, $pagination->per_page, true); \Theme::instance()->set_partial('content', $this->view_dir . 'attributes')->set('product', $product)->set('price_select', $price_select, false)->set('combinations', $combinations, false)->set('combinations_data', $combinations_data, false)->set('attribute_groups_select', $attribute_groups_select, false)->set('delete_items', $delete_items, false)->set('update_items', $update_items, false)->set('items_db', $items_db, false)->set('price_field', $price_field)->set('listing', $listing)->set('pagination', $pagination, false)->set('number_of_combinations', $number_of_combinations)->set('show_all', $show_all); }
<?php isset($filters) or $filters = true; if ($filters) { echo \Theme::instance()->view('views/_partials/search_filters', array('pagination' => $pagination, 'module' => 'Order ID, company and full', 'options' => array('order_date', 'order_total', 'order_status', 'user_group', 'tracking_no', 'payment_method', 'payment_status', 'shipping_status', 'country', 'state', 'product_category')), false); } ?> <?php echo \Form::close(); ?> <div class="clear"></div> <?php // \Theme::instance()->view('views/_partials/action_header'); ?> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'get', 'class' => 'data_form')); ?> <table class="grid greyTable2 separated table_small_screen" width="100%"> <thead> <tr class="blueTableHead"> <?php /* <th scope="col" style="width: 40px;"></th> */ ?> <th scope="col" class="center" style="width: 40px;">Order ID</th> <th scope="col">Date</th> <th scope="col">Full Name</th> <th scope="col">Company Name</th> <th scope="col">Email</th> <!--<th scope="col" title="Artwork Required / Supplied">Artwork</th>-->
<div class="panelContent"> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'get')); ?> <?php echo \Theme::instance()->view('views/_partials/search_filters', array('pagination' => $pagination, 'status' => $status, 'module' => 'product code or', 'options' => array('category_id')), false); ?> <?php echo \Form::close(); ?> <?php echo \Form::open(array('action' => \Uri::create(\Uri::admin('current'), array(), \Input::get()), 'method' => 'post')); ?> <table rel="<?php echo \Uri::create('admin/product/sort/product'); ?> " class="grid greyTable2 separated" width="100%"> <thead> <tr class="blueTableHead"> <?php /*<th scope="col" style="width: 40px;"></th>*/ ?> <th scope="col">Product Name</th> <th scope="col" class="center" style="width: 12%;">Category</th> <th scope="col">Product Code</th> <th scope="col" class="center" style="width: 15%;">Attribute</th> <th scope="col" class="center" style="width: 70px;">Stock Qty</th> </tr>
<!-- Document File Delivery Docket --> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'enctype' => 'multipart/form-data'), array('upload_type' => 'delivery_docket')); ?> <div class="panel"> <div class="panelHeader"> <div class="togglePanel"><a> <?php echo \Theme::instance()->asset->img('panelToggle-minus.gif', array('width' => 10, 'height' => 10, 'alt' => '')); ?> </a><a> <?php echo \Theme::instance()->asset->img('panelToggle-plus.gif', array('width' => 10, 'height' => 10, 'alt' => '')); ?> </a></div> <h4><i class="panel_documents"></i>Delivery Docket</h4> </div> <div class="panelContent">
/** * Update * * @access public * @return Response */ public function action_update($id = false) { if (!is_numeric($id)) { \Response::redirect('admin/discountcode/list'); } // Get item to edit if (!($item = Model_Discountcode::find_one_by_id($id))) { \Response::redirect('admin/discountcode/list'); } \View::set_global('title', 'Discount Codes Update'); if (\Input::post()) { $val = Model_Discountcode::validate('update', $item->id); if (\Input::post('type') != 'free shipping') { $val->add('type_value', 'Amount')->add_rule('required')->add_rule('numeric')->add_rule('numeric_min', 1); } if ($val->run()) { $insert = \Input::post(); if (isset($insert['active_from']) && $insert['active_from']) { $insert['active_from'] = date('Y-m-d', strtotime(str_replace('/', '-', $insert['active_from']))); } if (isset($insert['active_to']) && $insert['active_to']) { $insert['active_to'] = date('Y-m-d', strtotime(str_replace('/', '-', $insert['active_to']))); } $item->set($insert); try { $item->save(); \Messages::success('Discount successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/discountcode/list/') : \Uri::admin('current')); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update discount code</strong>'); } } else { if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update discount code</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $discountcode = Model_Discountcode::find_one_by_id($id); \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('item', $discountcode); }
public function action_update($id = false) { if (!is_numeric($id)) { \Response::redirect('admin/user/list'); } // Get user to edit if (!\Sentry::user_exists((int) $id)) { \Response::redirect('admin/user/list'); } \View::set_global('title', 'Edit User'); // Get groups $groups = \Sentry::group()->all('front'); // Update group details if (\Input::post('details', false)) { $item = new \Sentry_User((int) $id); $val = \User\Controller_Admin_Validate::forge('update', $item['id']); if ($val->run()) { // Get POST values $insert = \Input::post(); array_walk($insert, create_function('&$val', '$val = trim($val);')); try { // Generate random username //$username = '******' . \Str::random('numeric', 16); $username = $insert['email']; $email = $insert['email']; $password = $insert['password']; $user_group = $insert['user_group']; $activated = $insert['activated']; $email_client = $insert['email_client']; $insert['guest'] = $user_group == 3 ? 1 : 0; unset($insert['email'], $insert['password'], $insert['confirm_password'], $insert['user_group'], $insert['details'], $insert['save'], $insert['exit'], $insert['activated'], $insert['email_client']); $only_billing = array('business_name', 'purchase_limit_value', 'purchase_limit_period', 'master', 'note', 'credit_account', 'guest'); // Set shipping data to be same as billing by default /*foreach($insert as $key => $value) { if(!in_array($key, $only_billing) && strpos($key, 'shipping_') === false) { if(empty($insert['shipping_'.$key])) $insert['shipping_'.$key] = $value; } }*/ // create the user - no activation required $vars = array('username' => $username, 'email' => $email, 'password' => $password, 'metadata' => $insert, 'activated' => $activated); // Send email to user with new password if ($email_client == 1 && !empty($vars['password'])) { $email_data = array('site_title' => \Config::get('site_title'), 'customer_identity' => ucwords($item->get('metadata.first_name') . ' ' . $item->get('metadata.last_name')), 'new_password' => $vars['password']); $this->autoresponder($item, $email_data); } if (empty($vars['password'])) { unset($vars['password']); } if ($item->update($vars)) { //Change user group if needed $user_groups = $item->groups(); if (!empty($user_groups)) { // Remove user from all other groups... foreach ($user_groups as $value) { $item->remove_from_group((int) $value['id']); } } $item = new \Sentry_User((int) $id); // ...and add it to selected one $item->add_to_group((int) $user_group); \Messages::success('User successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/user/list/') : \Uri::admin('current')); } else { // show validation errors \Messages::error('<strong>' . 'There was an error while trying to update user' . '</strong>'); } } catch (\Sentry\SentryException $e) { // show validation errors \Messages::error('<strong>' . 'There was an error while trying to update user' . '</strong>'); $errors = $e->getMessage(); \Messages::error($errors); } } else { if ($val->error() != array()) { // show validation errors \Messages::error('<strong>' . 'There was an error while trying to update user' . '</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $user = new \Sentry_User((int) $id); // Get single user group $user_group = $user->groups(); $user_group = current($user_group); $user->group = $user_group; \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('user', $user)->set('groups', $groups); }
<?php \Autoloader::add_namespaces(array('Erp' => __DIR__ . DS . 'classes' . DS), true); $menu = \Menu_Admin::instance('indigo'); $menu->add(array(array('name' => gettext('ERP'), 'icon' => 'glyphicon glyphicon-file', 'sort' => 15, 'children' => array(array('name' => gettext('Products'), 'url' => \Uri::admin(false) . 'erp/stock/product'), array('name' => gettext('Manufacturers'), 'url' => \Uri::admin(false) . 'erp/stock/manufacturer')))));
public function action_update($id = false) { if (!is_numeric($id)) { \Response::redirect('admin/user/group/list'); } // Get group to edit if (!($item = \Sentry::group((int) $id))) { \Response::redirect('admin/user/group/list'); } \View::set_global('title', 'Edit Group'); // Update group details if (\Input::post('details', false)) { $val = $this->validate('update'); if ($val->run()) { try { $update = $item->update(array('name' => \Input::post('title'))); if ($update) { // Update discounts foreach (\Input::post('action') as $product_group_id => $value) { /** * OPTIONS */ $options[$product_group_id]['user_group_id'] = $item->id; $options[$product_group_id]['product_group_id'] = $product_group_id; //$options[$product_group_id]['action'] = $value; $options[$product_group_id]['able_to_buy'] = \Input::post('able_to_buy.' . $product_group_id); $options[$product_group_id]['able_to_view'] = \Input::post('able_to_view.' . $product_group_id); $options[$product_group_id]['sale_discount'] = \Input::post('sale_discount.' . $product_group_id); $options[$product_group_id]['apply_tier_to_sale'] = \Input::post('apply_tier_to_sale.' . $product_group_id); // Insert or update option $option = \Product\Model_Group_Options::find_by(array('user_group_id' => $item->id, 'product_group_id' => $product_group_id), null, null, 1); if ($option) { $option = $option[0]; $option->set($options[$product_group_id]); } else { $option = \Product\Model_Group_Options::forge($options[$product_group_id]); } $option->save(); /** * DISCOUNTS */ // Delete old discounts $all_discounts_id = array(); $all_discounts = \Product\Model_Group_Discounts::find_by(array('user_group_id' => $item->id, 'product_group_id' => $product_group_id), null, null, null); //if($all_discounts) foreach($all_discounts as $discount) $discount->delete(); if ($all_discounts) { foreach ($all_discounts as $discount) { $all_discounts_id[$discount->id] = $discount; } } // Update $discounts = array(); foreach (\Input::post('qty.' . $product_group_id, array()) as $key => $value) { // Ignore discounts with same qty. Only one discount per QTY number is allowed // We will insert first QTY in list. All other will be ignired if (!isset($discounts[$product_group_id][$value])) { if (isset($all_discounts_id[$key])) { unset($all_discounts_id[$key]); } $discounts[$product_group_id][$value]['id'] = $key; $discounts[$product_group_id][$value]['user_group_id'] = $item->id; $discounts[$product_group_id][$value]['product_group_id'] = $product_group_id; $discounts[$product_group_id][$value]['qty'] = $value; $discounts[$product_group_id][$value]['discount'] = \Input::post('discount.' . $product_group_id . '.' . $key); } } // Delete if ($all_discounts_id) { foreach ($all_discounts_id as $discount) { $discount->delete(); } } if (!empty($discounts)) { foreach ($discounts[$product_group_id] as $key => $value) { $id = $discounts[$product_group_id][$key]['id']; $discount = \Product\Model_Group_Discounts::find_one_by_id($id); if ($discount) { $discount->set($discounts[$product_group_id][$key]); $discount->save(); } } } // Insert $new_discounts = array(); foreach (\Input::post('new_qty.' . $product_group_id, array()) as $key => $value) { // Ignore discounts with same qty. Only one discount per QTY number is allowed // We will insert first QTY in list. All other will be ignired if (!isset($discounts[$product_group_id][$value])) { $new_discounts[$product_group_id][$value]['user_group_id'] = $item->id; $new_discounts[$product_group_id][$value]['product_group_id'] = $product_group_id; $new_discounts[$product_group_id][$value]['qty'] = $value; $new_discounts[$product_group_id][$value]['discount'] = \Input::post('new_discount.' . $product_group_id . '.' . $key); } } if (!empty($new_discounts)) { foreach ($new_discounts[$product_group_id] as $key => $value) { // Insert discount $discount = \Product\Model_Group_Discounts::forge($new_discounts[$product_group_id][$key]); $discount->save(); } } } // group was updated \Messages::success('Group successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/user/group/list/') : \Uri::admin('current')); } else { // show validation errors \Messages::error('<strong>There was an error while trying to update group</strong>'); \Messages::error('Please try again.'); } } catch (\Sentry\SentryGroupException $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update group</strong>'); // Uncomment lines below to show database errors $errors = $e->getMessage(); \Messages::error($errors); } } else { if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update group</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $group = \Sentry::group((int) $id); // Find all product groups and set usergroup id if ($group->product_groups = \Product\Model_Group::find_by_type('pricing')) { foreach ($group->product_groups as $product_group) { $product_group->set_user_group_id($group->id); } } \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('group', $group); }
public function action_products_assigned($id = false) { if (!is_numeric($id)) { \Response::redirect('admin/product/group/list'); } // Get group to edit if (!($item = Model_Group::find_one_by_id($id))) { \Response::redirect('admin/product/group/list'); } \View::set_global('title', 'Edit Group Products'); // Update group products if (\Input::post()) { $add = \Input::post('products.add', array()); $remove = \Input::post('products.remove', array()); $update = \Input::post('products.update', array()); if (\Input::post('add', false)) { foreach ($add as $value) { $related = Model_Product_To_Groups::forge(array('group_id' => $item->id, 'product_id' => $value)); $related->save(); // NRB-Gem: Get current Customer Group for this Pricing Group $product_group_option = \Product\Model_Group_Options::find_one_by(array('active' => 1, 'product_group_id' => $id)); $user_group_id = null; if ($product_group_option) { $user_group_id = $product_group_option->user_group_id; } // NRB-Gem: add attributes $a_attributes = \Product\Model_Attribute::find(function ($query) use($value) { $query->where('product_id', '=', $value); $query->where('active', '=', 1); }); $a_attribute_ids = array(); if (count($a_attributes)) { foreach ($a_attributes as $o_attr) { $o_attr_price = new Model_Attribute_Price(array('product_attribute_id' => $o_attr->id, 'pricing_group_id' => $item->id, 'user_group_id' => $user_group_id, 'type' => 'sale_price')); $o_attr_price->save(); } } } \Messages::success('Products successfully added to group.'); } else { if (\Input::post('remove', false)) { foreach ($remove as $value) { $related = Model_Product_To_Groups::find_one_by(array(array('group_id', '=', $item->id), array('product_id', '=', $value))); if (!is_null($related)) { $related->delete(); // NRB-Gem: remove attributes $a_attributes = \Product\Model_Attribute::find(function ($query) use($value) { $query->where('product_id', '=', $value); }); $a_attribute_ids = array(); if (count($a_attributes)) { foreach ($a_attributes as $o_attr) { $a_attribute_ids[] = $o_attr->id; } } if (count($a_attribute_ids)) { \DB::delete('product_attribute_price')->where('product_attribute_id', 'IN', \DB::expr('(' . implode(',', $a_attribute_ids) . ')'))->where('pricing_group_id', '=', $item->id)->execute(); } } } \Messages::success('Products successfully removed from group.'); } } if (!empty($update)) { foreach ($update['discount'] as $key => $value) { if (isset($update['attr_id'][$key])) { foreach ($update['attr_id'][$key] as $attribute_id) { $update_sale_price = Model_Attribute_Price::find_one_by(array(array('product_attribute_id', '=', $attribute_id), array('pricing_group_id', '=', $item->id))); if ($update_sale_price) { $update_sale_price->set(array('discount' => $update['discount'][$key][$attribute_id], 'able_discount' => $update['able_discount'][$key][$attribute_id], 'price' => $update['price'][$key][$attribute_id])); $update_sale_price->save(); } } } else { $prod_attributes = \Product\Model_Attribute::find_by_product_id($key); $attribute_id = $prod_attributes[0]->id; $o_attr_price_list = Model_Attribute_Price::find_one_by(array(array('product_attribute_id', '=', $attribute_id), array('pricing_group_id', '<>', $item->id))); if ($o_attr_price_list) { $o_attr_price_list->delete(); } $update_sale_price = Model_Attribute_Price::find_one_by(array(array('product_attribute_id', '=', $attribute_id), array('pricing_group_id', '=', $item->id))); if ($update_sale_price) { $update_sale_price->set(array('discount' => $update['discount'][$key], 'able_discount' => $update['able_discount'][$key], 'price' => $update['price'][$key])); $update_sale_price->save(); } } } \Messages::success('Products successfully updated.'); } // if(\Input::is_ajax()) // { // echo \Messages::display('left', false); // exit; // } // else // { \Response::redirect(\Input::referrer(\Uri::admin('current'))); // } } $group = Model_Group::find_one_by_id($id); /************ Get non related infotabs ***********/ $items = Model_Product::find(function ($query) use($item) { $product_ids = array(); // NRB-Gem: Comment out, to enable multiple pricing groups for a product // Products can be in only ONE discounted group // But can exist in MULTIPLE standard groups // if($item->type == 'pricing') // { // $discounted_products = Model_Product::in_group_type('pricing'); // foreach($discounted_products as $product) // array_push($product_ids, $product->id); // } foreach ($item->products as $product) { array_push($product_ids, $product->id); } if (!empty($product_ids)) { $product_ids = '(' . implode(',', $product_ids) . ')'; $query->where('id', 'NOT IN', \DB::expr($product_ids)); } // Filters foreach (\Input::get() as $key => $value) { if (!empty($value) || $value == '0') { switch ($key) { case 'title': $query->where($key, 'like', "%{$value}%"); break; case 'status': if (is_numeric($value)) { $query->where($key, $value); } break; case 'category_id': if (is_numeric($value)) { $products = Model_Product_To_Categories::find(function ($query) use($value) { return $query->where('category_id', $value); }, 'product_id'); if (empty($products)) { $products = array(0); } $query->where('id', 'IN', array_keys($products)); } break; } } } // Order query $query->order_by('sort', 'asc'); $query->order_by('id', 'asc'); }); $group->not_related_products = null; $not_related_products = $items ? $items : array(); // product_group_options $customer_groups = Model_Group_Options::find_by(array('active' => 1, 'product_group_id' => $id)); $customer_group = array(); if ($customer_groups) { $customer_group = Model_Customer_Group::find_one_by_id($customer_groups[0]->user_group_id); } // Reset to empty array if there are no result found by query if (is_null($items)) { $items = array(); } // Initiate pagination $pagination = \Hybrid\Pagination::make(array('total_items' => count($items), 'per_page' => \Input::get('per_page', 10), 'uri_segment' => null)); // Remove unwanted items, and show only required ones $items = array_slice($items, $pagination->offset, $pagination->per_page); $status = array('false' => 'Select', '1' => 'Active', '0' => 'Inactive', '2' => 'Active in period'); \Theme::instance()->set_partial('content', $this->view_dir . 'products_assigned')->set('group', $group, false)->set('items', $items, false)->set('pagination', $pagination, false)->set('status', $status, false)->set('customer_group', $customer_group, false); }
echo \Uri::create('admin'); ?> '; // Current admin URL w/o query string var uri_current = '<?php echo \Uri::admin('current'); ?> '; // Curent theme asset path var theme_path = '<?php echo \Uri::create(\Theme::instance()->asset_path('')); ?> '; // Current admin URL with query string var uri_current_with_query = '<?php echo \Uri::admin('current') . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''); ?> '; </script> <?php // Insert assets needed for every page echo \Theme::instance()->asset->js('jquery-1.8.2.min.js'); echo \Theme::instance()->asset->css('bootstrap.css'); echo \Theme::instance()->asset->css('bootstrap-responsive.css'); echo \Theme::instance()->asset->css('main.css'); // Dashboard ellements echo \Theme::instance()->asset->css('index.css'); echo \Theme::instance()->asset->css('elements.css'); echo \Theme::instance()->asset->css('jquery.ui.all.css'); echo \Theme::instance()->asset->js('jquery-ui-1.9.1.custom.min.js');
protected function file_upload() { // File upload configuration $this->file_upload_config = array('path' => \Config::get('details.file.location.root'), 'normalize' => true, 'ext_whitelist' => array('pdf', 'xls', 'xlsx', 'doc', 'docx', 'txt')); // process the uploaded files in $_FILES \Upload::process($this->file_upload_config); // if there are any valid files if (\Upload::is_valid()) { // save them according to the config \Upload::save(); \Messages::success('File successfully uploaded.'); $this->uploaded_files = \Upload::get_files(); return true; } else { // FILE ERRORS if (\Upload::get_errors() !== array()) { foreach (\Upload::get_errors() as $file) { foreach ($file['errors'] as $key => $value) { \Messages::error($value['message']); } } \Response::redirect(\Uri::admin('current')); } } return false; }
public function action_update($id = false) { if (!is_numeric($id)) { throw new \HttpNotFoundException(); } // Get accordion item to edit if (!($item = Model_Accordion::find_one_by_id($id))) { throw new \HttpNotFoundException(); } // Accordion from home page? if ($item->parent_id == 1) { \Config::load('page::accordion_banner', 'details', true, true); } \View::set_global('title', 'Edit Accordion'); if (\Input::post()) { $val = Model_Accordion::validate('update'); // Upload image and display errors if there are any $image = $this->upload_image(); if (!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images)) { // No previous images and image is not selected and it is required \Messages::error('<strong>There was an error while trying to upload accordion image</strong>'); \Messages::error('You have to select image'); } elseif ($image['errors']) { \Messages::error('<strong>There was an error while trying to upload accordion image</strong>'); foreach ($image['errors'] as $error) { \Messages::error($error); } } if ($val->run() && $image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images))) { /** IMAGES **/ // Get all alt texts to update if there is no image change foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) { if (strpos($image_id, 'new_') === false) { $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, ''))); } } // Save images if new files are submitted if (isset($this->_image_data)) { foreach ($this->_image_data as $image_data) { $cover_count = count($item->images); if (strpos($image_data['field'], 'new_') === false) { // Update existing image if (str_replace('image_', '', $image_data['field']) != 0) { $image_id = (int) str_replace('image_', '', $image_data['field']); $cover_count--; $item_images[$image_id] = array('id' => $image_id, 'data' => array('content_id' => $item->id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, ''))); $this->delete_image(\Input::post('image_db_' . $image_id, '')); } } else { // Save new image $image_tmp = str_replace('image_new_', '', $image_data['field']); $item_images[0] = array('id' => 0, 'data' => array('content_id' => $item->id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1)); } } } Model_Accordion::bind_images($item_images); /** END OF IMAGES **/ // Get POST values $insert = \Input::post(); // Prepare some values $insert['active_from'] = !empty($insert['active_from']) ? strtotime($insert['active_from']) : NULL; $insert['active_to'] = !empty($insert['active_to']) ? strtotime($insert['active_to']) : NULL; if ($insert['status'] != 2) { unset($insert['active_from']); unset($insert['active_to']); } $item->set($insert); try { $item->save(); \Messages::success('Accordion successfully updated.'); \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/page/accordion/list/' . $item->parent_id) : \Uri::admin('current')); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update accordion</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } else { // Delete uploaded images if there is page saving error if (isset($this->_image_data)) { foreach ($this->_image_data as $image_data) { $this->delete_image($image_data['saved_as']); } } if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update accordion</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } $accordion = Model_Accordion::find_one_by_id($id); $page = Model_Page::find_one_by_id($accordion->parent_id); \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('page', $page)->set('accordion', $accordion); }
/** * Update application SEO options * * @param $id = Application ID */ public function action_update_seo($id = false) { if (!is_numeric($id)) { \Response::redirect('admin/application/list'); } // Get news item to edit if (!($item = Model_Application::find_one_by_id($id))) { \Response::redirect('admin/application/list'); } \View::set_global('title', 'Edit Meta Content'); if (\Input::post()) { $val = Model_Seo::validate('update', $item->id); // Get POST values $insert = \Input::post(); if ($val->run($insert)) { // Update SEO database table $item_seo = Model_Seo::find_one_by_content_id($item->id); $item_seo->set($insert); try { $item_seo->save(); \Messages::success('Meta content successfully updated.'); \Response::redirect(\Uri::admin('current')); } catch (\Database_Exception $e) { // show validation errors \Messages::error('<strong>There was an error while trying to update meta content</strong>'); // Uncomment lines below to show database errors //$errors = $e->getMessage(); //\Messages::error($errors); } } else { if ($val->error() != array()) { // show validation errors \Messages::error('<strong>There was an error while trying to update meta content</strong>'); foreach ($val->error() as $e) { \Messages::error($e->get_message()); } } } } \Theme::instance()->set_partial('content', $this->view_dir . 'update_seo')->set('application', Model_Application::find_one_by_id($id)); }
?> <?php echo \Form::input('active_from', \Input::get('active_from'), array('class' => 'from_white dateInput', 'placeholder' => 'From')); ?> <div class="left spacing_double"> <?php echo \Form::input('active_to', \Input::get('active_to'), array('class' => 'to_white dateInput', 'placeholder' => 'To')); ?> </div> </div> </div> </td> <td width="70"> <a class="btn btn-small filters-reset" href="<?php echo \Uri::create(\Uri::admin('string')); ?> "><i class="icon-refresh"></i>Reset</a> </td> <td> <?php echo \Form::submit('search', ' ', array('class' => 'gray_search')); ?> </td> </tr> </table> </div> <?php echo \Form::close(); ?>
/** * Returns all segments in an array * * @return array */ public static function segments() { if ($request = \Request::active()) { $uri = \Uri::admin('string'); $uri = trim($uri ?: \Input::uri(), '/'); if (empty($uri)) { $segments = array(); } else { $segments = explode('/', $uri); } return $segments; } return null; }
<?php echo \Theme::instance()->view('views/discountcode/_action_links', array('create_form' => 1)); ?> </div> </div> <div class="row-fluid"> <?php echo \Theme::instance()->view('views/_partials/navigation'); ?> <!-- Main Content Holder --> <div class="content"> <?php echo \Form::open(array('action' => \Uri::admin('current'))); ?> <div class="panel"> <div class="panelHeader"> <h4>General Information</h4> </div> <div class="panelContent"> <div class="span6"> <div class="formRow"> <?php echo \Form::label('Discount Code' . ' <span class="req">*</span>'); ?> <div class="input_holder"><?php echo \Form::input('code', \Input::post('code', $item->code), array('placeholder' => 'ABC123')); ?> </div>
} echo \Breadcrumb::create_links(); ?> <?php //echo \Theme::instance()->view('views/product/stock/_action_links', array('stock' => 1)); ?> </div> </div> <div class="row-fluid"> <?php echo \Theme::instance()->view('views/_partials/navigation'); ?> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'post', 'class' => 'stock-option')); ?> <!-- Main Content Holder --> <div class="content"> <div class="panel"> <div class="panelHeader"> <h4><i class="panel_customer_details"></i> Stock Management Options</h4> </div> <div class="panelContent"> <div class="formRow"> <?php echo \Form::label('Manage Stock:'); ?>
<!-- Main Content Holder --> <div class="content"> <!-- Accordions Panel --> <div class="panel"> <div class="panelHeader"> <h4><i class="panel_information"></i>Order Products <?php if (!isset($duplicate_order)) { echo $order->number; } ?> </h4> </div> <?php echo \Form::open(\Uri::admin('current'), array('order_edit' => 1, 'order_id' => $order->id)); ?> <?php // Load page listing table echo \Theme::instance()->view('views/order/_listing_table_products', array('order' => $order, 'items' => $order->products, 'type' => 'duplicate_original', 'panel_title' => 'Original Order'), false); // Load page listing table echo \Theme::instance()->view('views/order/_listing_table_products', array('order' => $duplicate_order, 'items' => $duplicate_order->products, 'type' => 'duplicate_copy', 'panel_title' => 'Duplicated Order'), false); ?> <div class="save_button_holder m_b_10"> <?php echo \Form::button('save', '<i class="icon-ok icon-white"></i>Save', array('type' => 'submit', 'class' => 'btn btn-success right', 'value' => '1')); ?> <?php echo \Form::button('exit', 'Save & Exit', array('type' => 'submit', 'class' => 'btn right', 'value' => '1')); ?> </div>
\Breadcrumb::set('Backup', 'admin/backup'); echo \Breadcrumb::create_links(); ?> <?php echo \Theme::instance()->view('views/settings/option/_action_links'); ?> </div> </div> <div class="row-fluid"> <?php echo \Theme::instance()->view('views/_partials/navigation'); ?> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'method' => 'post', 'class' => 'row-fluid')); ?> <!-- Main Content Holder --> <div class="content"> <div class="panel"> <div class="panelHeader"> <h4><i class="panel_information"></i> Backup</h4> </div> <div class="panelContent"> <div class="formRow"> <label>Enable Database Backup: </label> <div class="input_holder"> <div class="custom_checkbox"> <?php echo \Form::checkbox('enable', 1, \Input::post('enable', $settings['enable'])); ?>
echo \Breadcrumb::create_links(); ?> <?php echo \Theme::instance()->view('views/product/_action_links', array('set_save_seo' => 1)); ?> </div> </div> <div class="row-fluid"> <?php echo \Theme::instance()->view('views/_partials/navigation'); ?> <?php echo \Form::open(array('action' => \Uri::admin('current'), 'enctype' => 'multipart/form-data', 'class' => 'row-fluid')); ?> <!-- Main Content Holder --> <div class="content"> <!-- Product Optimisation Panel --> <div class="panel"> <div class="panelHeader"> <div class="togglePanel"><a> <?php echo \Theme::instance()->asset->img('panelToggle-minus.gif', array('width' => 10, 'height' => 10, 'alt' => '')); ?> </a><a> <?php echo \Theme::instance()->asset->img('panelToggle-plus.gif', array('width' => 10, 'height' => 10, 'alt' => ''));
</button> </div> <div class="right"> <input type="text" class="medium_txt_input" placeholder="Price" id="all_price_attr" style="margin:0 10px;" /> </div> </div> </div> <?php echo \Form::close(); ?> <?php echo \Form::open(array('action' => \Uri::create(\Uri::admin('current'), array(), \Input::get()), 'enctype' => 'multipart/form-data', 'class' => 'main_form')); ?> <?php if (!empty($delete_items)) { echo \Form::hidden('delete_items', $delete_items); } ?> <div class="panelContent"> <?php // echo \Theme::instance()->view('views/_partials/action_header'); ?> <?php