コード例 #1
0
ファイル: Grid.php プロジェクト: cnglobal-sl/caterez
 /**
  * Test for AW_Advancedreports_Block_Advanced_Grid::getFilter($name)
  * @loadFixture
  * @dataProvider dataProvider
  */
 public function testGetFilterName($storedData, $postFilterString, $name, $result)
 {
     parse_str($storedData, $data);
     $session = Mage::getSingleton('adminhtml/session');
     $session->setData(AW_Advancedreports_Helper_Queue::DATA_KEY_LAST_FILTERS, $data);
     $block = new AW_Advancedreports_Block_Advanced_Grid();
     parse_str($postFilterString, $filters);
     foreach ($filters as $filterKey => $filterValue) {
         $block->setFilter($filterKey, $filterValue);
     }
     $block->setId('one')->setId('two');
     $this->assertEquals($result, $block->getFilter($name));
 }
コード例 #2
0
ファイル: Grid.php プロジェクト: cnglobal-sl/caterez
 /**
  * Retrives initialization array for custom report option
  * @return array
  */
 public function getCustomOptionsRequired()
 {
     $array = parent::getCustomOptionsRequired();
     $include = Mage::getModel('advancedreports/system_config_source_include');
     $skutypes = Mage::getSingleton('advancedreports/system_config_source_skutype')->toOptionArray();
     $addArray = array(array('id' => 'include_refunded', 'type' => 'select', 'args' => array('label' => $this->_helper()->__('Include refunded items'), 'title' => $this->_helper()->__('Include refunded items'), 'name' => 'include_refunded', 'values' => $include->toOptionArray()), 'default' => '1'), array('id' => self::OPTION_SALES_GROUPED_SKU, 'type' => 'select', 'args' => array('label' => $this->_helper()->__('SKU usage'), 'title' => $this->_helper()->__('SKU usage'), 'name' => self::OPTION_SALES_GROUPED_SKU, 'class' => '', 'required' => true, 'values' => $skutypes), 'default' => AW_Advancedreports_Model_System_Config_Source_Skutype::SKUTYPE_SIMPLE));
     return array_merge($array, $addArray);
 }
コード例 #3
0
ファイル: Aggregator.php プロジェクト: cnglobal-sl/caterez
 /**
  * Create database for grid columns
  * @param string $name
  * @param AW_Advancedreports_Block_Advanced_Grid $grid
  * @return AW_Advancedreports_Helper_Tools_Aggregator
  */
 private function _createFlatTable($name, $grid)
 {
     if ($grid) {
         $table = new Varien_Db_Ddl_Table();
         $table->setName($name);
         $periodKey = self::DATE_KEY_FIELD;
         $table->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_BIGINT, null, array('unsigned' => true, 'primary' => true, 'nullable' => false, 'identity' => true));
         $table->addColumn($periodKey, Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array('nullable' => false));
         foreach ($grid->getSetupColumns() as $column) {
             $index = $column->getIndex();
             $type = $column->getDdlType();
             $size = $column->getDdlSize();
             $options = $column->getDdlOptions();
             if ($index && $type) {
                 $table->addColumn($index, $type, $size, $options);
             }
         }
         $write = $this->_getWriteAdapter()->createTable($table);
     }
     return $this;
 }
コード例 #4
0
ファイル: Grid.php プロジェクト: CherylMuniz/fashion
 public function getPeriods()
 {
     return parent::_getOlderPeriods();
 }
コード例 #5
0
 protected function _prepareData()
 {
     for ($i = 0; $i < 24; $i++) {
         $row['hours'] = date('H:i', mktime($i, 0));
         $row['title'] = date('H', mktime($i, 0));
         $row['qty_ordered'] = 0;
         $row['total'] = 0;
         $this->_addCustomData($row);
     }
     //	echo $this->getCollection()->getSelect()->__toString();
     foreach ($this->getCollection() as $order) {
         $row = array();
         foreach ($this->_columns as $column) {
             if (!$column->getIsSystem()) {
                 $row[$column->getIndex()] = $order->getData($column->getIndex());
             }
         }
         $row['hours'] = date('H:i', mktime($order->getHour(), 0));
         $row['qty_ordered'] = $order->getSumQty();
         $row['total'] = $order->getSumTotal();
         $this->_addCustomData($row);
     }
     //        print_r( $this->_customData );
     if (!count($this->_customData)) {
         return $this;
     }
     $key = $this->getFilter('reload_key');
     if ($key === 'qty') {
         //All qty
         $qty = 0;
         foreach ($this->_customData as $d) {
             $qty += $d['qty_ordered'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             if ($qty) {
                 $d['percent'] = round($d['qty_ordered'] * 100 / $qty) . ' %';
                 $d['percent_data'] = round($d['qty_ordered'] * 100 / $qty);
                 $d['data_for_chart'] = $d['qty_ordered'];
             } else {
                 $d['percent'] = '0 %';
                 $d['percent_data'] = 0;
                 $d['data_for_chart'] = $d['qty_ordered'];
             }
         }
     } elseif ($key === 'total') {
         //All qty
         $total = 0;
         foreach ($this->_customData as $d) {
             $total += $d['total'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             if ($total) {
                 $d['percent'] = round($d['total'] * 100 / $total) . ' %';
                 $d['percent_data'] = round($d['total'] * 100 / $total);
                 $d['data_for_chart'] = $d['total'];
             } else {
                 $d['percent'] = '0 %';
                 $d['percent_data'] = 0;
                 $d['data_for_chart'] = $d['total'];
             }
         }
     } else {
         return $this;
     }
     Mage::helper('advancedreports')->setChartData($this->_customData, Mage::helper('advancedreports')->getDataKey($this->_routeOption));
     parent::_prepareData();
     return $this;
 }
コード例 #6
0
ファイル: Grid.php プロジェクト: CherylMuniz/fashion
 protected function _prepareData()
 {
     foreach ($this->_helper()->getWeekChain() as $i) {
         $row['weekday'] = $i;
         $row['title'] = $this->_helper()->getWeekday($row['weekday']);
         $row['qty_ordered'] = 0;
         $row['total'] = 0;
         $this->_addCustomData($row);
     }
     foreach ($this->getCollection() as $order) {
         $row = array();
         foreach ($this->_columns as $column) {
             if (!$column->getIsSystem()) {
                 $row[$column->getIndex()] = $order->getData($column->getIndex());
             }
         }
         $row['weekday'] = $order->getDayOfWeek() - 1;
         $row['qty_ordered'] = $order->getSumQty();
         $row['total'] = $order->getSumTotal();
         $this->_addCustomData($row);
     }
     if (!count($this->_customData)) {
         return $this;
     }
     $key = $this->getFilter('reload_key');
     if ($key === 'qty') {
         //All qty
         $qty = 0;
         foreach ($this->_customData as $d) {
             $qty += $d['qty_ordered'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             if ($qty) {
                 $d['percent'] = round($d['qty_ordered'] * 100 / $qty) . ' %';
                 $d['percent_data'] = round($d['qty_ordered'] * 100 / $qty);
                 $d['data_for_chart'] = $d['qty_ordered'];
             } else {
                 $d['percent'] = '0 %';
                 $d['percent_data'] = 0;
                 $d['data_for_chart'] = $d['qty_ordered'];
             }
         }
     } elseif ($key === 'total') {
         //All qty
         $total = 0;
         foreach ($this->_customData as $d) {
             $total += $d['total'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             if ($total) {
                 $d['percent'] = round($d['total'] * 100 / $total) . ' %';
                 $d['percent_data'] = round($d['total'] * 100 / $total);
                 $d['data_for_chart'] = $d['total'];
             } else {
                 $d['percent'] = '0 %';
                 $d['percent_data'] = 0;
                 $d['data_for_chart'] = $d['total'];
             }
         }
     } else {
         return $this;
     }
     Mage::helper('advancedreports')->setChartData($this->_customData, Mage::helper('advancedreports')->getDataKey($this->_routeOption));
     parent::_prepareData();
     return $this;
 }
コード例 #7
0
 public function getCsv($filename = '')
 {
     $this->_beforeExport();
     return parent::getCsv($filename);
 }
コード例 #8
0
ファイル: Grid.php プロジェクト: cnglobal-sl/caterez
 /**
  * Prepare data array for Pie and Grid
  * @return AW_Advancedreports_Block_Advanced_Purchased_Grid
  */
 protected function _prepareData()
 {
     foreach ($this->getCollection() as $order) {
         $row = array();
         foreach ($this->_columns as $column) {
             if (!$column->getIsSystem()) {
                 $row[$column->getIndex()] = $order->getData($column->getIndex());
             }
         }
         $row['customers'] = 1;
         $row['title'] = round($row['sum_qty']);
         $this->_addCustomData($row);
     }
     if (!count($this->_customData)) {
         return $this;
     }
     usort($this->_customData, array(&$this, "_compareQtyElements"));
     $this->_helper()->setChartData($this->_customData, $this->_helper()->getDataKey($this->_routeOption));
     parent::_prepareData();
     return $this;
 }
コード例 #9
0
ファイル: Grid.php プロジェクト: cnglobal-sl/caterez
 protected function _prepareData()
 {
     # Extract data from collection
     $col = $this->getCollection();
     if ($col && count($col)) {
         foreach ($col as $_subItem) {
             $row = array();
             # Get all colummns values
             foreach ($this->_columns as $column) {
                 if (!$column->getIsSystem()) {
                     $row[$column->getIndex()] = $column->getRowField($_subItem);
                 }
             }
             # Add quantity
             $row['ordered_qty'] = $_subItem->getSumQty();
             # Add total
             $row['total'] = $_subItem->getSumTotal();
             # Add product id
             $row['id'] = $_subItem->getProductId();
             if (isset($row['id']) && isset($row['name'])) {
                 $_product = Mage::getModel('catalog/product')->load($row['id']);
                 if ($_product->getData()) {
                     $row['name'] = $_product->getName();
                 }
                 unset($_product);
             }
             $this->_addBestsellerData($row);
         }
     }
     if (!count($this->_customData)) {
         return $this;
     }
     $key = $this->getFilter('reload_key');
     if ($key === 'qty') {
         # Sort data
         usort($this->_customData, array(&$this, "_compareQtyElements"));
         # Splice array
         array_splice($this->_customData, $this->getCustomOption('advancedreports_bestsellers_options_bestsellers_count'));
         # All qty
         $qty = 0;
         foreach ($this->_customData as $d) {
             $qty += $d['ordered_qty'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             $d['percent'] = round($d['ordered_qty'] * 100 / $qty) . ' %';
             $d['percent_data'] = round($d['ordered_qty'] * 100 / $qty);
             //Add title
             $d['title'] = $d['name'] . ' (' . $d['percent'] . ')';
         }
     } elseif ($key === 'total') {
         //Sort data
         usort($this->_customData, array(&$this, "_compareTotalElements"));
         //Splice array
         array_splice($this->_customData, $this->getCustomOption('advancedreports_bestsellers_options_bestsellers_count'));
         //All qty
         $total = 0;
         foreach ($this->_customData as $d) {
             $total += $d['total'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             $d['percent'] = round($d['total'] * 100 / $total) . ' %';
             $d['percent_data'] = round($d['total'] * 100 / $total);
             //Add title
             $d['title'] = $d['name'] . ' (' . $d['percent'] . ')';
         }
     } else {
         return $this;
     }
     $this->_helper()->setChartData($this->_customData, $this->_helper()->getDataKey($this->_routeOption));
     parent::_prepareData();
     return $this;
 }
コード例 #10
0
 protected function _prepareData()
 {
     //		echo $this->getCollection()->getSelect()->__toString();
     foreach ($this->getCollection() as $item) {
         $row = $item->getData();
         if (isset($row['order_ship_country_id'])) {
             //				$row['order_ship_country'] = Mage::getSingleton('directory/country')->loadByCode( $row['order_ship_country_id'] )->getName();
             $row['order_ship_country'] = $row['order_ship_country_id'];
         }
         if (isset($row['order_bil_country_id'])) {
             //				$row['order_bil_country'] = Mage::getSingleton('directory/country')->loadByCode( $row['order_bil_country_id'] )->getName();
             $row['order_bil_country'] = $row['order_bil_country_id'];
         }
         # Billing/Shipping logic
         if (isset($row['order_ship_country'])) {
             $row['order_country'] = $row['order_ship_country'];
         } elseif (isset($row['order_bil_country'])) {
             $row['order_country'] = $row['order_bil_country'];
         }
         if (isset($row['order_ship_region'])) {
             $row['order_region'] = $row['order_ship_region'];
         } elseif (isset($row['order_bil_region'])) {
             $row['order_region'] = $row['order_bil_region'];
         }
         if (isset($row['order_ship_city'])) {
             $row['order_city'] = $row['order_ship_city'];
         } elseif (isset($row['order_bil_city'])) {
             $row['order_city'] = $row['order_bil_city'];
         }
         if (isset($row['order_ship_postcode'])) {
             $row['order_postcode'] = $row['order_ship_postcode'];
         } elseif (isset($row['order_bil_postcode'])) {
             $row['order_postcode'] = $row['order_bil_postcode'];
         }
         $row['base_row_subtotal'] = $row['base_row_total'];
         $row['base_row_total'] = $row['base_row_total'] + $row['base_tax_amount'] - abs($row['base_discount_amount']);
         if ($row['base_row_total'] < 0) {
             $row['base_row_total'] = 0;
         }
         if ($row['base_row_invoiced'] > $row['base_row_total']) {
             $row['base_row_invoiced'] = $row['base_row_total'];
         }
         if (isset($row['base_row_refunded'])) {
             if ($row['base_row_refunded'] > $row['base_row_total']) {
                 $row['base_row_refunded'] = $row['base_row_total'];
             }
         } else {
             if ($row['base_amount_refunded'] > $row['base_row_total']) {
                 $row['base_row_refunded'] = $row['base_row_total'];
             } else {
                 $row['base_row_refunded'] = $row['base_amount_refunded'];
             }
         }
         if (isset($row['simple_sku'])) {
             $row['sku'] = $row['simple_sku'];
         }
         //			elseif (isset($row['product_id'])){
         //
         //			}
         //			Varien_Profiler::start('aw:advancedreports::sales::prepare_data::load_product');
         //			if (isset($row['product_id']) && $product = Mage::getSingleton('catalog/product')->load($row['product_id'])){
         //				$opt_id = $product->getManufacturer();
         //				$row['product_manufacturer'] = $this->_getManufacturer($opt_id);
         //			}
         //            Varien_Profiler::stop('aw:advancedreports::sales::prepare_data::load_product');
         if (isset($row['sku'])) {
             $this->_addCustomData($row);
         }
     }
     //        var_dump('speed:'.Varien_Profiler::fetch('aw:advancedreports::sales::prepare_data::load_product') );
     //        var_dump('mem:'.Varien_Profiler::fetch('aw:advancedreports::sales::prepare_data::load_product', 'emalloc') );
     //		echo '<pre>';
     //	var_dump($chartLabels);
     //		var_dump($this->_customData);
     //		echo '</pre>';
     parent::_prepareData();
     $this->_setColumnFilters();
     return $this;
 }
コード例 #11
0
ファイル: Grid.php プロジェクト: CherylMuniz/fashion
 /**
  * Prepare Custom Data to show chart
  * @return AW_Advancedreports_Block_Advanced_Country_Grid
  */
 protected function _prepareData()
 {
     foreach ($this->getCollection() as $order) {
         $row = array();
         foreach ($this->_columns as $column) {
             if (!$column->getIsSystem()) {
                 $row[$column->getIndex()] = $order->getData($column->getIndex());
             }
         }
         if ($order->getCountryId()) {
             $row['country_id'] = $order->getCountryId();
             $row['qty_ordered'] = $order->getSumQty();
             $row['total'] = $order->getSumTotal();
             $this->_addCustomData($row);
         }
     }
     if (!count($this->_customData)) {
         return $this;
     }
     $key = $this->getFilter('reload_key');
     if ($key === 'qty') {
         //Sort data
         usort($this->_customData, array(&$this, "_compareQtyElements"));
         //All qty
         $qty = 0;
         foreach ($this->_customData as $d) {
             $qty += $d['qty_ordered'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             $d['percent'] = round($d['qty_ordered'] * 100 / $qty) . ' %';
             $d['percent_data'] = round($d['qty_ordered'] * 100 / $qty);
             //Add title
             $d['country_name'] = Mage::getSingleton('directory/country')->loadByCode($d['country_id'])->getName();
         }
     } elseif ($key === 'total') {
         //Sort data
         usort($this->_customData, array(&$this, "_compareTotalElements"));
         //All qty
         $total = 0;
         foreach ($this->_customData as $d) {
             $total += $d['total'];
         }
         foreach ($this->_customData as $i => &$d) {
             $d['order'] = $i + 1;
             if ($total != 0) {
                 $d['percent'] = round($d['total'] * 100 / $total) . ' %';
                 $d['percent_data'] = round($d['total'] * 100 / $total);
             } else {
                 $d['percent'] = '0 %';
                 $d['percent_data'] = 0;
             }
             //Add title
             $d['country_name'] = Mage::getSingleton('directory/country')->loadByCode($d['country_id'])->getName();
         }
     } else {
         return $this;
     }
     $this->_helper()->setChartData($this->_customData, $this->_helper()->getDataKey($this->_routeOption));
     parent::_prepareData();
     return $this;
 }
コード例 #12
0
 protected function _prepareData()
 {
     //		echo $this->getCollection()->getSelect()->__toString();
     foreach ($this->getCollection() as $order) {
         $row = array();
         foreach ($this->_columns as $column) {
             if (!$column->getIsSystem()) {
                 $row[$column->getIndex()] = $order->getData($column->getIndex());
             }
         }
         $row['customers'] = 1;
         $row['title'] = round($row['sum_qty']);
         $this->_addCustomData($row);
     }
     //        var_dump( $this->_customData );
     if (!count($this->_customData)) {
         return $this;
     }
     usort($this->_customData, array(&$this, "_compareQtyElements"));
     Mage::helper('advancedreports')->setChartData($this->_customData, Mage::helper('advancedreports')->getDataKey($this->_routeOption));
     parent::_prepareData();
     return $this;
 }