File: //proc/self/cwd/nueva/modules/roja45quotationsprofree/views/js/roja45quotationspro_summary17.js
/**
* roja45quotationspro_order.js.
*
* @author Roja45
* @copyright 2016 Roja45
* @license license.txt
*
* 2016 ROJA45 - All rights reserved.
*
* DISCLAIMER
* Changing this file will render any support provided by us null and void.
*/
$(document).ready(function () {
$(".quote_quantity").TouchSpin({
verticalbuttons: true,
verticalupclass: 'material-icons touchspin-up',
verticaldownclass: 'material-icons touchspin-down',
buttondown_class: 'btn btn-touchspin js-touchspin',
buttonup_class: 'btn btn-touchspin js-touchspin',
min: 1,
max: 1000000
});
$(document.body).on('click', '.request-quotation', function (e) {
e.preventDefault();
if (roja45quotationspro_summary.processSend()) {
roja45quotationspro_summary.submitForm();
}
});
});
roja45quotationspro_summary = {
processSend : function() {
var url = $('#quotationspro_request_form').attr('action')
var errors = 0;
$('#quotationspro_request_form').find('input.validate', 'textarea.validate').each(function (index, value) {
if ($(this).hasClass('is_required')) {
var invalid = false;
if ($(this).val().length == 0) {
invalid = true;
} else if ($(this).attr('data-validate') != 'none') {
if ($(this).attr('name') == 'postcode' && typeof(countriesNeedZipCode[$('#id_country option:selected').val()]) != 'undefined')
var result = window['validate_' + $(this).attr('data-validate')]($(this).val(), countriesNeedZipCode[$('#id_country option:selected').val()]);
else
var result = window['validate_' + $(this).attr('data-validate')]($(this).val())
if (result) {
invalid = false;
} else {
invalid = true;
}
}
if (invalid) {
$(this).parent().addClass('form-error').removeClass('form-ok');
errors++;
} else {
$(this).parent().removeClass('form-error').addClass('form-ok');
}
}
});
if (errors == 0) {
//roja45quotationspro_summary.submitForm(source);
return true;
} else {
//source.preventDefault();
return false;
}
},
submitForm: function () {
$('.btn.btn-default.request-quotation').prop('disabled', 'disabled').addClass('disabled');
var request = {};
request.columns = [];
$('#quotationspro_request_form .quotationspro_request.column').each(function (i) {
var column = {};
var heading = $(this).find('.page-subheading').html();
column.heading = heading;
// column id
var col = $(this).data('column');
column.num = col;
column.fields = [];
$(this).find('.form-control').each(function (j) {
var label = $(this).closest('.form-group').find('.control-label').html();
var field = {};
field.pos = j;
field.name = $(this).attr('name');
field.label = label.trim();
field.value = $(this).val();
column.fields[j] = field;
});
request.columns[i] = column;
});
var json = JSON.stringify(request);
$('input[name=ROJA45QUOTATIONSPRO_FORMDATA]').val(json);
$('#quotationspro_request_form').submit();
},
}