diff --git a/IES-Bandung/app/Http/Controllers/HomeController.php b/IES-Bandung/app/Http/Controllers/HomeController.php index cb060b6f1134048313eb82c2e7118025b909fdcc..e96731c7fd1a845e16cf6a16781db8146ad1204c 100755 --- a/IES-Bandung/app/Http/Controllers/HomeController.php +++ b/IES-Bandung/app/Http/Controllers/HomeController.php @@ -4,6 +4,8 @@ namespace App\Http\Controllers; use App\Http\Requests; use Illuminate\Http\Request; +use Auth; +use App\User; class HomeController extends Controller { @@ -24,6 +26,18 @@ class HomeController extends Controller */ public function index() { - return view('home'); + $isGov = Auth::check() ? Auth::user()['type'] === 'gov' : false; + $users = null; + if ($isGov) { + $users = User::getAllNonGov(); + } + return view('home', [ + 'isGov' => $isGov, + 'users' => $users ]); + } + public function manage(Request $request) + { + $req = $request->all(); + return redirect('/'); } } diff --git a/IES-Bandung/app/Http/routes.php b/IES-Bandung/app/Http/routes.php index 9ae35916eaa1708484db75868c1d7d8a39491ab9..7c765753007ff21ce5877d06dac342b361534a1a 100755 --- a/IES-Bandung/app/Http/routes.php +++ b/IES-Bandung/app/Http/routes.php @@ -20,6 +20,7 @@ Route::get('/', function () { Route::auth(); Route::get('/home', 'HomeController@index'); +Route::post('/manage/user', 'HomeController@manage'); Route::get('/profile', 'ProfileController@index'); Route::get('/profile/{username}', ['uses' => 'ProfileController@showProfile']); diff --git a/IES-Bandung/app/Model/ObjectSell.php b/IES-Bandung/app/Model/ObjectSell.php index 06b603790f5a23ec3c1a45bb2f6d6f60638c4963..87e7deeaba5e730bf20735ef902c417653fcb64b 100644 --- a/IES-Bandung/app/Model/ObjectSell.php +++ b/IES-Bandung/app/Model/ObjectSell.php @@ -23,7 +23,7 @@ class ObjectSell extends Model } public static function getMostUpdated($vendorID) { - $updatedObject = ObjectSell::where('vendor_user_id', '=', $vendorID)->orderBy('updated_at', 'desc')->limit(5)->get(); + $updatedObject = ObjectSell::where('vendor_user_id', '=', $vendorID)->where('updated_at', '>=', strtotime("-1 week"))->orderBy('updated_at', 'desc')->limit(8)->get(); foreach ($updatedObject as $key => $value) { $lastlog = ObjectSell::getOldPrice($value['id']); if(is_null($lastlog)) @@ -35,7 +35,7 @@ class ObjectSell extends Model return $updatedObject; } public static function getOldPrice($object_sell_id) { - $result = DB::table('object_sell_logs')->where('object_sell_id', '=', $object_sell_id)->where('old_price', '<>', 'new_price')->orderBy('updated_at', 'desc')->select('old_price', 'new_price')->first(); + $result = DB::table('object_sell_logs')->where('object_sell_id', '=', $object_sell_id)->where('updated_at', '>=', strtotime("-1 week"))->where('old_price', '<>', 'new_price')->orderBy('updated_at', 'desc')->select('old_price', 'new_price')->first(); if(is_null($result)) return null; return $result->old_price; diff --git a/IES-Bandung/app/User.php b/IES-Bandung/app/User.php index c2e3df5c11dee3ddae4f02321a8018148d41dd70..2dbf4eaafa0637b477bc08cf9c6ae832c476ff28 100755 --- a/IES-Bandung/app/User.php +++ b/IES-Bandung/app/User.php @@ -3,6 +3,9 @@ namespace App; use Illuminate\Foundation\Auth\User as Authenticatable; +use App\Model\VendorUser; +use App\Model\PublicUser; +use App\Model\GovUser; class User extends Authenticatable { @@ -39,4 +42,7 @@ class User extends Authenticatable 'tel_no' => $newtel_no )); } + public static function getAllNonGov() { + return User::where('type', '<>', 'gov')->get(); + } } diff --git a/IES-Bandung/resources/views/home.blade.php b/IES-Bandung/resources/views/home.blade.php index 109105657e0db6e7d4301eeec7b816a2400aef26..b33e824fef27415f01a80d847f104eb8f3ad1d2a 100755 --- a/IES-Bandung/resources/views/home.blade.php +++ b/IES-Bandung/resources/views/home.blade.php @@ -64,6 +64,85 @@ </div> </div> </div> + + @if ($isGov) + <div class="wrapper-lg"> + <div class="row"> + <div class="col-md-12"> + <div class="panel panel-default"> + <div class="panel-heading font-semibold"> + Users + </div> + <form action="manage/user" method="post"> + {!! csrf_field() !!} + <div class="row wrapper-sm"> + <div class="col-sm-5"> + <select class="input-sm form-control w-sm inline v-middle" name="action"> + <option value="nothing">Action</option> + <option value="blacklist">Blacklist selected</option> + <option value="unblacklist">Unblacklist selected</option> + <option value="delete">Delete selected</option> + </select> + <button type="submit" class="btn btn-sm btn-default">Apply</button> + </div> + <div class="col-sm-4"> + </div> + <div class="col-sm-3"> + <div class="input-group"> + <input type="text" class="input-sm form-control" placeholder="Search"> + <span class="input-group-btn"> + <button class="btn btn-sm btn-default" type="button">Go!</button> + </span> + </div> + </div> + </div> + <div class="table-responsive"> + <table class="table table-striped b-t b-light"> + <thead> + <tr> + <th style="width:20px;"></th> + <th>Username</th> + <th>Full Name</th> + <th>Email</th> + <th>User Type</th> + <th>Status</th> + <th>Link</th> + <th style="width:20px;"></th> + </tr> + </thead> + <tbody> + @foreach ($users as $user) + <tr> + <td><label class="checkbox-inline "><input type="checkbox" name="user{{ $user->id }}"><i></i></label></td> + <td>{{ $user->username }}</td> + <td>{{ $user->full_name }}</td> + <td>{{ $user->email }}</td> + <td>{{ $user->type }}</td> + <td> + <a href class="active" ui-toggle-class><i class="fa fa-check text-success text-active"></i><i class="fa fa-times text-danger text"></i></a> + </td> + <td> + <a href="/profile/{{ $user->username }}" class="active"><i class="fa fa-link text-info text-active"></i></a> + </td> + </tr> + @endforeach + </tbody> + </table> + </div> + <footer class="panel-footer"> + <div class="row"> + <div class="col-sm-4 hidden-xs"></div> + <div class="col-sm-4 text-center"> + <small class="text-muted inline m-t-sm m-b-sm">showing {{ count($users) }} items</small> + </div> + </div> + </footer> + </form> + </div> + </div> + </div> + </div> + @endif </div> </div> <!-- App-content-body -->