The way I would go about it is just create a table of postcodes (and information relative exclusively to that postcode) with no engineer details in that table.
Then in your engineers DCA add a field "coverage" , use foreignKey and a multiple select to create a multi-selectable dropdown menu of postcodes for your existing engineer record -which I imagine are stored serialized in the "coverage" field (I've not used a multiple select box).
Code:
'coverage' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_Your_Engineers_Table']['coverage'],
'inputType' => 'select',
'foreignKey' => 'tl_Your_Postcode_Table.postcode',
'eval' => array('mandatory'=>true, 'multiple'=>true, 'includeBlankOption'=>true, 'tl_class'=>'w50' )
),
You could use multiple checkboxes if you prefer.
This way your engineers coverage area is stored and editable in his record, not elsewhere.
You'll need to add a postcode DCA (tl_Your_Postcode_Table.php), a postcode Language file (tl_Your_Postcode_Table.php),
add the tl_Your_Postcode_Table to your Config/database.sql, and register it all your Modules Config/config.php with something like
Code:
//backend module
$GLOBALS['BE_MOD']['content']['Your_Engineers_Module'] = array(
'tables' => array('tl_Your_Engineers_Table','tl_Your_Postcode_Table,'tl_Any_Other_Table),
'icon' => 'system/modules/Your_Engineers_Module/html/iconEngineer.gif'
);
You could also add into your Engineers DCA in the global operations area
Code:
'postcode' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_Your_Engineers_Table']['postcode'],
'class' => 'header_new',
'href' => 'table=tl_Your_Postcode_Table'
),
and add the buttons into your languages/en/tl_Your_Postcode_Table.php file
Code:
// Buttons
$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['new'] = array('New Postcode', 'Add a new Postcode');
$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['edit'] = array('Edit Postcode', '');
$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['copy'] = array('Copy Postcode', '');
$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['delete'] = array('Delete Postcode', '');
$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['show'] = array('Postcode details', 'Show Postcode details');
$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['return'] = array('Return to Your_Engineers_Main Screen'', '');
and this into the global_operations of your DCA/tl_Your_Postcode_Table.php
Code:
'global_operations' => array
(
//return to the Engineers module
'return' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['return'],
'class' => 'header_new',
'href' => 'table=tl_Your_Engineers_Table'
),
This adds a button at the top of the Engineers Screen, and a return button at the top of the Postcode screen.
Also edit,copy,delete,show buttons in the Postcode Screen for each postcode record so that the postcodes table becomes editable too (it could for instance carry other fields with info on Good_Neighbourhood, Average_Rainfall, size_in_square_km etc, mad_dog_alert....that is: info about the postcode, NOT about the engineer). That way you could add new postcodes in, delete them , edit them when they change (my home postcode has recently changed), add new postcode info in as mad dogs attack engineers etc.
Theres a bit more too it to have an editable postcode table, but that should get you going.
And on it goes, hope that helps.
:D
Bookmarks