From dd701d253c72e0dfddc5fbf4914ab22e16829bf5 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 Dec 2013 04:59:24 -0500 Subject: [PATCH] Set values to null if they are 0 --- app/controllers/admin/LicensesController.php | 24 +++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/controllers/admin/LicensesController.php b/app/controllers/admin/LicensesController.php index 151765b195..ce57a3e6fc 100644 --- a/app/controllers/admin/LicensesController.php +++ b/app/controllers/admin/LicensesController.php @@ -81,9 +81,13 @@ class LicensesController extends AdminController { $license->purchase_cost = e(Input::get('purchase_cost')); $license->user_id = Sentry::getId(); + if ($license->purchase_date == "0000-00-00") { + $license->purchase_date = NULL; + } - - + if ($license->purchase_cost == "0.00") { + $license->purchase_cost = NULL; + } // Was the license created? if($license->save()) @@ -129,6 +133,14 @@ class LicensesController extends AdminController { return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.does_not_exist')); } + if ($license->purchase_date == "0000-00-00") { + $license->purchase_date = NULL; + } + + if ($license->purchase_cost == "0.00") { + $license->purchase_cost = NULL; + } + // Show the page $license_options = array('' => 'Top Level') + DB::table('assets')->where('id', '!=', $licenseId)->lists('name', 'id'); $depreciation_list = array('0' => 'Do Not Depreciate') + Depreciation::lists('name', 'id'); @@ -156,6 +168,7 @@ class LicensesController extends AdminController { $new = Input::all(); + // attempt validation if ($license->validate($new)) { @@ -170,12 +183,11 @@ class LicensesController extends AdminController { $license->purchase_date = e(Input::get('purchase_date')); $license->purchase_cost = e(Input::get('purchase_cost')); - // Was the asset created? if($license->save()) { // Redirect to the new license page - return Redirect::to("admin/licenses/$licenseId/edit")->with('success', Lang::get('admin/licenses/message.update.success')); + return Redirect::to("admin/licenses/$licenseId/view")->with('success', Lang::get('admin/licenses/message.update.success')); } } else @@ -185,7 +197,7 @@ class LicensesController extends AdminController { return Redirect::back()->withInput()->withErrors($errors); } - // Redirect to the category create page + // Redirect to the license edit page return Redirect::to("admin/licenses/$licenseId/edit")->with('error', Lang::get('admin/licenses/message.update.error')); } @@ -248,7 +260,7 @@ class LicensesController extends AdminController { - /** + /** * Check out the asset to a person **/ public function postCheckout($seatId)