Example #1
0
 protected function _getProgressBarHtml(Varien_Object $row)
 {
     $percent = $row->getSaved() / $row->getTotal() * 100;
     if ($percent >= 100) {
         $percent = 100;
         $message = $row->getStatus();
     } else {
         $message = $this->__('%s of %s messages processed', $row->getSaved(), $row->getTotal());
     }
     return '
         <div id="progress_bar">
             <div class="status" style="width: ' . (int) $percent . '%;height:100%;"></div>
             <p>' . $message . '</p>
         </div>';
 }
Example #2
0
 /**
  * get csv data from grid
  * @return string
  * 
  */
 public function getCsv()
 {
     $csv = '';
     $this->_isExport = true;
     /*$this->_prepareGrid();*/
     $this->getCollection()->getSelect()->limit();
     $this->getCollection()->setPageSize(0);
     $this->getCollection()->load();
     //$this->_afterLoadCollection();
     $group_by = $this->getRequest()->getParam('group_by');
     if ($group_by == 1) {
         $this->addColumn('created_date', array('index' => 'created_date'));
         $this->addColumn('banner_title', array('index' => 'banner_title'));
     } else {
         if ($group_by == 2) {
             $this->addColumn('banner_title', array('index' => 'banner_title'));
             $this->addColumn('created_date', array('index' => 'created_date'));
         } else {
             if ($group_by == 3) {
                 $this->addColumn('referer', array('index' => 'referer'));
                 $this->addColumn('created_date', array('index' => 'created_date'));
                 $this->addColumn('banner_title', array('index' => 'banner_title'));
             }
         }
     }
     $this->addColumn('landing_page', array('index' => 'landing_page'));
     if ($group_by != 3) {
         $this->addColumn('referer', array('index' => 'referer'));
     }
     $this->addColumn('uniques', array('index' => 'is_unique'));
     $this->addColumn('raws', array('index' => 'totals'));
     Mage::dispatchEvent('affiliateplusstatistic_export_impression_addrow_tocsv', array('block' => $this));
     $data = array();
     foreach ($this->_columns as $id => $column) {
         $data[] = '"' . $id . '"';
     }
     $csv .= implode(',', $data) . "\n";
     foreach ($this->getCollection() as $item) {
         $data = array();
         foreach ($this->_columns as $column) {
             if ($column['index'] == 'commission') {
                 $data[] = '"' . str_replace(array('"', '\\', chr(13), chr(10)), array('""', '\\\\', '', '\\n'), $this->getCommissionOfRow($item)) . '"';
             } else {
                 $data[] = '"' . str_replace(array('"', '\\', chr(13), chr(10)), array('""', '\\\\', '', '\\n'), $item->getData($column['index'])) . '"';
             }
         }
         $csv .= implode(',', $data) . "\n";
     }
     //die('2');
     $totals = $this->getTotals();
     $data = array();
     if ($group_by == 1) {
         $totalObject['created_date'] = 'Total';
         $totalObject['banner_title'] = '';
         $totalObject['referer'] = '';
     } else {
         if ($group_by == 2) {
             $totalObject['created_date'] = '';
             $totalObject['banner_title'] = 'Total';
             $totalObject['referer'] = '';
         } else {
             if ($group_by == 3) {
                 $totalObject['created_date'] = '';
                 $totalObject['banner_title'] = '';
                 $totalObject['referer'] = 'Total';
             }
         }
     }
     $totalObject['landing_page'] = '';
     //$totalObject['referer'] = '';
     $totalObject['is_unique'] = $totals['uniques'];
     $totalObject['totals'] = $totals['raws'];
     $obj = new Varien_Object(array('total' => $totalObject));
     Mage::dispatchEvent('affiliateplusstatistic_export_impression_addtotal_tocsv', array('object' => $obj));
     $totalObject = $obj->getTotal();
     foreach ($this->_columns as $id => $column) {
         if ($column['index'] == 'commission') {
             $data[] = '"' . str_replace(array('"', '\\', chr(13), chr(10)), array('""', '\\\\', '', '\\n'), $totalObject[$column['index']]) . '"';
         } else {
             $data[] = '"' . str_replace(array('"', '\\', chr(13), chr(10)), array('""', '\\\\', '', '\\n'), $totalObject[$column['index']]) . '"';
         }
     }
     $csv .= implode(',', $data) . "\n";
     return $csv;
 }