public function generate() { $type = CI::uri()->segment(1); $slug = CI::uri()->segment(2); if (!$type || !$slug) { return; //return blank } if ($type == 'category') { $category = CI::Categories()->slug($slug); if (!$category) { return; } $this->trace_categories($category->id); } elseif ($type == 'product') { $product = CI::Products()->slug($slug); if (!$product) { return; } array_unshift($this->breadcrumbs, ['link' => site_url('product/' . $product->slug), 'name' => $product->name]); $this->trace_categories($product->primary_category); } elseif ($type == 'page') { $page = CI::Pages()->slug($slug); if (!$page) { return; } $this->trace_pages($page->id); } echo GoCart\Libraries\View::getInstance()->get('breadcrumbs', ['breadcrumbs' => $this->breadcrumbs]); }
public function generator($eng, $alt) { $cos_phi = 0.8; $engine = \CI::Products()->getProduct($eng); $engine->manufacturer = \CI::Products()->getManufacturers($engine->manufacturers); $alternator = \CI::Products()->getProduct($alt); $alternator->manufacturer = \CI::Products()->getManufacturers($alternator->manufacturers); $engine_parameters = \CI::Products()->getParameters($engine->id, 'engines'); $engine_alternator = \CI::Products()->getParameters($alternator->id, 'alternators'); //echo '<pre>';print_r($alternator);exit; $data['page_title'] = $engine->name; $data['meta'] = $engine->meta; $data['seo_title'] = !empty($engine->seo_title) ? $engine->seo_title : $engine->name; $data['product'] = $engine; $data['engine_parameters'] = $engine_parameters; $data['alt'] = $alternator; $data['engine_alternator'] = $engine_alternator; $generators = array(); $generators['kVA'] = $generators['kVA_standby'] = $engine_parameters->standby / $cos_phi * ($engine_alternator->efficiency * 0.01); $generators['kVA_prime'] = $engine_parameters->prime / $cos_phi * ($engine_alternator->efficiency * 0.01); $generators['price'] = $engine->price_1 + $alternator->price_1; if ($engine_alternator->power < $generators['kVA']) { $generators['kVA'] = $engine_alternator->power; } if ($engine->days > $alternator->days) { $generators['days'] = $engine->days; } else { $generators['days'] = $alternator->days; } $generators['name'] = 'G50-' . round($generators['kVA']) . $engine->manufacturer->code . $alternator->manufacturer->code . 'BA'; //echo '<pre>';print_r($generators);exit; $data['generators'] = $generators; $this->view('generator', $data); }
public function index($slug) { $product = \CI::Products()->slug($slug); if (!$product) { throw_404(); } else { $product->images = json_decode($product->images, true); if ($product->images) { $product->images = array_values($product->images); } else { $product->images = []; } //set product options $data['options'] = \CI::ProductOptions()->getProductOptions($product->id); $data['posted_options'] = \CI::session()->flashdata('option_values'); //get related items $data['related'] = $product->related_products; //create view variable $data['page_title'] = $product->name; $data['meta'] = $product->meta; $data['seo_title'] = !empty($product->seo_title) ? $product->seo_title : $product->name; $data['product'] = $product; //load the view $this->view('product', $data); } }
public function generateProducts() { $limit = \CI::input()->post('limit'); $offset = \CI::input()->post('col-md-offset-'); $products = \CI::Products()->products(['rows' => $limit, 'page' => $offset]); $xml = $this->partial('product_xml', ['products' => $products], true); echo $xml; $file = fopen('sitemap.xml', 'a'); fwrite($file, $xml); fclose($file); }
public function index($code = false, $page = 0) { $pagination_base_url = site_url('search/' . $code); //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'); \CI::load()->model('Search'); //check to see if we have a search term if (!$code) { //if the term is in post, save it to the db and give me a reference $term = \CI::input()->post('term', true); if (empty($term)) { //if there is still no search term throw an error $data['error'] = lang('search_error'); $this->view('search_error', $data); return; } else { $code = \CI::Search()->recordTerm($term); // no code? redirect so we can have the code in place for the sorting. // I know this isn't the best way... redirect('search/' . $code . '/' . $page); } } else { //if we have the md5 string, get the term $term = \CI::Search()->getTerm($code); } //fix for the category view page. $data['base_url'] = []; $sortArray = array('name/asc' => array('by' => 'name', 'sort' => 'ASC'), 'name/desc' => array('by' => 'name', 'sort' => 'DESC'), 'price/asc' => array('by' => 'price', 'sort' => 'ASC'), 'price/desc' => array('by' => 'price', 'sort' => 'DESC')); $sortBy = array('by' => false, 'sort' => false); if (isset($_GET['by'])) { if (isset($sortArray[$_GET['by']])) { $sortBy = $sortArray[$_GET['by']]; } } if (empty($term)) { //if there is still no search term throw an error $this->view('search_error', $data); return; } else { $result = \CI::Products()->search_products($term, $per_page, $page, $sortBy['by'], $sortBy['sort']); $config['total_rows'] = $result['count']; \CI::load()->library('pagination'); $config['base_url'] = $pagination_base_url; $config['uri_segment'] = 3; $config['per_page'] = $per_page; $config['num_links'] = 3; $config['total_rows'] = $result['count']; \CI::pagination()->initialize($config); $data['products'] = $result['products']; $data['category'] = (object) ['name' => str_replace('{term}', $term, lang('search_title'))]; $this->view('categories/category', $data); } }
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'); }
public function get($slug, $sort, $direction, $page, $products_per_page) { //get the category by slug $category = $this->getBySlug($slug); //if the category does not exist return false if (!$category || !$category->{'enabled_' . $this->customer->group_id}) { return false; } //create view variable $data['page_title'] = $category->name; $data['meta'] = $category->meta; $data['seo_title'] = !empty($category->seo_title) ? $category->seo_title : $category->name; $data['category'] = $category; $data['total_products'] = CI::Products()->count_products($category->id); $data['products'] = CI::Products()->getProducts($category->id, $products_per_page, $page, $sort, $direction); return $data; }
public function repriceItems() { $this->getCart(true); // refresh the cart and items again. $options = CI::Orders()->getItemOptions(GC::getCart()->id); foreach ($this->items as $item) { if ($item->type == 'product') { //grab the product from the database $product = \CI::Products()->getProduct($item->product_id); if (empty($product)) { //product can no longer be found. remove it $this->removeItem($item->id); continue; } //Clean up the product for the orderItems database $product = $this->cleanProduct($product); $totalPrice = 0; if ($product->{'saleprice_' . $this->customer->group_id} > 0) { //if it's on sale, give it the sale price $totalPrice = $product->{'saleprice_' . $this->customer->group_id}; } else { //not on sale give it the normal price $totalPrice = $product->{'price_' . $this->customer->group_id}; } if (isset($options[$item->id])) { foreach ($options[$item->id] as $option) { $totalPrice += $option->price; } } $product->id = $item->id; $product->hash = $item->hash; $product->total_price = $totalPrice; //updated price \CI::Orders()->saveItem((array) $product); } } $this->getCart(true); // refresh the cart and items just one more time. }
public function tu_ats() { $ats = \CI::Products()->getAts($this->kVA / 1.72 / 0.83); //echo lqr();pr($ats);exit; $this->gia_ats = $ats->price_1; //echo $this->gia_ats;exit; }
public function delete($id = false) { if ($id) { $product = \CI::Products()->find($id); //if the product does not exist, redirect them to the customer list with an error if (!$product) { \CI::session()->set_flashdata('error', lang('error_not_found')); redirect('admin/products'); } else { //if the product is legit, delete them \CI::Products()->delete_product($id); \CI::session()->set_flashdata('message', lang('message_deleted_product')); redirect('admin/products'); } } else { //if they do not provide an id send them to the product list page with an error \CI::session()->set_flashdata('error', lang('error_not_found')); redirect('admin/products'); } }
function documents($eng, $alt, $can, $con, $hz = 50, $phase = 3, $gen_number = 1) { if ($eng == '' || $alt == '') { redirect(site_url()); } $power_factor = 0.8; $engine = \CI::Products()->getProduct($eng); $alternator = \CI::Products()->getProduct($alt); $controller = \CI::Products()->getProduct($con); if (empty($engine) || empty($alternator)) { redirect(site_url()); } $engine->manufacturer = \CI::Products()->getManufacturers($engine->manufacturers); $alternator->manufacturer = \CI::Products()->getManufacturers($alternator->manufacturers); $engine_parameters = \CI::Products()->getParameters($engine->id, 'engines'); $engine_alternator = \CI::Products()->getParameters($alternator->id, 'alternators', $hz); $parameter_con = \CI::Products()->getParameters($controller->id, 'controllers'); $data['page_title'] = $engine->name; $data['meta'] = $engine->meta; $data['seo_title'] = !empty($engine->seo_title) ? $engine->seo_title : $engine->name; $data['product'] = $engine; $data['engine_parameters'] = $engine_parameters; $data['alt'] = $alternator; $data['eng'] = $engine; $data['engine_alternator'] = $engine_alternator; $data['hz'] = $hz; $data['phase'] = $phase; $data['gen_number'] = $gen_number; $generators = array(); $generators['kVA'] = $generators['kVA_standby'] = $engine_parameters->standby / $power_factor * ($engine_alternator->efficiency * 0.01); $generators['kVA_prime'] = $engine_parameters->prime / $power_factor * ($engine_alternator->efficiency * 0.01); $generators['price'] = $engine->price_1 + $alternator->price_1; if ($engine_alternator->power < $generators['kVA']) { $generators['kVA'] = $engine_alternator->power; } if ($engine->days > $alternator->days) { $generators['days'] = $engine->days; } else { $generators['days'] = $alternator->days; } $generators['name'] = 'G' . $hz / 10 . '-' . round($generators['kVA']) . $engine->manufacturer->code . $alternator->manufacturer->code . 'BA'; if ($gen_number == 3) { $generators['name'] = $gen_number . 'x' . $generators['name']; } //echo '<pre>';print_r($generators);exit; $data['generators'] = $generators; $data['engine_manufacturer'] = $engine->manufacturer->name; $data['alternator_manufacturer'] = $alternator->manufacturer->name; \CI::load()->helper('calculator'); \CI::load()->helper('html_to_pdf'); $data['fuel'] = get_info_fuel_consumption($engine->id, $alternator->id, $hz, $phase); //echo '<pre>';print_r($data);exit; $html = \CI::load()->view('documents', $data, true); convert2pdf($html, $data['generators']['name'] . '.pdf'); exit; }
public function generate_generators($data) { $generators = array(); $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']); return $generators; }