403Webshell
Server IP : 103.234.187.230  /  Your IP : 216.73.216.216
Web Server : Apache
System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/html/b2bzend/public/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/b2bzend/public/js/city.js
/**
 * @author  : Ranvir Singh
 * @Created : 01 Sep 2016
 * @Updated : 26 May 2017
 * This file is used for all city profiling functions 
 */

$(function() {
    
    $.validator.setDefaults({
        /*OBSERVATION (1): note the options used for "ignore"*/
        ignore: ':not(select:hidden, input:visible, textarea:visible)',
        /*...other options omitted to focus on the OP...*/
    });
    
   $.validator.addMethod("noStartEndWhiteSpaces", function(value, element) {
    return this.optional(element) || /^[a-zA-Z0-9](?:[a-zA-Z0-9 ]*[a-zA-Z0-9])?$/.test(value);
    }, "Spaces or special characters not allowed.");

    $.validator.addMethod("noStartEndWhiteSpacesAlpha", function(value, element) {
    return this.optional(element) || /^[a-zA-Z](?:[a-zA-Z ]*[a-zA-Z])?$/.test(value);
    }, "Number not allowed.");

    $.validator.addMethod("validPassport", function(value, element) {
    return this.optional(element) || /^([A-Z]{1})([0-9]{7})$/.test(value);
    }, "Passport number is not valid.");

    
    $("#addCityForm").validate({
        ignore: '*:not([name])',
//        debug: true,
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
        ignore: [],
        rules : {
            'country_id' : {required : true},
//            'state_listing' : {required : true},
            'cityname' : {required : true, noStartEndWhiteSpacesAlpha : true},
//            'citycategory[]': {required : true }
		},
        messages : {
            country_id : "Please select Country",
//            state_listing : "Please select State",
            cityname : { 'required' : "Please fill city name", 'noStartEndWhiteSpacesAlpha' : "Please fill valid city name" },
//            citycategory : "Please select city category",
        }
    });
	
	
        

// place for activity in the city form validation

    $("#activity_add_form").validate({
        ignore: '*:not([name])',
        //debug: true,
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
//        ignore: [],
        rules : {
            'Title' : {required : true},
//            'groupType' : {required : true},
//            'ActivitiesType' : {required : true},
            'Address' : {required : true},
            'WriteUp' : {required : true}
            },
        messages : {
            Title : "Please fill title",
//            groupType : "Please select option",
//            ActivitiesType : "Please select option",
            Address : "Please fill address",
            WriteUp : "Please fill activity details"
        }
    });
    
    
// place for events form validation

    $("#events_add_form").validate({
        ignore: '*:not([name])',
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
        rules : {
            Title : {required : true},
            Address : {required : true},
            ChrgPerAdult : {required : true , number : true},
            ChrgPerKid : {required : true , number : true}
            },
        messages : {
            Title : "Please fill title first",
            Address : "Please fill complete address",
            ChrgPerAdult : {required : "Please fill Adult charge", number : "Please fill numbers only" },
            ChrgPerKid : {required : "Please fill Kid charge", number : "Please fill numbers only"}
        }
    });
    
    
// place for sightseeing form validation

    $("#sightseeing_add_form").validate({
        ignore: '*:not([name])',
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
        rules : {
            SightseeingName : {required : true},
            Address : {required : true},
            WriteUp : {required : true}
            },
        messages : {
            SightseeingName : "Please fill title first",
            Address : "Please fill complete address",
            WriteUp : "Please fill sightseeing details"
        }
    });
    
    
    
    
// city add images form validation

    $("#city_images_form").validate({
        ignore: '*:not([name])',
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
        rules : {
            Title : {required : true},
            AltTag : {required : true},
            IsPrimary : {required : true},
            Seq : {required : true, digits :true}
            },
        messages : {
            Title : "Please fill image title",
            AltTag : "Please fill alt tag for image",
            IsPrimary : "Please select primary type",
            Seq : { 'required' : "Please fill image sequence", 'digits' : "Please fill Numbers only" }
        }
    });


    $("#places-to-eat-form").validate({
        ignore: '*:not([name])',
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
        rules : {
            CuisineMask : {required : true},
            Title : {required : true},
            NightLifeCatId : {required : true},
            start_from : {required : true},
            start_to : {required : true},
            Address : {required : true},
            IsIDRequired : {required : true}
            },
        messages : {
            CuisineMask : "Please select cuisine type",
            Title : "Please fill title",
            NightLifeCatId : "Please select category",
            start_from : "Please fill start date",
            start_to : "Please fill end date",
            Address : "Please fill complete Address",
            IsIDRequired : "Please select option"
        }
    });


// place for events form validation

    $("#places-for-shopping-form").validate({
        ignore: '*:not([name])',
        highlight: function (error, element) {
            var name = $(element).attr("name");
            $("input[name=" + name + "]").removeClass('error');
        },
        rules : {
            LocAddress : { required : true }
            },
        messages : {
            LocAddress : "Please fill Location Name"
        }
    });




//
//$('.datePickerOnly').datetimepicker({
//    format:'Y-m-d',
//    timepicker:false,
//    minDate: 0
//});
                

$('.timePickerOnly').datetimepicker({
    format:'h:i a',
    datepicker:false,
});
                
        //  var strDepartureDate = new Date($('#oneway_departure_date').val()); 
		//  alert(strDepartureDate)
        $('.datePickerOnly').datetimepicker({
			format:'Y-m-d',
			onShow:function( ct ){ //alert(ct)
				var day = ct.getDate(); // month (in integer 0-11)
				// var month = ct.getMonth() + 1; // month (in integer 0-11) // not allow to select previous date from current
				var month = ct.getMonth(); // month (in integer 0-11)
				var year = ct.getFullYear(); // year
				
			   this.setOptions({
				 minDate:year+"/"+month+"/"+day
			   })
			},
			timepicker:false
        });


/*
 *  function is used to add Why to Visit in overview > City profiling
 */
$("#whyShouldVisitSave").click(function(){
    
    var whyShouldVisitStr   = $("#whyShouldVisit").val();
    var CityId              = $("#CityId_hidden").val();
    var $addButton          = $(this);

    if(whyShouldVisitStr != '') {
        $addButton.attr('disabled',true);
        $.ajax({
            beforeSend : showLoader('whyShouldVisitAddLoader'), // show loader param as id where to show loader image
            url  : '/cityprofiling/overview/reason-to-visit',
            data : {whyShouldVisitStr : whyShouldVisitStr, CityId : CityId },
            type : 'POST',
            dataType : 'json',
            success : function(response) {
                hideLoader('whyShouldVisitAddLoader'); // hide loader
                $("#whyShouldVisit").val('');
                $("#reasonToVisitListing_contDiv").append('<div class="col-md-4" style="margin:5px 0px;">\n\
<a href="javascript:void(0);" title="Delete" id="'+ response.ReasonToVisitSysId +'" class="reasonToVisitSysId btn btn-xs btn-danger btn-round orange"><i class="fa fa-times"></i></a> <span>'+ response.reason +'</span>\n\
</div>');
                $("#messageContainerReasonToVisit").html(response.successMsg).css({'color':'#5CB85C','font-weight':'normal',display:'block'}).fadeOut(3000);

                setTimeout(function(){$("#messageContainerReasonToVisit").html("");}, 2000);
                $addButton.attr('disabled', false);
            }
        });
    }
    else {
        alert('Please fill the text first.');
        $('#whyShouldVisit').focus();
    }
    
});



/*
 *  function is used to delete Why to Visit in overview > City profiling
 */
$("#reasonToVisitListing_contDiv").on('click','.reasonToVisitSysId',function(){
    var $ReasonToVisitSysId = $(this).attr('id');
    var $selectedRecord = $(this).parent();
    
    if($ReasonToVisitSysId != '') {
        $.ajax({
            beforeSend : showLoader('messageContainerReasonToVisit'), // show loader param as id where to show loader image
            url  : '/cityprofiling/overview/reason-to-visit-delete',
            data : { ReasonToVisitSysId : $ReasonToVisitSysId },
            type : 'POST',
            dataType : 'json',
            success : function(response) {
                hideLoader('messageContainerReasonToVisit'); // hide loader
                $("#messageContainerReasonToVisit").html(response.successMsg).css({'color':'#5CB85C','font-weight':'normal',display:'block'}).fadeOut(3000);
                setTimeout(function(){$("#messageContainerReasonToVisit").html("");}, 2000);
                $selectedRecord.remove();
            }
        });
    }
});



$("#add_row_shop").click(function(){
    
    var data = '<div class="rv_row">\n\
 <div class="col-md-4"> <div class="form-group"> <label>Where to BUY</label> <input class="form-control google_places" type="text" name="Title[]" placeholder="Shop Name" value="" onblur="getShopDetails(this);" maxlength="200" />\n\
 <input type="hidden" class="latitude" name="Latitude[]"  /> <input type="hidden" class="longitude" name="Longitude[]"  /> </div> </div>\n\
 <div class="col-md-4"> <div class="form-group"> <label>Address</label> <input class="form-control shpp_formatted_address" type="text" name="Address[]" value="" placeholder="Address" maxlength="200" /> </div> </div>\n\
 <div class="col-md-3"> <div class="form-group"> <label>Contact Number</label> <input class="form-control" type="text" name="ContactNumber[]" placeholder="Contact Number" value="" maxlength="12" /> </div> </div>\n\
 <div class="col-md-1"> <div class="form-group"><a href="javascript:void(0);" class="remove_row red" onclick="removeme(this);"><i class="fa fa-times red"></i> Remove</a></div> </div>\n\
 <div class="clear"></div> </div>';
    
    
    $("#rows_div").append(data);
});




});  // jquery end




function removeme(ev)
{
    $(ev).parent().parent().parent().remove();
}



function getStateAjax(){
    var data = $('#country_code').val();

    $.ajax({
        url: '/cityprofiling/index/getstateajax',
        data: 'countrycode='+data,
        type: 'POST',
        beforeSend: function (data) {

        },
        success: function (response) {
                $("#state_listing").html(response);
        },
        error:function(){
                alert("fail : Please try after some time");
        }
    });	
}

function getCityAjax(){
	var cid = $('#country_code').val();
	var sid = $('#state_listing').val();
	
	$.ajax({
		url: '/city/getcityajax',
		data: 'countryid=' + cid + '&stateid=' +sid,
		type: 'POST',
		beforeSend: function (data) {
			
		},
		success: function (response) {
			$("#city_listing").html(response);
		},
		error:function(){
			alert("fail : Please try after some time");
		}
	});	
				
}



function getOpDiv()
{
    var max_fields = 3,
    srt = 2, //initlal text box count
    OperatingTimeCounter = $("#OperatingTimeCounter").val(),
    loader_span = 'id_loader_span';
    
    if(OperatingTimeCounter < 3) {
        $.ajax({
            url  : '/cityprofiling/activities/get-operating-time-div',
            data : { max_fields : max_fields, srt : srt, OperatingTimeCounter : OperatingTimeCounter },
            type : 'POST',
            dataType : 'html',
            beforeSend : showLoader(loader_span), // show loader
            success : function(response) {
                if(!isEmpty(response))
                {
                    $(".items_timeslots").append(response);
                    $("#OperatingTimeCounter").val(   parseInt($("#OperatingTimeCounter").val()) + 1 );
                    hideLoader(loader_span); // hide loader
                }
            }
        });
    }
}

function deleteOpTimeDiv(srt)
{
    $('div#opt_time_remove_' + srt).remove().animate('slow'); 
    srt = srt -1;  
    $("#OperatingTimeCounter").val(   parseInt($("#OperatingTimeCounter").val()) - 1 );
    
}




function getLatLongOverview() {

//    var $select = $("#ContSysId").selectize();
//    var ContSelectize = $select[0].selectize;
//    var country = ContSelectize.getItem(ContSelectize.getValue())[0].innerHTML;
//
//    var $select = $("#StateSysId").selectize();
//    var StateSelectize = $select[0].selectize;
//    var state = StateSelectize.getItem(StateSelectize.getValue())[0].innerHTML;
//  

    var city    = $("#City_Title").val();
    var state   = $("#state_listing").val();
    var country = $("#country_code").val();

    var addressSTR = city + ' ' + state + ' ' + country;
    

    var ev = $("#City_Title");
    
    /*
     * hitting ajax in below function
     * param : input Object, Address string, Latitude input field id, Longitude input field id, address input field id, loader/spinner span id
    */
    getPlaceDetails( ev , addressSTR, 'GetLat', 'GetLong', '', 'spinner_latlong' );
    
}



function getLatLong() {

    var Title = $("#Title").val();
    var address = $("#Address1").val();

    var addressStr = Title + ' ' + address;
    
    if(!$.trim(Title)) {
        alert("Please fill Title first.");
        return false;
    }
    
    $.ajax({
        beforeSend : showLoader('getLatLong_anchor_span'), // show loader
        url  : '/cityprofiling/index/getlocation',
        data : {address : addressStr},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            console.log(response);
            $("#Latitude").val(response.latitude);
            $("#Longitude").val(response.longitude);
            hideLoader('getLatLong_anchor_span'); // hide loader
        }
     });
}


// getLatLongLocationGeneral function is used for city shopping

function getLatLongLocationGeneral(ev) {

    var Title = $(ev).val();

    var addressStr = Title ;
    var latitude_ID = "latitude";
    var longitude_ID = "longitude";

    if(!$.trim(Title)) {
        alert("Please fill Title first.");
        return false;
    }
    // run the ajax
    getLatLongLocationGeneralAjax(addressStr, latitude_ID, longitude_ID);
}


function getLatLongLocationGeneralAjax(addressStr, latitude_ID, longitude_ID) {

    
    if(!$.trim(addressStr)) {
        alert("Please fill string first.");
        return false;
    }
    
    $.ajax({
        url  : '/cityprofiling/index/getlocation',
        data : {address : addressStr},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            
            $("#"+latitude_ID).val(response.latitude);
            $("#"+longitude_ID).val(response.longitude);
            
        }
     });
}


// getLatLongShop function is used for city shopping

function getLatLongLocation(ev) {

    var Title = $(ev).val();

    var addressStr = Title ;
    
    if(!$.trim(Title)) {
        alert("Please fill Title first.");
        return false;
    }
    
    $.ajax({
        url  : '/cityprofiling/index/getlocation',
        data : {address : addressStr},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            $(ev).next('.latitude').val(response.latitude).next('.longitude').val(response.longitude);
        }
     });
}


// getLatLongShop function is used for city shopping

function getShopDetails(ev) {

    var Title = $(ev).val();

    var addressStr = Title ;
    
    if(!$.trim(Title)) {
        alert("Please fill Title first.");
        return false;
    }
    
    $.ajax({
        url  : '/cityprofiling/index/get-place-details',
        data : {address : addressStr},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            response    = response[0];
            
            var formatted_address = response.formatted_address;
            var latitude = response.geometry.location.lat;
            var longitude = response.geometry.location.lng;
            
            $(ev).next('.latitude').val(latitude).next('.longitude').val(longitude);
            $(ev).parent().parent().next().children().children('.shpp_formatted_address').val(formatted_address);
        }
     });
}


function getPlaceDetails( ev , addressSTR, latID, longID, addressID , getLatLong_anchor_span ) {


    if(addressSTR =='')
      var addressStr = $(ev).val();
    else
      var addressStr = addressSTR;
    
    if(!$.trim(addressStr)) {
        alert("Please fill Title first.");
        return false;
    }
    
    $.ajax({
        beforeSend : showLoader(getLatLong_anchor_span), // show loader
        url  : '/cityprofiling/index/get-place-details',
        data : {address : addressStr},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            response    = response[0];
            
            var formatted_address = response.formatted_address;
            var latitude = response.geometry.location.lat;
            var longitude = response.geometry.location.lng;
            
            $('#'+latID).val(latitude);
            $('#'+longID).val(longitude);
            $('#'+addressID).val(formatted_address);
            hideLoader(getLatLong_anchor_span); // hide loader param id where loader was assigned
        }
    });
}


// Checks the entry into Database if already exists or not

function checkEntry(is_sightseeing_from_google, param , master_city_id, master_city_name, place_city_name)
{
    var myvalue='';
    var ajx = $.ajax({
        url  : '/general/is-exists',
        data : { str : param , is_sightseeing_from_google : is_sightseeing_from_google, master_city_id : master_city_id , master_city_name : master_city_name , place_city_name : place_city_name },
        async: false ,
        type : 'POST' ,
        dataType : 'json' ,
        success : function(response) {
            if(response.message === 'success') {
                myvalue += response;
                                
            }
        },
        error : function(request, status, error){
            // error
        }
        
    });
    
    return myvalue;
}


// sightseeing result based on google places API

function getSightseeingDetails(ev)
{
    var Title = $(ev).val();
    
    var addressStr = Title ;
    var checkExists= '';
    
    if(!$.trim(Title)) {
        alert("Please fill Title first.");
        return false;
    }
    var $loader_id = 'sightseeing_loader';
    
    var latitude_ID = "latitude";
    var longitude_ID= "longitude";
    var Address_ID  = "Address";
    var locality_ID = "locality_ID";
    var city_ID     = "city_ID";
    var state_ID    = "state_ID";
    var country_ID  = "country_ID";

    $.ajax({
        url  : '/cityprofiling/index/get-place-details',
        data : {address : addressStr},
        type : 'POST',
        dataType : 'json',
        beforeSend : function() {
            showLoader($loader_id)
            $("button#submit_myform").attr('disabled', false);
            $("#sightseeing_response").html('');
        },
        success : function(response) {
//alert(response);
            if(response != '') {
                
                response    = response[0];
                var gplace = {};
                gplace.obj = response;

                var formatted_address = response.formatted_address;

                var latitude = response.geometry.location.lat;
                var longitude = response.geometry.location.lng;

                $("#"+latitude_ID).val(latitude);
                $("#"+longitude_ID).val(longitude);
                $("#"+Address_ID).val(formatted_address);
                $("#is_sightseeing_from_google").val(1);

                gplace.pdetails = (google_places_parse_json_response( gplace ));

                if(gplace.pdetails.administrative_area_level_2){
                  $("#"+city_ID).val(gplace.pdetails.administrative_area_level_2);
                }
                else if(gplace.pdetails.administrative_area_level_1){
                  $("#"+city_ID).val(gplace.pdetails.administrative_area_level_1);
                }
                else if(gplace.pdetails.locality) {
                  $("#"+city_ID).val(gplace.pdetails.locality);
                }

                $("#"+state_ID).val(gplace.pdetails.administrative_area_level_1);
                $("#"+country_ID).val(gplace.pdetails.country);
                $("#"+locality_ID).val(gplace.pdetails.locality);
                
                if(!$("#"+city_ID).val())
                    $("#"+city_ID).val($('#'+state_ID).val());
                
                // start : code for checking the entry exists or not
                // collect the other helping variables
                    var is_sightseeing_from_google  = $('#is_sightseeing_from_google').val();
                    var master_cont_id      = $('#popupContId').val();
                    var master_city_id      = $('#popupCitySysId').val();
                    var master_city_name    = $('#master_city_name').val();
                    var place_city_name     = $("#"+city_ID).val();
                    var place_cont_name     = $("#"+country_ID).val();


//                    checkExists = checkEntry(is_sightseeing_from_google, addressStr, master_city_id, master_city_name , place_city_name );

                    $.ajax({
                        url  : '/general/is-exists',
                        data : { str : addressStr , is_sightseeing_from_google : is_sightseeing_from_google, master_cont_id : master_cont_id , master_city_id : master_city_id , master_city_name : master_city_name , place_city_name : place_city_name , place_cont_name : place_cont_name },
                        async: false ,
                        type : 'POST' ,
                        dataType : 'json' ,
                        success : function(response) {
                            if(response.message === 'success') {
                                checkExists = response;
//                                console.log(checkExists.msg);
                                if(checkExists.msg == 'NOT_MAPPED') {
                                    
                                    $("#sightseeing_response").css({'display':'block',color : '#f00'}).
                                        html('Sightseeing already exists in '+place_city_name+'. <a href="/cityprofiling/sightseeing/mapping?master_city='+master_city_id+'&place_city_id='+checkExists.place_city_id+'&SSSysId='+checkExists.SSSysId+'&city='+master_city_name+'"\n\
                                               onclick="return confirm(\'Are you sure? Map this sightseeing with '+master_city_name+'.\');" >Map With '+master_city_name+'</a>');
                                    $("button#submit_myform").attr('disabled', true);
                                
                                }
                                else if(checkExists.msg == 'ALREADY_MAPPED') {

                                    $("#sightseeing_response").css({'display':'block',color : '#f00'}).html('Sightseeing already mapped with city : '+ checkExists.MAPPED_CITY +
                                        '. <a href="/cityprofiling/sightseeing/mapping?master_city='+master_city_id+'&place_city_id='+checkExists.place_city_id+'&SSSysId='+checkExists.SSSysId+'&city='+master_city_name+'"\n\
                                               onclick="return confirm(\'Are you sure? Map this sightseeing with '+ master_city_name +'.\');" >Map With '+master_city_name+' Also</a>');
                                    $("button#submit_myform").attr('disabled', true);
                                
                                }
                                else if(checkExists.msg == 'ALREADY_MAPPED_FOR_SAME') {

                                    $("#sightseeing_response").css({'display':'block',color : '#f00'}).html('Sightseeing already mapped with city : '+checkExists.MAPPED_CITY );
                                    $("button#submit_myform").attr('disabled', true);
                                
                                }
                                else if(checkExists.msg == 'ALREADY_EXISTS') {

                                    $("#sightseeing_response").css({'display':'block',color : '#f00'}).html('Sightseeing already exists in city. <a href="">Add Another One</a>');
                                    $("button#submit_myform").attr('disabled', true);
                                
                                }
                                else if(checkExists.msg == 'NEW_ENTRY') {
                                    $("button#submit_myform").attr('disabled', false);
                                }
                                
                                
                                
                            }
                        },
                        error : function(request, status, error){
                            // error
                        }
                    });

                    
                    

                // end : code for checking the entry exists or not
                
            }
            else {
//                alert('nothing found.');
                $("#sightseeing_response").css({'display':'block',color : '#f00'}).html('Nothing Found!');
                $("#is_sightseeing_from_google").val('');
                $("#"+latitude_ID).val('');
                $("#"+longitude_ID).val('');
                $("#"+Address_ID).val('');
                $("#"+city_ID).val('');
                $("#"+state_ID).val('');
                $("#"+country_ID).val('');
                $("#"+locality_ID).val('');
            }
            // end : IF
            hideLoader($loader_id);
            
        }
        
     });
}


function getHotelDetails(ev)
{
    var Title       = $(ev).val(),
        cityid      = $('#popupCitySysId').val(),
        $loader_id  = 'spinner_loading' ;
    
    if(!$.trim(Title)) {
        alert("Please choose Hotel first.");
        return false;
    }
    
    $.ajax({
        url  : '/cityprofiling/hotels/get-hotel-details',
        data : { AccomSysId : Title, cityid : cityid },
        type : 'POST',
        dataType : 'json',
        beforeSend : showLoader($loader_id),
        success : function(response) {

          if(response == null) {
              $("#" + $loader_id).html('Nothing Found !').css({display :'block', color : '#f00', 'margin-right' : '6px'}); // if no result found in GTX database
          }
          else {
            var $r = response;
            var GTXRating   = $r.GTXRating,
                Rating      = $r.Rating,
                GTXComment  = $r.GTXComment,
                MinPriceRange   = $r.MinPriceRange,
                MaxPriceRange   = $r.MaxPriceRange,
                Stars       = $r.Stars;
            
            $('#GTXRating').val(GTXRating);
            $('#GTXComment').val(GTXComment);
            $('#Rating').val(Rating);
            $('#Stars').val(Stars);
            $('#MinPriceRange').val(MinPriceRange);
            $('#MaxPriceRange').val(MaxPriceRange);
            
            if($r.AccoAminitiesMask) {
                var array = $.map($r.AccoAminitiesMask, function(value, index) {
                    return [value];
                });
                for(var rv=0; rv < (array.length); rv++) {
                    $('#amenity_checkbox_'+array[rv]).prop('checked',true);
                }
            }
            
            // hide the loader spin
            hideLoader($loader_id);

          }
            
        }
     });
}


function getd(placeid)
{
    var placesService = new google.maps.places.PlacesService(map);
    placesService.getDetails(
        {placeId: placeid },
        function(results, status) {
            console.log(status);
            console.log(results); 
        }
    );
}



// for sightseeing country listing

function getPopupCityList(countryId) 
{
    if(countryId!='' && countryId!='0')
    {
        $("#popupCitySysId").parent().append('<img src="/public/assets/images/loader.gif" alt="Loading..." />');
        $("#popupCitySysId").prop("disabled",true);
        $.ajax({
            url  : '/sightseeing/get-city-details-list',
            data : { countryId : countryId},
            dataType : 'html',
            type : 'POST',
            error : function() {

            },
            beforeSend : function() {

            },
            success : function(response) { 
                $("#popupCitySysId").html(response);
                $("#popupCitySysId").prop("disabled",false);
                $("#popupCitySysId").parent().find('img').remove(); 
            }
        });
    } else {
        $("#popupCitySysId").html('<option vaue="0">Select City</option>');  
    }
}


function showLoader(id)
{
    $("#"+id).html('<img src="/public/assets/images/loading.gif" alt="Loading..." width="20" />');
}
function hideLoader(id)
{
    $("#"+id).html('');
}
	  
	
// for city profiling > others tab

function save_culture($type)
{
    var $selector   = ($type=='1') ? $("#culture_dos") : $("#culture_dont");
    var $loader_id  = ($type=='1') ? 'culture_do_anchor_span' : 'culture_dont_anchor_span';
    
    var culture_text = $selector.val();
    var CityId_hidden= $("#CityId_hidden").val();

    if(!$.trim(culture_text)) {
        alert("Please fill culture text first.");
        $selector.focus();
        return false;
    }
    
    $.ajax({
        beforeSend : showLoader($loader_id), // show loader
        url  : '/cityprofiling/index/city-culture',
        data : {culture_text : culture_text, type : $type, CityId : CityId_hidden},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            
            if(response.status=='success') {
                var msg = (response.successMsg);
                var colorcode   = '#5CB85C';
            }
            else {
                var msg = (response.errorMsg);
                var colorcode   = '#f00';
            }
            $("#culture_success_msg"+$type).html(msg).css({'color':colorcode,'font-weight':'normal',display:'block'}).fadeOut(3000);  // show action message
            $selector.val(''); // make empty to input box

            $("#new_data"+$type).html(response.data);
            
            hideLoader($loader_id); // hide loader
        }
     });
}

// for deleting culture dos and donts
function delete_culture($type, $sid)
{
    if(!rv_confirm())
    {
        return false; // if not confirm
    }

    var $selector   = ($type=='1') ? $("#culture_dos") : $("#culture_dont");
    var $loader_id  = ($type=='1') ? 'culture_do_anchor_span' : 'culture_dont_anchor_span';
    
    if(!($sid && $type)) {
        alert("Something went wrong!");
        return false;
    }
    
    $.ajax({
        beforeSend : showLoader($loader_id), // show loader
        url  : '/cityprofiling/index/culture-delete',
        data : {sid : $sid, type : $type},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            
            if(response.status=='success') {
                var msg = (response.successMsg);
                var colorcode   = '#5CB85C';
            }
            else {
                var msg = (response.errorMsg);
                var colorcode   = '#f00';
            }
            $("#culture_success_msg"+$type).html(msg).css({'color':colorcode,'font-weight':'normal',display:'block'}).fadeOut(3000); // show action message
            $("#culture_tr_"+ $type + '_' +$sid).remove(); // remove the row which is deleted from database
            hideLoader($loader_id); // hide loader
        }
    });
}


// ajax delete city images on overview page
function deleteCityImage(CityId , id_loader_span)
{
    if( rv_confirm() )
    {
        $.ajax({
            beforeSend : showLoader(id_loader_span), // show loader
            url  : '/cityprofiling/overview/delete-city-image',
            data : { CityId : CityId },
            type : 'POST',
            dataType : 'json',
            success : function(response) {
                hideLoader(id_loader_span); // hide loader
                if(response.status=='success'){
                    $("#div_container_image").remove();
                }
            }
        });

    }
    else {
        return;
    }
}


// for city profiling > others tab > add emergency contact numbers

function save_emergency_contact()
{
    var $loader_id  = 'ec_loader_span';

    var ec_isd      = $("#ec_isd").val();
    var ec_type     = $("#ec_type").val();
    var ec_number   = $("#ec_number").val();
    var CityId_hidden   = $("#CityId_hidden").val();

    if(!$.trim(ec_isd)) {
        alert("Please fill ISD Code first.");
        $("#ec_isd").focus();
        return false;
    }
    if(!$.trim(ec_type)) {
        alert("Please select Type of Contact.");
        $("#ec_type").focus();
        return false;
    }
    if(!$.trim(ec_number)) {
        alert("Please fill contact number.");
        $("#ec_number").focus();
        return false;
    }
    
    $.ajax({
        beforeSend : showLoader($loader_id), // show loader
        url  : '/cityprofiling/index/city-emergency-contact',
        data : {ec_isd : ec_isd, ec_type : ec_type, ec_number : ec_number, CityId : CityId_hidden},
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            
            if(response.status=='success') {
                var msg = (response.successMsg);
                var colorcode   = '#5CB85C';
            }
            else {
                var msg = (response.errorMsg);
                var colorcode   = '#f00';
            }
            $("#ec_success_msg").html(msg).css({'color':colorcode,'font-weight':'normal',display:'block'}).fadeOut(3000);  // show action message
            $("#ec_isd, #ec_number").val(''); // make empty to input box
            
            var $select = $('#ec_type');  // This initializes the selectize control
            var selectize = $select[0].selectize; // This stores the selectize object to a variable (with name 'selectize')
            selectize.setValue('*', false);

            $("#new_data_ec").html(response.data);
            
            hideLoader($loader_id); // hide loader
        }
     });
}


// for deleting emergengy contacts
function delete_ec($sid)
{
    if(!rv_confirm())
    {
        return false; // if not confirm
    }

    var $loader_id  = 'ec_loader_span';
    
    if(!$sid ) {
        alert("Something went wrong!");
        return false;
    }
    
    $.ajax({
        beforeSend : showLoader($loader_id), // show loader
        url  : '/cityprofiling/index/ec-delete',
        data : {sid : $sid },
        type : 'POST',
        dataType : 'json',
        success : function(response) {
            
            if(response.status=='success') {
                var msg = (response.successMsg);
                var colorcode   = '#5CB85C';
            }
            else {
                var msg = (response.errorMsg);
                var colorcode   = '#f00';
            }
            $("#ec_success_msg").html(msg).css({'color':colorcode,'font-weight':'normal',display:'block'}).fadeOut(3000); // show action message
            $("#ec_tr_" +$sid).remove(); // remove the row which is deleted from database
            hideLoader($loader_id); // hide loader
        }
    });
}


function rv_confirm()
{
    return confirm('Are you sure you want to delete the selected record?');
}

Youez - 2016 - github.com/yon3zu
LinuXploit