Пример #1
0
    function displayorderAction()
    {
        ##########################   data ###########################
        $orderIdForPurchase = $this->_getParam('orderid');
        $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();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        $modelImage = new Publisher_Model_DbTable_BookImages();
        $modelStore = new Admin_Model_DbTable_Countries();
        $productPrice = new Publisher_Model_DbTable_BookPrices();
        $modelSubscription = new Publisher_Model_DbTable_Subscriptions();
        $this->modelBooks = new Publisher_Model_DbTable_Books();
        $storage_company = new Zend_Auth_Storage_Session('company_type');
        $company_data = $storage_company->read();
        $storage = new Zend_Auth_Storage_Session('account_type');
        $data = $storage->read();
        if ($data->id) {
            $user_id = $data->id;
        } elseif ($company_data->id) {
            $user_id = $company_data->id;
        }
        if ($company_data->account_type == '1') {
            $groupObj = new Company_Model_DbTable_Groups();
            $groupList = $groupObj->getGroupList($company_data->id);
        }
        $datahistory = "<div class='top_heading'>\t\t\t\t\n\t\t    \t<div class='item'>Item(s)</div>\n\t\t        <div class='prices'>Subscription Type</div>\n\t\t        <div class='prices'>Price</div>";
        if ($company_data->account_type == '1') {
            $datahistory .= "<div class='quantity'>Qty</div>";
        } else {
            $datahistory .= "<div class='quantity'>&nbsp;</div>";
        }
        $datahistory .= "<div class='total'>Total</div>\n\t\t    </div>";
        $orderData = $creditHistoryObj->fetchAll("order_id='" . $orderIdForPurchase . "'");
        $dataDet = '';
        foreach ($orderData as $dataDet) {
            $price = $dataDet['price'];
            $subscription_data = $modelSubscription->fetchAll('id="' . $dataDet['subscription_type'] . '"');
            $product_details = $this->modelBooks->fetchRow("id='" . $dataDet['bookid'] . "'");
            $transaction_details = $transactionHistoryObj->fetchRow("id='" . $dataDet['transaction_id'] . "'");
            $catInfo = $this->modelBooks->getCategoryInfo($product_details['cat_id']);
            $getCurrencyName = $producturrency->getCurrencyCode($dataDet['store_id']);
            $authorInfo = $modelAuthor->getInfoByPublisherId($product_details['publisher_id']);
            $imageInfo = $modelImage->getImageInfoByProductId($product_details['id']);
            $total_price = $total_price + $producturrency->currencyconverter($getCurrencyName, "NGN", $dataDet['quantity'] * $price);
            if ($dataDet['payment_status'] == 1) {
                $orderStatus = 'Approved';
            } elseif ($dataDet['payment_status'] == 2) {
                $orderStatus = 'Declined';
            } else {
                $orderStatus = 'Pending';
            }
            if (count($subscription_data) > 0) {
                $subtype = $subscription_data[0]->subscription_type;
            } else {
                $subtype = "N/A";
            }
            $datahistory .= '<div class="cart_detail">
		    	<div class="item_content">
		   	    	<img src="' . $this->view->serverUrl() . $this->view->baseUrl() . '/' . USER_UPLOAD_DIR . 'thumb1_' . $imageInfo['image_name'] . '" width="140" height="175" alt="">
		            <h5>' . stripslashes($dataDet['book_name']) . '</h5>';
            if ($authorInfo['first_name'] != '') {
                $datahistory .= '<span><em>by: </em> ' . stripslashes($authorInfo['first_name'] . '&nbsp;' . $authorInfo['last_name']) . '</span>';
            }
            $datahistory .= '<span><em>Category: </em> ' . stripslashes($catInfo['category_name']) . '</span>
					<span><em>publisher:</em> ' . stripslashes($authorInfo['publisher']) . '</span>
		           </div>     
				  <div class="space_content"></div>
				<div class="prices_content">' . $subtype . '</div>
		        <div class="prices_content">&#x20a6;' . $producturrency->currencyconverter($getCurrencyName, "NGN", $price) . '</div>
		        <div style="float: left;padding: 5% 0;text-align: center;width: 70px;">
		        	<div class="">';
            if ($dataDet['group_id'] != 0) {
                $datahistory .= '<div >' . $dataDet['quantity'] . '</div>';
            }
            $datahistory .= '</div>
		        </div>
		        <div class="total_content">&#x20a6;' . @number_format($producturrency->currencyconverter($getCurrencyName, "NGN", $dataDet['quantity'] * $price), 2) . '</div>    
		 		</div>';
            if ($company_data->account_type == '1') {
                $finalsubprice = $finalsubprice + $dataDet['quantity'] * $price;
            } else {
                $finalsubprice = $finalsubprice + $price;
            }
        }
        $datahistory .= '<div class="shipping_total">
					<div class="row">
				    	<div class="lt">Subtotal</div>
				        <div class="rt">&#x20a6;' . @number_format($total_price, 2) . '</div>
				    </div>
				 		    
				    <div class="row" style="border:none;">
				    	<div class="lt">Tax</div>
				        <div class="rt">&#x20a6;' . '00.00</div>
				    </div>
				    
				    <div class="row subtotal">
				    	<div class="lt">Total</div>
				        <div class="rt">&#x20a6;' . @number_format($total_price, 2) . '</div>
				    </div>	
				      <div class="row subtotal">
				    	<div class="lt">Order Id</div>
				        <div class="rt">' . $orderIdForPurchase . '</div>
				    </div>
				      <div class="row subtotal">
				    	<div class="lt">Payment Status</div>
				        <div class="rt">' . $orderStatus . '</div>
				    </div>		   
				</div>';
        $this->view->datahistory = $datahistory;
        $this->view->orderId = $orderIdForPurchase;
        $this->view->transactionId = $orderData[0]['transaction_id'];
        $this->view->orderStatus = $orderStatus;
        $this->view->responseDescription = $transaction_details['responseDescription'];
    }
Пример #2
0
    public function activeAction()
    {
        $arrayids = array();
        $this->usersubscriptions = new Model_DbTable_Usersubscription();
        $this->userdetails = new Model_DbTable_Companies();
        $modelCategory = new Publisher_Model_DbTable_Books();
        $this->notifications = new Admin_Model_DbTable_Notifications();
        $modelImage = new Admin_Model_DbTable_ProductImages();
        $modelPrice = new Admin_Model_DbTable_ProductPrices();
        $creditHistoryObj = new User_Model_DbTable_Chistory();
        $this->modelBooks = new Publisher_Model_DbTable_Books();
        $notificationdata = $this->notifications->fetchAll('ntype="booksubscription" and status=1');
        $bookuploaddata = $this->notifications->fetchAll('ntype="bookupload" and status=1');
        $pid = $this->_request->getParam('pid', 0);
        $id = $this->_request->getParam('id', 0);
        $transactionHistoryObj = new User_Model_DbTable_Transactionhistory();
        if ($id > 0 && $this->modelPublications->isExist($id)) {
            $data['admin_approve'] = 1;
            $success = $this->modelPublications->update($data, 'id="' . $id . '"');
            if ($success) {
                $this->usersubscriptionsdata = $this->usersubscriptions->fetchAll('subscription_type >0
				 and publication_id=' . $pid . ' and start_date!="0000-00-00 00:00:00"');
                if (count($this->usersubscriptionsdata) > 0) {
                    if (count($bookuploaddata) > 0) {
                        foreach ($this->usersubscriptionsdata as $row_subdata) {
                            /*echo "publication id : - ".$pid;
                            		echo 'subscription_type >0
                            		AND number_of_issues > number_of_downloaded and product_id='.$id.' and user_id="'.$row_userids['id'].'"';
                            		die();*/
                            $product_details = $this->modelBooks->fetchRow("id='" . $id . "'");
                            $explode_product_addtime = @explode(" ", $product_details['add_time']);
                            $explode_start_date = @explode(" ", $row_subdata['start_date']);
                            $this->totalactivesubscription = $this->usersubscriptions->fetchAll('subscription_type >0
						 and publication_id=' . $pid . ' and user_id="' . $row_subdata['user_id'] . '" and start_date IS NULL');
                            $this->totalactivesubscription_with_startdate = $this->usersubscriptions->fetchAll('subscription_type >0
						AND number_of_issues > number_of_downloaded and publication_id=' . $pid . ' and user_id="' . $row_subdata['user_id'] . '" and start_date IS NOT NULL');
                            $totalactive = count($this->totalactivesubscription) + 1;
                            if ($this->totalactivesubscription_with_startdate[0]['number_of_issues'] > $totalactive && strtotime($product_details['add_time']) > strtotime($row_subdata['start_date'])) {
                                $this->userdata = $this->userdetails->fetchAll('id="' . $row_subdata['user_id'] . '" and status="1"');
                                $chk_subscription = $this->usersubscriptions->fetchAll('user_id="' . $row_subdata['user_id'] . '" and product_id="' . $id . '"');
                                if (count($chk_subscription) == 0) {
                                    $getBrandInfo = $this->modelBooks->getBrandInfo($product_details['title']);
                                    if (!empty($getBrandInfo) && is_numeric($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'];
                                        }
                                    }
                                    $productInfo = $this->modelBooks->fetchRow('id="' . $product_details['parent_brand_id'] . '"');
                                    $getParentBrandInfo = $this->modelBooks->getBrandInfo($productInfo->title);
                                    if (!empty($getParentBrandInfo)) {
                                        //$titleBrand=$titleBrand.' ('.$getParentBrandInfo['brand'].')';
                                        //$titleBrand=$getParentBrandInfo['brand']." - ".$titleBrand;
                                        $titleBrand = $getParentBrandInfo['brand'];
                                    }
                                    $tempDatInsert = array();
                                    $formDataTransApproved = array();
                                    $getdata = $transactionHistoryObj->fetchRow('orderId=' . $row_subdata['order_id'] . '');
                                    $tempDatInsert['userid'] = $row_subdata['user_id'];
                                    $tempDatInsert['bookid'] = $id;
                                    $tempDatInsert['store_id'] = '226';
                                    $tempDatInsert['price'] = $row_subdata['subscription_price'];
                                    $tempDatInsert['quantity'] = '1';
                                    $tempDatInsert['transaction_id'] = $getdata->id;
                                    $tempDatInsert['book_name'] = $titleBrand;
                                    $tempDatInsert['add_date'] = date('Y-m-d H:i:s');
                                    $tempDatInsert['group_id'] = $this->userdata[0]['group_id'];
                                    $tempDatInsert['order_id'] = $row_subdata['order_id'];
                                    $tempDatInsert['payment_status'] = '1';
                                    $tempDatInsert['converted_price'] = $row_subdata['subscription_price'];
                                    $tempDatInsert['subscription_type'] = $row_subdata['subscription_type'];
                                    $tempDatInsert['subscription_store'] = $row_subdata['country'];
                                    $tempDatInsert['subscription_language'] = $row_subdata['language'];
                                    $tempDatInsert['subscription_name'] = $row_subdata['subscription_name'];
                                    $creditHistoryObj->insert($tempDatInsert);
                                    $formDataTransApproved = array("orderId" => $row_subdata['order_id'], "transactionType" => $getdata->transactionType, "pan" => $getdata->pan, "purchaseAmount" => $getdata->purchaseAmount, "tranDateTime" => $getdata->tranDateTime, "responseCode" => $getdata->responseCode, "responseDescription" => $getdata->responseDescription, "orderStatus" => $getdata->orderStatus, "approvalCode" => $getdata->approvalCode, "merchantTranId" => $getdata->merchantTranId, "orderDescription" => $getdata->orderDescription, "approvalCodeScr" => $getdata->approvalCodeScr, "currency" => $getdata->currency, "brand" => $getdata->brand, "card_holder_name" => $getdata->card_holder_name, "ThreeDSStatus" => $getdata->ThreeDSStatus, "threeDsVerification" => $getdata->threeDsVerification, "transaction_xml" => $getdata->transaction_xml);
                                    $inserted_id = $transactionHistoryObj->insert($formDataTransApproved);
                                    $insert_user_sub_details_array = array("order_id" => $row_subdata['order_id'], "product_id" => $id, "publisher_id" => $row_subdata['publisher_id'], "author_id" => $row_subdata['author_id'], "group_id" => $this->userdata[0]['group_id'], "user_id" => $row_subdata['user_id'], "subscription_type" => $row_subdata['subscription_type'], "subscription_name" => $row_subdata['subscription_name'], "subscription_price" => $row_subdata['subscription_price'], "country" => $row_subdata['country'], "language" => $row_subdata['language'], "publication_id" => $row_subdata['publication_id'], "company_id" => $this->userdata[0]['parent_id'], "active_date" => date('Y-m-d H:i:s'));
                                    $this->usersubscriptions->insert($insert_user_sub_details_array);
                                    $sql1 = "update pclive_products set best_seller=best_seller+1 where id='" . $id . "'";
                                    $result1 = $this->modelBooks->getAdapter()->query($sql1);
                                }
                                $publicationdetails = $this->modelPublications->fetchAll('id=' . $id . '');
                                $product_price = $modelPrice->fetchAll('product_id="' . $id . '" and country_id=226 and language_id=1');
                                $getproductimage = $modelImage->fetchAll('product_id="' . $publicationdetails[0]['id'] . '"');
                                $publisher_info_array = $this->modelPublications->getPublisherInfo($publicationdetails[0]['publisher_id']);
                                $author_info_array = $this->modelPublications->getAuthorInfo($publicationdetails[0]['author_id']);
                                $getBrandInfo = $modelCategory->getBrandInfo($publicationdetails[0]['title']);
                                if (!empty($getBrandInfo)) {
                                    $titleBrand = $getBrandInfo['brand'];
                                } else {
                                    $titleBrand = $publicationdetails[0]['title'];
                                }
                                $fullname = $this->userdata[0]['first_name'] . ' ' . $this->userdata[0]['last_name'];
                                $description_full = stripslashes($bookuploaddata[0]['message_body']);
                                $description_full = nl2br($description_full);
                                $description = str_replace("{name}", $fullname, $description_full);
                                $description = str_replace("{title}", $titleBrand, $description);
                                if (count($this->usersubscriptionsdata) > 0) {
                                    $description = str_replace("{price}", "N/A", $description);
                                } else {
                                    if (isset($product_price[0]['price']) && $product_price[0]['price'] != '') {
                                        $description = str_replace("{price}", "&#8358;" . $product_price[0]['price'], $description);
                                    }
                                }
                                if (count($getproductimage) > 0) {
                                    $linkdata = 'http://miprojects2.com.php53-6.ord1-1.websitetestlink.com/projects/evendor/catalogue/detail/id/' . $publicationdetails[0]['id'] . '/store/226/lang/1';
                                } else {
                                    $linkdata = "javascript:void(0);";
                                }
                                $description = str_replace("{link}", $linkdata, $description);
                                if (count($getproductimage) > 0) {
                                    $imagedata = 'http://miprojects2.com.php53-6.ord1-1.websitetestlink.com/projects/evendor/public/uploads/users/' . $getproductimage[0]['image_name_thumb'] . '';
                                } else {
                                    $imagedata = "";
                                }
                                $description = str_replace("{image}", $imagedata, $description);
                                $publishername = $publisher_info_array['first_name'] . " " . $publisher_info_array['last_name'];
                                $authorname = $author_info_array['first_name'] . " " . $author_info_array['last_name'];
                                $description = str_replace("{publisher}", $publishername, $description);
                                $description = str_replace("{desc}", $publicationdetails[0]['description'], $description);
                                $description = str_replace("{author}", $authorname, $description);
                                $mailhost = SMTP_SERVER;
                                $mailconfig = array('ssl' => SMTP_SSL, 'port' => SMTP_PORT, 'auth' => SMTP_AUTH, 'username' => SMTP_USERNAME, 'password' => SMTP_PASSWORD);
                                $transport = new Zend_Mail_Transport_Smtp($mailhost, $mailconfig);
                                Zend_Mail::setDefaultTransport($transport);
                                $mail = new Zend_Mail();
                                $mail->addTo($this->userdata[0]['user_email']);
                                $mail->setSubject(stripslashes($bookuploaddata[0]['title']));
                                $mail->setBodyHtml($description);
                                $mail->setFrom(SETFROM, SETNAME);
                                //$mail->send();
                                /*$reg='APA91bEZVTcqtar_br_cipLae9TyYe26JhsE2jHHnV76K_zWSAAyly2ZW6SCd4-REMgY_lGtHLh-2VvObjlj-pRvHd2932KlKY7anEOKQMyviVLs1A1Y7RYDPNtXwuRqTY7rILdF_LcXvY4GntxKouBU1EUv8E1mCQ';
                                
                                						$title = str_replace("_"," ",$title);
                                						$regID = array($reg);
                                						// $message="You have registerted successfully";
                                						$message = array("userID" =>$row_userids['id'],"msg" =>$bookuploaddata[0]['title']." is ready to download","email" =>$row_userids['user_email']);
                                						send_push_notification($regID, $message);*/
                                if (isset($publicationdetails[0]['file_name']) && $publicationdetails[0]['file_name'] != '' && count($getproductimage) > 0 && count($product_price) > 0) {
                                    $get_registeration_id = mysql_query("select * from pclive_deviceID where user_publisher_id='" . $this->userdata[0]['id'] . "' and reg_id!=''");
                                    $res_registeration_id = mysql_fetch_array($get_registeration_id);
                                    $reg = $res_registeration_id['reg_id'];
                                    $regID = array($reg);
                                    // $message="You have registerted successfully";
                                    $message = array("userID" => $this->userdata[0]['id'], "msg" => "publication is ready to download", "email" => $this->userdata[0]['user_email']);
                                    if ($res_registration_id['os_type'] == 0) {
                                        send_push_notification($regID, $message);
                                    } else {
                                        send_push_notification_ios($regID, $row_userids['user_email'], $this->userdata[0]['id'], "publication is ready to download");
                                    }
                                }
                            }
                        }
                    }
                }
                $this->_flashMessenger->addMessage('<div class="div-success">Product activated successfully</div>');
            } else {
                $this->_flashMessenger->addMessage('<div class="div-error">Sorry!, unable to activate product</div>');
            }
        }
        $this->_redirect('admin/publications/');
    }