public function freepurchaseAction() { $producturrency = new Admin_Model_DbTable_Countries(); $modelAuthor = new Publisher_Model_DbTable_Publishers(); $tempObj = new Model_DbTable_Checkout(); $creditHistoryObj = new User_Model_DbTable_Chistory(); $transactionHistoryObj = new User_Model_DbTable_Transactionhistory(); $this->modelBooks = new Publisher_Model_DbTable_Books(); $modelImage = new Publisher_Model_DbTable_BookImages(); $modelStore = new Admin_Model_DbTable_Countries(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $orderId = time(); $subscription_store = ""; $subscription_language = ""; $subscription_issues = ""; $formDataTransApproved = array("orderId" => $orderId, "transactionType" => $transactionType, "pan" => $pan, "purchaseAmount" => $purchaseAmount, "tranDateTime" => $tranDateTime, "responseCode" => $responseCode, "responseDescription" => $responseDescription, "orderStatus" => $orderStatus, "approvalCode" => $approvalCode, "approvalCode" => $approvalCode, "merchantTranId" => $merchantTranId, "orderDescription" => $orderDescription, "approvalCodeScr" => $approvalCodeScr, "currency" => $currency, "threeDsVerification" => $threeDsVerification); $inserted_id = $transactionHistoryObj->insert($formDataTransApproved); $tempData = $tempObj->fetchAll("order_id='" . $orderIdForPurchase . "'"); foreach ($tempData as $dataDet) { $productPriceInfo = $productPrice->getPriceByStoreId($dataDet['product_id'], $dataDet['store_id']); if ($dataDet['subscription_type'] == '' || $dataDet['subscription_type'] == '0') { if ($dataDet['group_id'] > 0) { $price = $productPriceInfo['group_price']; } else { $price = $productPriceInfo['price']; } } else { $price = $dataDet['subscription_price']; $subscription_store = $dataDet['subscription_store']; $subscription_language = $dataDet['subscription_language']; $subscription_issues = $dataDet['subscription_issues']; } if ($orderStatus == 'APPROVED') { $orderSt = 1; } else { $orderSt = 0; } $product_details = $this->modelBooks->fetchRow("id='" . $dataDet['product_id'] . "'"); $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']); if (!empty($getBrandInfo) && is_numeric($this->{$product_details}['title'])) { $titleBrand = $getBrandInfo['brand']; } else { $titleBrand = $product_details['title']; } if (!empty($product_details['parent_brand_id']) && $product_details['cat_id'] != '3') { $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"'); $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title); if (!empty($getParentBrandInfo)) { $titleBrand = $getParentBrandInfo['brand'] . " - " . $titleBrand; } } $getCurrencyName = $producturrency->getCurrencyCode($dataDet['store_id']); $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['author_id']); $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']); $tempDatInsert = array(); $tempDatInsert['userid'] = $dataDet['user_id']; $tempDatInsert['bookid'] = $dataDet['product_id']; $tempDatInsert['store_id'] = $dataDet['store_id']; $tempDatInsert['price'] = $price; $tempDatInsert['userid'] = $dataDet['user_id']; $tempDatInsert['quantity'] = $dataDet['quntity']; $tempDatInsert['book_name'] = $titleBrand; $tempDatInsert['transaction_id'] = $inserted_id; $tempDatInsert['add_date'] = date('Y-m-d H:i:s'); $tempDatInsert['group_id'] = $dataDet['group_id']; $tempDatInsert['order_id'] = $dataDet['order_id']; $tempDatInsert['payment_status'] = $orderSt; $tempDatInsert['subscription_type'] = $dataDet['subscription_type']; $tempDatInsert['subscription_name'] = $dataDet['subscription_name']; $tempDatInsert['subscription_store'] = $dataDet['subscription_store']; $tempDatInsert['subscription_language'] = $dataDet['subscription_language']; $tempDatInsert['subscription_issues'] = $dataDet['subscription_issues']; $creditHistoryObj->insert($tempDatInsert); $total_price = $total_price + $dataDet['quntity'] * $price; $todaysdate = date('Y-m-d H:i:s'); if ($dataDet['subscription_name'] == 'Weekly') { $date = new DateTime($todaysdate); $date->modify("+7 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Monthly') { $date = new DateTime($todaysdate); $date->modify("+30 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Quarterly') { $date = new DateTime($todaysdate); $date->modify("+90 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Half Yearly') { $date = new DateTime($todaysdate); $date->modify("+182 day"); $end_date = $date->format("Y-m-d H:i:s"); } else { if ($dataDet['subscription_name'] == 'Yearly') { $date = new DateTime($todaysdate); $date->modify("+365 day"); $end_date = $date->format("Y-m-d H:i:s"); } } } } } $subscriptionObj = array(); $subscriptionObj['order_id'] = $orderid; $subscriptionObj['product_id'] = $dataDet['product_id']; $subscriptionObj['group_id'] = $dataDet['group_id']; $subscriptionObj['user_id'] = ''; $subscriptionObj['subscription_type'] = $dataDet['subscription_type']; $subscriptionObj['subscription_name'] = $dataDet['subscription_name']; $subscriptionObj['subscription_price'] = $price; $subscriptionObj['country'] = $dataDet['subscription_store']; $subscriptionObj['language'] = $dataDet['subscription_language']; $subscriptionObj['number_of_issues'] = $dataDet['subscription_issues']; $subscriptionObj['start_date'] = date('Y-m-d H:i:s'); $subscriptionObj['end_date'] = $end_date; $subscriptionObj['remaining_downloads'] = $dataDet['subscription_issues']; $subscriptionObj['publication_id'] = $product_details['parent_brand_id']; $UsersubObj->insert($subscriptionObj); } $tempObj->delete('order_id="' . $orderIdForPurchase . '"'); $this->_redirect('/checkout/displayorder/orderid/' . $orderIdForPurchase); //exit; }
public function expordetailsreportxlsAction() { $modelCategory = new Publisher_Model_DbTable_Books(); $producturrency = new Admin_Model_DbTable_Countries(); $productPrice = new Publisher_Model_DbTable_BookPrices(); $separator = ","; $publication = $this->_request->getParam('publication'); $request_list = $this->modelBooks->gerDetailsReportsById($publication); 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> <th>Total Purchase</th> <th>Unit Price</th> <th>Total Amount</th> <th>Last Purchased</th> </tr>'; foreach ($request_list as $req) { //$req['country']; //$countryName = $this->modelUsers->getCountryInfo($req['country']); $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 = $titleBrand . ' (' . $getParentBrandInfo['brand'] . ')'; } } $title = stripslashes($titleBrand); $catInfo = $modelCategory->getCategoryInfo($req['cat_id']); $productPriceInfo = $productPrice->getPriceByStoreId($req['id'], $req['store_id']); $publiseherDetails = $this->modelPublisher->getInfoByPublisherId($req['publisher_id']); $publisherName = $publiseherDetails['publisher']; $totalDownLoad = $req['no_download']; $publication_id = $req['id']; $price = $req['price']; $quantity = $req['quantity']; $category_name = $catInfo['category_name']; $totalPurchase = $req['best_seller']; $currency = $producturrency->getCurrencyInfo($req['store_id']); $currencyN = $producturrency->getCurrencyInfo(226); if ($req['group_id'] != 0) { $price = $productPriceInfo['group_price']; } else { $price = $productPriceInfo['group_price']; } $getCurrencyName = $producturrency->getCurrencyCode($req['store_id']); $tot = $req['quantity'] * $req['price']; $totNairaPrice = $producturrency->currencyconverter($getCurrencyName, "NGN", $tot); $content .= '<tr> <td>' . $publication_id . '</td> <td>' . $title . '</td> <th>' . $category_name . '</th> <td>' . $publisherName . '</td> <td>' . $totalDownLoad . '</td> <td>' . $quantity . '</td> <td>' . $currency . $price . '</td> <td>' . $currencyN . $totNairaPrice . '</td> <td>' . $req['add_date'] . '</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="8" class="list-not-found">Data Not Found</td></tr>'; } $content .= '</table>'; $file = "report"; $filename = $file . "_" . time() . ".xls"; $test = $content; header("Content-type: application/vnd.ms-excel"); header("Content-Disposition: attachment; filename={$filename}"); echo $test; exit; }