Пример #1
0
 public function sendEmail($tpl, $secondUser = '', $invoiceID = '')
 {
     $templater = new Templater();
     $templater->user = $this;
     if ($secondUser != '') {
         $templater->member = $secondUser;
     }
     if ($invoiceID != '') {
         $order = new DatabaseObject_Order($this->_db);
         if ($order->loadOrderByUrl($invoiceID)) {
             if ($order->promotion_code == '') {
                 $templater->addPromo = 'true';
             } else {
                 $templater->promoCode = $order->promotion_code;
                 $templater->discount = $order->total_after_p - $order->total_before_p;
                 $templater->finalTotal = $order->total_after_p;
             }
             //echo "promotion code: ";
             $orderProfile = new Profile_Order($this->_db);
             $result = $orderProfile->loadProifleByOrderID($order->getId());
             if ($order->buyer_id > 30000000) {
                 $member = new DatabaseObject_Guest($this->_db);
                 $member->loadByID($order->buyer_id - 30000000);
                 $templater->guest = 'true';
             } else {
                 $member = new DatabaseObject_User($this->_db);
                 if ($type == 'buyer') {
                     $member->loadByUserId($order->user_id);
                     ////echo "here at odertype buyer";
                 }
             }
             echo "order status: " . $order->url . "<br/>";
             echo "count of order in that order: " . count($result) . "<br/>";
             echo $result[0]['profile_id'];
             echo $result[0]['product_name'];
             $templater->member = $member;
             $productProfile = array();
             foreach ($result as $k => $v) {
                 //echo "<br/>here0<br/>";
                 $productProfile[$result[$k]['profile_id']] = new Profile_Order($this->_db);
                 $productProfile[$result[$k]['profile_id']]->loadOrder($result[$k]['profile_id'], $order->url);
                 //echo "<br/>heels are for profile_id: ".$result[$k]['profile_id']." and heels are: ".$productProfileArray[$result[$k]['profile_id']]->orderAttribute->heel."<br/>";
                 //echo "<br/>name: ".$productProfileArray[1]->product_name;
             }
             $templater->productsProfile = $productProfile;
             $templater->invoice = $invoiceID;
             $templater->dateTime = date(date("F j, Y, g:i a"), $order->ts_created);
             $templater->finalTotal = $order->total_after_p;
             //////////////////////////////////////////////////////////////////////////////////
             /*
             					$this->orderShoppingCart = new DatabaseObject_Order($this->_db);
             					
             					$this->orderCartObject=$this->orderShoppingCart->loadOrderByUrl($invoiceID);
             					
             					if($this->orderShoppingCart->promotion_code == '')
             					{
             						$templater->addPromo = 'true';
             						$templater->total = $this->orderShoppingCart->total_before_p;
             	
             					}
             					else
             					{
             						$templater->promoCode = $this->orderShoppingCart->promotion_code;
             						$templater->total = $this->orderShoppingCart->total_before_p;
             						$templater->discount = $this->orderShoppingCart->total_after_p-$this->orderShoppingCart->total_before_p;
             						$templater->finalTotal = $this->orderShoppingCart->total_after_p;
             					}
             					
             					
             					$product = $this->orderCartObject;
             					
             					echo "count product: ".count($product);
             					$templater->shoppingCart = $this->orderShoppingCart;
             					$templater->dateTime= date(date("F j, Y, g:i a"), $this->orderShoppingCart->ts_created);
             					$templater->products = $product;
             					
             					
             					$productProfile=array();
             					
             					foreach($product as $k => $v)
             					{
             						echo $product[$k]->getId();
             						
             						$productProfile[$product[$k]['profile_id']] = new Profile_Order($this->db);
             						
             						$productProfile[$product[$k]['profile_id']]->loadOrder($product[$k]['profile_id'], $order->url);
             						
             						
             						
             															
             					}
             				
             					$templater->productsProfile=$productProfile;*/
         }
     }
     //fetch teh e-amil body
     $body = $templater->render('email/' . $tpl);
     //extract the subject from the first line
     list($subject, $body) = preg_split('/\\r|\\n/', $body, 2);
     //now set up and send teh email
     echo "here at mail" . "<br/>";
     $mail = new Zend_Mail();
     //set the to address and the user's full name in the 'to' line
     echo "the email sent out is: " . $this->email . "<br />";
     $mail->addTo($this->email, trim($this->first_name . ' ' . $this->last_name));
     //get the admin 'from details form teh config
     $mail->setFrom('*****@*****.**', 've-no-reply');
     //set the subject and boy and send the mail
     $mail->setSubject(trim($subject));
     $mail->setBodyText(trim($body));
     $mail->send();
 }
 public function orderconfirmedAction()
 {
     $request = $this->getRequest();
     $orderId = $request->getParam('orderId');
     $shoppingCart = new DatabaseObject_ShoppingCart($this->db);
     $shoppingCart->loadCartOnly($orderId);
     $shoppingCart->loadCartProducts();
     Zend_Debug::dump($shoppingCart->products);
     $buyer = new DatabaseObject_User($this->db);
     $buyer->load($shoppingCart->buyer_id);
     $buyerBalanceAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $buyer);
     $danceRialto = new DatabaseObject_User($this->db);
     //that is the id of DanceRialto Admin
     $danceRialto->load(1);
     $danceRialtoAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $danceRialto);
     //DanceRialto load;
     $confirmedOrder = new DatabaseObject_Order($this->db);
     $confirmedOrder->order_unique_id = $shoppingCart->order_unique_id;
     $confirmedOrder->buyer_username = $shoppingCart->buyer_username;
     $confirmedOrder->buyer_id = $shoppingCart->buyer_id;
     $confirmedOrder->buyer_email = $shoppingCart->buyer_email;
     $confirmedOrder->buyer_name = $shoppingCart->buyer_name;
     $confirmedOrder->total_number_items = $shoppingCart->total_number_items;
     $confirmedOrder->reward_points_awarded = $shoppingCart->reward_points_awarded;
     $confirmedOrder->cart_costs = $shoppingCart->cart_costs;
     $confirmedOrder->total_costs = $shoppingCart->total_costs;
     $confirmedOrder->total_shipping_costs = $shoppingCart->total_shipping_costs;
     $confirmedOrder->reward_points_used = $shoppingCart->reward_points_used;
     $confirmedOrder->reward_amount_deducted = $shoppingCart->reward_amount_deducted;
     $confirmedOrder->promotion_code_used = $shoppingCart->promotion_code_used;
     $confirmedOrder->promotion_amount_deducted = $shoppingCart->promotion_amount_deducted;
     $confirmedOrder->final_total_costs = $shoppingCart->final_total_costs;
     $confirmedOrder->order_shipping_id = $shoppingCart->order_shipping_id;
     if ($confirmedOrder->save()) {
         //upate reward points for buyer
         if ($confirmedOrder->reward_points_used > 0) {
             $buyerBalanceAccountProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_DEDUCTION', $confirmedOrder->reward_points_used, 'from_order_id', $confirmedOrder->order_unique_id, 'Reward points used for the purchase of order id: ' . $confirmedOrder->order_unique_id);
         }
     }
     foreach ($shoppingCart->products as $k => $v) {
         $orderProfile = new DatabaseObject_OrderProfile($this->db);
         foreach ($v as $key => $value) {
             if ($key != 'profile' && $key != 'ts_created') {
                 echo 'key is: ' . $key . ' value is:' . $value . '<br />';
                 $orderProfile->{$key} = $value;
             } elseif ($key == 'profile') {
                 foreach ($value as $attributeKey => $attributeValue) {
                     //$productProfile->profile->$attributeKey = $attributeValue;
                     $orderProfile->profile->{$attributeValue}['profile_key'] = $attributeValue['profile_value'];
                     echo "attribute key is: " . $attributeValue['profile_key'] . ' ';
                     echo "attribute value is: " . $attributeValue['profile_value'] . '<br />';
                 }
             }
         }
         $orderProfile->dr_receivable = $orderProfile->product_price * 0.15;
         $orderProfile->order_id = $confirmedOrder->getId();
         if ($orderProfile->save()) {
             //****update reward points for buyer
             if ($orderProfile->reward_points_awarded > 0) {
                 $buyerBalanceAccountProcessor->updatePendingRewardPointsAndBalanceForUser('REWARD_ADDITION', $orderProfile->reward_points_awarded, 'from_order_profile_id', $orderProfile->getId(), 'Reward points awarded for the purchase of ' . $orderProfile->product_name . ' in order Id: ' . $confirmedOrder->order_unique_id);
             }
             //****update seller account balance
             $seller = new DatabaseObject_User($this->db);
             $seller->load($orderProfile->uploader_id);
             echo 'orderProfile uploader_id is: ' . $seller->getId();
             //Zend_Debug::dump($seller);
             $sellerBalanceAccountProcessor = new AccountBalanceAndRewardPointProcessor($this->db, $seller);
             echo 'account processor user: '******'BALANCE_ADDITION', $orderProfile->seller_receivable, 'from_order_profile_id', $orderProfile->getId(), 'Balance addition from the sale of ' . $orderProfile->product_name . ' in order Id: ' . $orderProfile->order_unique_id);
             //update balance for DR.
             $danceRialtoAccountProcessor->updatePendingRewardPointsAndBalanceForUser('BALANCE_ADDITION', $orderProfile->dr_receivable, 'from_order_profile_id', $orderProfile->getId(), 'Balance addition from the sale of ' . $orderProfile->product_name . ' in order Id: ' . $orderProfile->order_unique_id);
         }
         $orderProfileStatusAndDelivery = new DatabaseObject_OrderProfileStatusAndDelivery($this->db);
         $orderProfileStatusAndDelivery->order_profile_id = $orderProfile->getId();
         $orderProfileStatusAndDelivery->save();
     }
     //now at deleting the shopping cart after completion.
     foreach ($shoppingCart->products as $k => $v) {
         $shoppingCartProfile = new DatabaseObject_ShoppingCartProfile($this->db);
         $shoppingCartProfile->load($k);
         $shoppingCartProfile->delete();
     }
     //echo 'shoppingcart->rewardPointsUsed: '.$shoppingCart->reward_points_used;
     //$rewardPoints = 0-$shoppingCart->reward_points_used;
     //echo'shopping cart reward point is: '.$rewardPoints.'<br />';
     //DatabaseObject_Helper_UserManager::addRewardPointToUser($this->db, $this->signedInUserSessionInfoHolder->generalInfo->referee_id, $rewardPoints, "Reward points used for the purchase of order: $confirmedOrder->order_unique_id", $_SERVER['REMOTE_ADDR'], $this->signedInUserSessionInfoHolder->generalInfo->username, $this->signedInUserSessionInfoHolder->generalInfo->userID, $this->signedInUserSessionInfoHolder->generalInfo->referee_id);
     $shoppingCart->delete();
 }
Пример #3
0
 public static function retrieveOrderSummaryForUser($db, $user_id, $params = array())
 {
     $orderArray = array();
     $select = $db->select();
     $select->from('orders', '*')->where('buyer_id = ?', $user_id)->order('ts_created DESC');
     //echo $select;
     $idArray = $db->fetchAll($select);
     foreach ($idArray as $k => $v) {
         $select2 = $db->select();
         $select2->from(array('o' => 'order_profile'), '*')->where('o.order_id = ?', $v['order_id'])->join(array('s' => 'order_profile_status_and_delivery'), 's.order_profile_id = o.order_profile_id');
         $orderProfiles = $db->fetchAll($select2);
         foreach ($orderProfiles as $key => $value) {
             $select3 = $db->select();
             $select3->from(array('pa' => 'order_profile_attribute'), '*')->where('pa.order_profile_attribute_id = ? ', $value['order_profile_attribute_id']);
             $orderProfiles[$key]['attributes'] = $db->fetchAll($select3);
         }
         $orderArray[$v['order_unique_id']] = $orderProfiles;
         $messageThreads = array();
         foreach ($order->products as $k => $v) {
             $MessageSelect = $db->select();
             $MessageSelect->from('sender_message', '*')->where('sender_subject = ? ', 'orderID: ' . $order->order_unique_id)->where('product_id = ?', $v['product_id'])->where('product_type_seller = ?', $v['product_market'])->order('ts_created DESC');
             //echo $MessageSelect.'<br />';
             $productMessageThreads = $db->fetchAll($MessageSelect);
             if (count($productMessageThreads) > 0) {
                 $order->products[$k]['messageThreads'] = $productMessageThreads;
                 //Zend_Debug::dump($v['messageThreads']);
             }
         }
         $order = new DatabaseObject_Order($db);
         $order->load($v['order_id']);
         $order->loadOrderProducts();
         $orderArray[] = $order;
         //Zend_Debug::dump($order->products);
     }
     return $orderArray;
 }