示例#1
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::load()->model(['Categories', 'Products', 'Pages']);
     \CI::lang()->load('sitemap');
 }
示例#2
0
 public function __construct()
 {
     parent::__construct();
     \CI::load()->model(array('Customers', 'Locations'));
     \CI::load()->helper('formatting_helper');
     \CI::lang()->load('customers');
 }
示例#3
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::load()->model('Locations');
     \CI::lang()->load('locations');
 }
示例#4
0
 function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::lang()->load('categories');
     \CI::load()->model('Categories');
 }
示例#5
0
 public function index($slug, $sort = 'id', $dir = "ASC", $page = 0)
 {
     \CI::lang()->load('categories');
     //define the URL for pagination
     $pagination_base_url = site_url('category/' . $slug . '/' . $sort . '/' . $dir);
     //how many products do we want to display per page?
     //this is configurable from the admin settings page.
     $per_page = config_item('products_per_page');
     //grab the categories
     $categories = \CI::Categories()->get($slug, $sort, $dir, $page, $per_page);
     //no category? show 404
     if (!$categories) {
         throw_404();
         return;
     }
     $categories['sort'] = $sort;
     $categories['dir'] = $dir;
     $categories['slug'] = $slug;
     $categories['page'] = $page;
     //load up the pagination library
     \CI::load()->library('pagination');
     $config['base_url'] = $pagination_base_url;
     $config['uri_segment'] = 5;
     $config['per_page'] = $per_page;
     $config['num_links'] = 3;
     $config['total_rows'] = $categories['total_products'];
     \CI::pagination()->initialize($config);
     //load the view
     $this->view('categories/category', $categories);
 }
示例#6
0
 public function __construct()
 {
     parent::__construct();
     \CI::load()->model('GiftCards');
     \CI::load()->helper('form');
     \CI::load()->library('form_validation');
     \CI::lang()->load('gift_cards');
 }
示例#7
0
 function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::load()->model(['Orders', 'Search']);
     \CI::load()->helper(array('formatting'));
     \CI::lang()->load('reports');
 }
示例#8
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::load()->model('Coupons');
     \CI::load()->model('products');
     \CI::lang()->load('coupons');
 }
示例#9
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::load()->model(['Messages', 'Pages', 'Locations']);
     \CI::lang()->load('settings');
     \CI::load()->helper('inflector');
 }
示例#10
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     //load the admin language file in
     \CI::lang()->load('users');
     $this->current_admin = \CI::session()->userdata('admin');
 }
示例#11
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::load()->model(['Products', 'Categories']);
     \CI::load()->helper('form');
     \CI::lang()->load('products');
 }
示例#12
0
 public function __construct()
 {
     parent::__construct();
     \CI::load()->model('Orders');
     \CI::load()->model('Search');
     \CI::load()->model('Locations');
     \CI::load()->helper(array('formatting'));
     \CI::lang()->load('orders');
 }
示例#13
0
 public function index()
 {
     \CI::auth()->check_access('Admin', true);
     \CI::lang()->load('settings');
     \CI::load()->helper('inflector');
     global $shippingModules;
     $data['shipping_modules'] = $shippingModules;
     $data['enabled_modules'] = \CI::Settings()->get_settings('shipping_modules');
     $data['page_title'] = lang('common_shipping_modules');
     $this->view('shipping_index', $data);
 }
示例#14
0
 public function __construct()
 {
     parent::__construct();
     if (\CI::auth()->check_access('Orders')) {
         redirect(config_item('admin_folder') . '/orders');
     }
     \CI::load()->model('Orders');
     \CI::load()->model('Customers');
     \CI::load()->helper('date');
     \CI::lang()->load('dashboard');
 }
示例#15
0
 public function index()
 {
     \CI::auth()->check_access('Admin', true);
     \CI::lang()->load('settings');
     \CI::load()->helper('inflector');
     global $paymentModules;
     //Payment Information
     $payment_order = \CI::Settings()->get_settings('payment_order');
     $data['payment_modules'] = $paymentModules;
     $data['enabled_modules'] = \CI::Settings()->get_settings('payment_modules');
     $data['page_title'] = lang('common_payment_modules');
     $this->view('payment_index', $data);
 }
示例#16
0
 public function __construct()
 {
     parent::__construct();
     //add the theme to the packages path
     \CI::load()->add_package_path(FCPATH . 'themes/' . config_item('theme') . '/');
     \CI::load()->model(array('Pages', 'Customers', 'Login', 'Categories', 'Coupons', 'Locations', 'Products', 'ProductOptions', 'DigitalProducts'));
     //load in some base information
     \CI::load()->helper('theme');
     \CI::lang()->load('common');
     $this->pages = \CI::Pages()->get_pages_tiered();
     //see if the customer is logged in.
     //if the customer is not logged in, then we'll have a temporary guest customer created.
     $this->isLoggedIn = \CI::Login()->isLoggedIn();
 }
示例#17
0
文件: Page.php 项目: lekhang/gonline
 public function homepage()
 {
     //echo FCPATH.'themes/'.config_item('theme').'/views/homepage.php';exit;
     //do we have a homepage view?
     \CI::load()->model(['Products', 'Categories']);
     \CI::load()->helper('form');
     \CI::lang()->load('products');
     if (file_exists(FCPATH . 'themes/' . config_item('theme') . '/views/homepage.php')) {
         $data['power'] = @$_POST['power'];
         $data['hz'] = @$_POST['hz'];
         $engines = array();
         $alternators = array();
         $generators = array();
         $data['engines'] = $engines;
         $data['alternators'] = $alternators;
         if ($data['power'] > 0) {
             $data['hz'] = @$_POST['hz'];
             $categories['sort'] = $data['sort'] = '';
             $categories['dir'] = $data['dir'] = '';
             $categories['slug'] = $data['slug'] = '';
             $categories['page'] = $data['page'] = '';
             $categories['$per_page'] = $data['per_page'] = '';
             $categories = \CI::Categories()->get($data['slug'], $data['sort'], $data['dir'], $data['page'], $data['per_page']);
             $engines = \CI::Products()->getProductsCondition($data['power'], $data['hz']);
             $alternators = \CI::Products()->getProductsAlternators($data['power'], $data['hz']);
             //echo \CI::db()->last_query().'<pre>';print_r($alternators);exit;
             $data['engines'] = $engines;
             $data['alternators'] = $alternators;
             $generators = $this->results($data['hz'], $data['engines'], $data['alternators'], $data['power']);
         }
         $generators = $this->array_orderby(@$generators, 'kVA', SORT_ASC, 'price', SORT_ASC);
         $data['generators'] = @$generators;
         //echo '<pre>';print_r($generators);exit;
         $this->view('homepage', $data);
         return;
     } else {
         //if we don't have a homepage view, check for a registered homepage
         if (config_item('homepage')) {
             if (isset($this->pages['all'][config_item('homepage')])) {
                 //we have a registered homepage and it's active
                 $this->index($this->pages['all'][config_item('homepage')]->slug, false);
                 return;
             }
         }
     }
     // wow, we do not have a registered homepage and we do not have a homepage.php
     // let's give them something default to look at.
     $this->view('homepage_fallback');
 }
示例#18
0
 public function form($id = false, $duplicate = false)
 {
     $this->product_id = $id;
     \CI::load()->library('form_validation');
     \CI::load()->model(array('ProductOptions', 'Categories', 'DigitalProducts', 'Customers'));
     \CI::lang()->load('digital_products');
     \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
     $data['groups'] = \CI::Customers()->get_groups();
     $data['categories'] = \CI::Categories()->get_categories_tiered();
     $data['file_list'] = \CI::DigitalProducts()->getList();
     $data['page_title'] = lang('product_form');
     //default values are empty if the product is new
     $data['id'] = '';
     $data['sku'] = '';
     $data['primary_category'] = '';
     $data['name'] = '';
     $data['slug'] = '';
     $data['description'] = '';
     $data['excerpt'] = '';
     $data['weight'] = '';
     $data['track_stock'] = '';
     $data['seo_title'] = '';
     $data['meta'] = '';
     $data['shippable'] = '';
     $data['taxable'] = '';
     $data['fixed_quantity'] = '';
     $data['quantity'] = '';
     $data['enabled'] = '';
     $data['related_products'] = [];
     $data['product_categories'] = [];
     $data['images'] = [];
     $data['product_files'] = [];
     $data['productOptions'] = [];
     foreach ($data['groups'] as $group) {
         $data['enabled_' . $group->id] = '';
         $data['price_' . $group->id] = '';
         $data['saleprice_' . $group->id] = '';
     }
     // get_manufacturers
     $data['manufacturers'] = \CI::Products()->get_manufacturers(true);
     //create the photos array for later use
     $data['photos'] = [];
     if ($id) {
         // get the existing file associations and create a format we can read from the form to set the checkboxes
         $pr_files = \CI::DigitalProducts()->getAssociationsByProduct($id);
         foreach ($pr_files as $f) {
             $data['product_files'][] = $f->file_id;
         }
         // get product & options data
         $data['productOptions'] = \CI::ProductOptions()->getProductOptions($id);
         $product = \CI::Products()->find($id, true);
         //if the product does not exist, redirect them to the product list with an error
         if (!$product) {
             \CI::session()->set_flashdata('error', lang('error_not_found'));
             redirect('admin/products');
         }
         //helps us with the slug generation
         $this->product_name = \CI::input()->post('slug', $product->slug);
         //set values to db values
         $data['id'] = $id;
         $data['sku'] = $product->sku;
         $data['primary_category'] = $product->primary_category;
         $data['name'] = $product->name;
         $data['seo_title'] = $product->seo_title;
         $data['meta'] = $product->meta;
         $data['slug'] = $product->slug;
         $data['description'] = $product->description;
         $data['excerpt'] = $product->excerpt;
         $data['weight'] = $product->weight;
         $data['dimensions'] = $product->dimensions;
         $data['days'] = $product->days;
         $data['ogirin'] = $product->ogirin;
         $data['track_stock'] = $product->track_stock;
         $data['shippable'] = $product->shippable;
         $data['quantity'] = $product->quantity;
         $data['taxable'] = $product->taxable;
         $data['fixed_quantity'] = $product->fixed_quantity;
         $data['manufacturer'] = $product->manufacturers;
         $data['protection_class'] = $product->protection_class;
         $data['document_link'] = $product->document_link;
         foreach ($data['groups'] as $group) {
             $data['enabled_' . $group->id] = $product->{'enabled_' . $group->id};
             $data['price_' . $group->id] = $product->{'price_' . $group->id};
             $data['saleprice_' . $group->id] = $product->{'saleprice_' . $group->id};
         }
         //make sure we haven't submitted the form yet before we pull in the images/related products from the database
         if (!\CI::input()->post('submit')) {
             $data['product_categories'] = [];
             foreach ($product->categories as $product_category) {
                 $data['product_categories'][] = $product_category->id;
             }
             $data['related_products'] = $product->related_products;
             $data['images'] = (array) json_decode($product->images);
         }
         // get document file
         $data['documents'] = \CI::Products()->get_documents($id);
         if ($data['primary_category'] == 1) {
             // engine
             $engine = \CI::Products()->find_engine($id);
             $data['prime'] = isset($engine->prime) ? $engine->prime : '';
             $data['standby'] = isset($engine->standby) ? $engine->standby : '';
             $data['prime_2'] = isset($engine->prime_2) ? $engine->prime_2 : '';
             $data['standby_2'] = isset($engine->standby_2) ? $engine->standby_2 : '';
             //$data['funnel_phi'] = isset($engine->funnel_phi) ? $engine->funnel_phi : '';
             $data['type_cooled'] = isset($engine->type_cooled) ? $engine->type_cooled : '';
             $data['type_fuel'] = isset($engine->type_fuel) ? $engine->type_fuel : '';
             $data['dBA'] = isset($engine->dBA) ? $engine->dBA : '';
             $data['rpm'] = isset($engine->rpm) ? $engine->rpm : 1500;
             $data['rpm_2'] = isset($engine->rpm_2) ? $engine->rpm_2 : 1800;
             $fuel_consumption = \CI::Products()->find_fuel_consumption($id, 50);
             $data['standby_fuel_con_1'] = isset($fuel_consumption->standby_fuel_con_1) ? $fuel_consumption->standby_fuel_con_1 : '';
             $data['standby_fuel_con_2'] = isset($fuel_consumption->standby_fuel_con_2) ? $fuel_consumption->standby_fuel_con_2 : '';
             $data['standby_fuel_con_3'] = isset($fuel_consumption->standby_fuel_con_3) ? $fuel_consumption->standby_fuel_con_3 : '';
             $data['prime_fuel_con_1'] = isset($fuel_consumption->prime_fuel_con_1) ? $fuel_consumption->prime_fuel_con_1 : '';
             $data['prime_fuel_con_2'] = isset($fuel_consumption->prime_fuel_con_2) ? $fuel_consumption->prime_fuel_con_2 : '';
             $data['prime_fuel_con_3'] = isset($fuel_consumption->prime_fuel_con_3) ? $fuel_consumption->prime_fuel_con_3 : '';
             $fuel_consumption = \CI::Products()->find_fuel_consumption($id, 60);
             $data['standby_fuel_con_2_1'] = isset($fuel_consumption->standby_fuel_con_2_1) ? $fuel_consumption->standby_fuel_con_2_1 : '';
             $data['standby_fuel_con_2_2'] = isset($fuel_consumption->standby_fuel_con_2_2) ? $fuel_consumption->standby_fuel_con_2_2 : '';
             $data['standby_fuel_con_2_3'] = isset($fuel_consumption->standby_fuel_con_2_3) ? $fuel_consumption->standby_fuel_con_2_3 : '';
             $data['prime_fuel_con_2_1'] = isset($fuel_consumption->prime_fuel_con_2_1) ? $fuel_consumption->prime_fuel_con_2_1 : '';
             $data['prime_fuel_con_2_2'] = isset($fuel_consumption->prime_fuel_con_2_2) ? $fuel_consumption->prime_fuel_con_2_2 : '';
             $data['prime_fuel_con_2_3'] = isset($fuel_consumption->prime_fuel_con_2_3) ? $fuel_consumption->prime_fuel_con_2_3 : '';
         }
         if ($data['primary_category'] == 2) {
             // canopy
             $alternator = \CI::Products()->find_alternator($id, 50);
             $data['hz'] = isset($alternator->hz) ? $alternator->hz : 50;
             $data['power'] = isset($alternator->power) ? $alternator->power : '';
             $data['efficiency'] = isset($alternator->efficiency) ? $alternator->efficiency : '';
             $data['efficiency_2'] = isset($alternator->efficiency_2) ? $alternator->efficiency_2 : '';
             $data['efficiency_3'] = isset($alternator->efficiency_3) ? $alternator->efficiency_3 : '';
             $data['efficiency_4'] = isset($alternator->efficiency_4) ? $alternator->efficiency_4 : '';
             $data['power_single_phase'] = isset($alternator->power_single_phase) ? $alternator->power_single_phase : '';
             $alternator_2 = \CI::Products()->find_alternator($id, 60);
             //print_r($alternator_2);exit;
             $data['hz_2'] = isset($alternator_2->hz) ? $alternator_2->hz : 60;
             $data['power_2'] = isset($alternator_2->power) ? $alternator_2->power : '';
             $data['efficiency_2_1'] = isset($alternator_2->efficiency) ? $alternator_2->efficiency : '';
             $data['efficiency_2_2'] = isset($alternator_2->efficiency_2) ? $alternator_2->efficiency_2 : '';
             $data['efficiency_2_3'] = isset($alternator_2->efficiency_3) ? $alternator_2->efficiency_3 : '';
             $data['efficiency_2_4'] = isset($alternator_2->efficiency_4) ? $alternator_2->efficiency_4 : '';
             $data['phase'] = isset($alternator->phase) ? $alternator->phase : '';
             $data['power_single_phase_2'] = isset($alternator->power_single_phase) ? $alternator->power_single_phase : '';
         }
         if ($data['primary_category'] == 4) {
             // alternators
             $canopy = \CI::Products()->find_canopy($id);
             //print_r($canopy);exit;
             $data['canopy_kVA_min'] = isset($canopy->kVA_min) ? $canopy->kVA_min : '';
             $data['canopy_kVA_max'] = isset($canopy->kVA_max) ? $canopy->kVA_max : '';
             $data['canopy_standard'] = isset($canopy->standard) ? $canopy->standard : 0;
         }
     }
     //if $data['related_products'] is not an array, make it one.
     if (!is_array($data['related_products'])) {
         $data['related_products'] = [];
     }
     if (!is_array($data['product_categories'])) {
         $data['product_categories'] = [];
     }
     //no error checking on these
     \CI::form_validation()->set_rules('caption', 'Caption');
     \CI::form_validation()->set_rules('primary_photo', 'Primary');
     \CI::form_validation()->set_rules('sku', 'lang:sku', 'trim');
     \CI::form_validation()->set_rules('seo_title', 'lang:seo_title', 'trim');
     \CI::form_validation()->set_rules('meta', 'lang:meta_data', 'trim');
     \CI::form_validation()->set_rules('name', 'lang:name', 'trim|required|max_length[64]');
     \CI::form_validation()->set_rules('slug', 'lang:slug', 'trim');
     \CI::form_validation()->set_rules('description', 'lang:description', 'trim');
     \CI::form_validation()->set_rules('excerpt', 'lang:excerpt', 'trim');
     \CI::form_validation()->set_rules('weight', 'lang:weight', 'trim|numeric|floatval');
     \CI::form_validation()->set_rules('track_stock', 'lang:track_stock', 'trim|numeric');
     \CI::form_validation()->set_rules('quantity', 'lang:quantity', 'trim|numeric');
     \CI::form_validation()->set_rules('shippable', 'lang:shippable', 'trim|numeric');
     \CI::form_validation()->set_rules('taxable', 'lang:taxable', 'trim|numeric');
     \CI::form_validation()->set_rules('fixed_quantity', 'lang:fixed_quantity', 'trim|numeric');
     foreach ($data['groups'] as $group) {
         \CI::form_validation()->set_rules('enabled_' . $group->id, lang('enabled') . '(' . $group->name . ')', 'trim|numeric');
         \CI::form_validation()->set_rules('price_' . $group->id, lang('price') . '(' . $group->name . ')', 'trim|numeric|floatval');
         \CI::form_validation()->set_rules('saleprice_' . $group->id, lang('saleprice') . '(' . $group->name . ')', 'trim|numeric|floatval');
     }
     /*
     if we've posted already, get the photo stuff and organize it
     if validation comes back negative, we feed this info back into the system
     if it comes back good, then we send it with the save item
     
     submit button has a value, so we can see when it's posted
     */
     if ($duplicate) {
         $data['id'] = false;
     }
     if (\CI::input()->post('submit')) {
         //reset the product options that were submitted in the post
         $data['ProductOptions'] = \CI::input()->post('option');
         $data['related_products'] = \CI::input()->post('related_products');
         $data['product_categories'] = \CI::input()->post('categories');
         $data['images'] = \CI::input()->post('images');
         $data['product_files'] = \CI::input()->post('downloads');
     }
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('product_form', $data);
     } else {
         \CI::load()->helper('text');
         //first check the slug field
         $slug = \CI::input()->post('slug');
         //if it's empty assign the name field
         if (empty($slug) || $slug == '') {
             $slug = \CI::input()->post('name');
         }
         $slug = url_title(convert_accented_characters($slug), '-', TRUE);
         //validate the slug
         $slug = $id ? \CI::Products()->validate_slug($slug, $product->id) : \CI::Products()->validate_slug($slug);
         $save['id'] = $id;
         $save['sku'] = \CI::input()->post('sku');
         $save['name'] = \CI::input()->post('name');
         $save['seo_title'] = \CI::input()->post('seo_title');
         $save['meta'] = \CI::input()->post('meta');
         $save['description'] = \CI::input()->post('description');
         $save['excerpt'] = \CI::input()->post('excerpt');
         $save['weight'] = \CI::input()->post('weight');
         $save['days'] = \CI::input()->post('days');
         $save['track_stock'] = \CI::input()->post('track_stock');
         $save['fixed_quantity'] = \CI::input()->post('fixed_quantity');
         $save['quantity'] = \CI::input()->post('quantity');
         $save['shippable'] = \CI::input()->post('shippable');
         $save['taxable'] = \CI::input()->post('taxable');
         $save['dimensions'] = \CI::input()->post('dimensions');
         $save['ogirin'] = \CI::input()->post('ogirin');
         $save['manufacturers'] = \CI::input()->post('manufacturers');
         $save['protection_class'] = \CI::input()->post('protection_class');
         $save['document_link'] = \CI::input()->post('document_link');
         $post_images = \CI::input()->post('images');
         foreach ($data['groups'] as $group) {
             $save['enabled_' . $group->id] = \CI::input()->post('enabled_' . $group->id);
             $save['price_' . $group->id] = \CI::input()->post('price_' . $group->id);
             $save['saleprice_' . $group->id] = \CI::input()->post('saleprice_' . $group->id);
         }
         $save['slug'] = $slug;
         if ($primary = \CI::input()->post('primary_image')) {
             if ($post_images) {
                 foreach ($post_images as $key => &$pi) {
                     if ($primary == $key) {
                         $pi['primary'] = true;
                         continue;
                     }
                 }
             }
         }
         $save['images'] = json_encode($post_images);
         if (\CI::input()->post('related_products')) {
             $save['related_products'] = json_encode(\CI::input()->post('related_products'));
         } else {
             $save['related_products'] = '';
         }
         //save categories
         $categories = \CI::input()->post('categories');
         if (!$categories) {
             $categories = [];
         }
         //(\CI::input()->post('primary_category')) ? \CI::input()->post('primary_category') : 0;
         if (!\CI::input()->post('primary_category') && $categories) {
             $save['primary_category'] = $categories[0];
         } elseif (!\CI::input()->post('primary_category') && !$categories) {
             $save['primary_category'] = 0;
         } else {
             $save['primary_category'] = \CI::input()->post('primary_category');
         }
         // format options
         $options = [];
         if (\CI::input()->post('option')) {
             foreach (\CI::input()->post('option') as $option) {
                 $options[] = $option;
             }
         }
         // save product
         $product_id = \CI::Products()->save($save, $options, $categories);
         // save file
         //should check upload file
         $config['allowed_types'] = '*';
         $config['upload_path'] = 'uploads/documents';
         //config_item('digital_products_path');
         $config['remove_spaces'] = true;
         \CI::load()->library('upload', $config);
         if (\CI::upload()->do_upload()) {
             $upload_data = \CI::upload()->data();
             $document['product_id'] = $product_id;
             $document['file_name'] = $upload_data['file_name'];
             $document['display_name'] = \CI::input()->post('display_name');
             $document['size'] = $upload_data['file_size'];
             \CI::Products()->save_document($document);
         }
         /*else {
               $data['error'] 	= \CI::upload()->display_errors();
           }*/
         // save engine
         if ($data['primary_category'] == 1) {
             // engine
             $save_engine['product_id'] = $id;
             $save_engine['rpm'] = \CI::input()->post('rpm');
             $save_engine['prime'] = \CI::input()->post('prime');
             $save_engine['standby'] = \CI::input()->post('standby');
             $save_engine['rpm_2'] = \CI::input()->post('rpm_2');
             $save_engine['prime_2'] = \CI::input()->post('prime_2');
             $save_engine['standby_2'] = \CI::input()->post('standby_2');
             //$save_engine['funnel_phi']          = \CI::input()->post('funnel_phi');
             $save_engine['type_cooled'] = \CI::input()->post('type_cooled');
             $save_engine['type_fuel'] = \CI::input()->post('type_fuel');
             $save_engine['dBA'] = \CI::input()->post('dBA');
             $engine_id = \CI::Products()->save_engine($id, $engine->id, $save_engine);
             $save_fuel_consumption['standby_fuel_con_1'] = \CI::input()->post('standby_fuel_con_1');
             $save_fuel_consumption['standby_fuel_con_2'] = \CI::input()->post('standby_fuel_con_2');
             $save_fuel_consumption['standby_fuel_con_3'] = \CI::input()->post('standby_fuel_con_3');
             $save_fuel_consumption['prime_fuel_con_1'] = \CI::input()->post('prime_fuel_con_1');
             $save_fuel_consumption['prime_fuel_con_2'] = \CI::input()->post('prime_fuel_con_2');
             $save_fuel_consumption['prime_fuel_con_3'] = \CI::input()->post('prime_fuel_con_3');
             $save_fuel_consumption['product_id'] = $id;
             $save_fuel_consumption['rpm'] = 1500;
             $save_fuel_consumption['hz'] = 50;
             $engine_id = \CI::Products()->fuel_consumption($id, $fuel_consumption->id, $save_fuel_consumption);
             //  echo lqr();
             $save_fuel_consumption_2['standby_fuel_con_1'] = \CI::input()->post('standby_fuel_con_2_1');
             $save_fuel_consumption_2['standby_fuel_con_2'] = \CI::input()->post('standby_fuel_con_2_2');
             $save_fuel_consumption_2['standby_fuel_con_3'] = \CI::input()->post('standby_fuel_con_2_3');
             $save_fuel_consumption_2['prime_fuel_con_1'] = \CI::input()->post('prime_fuel_con_2_1');
             $save_fuel_consumption_2['prime_fuel_con_2'] = \CI::input()->post('prime_fuel_con_2_2');
             $save_fuel_consumption_2['prime_fuel_con_3'] = \CI::input()->post('prime_fuel_con_2_3');
             $save_fuel_consumption_2['product_id'] = $id;
             $save_fuel_consumption_2['rpm'] = 1800;
             $save_fuel_consumption_2['hz'] = 60;
             $engine_id = \CI::Products()->fuel_consumption($id, $fuel_consumption->id, $save_fuel_consumption_2);
         }
         // save alternators
         if ($data['primary_category'] == 2) {
             // engine
             $save_alternator['product_id'] = $id;
             $save_alternator['hz'] = 50;
             $save_alternator['phase'] = \CI::input()->post('phase');
             $save_alternator['efficiency'] = \CI::input()->post('efficiency');
             $save_alternator['efficiency_2'] = \CI::input()->post('efficiency_2');
             $save_alternator['efficiency_3'] = \CI::input()->post('efficiency_3');
             $save_alternator['efficiency_4'] = \CI::input()->post('efficiency_4');
             $save_alternator['power'] = \CI::input()->post('power');
             $save_alternator['power_single_phase'] = \CI::input()->post('power_single_phase');
             $alternator_id = \CI::Products()->save_alternator($id, $alternator->id, $save_alternator);
             $save_alternator['hz'] = 60;
             $save_alternator['phase'] = \CI::input()->post('phase');
             $save_alternator['efficiency'] = \CI::input()->post('efficiency_2_1');
             $save_alternator['efficiency_2'] = \CI::input()->post('efficiency_2_2');
             $save_alternator['efficiency_3'] = \CI::input()->post('efficiency_2_3');
             $save_alternator['efficiency_4'] = \CI::input()->post('efficiency_2_4');
             $save_alternator['power'] = \CI::input()->post('power_2');
             $save_alternator['power_single_phase'] = \CI::input()->post('power_single_phase_2');
             $alternator_id = \CI::Products()->save_alternator($id, $alternator_2->id, $save_alternator);
         }
         if ($data['primary_category'] == 4) {
             // engine
             $save_canopy['product_id'] = $id;
             $save_canopy['kVA_min'] = \CI::input()->post('kVA_min');
             $save_canopy['kVA_max'] = \CI::input()->post('kVA_max');
             $save_canopy['standard'] = \CI::input()->post('standard');
             $canopy_id = \CI::Products()->save_canopy($canopy->id, $save_canopy);
         }
         // add file associations
         // clear existsing
         \CI::DigitalProducts()->disassociate(false, $product_id);
         // save new
         $downloads = \CI::input()->post('downloads');
         if (is_array($downloads)) {
             foreach ($downloads as $d) {
                 \CI::DigitalProducts()->associate($d, $product_id);
             }
         }
         \CI::session()->set_flashdata('message', lang('message_saved_product'));
         //go back to the product list
         redirect('admin/products');
     }
 }
示例#19
0
 public function __construct()
 {
     parent::__construct();
     \CI::auth()->check_access('Admin', true);
     \CI::lang()->load('cod');
 }
示例#20
0
 public function __construct()
 {
     parent::__construct();
     \CI::lang()->load('cod');
 }
示例#21
0
 public function form($id = false, $duplicate = false)
 {
     $this->product_id = $id;
     \CI::load()->library('form_validation');
     \CI::load()->model(array('ProductOptions', 'Categories', 'DigitalProducts', 'Customers'));
     \CI::lang()->load('digital_products');
     \CI::form_validation()->set_error_delimiters('<div class="error">', '</div>');
     $data['groups'] = \CI::Customers()->get_groups();
     $data['categories'] = \CI::Categories()->get_categories_tiered();
     $data['file_list'] = \CI::DigitalProducts()->getList();
     $data['page_title'] = lang('product_form');
     //default values are empty if the product is new
     $data['id'] = '';
     $data['sku'] = '';
     $data['primary_category'] = '';
     $data['name'] = '';
     $data['slug'] = '';
     $data['description'] = '';
     $data['excerpt'] = '';
     $data['weight'] = '';
     $data['track_stock'] = '';
     $data['seo_title'] = '';
     $data['meta'] = '';
     $data['shippable'] = '';
     $data['taxable'] = '';
     $data['fixed_quantity'] = '';
     $data['quantity'] = '';
     $data['enabled'] = '';
     $data['related_products'] = [];
     $data['product_categories'] = [];
     $data['images'] = [];
     $data['product_files'] = [];
     $data['productOptions'] = [];
     foreach ($data['groups'] as $group) {
         $data['enabled_' . $group->id] = '';
         $data['price_' . $group->id] = '';
         $data['saleprice_' . $group->id] = '';
     }
     //create the photos array for later use
     $data['photos'] = [];
     if ($id) {
         // get the existing file associations and create a format we can read from the form to set the checkboxes
         $pr_files = \CI::DigitalProducts()->getAssociationsByProduct($id);
         foreach ($pr_files as $f) {
             $data['product_files'][] = $f->file_id;
         }
         // get product & options data
         $data['productOptions'] = \CI::ProductOptions()->getProductOptions($id);
         $product = \CI::Products()->find($id, true);
         //if the product does not exist, redirect them to the product list with an error
         if (!$product) {
             \CI::session()->set_flashdata('error', lang('error_not_found'));
             redirect('admin/products');
         }
         //helps us with the slug generation
         $this->product_name = \CI::input()->post('slug', $product->slug);
         //set values to db values
         $data['id'] = $id;
         $data['sku'] = $product->sku;
         $data['primary_category'] = $product->primary_category;
         $data['name'] = $product->name;
         $data['seo_title'] = $product->seo_title;
         $data['meta'] = $product->meta;
         $data['slug'] = $product->slug;
         $data['description'] = $product->description;
         $data['excerpt'] = $product->excerpt;
         $data['weight'] = $product->weight;
         $data['track_stock'] = $product->track_stock;
         $data['shippable'] = $product->shippable;
         $data['quantity'] = $product->quantity;
         $data['taxable'] = $product->taxable;
         $data['fixed_quantity'] = $product->fixed_quantity;
         foreach ($data['groups'] as $group) {
             $data['enabled_' . $group->id] = $product->{'enabled_' . $group->id};
             $data['price_' . $group->id] = $product->{'price_' . $group->id};
             $data['saleprice_' . $group->id] = $product->{'saleprice_' . $group->id};
         }
         //make sure we haven't submitted the form yet before we pull in the images/related products from the database
         if (!\CI::input()->post('submit')) {
             $data['product_categories'] = [];
             foreach ($product->categories as $product_category) {
                 $data['product_categories'][] = $product_category->id;
             }
             $data['related_products'] = $product->related_products;
             $data['images'] = (array) json_decode($product->images);
         }
     }
     //if $data['related_products'] is not an array, make it one.
     if (!is_array($data['related_products'])) {
         $data['related_products'] = [];
     }
     if (!is_array($data['product_categories'])) {
         $data['product_categories'] = [];
     }
     //no error checking on these
     \CI::form_validation()->set_rules('caption', 'Caption');
     \CI::form_validation()->set_rules('primary_photo', 'Primary');
     \CI::form_validation()->set_rules('sku', 'lang:sku', 'trim');
     \CI::form_validation()->set_rules('seo_title', 'lang:seo_title', 'trim');
     \CI::form_validation()->set_rules('meta', 'lang:meta_data', 'trim');
     \CI::form_validation()->set_rules('name', 'lang:name', 'trim|required|max_length[64]');
     \CI::form_validation()->set_rules('slug', 'lang:slug', 'trim');
     \CI::form_validation()->set_rules('description', 'lang:description', 'trim');
     \CI::form_validation()->set_rules('excerpt', 'lang:excerpt', 'trim');
     \CI::form_validation()->set_rules('weight', 'lang:weight', 'trim|numeric|floatval');
     \CI::form_validation()->set_rules('track_stock', 'lang:track_stock', 'trim|numeric');
     \CI::form_validation()->set_rules('quantity', 'lang:quantity', 'trim|numeric');
     \CI::form_validation()->set_rules('shippable', 'lang:shippable', 'trim|numeric');
     \CI::form_validation()->set_rules('taxable', 'lang:taxable', 'trim|numeric');
     \CI::form_validation()->set_rules('fixed_quantity', 'lang:fixed_quantity', 'trim|numeric');
     foreach ($data['groups'] as $group) {
         \CI::form_validation()->set_rules('enabled_' . $group->id, lang('enabled') . '(' . $group->name . ')', 'trim|numeric');
         \CI::form_validation()->set_rules('price_' . $group->id, lang('price') . '(' . $group->name . ')', 'trim|numeric|floatval');
         \CI::form_validation()->set_rules('saleprice_' . $group->id, lang('saleprice') . '(' . $group->name . ')', 'trim|numeric|floatval');
     }
     /*
     if we've posted already, get the photo stuff and organize it
     if validation comes back negative, we feed this info back into the system
     if it comes back good, then we send it with the save item
     
     submit button has a value, so we can see when it's posted
     */
     if ($duplicate) {
         $data['id'] = false;
     }
     if (\CI::input()->post('submit')) {
         //reset the product options that were submitted in the post
         $data['ProductOptions'] = \CI::input()->post('option');
         $data['related_products'] = \CI::input()->post('related_products');
         $data['product_categories'] = \CI::input()->post('categories');
         $data['images'] = \CI::input()->post('images');
         $data['product_files'] = \CI::input()->post('downloads');
     }
     if (\CI::form_validation()->run() == FALSE) {
         $this->view('product_form', $data);
     } else {
         \CI::load()->helper('text');
         //first check the slug field
         $slug = \CI::input()->post('slug');
         //if it's empty assign the name field
         if (empty($slug) || $slug == '') {
             $slug = \CI::input()->post('name');
         }
         $slug = url_title(convert_accented_characters($slug), '-', TRUE);
         //validate the slug
         $slug = $id ? \CI::Products()->validate_slug($slug, $product->id) : \CI::Products()->validate_slug($slug);
         $save['id'] = $id;
         $save['sku'] = \CI::input()->post('sku');
         $save['name'] = \CI::input()->post('name');
         $save['seo_title'] = \CI::input()->post('seo_title');
         $save['meta'] = \CI::input()->post('meta');
         $save['description'] = \CI::input()->post('description');
         $save['excerpt'] = \CI::input()->post('excerpt');
         $save['weight'] = \CI::input()->post('weight');
         $save['track_stock'] = \CI::input()->post('track_stock');
         $save['fixed_quantity'] = \CI::input()->post('fixed_quantity');
         $save['quantity'] = \CI::input()->post('quantity');
         $save['shippable'] = \CI::input()->post('shippable');
         $save['taxable'] = \CI::input()->post('taxable');
         $post_images = \CI::input()->post('images');
         foreach ($data['groups'] as $group) {
             $save['enabled_' . $group->id] = \CI::input()->post('enabled_' . $group->id);
             $save['price_' . $group->id] = \CI::input()->post('price_' . $group->id);
             $save['saleprice_' . $group->id] = \CI::input()->post('saleprice_' . $group->id);
         }
         $save['slug'] = $slug;
         if ($primary = \CI::input()->post('primary_image')) {
             if ($post_images) {
                 foreach ($post_images as $key => &$pi) {
                     if ($primary == $key) {
                         $pi['primary'] = true;
                         continue;
                     }
                 }
             }
         }
         $save['images'] = json_encode($post_images);
         if (\CI::input()->post('related_products')) {
             $save['related_products'] = json_encode(\CI::input()->post('related_products'));
         } else {
             $save['related_products'] = '';
         }
         //save categories
         $categories = \CI::input()->post('categories');
         if (!$categories) {
             $categories = [];
         }
         //(\CI::input()->post('primary_category')) ? \CI::input()->post('primary_category') : 0;
         if (!\CI::input()->post('primary_category') && $categories) {
             $save['primary_category'] = $categories[0];
         } elseif (!\CI::input()->post('primary_category') && !$categories) {
             $save['primary_category'] = 0;
         } else {
             $save['primary_category'] = \CI::input()->post('primary_category');
         }
         // format options
         $options = [];
         if (\CI::input()->post('option')) {
             foreach (\CI::input()->post('option') as $option) {
                 $options[] = $option;
             }
         }
         // save product
         $product_id = \CI::Products()->save($save, $options, $categories);
         // add file associations
         // clear existsing
         \CI::DigitalProducts()->disassociate(false, $product_id);
         // save new
         $downloads = \CI::input()->post('downloads');
         if (is_array($downloads)) {
             foreach ($downloads as $d) {
                 \CI::DigitalProducts()->associate($d, $product_id);
             }
         }
         \CI::session()->set_flashdata('message', lang('message_saved_product'));
         //go back to the product list
         redirect('admin/products');
     }
 }
 public function __construct()
 {
     parent::__construct();
     \CI::lang()->load('digital_products');
     \CI::load()->model('DigitalProducts');
 }
示例#23
0
 function calculator_price_again($eng, $alt, $can, $con, $hz = 50, $phase = 3, $gen_number = 1)
 {
     \CI::lang()->load('products');
     $hz = $_POST['hz'];
     $kVA = $_POST['kVA'];
     $engine = \CI::Products()->getProduct($eng);
     $alternator = \CI::Products()->getProduct($alt);
     $canopy = \CI::Products()->getProduct($can);
     $controller = \CI::Products()->getProduct($con);
     $parameter_con = \CI::Products()->getParameters($con, 'controllers');
     //echo $con ;print_r($controller);exit;
     $engine->manufacturer = \CI::Products()->getManufacturers($engine->manufacturers);
     $alternator->manufacturer = \CI::Products()->getManufacturers($alternator->manufacturers);
     if (isset($canopy->manufacturers)) {
         $canopy->manufacturer = \CI::Products()->getManufacturers($canopy->manufacturers);
         $canopy_manufacturer_code = $canopy->manufacturer->code;
         $price_can = $canopy->price_1;
     } else {
         $canopy_manufacturer_code = 'N';
         $price_can = 0;
     }
     if (isset($controller->manufacturers)) {
         $controller->manufacturer = \CI::Products()->getManufacturers($controller->manufacturers);
         $controller_manufacturer_code = $controller->manufacturer->code;
         $price_con = $controller->price_1;
     } else {
         $controller_manufacturer_code = 'N';
         $price_con = 0;
     }
     $generators['price'] = $engine->price_1 + $alternator->price_1 + $price_can + $price_con;
     $data['currency'] = format_currency($generators['price']);
     $data['price'] = $generators['price'];
     $data['ats'] = $parameter_con->ats;
     //if($parameter_con->ats == 1)
     if (isset($_POST['ats'])) {
         $data['gen_control_panel'] = lang('gen_with_ats_control');
     } else {
         $data['gen_control_panel'] = lang('gen_with_manual_control');
     }
     $data['name'] = 'G' . (int) ($hz / 10) . '-' . $kVA . $engine->manufacturer->code . $alternator->manufacturer->code . $canopy_manufacturer_code . $controller_manufacturer_code;
     echo json_encode($data);
 }
示例#24
0
 public function homepage()
 {
     //echo FCPATH.'themes/'.config_item('theme').'/views/homepage.php';exit;
     //do we have a homepage view?
     \CI::load()->model(['Products', 'Categories']);
     \CI::load()->helper('form');
     \CI::lang()->load('products');
     /*
     \CI::load()->helper('calculator');
     \CI::load()->helper('html_to_pdf');
     get_exchangeRates();exit;
     convert2pdf('','');exit;
     */
     if (file_exists(FCPATH . 'themes/' . config_item('theme') . '/views/homepage.php')) {
         $data['power'] = @$_POST['power'];
         $data['hz'] = @$_POST['hz'];
         $data['phase'] = @$_POST['phase'];
         $engines = array();
         $alternators = array();
         $generators = array();
         $data['engines'] = $engines;
         $data['alternators'] = $alternators;
         $data['stand_by'] = isset($_POST['stand_by']) ? $_POST['stand_by'] : 1;
         if ($data['power'] > 0) {
             $data['hz'] = @$_POST['hz'];
             $data['phase'] = @$_POST['phase'];
             /*
             				$categories['sort'] = $data['sort'] = '';
             				$categories['dir'] 	= $data['dir']  = '';
             				$categories['slug'] = $data['slug'] = '';
             				$categories['page'] = $data['page'] = '';
             				$categories['per_page'] = $data['per_page'] = '';
             				$categories     = \CI::Categories()->get($data['slug'], $data['sort'], $data['dir'], $data['page'], $data['per_page'], $data['stand_by']);
             
             				$engines        = \CI::Products()->getProductsCondition($data['power'], $data['hz'], true, $data['stand_by']);
             //echo \CI::db()->last_query().'<pre>';print_r($engines);exit;
             $engines_min    = \CI::Products()->getProductsCondition($data['power'], $data['hz'], false, $data['stand_by']);
             $engines = array_merge($engines_min, $engines);
             //echo \CI::db()->last_query().'<pre>';print_r($engines);exit;
             				$alternators    = \CI::Products()->getProductsAlternators($data['power'], $data['hz'], $data['phase']);
             				//echo \CI::db()->last_query().'<pre>';print_r($alternators);exit;
             $canopies    = \CI::Products()->getProductsCanopies();
             //echo \CI::db()->last_query().'<pre>';print_r($canopies);exit;
             $controllers    = \CI::Products()->getProductsControllers();
             //echo \CI::db()->last_query().'<pre>';print_r($controllers);exit;
             
             				$data['engines']    = $engines;
             				$data['alternators']= $alternators;
             $data['canopies']   = $canopies;
             $data['controllers']= $controllers;
             
             				$generators         = $this->results($data['hz'], $engines, $alternators, $data['power'], $data['phase'], $canopies, $controllers, $data['stand_by']);
             */
             $generators = $this->generate_generators($data);
             if ($data['power'] > 1000) {
                 $general_generators = $this->general_generators($data);
             }
             //echo '<pre>';print_r($general_generators);exit;
             if (isset($general_generators)) {
                 $generators = array_merge($generators, $general_generators);
             }
             $generators = $this->array_orderby(@$generators, 'kVA', SORT_ASC, 'price', SORT_ASC);
         }
         $data['generators'] = @$generators;
         //echo '<pre>';
         //pr($generators);exit;
         $this->view('homepage', $data);
         return;
     } else {
         //if we don't have a homepage view, check for a registered homepage
         if (config_item('homepage')) {
             if (isset($this->pages['all'][config_item('homepage')])) {
                 //we have a registered homepage and it's active
                 $this->index($this->pages['all'][config_item('homepage')]->slug, false);
                 return;
             }
         }
     }
     // wow, we do not have a registered homepage and we do not have a homepage.php
     // let's give them something default to look at.
     $this->view('homepage_fallback');
 }
示例#25
0
 public function __construct()
 {
     parent::__construct();
     \CI::lang()->load('admin_common');
     \CI::auth()->isLoggedIn(uri_string());
 }
示例#26
0
 public function __construct()
 {
     parent::__construct();
     \CI::load()->model('Banners');
     \CI::lang()->load('banners');
 }