Subversion Repositories SmartDukaan

Rev

Rev 17987 | Rev 18001 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 17987 Rev 17997
Line 284... Line 284...
284
        // $("#showmore").empty();
284
        // $("#showmore").empty();
285
        $("#showmore").html('Show More');    
285
        $("#showmore").html('Show More');    
286
    }
286
    }
287
});
287
});
288
 
288
 
289
 
-
 
290
$(document).on("click", "form input[type=submit]", function() {
289
$(document).on("click", "form input[type=submit]", function() {
-
 
290
    $('#message').empty();
-
 
291
    var name = document.getElementById("name").value;
-
 
292
    var line1 = document.getElementById("line1").value;
-
 
293
    var city = document.getElementById("city").value;
-
 
294
    var phone = document.getElementById("phone").value;
-
 
295
    var state = document.getElementById("state").value;
-
 
296
    var pin = document.getElementById("pin").value;
-
 
297
    var message ="";
-
 
298
    var value = "true";
-
 
299
    if(name == '')
-
 
300
    {
-
 
301
       value = "false";
-
 
302
       message = "Please fill name field!";
-
 
303
    }
-
 
304
    else if(line1 == '')
-
 
305
    {
-
 
306
        value = "false";
-
 
307
        message = "Please fill address field!";
-
 
308
    }
-
 
309
    else if(city == '')
-
 
310
    {
-
 
311
        value = "false";
-
 
312
        message = "Please fill city field!";
-
 
313
    }
-
 
314
    
-
 
315
    else if(phone == '')
-
 
316
    {
-
 
317
        value = "false";
-
 
318
        message = "Please fill contact number field!";    
-
 
319
        
-
 
320
    }
-
 
321
 
-
 
322
    else if(phone.match(/^\d{10}$/) == null)
-
 
323
    {
-
 
324
        value = "false";
-
 
325
        message = "Invalid contact number";    
-
 
326
    }
-
 
327
 
-
 
328
    else if(state == '')
-
 
329
    {
-
 
330
        value = "false";
-
 
331
        message = "Please fill state field!";
-
 
332
    }
-
 
333
    else if(pin == '')
-
 
334
    {
-
 
335
 
-
 
336
        value = "false";
-
 
337
        message = "Please fill pin field!";
-
 
338
    }
-
 
339
    else if(pin.match(/^\d{6}$/) == null)
-
 
340
    {
-
 
341
        value = "false";
-
 
342
        message = "Invalid contact number";    
-
 
343
    }
-
 
344
 
-
 
345
    if(value == "false")
-
 
346
    {
-
 
347
        $('#message').append(message);
-
 
348
        $('#message').removeClass('hidden');
-
 
349
        setTimeout(function() {
-
 
350
                    $('#message').addClass('hidden');
-
 
351
                }, 2000);  
-
 
352
        return false;
-
 
353
    }
-
 
354
    else{
-
 
355
 
291
        $("input[type=submit]", $(this).parents("form")).removeAttr("clicked");
356
        $("input[type=submit]", $(this).parents("form")).removeAttr("clicked");
292
        $(this).attr("clicked", "true");
357
        $(this).attr("clicked", "true");
-
 
358
    }
-
 
359
        
293
});
360
});
294
 
361
 
295
$(document).on('submit', '#form2', function(e){
362
$(document).on('submit', '#form2', function(e){
296
	var payOption = $("input[type=submit][clicked=true]").data('name');
363
    var payOption = $("input[type=submit][clicked=true]").data('name');
297
	var formData = {
364
    var formData = {
298
        'name'              : $('#name').val(),
365
        'name'              : $('#name').val(),
299
        'line1'             : $('#line1').val(),
366
        'line1'             : $('#line1').val(),
300
        'city'    			: $('#city').val(),
367
        'city'              : $('#city').val(),
301
        'phone'				: $('#phone').val(),
368
        'phone'             : $('#phone').val(),
302
        'state'				: $('#state').val(),
369
        'state'             : $('#state').val(),
303
        'pin'				: $('#pin').val()
370
        'pin'               : $('#pin').val()
304
    };
371
    };
305
    $.ajax(
372
    $.ajax(
306
    	{
373
    {
307
                method: "POST",
374
        method: "POST",
308
                url:  apihost + "shippings/submitcheck",
375
        url:  apihost + "shippings/submitcheck",
309
                data: formData,
376
        data: formData,
310
        },'json')
377
    },'json')
311
        .done(function(msg){ 
378
    .done(function(msg){ 
312
    	if(msg==''){	
379
        if(msg==''){    
313
    		window.location.replace(apihost + "shippings/index/"+msg);
380
            window.location.replace(apihost + "shippings/index/"+msg);
314
    	} else {
381
        } else {
315
    		if(payOption=='cod'){
382
            if(payOption=='cod'){
316
    			confirmCheckout(msg);
383
                confirmCheckout(msg);
317
    		} else if (payOption=='other_option'){
384
            } else if (payOption=='other_option'){
318
    			confirmPrepaid(msg);
385
                confirmPrepaid(msg);
319
    		}
386
            }
320
    	}    	                    
387
        }                           
321
	});
388
    });
322
	return false; 
389
    return false;    
-
 
390
 
323
});
391
});
324
 
392
 
325
function confirmPrepaid(addressid){
393
function confirmPrepaid(addressid){
326
	if (typeof addressid=="undefined"){
394
	if (typeof addressid=="undefined"){
327
		addressid=$("input.css-checkbox:checked").val();
395
		addressid=$("input.css-checkbox:checked").val();