Hi there,
Ive extended the CsvBulkLoader (code below) but i have two wee problems one the dates are screwy, the spreadsheets im importing from have the dates in dd/mm/yy hh:mm format and even though i have the site set you UK date when the importer gets a date it imports the data as mm/dd/yy hh:mm if the dates are correct. ie 01/02/2014 10:22 (1st Feb 2014) is imported as 02/01/2014 10:22 (2nd Jan 2014) any help or pointers on that please?
The second problem is that i'd like to set a boolean to 1 if a record has been imported but without adding a field to the spreadsheet to set this i'm unsure how to flag that, any ideas on that?
Hope you can help
Mick
class TheSearchCsvBulkLoader extends CsvBulkLoader{
public $columnMap = array(
//Straight Import fields
'Date Missing' => 'DateMissing',
'Date Found' => 'DateFound',
'Gender' => 'Gender',
'Age' => 'Age',
'Time of Day' => 'TOD',
'IPP Grid' => 'IPPGR',
'Find Grid' => 'FindGR',
'Destination Grid' => 'DestGR',
'Track Offset (m)' => 'TrackOff',
'Area Type' => 'AreaType',
'Notes' => 'Notes',
//Mappings
'Area' => 'Area.Name',
'Type' => 'Mipser.Name',
'Location Type' => 'Location.Name',
'Survivability' => 'Survivability.Name',
'Missing From' => 'MissingLoc.Name'
);
public $duplicateChecks = array(
//'SearchID' => 'ID' // This stops duplicate entries
);
public $relationCallbacks = array(
'Area.Name' => array(
'relationname' => 'Area',
'callback' => 'getAreabyName'
),
'Mipser.Name' => array(
'relationname' => 'Misper',
'callback' => 'getMisperbyName'
),
'Location.Name' => array(
'relationname' => 'Location',
'callback' => 'getLocationbyName'
),
'Survivability.Name' => array(
'relationname' => 'Survivability',
'callback' => 'getSurvivabilitybyName'
),
'MissingLoc.Name' => array(
'relationname' => 'MissingLoc',
'callback' => 'getMissingLocbyName'
)
);
public static function getAreabyName($obj, $val, $record){
return Team::get()->filter('Name', $val)->First();
}
public static function getMisperbyName($obj, $val, $record){
return Type::get()->filter('Name', $val)->First();
}
public static function getLocationbyName($obj, $val, $record){
return Location::get()->filter('Name', $val)->First();
}
public static function getSurvivabilitybyName($obj, $val, $record){
return Survivability::get()->filter('Name', $val)->First();
}
public static function getMissingLocbyName($obj, $val, $record){
return MissingLoc::get()->filter('Name', $val)->First();
}
}