Esempio n. 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;
        }
    }
}
Esempio n. 2
0
 function sendOnSellrequest()
 {
     $formData = $_POST['form'];
     $customer = RSFormHelper::getCustomerData($formData);
     $suggestedStay = null;
     $redirect = $formData['Redirect'];
     $otherData = [];
     if (!empty($formData['resourceId'])) {
         $sStay = array('UnitId' => $formData['resourceId']);
         $suggestedStay = new stdClass();
         foreach ($sStay as $key => $value) {
             $suggestedStay->{$key} = $value;
         }
         $otherData["UnitId:"] = "UnitId:" . $formData['resourceId'];
     }
     if (!empty($formData['pageurl'])) {
         $otherData["pageurl:"] = "pageurl:" . $formData['pageurl'];
     }
     if (!empty($formData['title'])) {
         $otherData["title:"] = "title:" . $formData['title'];
     }
     if (!empty($formData['resourceId'])) {
         $otherData["onsellunitid:"] = "onsellunitid:" . $formData['resourceId'];
     }
     if (!empty($formData['accettazione'])) {
         $otherData["accettazione:"] = "accettazione:" . RSFormHelper::getOptionsFromSelect($formData, 'accettazione');
     }
     $orderData = BFCHelper::prepareOrderData($formData, $customer, $suggestedStay, implode("|", $otherData), null);
     $orderData['processOrder'] = true;
     $orderData['label'] = $this->formlabel;
     $return = BFCHelper::setInfoRequest($orderData['customerData'], $orderData['suggestedStay'], $orderData['otherNoteData'], $orderData['merchantId'], $orderData['orderType'], $orderData['userNotes'], $orderData['label'], $orderData['cultureCode'], $orderData['processOrder']);
     if (empty($return)) {
         $return = "";
     }
     echo json_encode($return);
     $app = JFactory::getApplication();
     $app->redirect($redirect, false);
     $app->close();
 }