public function editAction() { $this->view->pageHeading = "Edit package"; $this->view->buttonTitle = "Edit package"; try { //$admins = new Application_Model_Admins; $packagesMapper = new Application_Model_PackagesMapper(); $request = $this->getRequest(); $package_form = new Application_Form_PackageForm(); $this->view->form = $package_form; $elements = $package_form->getElements(); $id = $request->getParam("id"); $package = $packagesMapper->getPackageById($id); foreach ($elements as $element) { $element->setValue($package->__get($element->getName())); } if ($request->isPost()) { $params = $request->getParams(); if ($package_form->isValid($params)) { $packageIconName = $this->_imageUpload('package_icon', 'file'); $packageIconHoverName = $this->_imageUpload('package_icon_hover', 'file'); foreach ($params as $param => $value) { $package->__set($param, $value); } if (!empty($packageIconName)) { $package->__set("package_icon", $packageIconName); } if (!empty($packageIconHoverName)) { $package->__set("package_icon_hover", $packageIconHoverName); } $isUpdated = $packagesMapper->updatePackage($package); if (is_object($isUpdated) && $isUpdated->success) { if ($isUpdated->row_affected > 0) { $this->view->message = "Package Updated successfully"; } else { $this->view->message = "No Data Updated"; } $this->view->hasMessage = true; $this->view->messageType = "success"; } else { $this->view->message = "Error occured while updating. Please try again"; $this->view->hasMessage = true; $this->view->messageType = "danger"; } } else { $this->view->message = "Error occured while updating. Please fill form correctly"; $this->view->hasMessage = true; $this->view->messageType = "danger"; } } $this->authorised = true; } catch (Exception $ex) { $this->authorised = false; $this->view->hasMessage = true; $this->view->messageType = "danger"; $this->view->message = $ex->getMessage(); } $this->render("add"); }
public function indexAction() { try { $usersMapper = new Application_Model_UsersMapper(); $transaction_type = ""; $id = ""; $amount = 0; $request = $this->getRequest(); $package_id = $request->getParam("package_id"); $type = $request->getParam("transaction_type"); $order_id = $request->getParam("order_id"); if ($order_id) { $transaction_type = "Online"; $id = $order_id; $ordersMapper = new Application_Model_OrdersMapper(); $order = $ordersMapper->getOrderById($order_id); $amount = $order->__get("order_amount"); } $namespace = new Zend_Session_Namespace('userInfo'); // if ($this->_auth->hasIdentity()) { if (!empty($namespace->user_id)) { // $user_id = $this->_auth->getIdentity()->user_id; $user_id = $namespace->user_id; $user = $usersMapper->getUserById($user_id); if ($package_id) { $transaction_type = "Package"; $packagesMapper = new Application_Model_PackagesMapper(); $package = $packagesMapper->getPackageById($package_id); //$amount = $package->__get("package_price"); $this->view->package = $package; $this->view->transaction_type = $transaction_type; } $fname = $user->__get("user_fname"); $lname = $user->__get("user_lname"); $email = $user->__get("user_email"); $number = $user->__get("user_number"); } else { $this->_redirect("/index/login/?redirect_url=" . $ref); } $merchant_key = "jqsdG2"; //test key $merchant_key = "gtKFFx"; $salt = "dwf1Ltip"; //test salt $salt = "eCwWELxi"; $baseUrl = "https://secure.payu.in"; $baseUrl = "https://test.payu.in"; $txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20); $service_provider = "payu_paisa"; //test $service_provider = ""; $surl = BASE_URL . "index/orderlist?SUCC=succ"; $furl = BASE_URL . "index/orderlist?SUCC=err"; $posted = array(); $posted['key'] = $merchant_key; $posted['txnid'] = $txnid; $posted['amount'] = $amount; $posted['firstname'] = $fname; $posted['email'] = $email; $posted['phone'] = $number; $posted['productinfo'] = "transaction_type:" . $transaction_type . "|user_id:" . $user_id . "|id:" . $id . "|package:" . $packageId; //$product_info; $posted['surl'] = $surl; $posted['furl'] = $furl; $posted['service_provider'] = $service_provider; //print_r($posted);exit; $hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10"; $hashVarsSeq = explode('|', $hashSequence); $hash_string = ''; foreach ($hashVarsSeq as $hash_var) { $hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : ''; $hash_string .= '|'; } $hash_string .= $salt; $hash = strtolower(hash('sha512', $hash_string)); $action = $baseUrl . '/_payment'; $this->view->posted = $posted; $this->view->hash = $hash; $this->view->action = $action; $this->view->authorized = TRUE; } catch (Exception $ex) { $this->view->authorized = FALSE; $this->view->message = $ex->getMessage(); } }
public function init() { /* Form Elements & Other Definitions Here ... */ $this->setMethod('post'); $this->setElementDecorators($this->elementDecorators); //get delivery types from delivery master $deliveryMapper = new Application_Model_DeliveryTypeMasterMapper(); //get service types list $serviceMaster = new Application_Model_ServiceMasterMapper(); $packageMaster = new Application_Model_PackagesMapper(); $this->addElement('text', 'order_mobile_number', array('label' => 'User\'s Phone Number', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Enter User's Contact number", 'class' => 'mws-textinput required')); $this->addElement('hidden', 'order_user_id', array()); $this->addElement('text', 'order_first_name', array('label' => 'User\'s First Name', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Enter User's First Name", 'class' => 'mws-textinput required')); $this->addElement('text', 'order_last_name', array('label' => 'User\'s Last Name', 'filters' => array('StringTrim'), 'placeholder' => "Enter User's Last Name", 'class' => 'mws-textinput')); $this->addElement('text', 'order_user_email', array('label' => 'User\'s Email', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Enter User's Email", 'class' => 'mws-textinput')); $this->addElement('text', 'order_address', array('label' => 'User\'s House/Apartment #', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Enter User's House/Apartment #", 'class' => 'mws-textinput')); $this->addElement('text', 'order_city', array('label' => 'City', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Enter City", 'class' => 'mws-textinput')); // $this->addElement('text', 'order_pincode', array( // 'label' => 'Pincode', // 'filters' => array('StringTrim'), // 'placeholder' => "Enter Pincode", // 'class' => 'mws-textinput', // )); $orderType = array('service' => 'service', 'package' => 'package'); $this->addElement('select', 'order_type', array('label' => 'Order Type', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Select Order type", 'class' => 'mws-textinput', 'multiOptions' => $orderType, 'onchange' => 'changeOrderType(this.value)')); //============== Service Type //get service list $serviceList = $serviceMaster->getAllServiceMasters(); foreach ($serviceList as $serviceVal) { $serviceType[$serviceVal->service_id] = $serviceVal->service_name; } // $serviceType = array(3=>"laundry",4=>"dryclean",5=>"ironing",6=>"washandfold",0=>"other"); $this->addElement('multiselect', 'order_service_type', array('label' => 'Service Type', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Select Service Type", 'class' => 'mws-textinput', 'multiOptions' => $serviceType, 'onchange' => 'updateDeliveryType(this.value)')); //=========== Delivery Type $deliveryTypes = $deliveryMapper->getAllDeliveryTypeMaster(); foreach ($deliveryTypes as $delVal) { $delivery_types[$delVal->delivery_type_id] = $delVal->delivery_type_name; } // $delivery_types = array("Regular", "Express"); $this->addElement('select', 'order_delivery_type', array('label' => 'Delivery Type', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Select Delivery type", 'class' => 'mws-textinput', 'multiOptions' => $delivery_types)); $packageList = $packageMaster->getAllPackages(); $packageArr = array(); foreach ($packageList as $packageVal) { $packageArr[$packageVal->package_id] = $packageVal->package_name; } // $delivery_types = array("Regular", "Express"); $this->addElement('select', 'order_package', array('label' => 'Package', 'required' => true, 'filters' => array('StringTrim'), 'placeholder' => "Select Package", 'class' => 'mws-textinput', 'multiOptions' => $packageArr)); // $payment_methods = array("Credit Card", "Debit Card", "Net Banking", "Cash On Delivery", "Wallet"); // $this->addElement('select', 'order_payment_type', array( // 'label' => 'Payment Method', // 'required' => true, // 'filters' => array('StringTrim'), // 'placeholder' => "Select Payment Method", // 'class' => 'mws-textinput', // 'multiOptions' => $payment_methods // )); // $payment_statuses = array("Paid","Unpaid"); // $this->addElement('select', 'order_payment_status', array( // 'label' => 'Payment Status', // 'required' => true, // 'filters' => array('StringTrim'), // 'placeholder' => "Select Payment Status", // 'class' => 'mws-textinput', // 'multiOptions' => $payment_statuses // )); // $order_statuses = array("New","Picked","Processed","Dispatched","Delivered"); // $this->addElement('select', 'order_status', array( // 'label' => 'Order Status', // 'required' => true, // 'filters' => array('StringTrim'), // 'placeholder' => "Select Order Status", // 'class' => 'mws-textinput', // 'multiOptions' => $order_statuses // )); // // TO DO - from db // $serviceType = array(3=>"laundry",4=>"dryclean",5=>"ironing",6=>"washandfold",0=>"other"); // $this->addElement('select', 'order_service_type', array( // 'label' => 'Service Type', // 'required' => true, // 'filters' => array('StringTrim'), // 'placeholder' => "Select Service Type", // 'class' => 'mws-textinput', // 'multiOptions' => $order_statuses // )); // $this->addElement('text', 'order_amount', array( // 'label' => 'Total Price', // 'required' => true, // 'filters' => array('StringTrim'), // 'placeholder' => "Enter Total Price", // 'class' => 'mws-textinput', // )); }
public function orderlistAction() { $namespace = new Zend_Session_Namespace('userInfo'); $orderSuccess = $this->getRequest()->getParam('SUCC'); $this->view->user_fname = $namespace->user_fname; $this->view->user_lname = $namespace->user_lname; $this->view->user_img = $namespace->user_img; $this->view->user_number = $namespace->user_number; if (isset($namespace->user_id)) { $orderModel = new Application_Model_OrdersMapper(); $packageModel = new Application_Model_PackagesMapper(); $serviceModel = new Application_Model_ServiceMasterMapper(); $orders = $orderModel->getOrdersByUserId($namespace->user_id); //get list of services $services = $serviceModel->getAllServiceMasters(); $servicesArr = array(); foreach ($services as $serviceKey => $service) { $servicesArr[$service->__get('service_id')]['service_name'] = $service->__get('service_name'); } //get list of packages $packages = $packageModel->getAllPackages(); $packagesArr = array(); foreach ($packages as $packageKey => $package) { $packagesArr[$package->__get('package_id')]['package_name'] = $package->__get('package_name'); } $ordersArr = array(); foreach ($orders as $key => $item) { $ordersArr[$key]['order_id'] = $item->__get('order_id'); $ordersArr[$key]['order_pickup'] = $item->__get('order_pickup'); $serviceIds = $item->__get('order_service_type'); $serviceIds = explode(",", $serviceIds); $ordersArr[$key]['order_services'] = array_map(function ($val) use($servicesArr) { return @$servicesArr[$val]['service_name']; }, $serviceIds); $ordersArr[$key]['order_packages'] = array_map(function ($val) use($packagesArr) { return @$packagesArr[$val]['package_name']; }, $serviceIds); $ordersArr[$key]['order_delivery'] = $item->__get('order_delivery'); $ordersArr[$key]['order_address'] = $item->__get('order_address'); $ordersArr[$key]['delivery_charge'] = $item->__get('delivery_charge') ?: 0; $ordersArr[$key]['order_amount'] = $item->__get('order_amount'); $ordersArr[$key]['service_tax'] = $item->__get('service_tax') ?: 0; $ordersArr[$key]['order_type'] = $item->__get('order_type') ?: 'service'; $ordersArr[$key]['order_mobile_number'] = $item->__get('order_mobile_number') ?: $namespace->user_number; } $this->view->orders = $ordersArr; $this->view->headlineText = 'My Orders'; $this->view->noFooter = 'true'; if ($orderSuccess == 'succ') { $this->view->hasMessage = true; $this->view->messageType = 'success'; $this->view->message = 'Your order was successfully placed'; } elseif ($orderSuccess == 'err') { $this->view->hasMessage = true; $this->view->messageType = 'danger'; $this->view->message = 'Some error occurred. Please try again.'; } } else { $this->_redirect(); } }