Esempio n. 1
0
 public function orderDetailsAction()
 {
     $request = $this->getRequest();
     $order_id = $request->getParam("id");
     $ordersMapper = new Application_Model_OrdersMapper();
     $orderItemsMapper = new Application_Model_OrderItemsMapper();
     $order = $ordersMapper->getOrderById($order_id);
     $this->view->order = $order;
     $items = $orderItemsMapper->getOrderItemByOrderId($order_id);
     $this->view->items = $items;
 }
Esempio n. 2
0
 public function checkoutAction()
 {
     $user_id = 0;
     if ($this->_auth->hasIdentity()) {
         $user_id = $this->_auth->getIdentity()->user_id;
         $this->view->user_id = $user_id;
     }
     $errors = array();
     $request = $this->getRequest();
     //$delivery_type = $request->getParam("delivery_type");
     //$service_name = $request->getParam("service_name");
     //$pickup_date = $request->getParam("pickup_date");
     //$pickup_time = $request->getParam("pickup_time");
     //$delivery_date = $request->getParam("del_date");
     //$delivery_time = $request->getParam("del_time");
     $date_session = new Zend_Session_Namespace("date");
     //print_r($_SESSION);exit;
     $pickup_date = $date_session->pick_date;
     $pickup_time = $date_session->pick_time;
     $delivery_date = $date_session->del_date;
     $delivery_time = $date_session->del_time;
     $service_name = $date_session->service_id;
     $delivery_type = $date_session->del_name;
     $user_package_id = $request->getParam("user_package_id");
     $this->view->user_package_id = $user_package_id;
     //$this->view->del_name = $delivery_type;
     //$this->view->service_id = $service_name;
     //$this->view->date = $pickup_date;
     //$this->view->time = $pickup_time;
     //$this->view->del_time = $delivery_time;
     //$this->view->del_date = $delivery_date;
     $request_type = $request->getParam("request_type", false);
     $addressMapper = new Application_Model_SavedAddressesMapper();
     $usersWalletMapper = new Application_Model_UserWalletMapper();
     $userWallet = new Application_Model_UserWallet();
     $payment_type = $request->getParam("payment_type");
     if ($user_id) {
         $credit_amount = $usersWalletMapper->getUserWalletCreditByUserId($user_id);
         $debit_amount = $usersWalletMapper->getUserWalletDebitByUserId($user_id);
         $wallet_amount = $credit_amount - $debit_amount;
         $wallet_session = new Zend_Session_Namespace("wallet");
         $wallet_session->amount = $wallet_amount;
         $this->view->wallet_amount = $wallet_amount;
         $userPackagesMapper = new Application_Model_UserPackagesMapper();
         $userPackages = $userPackagesMapper->getUserPackageByUserId($user_id);
         $this->view->userPackages = $userPackages;
     }
     if ($request_type) {
         if ($request_type == "item_details") {
             $session_quantity = $request->getParam("qty");
             $session_price = $request->getParam("price");
             $session_items = $request->getParam("items");
             //print_r($session_items);exit;
             $session = new Zend_Session_Namespace("order");
             //print_r($session_quantity);
             $total = 0;
             $i = 0;
             $quantity_total = 0;
             $actual_items = array();
             $actual_qty = array();
             $actual_price = array();
             foreach ($session_items as $item) {
                 $item_id = $item;
                 $qty = $session_quantity[$i];
                 $new_price = $session_price[$i];
                 if ($qty != 0) {
                     $actual_items[] = $item_id;
                     $actual_qty[] = $qty;
                     $actual_price[] = $new_price;
                 }
                 $item_total = $qty * $new_price;
                 $total += $item_total;
                 $quantity_total += $qty;
                 $i++;
             }
             $session->quantity = $actual_qty;
             $session->price = $actual_price;
             $session->items = $actual_items;
             $session->total = $total;
             $session->quantity_total = $quantity_total;
             //print_r($actual_items);exit;
             //print_r($actual_qty);exit;
             //$this->view->actual_qty = $actual_qty;
             //$this->view->actual_items = $actual_items;
             //print_r($_SESSION);
             //exit;
         } elseif ($request_type == "payment_type") {
             $ordersMapper = new Application_Model_OrdersMapper();
             $orders = new Application_Model_Orders();
             $orderItemsMapper = new Application_Model_OrderItemsMapper();
             $orderItems = new Application_Model_OrderItems();
             $savedAddressMapper = new Application_Model_SavedAddressesMapper();
             $session = new Zend_Session_Namespace("order");
             $quantity = $session->quantity;
             $price = $session->price;
             $items = $session->items;
             //print_r($items);exit;
             $i = 0;
             if (empty($payment_type)) {
                 $errors[] = "Select a Payment Type";
             }
             if (count($errors) == 0) {
                 $add_session = new Zend_Session_Namespace("address");
                 $user_name = $add_session->username;
                 $pincode = $add_session->pincode;
                 $landmark = $add_session->landmark;
                 $city = $add_session->city;
                 $address = $add_session->address;
                 $state = $add_session->state;
                 $number = $add_session->phone;
                 $guest_email = $add_session->email;
                 $revised_amount = $request->getParam("revised_amount");
                 $discount_amount = $request->getParam("discount_amount");
                 //$number = $saved->__get("contact_person_phn");
                 //$address = $saved->__get("saved_address");
                 //$locality = $saved->__get("address_locality");
                 //$landmark = $saved->__get("address_landmark");
                 //$city = $saved->__get("address_city");
                 //$state- = $saved->__get("address_state");
                 //$pincode = $saved->__get("address_pincode");
                 //$country = $saved->__get("address_country");
                 if ($user_id) {
                     $usersMapper = new Application_Model_UsersMapper();
                     $user = $usersMapper->getUserById($user_id);
                     $fname = $user->__get("user_fname");
                     $lname = $user->__get("user_lname");
                     $user_email = $user->__get("user_email");
                     $number = $user->__get("user_number");
                     $orders->__set("user_fname", $fname);
                     $orders->__set("user_lname", $lname);
                     $orders->__set("user_email", $user_email);
                     $orders->__set("user_phn_number", $number);
                     $orders->__set("user_address", $address);
                     $orders->__set("address_locality", "");
                     $orders->__set("address_street", "");
                     $orders->__set("address_landmark", $landmark);
                     $orders->__set("address_city", $city);
                     $orders->__set("address_state", $state);
                     $orders->__set("address_country", "India");
                     $orders->__set("address_pincode", $pincode);
                     $orders->__set("payment_method", $payment_type);
                     $orders->__set("payment_status", "Unpaid");
                     $orders->__set("order_status", "New");
                     $orders->__set("order_total", 0);
                     $orders->__set("delivery_type", $delivery_type);
                     $orders->__set("service", $service_name);
                     //echo $pickup_date;exit;
                     $zend_date = new Zend_Date($pickup_date, "dd/MM/yyyy");
                     $pickup_date_new = $zend_date->toString("dd-MMM-yyyy");
                     $orders->__set("pickup_date", $pickup_date_new);
                     $orders->__set("pickup_time", $pickup_time);
                     if ($delivery_type == "Regular") {
                         $zendDate = new Zend_Date($delivery_date, "dd/MM/yyyy");
                         $delivery_date_new = $zendDate->toString("dd-MMM-yyyy");
                     } else {
                         $z_date = $zend_date->addDay(1);
                         $delivery_date_new = $z_date->toString("dd-MMM-yyyy");
                     }
                     if ($delivery_type == "Regular") {
                         $delivery_time = $delivery_time;
                     } else {
                         //$zendDate = new Zend_Date($pickup_time);
                         $delivery_time = "";
                         //echo $delivery_time;exit;
                     }
                     $orders->__set("delivery_date", $delivery_date_new);
                     $orders->__set("delivery_time", $delivery_time);
                 } else {
                     $orders->__set("user_fname", $user_name);
                     $orders->__set("user_lname", "");
                     $orders->__set("user_email", $guest_email);
                     $orders->__set("user_phn_number", $number);
                     $orders->__set("user_address", $address);
                     $orders->__set("address_locality", "");
                     $orders->__set("address_street", "");
                     $orders->__set("address_landmark", $landmark);
                     $orders->__set("address_city", $city);
                     $orders->__set("address_state", $state);
                     $orders->__set("address_country", "India");
                     $orders->__set("address_pincode", $pincode);
                     $orders->__set("payment_method", $payment_type);
                     $orders->__set("payment_status", "Unpaid");
                     $orders->__set("order_status", "New");
                     $orders->__set("order_total", 0);
                     $orders->__set("delivery_type", $delivery_type);
                     $orders->__set("service", $service_name);
                     $zend_date = new Zend_Date($pickup_date, "dd/MM/yyyy");
                     $pickup_date_new = $zend_date->toString("dd-MMM-yyyy");
                     $orders->__set("pickup_date", $pickup_date_new);
                     $orders->__set("pickup_time", $pickup_time);
                     if ($delivery_type == "Regular") {
                         $zendDate = new Zend_Date($delivery_date, "dd/MM/yyyy");
                         $delivery_date_new = $zendDate->toString("dd-MMM-yyyy");
                     } else {
                         $z_date = $zend_date->addDay(1);
                         $delivery_date_new = $z_date->toString("dd-MMM-yyyy");
                     }
                     if ($delivery_type == "Regular") {
                         $delivery_time = $delivery_time;
                     } else {
                         //$zendDate = new Zend_Date($pickup_time);
                         $delivery_time = "";
                         //echo $delivery_time;exit;
                     }
                     $orders->__set("delivery_date", $delivery_date_new);
                     $orders->__set("delivery_time", $delivery_time);
                 }
                 if ($payment_type == "wallet") {
                     $session = new Zend_Session_Namespace("order");
                     $total = $session->total;
                     $q_total = $total = $session->quantity_total;
                     if ($total > $wallet_amount) {
                         $this->view->hasMessage = true;
                         $this->view->messageType = "Danger";
                         $this->view->message = "Insufficient Fund in your Wallet.";
                     } else {
                         $order_id = $ordersMapper->addNewOrder($orders);
                         $total = 0;
                         foreach ($items as $item) {
                             $item_id = $item;
                             $qty = $quantity[$i];
                             $new_price = $price[$i];
                             $item_total = $qty * $new_price;
                             $total += $item_total;
                             $i++;
                             if ($order_id) {
                                 $orderItems->__set("order_id", $order_id);
                                 $orderItems->__set("item_id", $item_id);
                                 $orderItems->__set("quantity", $qty);
                                 $orderItems->__set("total_price", $item_total);
                                 $orderItems->__set("unit_price", $new_price);
                                 $orderItemsMapper->addNewOrderItem($orderItems);
                             }
                         }
                         $orders = $ordersMapper->getOrderById($order_id);
                         if ($total <= 100) {
                             $total_new = $total + 50;
                         } else {
                             $total_new = $total;
                         }
                         $orders->__set("order_total", $total_new);
                         $orders->__set("payment_status", "Paid");
                         $service = $orders->__get("service");
                         $d_date = $orders->__get("delivery_date");
                         if ($discount_amount && $revised_amount) {
                             $orders->__set("discount_price", $discount_amount);
                             $orders->__set("revised_price", $revised_amount);
                             $total_new = $revised_amount;
                         }
                         $sms = "Dear " . $fname . ", Your order " . $order_id . " with QTY " . $q_total . " and amount " . $total_new . " will be ready on " . $d_date . ". Thanks LaundryWala";
                         $sms_result = $this->_smsNotification($number, $sms);
                         $userWallet->__set("user_id", $user_id);
                         $userWallet->__set("entry_type", "DEBIT");
                         $userWallet->__set("entry_amount", $total);
                         $usersWalletMapper->addNewUserWallet($userWallet);
                         $subject = "Order Details From LaundryWala";
                         $message = "<table style='font-size:12px;'>";
                         $message .= "<tbody>";
                         $message .= "<tr><td>Dear Customer ,<br><br></td></tr>";
                         $message .= "<tr><td>Thank you for your association with LaundryWala.We are pleased to provide you details around your recent transaction with us.<br><br></td></tr>";
                         $message .= "<tr><td><strong>Invoice No :</strong>" . $order_id . "</td></tr>";
                         $message .= "<tr><td><strong>Customer Name :</strong>" . $fname . "</td></tr>";
                         $message .= "<tr><td><strong>Address :</strong>" . $address . "</td></tr>";
                         $message .= "<tr><td><strong>Phone No. :</strong><a>" . $number . "</a></td></tr>";
                         if ($orders) {
                             $email = $orders->__get("user_email");
                             $address = $orders->__get("user_address");
                             $city = $orders->__get("address_city");
                             $state = $orders->__get("address_state");
                             $pincode = $orders->__get("address_pincode");
                             $date = $orders->__get("timestamp");
                             $zendDate = new Zend_Date($date, "dd-MMM-yyyy");
                             $date_new = $zendDate->toString("dd-MMM-yyyy");
                             $number = $orders->__get("user_phn_number");
                             $method = $orders->__get("payment_method");
                             $del_date = $orders->__get("delivery_date");
                             $message .= "<tr><td><strong>Booking Date :</strong>" . $date_new . "<br><strong>Payment Mode:</strong>" . $method . "</td></tr>";
                             $message .= "<tr><td><strong>Total Amount Due Rs.:</strong>" . $total_new . "<br></td></tr>";
                             $message .= "<tr><td><strong>Due Delivery Date :</strong>" . $del_date . "</td></tr>";
                             $message .= "<tr><td><strong>Total Pcs. :</strong>" . $q_total . "</td></tr>";
                             $message .= "<tr style='font-size:12px'>";
                             $message .= "<td colspan='4'>";
                             $message .= "<table style='width:7.9in'>";
                             $message .= "<tbody>";
                             $message .= "<tr>";
                             $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>S.No.</td>";
                             $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>Qty</td>";
                             $message .= "<td style='width:5.0in;font-weight:bold;font-size:12px' align='left'>Particular's</td>";
                             $message .= "<td style='width:1.0in;font-weight:bold' align='right'></td>";
                             $message .= "<td style='width:1.0in;font-weight:bold;font-size:12px' align='right'>Amount</td>";
                             $message .= "</tr>";
                             $message .= "<tr style='font-size:9px'>";
                             $message .= "<td colspan='5' style='font-weight:bold;border-top-style:solid;border-top-width:thin;border-top-color:#000000'></td>";
                             $message .= "</tr>";
                             $orderItemsMapper = new Application_Model_OrderItemsMapper();
                             $items_new = $orderItemsMapper->getOrderItemByOrderId($orders->__get("order_id"));
                             $i = 1;
                             if ($items_new) {
                                 foreach ($items_new as $item) {
                                     $itemsMapper = new Application_Model_ItemsMapper();
                                     $item_name = $itemsMapper->getItemById($item->__get("item_id"));
                                     if ($item_name) {
                                         $name = $item_name->__get("item_name");
                                     } else {
                                         $name = "None";
                                     }
                                     $message .= "<tr style='font-size:12px'>";
                                     $message .= "<td>" . $i++ . "</td>";
                                     $message .= "<td>" . $item->__get("quantity") . "</td>";
                                     $message .= "<td colspan='2'><span style='font-family:arial black;font-size:11px'>" . $name . "</span></td>";
                                     //$message.= "<td align='right'></td>";
                                     $message .= "<td align='right'>Rs." . $item->__get("total_price") . "&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</td>";
                                     $message .= "</tr>";
                                 }
                             }
                         }
                         $message .= "<tr style='font-size:10px'><td colspan='5'></td></tr>";
                         $message .= "<tr style='font-size:10px'>";
                         $message .= "<td colspan='2'></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Subtotal</td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total . "</td>";
                         $message .= "</tr>";
                         if ($total <= 100) {
                             $message .= "<tr style='font-size:10px'>";
                             $message .= "<td colspan='3'></td>";
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Delivery Charges</td>";
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                             $message .= "</tr>";
                         } else {
                             $message .= "<tr style='font-size:10px'>";
                             $message .= "<td colspan='3'></td>";
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Discount</td>";
                             if ($discount_amount) {
                                 $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $revised_amount . "</td>";
                             } else {
                                 $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                             }
                             $message .= "</tr>";
                         }
                         $message .= "<tr style='font-size:10px'>";
                         $message .= "<td colspan='3'></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                         $message .= "</tr>";
                         $message .= "<tr><td nowrap='' colspan='3'>Assuring you of our best service.</td></tr>";
                         $message .= "<tr><td colspan='3'>Warm Regards.</td></tr>";
                         $message .= "<tr><td colspan='3'>LaundryWala</td></tr>";
                         $message .= "</tbody></table></td></tr></tbody></table>";
                         $this->getMailAction($email, $subject, $message);
                         $this->getMailAction("*****@*****.**", $subject, $message);
                         if ($ordersMapper->updateOrder($orders)) {
                             $this->_helper->redirector('notification', 'checkout');
                             $this->view->hasMessage = true;
                             $this->view->messageType = "success";
                             $this->view->message = "Your Order added sucessfully";
                         } else {
                             $this->view->hasMessage = true;
                             $this->view->messageType = "danger";
                             $this->view->message = "Error";
                         }
                     }
                 } elseif ($payment_type == "package") {
                     $session = new Zend_Session_Namespace("order");
                     $total = $session->total;
                     $quantity_total = $session->quantity_total;
                     if ($user_package_id) {
                         $userPackage = $userPackagesMapper->getUserPackageById($user_package_id);
                         if ($userPackage) {
                             $number_clothes = $userPackage->__get("clothes_left");
                             $number_pickups = $userPackage->__get("pickups_left");
                             if ($quantity_total > $number_clothes) {
                                 $this->view->hasMessage = true;
                                 $this->view->messageType = "Danger";
                                 $this->view->message = "Insufficient Number of clothes.";
                             } else {
                                 $order_id = $ordersMapper->addNewOrder($orders);
                                 $total = 0;
                                 foreach ($items as $item) {
                                     $item_id = $item;
                                     $qty = $quantity[$i];
                                     $new_price = $price[$i];
                                     $item_total = $qty * $new_price;
                                     $total += $item_total;
                                     $i++;
                                     if ($order_id) {
                                         $orderItems->__set("order_id", $order_id);
                                         $orderItems->__set("item_id", $item_id);
                                         $orderItems->__set("quantity", $qty);
                                         $orderItems->__set("total_price", $item_total);
                                         $orderItems->__set("unit_price", $new_price);
                                         $orderItemsMapper->addNewOrderItem($orderItems);
                                     }
                                 }
                                 $orders = $ordersMapper->getOrderById($order_id);
                                 if ($total <= 100) {
                                     $total_new = $total + 50;
                                 } else {
                                     $total_new = $total;
                                 }
                                 $orders->__set("order_total", $total_new);
                                 $orders->__set("payment_status", "Paid");
                                 $service = $orders->__get("service");
                                 $d_date = $orders->__get("delivery_date");
                                 if ($discount_amount && $revised_amount) {
                                     $orders->__set("discount_price", $discount_amount);
                                     $orders->__set("revised_price", $revised_amount);
                                     $total_new = $revised_amount;
                                 }
                                 $sms = "Dear " . $fname . ", Your order " . $order_id . " with QTY " . $quantity_total . " and amount " . $total_new . " will be ready on " . $d_date . ". Thanks LaundryWala";
                                 //$sms_result = $this->_smsNotification($number, $sms);
                                 $clothes_left = $number_clothes - $quantity_total;
                                 $pickups_left = $number_pickups - 1;
                                 $userPackage->__set("clothes_left", $clothes_left);
                                 $userPackage->__set("pickups_left", $pickups_left);
                                 $userPackagesMapper->updateUserPackage($userPackage);
                                 $subject = "Order Details From LaundryWala";
                                 $message = "<table style='font-size:12px;'>";
                                 $message .= "<tbody>";
                                 $message .= "<tr><td>Dear Customer ,<br><br></td></tr>";
                                 $message .= "<tr><td>Thank you for your association with LaundryWala.We are pleased to provide you details around your recent transaction with us.<br><br></td></tr>";
                                 $message .= "<tr><td><strong>Invoice No :</strong>" . $order_id . "</td></tr>";
                                 $message .= "<tr><td><strong>Customer Name :</strong>" . $fname . "</td></tr>";
                                 $message .= "<tr><td><strong>Address :</strong>" . $address . "</td></tr>";
                                 $message .= "<tr><td><strong>Phone No. :</strong><a>" . $number . "</a></td></tr>";
                                 if ($orders) {
                                     $email = $orders->__get("user_email");
                                     $address = $orders->__get("user_address");
                                     $city = $orders->__get("address_city");
                                     $state = $orders->__get("address_state");
                                     $pincode = $orders->__get("address_pincode");
                                     $date = $orders->__get("timestamp");
                                     $zendDate = new Zend_Date($date, "dd-MMM-yyyy");
                                     $date_new = $zendDate->toString("dd-MMM-yyyy");
                                     $number = $orders->__get("user_phn_number");
                                     $method = $orders->__get("payment_method");
                                     $del_date = $orders->__get("delivery_date");
                                     $message .= "<tr><td><strong>Booking Date :</strong>" . $date_new . "<br><strong>Payment Mode:</strong>" . $method . "</td></tr>";
                                     $message .= "<tr><td><strong>Total Amount Due Rs.:</strong>" . $total_new . "<br></td></tr>";
                                     $message .= "<tr><td><strong>Due Delivery Date :</strong>" . $del_date . "</td></tr>";
                                     $message .= "<tr><td><strong>Total Pcs. :</strong>" . $quantity_total . "</td></tr>";
                                     $message .= "<tr style='font-size:12px'>";
                                     $message .= "<td colspan='4'>";
                                     $message .= "<table style='width:7.9in'>";
                                     $message .= "<tbody>";
                                     $message .= "<tr>";
                                     $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>S.No.</td>";
                                     $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>Qty</td>";
                                     $message .= "<td style='width:5.0in;font-weight:bold;font-size:12px' align='left'>Particular's</td>";
                                     $message .= "<td style='width:1.0in;font-weight:bold' align='right'></td>";
                                     $message .= "<td style='width:1.0in;font-weight:bold;font-size:12px' align='right'>Amount</td>";
                                     $message .= "</tr>";
                                     $message .= "<tr style='font-size:9px'>";
                                     $message .= "<td colspan='5' style='font-weight:bold;border-top-style:solid;border-top-width:thin;border-top-color:#000000'></td>";
                                     $message .= "</tr>";
                                     $orderItemsMapper = new Application_Model_OrderItemsMapper();
                                     $items_new = $orderItemsMapper->getOrderItemByOrderId($orders->__get("order_id"));
                                     $i = 1;
                                     if ($items_new) {
                                         foreach ($items_new as $item) {
                                             $itemsMapper = new Application_Model_ItemsMapper();
                                             $item_name = $itemsMapper->getItemById($item->__get("item_id"));
                                             if ($item_name) {
                                                 $name = $item_name->__get("item_name");
                                             } else {
                                                 $name = "None";
                                             }
                                             $message .= "<tr style='font-size:12px'>";
                                             $message .= "<td>" . $i++ . "</td>";
                                             $message .= "<td>" . $item->__get("quantity") . "</td>";
                                             $message .= "<td><span style='font-family:arial black;font-size:11px'>" . $name . "</span></td>";
                                             $message .= "<td align='right'></td>";
                                             $message .= "<td align='right'>Rs." . $item->__get("total_price") . "&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</td>";
                                             $message .= "</tr>";
                                         }
                                     }
                                 }
                                 $message .= "<tr style='font-size:10px'><td colspan='5'></td></tr>";
                                 $message .= "<tr style='font-size:10px'>";
                                 $message .= "<td colspan='3'></td>";
                                 $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Subtotal</td>";
                                 $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total . "</td>";
                                 $message .= "</tr>";
                                 if ($total <= 100) {
                                     $message .= "<tr style='font-size:10px'>";
                                     $message .= "<td colspan='3'></td>";
                                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Delivery Charges</td>";
                                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                                     $message .= "</tr>";
                                 } else {
                                     $message .= "<tr style='font-size:10px'>";
                                     $message .= "<td colspan='3'></td>";
                                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Discount</td>";
                                     if ($discount_amount) {
                                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $revised_amount . "</td>";
                                     } else {
                                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                                     }
                                     $message .= "</tr>";
                                 }
                                 $message .= "<tr style='font-size:10px'>";
                                 $message .= "<td colspan='3'></td>";
                                 $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                                 $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                                 $message .= "</tr>";
                                 $message .= "<tr><td nowrap='' colspan='3'>Assuring you of our best service.</td></tr>";
                                 $message .= "<tr><td colspan='3'>Warm Regards.</td></tr>";
                                 $message .= "<tr><td colspan='3'>LaundryWala</td></tr>";
                                 $message .= "</tbody></table></td></tr></tbody></table>";
                                 $this->getMailAction($email, $subject, $message);
                                 $this->getMailAction("*****@*****.**", $subject, $message);
                                 if ($ordersMapper->updateOrder($orders)) {
                                     $this->_helper->redirector('notification', 'checkout');
                                     $this->view->hasMessage = true;
                                     $this->view->messageType = "success";
                                     $this->view->message = "Your Order added sucessfully";
                                 } else {
                                     $this->view->hasMessage = true;
                                     $this->view->messageType = "danger";
                                     $this->view->message = "Error";
                                 }
                             }
                         }
                     } else {
                         echo "<script>alert('No Package Selected or Available');</script>";
                     }
                     //print_r($userPackage);exit;
                 } elseif ($payment_type == "online-payment") {
                     $session = new Zend_Session_Namespace("order");
                     $total = $session->total;
                     $q_total = $total = $session->quantity_total;
                     $order_id = $ordersMapper->addNewOrder($orders);
                     $total = 0;
                     foreach ($items as $item) {
                         $item_id = $item;
                         $qty = $quantity[$i];
                         $new_price = $price[$i];
                         $item_total = $qty * $new_price;
                         $total += $item_total;
                         $i++;
                         if ($order_id) {
                             $orderItems->__set("order_id", $order_id);
                             $orderItems->__set("item_id", $item_id);
                             $orderItems->__set("quantity", $qty);
                             $orderItems->__set("total_price", $item_total);
                             $orderItems->__set("unit_price", $new_price);
                             $orderItemsMapper->addNewOrderItem($orderItems);
                         }
                     }
                     $orders = $ordersMapper->getOrderById($order_id);
                     if ($total <= 100) {
                         $total_new = $total + 50;
                     } else {
                         $total_new = $total;
                     }
                     $orders->__set("order_total", $total_new);
                     $orders->__set("payment_status", "Unpaid");
                     $service = $orders->__get("service");
                     $d_date = $orders->__get("delivery_date");
                     if ($discount_amount && $revised_amount) {
                         $orders->__set("discount_price", $discount_amount);
                         $orders->__set("revised_price", $revised_amount);
                         $total_new = $revised_amount;
                     }
                     $sms = "Dear " . $fname . ", Your order " . $order_id . " with QTY " . $q_total . " and amount " . $total_new . " will be ready on " . $d_date . ". Thanks LaundryWala";
                     $sms_result = $this->_smsNotification($number, $sms);
                     $subject = "Order Details From LaundryWala";
                     $message = "<table style='font-size:12px;'>";
                     $message .= "<tbody>";
                     $message .= "<tr><td>Dear Customer ,<br><br></td></tr>";
                     $message .= "<tr><td>Thank you for your association with LaundryWala.We are pleased to provide you details around your recent transaction with us.<br><br></td></tr>";
                     $message .= "<tr><td><strong>Invoice No :</strong>" . $order_id . "</td></tr>";
                     $message .= "<tr><td><strong>Customer Name :</strong>" . $fname . "</td></tr>";
                     $message .= "<tr><td><strong>Address :</strong>" . $address . "</td></tr>";
                     $message .= "<tr><td><strong>Phone No. :</strong><a>" . $number . "</a></td></tr>";
                     if ($orders) {
                         $email = $orders->__get("user_email");
                         $address = $orders->__get("user_address");
                         $city = $orders->__get("address_city");
                         $state = $orders->__get("address_state");
                         $pincode = $orders->__get("address_pincode");
                         $date = $orders->__get("timestamp");
                         $zendDate = new Zend_Date($date, "dd-MMM-yyyy");
                         $date_new = $zendDate->toString("dd-MMM-yyyy");
                         $number = $orders->__get("user_phn_number");
                         $method = $orders->__get("payment_method");
                         $del_date = $orders->__get("delivery_date");
                         $message .= "<tr><td><strong>Booking Date :</strong>" . $date_new . "<br><strong>Payment Mode:</strong>" . $method . "</td></tr>";
                         $message .= "<tr><td><strong>Total Amount Due Rs.:</strong>" . $total_new . "<br></td></tr>";
                         $message .= "<tr><td><strong>Due Delivery Date :</strong>" . $del_date . "</td></tr>";
                         $message .= "<tr><td><strong>Total Pcs. :</strong>" . $q_total . "</td></tr>";
                         $message .= "<tr style='font-size:12px'>";
                         $message .= "<td colspan='4'>";
                         $message .= "<table style='width:7.9in'>";
                         $message .= "<tbody>";
                         $message .= "<tr>";
                         $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>S.No.</td>";
                         $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>Qty</td>";
                         $message .= "<td style='width:5.0in;font-weight:bold;font-size:12px' align='left'>Particular's</td>";
                         $message .= "<td style='width:1.0in;font-weight:bold' align='right'></td>";
                         $message .= "<td style='width:1.0in;font-weight:bold;font-size:12px' align='right'>Amount</td>";
                         $message .= "</tr>";
                         $message .= "<tr style='font-size:9px'>";
                         $message .= "<td colspan='5' style='font-weight:bold;border-top-style:solid;border-top-width:thin;border-top-color:#000000'></td>";
                         $message .= "</tr>";
                         $orderItemsMapper = new Application_Model_OrderItemsMapper();
                         $items_new = $orderItemsMapper->getOrderItemByOrderId($orders->__get("order_id"));
                         $i = 1;
                         if ($items_new) {
                             foreach ($items_new as $item) {
                                 $itemsMapper = new Application_Model_ItemsMapper();
                                 $item_name = $itemsMapper->getItemById($item->__get("item_id"));
                                 if ($item_name) {
                                     $name = $item_name->__get("item_name");
                                 } else {
                                     $name = "None";
                                 }
                                 $message .= "<tr style='font-size:12px'>";
                                 $message .= "<td>" . $i++ . "</td>";
                                 $message .= "<td>" . $item->__get("quantity") . "</td>";
                                 $message .= "<td><span style='font-family:arial black;font-size:11px'>" . $name . "</span></td>";
                                 $message .= "<td align='right'></td>";
                                 $message .= "<td align='right'>Rs." . $item->__get("total_price") . "&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</td>";
                                 $message .= "</tr>";
                             }
                         }
                     }
                     $message .= "<tr style='font-size:10px'><td colspan='5'></td></tr>";
                     $message .= "<tr style='font-size:10px'>";
                     $message .= "<td colspan='3'></td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Subtotal</td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total . "</td>";
                     $message .= "</tr>";
                     if ($total <= 100) {
                         $message .= "<tr style='font-size:10px'>";
                         $message .= "<td colspan='3'></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Delivery Charges</td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                         $message .= "</tr>";
                     } else {
                         $message .= "<tr style='font-size:10px'>";
                         $message .= "<td colspan='3'></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Discount</td>";
                         if ($discount_amount) {
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $revised_amount . "</td>";
                         } else {
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                         }
                         $message .= "</tr>";
                     }
                     $message .= "<tr style='font-size:10px'>";
                     $message .= "<td colspan='3'></td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                     $message .= "</tr>";
                     $message .= "<tr><td nowrap='' colspan='3'>Assuring you of our best service.</td></tr>";
                     $message .= "<tr><td colspan='3'>Warm Regards.</td></tr>";
                     $message .= "<tr><td colspan='3'>LaundryWala</td></tr>";
                     $message .= "</tbody></table></td></tr></tbody></table>";
                     $this->getMailAction($email, $subject, $message);
                     $this->getMailAction("*****@*****.**", $subject, $message);
                     if ($ordersMapper->updateOrder($orders)) {
                         $this->view->hasMessage = true;
                         $this->view->messageType = "success";
                         $this->view->message = "Your Order added sucessfully";
                     } else {
                         $this->view->hasMessage = true;
                         $this->view->messageType = "danger";
                         $this->view->message = "Error";
                     }
                     if ($guest_email) {
                         $this->_redirect('/payment/index/order_id/' . $order_id . '/email/' . $guest_email . '/name/' . $user_name . '/number/' . $number);
                     } else {
                         $this->_redirect('/payment/index/order_id/' . $order_id);
                     }
                 } else {
                     $order_id = $ordersMapper->addNewOrder($orders);
                     $session = new Zend_Session_Namespace("order");
                     $q_total = $total = $session->quantity_total;
                     $total = 0;
                     foreach ($items as $item) {
                         $item_id = $item;
                         $qty = $quantity[$i];
                         $new_price = $price[$i];
                         $item_total = $qty * $new_price;
                         $total += $item_total;
                         $i++;
                         $amount_session = new Zend_Session_Namespace("total_amount");
                         $amount_session->total_amount = $total;
                         if ($order_id) {
                             $orderItems->__set("order_id", $order_id);
                             $orderItems->__set("item_id", $item_id);
                             $orderItems->__set("quantity", $qty);
                             $orderItems->__set("total_price", $item_total);
                             $orderItems->__set("unit_price", $new_price);
                             $orderItemsMapper->addNewOrderItem($orderItems);
                         }
                     }
                     $orders = $ordersMapper->getOrderById($order_id);
                     if ($total <= 100) {
                         $total_new = $total + 50;
                     } else {
                         $total_new = $total;
                     }
                     $orders->__set("order_total", $total_new);
                     $orders->__set("payment_status", "Unpaid");
                     $service = $orders->__get("service");
                     $d_date = $orders->__get("delivery_date");
                     if ($discount_amount && $revised_amount) {
                         $orders->__set("discount_price", $discount_amount);
                         $orders->__set("revised_price", $revised_amount);
                         $total_new = $revised_amount;
                     }
                     $sms = "Dear " . $fname . ", Your order " . $order_id . " with QTY " . $q_total . " and amount Rs. " . $total_new . " will be ready on " . $d_date . ". Thanks LaundryWala";
                     //$sms = "Dear Divya, Your order 12 with QTY 12 and amount Rs. 200 will be ready on 12. Thanks LaundryWala";
                     $sms_result = $this->_smsNotification($number, $sms);
                     $subject = "Order Details From LaundryWala";
                     $message = "<table style='font-size:12px;'>";
                     $message .= "<tbody>";
                     $message .= "<tr><td>Dear Customer ,<br><br></td></tr>";
                     $message .= "<tr><td>Thank you for your association with LaundryWala.We are pleased to provide you details around your recent transaction with us.<br><br></td></tr>";
                     $message .= "<tr><td><strong>Invoice No :</strong>" . $order_id . "</td></tr>";
                     $message .= "<tr><td><strong>Customer Name :</strong>" . $fname . "</td></tr>";
                     $message .= "<tr><td><strong>Address :</strong>" . $address . "</td></tr>";
                     $message .= "<tr><td><strong>Phone No. :</strong><a>" . $number . "</a></td></tr>";
                     if ($orders) {
                         $email = $orders->__get("user_email");
                         $address = $orders->__get("user_address");
                         $city = $orders->__get("address_city");
                         $state = $orders->__get("address_state");
                         $pincode = $orders->__get("address_pincode");
                         $date = $orders->__get("timestamp");
                         $zendDate = new Zend_Date($date, "dd-MMM-yyyy");
                         $date_new = $zendDate->toString("dd-MMM-yyyy");
                         $number = $orders->__get("user_phn_number");
                         $method = $orders->__get("payment_method");
                         $del_date = $orders->__get("delivery_date");
                         $message .= "<tr><td><strong>Booking Date :</strong>" . $date_new . "<br><strong>Payment Mode:</strong>" . $method . "</td></tr>";
                         $message .= "<tr><td><strong>Total Amount Due Rs.:</strong>" . $total_new . "<br></td></tr>";
                         $message .= "<tr><td><strong>Due Delivery Date :</strong>" . $del_date . "</td></tr>";
                         $message .= "<tr><td><strong>Total Pcs. :</strong>" . $q_total . "</td></tr>";
                         $message .= "<tr style='font-size:12px'>";
                         $message .= "<td colspan='4'>";
                         $message .= "<table style='width:7.9in'>";
                         $message .= "<tbody>";
                         $message .= "<tr>";
                         $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>S.No.</td>";
                         $message .= "<td style='width:0.5in;font-weight:bold;font-size:12px'>Qty</td>";
                         $message .= "<td style='width:5.0in;font-weight:bold;font-size:12px' align='left'>Particular's</td>";
                         $message .= "<td style='width:1.0in;font-weight:bold' align='right'></td>";
                         $message .= "<td style='width:1.0in;font-weight:bold;font-size:12px' align='right'>Amount</td>";
                         $message .= "</tr>";
                         $message .= "<tr style='font-size:9px'>";
                         $message .= "<td colspan='5' style='font-weight:bold;border-top-style:solid;border-top-width:thin;border-top-color:#000000'></td>";
                         $message .= "</tr>";
                         $orderItemsMapper = new Application_Model_OrderItemsMapper();
                         $items_new = $orderItemsMapper->getOrderItemByOrderId($orders->__get("order_id"));
                         $i = 1;
                         if ($items_new) {
                             foreach ($items_new as $item) {
                                 $itemsMapper = new Application_Model_ItemsMapper();
                                 $item_name = $itemsMapper->getItemById($item->__get("item_id"));
                                 if ($item_name) {
                                     $name = $item_name->__get("item_name");
                                 } else {
                                     $name = "None";
                                 }
                                 $message .= "<tr style='font-size:12px'>";
                                 $message .= "<td>" . $i++ . "</td>";
                                 $message .= "<td>" . $item->__get("quantity") . "</td>";
                                 $message .= "<td><span style='font-family:arial black;font-size:11px'>" . $name . "</span></td>";
                                 $message .= "<td align='right'></td>";
                                 $message .= "<td align='right'>Rs." . $item->__get("total_price") . "&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;</td>";
                                 $message .= "</tr>";
                             }
                         }
                     }
                     $message .= "<tr style='font-size:10px'><td colspan='5'></td></tr>";
                     $message .= "<tr style='font-size:10px'>";
                     $message .= "<td colspan='3'></td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Subtotal</td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total . "</td>";
                     $message .= "</tr>";
                     if ($total <= 100) {
                         $message .= "<tr style='font-size:10px'>";
                         $message .= "<td colspan='3'></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Delivery Charges</td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                         $message .= "</tr>";
                     } else {
                         $message .= "<tr style='font-size:10px'>";
                         $message .= "<td colspan='3'></td>";
                         $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Amount after Discount</td>";
                         if ($discount_amount) {
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $revised_amount . "</td>";
                         } else {
                             $message .= "<td align='right' style='font-size:12px;font-weight:bold'>Rs." . $total_new . "</td>";
                         }
                         $message .= "</tr>";
                     }
                     $message .= "<tr style='font-size:10px'>";
                     $message .= "<td colspan='3'></td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                     $message .= "<td align='right' style='font-size:12px;font-weight:bold'><br></td>";
                     $message .= "</tr>";
                     $message .= "<tr><td nowrap='' colspan='3'>Assuring you of our best service.</td></tr>";
                     $message .= "<tr><td colspan='3'>Warm Regards.</td></tr>";
                     $message .= "<tr><td colspan='3'>LaundryWala</td></tr>";
                     $message .= "</tbody></table></td></tr></tbody></table>";
                     $this->getMailAction($email, $subject, $message);
                     $this->getMailAction("*****@*****.**", $subject, $message);
                     if ($ordersMapper->updateOrder($orders)) {
                         $this->_helper->redirector('notification', 'checkout');
                         $this->view->hasMessage = true;
                         $this->view->messageType = "success";
                         $this->view->message = "Your Order added sucessfully";
                     } else {
                         $this->view->hasMessage = true;
                         $this->view->messageType = "danger";
                         $this->view->message = "Error";
                     }
                 }
             } else {
                 $errorString = "";
                 foreach ($errors as $error) {
                     $errorString .= $error . "<br/>";
                 }
                 $this->view->hasMessage = true;
                 $this->view->messageType = "danger";
                 $this->view->message = $errorString;
             }
         }
     }
 }
Esempio n. 3
0
 public function printorderAction()
 {
     $this->_helper->layout->disableLayout();
     error_reporting(0);
     $orderId = $this->_getParam("order");
     $i = '1';
     $ordersMapper = new Application_Model_OrdersMapper();
     $orderDetail = $ordersMapper->getOrderById($orderId);
     $orderItemsMapper = new Application_Model_OrderItemsMapper();
     $orderItems = $orderItemsMapper->getOrderItemByOrderId($orderId);
     if (empty($orderDetail)) {
         echo "Order Not Found";
         die;
     }
     //echo $orderItems[0]->order_service_name;
     $code = $orderId . '-0000-' . $orderDetail->order_user_id;
     $bc = new Barcode39($code);
     $bc->draw("public/barcode/barcode_" . $orderId . '_' . $orderDetail->order_user_id . ".gif");
     $barcode = '<img src="../../public/barcode/barcode_' . $orderId . '_' . $orderDetail->order_user_id . '.gif">';
     $print = '';
     $print .= '<div id="divToPrint" ><div style="width:290px;background-color:#ffffff;border:1px solid #ccc;padding:4px;font-size:12px;"><h2 style="text-align:center;" >Laundrywala<hr></h2><table  cellspacing="4"  cellpadding="4" style="padding:4px; font-size:12px;"><tr><td> Address :</td><td>A-109Q,2nd Flr,<br>Sec-80 </td></tr><tr><td>State :</td><td>Noida-201305</td></tr><tr><td>Contact :</td><td>9953180071</td></tr><tr><td>Mail :</td><td>info@laundrywala.co.in </td></tr><tr><td>TIN No :</td><td>NA </td></tr><tr><td>Service Tax No :</td><td>NA </td></tr><tr><td>CIN No: </td><td>NA</td></tr><tr></table>';
     $print .= '<hr><h4 style="text-align:center;">Customer Details</h4><table  cellspacing="4"  cellpadding="4" style="padding:4px; font-size:12px;">';
     $print .= '<tr><td>Name :</td><td>' . $orderDetail->order_first_name . ' ' . $orderDetail->order_last_name . '</td></tr><tr><td>Address :</td><td>' . $orderDetail->order_address . '</td></tr><tr><td>City/State</td><td>' . $orderDetail->order_city . '</td></tr><tr><td>Contact No. </td><td>' . $orderDetail->order_mobile_number . '</td></tr><tr></table><hr>';
     $print .= '<h4 style="text-align:center;">Order Details</h4><table border="1" cellpadding="1" cellspacing="0"  style=" font-size:10px;padding:2px; width:100%;" > <tr style="border:1px solid #000"><td>SN</td><td>Service</td><td>Product</td><td>QTY</td><td>Amount</td><td>Total</td></tr>';
     foreach ($orderItems as $orderItems) {
         $print .= '<tr style="border:1px solid #000"><td>' . $i . '</td><td>' . $orderItems->order_service_name . '</td><td>' . $orderItems->order_product_name . '</td><td>' . $orderItems->quantity . '</td><td>' . $orderItems->unit_price . '</td><td>' . $orderItems->total_price . '</td></tr>';
         $i++;
     }
     $print .= '<tr ><td></td><td></td><td></td><td></td><td>Delivery Charges</td><td>' . $orderDetail->delivery_charge . '</td>';
     $print .= '</tr><tr ><td></td><td></td><td></td><td></td><td>Service Tax(15%)</td><td>' . $orderDetail->service_tax . '</td></tr>';
     $print .= '<tr style="border:1px solid #000" ><td></td><td></td><td></td><td></td><td>Total</td><td>' . $orderDetail->order_amount . '</td></tr></table>';
     $print .= '<div style="text-align:center;" >' . $barcode . '</div></div></div>';
     $fp = trim($print);
     echo $fp;
     exit;
 }