// Generic CSV - Display an Editor form that allows the user to pick the CSV data to apply to each column
function selectGCSVColumns ( GCSVImport, csv, header ) {
header.push('');
selectGCSVImport = new $.fn.dataTable.Editor( {
fields: [
{
"label": "Prefix:",
"name": "prefix",
"type": 'hidden'
},
{
"label": "First Name:",
"name": "first_name",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Middle Name:",
"name": "middle_name",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Last Name:",
"name": "last_name",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Suffix:",
"name": "suffix",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Preferred Name:",
"name": "preferred_name",
"type": 'hidden'
},
{
"label": "Title:",
"name": "title",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Company Name:",
"name": "company_name",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Nest:",
"name": "nest",
"type": 'hidden'
},
{
"label": "Date of Birth:",
"name": "date_of_birth",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Gender:",
"name": "gender",
"type": 'hidden'
},
{
"label": "Phone:",
"name": "phone_choice",
"type": 'hidden'
},
{
"label": "Home Phone:",
"name": "home_phone",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Mobile Phone:",
"name": "mobile_phone",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Work Phone:",
"name": "work_phone",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Fax:",
"name": "fax_phone",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Email:",
"name": "email_choice",
"type": 'hidden'
},
{
"label": "Personal Email:",
"name": "personal_email",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Work Email:",
"name": "work_email",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Preferred Email Type:",
"name": "preferred_email_type",
"type": 'hidden'
},
{
"label": "Street:",
"name": "street",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "City:",
"name": "city",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "State:",
"name": "state",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Postal Code:",
"name": "postal_code",
"type": 'select',
"options": header,
"def": ''
},
{
"label": "Source:",
"name": "source",
"className": "",
"type": "hidden",
"def": "Initial Market"
},
{
"label": "MOD Email:",
"name": "mod_email",
"type": "hidden",
"def": ""
},
{
"label": "Street 2:",
"name": "street2",
"type": "hidden",
"def": ""
},
{
"label": "Index Count:",
"name": "index_count",
"className": "",
"type": "hidden",
"def": "2"
}
]
});
selectGCSVImport.create({
title: 'Map CSV fields',
buttons: 'Import '+csv.length+' records',
message: 'Select the CSV column you want to use the data from for each field.'
});
selectGCSVImport.on('submitComplete', function (e, json, data, action) {
// Use the host Editor instance to show a multi-row create form allowing the user to submit the data.
GCSVImport.create( csv.length, {
title: 'Confirm import',
buttons: 'Submit',
message: 'Click the Submit button to confirm the import of '+csv.length+' rows of data. Optionally, override the value for a field to set a common value by clicking on the field below.'
} );
for ( var i=0 ; i