Got rid of the temporary function to determine unit status enums, and switched over to actually querying the database. Eliminated a legend entry for DELETED since no one should ever see a unit like that given that it should be, well, deleted. Modified the legend algorithm slightly to fix the number of rows instead of columns, since the placement algorithm works through the rows before moving to the next column.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@206 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -72,7 +72,7 @@ class AppModel extends Model {
|
||||
|
||||
//Get the values
|
||||
return array_flip(array_merge(array(''), // MySQL sets 0 to be the empty string
|
||||
explode("','", preg_replace("/(enum)\('(.+?)'\)/","\\2", $types))
|
||||
explode("','", strtoupper(preg_replace("/(enum)\('(.+?)'\)/","\\2", $types)))
|
||||
));
|
||||
} //end getEnumValues
|
||||
|
||||
|
||||
@@ -151,22 +151,6 @@ class MapsController extends AppController {
|
||||
return $info;
|
||||
}
|
||||
|
||||
// Temporary function
|
||||
function unitStatusList() {
|
||||
return
|
||||
array('DELETED' => array(),
|
||||
'DAMAGED' => array(),
|
||||
'COMPANY' => array(),
|
||||
'UNAVAILABLE' => array(),
|
||||
'RESERVED' => array(),
|
||||
'DIRTY' => array(),
|
||||
'VACANT' => array(),
|
||||
'OCCUPIED' => array(),
|
||||
'LATE' => array(),
|
||||
'LOCKED' => array(),
|
||||
'LIENED' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -176,9 +160,10 @@ class MapsController extends AppController {
|
||||
*/
|
||||
|
||||
function legend($id = null, $requested_width = 400) {
|
||||
$status = $this->unitStatusList();
|
||||
$cols = 6;
|
||||
$rows = (int)((count($status) + $cols - 1) / $cols);
|
||||
$status = $this->Map->Unit->activeStatusEnums();
|
||||
//pr($status);
|
||||
$rows = 2;
|
||||
$cols = (int)((count($status) + $rows - 1) / $rows);
|
||||
|
||||
$info = array('units' => array());
|
||||
|
||||
@@ -206,7 +191,7 @@ class MapsController extends AppController {
|
||||
$item_width *= $screen_adjustment_factor;
|
||||
$item_depth *= $screen_adjustment_factor;
|
||||
|
||||
foreach ($status AS $code => $color) {
|
||||
foreach ($status AS $code => $value) {
|
||||
$info['units'][] = array('name' => $code,
|
||||
'status' => $code,
|
||||
'width' => $item_width,
|
||||
|
||||
@@ -40,6 +40,10 @@ class Unit extends AppModel {
|
||||
return $status_enums;
|
||||
}
|
||||
|
||||
function activeStatusEnums() {
|
||||
return array_diff_key($this->statusEnums(), array(''=>1, 'DELETED'=>1));
|
||||
}
|
||||
|
||||
function statusValue($enum) {
|
||||
$enums = $this->statusEnums();
|
||||
return $enums[$enum];
|
||||
|
||||
Reference in New Issue
Block a user