Skip to content

Commit 5c0e912

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 45f353e + 47a8363 commit 5c0e912

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1172
-253
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ We use Waffle.io to help better communicate our roadmap with users. Our [project
1818

1919
[![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready&title=Ready)](http://waffle.io/snipe/snipe-it)
2020

21+
### Announcement List
22+
23+
To be notified of important news (such as new releases, security advisories, etc), [sign up for our list](http://eepurl.com/XyZKz). We'll never sell or give away your info, and we'll only email you when it's important.
24+
2125
-----
2226

2327
## Requirements

app/controllers/admin/AssetsController.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use Input;
55
use Lang;
66
use Asset;
7+
use Supplier;
78
use Statuslabel;
89
use User;
910
use Setting;
@@ -160,11 +161,12 @@ public function getCreate()
160161
{
161162
// Grab the dropdown list of models
162163
$model_list = array('' => '') + Model::orderBy('name', 'asc')->lists('name', 'id');
164+
$supplier_list = array('' => '') + Supplier::orderBy('name', 'asc')->lists('name', 'id');
163165

164166
// Grab the dropdown list of status
165167
$statuslabel_list = array('' => Lang::get('general.pending')) + array('0' => Lang::get('general.ready_to_deploy')) + Statuslabel::orderBy('name', 'asc')->lists('name', 'id');
166168

167-
return View::make('backend/hardware/edit')->with('model_list',$model_list)->with('statuslabel_list',$statuslabel_list)->with('asset',new Asset);
169+
return View::make('backend/hardware/edit')->with('supplier_list',$supplier_list)->with('model_list',$model_list)->with('statuslabel_list',$statuslabel_list)->with('asset',new Asset);
168170

169171
}
170172

@@ -218,6 +220,7 @@ public function postCreate()
218220
$asset->order_number = e(Input::get('order_number'));
219221
$asset->notes = e(Input::get('notes'));
220222
$asset->asset_tag = e(Input::get('asset_tag'));
223+
$asset->supplier_id = e(Input::get('supplier_id'));
221224
$asset->user_id = Sentry::getId();
222225
$asset->assigned_to = '0';
223226
$asset->archived = '0';
@@ -262,11 +265,12 @@ public function getEdit($assetId = null)
262265

263266
// Grab the dropdown list of models
264267
$model_list = array('' => '') + Model::orderBy('name', 'asc')->lists('name', 'id');
268+
$supplier_list = array('' => '') + Supplier::orderBy('name', 'asc')->lists('name', 'id');
265269

266270
// Grab the dropdown list of status
267271
$statuslabel_list = array('' => Lang::get('general.pending')) + array('0' => Lang::get('general.ready_to_deploy')) + Statuslabel::orderBy('name', 'asc')->lists('name', 'id');
268272

269-
return View::make('backend/hardware/edit', compact('asset'))->with('model_list',$model_list)->with('statuslabel_list',$statuslabel_list);
273+
return View::make('backend/hardware/edit', compact('asset'))->with('model_list',$model_list)->with('supplier_list',$supplier_list)->with('statuslabel_list',$statuslabel_list);
270274
}
271275

272276

@@ -338,6 +342,7 @@ public function postEdit($assetId = null)
338342
$asset->order_number = e(Input::get('order_number'));
339343
$asset->asset_tag = e(Input::get('asset_tag'));
340344
$asset->notes = e(Input::get('notes'));
345+
$asset->supplier_id = e(Input::get('supplier_id'));
341346
$asset->physical = '1';
342347

343348
// Was the asset updated?
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
<?php namespace Controllers\Admin;
2+
3+
use AdminController;
4+
use Input;
5+
use Lang;
6+
use Supplier;
7+
use Redirect;
8+
use Setting;
9+
use Sentry;
10+
use Str;
11+
use Validator;
12+
use View;
13+
14+
class SuppliersController extends AdminController {
15+
16+
/**
17+
* Show a list of all suppliers
18+
*
19+
* @return View
20+
*/
21+
public function getIndex()
22+
{
23+
// Grab all the suppliers
24+
$suppliers = Supplier::orderBy('created_at', 'DESC')->paginate(Setting::getSettings()->per_page);
25+
26+
// Show the page
27+
return View::make('backend/suppliers/index', compact('suppliers'));
28+
}
29+
30+
31+
/**
32+
* Supplier create.
33+
*
34+
* @return View
35+
*/
36+
public function getCreate()
37+
{
38+
return View::make('backend/suppliers/edit')->with('supplier', new Supplier);
39+
}
40+
41+
42+
/**
43+
* Supplier create form processing.
44+
*
45+
* @return Redirect
46+
*/
47+
public function postCreate()
48+
{
49+
50+
// get the POST data
51+
$new = Input::all();
52+
53+
// Create a new supplier
54+
$supplier = new Supplier;
55+
56+
// attempt validation
57+
if ($supplier->validate($new))
58+
{
59+
60+
// Save the location data
61+
$supplier->name = e(Input::get('name'));
62+
$supplier->address = e(Input::get('address'));
63+
$supplier->address2 = e(Input::get('address2'));
64+
$supplier->city = e(Input::get('city'));
65+
$supplier->state = e(Input::get('state'));
66+
$supplier->country = e(Input::get('country'));
67+
$supplier->zip = e(Input::get('zip'));
68+
$supplier->contact = e(Input::get('contact'));
69+
$supplier->phone = e(Input::get('phone'));
70+
$supplier->fax = e(Input::get('fax'));
71+
$supplier->email = e(Input::get('email'));
72+
$supplier->notes = e(Input::get('notes'));
73+
$supplier->url = e(Input::get('url'));
74+
$supplier->user_id = Sentry::getId();
75+
76+
// Was it created?
77+
if($supplier->save())
78+
{
79+
// Redirect to the new supplier page
80+
return Redirect::to("admin/settings/suppliers")->with('success', Lang::get('admin/suppliers/message.create.success'));
81+
}
82+
}
83+
else
84+
{
85+
// failure
86+
$errors = $supplier->errors();
87+
return Redirect::back()->withInput()->withErrors($errors);
88+
}
89+
90+
// Redirect to the supplier create page
91+
return Redirect::to('admin/settings/suppliers/create')->with('error', Lang::get('admin/suppliers/message.create.error'));
92+
93+
}
94+
95+
/**
96+
* Supplier update.
97+
*
98+
* @param int $supplierId
99+
* @return View
100+
*/
101+
public function getEdit($supplierId = null)
102+
{
103+
// Check if the supplier exists
104+
if (is_null($supplier = Supplier::find($supplierId)))
105+
{
106+
// Redirect to the supplier page
107+
return Redirect::to('admin/settings/suppliers')->with('error', Lang::get('admin/suppliers/message.does_not_exist'));
108+
}
109+
110+
// Show the page
111+
return View::make('backend/suppliers/edit', compact('supplier'));
112+
}
113+
114+
115+
/**
116+
* Supplier update form processing page.
117+
*
118+
* @param int $supplierId
119+
* @return Redirect
120+
*/
121+
public function postEdit($supplierId = null)
122+
{
123+
// Check if the supplier exists
124+
if (is_null($supplier = Supplier::find($supplierId)))
125+
{
126+
// Redirect to the supplier page
127+
return Redirect::to('admin/settings/suppliers')->with('error', Lang::get('admin/suppliers/message.does_not_exist'));
128+
}
129+
130+
131+
// get the POST data
132+
$new = Input::all();
133+
134+
// attempt validation
135+
if ($supplier->validate($new))
136+
{
137+
138+
139+
140+
// Save the data
141+
$supplier->name = e(Input::get('name'));
142+
$supplier->address = e(Input::get('address'));
143+
$supplier->address2 = e(Input::get('address2'));
144+
$supplier->city = e(Input::get('city'));
145+
$supplier->state = e(Input::get('state'));
146+
$supplier->country = e(Input::get('country'));
147+
$supplier->zip = e(Input::get('zip'));
148+
$supplier->contact = e(Input::get('contact'));
149+
$supplier->phone = e(Input::get('phone'));
150+
$supplier->fax = e(Input::get('fax'));
151+
$supplier->email = e(Input::get('email'));
152+
$supplier->url = e(Input::get('url'));
153+
$supplier->notes = e(Input::get('notes'));
154+
155+
156+
// Was it created?
157+
if($supplier->save())
158+
{
159+
// Redirect to the new supplier page
160+
return Redirect::to("admin/settings/suppliers")->with('success', Lang::get('admin/suppliers/message.update.success'));
161+
}
162+
}
163+
else
164+
{
165+
// failure
166+
$errors = $supplier->errors();
167+
return Redirect::back()->withInput()->withErrors($errors);
168+
}
169+
170+
// Redirect to the supplier management page
171+
return Redirect::to("admin/settings/suppliers/$supplierId/edit")->with('error', Lang::get('admin/suppliers/message.update.error'));
172+
173+
}
174+
175+
/**
176+
* Delete the given supplier.
177+
*
178+
* @param int $supplierId
179+
* @return Redirect
180+
*/
181+
public function getDelete($supplierId)
182+
{
183+
// Check if the supplier exists
184+
if (is_null($supplier = Supplier::find($supplierId)))
185+
{
186+
// Redirect to the suppliers page
187+
return Redirect::to('admin/settings/suppliers')->with('error', Lang::get('admin/suppliers/message.not_found'));
188+
}
189+
190+
if ($supplier->num_assets() > 0) {
191+
192+
// Redirect to the asset management page
193+
return Redirect::to('admin/settings/suppliers')->with('error', Lang::get('admin/suppliers/message.assoc_users'));
194+
} else {
195+
196+
// Delete the supplier
197+
$supplier->delete();
198+
199+
// Redirect to the suppliers management page
200+
return Redirect::to('admin/settings/suppliers')->with('success', Lang::get('admin/suppliers/message.delete.success'));
201+
}
202+
203+
}
204+
205+
206+
/**
207+
* Get the asset information to present to the supplier view page
208+
*
209+
* @param int $assetId
210+
* @return View
211+
**/
212+
public function getView($supplierId = null)
213+
{
214+
$supplier = Supplier::find($supplierId);
215+
216+
if (isset($supplier->id)) {
217+
return View::make('backend/suppliers/view', compact('supplier'));
218+
} else {
219+
// Prepare the error message
220+
$error = Lang::get('admin/suppliers/message.does_not_exist', compact('id'));
221+
222+
// Redirect to the user management page
223+
return Redirect::route('suppliers')->with('error', $error);
224+
}
225+
226+
227+
}
228+
229+
230+
231+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class AddSuppliers extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::create('suppliers', function($table)
16+
{
17+
$table->increments('id');
18+
$table->string('name');
19+
$table->string('address',50)->nullable()->default(NULL);
20+
$table->string('address2',50)->nullable()->default(NULL);
21+
$table->string('city')->nullable()->default(NULL);
22+
$table->string('state',2)->nullable()->default(NULL);
23+
$table->string('country',2)->nullable()->default(NULL);
24+
$table->string('phone',20)->nullable()->default(NULL);
25+
$table->string('fax',20)->nullable()->default(NULL);
26+
$table->string('email',150)->nullable()->default(NULL);
27+
$table->string('contact',100)->nullable()->default(NULL);
28+
$table->string('notes')->nullable()->default(NULL);
29+
$table->timestamps();
30+
$table->integer('user_id');
31+
$table->softDeletes();
32+
});
33+
}
34+
35+
/**
36+
* Reverse the migrations.
37+
*
38+
* @return void
39+
*/
40+
public function down()
41+
{
42+
//
43+
Schema::drop('suppliers');
44+
}
45+
46+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
use Illuminate\Database\Schema\Blueprint;
4+
use Illuminate\Database\Migrations\Migration;
5+
6+
class AddSupplierIdToAsset extends Migration {
7+
8+
/**
9+
* Run the migrations.
10+
*
11+
* @return void
12+
*/
13+
public function up()
14+
{
15+
Schema::table('assets', function($table)
16+
{
17+
$table->integer('supplier_id')->nullable()->default(NULL);
18+
});
19+
}
20+
21+
/**
22+
* Reverse the migrations.
23+
*
24+
* @return void
25+
*/
26+
public function down()
27+
{
28+
Schema::table('assets', function($table)
29+
{
30+
$table->dropColumn('supplier_id');
31+
});
32+
}
33+
34+
}

0 commit comments

Comments
 (0)