Set values to null if they are 0

This commit is contained in:
snipe
2013-12-06 04:59:24 -05:00
parent 78b3a0e1f9
commit dd701d253c
+18 -6
View File
@@ -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)