Ejemplo n.º 1
0
<?php

$colors = $this->config->item('report_colors');
$style = $report_chart === 'line' ? 'style="border: 1px solid #E7E6E5;height: 20px;padding: 2px 0 0 10px;text-align: left;vertical-align: top;"' : 'style="border: 1px solid #E7E6E5;height: 20px;padding: 2px 0 0 10px;text-align: left;vertical-align: top;"';
if (isset($Data) && count($Data) > 0) {
    $j = 0;
    $url_modifier = $report === 'bycompetition' ? '0/bycompetition' : '';
    foreach ($Data as $prodId => $productData) {
        $pTitle = getProductsTitle($prodId);
        echo '<div class="search-result" rel="' . $prodId . '">';
        $image = isset($colors[$j]) ? frontImageUrl() . $colors[$j]['string'] . '_image.png' : '';
        echo '<div style="margin-bottom:10px;" class="product_save">
			<span class="prod-heading"><img src="' . $image . '" alt="' . $pTitle . ' key">Product Name: ' . $pTitle . '</span>
			<div class="clear"></div>
		  </div>
		</div>';
        if (!empty($marketplacesExist[$prodId])) {
            ?>
		<table border="0" bordercolor="#CCCCCC" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse; background:#fff; font-family:Arial, Helvetica, sans-serif; font-size:12px">
			<thead>
			<?php 
            if ($report_chart === 'line') {
                ?>
				<tr style="background:#E7E7E8; height:30px; color:#000; vertical-align: top">
					<th width="200" align="left" <?php 
                echo $style;
                ?>
>Marketplace</th>
					<th width="160" align="left" <?php 
                echo $style;
                ?>
        echo $competitor_map_id;
        ?>
" style="float:left; width:<?php 
        echo $brandWidth;
        ?>
%;">
			<div style="margin-bottom:10px;" class="product_save">
				<span style="background-color:<?php 
        echo $competitor_map_color;
        ?>
; <?php 
        echo $square;
        ?>
"></span>
				Our Product: <b><?php 
        echo getProductsTitle($competitor_map_id);
        ?>
</b><br>
			</div>
		</div>
		<?php 
    }
    ?>
		<div class="clear"></div>
	</div>

	<?php 
    if (!empty($marketplacesExist[$prodId])) {
        ?>
	<table border="0" bordercolor="#CCCCCC" cellpadding="3" cellspacing="0" width="100%" style=" border-collapse: collapse; background:#fff; font-family:Arial, Helvetica, sans-serif; font-size:12px">
		<thead>
Ejemplo n.º 3
0
            <?php 
        }
    }
    $i = 0;
    foreach ($gData['data']['result'] as $prodId => $series) {
        $has_outliers = ($gData['type'] === 'scatter' and isset($gData['data']['columns'][$prodId]['stats']['outliers']) and count($gData['data']['columns'][$prodId]['stats']['outliers']));
        ?>
            <div class="product_save">
                <span class="squareKey" style="background-color:<?php 
        echo $gData['data']['columns'][$prodId]['color']['hex'];
        ?>
"></span>
                <span class="draw_lines">
					Show our price-points:<br>
                    <!--<b><?php 
        echo getProductsTitle($prodId);
        ?>
</b><br>-->
                    <input type="checkbox" value="1" onclick="drawLines(<?php 
        echo $prodId;
        ?>
, 'retail', this);" id="retail_<?php 
        echo $prodId;
        ?>
" name="retail_<?php 
        echo $prodId;
        ?>
"><label for="retail_<?php 
        echo $prodId;
        ?>
">Retail</label>
Ejemplo n.º 4
0
 public function schedule_reports_list()
 {
     $this->_response_type('json');
     $data = array();
     $search = isset($_REQUEST['keyword']) ? $this->input->xss_clean($_REQUEST['keyword']) : '';
     $recurrings = array(0 => "", 1 => "Every Day", 7 => "Every Week", 31 => "Every Month", 365 => "Every Year");
     $rows = $this->report->get_report_schedule_list($search);
     for ($i = 0; $i < count($rows); $i++) {
         $wInfo = json_decode($rows[$i]->report_where, true);
         $dName = '';
         if (isset($wInfo['groupId'])) {
             $group = $this->products->getGroupByID($wInfo['groupId'][0]);
             $dName = $group['name'];
         } else {
             if (isset($wInfo['productIds'])) {
                 for ($x = 0, $y = sizeof($wInfo['productIds']); $x < $y; $x++) {
                     $dName .= getProductsTitle($wInfo['productIds'][$x]) . ', ';
                 }
                 $dName = trim($dName, ', ');
             }
         }
         $row = array();
         $row['check'] = 0;
         $row['id'] = $rows[$i]->id;
         $row['report_id'] = $rows[$i]->id;
         $row['report_name'] = $rows[$i]->report_name;
         $row['display_type'] = $this->report->set_report_type($rows[$i]->controller);
         $row['report_products_val'] = $dName;
         $row['report_where'] = $rows[$i]->report_where;
         $row['controller'] = $rows[$i]->controller;
         $row['controller_function'] = $rows[$i]->controller_function;
         $row['report_datetime'] = $rows[$i]->report_datetime;
         //$row['report_datetime'] = $rows[$i]->datetime;
         $row['report_recursive_frequency'] = $rows[$i]->report_recursive_frequency;
         $row['report_recursive_string'] = $recurrings[(int) $rows[$i]->report_recursive_frequency];
         $row['email_addresses'] = $rows[$i]->email_addresses;
         $data[$i] = $row;
     }
     $this->data = array('data' => $data);
 }
Ejemplo n.º 5
0
%;">
				<div style="margin-bottom:10px;" class="product_save">
					<span class="prod-heading">
						<span class="squareKey" style="margin-right: 5px; margin-top: 5px; background-color:<?php 
        echo $color;
        ?>
"></span>Competitor Product: <?php 
        echo $pTitle;
        ?>
					</span>
					<div class="clear"></div>
				</div>
			</div><?php 
        if (isset($comparison_data[$prodId])) {
            $competitor_map_id = $competitor_map[$prodId]['id'];
            $competitor_map_title = getProductsTitle($competitor_map_id);
            $competitor_map_color = Color_handler::get_next($color_index[$competitor_map_id])->get_hex();
            ?>

			<div class="search-result" rel="<?php 
            echo $competitor_map_id;
            ?>
" style="float:left; width:<?php 
            echo $brandWidth;
            ?>
%">
				<div style="margin-bottom:10px;" class="product_save">
					<span class="prod-heading">
						<span class="squareKey" style="margin-right: 5px; margin-top: 5px; background-color:<?php 
            echo $competitor_map_color;
            ?>
Ejemplo n.º 6
0
 /**
  * Pre process the data to use in google charts
  *
  * @param array $data
  * @param array $report_where
  * @param String $chartType
  * @return array
  */
 public function prepGoogleData($data, $report_where, $chartType)
 {
     if (empty($data)) {
         $data = array();
     }
     $store_id = get_instance()->store_id;
     //define chart type, colors come from global config
     //use productId as indexes for data=>result keys
     $googleData = array('type' => '', 'date' => array('start' => time(), 'end' => time()), 'data' => array('size' => 0));
     $marketColors = $this->config->item('market_colors');
     $prepData = array();
     switch ($chartType) {
         case 'scatter':
             /* example price array - only take what we need for the google data
             		array('price' => '17.59', 'retail' => '30.85', 'wholesale' => '17.56', 'map' => '21.6', 'count' => '1', 'upc' => '658010113403', 'title' => 'GARDEN OF LIFE 100% Organic Extra Virgin Coconut Oil 32 fl.oz', 'marketplace' => 'Shopping.com', 'url' => 'http://www.allstarhealth.com/de_p_ref/21115/DT21115/GARDEN_OF_LIFE_100Percent_Organic_Extra_Virgin_Coconut_Oil.htm', 'dt' => '1340074876', 'prod_id' => '391', 'timestamp' => '1340074876', 'hash_key' => 'AllStarHealth#658010113403', 'merchant' => 'AllStarHealth', 'original_name' => 'AllStarHealth', 'merchant_id' => '9183', 'date' => '06/18/2012 20:01:16')*/
             //scatterchart
             $c = 0;
             $googleData['type'] = 'scatter';
             //we can't have the start & end be the same for the scatter chart
             $googleData['date']['start'] = $report_where['date_from'];
             $googleData['date']['end'] = $report_where['date_to'] == $report_where['date_from'] ? $report_where['date_from'] + 86400 : $report_where['date_to'];
             $googleData['date']['earliest'] = time();
             $googleData['data']['size'] = sizeof($data);
             $num_outliers = 0;
             foreach ($data as $prodId => $prodData) {
                 // create the prepData and calculate average on pass 1
                 $avg = 0;
                 for ($i = 0, $n = sizeof($prodData); $i < $n; $i++) {
                     $price = (double) $prodData[$i]['price'];
                     $map = (double) $prodData[$i]['map'];
                     $violation = $price < $map;
                     $avg += $price;
                     $prepData[$prodId][] = array('price' => $price, 'map' => $map, 'marketplace' => $prodData[$i]['marketplace'], 'merchant' => getMerchantName($prodData[$i]['merchant_id']), 'merchant_id' => $prodData[$i]['merchant_id'], 'timestamp' => $prodData[$i]['timestamp'], 'violation' => $violation);
                     //reset earliest date if necessary
                     if ($prodData[$i]['timestamp'] < $googleData['date']['earliest']) {
                         $googleData['date']['earliest'] = $prodData[$i]['timestamp'];
                     }
                 }
                 // Calculate standard deviation on pass 2
                 $avg = $n > 0 ? round($avg / $n, 2) : 0;
                 $sd = 0;
                 for ($i = 0; $i < $n; $i++) {
                     $sd += pow($prepData[$prodId][$i]['price'] - $avg, 2);
                 }
                 $sd = $n > 0 ? round(sqrt($sd / $n), 2) : round(sqrt($sd), 2);
                 // find outliers on pass 3
                 $thresh = 3 * $sd;
                 $outliers = array();
                 for ($i = 0; $i < $n; $i++) {
                     if (abs($prepData[$prodId][$i]['price'] - $avg) > $thresh) {
                         $outliers[] = $i;
                         $num_outliers++;
                     }
                 }
                 // build data column
                 $productInfo = getProductUPCByID($prodId, $this->ci->store_id);
                 $mapPrice = getPricingHistory($productInfo['upc_code'], $this->ci->store_id, 'price_floor', $googleData['date']['start'], $googleData['date']['end']);
                 $retailPrice = getPricingHistory($productInfo['upc_code'], $this->ci->store_id, 'retail_price', $googleData['date']['start'], $googleData['date']['end']);
                 $wholeSalePrice = getPricingHistory($productInfo['upc_code'], $this->ci->store_id, 'wholesale_price', $googleData['date']['start'], $googleData['date']['end']);
                 $Color = Color_handler::get_next();
                 $color_info = array('hex' => $Color->get_hex(), 'string' => $Color->get_string());
                 $this->ci->data->colors[] = $color_info;
                 $googleData['data']['columns'][$prodId] = array('type' => 'number', 'color' => $color_info, 'name' => getProductsTitle($prodId), 'pricing' => array('map' => $mapPrice, 'retail' => $retailPrice, 'wholesale' => $wholeSalePrice), 'stats' => array('avg' => $avg, 'sd' => $sd, 'thresh' => $thresh, 'outliers' => $outliers));
                 $c++;
             }
             $googleData['data']['outliers'] = $num_outliers;
             $googleData['data']['result'] = $prepData;
             break;
         case 'line':
         default:
             /* example price array - only take what we need for the google data
             			array(391 => array(0 => array("marketplace" => "amazon", "upc" => "658010113403", "price" => "30.20", "wholesale" => array(0 => array("start" => "0000-00-00 00:00:00", "stamp" => 1340631116, "price" => 17.56)), "retail" => array(0 => array("start" => "0000-00-00 00:00:00", "stamp" => 1340631116, "price" => 30.85)), "map" => array(0 => array("start" => "0000-00-00 00:00:00", "stamp" => 1340631116, "price" => 21.6)), "dt" => 1340089200, "prod_id" => "391"))) */
             $googleData['type'] = 'line';
             $googleData['date']['start'] = $report_where['date_from'];
             $googleData['date']['end'] = $report_where['date_to'];
             $size = $c = 0;
             foreach ($data as $prodId => $data) {
                 $marketColorArray = array();
                 $upc = getProductsUPC($prodId);
                 $marketColorArray[$c] = array();
                 $Color = Color_handler::get_next();
                 $color_info = array('hex' => $Color->get_hex(), 'string' => $Color->get_string());
                 $this->ci->data->colors[] = $color_info;
                 $googleData['data']['columns'][$prodId] = array('type' => 'number', 'color' => $color_info, 'name' => getProductsTitle($prodId), 'pricing' => array('map' => getPricingHistory($upc, $store_id, 'price_floor', $report_where['date_from'], $report_where['date_to']), 'retail' => getPricingHistory($upc, $store_id, 'retail_price', $report_where['date_from'], $report_where['date_to']), 'wholesale' => getPricingHistory($upc, $store_id, 'wholesale_price', $report_where['date_from'], $report_where['date_to'])));
                 foreach ($data as $market => $pricing) {
                     $size++;
                     $marketColorArray['market'][$market] = isset($marketColors[$market]) ? $marketColors[$market] : stringToColorCode($market);
                     foreach ($pricing as $priceArr) {
                         $prepData[$prodId][$market][] = array('upc' => $priceArr['upc'], 'price' => (double) $priceArr['price'], 'dt' => $priceArr['dt'], 'date' => date('Y-m-d', $priceArr['dt']));
                     }
                 }
                 array_push($googleData['data']['columns'][$prodId]['color'], $marketColorArray['market']);
                 $c++;
             }
             $googleData['data']['size'] = $size;
             $googleData['data']['result'] = $prepData;
             break;
     }
     if ($googleData['data']['size'] == 0) {
         $googleData['type'] = "empty";
     }
     //echo "googs<br>\n";
     //var_dump($googleData);exit;
     return $googleData;
 }
Ejemplo n.º 7
0
function formatInputText($products, $skip_in = false)
{
    $text = '';
    $cnt = count($products);
    $i = 0;
    if ($products) {
        foreach ($products as $prod) {
            if (trim($prod) != '') {
                $upc = getProductsTitle($prod);
                if ($cnt == 1) {
                    $text = '' . $upc . ' pricing activity' . ($skip_in ? '' : ' in the');
                } elseif ($cnt == 2) {
                    if ($i == 0) {
                        $text .= '' . $upc . '';
                    } else {
                        $text .= ' and ' . $upc . ' pricing activity' . ($skip_in ? '' : ' in the');
                    }
                } else {
                    if ($i == 0) {
                        $text .= '' . $upc . '';
                    } elseif ($i == $cnt - 1) {
                        $text .= ' and ' . $upc . ' pricing activity' . ($skip_in ? '' : ' in the');
                    } else {
                        $text .= ', ' . $upc . '';
                    }
                }
                $i++;
            }
        }
    }
    //echo "TEXT : ".$text;
    return $text;
}
Ejemplo n.º 8
0
 /**
  *
  * function productViolationGraph
  *
  * @param <array>     $data
  *
  *
  */
 public static function productViolationGraph($gData, $request_info)
 {
     $graph_data = $gData['violations'];
     $series = array();
     $i = 0;
     $cat = createDateRangeArray($request_info['fromDate'], $request_info['toDate']);
     $cat = array_unique($cat);
     $tempArray = array();
     sort($cat);
     foreach ($graph_data as $key => $dArr) {
         $priceD1 = array();
         $priceD2 = array();
         $priceD3 = array();
         $k = 1;
         foreach ($cat as $ckey => $cval) {
             if (!isset($dArr[$cval])) {
                 unset($cat[$ckey]);
             } else {
                 if (!in_array($cat[$ckey], $tempArray)) {
                     $tempArray[] = $cat[$ckey];
                 }
                 $priceD1[] = isset($dArr[$cval]['amazon']) ? $dArr[$cval]['amazon'] : 0;
                 $priceD2[] = isset($dArr[$cval]['google']) ? $dArr[$cval]['google'] : 0;
                 $priceD3[] = isset($dArr[$cval]['Shopping.com']) ? $dArr[$cval]['Shopping.com'] : 0;
             }
         }
         if (in_array('all', $request_info['api_type'])) {
             $series[] = array('name' => getProductsTitle($key, 'Amazon'), 'data' => $priceD1, 'color' => Color_handler::get_next(0)->get_hex(), 'id' => $key);
             $series[] = array('name' => getProductsTitle($key, 'Google'), 'data' => $priceD2, 'color' => Color_handler::get_next(1)->get_hex(), 'id' => $key);
             $series[] = array('name' => getProductsTitle($key, 'Shopping.com'), 'data' => $priceD3, 'color' => Color_handler::get_next(2)->get_hex(), 'id' => $key);
         } else {
             if (in_array('Amazon', $request_info['api_type']) || in_array('amazon', $request_info['api_type'])) {
                 $series[] = array('name' => getProductsTitle($key, 'Amazon'), 'data' => $priceD1, 'color' => Color_handler::get_next(0)->get_hex(), 'id' => $key);
             }
             if (in_array('Google', $request_info['api_type']) || in_array('google', $request_info['api_type'])) {
                 $series[] = array('name' => getProductsTitle($key, 'Google'), 'data' => $priceD2, 'color' => Color_handler::get_next(1)->get_hex(), 'id' => $key);
             }
             if (in_array('Shopping.com', $request_info['api_type']) || in_array('shopping.com', $request_info['api_type']) || in_array('Shopping', $request_info['api_type']) || in_array('shopping', $request_info['api_type'])) {
                 $series[] = array('name' => getProductsTitle($key, 'Shoping.com'), 'data' => $priceD3, 'color' => Color_handler::get_next(2)->get_hex(), 'id' => $key);
             }
         }
         $i++;
     }
     $cat = $tempArray;
     foreach ($cat as $val) {
         $mcat[] = date('n/j', strtotime($val));
     }
     $cat = $mcat;
     if (count($cat) > 10) {
         foreach ($cat as $ind => &$val) {
             $val = ' ';
         }
     }
     $fArray = array('data' => $series, 'y_title' => 'Violations', 'x_title' => 'Date', 'cat' => $cat, 'type' => 'column');
     /* For Google Charts */
     $googledataColorArray = array();
     $googleDataArray = array();
     $googleDataArray[0][] = 'Date';
     $maxValue = 0;
     $prCount = count($graph_data);
     $keys = array_keys($graph_data);
     for ($prcounter = 0; $prcounter < $prCount; $prcounter++) {
         $color = Color_handler::get_next($prcounter)->get_hex();
         if (in_array('all', $request_info['api_type'])) {
             $googleDataArray[0][] = 'Amazon: ' . getProductsTitle($keys[$prcounter]);
             $googleDataArray[0][] = 'Google:' . getProductsTitle($keys[$prcounter]);
             $googleDataArray[0][] = 'Shopping.com:' . getProductsTitle($keys[$prcounter]);
             $googledataColorArray[] = $color;
             $googledataColorArray[] = $color;
             $googledataColorArray[] = $color;
         } else {
             if (in_array('Amazon', $request_info['api_type']) || in_array('amazon', $request_info['api_type'])) {
                 $googleDataArray[0][] = 'Amazon: ' . getProductsTitle($keys[$prcounter]);
                 $googledataColorArray[] = $color;
             }
             if (in_array('Google', $request_info['api_type']) || in_array('google', $request_info['api_type'])) {
                 $googleDataArray[0][] = 'Google:' . getProductsTitle($keys[$prcounter]);
                 $googledataColorArray[] = $color;
             }
             if (in_array('Shopping.com', $request_info['api_type']) || in_array('shopping.com', $request_info['api_type']) || in_array('Shopping', $request_info['api_type']) || in_array('shopping', $request_info['api_type'])) {
                 $googleDataArray[0][] = 'Shopping.com:' . getProductsTitle($keys[$prcounter]);
                 $googledataColorArray[] = $color;
             }
         }
     }
     foreach ($cat as $keyCat => $vCat) {
         $googleDataArray[$keyCat + 1][] = $vCat;
         foreach ($series as $seriesKey => $seriesData) {
             $valueForDisplay = isset($seriesData['data'][$keyCat]) ? $seriesData['data'][$keyCat] : 0;
             $googleDataArray[$keyCat + 1][] = $valueForDisplay;
             if ($valueForDisplay > $maxValue) {
                 $maxValue = $valueForDisplay;
             }
         }
     }
     $fArray['googleData'] = $googleDataArray;
     $fArray['googleDataColors'] = $googledataColorArray;
     $fArray['maxValue'] = $maxValue;
     /* END FOR Google Charts */
     return $fArray;
 }
Ejemplo n.º 9
0
 function priceViolation($gData, $report_where, $skip_graph_image = false)
 {
     $this->data->report_where = $report_where;
     $cat = array();
     $oItem = array();
     $item = array();
     $graph_data = array();
     $hourFlag = isset($this->data->report_where['time_frame']) && $this->data->report_where['time_frame'] == '24' ? true : false;
     $products = $this->data->report_where['product_ids'];
     // @TODO Universal colors
     $colors = array("#FBB925", "#00AEEF", "#BF302D", "#83B519", "#FD9B00");
     $series = array();
     $graph_data_temp = array();
     $tempcat = array();
     //echo "populating gData from priceViolation();<br>\n";
     $i = 0;
     //debug('Request in GRaph',$this->data->report_where,2);
     //debug('GraphData',$gData,2);
     //debug('REQUEST INFO',$this->data->report_where,2);
     $yTitle = 'Violations';
     if ($hourFlag) {
         $cat = last24HourCat($gData, true);
         //debug("CAT",$cat,2);
         //debug("Products",$products,2);
         //debug("gData",$gData,2);//exit;
         //debug('request',$this->data->report_where,2);
         $skipColorIndex = array();
         $ind = 0;
         foreach ($products as $key1 => $val) {
             $colorCount = 0;
             foreach ($gData as $key => $data) {
                 $key = explode('-', $key);
                 foreach ($data as $inData) {
                     if ($val == $inData['prod_id']) {
                         $colorCount++;
                         $tempTime = $inData['dt'];
                         $price = $inData['price'];
                         $alarmPrice = $inData['alarm_price'];
                         $market = $inData['market_place'];
                         if (isset($graph_data[$val]) && array_key_exists($key[0], $graph_data[$val]) && array_key_exists($key[1], $graph_data[$val][$key[0]])) {
                             $graph_data[$val][$key[0]][$key[1]]['count'] = $graph_data[$val][$key[0]][$key[1]]['count'] + 1;
                             $graph_data[$val][$key[0]][$key[1]]['price'] = $graph_data[$val][$key[0]][$key[1]]['price'] + $price;
                             $graph_data[$val][$key[0]][$key[1]]['alarmPrice'] = $graph_data[$val][$key[0]][$key[1]]['alarmPrice'] + $alarmPrice;
                         } else {
                             $graph_data[$val][$key[0]][$key[1]] = array('count' => 1, 'price' => $price, 'alarmPrice' => $alarmPrice, 'market_place' => $market);
                         }
                     }
                 }
             }
             if ($colorCount == '0') {
                 $skipColorIndex[] = $ind;
             }
             $ind++;
         }
         $cat = array_unique($cat);
         $tempArray = array();
         sort($cat);
         //debug('Graph Data',$graph_data,2);
         //debug('Cat',$cat,2);exit;
         // For colors Handling
         if (count($skipColorIndex) > 0) {
             $tmpColor = array();
             foreach ($colors as $cKeyC => $cValC) {
                 if (in_array($cKeyC, $skipColorIndex)) {
                     unset($colors[$cKeyC]);
                 } else {
                     $tmpColor[] = $cValC;
                 }
             }
             unset($colors);
             $colors = $tmpColor;
         }
         foreach ($graph_data as $key => $dArr) {
             $keyComp = key($dArr);
             $priceD = array();
             $alpriceD = array();
             $priceD1 = array();
             $priceD2 = array();
             $priceD3 = array();
             $k = 1;
             foreach ($cat as $ckey => $cval) {
                 $keyOther = $cval;
                 //echo date('Y-m-d H:i:s',$keyComp)."===============".date('Y-m-d H:i:s',$keyOther);
                 if (!isset($dArr[$cval])) {
                     continue;
                 } else {
                     if (!in_array($cat[$ckey], $tempArray)) {
                         $tempArray[] = $cat[$ckey];
                     }
                     $arr = $dArr[$cval];
                     //debug('ARR',$arr,2);
                     /* Added for adjusting data for google charts */
                     $priceD1[] = isset($arr['amazon']) ? $arr['amazon']['count'] : 0;
                     $priceD2[] = isset($arr['google']) ? $arr['google']['count'] : 0;
                     $priceD3[] = isset($arr['shopping']) ? $arr['shopping']['count'] : 0;
                 }
             }
             if (in_array('all', $this->data->report_where['api_type'])) {
                 $series[] = array('name' => getProductsTitle($key, 'Amazon'), 'data' => $priceD1, 'color' => $colors[0], 'id' => $key);
                 $series[] = array('name' => getProductsTitle($key, 'Google'), 'data' => $priceD2, 'color' => $colors[1], 'id' => $key);
                 $series[] = array('name' => getProductsTitle($key, 'Shopping.com'), 'data' => $priceD3, 'color' => $colors[2], 'id' => $key);
             } else {
                 if (in_array('Amazon', $this->data->report_where['api_type']) || in_array('amazon', $this->data->report_where['api_type'])) {
                     $series[] = array('name' => getProductsTitle($key, 'Amazon'), 'data' => $priceD1, 'color' => $colors[0], 'id' => $key);
                 }
                 if (in_array('Google', $this->data->report_where['api_type']) || in_array('google', $this->data->report_where['api_type'])) {
                     $series[] = array('name' => getProductsTitle($key, 'Google'), 'data' => $priceD2, 'color' => $colors[1], 'id' => $key);
                 }
                 if (in_array('Shopping.com', $this->data->report_where['api_type']) || in_array('shopping.com', $this->data->report_where['api_type']) || in_array('shopping', $this->data->report_where['api_type']) || in_array('Shopping', $this->data->report_where['api_type'])) {
                     $series[] = array('name' => getProductsTitle($key, 'Shoping.com'), 'data' => $priceD3, 'color' => $colors[2], 'id' => $key);
                 }
             }
             $i++;
         }
         //debug('cat',$cat,2);
         $cat = $tempArray;
         $mcat = array();
         foreach ($cat as $val) {
             $valExplode = explode('-', $val);
             $val = isset($valExplode[0]) ? $valExplode[0] : $val;
             $mcat[] = date('n/j/Y h:i A', $val);
         }
         $cat = $mcat;
     } else {
         $yTitle = 'Violations';
         $cat = createDateRangeArray($this->data->report_where['date_from'], $this->data->report_where['date_to']);
         $skipColorIndex = array();
         $ind = 0;
         $marketPlaceAr = array();
         foreach ($products as $key => $val) {
             $colorCount = 0;
             foreach ($gData as $data) {
                 if ($val == $data['prod_id']) {
                     $colorCount++;
                     $marketplace = strtolower($data['market_place']);
                     $date = date('m/d/y', $data['dt']);
                     if (isset($graph_data[$val]) && array_key_exists($date, $graph_data[$val])) {
                         $graph_data[$val][$date][$marketplace] += $data['violation_count'];
                     } else {
                         $graph_data[$val][$date][$marketplace] = $data['violation_count'];
                     }
                 }
             }
             if ($colorCount == '0') {
                 $skipColorIndex[] = $ind;
             }
             $ind++;
         }
         $cat = array_unique($cat);
         $tempArray = array();
         sort($cat);
         //debug('Market Place',$graph_data,2);
         //For handling Colors
         if (count($skipColorIndex) > 0) {
             $tmpColor = array();
             foreach ($colors as $cKeyC => $cValC) {
                 if (in_array($cKeyC, $skipColorIndex)) {
                     unset($colors[$cKeyC]);
                 } else {
                     $tmpColor[] = $cValC;
                 }
             }
             unset($colors);
             $colors = $tmpColor;
         }
         foreach ($graph_data as $key => $dArr) {
             $priceD1 = array();
             $priceD2 = array();
             $priceD3 = array();
             foreach ($cat as $ckey => $cval) {
                 if (!isset($dArr[$cval])) {
                     unset($cat[$ckey]);
                 } else {
                     if (!in_array($cat[$ckey], $tempArray)) {
                         $tempArray[] = $cat[$ckey];
                     }
                     $m = 0;
                     //debug('abc',$dArr,2);
                     $priceD1[] = isset($dArr[$cval]['amazon']) ? $dArr[$cval]['amazon'] : 0;
                     $priceD2[] = isset($dArr[$cval]['google']) ? $dArr[$cval]['google'] : 0;
                     $priceD3[] = isset($dArr[$cval]['shopping.com']) ? $dArr[$cval]['shopping.com'] : 0;
                 }
             }
             $series[] = array('name' => getProductsTitle($key), 'data' => $priceD1, 'color' => $colors[0], 'id' => $key);
             //'dashStyle' => 'Dot', 'color' => $colors[$i],
             $series[] = array('name' => getProductsTitle($key), 'data' => $priceD2, 'color' => $colors[1], 'id' => $key);
             //'dashStyle' => 'Dot', 'color' => $colors[$i],
             $series[] = array('name' => getProductsTitle($key), 'data' => $priceD3, 'color' => $colors[2], 'id' => $key);
             //'dashStyle' => 'Dot', 'color' => $colors[$i],
             $i++;
         }
         $cat = $tempArray;
         foreach ($cat as $val) {
             $mcat[] = date('n/j', strtotime($val));
         }
         $cat = $mcat;
     }
     //debug('series',$series,2);
     //debug('cat',$cat,2);
     /*debug('cat',$cat,2);
        debug('series',$series,2);
       exit; */
     if (count($cat) > 10) {
         $newCat = array();
         foreach ($cat as $ind => $val) {
             $newCat[] = ' ';
         }
         $cat = $newCat;
     }
     $fArray = array('data' => $series, 'y_title' => isset($yTitle) ? $yTitle : 'Violations', 'x_title' => 'Date', 'cat' => $cat, 'type' => 'scatter');
     /* For Google Charts */
     $googledataColorArray = array();
     $googleDataArray = array();
     $googleDataArray[0][] = 'Date';
     $maxValue = 0;
     $prCount = count($products);
     for ($prcounter = 0; $prcounter < $prCount; $prcounter++) {
         if (in_array('all', $this->data->report_where['api_type'])) {
             $googleDataArray[0][] = 'Amazon: ' . getProductsTitle($products[$prcounter]);
             $googleDataArray[0][] = 'Google: ' . getProductsTitle($products[$prcounter]);
             $googleDataArray[0][] = 'Shopping.com: ' . getProductsTitle($products[$prcounter]);
             $googledataColorArray[] = $colors[$prcounter];
             $googledataColorArray[] = $colors[$prcounter];
             $googledataColorArray[] = $colors[$prcounter];
         } else {
             if (in_array('Amazon', $this->data->report_where['api_type']) || in_array('amazon', $this->data->report_where['api_type'])) {
                 $googleDataArray[0][] = 'Amazon: ' . getProductsTitle($products[$prcounter]);
                 $googledataColorArray[] = $colors[$prcounter];
             }
             if (in_array('Google', $this->data->report_where['api_type']) || in_array('google', $this->data->report_where['api_type'])) {
                 $googleDataArray[0][] = 'Google: ' . getProductsTitle($products[$prcounter]);
                 $googledataColorArray[] = $colors[$prcounter];
             }
             if (in_array('Shopping.com', $this->data->report_where['api_type']) || in_array('shopping.com', $this->data->report_where['api_type']) || in_array('shopping', $this->data->report_where['api_type']) || in_array('Shopping', $this->data->report_where['api_type'])) {
                 $googleDataArray[0][] = 'Shopping.com: ' . getProductsTitle($products[$prcounter]);
                 $googledataColorArray[] = $colors[$prcounter];
             }
         }
     }
     foreach ($cat as $keyCat => $vCat) {
         /*For Scatter chart*/
         $newDate = date('Y-m-d H:i:s', strtotime($vCat));
         $newDate = explode(' ', $newDate);
         $newDate1 = explode('-', $newDate[0]);
         $newDate2 = explode(':', $newDate[1]);
         if ($hourFlag) {
             $googleDataArray[$keyCat + 1][] = 'new  Date(' . $newDate1[0] . ',' . ($newDate1[1] - 1) . ',' . $newDate1[2] . ',' . $newDate2[0] . ',' . $newDate2[1] . ',' . $newDate2[2] . ')';
         } else {
             $googleDataArray[$keyCat + 1][] = $vCat;
             //uncomment for column chart and comment the above line
         }
         foreach ($series as $seriesKey => $seriesData) {
             $valueForDisplay = isset($seriesData['data'][$keyCat]) ? $seriesData['data'][$keyCat] : 0;
             $googleDataArray[$keyCat + 1][] = $valueForDisplay;
             if ($valueForDisplay > $maxValue) {
                 $maxValue = $valueForDisplay;
             }
         }
     }
     //debug('Final Array',$fArray,2);
     //debug('Google Array',$googleDataArray,2);
     $fArray['googleData'] = $googleDataArray;
     $fArray['googleDataColors'] = $googledataColorArray;
     $fArray['maxValue'] = $maxValue;
     /* END FOR Google Charts */
     $graphImagename = '';
     if (!$skip_graph_image) {
         //$graphImagename = $this->generateGraphImage($fArray, $hourFlag, 'Violation Report');
     }
     $fArray['graphImageName'] = $graphImagename;
     //debug('DATA',$fArray,2);
     return $fArray;
 }