added stat
This commit is contained in:
@@ -17,9 +17,37 @@ use Illuminate\Support\Facades\Storage;
|
|||||||
class UserController extends Controller {
|
class UserController extends Controller {
|
||||||
|
|
||||||
public function index(){
|
public function index(){
|
||||||
|
$m = new UserModel;
|
||||||
|
$userRole = Auth::user()->role;
|
||||||
|
|
||||||
|
if($userRole == "store_owner"){
|
||||||
|
$storeId = Auth::user()->store_id;
|
||||||
|
|
||||||
|
$countStoreOrder = $m->countStoreOrder($storeId);
|
||||||
|
$storeIncome = $m->storeIncome($storeId);
|
||||||
|
$countStoreProduct = $m->countStoreProduct($storeId);
|
||||||
|
$countStorePublishedProduct = $m->countStorePublishedProduct($storeId);
|
||||||
|
|
||||||
|
$post_data = array(
|
||||||
|
'isStoreOwner' => true,
|
||||||
|
'store_order' => $countStoreOrder[0]->count_order,
|
||||||
|
'store_income' => $storeIncome[0]->store_income,
|
||||||
|
'store_product_count' => $countStoreProduct[0]->store_product_count,
|
||||||
|
'store_published_product' => $countStorePublishedProduct[0]->store_published_product
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
$post_data = array(
|
||||||
|
'isStoreOwner' => false,
|
||||||
|
'store_order' => "",
|
||||||
|
'store_income' => "",
|
||||||
|
'store_product_count' => "",
|
||||||
|
'store_published_product' => ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $post_data = json_encode($post_data, JSON_FORCE_OBJECT);
|
||||||
|
return view('user-layouts.index')->with('data', $post_data);
|
||||||
|
|
||||||
return view('user-layouts.index');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addressBook(){
|
public function addressBook(){
|
||||||
|
|||||||
@@ -317,4 +317,35 @@ class UserModel extends Model {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function countStoreOrder($storeId){
|
||||||
|
$pdo = DB::connection()->getPdo();
|
||||||
|
$query = $pdo->prepare("SELECT SUM(o.Quantity) AS count_order FROM orders AS o WHERE o.StoreId = :storeId");
|
||||||
|
$query->execute([':storeId'=>$storeId]);
|
||||||
|
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
function storeIncome($storeId){
|
||||||
|
$pdo = DB::connection()->getPdo();
|
||||||
|
$query = $pdo->prepare("SELECT SUM(o.Price) AS store_income FROM orders AS o WHERE o.StoreId = :storeId");
|
||||||
|
$query->execute([':storeId'=>$storeId]);
|
||||||
|
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
function countStoreProduct($storeId){
|
||||||
|
$pdo = DB::connection()->getPdo();
|
||||||
|
$query = $pdo->prepare("SELECT COUNT(Id) AS store_product_count FROM teamstore_products AS tp WHERE tp.TeamStoreId = :storeId");
|
||||||
|
$query->execute([':storeId'=>$storeId]);
|
||||||
|
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
function countStorePublishedProduct($storeId){
|
||||||
|
$pdo = DB::connection()->getPdo();
|
||||||
|
$query = $pdo->prepare("SELECT COUNT(Id) AS store_published_product FROM teamstore_products AS tp WHERE tp.TeamStoreId = :storeId AND PrivacyStatus = 'public'");
|
||||||
|
$query->execute([':storeId'=>$storeId]);
|
||||||
|
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,15 +17,80 @@
|
|||||||
|
|
||||||
<section class="content">
|
<section class="content">
|
||||||
@if(Auth::user()->email_is_verified == "0")
|
@if(Auth::user()->email_is_verified == "0")
|
||||||
<div class="alert alert-warning alert-dismissible">
|
<div class="alert alert-warning alert-dismissible">
|
||||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||||
<h4><i class="icon fa fa-check"></i> To do!</h4>
|
<h4><i class="icon fa fa-check"></i> To do!</h4>
|
||||||
Please verify your Email Address. <a href="{{ url('user/email-verify') }}">Click here</a>
|
Please verify your Email Address. <a href="{{ url('user/email-verify') }}">Click here</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center" id="homepage-logo">
|
@endif
|
||||||
|
|
||||||
|
@if ($data['isStoreOwner'])
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-lg-3 col-xs-6">
|
||||||
|
<!-- small box -->
|
||||||
|
<div class="small-box bg-aqua">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>{{ $data['store_order'] }}</h3>
|
||||||
|
<p>Total Item Ordered</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="ion ion-bag"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ./col -->
|
||||||
|
<div class="col-lg-3 col-xs-6">
|
||||||
|
<!-- small box -->
|
||||||
|
<div class="small-box bg-green">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>{{ number_format($data['store_income'], 2) }}</h3>
|
||||||
|
|
||||||
|
<p>Store Income</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="ion ion-stats-bars"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ./col -->
|
||||||
|
<div class="col-lg-3 col-xs-6">
|
||||||
|
<!-- small box -->
|
||||||
|
<div class="small-box bg-yellow">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>{{ $data['store_product_count'] }}</h3>
|
||||||
|
|
||||||
|
<p>Total Products</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="ion ion-person-add"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ./col -->
|
||||||
|
<div class="col-lg-3 col-xs-6">
|
||||||
|
<!-- small box -->
|
||||||
|
<div class="small-box bg-red">
|
||||||
|
<div class="inner">
|
||||||
|
<h3>{{ $data['store_published_product'] }}</h3>
|
||||||
|
|
||||||
|
<p>Total Published Product</p>
|
||||||
|
</div>
|
||||||
|
<div class="icon">
|
||||||
|
<i class="ion ion-key"></i>
|
||||||
|
</div>
|
||||||
|
<a href="#" class="small-box-footer">More info <i class="fa fa-arrow-circle-right"></i></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- ./col -->
|
||||||
|
</div>
|
||||||
|
@else
|
||||||
|
<div class="text-center" id="homepage-logo">
|
||||||
|
<img src="{{asset('/public/images/logo.png')}}" style="height: 200px;" class="img img-responsive" />
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
<img src="{{asset('/public/images/logo.png')}}" style="height: 200px;" class="img img-responsive" />
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
<!-- /.content -->
|
<!-- /.content -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user