Beispiel #1
0
function sendOrder($formData)
{
    $formData['orderType'] = 'a';
    $formData['cultureCode'] = $GLOBALS['bfi_lang'];
    $customer = RSFormHelper::getCustomerData($formData);
    $suggestedStay = json_decode(stripslashes($formData['staysuggested']));
    $req = json_decode(stripslashes($formData['stayrequest']), true);
    //  $suggestedStay = json_decode($_SESSION['search.params']['suggestedstay']);
    //  $req = array('resourceId' => $_SESSION['search.params']['resourceId'], 'checkin' => $formData['checkin']['date'], 'checkout' =>$formData['checkout']['date'] , 'duration' => $_SESSION['search.params']['duration'], 'paxages' => '['.implode(',', $_SESSION['search.params']['paxages']).']', 'extras' => $_SESSION['search.params']['extras'], 'packages' => $_SESSION['search.params']['packages'], 'pricetype' => $_SESSION['search.params']['pricetype'], 'rateplanId' => $_SESSION['search.params']['rateplanId'], 'state' => 'booking' , 'variationPlanId' => $_SESSION['search.params']['variationPlanId'], 'gotCalculator' => false);
    $redirect = $formData['Redirect'];
    $redirecterror = $formData['Redirecterror'];
    $isgateway = $formData['isgateway'];
    $otherData = "paxages:" . str_replace("]", "", str_replace("[", "", $req['paxages'])) . "|" . "checkin_eta_hour:" . $formData['checkin_eta_hour'];
    $ccdata = null;
    if (RSFormHelper::canAcquireCCData($formData)) {
        $ccdata = json_encode(RSFormHelper::getCCardData($formData));
        $ccdata = BFCHelper::encrypt($ccdata);
    }
    $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, $otherData, $ccdata);
    $orderData['pricetype'] = $req['pricetype'];
    //  $orderData['label'] = 'developerdemo';
    $orderData['label'] = $formData['label'];
    $processOrder = null;
    /*
    		if(!empty($isgateway) && ($isgateway =="true" ||$isgateway =="1")){
    			$processOrder=false;
    		}
    */
    $order = BFCHelper::setOrder($orderData['customerData'], $orderData['suggestedStay'], $orderData['creditCardData'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode'], $processOrder, $orderData['pricetype']);
    if (empty($order)) {
        $order = "";
        $redirect = $redirecterror;
    }
    if (!empty($order)) {
        if (!empty($isgateway) && ($isgateway == "true" || $isgateway == "1")) {
            wp_redirect(get_site_url() . '/payment/?orderId=' . $order->OrderId);
            exit;
        } else {
            $numAdults = 0;
            $persons = explode("|", $suggestedStay->Paxes);
            foreach ($persons as $person) {
                $totper = explode(":", $person);
                $numAdults += (int) $totper[1];
            }
            $startDate = DateTime::createFromFormat('Y-m-d', BFCHelper::parseJsonDate($order->StartDate, 'Y-m-d'));
            $endDate = DateTime::createFromFormat('Y-m-d', BFCHelper::parseJsonDate($order->EndDate, 'Y-m-d'));
            $redirect = $redirect . '?act=Order&orderid=' . $order->OrderId . '&merchantid=' . $order->MerchantId . '&OrderType=' . $order->OrderType . '&OrderTypeId=' . $order->OrderTypeId . '&totalamount=' . $order->TotalAmount * 100 . '&startDate=' . $startDate->format('Y-m-d') . '&endDate=' . $endDate->format('Y-m-d') . '&numAdults=' . $numAdults;
            wp_redirect($redirect);
            exit;
        }
    }
}
 function sendOrder()
 {
     $formData = $_POST['form'];
     if (empty($formData)) {
     }
     $customer = RSFormHelper::getCustomerData($formData);
     $suggestedStay = json_decode($formData['staysuggested']);
     $req = json_decode($formData['stayrequest'], true);
     $redirect = $formData['Redirect'];
     $redirecterror = $formData['Redirecterror'];
     $isgateway = $formData['isgateway'];
     // eta persone
     $otherData = "paxages:" . str_replace("]", "", str_replace("[", "", implode($req['paxages'], ',')));
     $ccdata = null;
     if (RSFormHelper::canAcquireCCData($formData)) {
         $ccdata = json_encode(RSFormHelper::getCCardData($formData));
         $ccdata = BFCHelper::encrypt($ccdata);
         //			$ccdata = RSFormHelper::getCCardData($formData);
     }
     $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, $otherData, $ccdata);
     $orderData['pricetype'] = $req['pricetype'];
     $orderData['label'] = $formData['label'];
     $processOrder = null;
     if (!empty($isgateway) && ($isgateway == "true" || $isgateway == "1")) {
         $processOrder = false;
     }
     $order = BFCHelper::setOrder($orderData['customerData'], $orderData['suggestedStay'], $orderData['creditCardData'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode'], $processOrder, $orderData['pricetype']);
     if (empty($order)) {
         $order = "";
         $redirect = $redirecterror;
     }
     if (!empty($order)) {
         if (!empty($isgateway) && ($isgateway == "true" || $isgateway == "1")) {
             $redirect = JRoute::_('index.php?view=payment&orderId=' . $order->OrderId);
         } else {
             $numAdults = 0;
             $persons = explode("|", $suggestedStay->Paxes);
             foreach ($persons as $person) {
                 $totper = explode(":", $person);
                 $numAdults += (int) $totper[1];
             }
             $startDate = DateTime::createFromFormat('Y-m-d', BFCHelper::parseJsonDate($order->StartDate, 'Y-m-d'));
             $endDate = DateTime::createFromFormat('Y-m-d', BFCHelper::parseJsonDate($order->EndDate, 'Y-m-d'));
             $redirect = $redirect . '?orderid=' . $order->OrderId . '&merchantid=' . $order->MerchantId . '&totalamount=' . $order->TotalAmount * 100 . '&startDate=' . $startDate->format('Y-m-d') . '&endDate=' . $endDate->format('Y-m-d') . '&numAdults=' . $numAdults;
         }
         //			$urlredirpayment = JRoute::_('index.php?view=payment&orderId=' . $order->OrderId);
         //			$redirect = JRoute::_('index.php?view=payment&orderId=' . $order->OrderId);
     }
     //		echo json_encode($return);
     $app = JFactory::getApplication();
     $app->redirect($redirect, false);
     $app->close();
 }