示例#1
0
function inforequest_process()
{
    $formData = isset($_POST['form']) ? $_POST['form'] : $_POST;
    $checkin = isset($formData['CheckIn']['date']) ? $formData['CheckIn']['date'] : $formData['CheckIn'];
    $checkout = isset($formData['CheckOut']['date']) ? $formData['CheckOut']['date'] : $formData['CheckOut'];
    $customer = RSFormHelper::getCustomerData($formData);
    $suggestedStay = null;
    $redirect = $formData['Redirect'];
    $otherData = "persone:" . RSFormHelper::getOptionsFromSelect($formData, 'Totpersons') . "|" . "accettazione:" . RSFormHelper::getOptionsFromSelect($formData, 'accettazione');
    if (!empty($checkin) && !empty($checkout)) {
        $sStay = array('CheckIn' => DateTime::createFromFormat('d/m/Y', $checkin)->format('Y-m-d\\TH:i:sO'), 'CheckOut' => DateTime::createFromFormat('d/m/Y', $checkout)->format('Y-m-d\\TH:i:sO'));
        if ($formData['orderType'] == 'c') {
            //    $sStay['UnitId'] = '11' .$formData['resourceId'];
            $resourceid = 0;
            if (!empty($formData['resourceId'])) {
                $resourceid = $formData['resourceId'];
            }
            if (!empty($_REQUEST['resourceid'])) {
                $resourceid = $_REQUEST['resourceid'];
            }
            if (!empty($_POST['resourceid'])) {
                $resourceid = $_POST['resourceid'];
            }
            $sStay['UnitId'] = $resourceid;
        }
        $suggestedStay = new stdClass();
        foreach ($sStay as $key => $value) {
            $suggestedStay->{$key} = $value;
        }
        $otherData .= "|" . "CheckIn:" . DateTime::createFromFormat('d/m/Y', $checkin)->format('Y-m-d') . "|" . "CheckOut:" . DateTime::createFromFormat('d/m/Y', $checkout)->format('Y-m-d');
        if ($formData['orderType'] == 'c') {
            $resourceid = 0;
            if (!empty($formData['resourceId'])) {
                $resourceid = $formData['resourceId'];
            }
            if (!empty($_REQUEST['resourceid'])) {
                $resourceid = $_REQUEST['resourceid'];
            }
            if (!empty($_POST['resourceid'])) {
                $resourceid = $_POST['resourceid'];
            }
            $otherData = $otherData . "|" . "UnitId:" . $resourceid;
        }
    } else {
        if (!empty($formData['resourceId'])) {
            $sStay = array('UnitId' => $formData['resourceId']);
            $suggestedStay = new stdClass();
            foreach ($sStay as $key => $value) {
                $suggestedStay->{$key} = $value;
            }
            $otherData .= "|" . "UnitId:" . $formData['resourceId'];
        }
    }
    $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, $otherData, null);
    $orderData['processOrder'] = true;
    $orderData['label'] = $formData['label'];
    //echo '<PRE>';print_r($orderData);die();
    $return = BFCHelper::setInfoRequest($orderData['customerData'], $orderData['suggestedStay'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode'], $orderData['processOrder']);
    if (!empty($return)) {
        if ($orderData['orderType'] == 'c') {
            wp_redirect($redirect);
            exit;
        } else {
            wp_redirect($redirect);
            exit;
        }
    }
}
 function sendScalarRequest()
 {
     $formData = $_POST['form'];
     $customer = RSFormHelper::getCustomerData($formData);
     $redirect = $formData['Redirect'];
     // create otherData (string)
     $otherData = "adulti:" . RSFormHelper::getOptionsFromSelect($formData, 'TotPersons') . "|" . "bambini:" . RSFormHelper::getOptionsFromSelect($formData, 'Totchildrens') . "|" . "etabambini:" . $formData['ChildrenAge'] . "|" . "tipologiastruttura:" . RSFormHelper::getOptionsFromSelect($formData, 'merchantcategory') . "|" . "trattamento:" . RSFormHelper::getOptionsFromSelect($formData, 'treatments') . "|" . "maxrisposte:" . RSFormHelper::getOptionsFromSelect($formData, 'Maxresponse') . "|" . "accettazione:" . RSFormHelper::getOptionsFromSelect($formData, 'accettazione');
     $suggestedStay = null;
     // create SuggestedStay
     if ($formData['CheckIn'] != null && $formData['CheckOut'] != null) {
         $sStay = array('CheckIn' => DateTime::createFromFormat('d/m/Y', $formData['CheckIn'])->format('Y-m-d\\TH:i:sO'), 'CheckOut' => DateTime::createFromFormat('d/m/Y', $formData['CheckOut'])->format('Y-m-d\\TH:i:sO'));
         $suggestedStay = new stdClass();
         foreach ($sStay as $key => $value) {
             $suggestedStay->{$key} = $value;
         }
         $otherData .= "|" . "CheckIn:" . DateTime::createFromFormat('d/m/Y', $formData['CheckIn'])->format('Y-m-d') . "|" . "CheckOut:" . DateTime::createFromFormat('d/m/Y', $formData['CheckOut'])->format('Y-m-d');
     }
     $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, $otherData, null);
     $orderData['processOrder'] = true;
     $orderData['label'] = $this->formlabel;
     $order = BFCHelper::setOrder($orderData['customerData'], $orderData['suggestedStay'], $orderData['creditCardData'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode']);
     /*if (isset($order))
     			$thankYouMessage = "Grazie";
     		else
     		$thankYouMessage = "Errore invio dati";*/
     if (empty($order)) {
         $order = "";
     }
     echo json_encode($order);
     $app = JFactory::getApplication();
     $app->redirect($redirect, false);
     $app->close();
 }