//Save based data values in prepared variables
     $stars_counter = 0;
     for ($stars = 3; $stars >= 0; $stars--) {
         $stars_counter++;
         $b = array();
         $b['based_id'] = $stars;
         $b['name'] = "{$stars} Stars";
         $based_list[] = $b;
         $based_key[$stars] = $stars_counter;
     }
     $total_key = $stars_counter + 1;
 }
 //retrieve saved plan data of this year
 $plans = scorecard::retrievePlan($based, $year_period);
 //retrieve manually input data from last year to current year
 $manual_inputs = scorecard::retrieveManualInput($based, $year_period, $year_previous);
 //Prepare name of each data table
 $table_header = array();
 $table_header['daily'] = 'Daily Average';
 $table_header['total'] = 'Monthly Total';
 $table = array();
 $table['daily'] = array();
 $table['total'] = array();
 $table['neutral'] = array();
 //Default table collection for monthly and daily values
 //where monthly = total and daily = average
 $table_collection = array();
 $table_collection['sent_value'] = 'Gross Sales';
 $table_collection['sent'] = 'Quantity';
 //$table_collection['sent_vc'] = 'VC';
 //Table collection for data which is saved as average
 $based_list = array();
 $based_key = array();
 $based_name = 'Products Stars';
 $table_name = 'scorecard_warehouses';
 $table_key_column = 'stars';
 $stars_counter = 0;
 for ($stars = 3; $stars >= 0; $stars--) {
     $stars_counter++;
     $b = array();
     $b['based_id'] = $stars;
     $b['name'] = "{$stars} Stars";
     $based_list[] = $b;
     $based_key[$stars] = $stars_counter;
 }
 $total_key = $stars_counter + 1;
 $manual_inputs = scorecard::retrieveManualInput('warehouses_sp', $year_period, $year_previous);
 $table_header = array();
 $table_header['element'] = 'Element Stock Bali';
 $table_header['depot'] = 'Depot Stock HH';
 $table_header['amvd'] = 'Amazon Vendor Stock';
 $table_key_reference = array('1' => 'element', '5' => 'depot', 'amvd' => 'amvd');
 $table = array();
 foreach ($table_key_reference as $tbk) {
     $table[$tbk] = array();
 }
 $table_collection = array();
 $table_collection['quantity'] = 'Total Quantity';
 $table_collection['value'] = 'Total Value';
 $table_collection['incoming'] = 'Incoming Quantity';
 $table_collection['incoming_value'] = 'Incoming Value';
 $table_collection['outgoing'] = 'Outgoing Quantity';