Exemplo n.º 1
0
 function csvexport()
 {
     $model = $this->getModel("vendor");
     $CSVData = $model->getCsvexportData();
     $filename = "SalesPerSellerReport_" . date("Y-m-d");
     $csvData = null;
     //$csvData.= "Item_id;Product Name;Store Name;Store Id;Sales Count;Amount;Created By;";
     $headColumn = array();
     $headColumn[0] = JText::_('COM_QUICK2CART_SALESPERSELLER_STORENAME');
     $headColumn[1] = JText::_('COM_QUICK2CART_SALESPERSELLER_VENDORNAME');
     // 'Product Name';
     $headColumn[2] = JText::_('COM_QUICK2CART_SALESPERSELLER_STATUS');
     $headColumn[3] = JText::_('COM_QUICK2CART_SALESPERSELLER_EMAIL');
     $headColumn[4] = JText::_('COM_QUICK2CART_SALESPERSELLER_PHONE');
     $headColumn[5] = JText::_('COM_QUICK2CART_SALESPERSELLER_SALE');
     $csvData .= implode(";", $headColumn);
     $csvData .= "\n";
     header("Content-type: application/vnd.ms-excel");
     header("Content-disposition: csv" . date("Y-m-d") . ".csv");
     header("Content-disposition: filename=" . $filename . ".csv");
     if (!empty($CSVData)) {
         $storeHelper = new storeHelper();
         foreach ($CSVData as $data) {
             $csvrow = array();
             $csvrow[0] = '"' . $data['title'] . '"';
             $csvrow[1] = '"' . $data['username'] . '"';
             if ($data['published'] == 1) {
                 $status = JText::_('COM_QUICK2CART_PUBLISH');
             } else {
                 $status = JText::_('COM_QUICK2CART_UNPUBLISH');
             }
             $csvrow[2] = '"' . $status . '"';
             $csvrow[3] = '"' . $data['store_email'] . '"';
             $csvrow[4] = '"' . $data['phone'] . '"';
             $storeHelper = new storeHelper();
             $comquick2cartHelper = new comquick2cartHelper();
             $total_sale = $storeHelper->getTotalSalePerStore($data['id']);
             if ($total_sale) {
                 $sale = $comquick2cartHelper->getFromattedPrice($total_sale);
             }
             $csvrow[5] = '"' . $sale . '"';
             $csvData .= implode(";", $csvrow);
             $csvData .= "\n";
         }
     }
     ob_clean();
     echo $csvData . "\n";
     jexit();
     $link = JUri::base() . substr(JRoute::_('index.php?option=com_quick2cart&view=vendor&layout=salespervendor', false), strlen(JUri::base(true)) + 1);
     $this->setRedirect($link);
 }