From 87d6d9349313ce60de0d79810ebd737e5b750a23 Mon Sep 17 00:00:00 2001 From: Abijah Date: Mon, 3 Mar 2014 07:22:06 +0000 Subject: [PATCH] Fixed bug causing crash if locks in use exceeds the number of locks that are supposed to exist git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1043 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/controllers/locks_controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/controllers/locks_controller.php b/site/controllers/locks_controller.php index 81115be..c42420b 100644 --- a/site/controllers/locks_controller.php +++ b/site/controllers/locks_controller.php @@ -55,7 +55,7 @@ class LocksController extends AppController { function gridDataFields(&$params, &$model) { $fields = parent::gridDataFields($params, $model); $fields[] = 'COUNT(LocksUnit.id) AS inuse'; - $fields[] = 'Lock.qty - COUNT(LocksUnit.id) AS avail'; + $fields[] = 'IF(Lock.qty > COUNT(LocksUnit.id), Lock.qty - COUNT(LocksUnit.id), 0) AS avail'; return $fields; }