3 window._w.customervaluation = {
12 highestOfferId : false,
14 publicCentreList : {},
17 onCustomerValuationViewTemplateReady : function( template, event, eventData )
19 _w.customervaluation.itemData = null;
20 _w.customervaluation.ti = _t[template];
21 _w.customervaluation.limited = false;
23 _w.customervaluation.setValuationViewFormMeta();
24 // Retrieve initial view data.
25 _w.customervaluation.itemId = 0;
27 _w.customervaluation.newItem = true;
28 _w.customervaluation.itemData = {stock:{}};
31 onCustomerValuationViewPublished : function( template, event, eventData )
34 App.DataStore.loadSelectListData(
35 'years', false, 'Stock', 'Year.SelectList', null,
38 App.DataStore.loadSelectListData(
39 'categories', false, 'Stock', 'Category.SelectList', null,
42 App.DataStore.loadSelectListData(
43 'fuelTypes', false, 'Stock', 'FuelType.SelectList', null,
46 App.DataStore.loadSelectListData(
47 'transmissionTypes', false, 'Stock', 'TransmissionType.SelectList', null,
50 App.DataStore.loadSelectListData(
51 'fsh', false, 'Stock', 'FullServiceHistory.SelectList', null,
55 App.DataStore.loadSelectListData(
56 'regions', false, 'Location', 'Region.SelectListNames', null,
59 "name" : ['Gauteng','Western Cape','KwaZulu-Natal']
64 'publicCentreList', 'Company', 'Company.SelectGrid', null, {},
68 'publicCentreList', {}, {},
69 $.proxy(function(response)
71 _w.customervaluation.publicCentreList = {};
72 for (var i in response.Data.DataSet)
74 var company = response.Data.DataSet[i];
75 if (undefined == _w.customervaluation.publicCentreList[company.city.region.id])
77 _w.customervaluation.publicCentreList[company.city.region.id] = [];
79 _w.customervaluation.publicCentreList[company.city.region.id].push({
94 'createCustomerValuation', 'Valuation', 'Valuation.CreateCustomerPublic',
95 null, {}, function(){}, _w.taskContractError
98 App.DataStore.setData('sparekeys', [{"value":"1", "label":"Yes"}, {"value":"0", "label":"No"}]);
101 // Do a check here for the ie browser - if ie show upload file buttons
102 // IE browsers prevent submitting files when the input field didn't receive a direct click
104 if(navigator.appVersion.indexOf("MSIE ")!=-1)
106 $('#terms').parent().addClass("IE");
111 _w.customervaluation.limited = false;
112 _w.customervaluation._setupValidation();
114 $('.back-btn').on('click', function(){
115 window.history.back();
118 $('#btnContinue1').click(function () {
120 $('.btn-next').click();
123 $('#btnContinue2').click(function () {
125 $('.btn-next').click();
128 $('#btnContinue3').click(function () {
131 firstName: {required: true, minlength: 3},
132 familyName: {required: true, minlength: 3},
133 email: {required: true, email: true},
134 confirmEmail: {required: true, email: true, equalTo: "#email"},
135 mobile: {required: true, mobile: true},
136 region: {required: true},
137 city: {required: false},
138 publicCentre: {required: true},
139 street: {required: false},
140 requiredPrice: {required: true, number: true, min: 0.01},
141 vehicleYear: "required",
142 vehicleCategory: "required",
143 vehicleMake: "required",
144 vehicleModel: "required",
145 vehicleType: "required",
146 vehicleFuelType: "required",
147 vehicleTransmissionType: "required",
148 registrationNumber: "required",
149 fullServiceHistory: "required",
150 km: { required: true, digits: true }
152 $('#frmCustomerValuationView').validate({
156 minlength: "This field is required."
159 minlength: "This field is required."
162 required: "This field is required.",
163 email: "Please enter a valid<br/>email address."
166 required: "This field is required.",
167 email: "Please enter a valid<br/>email address.",
168 equalTo: "Please enter the same<br/>value again."
171 required: "This field is required.",
172 number: "Please enter a valid amount.",
173 min: "Please enter a<br/>valid amount."
175 vehicleYear : "This field is required.",
176 vehicleCategory : "This field is required.",
177 vehicleMake : "This field is required.",
178 vehicleModel : "This field is required.",
179 vehicleType : "This field is required.",
180 vehicleFuelType : "This field is required.",
181 vehicleTransmissionType : "This field is required.",
182 fullServiceHistory : "This field is required.",
183 registrationNumber : "This field is required.",
184 km : {required: "This field is required."}
186 invalidHandler: function(event, validator) {
187 var errors = validator.numberOfInvalids();
188 if (0 < _w.customervaluation.validations && errors) {
189 var message = errors == 1
190 ? 'You missed 1 field. It has been highlighted'
191 : 'You missed ' + errors + ' fields. They have been highlighted';
194 _w.customervaluation.validations++;
196 submitHandler: function( form ) {
201 _w.customervaluation.validations = 0;
202 var formValid = $('#frmCustomerValuationView').valid();
206 var confirmationOfvehicleYear = $('#vehicleYear option:selected').text();
207 var confirmationOfcategory = $('#vehicleCategory option:selected').text();
208 var confirmationOfmake = $('#vehicleMake option:selected').text();
209 var confirmationOfmodel = $('#vehicleModel option:selected').text();
210 var confirmationOftype = $('#vehicleType option:selected').text();
211 var confirmationOffullServiceHistory = $('#fullServiceHistory option:selected').text();
212 var confirmationOffuelType = $('#vehicleFuelType option:selected').text();
213 var confirmationOftransmissionType = $('#vehicleTransmissionType option:selected').text();
214 var confirmationOfkm = $('#km').val();
215 var confirmationOfregistrationNumber = $('#registrationNumber').val();
216 var confirmationOffirstName = $('#firstName').val();
217 var confirmationOffamilyName = $('#familyName').val();
218 var confirmationOfmobile = $('#mobile').val();
219 var confirmationOfemail = $('#email').val();
220 var confirmationOfregion = $('#region option:selected').text();
221 var confirmationOfpublicCentre = $('#publicCentre option:selected').text();
222 var confirmationOfrequiredPrice = $('#requiredPrice').val();
224 //var confirmationOfInfoHtml =
225 // '<div class="span5 offset1">'
226 // + '<h4>Customer information:<h4>'
228 // + '<h5>' + confirmationOffirstName + ' ' + confirmationOffamilyName + '<h5>'
230 // + '<h5>' + confirmationOfmobile + '<h5>'
232 // + '<h5>' + confirmationOfemail + '<h5>'
234 // + '<div class="span6">'
235 // + '<h4>Vehicle Information:<h4>'
237 // + '<h5>' + confirmationOfvehicleYear + '<h5>'
238 // + '<h5>' + confirmationOfmake + '<h5>'
239 // + '<h5>' + confirmationOfmodel + '<h5>'
240 // + '<h5>' + confirmationOftype + '<h5>'
241 // + '<h5>' + confirmationOfkm + ' Kms<h5>'
242 // + '<h5>' + confirmationOfregistrationNumber + '<h5>'
243 // + '<h5>' + confirmationOffuelType + '<h5>'
244 // + '<h5>' + confirmationOftransmissionType + '<h5>'
248 var confirmationOfInfoHtml =
249 '<div class="span5">'
250 + '<h4><u>Customer information:</u><h4>'
252 + '<div class="span12">'
253 + '<span class="text-h4 span4">Customer: </span>'
254 + '<span class="text-h5 span8">' + confirmationOffirstName + ' ' + confirmationOffamilyName + '</span>'
256 + '<div class="span12">'
257 + '<span class="text-h4 span4">Cell Number: </span>'
258 + '<span class="text-h5 span8">+27' + confirmationOfmobile + '</span>'
260 + '<div class="span12">'
261 + '<span class="text-h4 span4">Email: </span>'
262 + '<span class="text-h5 span8">' + confirmationOfemail + '</span>'
265 + '<div class="span6">'
266 + '<h4><u>Vehicle Information:</u><h4>'
268 + '<div class="span12">'
269 + '<span class="text-h4 span4">Year: </span>'
270 + '<span class="text-h5 span8">' + confirmationOfvehicleYear + '</span>'
272 + '<div class="span12">'
273 + '<span class="text-h4 span4">Make: </span>'
274 + '<span class="text-h5 span8">' + confirmationOfmake + '</span>'
276 + '<div class="span12">'
277 + '<span class="text-h4 span4">Model: </span>'
278 + '<span class="text-h5 span8">' + confirmationOfmodel + '</span>'
280 + '<div class="span12">'
281 + '<span class="text-h4 span4">Mileage: </span>'
282 + '<span class="text-h5 span8">' + confirmationOfkm + '</span>'
284 + '<div class="span12">'
285 + '<span class="text-h4 span4">Registration: </span>'
286 + '<span class="text-h5 span8">' + confirmationOfregistrationNumber + '</span>'
288 + '<div class="span12">'
289 + '<span class="text-h4 span4">Transmission: </span>'
290 + '<span class="text-h5 span8">' + confirmationOftransmissionType + '</span>'
292 + '<div class="span12">'
293 + '<span class="text-h4 span4">Fuel Type: </span>'
294 + '<span class="text-h5 span8">' + confirmationOffuelType + '</span>'
300 $('#confirmationOfInfo').html(confirmationOfInfoHtml);
302 $('.btn-next').click();
306 $('label.error').remove();
307 $('.valid').removeClass('valid');
312 $('#terms').change($.proxy(function () {
314 console.log('terms checked',$('#terms').is(':checked'));
316 if($('#terms').is(':checked'))
318 $('#btnContinue4').prop('disabled', false);
322 $('#btnContinue4').prop('disabled', true);
327 $('#btnContinue4').click(function () {
328 //$('#frmCustomerValuationView').submit();
329 _w.customervaluation._setupValidation();
331 var data = _w.customervaluation._prepValuationUpdateData();
333 'createCustomerValuation', data, {},
334 _w.customervaluation._onValuationUpdated,
335 _w.customervaluation._onValuationFail
338 $('.btn-prev').click($.proxy(function () {
339 _w.customervaluation.currentStep--;
341 $('.btn-next').click($.proxy(function () {
342 $('.btn-next').prop('disabled', true);
343 _w.customervaluation.currentStep++;
344 _w.customervaluation.validatePage(_w.customervaluation.currentStep);
346 $('.btn-next').prop('disabled', true);
347 $('#btnContinue1').prop('disabled', true);
348 $('#btnContinue4').prop('disabled', true);
351 _w.customervaluation.ti.hydrate(_w.customervaluation.formMeta);
355 validatePage : function(step)
363 '#vehicleYear': true,
364 '#vehicleCategory': true,
365 '#vehicleMake': true,
366 '#vehicleModel': true,
372 '#vehicleFuelType': true,
373 '#vehicleTransmissionType': true,
374 '#fullServiceHistory': true,
385 '#publicCentre': true
391 for (var field in fields)
393 if ('' !== $(field).val() && null !== $(field).val())
395 if (!$(field).valid())
397 $('.btn-next').prop('disabled', true);
398 $('#btnContinue' + step).prop('disabled', true);
402 else if (fields[field])
404 $('.btn-next').prop('disabled', true);
405 $('#btnContinue' + step).prop('disabled', true);
413 $('.btn-next').prop('disabled', false);
414 $('#btnContinue' + step).prop('disabled', false);
417 //$('.btn-next').prop('disabled', false);
418 //$('#btnContinue' + step).prop('disabled', false);
422 setValuationViewFormMeta : function()
425 _w.customervaluation.formMeta = {
430 dataStoreId : 'years',
431 value : data.stock.vehicleYear ? data.stock.vehicleYear : '',
432 onChange : function (evt) {
433 if (!App.DataStore.getItem('BuildSelect:vehicleYear', false))
435 _w.customervaluation._listMakesModelsTypes();
437 var value = $(evt.currentTarget).val();
438 if (null == value || '' == value)
442 _w.customervaluation.validatePage(1);
447 id : 'vehicleCategory',
449 dataStoreId : 'categories',
450 value : data.stock.type ? data.stock.type.category.id : '',
451 onChange : function (evt) {
452 if (!App.DataStore.getItem('BuildSelect:vehicleCategory', false))
454 _w.customervaluation._listMakesModelsTypes();
456 var value = $(evt.currentTarget).val();
457 if (null == value || '' == value)
461 _w.customervaluation.validatePage(1);
467 title : 'Vehicle Make',
468 dataStoreId : 'makes',
469 value : data.stock.type ? data.stock.type.model.make.id : '',
470 onChange : function (evt) {
471 if (!App.DataStore.getItem('BuildSelect:vehicleMake', false))
473 _w.customervaluation._listMakesModelsTypes();
475 var value = $(evt.currentTarget).val();
476 if (null == value || '' == value)
480 _w.customervaluation.validatePage(1);
486 title : 'Vehicle Model',
487 dataStoreId : 'models',
488 value : data.stock.type ? data.stock.type.model.id : '',
489 onChange : function (evt) {
490 if (!App.DataStore.getItem('BuildSelect:vehicleModel', false))
492 _w.customervaluation._listMakesModelsTypes();
494 var value = $(evt.currentTarget).val();
495 if (null == value || '' == value)
499 _w.customervaluation.validatePage(1);
505 title : 'Vehicle Type',
506 dataStoreId : 'types',
507 value : data.stock.type ? data.stock.type.id : '',
508 onChange : function (evt) {
509 var value = $(evt.currentTarget).val();
510 if (null == value || '' == value)
515 'TransUnionFromMmCode', 'Stock', 'Utility.TransUnionFromMmCode', null,
516 {}, _w.customervaluation._onTuReady, _w.taskContractError
519 'GetMmCode' + $(this).val(), 'Stock', 'Type.GetMmCode', null,
520 {id:$(this).val()}, function(response){
521 $('#mmCode').html(response.Data.mmCode);
522 }, _w.taskContractError
524 _w.customervaluation.validatePage(1);
531 id : 'vehicleFuelType',
533 dataStoreId : 'fuelTypes',
534 value : data.stock.fuelType ? data.stock.fuelType : '',
535 onChange : function (evt) {
536 var value = $(evt.currentTarget).val();
537 if (null == value || '' == value)
541 _w.customervaluation.validatePage(2);
544 'transmissionType' : {
546 id : 'vehicleTransmissionType',
547 title : 'Transmission Type',
548 dataStoreId : 'transmissionTypes',
549 value : data.stock.transmissionType ? data.stock.transmissionType : '',
550 onChange : function (evt) {
551 var value = $(evt.currentTarget).val();
552 if (null == value || '' == value)
556 _w.customervaluation.validatePage(2);
559 'registrationNumber' : {
561 id : 'registrationNumber',
562 title : 'Registration no',
563 value : data.stock.registrationNumber ? data.stock.registrationNumber : '',
564 style : 'capitalise',
565 onChange : function (evt) {
566 var value = $(evt.currentTarget).val();
567 if (null == value || '' == value)
571 _w.customervaluation.validatePage(2);
578 value : data.stock.km ? data.stock.km : '',
579 onChange : function (evt) {
580 var value = $(evt.currentTarget).val();
581 if (null == value || '' == value)
585 _w.customervaluation.validatePage(2);
587 onKeyUp : function (evt) { _w.customervaluation.validatePage(2);}
589 'fullServiceHistory' : {
591 id : 'fullServiceHistory',
592 title : 'Full service history',
594 value : data.stock.fullServiceHistory ? data.stock.fullServiceHistory : '',
595 onChange : function (evt) {
596 var value = $(evt.currentTarget).val();
597 if (null == value || '' == value)
601 _w.customervaluation.validatePage(2);
609 value : data.firstName ? data.firstName : '',
610 onChange : function (evt) {
611 var value = $(evt.currentTarget).val();
612 if (null == value || '' == value)
616 _w.customervaluation.validatePage(3);
623 value : data.familyName ? data.familyName : '',
624 onChange : function (evt) {
625 var value = $(evt.currentTarget).val();
626 if (null == value || '' == value)
630 _w.customervaluation.validatePage(3);
636 title : 'Email address',
637 value : data.email ? data.email : '',
638 onChange : function (evt) {
639 var value = $(evt.currentTarget).val();
640 if (null == value || '' == value)
644 _w.customervaluation.validatePage(3);
650 title : 'Confirm email address',
658 value : data.mobile ? data.mobile : '',
659 onChange : function (evt) {
660 var value = $(evt.currentTarget).val();
661 if (null == value || '' == value)
665 _w.customervaluation.validatePage(3);
672 dataStoreId : 'regions',
674 onChange : $.proxy(function (evt) {
675 if (!App.DataStore.getItem('BuildSelect:region', false))
677 /*App.DataStore.loadSelectListData(
678 'cities', false, 'Location', 'Town.SelectList', null,
680 "region" : $(this).val()
684 var dataList = undefined != _w.customervaluation.publicCentreList[$('#region').val()]
685 ? _w.customervaluation.publicCentreList[$('#region').val()]
687 App.DataStore.setData('publicCentre', dataList);
688 if ($('#sameAsBusinessAddress').prop('checked'))
690 $('#billingRegion').selectpicker('val', $('#region').val());
693 var value = $(evt.currentTarget).val();
694 if (null == value || '' == value)
698 _w.customervaluation.validatePage(3);
706 dataStoreId : 'cities',
708 onChange : function (evt) {
709 var value = $(evt.currentTarget).val();
710 if (null == value || '' == value)
714 _w.customervaluation.validatePage(3);
721 title : 'Public Center',
722 dataStoreId : 'publicCentre',
724 onChange : function (evt) {
725 var value = $(evt.currentTarget).val();
726 if (null == value || '' == value)
730 _w.customervaluation.validatePage(3);
741 onChange : function (evt) {
742 var value = $(evt.currentTarget).val();
743 if (null == value || '' == value)
747 _w.customervaluation.validatePage(3);
752 style : 'rand-input',
753 id : 'requiredPrice',
754 title : 'Requested Price',
756 onChange : function (evt) {
757 var value = $(evt.currentTarget).val();
758 if (null == value || '' == value)
762 _w.customervaluation.validatePage(3);
768 _listMakesModelsTypes : function( fromItemData, callback )
772 var year = _w.customervaluation.itemData.stock.vehicleYear;
773 var category = _w.customervaluation.itemData.stock.type.category.id;
774 var make = _w.customervaluation.itemData.stock.type.model.make.id;
775 var model = _w.customervaluation.itemData.stock.type.model.id;
776 var type = _w.customervaluation.itemData.stock.type.id;
780 var year = $('#vehicleYear').val();
781 var category = $('#vehicleCategory').val();
782 var make = $('#vehicleMake').val();
783 var model = $('#vehicleModel').val();
784 var type = $('#vehicleType').val();
785 var mmcode = $('#mmCode').val();
787 if (year && category)
789 App.DataStore.loadSelectListData(
790 'makes', false, 'Stock', 'Utility.ListMakes', null,
792 "category": category,
794 }}, {}, $.proxy(function (categoryId)
798 var data = App.DataStore.getData('makes');
803 App.DataStore.setData('makes', data);
808 if (make && year && category)
810 App.DataStore.loadSelectListData(
811 'models', false, 'Stock', 'Utility.ListModels', null,
814 "category": category,
816 }}, {}, $.proxy(function (categoryId)
820 var data = App.DataStore.getData('models');
825 App.DataStore.setData('models', data);
830 if (model && year && category)
832 App.DataStore.loadSelectListData(
833 'types', false, 'Stock', 'Utility.ListTypes', null,
836 "category": category,
838 }}, {}, $.proxy(function (categoryId, callback)
842 var data = App.DataStore.getData('types');
847 App.DataStore.setData('types', data);
853 }, this, category, callback)
858 _setupValidation : function ()
861 firstName: {required: true, minlength: 3},
862 familyName: {required: true, minlength: 3},
863 email: {required: true, email: true},
864 confirmEmail: {required: true, email: true, equalTo: "#email"},
865 mobile: {required: true, mobile: true},
866 region: {required: true},
867 city: {required: false},
868 publicCentre: {required: true},
869 street: {required: false},
870 requiredPrice: {required: false, number: true, min: 0.01},
871 vehicleYear: "required",
872 vehicleCategory: "required",
873 vehicleMake: "required",
874 vehicleModel: "required",
875 vehicleType: "required",
876 vehicleFuelType: "required",
877 vehicleTransmissionType: "required",
878 registrationNumber: "required",
879 fullServiceHistory: "required",
880 km: { required: true, digits: true }
882 $('#frmCustomerValuationView').validate({
886 minlength: "This field is required."
889 minlength: "This field is required."
892 required: "This field is required.",
893 email: "Please enter a valid<br/>email address."
896 required: "This field is required.",
897 email: "Please enter a valid<br/>email address.",
898 equalTo: "Please enter the same<br/>value again."
901 required: "This field is required.",
902 number: "Please enter a valid amount.",
903 min: "Please enter a<br/>valid amount."
905 vehicleYear : "This field is required.",
906 vehicleCategory : "This field is required.",
907 vehicleMake : "This field is required.",
908 vehicleModel : "This field is required.",
909 vehicleType : "This field is required.",
910 vehicleFuelType : "This field is required.",
911 vehicleTransmissionType : "This field is required.",
912 fullServiceHistory : "This field is required.",
913 registrationNumber : "This field is required.",
914 km : {required: "This field is required."}
916 invalidHandler: function(event, validator) {
917 var errors = validator.numberOfInvalids();
918 if (0 < _w.customervaluation.validations && errors) {
919 var message = errors == 1
920 ? 'You missed 1 field. It has been highlighted'
921 : 'You missed ' + errors + ' fields. They have been highlighted';
924 _w.customervaluation.validations++;
926 submitHandler: function( form ) {
931 _w.customervaluation.validations = 0;
932 $('#frmCustomerValuationView').valid();
934 $('label.error').remove();
935 $('.valid').removeClass('valid');
938 _onTuReady : function ()
941 'TransUnionFromMmCode', {
943 vehicleYear : parseInt($('#vehicleYear').val()),
944 type : parseInt($('#vehicleType').val())
947 _w.customervaluation._onTuReceived, function(){alert('There were no trade and retail from TransUnion');}
951 _onTuReceived : function ( response )
953 if ('Success' != response.Data.Status)
955 alert(response.Data.Status);
958 var vals = response.Data.VehicleDetails[0].Value;
959 $('#retailPrice').val(vals.RetailPrice);
960 $('#tradePrice').val(vals.TradePrice);
961 $('#listPrice').val(vals.NewPrice);
962 $('#' + _w.customervaluation.ti.tid + '_retailPrice').html('R ' + vals.RetailPrice + '.00');
963 $('#' + _w.customervaluation.ti.tid + '_tradePrice').html('R ' + vals.TradePrice + '.00');
964 $('#' + _w.customervaluation.ti.tid + '_listPrice').html('R ' + vals.NewPrice + '.00');
967 _prepValuationUpdateData : function()
969 function isValidEmailAddress(emailAddress) {
970 var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);
971 return pattern.test(emailAddress);
974 var data = _w.customervaluation.ti.harvest();
975 data.km = '' == data.km
978 //data.retailPrice = 0.00;
979 //data.tradePrice = 0.00;
980 //data.listPrice = 0.00;
981 var retailPrice = $('#retailPrice').val();
982 var tradePrice = $('#tradePrice').val();
983 var listPrice = $('#listPrice').val();
985 data.retailPrice = ('' == retailPrice)
987 : parseFloat(retailPrice);
988 data.tradePrice = ('' == tradePrice)
990 : parseFloat(tradePrice);
991 data.listPrice = ('' == listPrice)
993 : parseFloat(listPrice);
995 delete data.damageTotal;
998 var postData = {Stock:{}, Valuation:{}};
999 var valuationFields = [
1000 "firstName","familyName","mobile",
1001 "email","region","city","street","requiredPrice"," publicCentre"
1003 for (var field in data)
1005 if (-1 == valuationFields.indexOf(field))
1007 postData.Stock[field] = data[field];
1011 postData.Valuation[field] = data[field];
1016 if('' == postData.Valuation.requiredPrice)
1018 postData.Valuation.requiredPrice = 0;
1021 if( !isValidEmailAddress( postData.Valuation.email ) )
1023 testEmail = postData.Valuation.email;
1024 console.log("went through check", testEmail);
1025 postData.Valuation.email = null;
1029 if ('' == postData.Valuation.email)
1031 postData.Valuation.email = null;
1037 _onValuationUpdated : function( response )
1039 //alert('Your vehicle has successfully been submitted.');
1040 window.location.hash = '/thankyouvaluation';
1042 //send customer valuation email
1044 _onValuationFail : function( response )
1046 console.log('response',response );
1047 alert('Oops, something went wrong, please check your data carefully and try again.');
1048 //window.location.hash = '/public-landing';
1055 //this is for refreshing dropdowns if no data is populated on first load
1057 // $.proxy(function(){
1058 //// console.log('PageContent', $('#PageContent').children().length);
1059 //// if ( $('#vehicleYear').children().length == 0 ) {
1060 //// console.log ('PageContent no Year data - running task again...');
1061 //// _w.customervaluation.setValuationViewFormMeta();
1064 //// if ( $('#vehicleCategory').children().length == 0 ) {
1065 //// _w.customervaluation.setValuationViewFormMeta();
1069 // if ( $('#publicCenter').children().length == 0 ) {
1070 // console.log ('PageContent no publicCenter data - running task again...');
1071 // _w.customervaluation.setValuationViewFormMeta();
1074 // if ( $('#vehicleYear').children().length == 0 ) {
1075 // App.DataStore.loadSelectListData(
1076 // 'years', false, 'Stock', 'Year.SelectList', null,
1080 // if ( $('#vehicleCategory').children().length == 0 ) {
1081 // App.DataStore.loadSelectListData(
1082 // 'categories', false, 'Stock', 'Category.SelectList', null,
1086 // if ( $('#fullServiceHistory').children().length == 0 ) {
1087 // App.DataStore.loadSelectListData(
1088 // 'fsh', false, 'Stock', 'FullServiceHistory.SelectList', null,
1092 // if ( $('#vehicleFuelType').children().length == 0 ) {
1093 // App.DataStore.loadSelectListData(
1094 // 'fuelTypes', false, 'Stock', 'FuelType.SelectList', null,
1098 // if ( $('#vehicleTransmissionType').children().length == 0 ) {
1099 // App.DataStore.loadSelectListData(
1100 // 'transmissionTypes', false, 'Stock', 'TransmissionType.SelectList', null,
1108 // $.proxy(function(){
1109 // if ( $('#vehicleYear').children().length == 0 ) {
1110 // location.reload();
1111 // console.log('reload');