public function bygroup() { $this->data->report = 'bygroup'; $this->data->proMerchants = getProductMerchant($this->store_id); $this->data->product_groups = $this->Product->getGroups($this->store_id); $this->_build_options_array($this->data->report); }
public function bydate() { $this->data->report = 'bydate'; $this->data->proMerchants = getProductMerchant($this->store_id); $this->_build_options_array($this->data->report); }
/** * Return the report as an html String * * @return String */ private function renderHtml() { $products_w_comparisons = array(); if ($this->data->controller_function === 'bycompetition') { // this is a competitor's product $this->data->competitor_products = $this->Product->getProductsById(null, $this->data->products); $this->data->competitor_store_id = array(); for ($i = 0, $n = count($this->data->competitor_products); $i < $n; $i++) { $this->data->competitor_store_id[] = $this->data->competitor_products[$i]['store_id']; } $this->data->competitor_store_id = array_unique($this->data->competitor_store_id); $this->data->proMerchants = getProductMerchant($this->data->competitor_store_id); if ($this->data->show_comparison) { // and it's a comparison $competitor_map = $this->Store->getCompetitorMap($this->report_info->store_id, $this->data->products); $this->data->competitor_store_id[] = $this->report_info->store_id; $products_wo_comparisons = $this->data->products; $this->data->competitor_map = array(); foreach ($competitor_map as $bpp) { $this->data->products[] = $bpp['owner_brand_product']; $owned_product = $this->Product->getProductsById(null, $bpp['owner_brand_product']); if (!empty($owned_product[0]['id'])) { $this->data->competitor_map[$bpp['competitor_brand_product']] = $owned_product[0]; } } $products_w_comparisons = $this->data->products; } } if ($this->data->show_comparison and isset($products_wo_comparisons)) { // don't populate product fields with the compared $this->data->products = $products_wo_comparisons; } $this->_get_retailers_marketplaces_exists(); $this->_prep_competitor_map($products_w_comparisons); $this->_prep_graph_image(); $html = $this->_get_report_html(); return $html; }
function market($market, $prodId, $dateStart, $dateEnd = NULL, $report_type = NULL, $id = false) { $this->data->by_which = $report_type ? $report_type : 'bymarket'; $this->data->competitor_store_id = false; if ($this->data->by_which === 'bycompetition') { // this is a competitor's product $this->data->competitor_product = $this->Product->get_by('id', $prodId); $this->data->competitor_store_id = $this->data->competitor_product->store_id; $this->data->proMerchants = getProductMerchant($this->data->competitor_store_id); $lookup_id = $this->data->competitor_store_id; } else { $lookup_id = $this->store_id; } $searchProduct = $this->Product->getProductsById($lookup_id, $prodId); if (!isset($searchProduct[0])) { redirect('reports'); } $this->layout = 'frontend_inner'; $this->data->time_frame = '24'; if (!$dateEnd) { $this->data->flagDates24 = true; } $this->data->my = 'productpricing'; $this->data->productArr = getProductsDrp($this->store_id); $this->data->proMerchants = getProductMerchant($this->store_id); //$this->data->markertArr = getMarketArray(); $this->data->product_ids = array($prodId); $this->data->searchProducts = array($prodId => $searchProduct[0]['title']); $this->data->date_from = $dateStart; $this->data->date_to = $dateEnd ? $dateEnd : $dateStart; $this->data->submitted = true; $this->data->all_markets = false; $this->data->all_retailers = false; if ($this->data->date_from !== 'Start' && $this->data->date_to !== 'Stop') { $this->data->dateStartField = $this->data->date_from; $this->data->dateEndField = $this->data->date_to; $this->data->date_from = strtotime($this->data->date_from); $this->data->date_to = !$dateEnd ? strtotime($this->data->date_to . ' 23:59:59') : strtotime($this->data->date_to); $this->data->time_frame = ''; if ($this->data->date_from == $this->data->date_to) { $this->data->flagDates24 = true; $this->data->time_frame = '24'; } } else { $tF = getTimeFrame($this->data->time_frame); $this->data->date_from = $tF['date_from']; $this->data->date_to = $tF['date_to']; } //the saved report Id if ($id) { $this->data->report_id = $this->input->post('report_id'); } if ($product_name = $this->input->post('product_name')) { if (is_array($product_name)) { for ($i = 0, $n = sizeof($product_name); $i < $n; $i++) { $this->data->report_name .= $product_name[$i] . ' '; } $this->data->report_name .= 'Product Pricing'; } $this->data->file_name = str_replace(' ', '_', $this->data->report_name . ' ' . date('Y-m-d')); $this->data->productNames = $this->input->post('product_name'); } $this->data->merchants = $this->input->post('merchants') ? $this->input->post('merchants') : array(); $this->data->markets = array(ucfirst($market)); $this->data->show_comparison = false; $this->data->report_where = array('date_from' => $this->data->date_from, 'date_to' => $this->data->date_to, 'api_type' => $this->data->markets, 'product_ids' => $this->data->product_ids, 'merchants' => $this->data->merchants, 'time_frame' => $this->data->time_frame, 'store_id' => $this->store_id, 'competitor_store_id' => array($this->data->competitor_store_id), 'show_comparison' => $this->data->show_comparison); //get cron_ids for 24 hour scatter $this->data->report_chart = 'scatter'; if ($this->data->flagDates24) { $this->data->report_where['cron_ids'] = getLast24HoursCronIds($this->data->date_from, '', $this->data->report_where['api_type']); } else { $this->data->report_where['cron_ids'] = getLast24HoursCronIds('', '', $this->data->report_where['api_type']); } $response = $this->Report->productPricingReport24($this->data->report_where); $this->data->Data = $response['data']; $this->data->gData = $this->Chart->prepGoogleData($response['data'], $this->data->report_where, $this->data->report_chart); $this->data->submitted = true; $this->session->set_userdata('report_where', $this->data->report_where); $this->data->graphDataType = 'chart'; // // Set retailer/marketplace information // $this->data->marketRetailer = array(); $this->data->retailersExist = array(); $this->data->marketplacesExist = array(); if ($this->data->report_chart === 'line') { foreach ($this->data->Data as $prodId => $marketArr) { foreach ($marketArr as $marketName => $productData) { if (!isset($this->data->marketRetailer[$marketName])) { $this->data->marketRetailer[$marketName] = $this->Marketplace->is_retailer($marketName); } if ($this->data->marketRetailer[$marketName]) { $this->data->retailersExist[$prodId] = true; } else { $this->data->marketplacesExist[$prodId] = true; } } } } elseif ($this->data->report_chart === 'scatter') { foreach ($this->data->Data as $prodId => $productData) { for ($i = 0, $n = count($productData); $i < $n; $i++) { $marketName = strtolower($productData[$i]['marketplace']); if (!isset($this->data->marketRetailer[$marketName])) { $this->data->marketRetailer[$marketName] = $this->Marketplace->is_retailer($marketName); } if ($this->data->marketRetailer[$marketName]) { $this->data->retailersExist[$prodId] = true; } else { $this->data->marketplacesExist[$prodId] = true; } } } } $this->_build_options_array($this->data->by_which); //$this->data->headerHTML = $this->load->view("front/reports_new_header", $this->data, true); }
/** * * @author unknown * @param unknown_type $id * @param unknown_type $whois_switch */ private function setDefaultValues($id = 0, $whois_switch = 'marketplace') { $this->session->set_userdata("report_type", "whois"); $this->data->productArr = getProductsDrp($this->store_id); $this->data->proMerchants = getProductMerchant($this->store_id); $this->data->markertArr = getMarketArray(); $this->data->is_report = false; $this->data->report = 'default'; $this->data->is_post = false; $this->data->my = "whois"; $this->data->merchantReport = ''; $this->data->report_id = 0; $this->data->date_from = 'Start'; $this->data->date_to = 'Stop'; $this->data->time_frame = ''; $this->data->products_ids = $this->data->markets = $this->data->merchants = array(); $this->data->whoisSwitch = $whois_switch; if ($id == 0) { $post = array('report_type' => 'whois', 'report' => 'default', 'date_from' => 'Start', 'date_to' => 'Stop', 'time_frame' => '', 'products_ids' => array(), 'merchants' => array(), 'markets' => array(), 'whoisSwitch' => $whois_switch); $data = $this->input->post_default($post); foreach ($data as $key => $value) { $this->data->{$key} = $value; } } else { $this->data->report_id = $id; $this->data->report_info = $this->Report->get_save_report_by_id($id); $report_where = json_decode($this->data->report_info['report_where'], true); if (!empty($report_where)) { foreach ($report_where as $key => $value) { $this->data->{$key} = $value; } } if ($this->data->date_from !== 'Start') { $this->data->date_from = date('Y-m-d', $this->data->date_from); } if ($this->data->date_to !== 'Stop') { $this->data->date_to = date('Y-m-d', $this->data->date_to); } } $this->data->marketplace_keys = array(); $tempProducts = array(); if (!empty($this->data->products_ids)) { foreach ($this->data->products_ids as $indexKey => $nV) { if ($nV == '') { unset($this->data->products_ids[$indexKey]); } else { $tempProducts[] = $nV; } } $this->data->is_post = true; } $this->data->product_ids = $tempProducts; $this->data->product_data = array(); $this->data->report_where = array('date_from' => $this->data->date_from, 'date_to' => $this->data->date_to, 'api_type' => empty($this->data->api_type) ? array('all') : $this->data->api_type, 'product_ids' => $this->data->product_ids, 'merchants' => $this->data->merchants, 'time_frame' => 1, 'report_type' => $this->data->report_type, 'cron_ids' => array(), 'whoisSwitch' => $this->data->whoisSwitch, 'isoverview' => true, 'is_retailer' => false); }