UPDATE to Registration process to include location details and create dealership
[namibia] / public / js / app / brochure-workspace / register.js
index 4ab2aa1..b7f2d5d 100644 (file)
@@ -38,7 +38,7 @@
              //     {"value":"Turnover > R3,000,000", "label":"Turnover > R3,000,000"}
              //     ]);
                        App.DataStore.loadSelectListData('permissions', true, 'User', 'Permissions.SelectList');
-                       //App.DataStore.loadSelectListData('countries', true, 'Location', 'Country.SelectList');
+                       App.DataStore.loadSelectListData('countries', true, 'Location', 'Country.SelectList');
                        //App.DataStore.loadSelectListData('groups', true, 'Company', 'Group.SelectList');
                        //App.DataStore.loadSelectListData('foundmethods', true, 'Company', 'FoundMethod.SelectList');
 
                 //
                 //
                                //// Adresses and billing contact
-                               //'country' : {
-                               //      type        : 'select',
-                               //      id          : 'country',
-                               //      title       : 'Country',
-                               //      dataStoreId : 'countries',
-                               //      value       : '',
-                               //      onChange    : function () {
-                               //              if (!App.DataStore.getItem('BuildSelect:country', false))
-                               //              {
-                               //                      App.DataStore.loadSelectListData(
-                               //                                      'regions', false, 'Location', 'Region.SelectList', null,
-                               //                                      {"Filter": {
-                               //                                              "country" : $(this).val()
-                               //                                              }}
-                               //                                      );
-                               //                      App.DataStore.setData('cities', []);
-                               //                      if ($('#sameAsBusinessAddress').prop('checked'))
-                               //                      {
-                               //                              $('#billingCountry').selectpicker('val', $('#country').val());
-                               //                      }
-                               //              }
-                               //      }
-                               //},
-                               //'region' : {
-                               //      type        : 'select',
-                               //      id          : 'region',
-                               //      title       : 'Region',
-                               //      dataStoreId : 'regions',
-                               //      value       : '',
-                               //      onChange    : function () {
-                               //              if (!App.DataStore.getItem('BuildSelect:region', false))
-                               //              {
-                               //                      App.DataStore.loadSelectListData(
-                               //                                      'cities', false, 'Location', 'Town.SelectList', null,
-                               //                                      {"Filter": {
-                               //                                              "region" : $(this).val()
-                               //                                              }}
-                               //                                      );
-                               //                      if ($('#sameAsBusinessAddress').prop('checked'))
-                               //                      {
-                               //                              $('#billingRegion').selectpicker('val', $('#region').val());
-                               //                      }
-                               //              }
-                               //      }
-                               //},
-                               //'city' : {
-                               //      type        : 'select',
-                               //      id          : 'city',
-                               //      title       : 'Town',
-                               //      dataStoreId : 'cities',
-                               //      value       : ''
-                               //},
-                               //'street' : {
-                               //      type  : 'input',
-                               //      id    : 'street',
-                               //      title : 'Street',
-                               //      value : '',
-                               //      maxlength : 75
-                               //},
-                               //'postalCode' : {
-                               //      type  : 'input',
-                               //      id    : 'postalCode',
-                               //      title : 'Code',
-                               //      value : '',
-                               //      maxlength : 10
-                               //},
+                               'country' : {
+                                       type        : 'select',
+                                       id          : 'country',
+                                       title       : 'Country',
+                                       dataStoreId : 'countries',
+                                       value       : '',
+                                       onChange    : function () {
+                                               if (!App.DataStore.getItem('BuildSelect:country', false))
+                                               {
+                                                       App.DataStore.loadSelectListData(
+                                                                       'regions', false, 'Location', 'Region.SelectList', null,
+                                                                       {"Filter": {
+                                                                               "country" : $(this).val()
+                                                                               }}
+                                                                       );
+                                                       App.DataStore.setData('cities', []);
+                                                       if ($('#sameAsBusinessAddress').prop('checked'))
+                                                       {
+                                                               $('#billingCountry').selectpicker('val', $('#country').val());
+                                                       }
+                                               }
+                                       }
+                               },
+                               'region' : {
+                                       type        : 'select',
+                                       id          : 'region',
+                                       title       : 'Region',
+                                       dataStoreId : 'regions',
+                                       value       : '',
+                                       onChange    : function () {
+                                               if (!App.DataStore.getItem('BuildSelect:region', false))
+                                               {
+                                                       App.DataStore.loadSelectListData(
+                                                                       'cities', false, 'Location', 'Town.SelectList', null,
+                                                                       {"Filter": {
+                                                                               "region" : $(this).val()
+                                                                               }}
+                                                                       );
+                                                       if ($('#sameAsBusinessAddress').prop('checked'))
+                                                       {
+                                                               $('#billingRegion').selectpicker('val', $('#region').val());
+                                                       }
+                                               }
+                                       }
+                               },
+                               'city' : {
+                                       type        : 'select',
+                                       id          : 'city',
+                                       title       : 'Town',
+                                       dataStoreId : 'cities',
+                                       value       : ''
+                               },
+                               'street' : {
+                                       type  : 'input',
+                                       id    : 'street',
+                                       title : 'Street',
+                                       value : '',
+                                       maxlength : 75
+                               },
+                               'postalCode' : {
+                                       type  : 'input',
+                                       id    : 'postalCode',
+                                       title : 'Code',
+                                       value : '',
+                                       maxlength : 10
+                               },
                                //'sameAsBusinessAddress' : {
                                //      type  : 'checkbox',
                                //      id    : 'sameAsBusinessAddress',
                                        //companyRegistrationNumber: {companyReg: true},
                                        //vatNumber: {digits: true},
 
-                                       //country: {required: true},
-                                       //region: {required: true},
-                                       //city: {required: true},
-                                       //street: {required: true},
-                                       //postalCode: {required: true, digits: true},
+                                       country: {required: true},
+                                       region: {required: true},
+                                       city: {required: true},
+                                       street: {required: true},
+                                       postalCode: {required: true, digits: true},
                                        //billingCountry: {required: true},
                                        //billingRegion: {required: true},
                                        //billingCity: {required: true},
                  "firstName","familyName","permissions","email","confirmEmail",
                  "pin","confirmPin","idNumber","dateOfBirth","mobile", "subscribeNewsletter"
                  ];
-                       //var companyFields = [
-             //    "dealerType","clientType","group","groupDivision","companyType",
-             //    "businessName","name","companyRegistrationNumber","vatNumber","turmiNumber",
-             //    "dealerStockNumber","turnover","foundMethod","foundMethodDetail",
-             //    "country","region","city","street","postalCode",
-             //    "billingCountry","billingRegion","billingCity","billingStreet","billingPostalCode",
-             //    "docStockCertificate","docAddressProof","docCopyOfId",
-             //    "docCopyOfDirectorId","docCompanyRegistration"
-             //    ];
+                       var companyFields = [
+                 //"dealerType","clientType","group","groupDivision","companyType",
+                 //"businessName","name","companyRegistrationNumber","vatNumber","turmiNumber",
+                 //"dealerStockNumber","turnover","foundMethod","foundMethodDetail",
+                 "country","region","city","street","postalCode",
+                 //"billingCountry","billingRegion","billingCity","billingStreet","billingPostalCode",
+                 //"docStockCertificate","docAddressProof","docCopyOfId",
+                 //"docCopyOfDirectorId","docCompanyRegistration"
+                 ];
                        var contactFields = {
                  "contactFirstName"  : "firstName",
                  "contactFamilyName" : "familyName",
                        };
                        for (var field in data)
                        {
-                               //if (-1 != companyFields.indexOf(field))
-                               //{
-                               //      postData.Company[field] = '' != data[field] ? data[field] : null;
-                               //}
-                               //else
+                               if (-1 != companyFields.indexOf(field))
+                               {
+                                       postData.Company[field] = '' != data[field] ? data[field] : null;
+                               }
+                               else
                                if (-1 != profileFields.indexOf(field))
                                {
                                        postData.Profile[field] = '' != data[field] ? data[field] : null;