{"id":1052,"date":"2025-10-19T14:07:01","date_gmt":"2025-10-19T14:07:01","guid":{"rendered":"https:\/\/wonderbirdholidays.com\/?page_id=1052"},"modified":"2025-10-19T15:00:58","modified_gmt":"2025-10-19T15:00:58","slug":"crm","status":"publish","type":"page","link":"https:\/\/wonderbirdholidays.com\/?page_id=1052","title":{"rendered":"crm"},"content":{"rendered":"\n<div class=\"wrap\">\n  <div class=\"card\">\n    <h2>Travel Booking<\/h2>\n    <p class=\"lead\">Fill the details below \u2014 your booking request will open in WhatsApp and an order will be created.<\/p>\n\n    <form id=\"travelForm\" autocomplete=\"on\">\n      <div class=\"full\">\n        <label for=\"serviceType\">Service Type<\/label>\n        <select id=\"serviceType\" required>\n          <option value=\"\">&#8212; Select Service &#8212;<\/option>\n          <option value=\"Flights\">Flights<\/option>\n          <option value=\"Visa\">Visa<\/option>\n          <option value=\"Tour Packages\">Tour Packages<\/option>\n        <\/select>\n      <\/div>\n\n      <!-- Flights Section -->\n      <div class=\"two flight-field\">\n        <label for=\"fromCity\">From<\/label>\n        <input type=\"text\" id=\"fromCity\" placeholder=\"City \/ Airport\"\/>\n      <\/div>\n      <div class=\"two flight-field\">\n        <label for=\"toCity\">To<\/label>\n        <input type=\"text\" id=\"toCity\" placeholder=\"City \/ Airport\"\/>\n      <\/div>\n      <div class=\"two flight-field\">\n        <label for=\"departDate\">Departure Date<\/label>\n        <input type=\"date\" id=\"departDate\"\/>\n      <\/div>\n      <div class=\"two flight-field\">\n        <label for=\"returnDate\">Return Date (Optional)<\/label>\n        <input type=\"date\" id=\"returnDate\"\/>\n      <\/div>\n\n      <!-- Visa Section -->\n      <div class=\"two visa-field\" style=\"display:none;\">\n        <label for=\"visaCountry\">Visa Country<\/label>\n        <input type=\"text\" id=\"visaCountry\" placeholder=\"e.g. Dubai, Singapore\"\/>\n      <\/div>\n      <div class=\"two visa-field\" style=\"display:none;\">\n        <label for=\"visaType\">Visa Type<\/label>\n        <input type=\"text\" id=\"visaType\" placeholder=\"Tourist \/ Business\"\/>\n      <\/div>\n\n      <!-- Tour Package Section -->\n      <div class=\"two package-field\" style=\"display:none;\">\n        <label for=\"packageDestination\">Package Destination<\/label>\n        <input type=\"text\" id=\"packageDestination\" placeholder=\"e.g. Kerala, Bali\"\/>\n      <\/div>\n      <div class=\"two package-field\" style=\"display:none;\">\n        <label for=\"travelDate\">Travel Date<\/label>\n        <input type=\"date\" id=\"travelDate\"\/>\n      <\/div>\n\n      <!-- Common -->\n      <div class=\"two\">\n        <label for=\"guestName\">Name<\/label>\n        <input type=\"text\" id=\"guestName\" required placeholder=\"Full name\"\/>\n      <\/div>\n      <div>\n        <label for=\"guestMobile\">Mobile<\/label>\n        <input type=\"tel\" id=\"guestMobile\" required placeholder=\"10-digit number\"\/>\n      <\/div>\n      <div>\n        <label for=\"guestEmail\">Email (Optional)<\/label>\n        <input type=\"email\" id=\"guestEmail\" placeholder=\"you@example.com\"\/>\n      <\/div>\n      <div class=\"full\">\n        <label for=\"extraNotes\">Notes (Optional)<\/label>\n        <textarea id=\"extraNotes\" placeholder=\"Any special request or additional details\"><\/textarea>\n      <\/div>\n\n      <div class=\"actions\">\n        <button type=\"submit\" id=\"submitBtn\">SUBMIT<\/button>\n      <\/div>\n      <div id=\"formStatus\" class=\"status\"><\/div>\n    <\/form>\n  <\/div>\n<\/div>\n\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function(){\n  const serviceType = document.getElementById(\"serviceType\");\n  const flightFields = document.querySelectorAll(\".flight-field\");\n  const visaFields = document.querySelectorAll(\".visa-field\");\n  const packageFields = document.querySelectorAll(\".package-field\");\n  const form = document.getElementById(\"travelForm\");\n  const statusDiv = document.getElementById(\"formStatus\");\n  const submitBtn = document.getElementById(\"submitBtn\");\n\n  serviceType.addEventListener(\"change\", function(){\n    const type = this.value;\n    [flightFields, visaFields, packageFields].forEach(set => set.forEach(el=>el.style.display=\"none\"));\n    if (type === \"Flights\") flightFields.forEach(el=>el.style.display=\"block\");\n    if (type === \"Visa\") visaFields.forEach(el=>el.style.display=\"block\");\n    if (type === \"Tour Packages\") packageFields.forEach(el=>el.style.display=\"block\");\n  });\n\n  form.addEventListener(\"submit\", function(e){\n    e.preventDefault();\n    submitBtn.disabled = true;\n    statusDiv.textContent = \"\";\n\n    const type = serviceType.value;\n    const name = document.getElementById(\"guestName\").value.trim();\n    const mobile = document.getElementById(\"guestMobile\").value.trim();\n    const email = document.getElementById(\"guestEmail\").value.trim();\n    const notes = document.getElementById(\"extraNotes\").value.trim();\n\n    let message = `\ud83d\udccc Vihari Tourism Booking Request\\n\\n\ud83e\uddfe Service: ${type}\\n\ud83d\udc64 Name: ${name}\\n\ud83d\udcde Mobile: ${mobile}`;\n    if(email) message += `\\n\u2709\ufe0f Email: ${email}`;\n\n    if(type===\"Flights\"){\n      message += `\\n\ud83d\udeeb From: ${document.getElementById(\"fromCity\").value.trim()}\\n\ud83d\udeec To: ${document.getElementById(\"toCity\").value.trim()}\\n\ud83d\udcc5 Departure: ${document.getElementById(\"departDate\").value}`;\n      if(document.getElementById(\"returnDate\").value) message += `\\n\ud83d\udcc5 Return: ${document.getElementById(\"returnDate\").value}`;\n    }\n\n    if(type===\"Visa\"){\n      message += `\\n\ud83c\udf0d Country: ${document.getElementById(\"visaCountry\").value.trim()}\\n\ud83d\udcc4 Visa Type: ${document.getElementById(\"visaType\").value.trim()}`;\n    }\n\n    if(type===\"Tour Packages\"){\n      message += `\\n\ud83c\udfd6 Destination: ${document.getElementById(\"packageDestination\").value.trim()}\\n\ud83d\udcc5 Travel Date: ${document.getElementById(\"travelDate\").value}`;\n    }\n\n    if(notes) message += `\\n\ud83d\udcdd Notes: ${notes}`;\n\n    const encodedMsg = encodeURIComponent(message);\n    const waLink = `https:\/\/wa.me\/91${mobile}?text=${encodedMsg}`;\n    window.open(waLink, \"_blank\");\n\n    \/\/ --- AJAX to create WooCommerce order ---\n    fetch('<?php echo admin_url(\"admin-ajax.php\"); ?>', {\n      method:'POST',\n      headers:{'Content-Type':'application\/x-www-form-urlencoded'},\n      body: new URLSearchParams({\n        action:'create_travel_order',\n        service:type,\n        name:name,\n        mobile:mobile,\n        email:email,\n        notes:notes,\n        from:type===\"Flights\"?document.getElementById(\"fromCity\").value.trim():\"\",\n        to:type===\"Flights\"?document.getElementById(\"toCity\").value.trim():\"\",\n        depart:type===\"Flights\"?document.getElementById(\"departDate\").value:\"\",\n        ret:type===\"Flights\"?document.getElementById(\"returnDate\").value:\"\",\n        country:type===\"Visa\"?document.getElementById(\"visaCountry\").value.trim():\"\",\n        vType:type===\"Visa\"?document.getElementById(\"visaType\").value.trim():\"\",\n        dest:type===\"Tour Packages\"?document.getElementById(\"packageDestination\").value.trim():\"\",\n        tDate:type===\"Tour Packages\"?document.getElementById(\"travelDate\").value:\"\"\n      })\n    }).then(res=>res.json())\n      .then(data=>{\n        if(data.success){\n          statusDiv.className = \"status success\";\n          statusDiv.textContent += ` | WooCommerce Order Created: #${data.data}`;\n        } else {\n          statusDiv.className = \"status error\";\n          statusDiv.textContent += \" | WooCommerce Order Failed\";\n        }\n        submitBtn.disabled = false;\n        form.reset();\n      }).catch(err=>{\n        console.error(err);\n        statusDiv.className = \"status error\";\n        statusDiv.textContent += \" | WooCommerce AJAX Error\";\n        submitBtn.disabled = false;\n      });\n\n    statusDiv.textContent = \"\u2705 Booking details sent to WhatsApp!\";\n    statusDiv.classList.add(\"success\");\n  });\n});\n<\/script>\n\n<script>\ndocument.addEventListener(\"DOMContentLoaded\", function(){\n  const form = document.getElementById(\"travelForm\");\n  const statusDiv = document.getElementById(\"formStatus\");\n  const submitBtn = document.getElementById(\"submitBtn\");\n\n  form.addEventListener(\"submit\", function(e){\n    e.preventDefault();\n    submitBtn.disabled = true;\n    statusDiv.textContent = \"\";\n\n    const service = document.getElementById(\"serviceType\").value;\n    const name = document.getElementById(\"guestName\").value.trim();\n    const mobile = document.getElementById(\"guestMobile\").value.trim();\n    const email = document.getElementById(\"guestEmail\").value.trim();\n    const notes = document.getElementById(\"extraNotes\").value.trim();\n\n    \/\/ Collect extra fields\n    let extraData = {};\n    if(service === \"Flights\"){\n      extraData.fromCity = document.getElementById(\"fromCity\").value.trim();\n      extraData.toCity = document.getElementById(\"toCity\").value.trim();\n      extraData.departDate = document.getElementById(\"departDate\").value;\n      extraData.returnDate = document.getElementById(\"returnDate\").value;\n    } else if(service === \"Visa\"){\n      extraData.visaCountry = document.getElementById(\"visaCountry\").value.trim();\n      extraData.visaType = document.getElementById(\"visaType\").value.trim();\n    } else if(service === \"Tour Packages\"){\n      extraData.packageDestination = document.getElementById(\"packageDestination\").value.trim();\n      extraData.travelDate = document.getElementById(\"travelDate\").value;\n    }\n\n    \/\/ Send AJAX request\n    const formData = new FormData();\n    formData.append('action','create_travel_order');\n    formData.append('service', service);\n    formData.append('name', name);\n    formData.append('mobile', mobile);\n    formData.append('email', email);\n    formData.append('notes', notes);\n\n    for(const key in extraData){\n      formData.append(key, extraData[key]);\n    }\n\n    fetch(travel_ajax.ajax_url, { method: 'POST', body: formData })\n      .then(res => res.json())\n      .then(data => {\n        if(data.success){\n          statusDiv.textContent = `\u2705 Order #${data.data.order_id} created successfully! Opening WhatsApp...`;\n          statusDiv.className = \"status success\";\n\n          \/\/ Open WhatsApp with all details\n          const waLink = `https:\/\/wa.me\/91${mobile}?text=${encodeURIComponent(data.data.message)}`;\n          window.open(waLink, \"_blank\");\n          form.reset();\n        } else {\n          statusDiv.textContent = \"\u274c Failed to create order.\";\n          statusDiv.className = \"status error\";\n        }\n        submitBtn.disabled = false;\n      })\n      .catch(err => {\n        console.error(err);\n        statusDiv.textContent = \"\u274c Error sending request.\";\n        statusDiv.className = \"status error\";\n        submitBtn.disabled = false;\n      });\n  });\n});\n<\/script>\n\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Travel Booking Fill the details below \u2014 your booking request will open in WhatsApp and an order will be created. Service Type &#8212; Select Service &#8212;FlightsVisaTour Packages From To Departure Date Return Date (Optional) Visa Country Visa Type Package Destination Travel Date Name Mobile Email (Optional) Notes (Optional) SUBMIT<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1052","page","type-page","status-publish","hentry"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=\/wp\/v2\/pages\/1052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1052"}],"version-history":[{"count":5,"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=\/wp\/v2\/pages\/1052\/revisions"}],"predecessor-version":[{"id":1056,"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=\/wp\/v2\/pages\/1052\/revisions\/1056"}],"wp:attachment":[{"href":"https:\/\/wonderbirdholidays.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}