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 freereportAction() { $publisher_user = new Publisher_Model_DbTable_Publishers(); $params = $this->getRequest()->getParams(); $category = $this->_request->getParam('category'); $brand = $this->_request->getParam('brand'); $productid = $this->_request->getParam('product_id'); $frmdate = $this->_request->getParam('frmdate'); $todate = $this->_request->getParam('todate'); $publisher_id = $this->_request->getParam('publisher'); $publisher_user_data = $publisher_user->fetchAll("user_type='publisher' and publisher!=''"); $brand_exp = explode("**", $brand); if ($this->getRequest()->isPost()) { $productData = $this->modelBooks->getProductFreeReport($category, $brand_exp[0], $productid, $frmdate, $todate, $publisher_id); } else { $productData = $this->modelBooks->getProductFreeReport($category, $brand_exp[0], $productid, $frmdate, $todate, $publisher_id); } $formData['category'] = $category; $formData['brand'] = $brand; $formData['product_id'] = $productid; $formData['from_date'] = $frmdate; $formData['to_date'] = $todate; $formData['publisher'] = $publisher_id; $this->view->prodList = $productData; $page = $this->_getParam('page', 1); $paginator = Zend_Paginator::factory($productData); $paginator->setItemCountPerPage(10); $paginator->setCurrentPageNumber($page); $this->view->totalCount = count($productData); $this->view->pageSize = 10; $this->view->page = $page; $this->view->prodList = $paginator; $this->view->publisher_data = $publisher_user_data; $this->view->formData = $formData; }