public function exportfreereportxlsAction() { $category = $this->_request->getParam('category'); $brand = $this->_request->getParam('brand'); $productid = $this->_request->getParam('productid'); $frmdate = $this->_request->getParam('frmdate'); $todate = $this->_request->getParam('todate'); $publisher_id = $this->_request->getParam('publisher'); $modelCategory = new Publisher_Model_DbTable_Books(); $brand_exp = explode("**", $brand); $request_list = $this->modelBooks->getProductReport($category, $brand_exp[0], $productid, $frmdate, $todate, $publisher_id); $request_list = $this->modelBooks->getProductFreeReport($category, $brand_exp[0], $productid, $frmdate, $todate, $publisher_id); $separator = ","; // separate column in csv if (count($request_list) > 0) { $csv_output = ""; //$csv_output.="First Name".$separator."Last Name".$separator."User Name".$separator."Country".$separator."Email".$separator."Phone\n"; $content = '<table class="table-list" cellpadding="0" cellspacing="0" width="100%"> <tr> <th>Publication Id</th> <th>Title / Brand</th> <th>Category</th> <th>Publisher</th> <th>Total Downloads</th> </tr>'; foreach ($request_list as $req) { $getBrandInfo = $modelCategory->getBrandInfo($req['title']); if (!empty($getBrandInfo)) { $titleBrand = $getBrandInfo['brand']; } else { $titleBrand = $req['title']; } if (!empty($row->parent_brand_id)) { $productInfo = $this->modelPublications->fetchRow('id=' . $req['parent_brand_id']); $getParentBrandInfo = $modelCategory->getBrandInfo($productInfo->title); if (!empty($getParentBrandInfo)) { $titleBrand = $getParentBrandInfo['brand'] . " - " . $titleBrand; } } $title = stripslashes($titleBrand); $catInfo = $modelCategory->getCategoryInfo($req['cat_id']); $publiseherDetails = $this->modelPublisher->getInfoByPublisherId($req['publisher_id']); $publisherName = $publiseherDetails['publisher']; $totalDownLoad = $req['no_download']; $publication_id = $req['id']; $price = $req['price']; $quantity = $req['total_count']; $category_name = $catInfo['category_name']; $totalPurchase = $req['best_seller']; $content .= '<tr> <td>' . $publication_id . '</td> <td>' . stripslashes($title) . '</td> <th>' . $category_name . '</th> <td>' . $publisherName . '</td> <td>' . $totalDownLoad . '</td> </tr>'; //$csv_output .= str_replace(",","",$req['first_name']).$separator.str_replace(",","",$req['last_name']).$separator.str_replace(",","",$req['user_name']).$separator.str_replace(",","",$countryName['country']).$separator.str_replace(",","",$req['user_email']).$separator.str_replace(",","",$req['phone'])."\n"; } } else { $content .= '<tr><td colspan="5" class="list-not-found">Data Not Found</td></tr>'; } $content .= '</table>'; $file = "freereport"; $filename = $file . "_" . time() . ".xls"; $test = $content; header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename={$filename}"); echo $test; exit; }