added announcement
This commit is contained in:
@@ -19,6 +19,8 @@ class TeamStoreController extends Controller {
|
||||
{
|
||||
// var_dump($teamStoreURL);
|
||||
$m = new TeamStoreModel;
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$store_array = $m->selectTeamStore('StoreUrl', $teamStoreURL);
|
||||
$product_array = $m->selectTeamStoreProducts('TeamStoreId', $store_array[0]->Id);
|
||||
$user_role = '';
|
||||
@@ -44,7 +46,6 @@ class TeamStoreController extends Controller {
|
||||
return redirect()->back();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,11 +82,24 @@ class TeamStoreController extends Controller {
|
||||
);
|
||||
}
|
||||
}
|
||||
$getAnnouncement = $UserModel->getAnnouncement($store_array[0]->Id);
|
||||
|
||||
if(count($getAnnouncement) > 0){
|
||||
$data = $getAnnouncement[0];
|
||||
}else{
|
||||
$data = (object) array(
|
||||
'Id' => 0,
|
||||
'StoreId' => "",
|
||||
'Announcement' => "",
|
||||
'IsActive' => 0,
|
||||
'DateCreated' => ""
|
||||
);
|
||||
}
|
||||
|
||||
// var_dump($thumbnails);
|
||||
return view('teamstore-sublayouts.index')
|
||||
->with('store_array', $store_array)
|
||||
->with('product_array', $product_array)
|
||||
->with('announcement', $data)
|
||||
->with('thumbnails', $thumbnails);
|
||||
}
|
||||
|
||||
|
||||
@@ -1072,10 +1072,100 @@ class UserController extends Controller {
|
||||
$UserModel = new UserModel;
|
||||
$res = $UserModel->deleteStoreItem($post['id']);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function announcementIndex(){
|
||||
$UserModel = new UserModel;
|
||||
$storeId = Auth::user()->store_id;
|
||||
|
||||
$getAnnouncement = $UserModel->getAnnouncement($storeId);
|
||||
|
||||
if(count($getAnnouncement) > 0){
|
||||
$data = $getAnnouncement[0];
|
||||
}else{
|
||||
$data = (object) array(
|
||||
'Id' => 0,
|
||||
'StoreId' => "",
|
||||
'Announcement' => "",
|
||||
'IsActive' => 0,
|
||||
'DateCreated' => ""
|
||||
);
|
||||
}
|
||||
return view('user-layouts.announcement')
|
||||
->with("data", $data)
|
||||
->render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function announcementUpdateSave(Request $request){
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$storeId = Auth::user()->store_id;
|
||||
|
||||
$getAnnouncement = $UserModel->getAnnouncement($storeId);
|
||||
$data = array(
|
||||
'StoreId' => $storeId,
|
||||
'Announcement' => htmlentities($post['announcementInput'])
|
||||
);
|
||||
|
||||
// var_dump($getAnnouncement[0]->Id);
|
||||
|
||||
if(count($getAnnouncement) > 0){
|
||||
$response = $UserModel->updateAnnouncement($getAnnouncement[0]->Id, $data);
|
||||
}else{
|
||||
$data['IsActive'] = 0;
|
||||
$response = $UserModel->saveNewAnnouncement($data);
|
||||
}
|
||||
|
||||
try {
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => "Announcement is successfully updated."
|
||||
));
|
||||
} catch (\Throwable $th) {
|
||||
//throw $th;
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => $th
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
function announcementUpdateStatus(Request $request){
|
||||
$post = $request->all();
|
||||
$UserModel = new UserModel;
|
||||
|
||||
$storeId = Auth::user()->store_id;
|
||||
|
||||
$getAnnouncement = $UserModel->getAnnouncement($storeId);
|
||||
|
||||
if(!count($getAnnouncement)){
|
||||
return response()->json(array(
|
||||
'success' => false,
|
||||
'message' => 'Please update your announcement first.'
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$data = array(
|
||||
'IsActive' => ($post['IsActive'] == 'true') ? 1 : 0
|
||||
);
|
||||
|
||||
$UserModel->updateAnnouncement($getAnnouncement[0]->Id, $data);
|
||||
|
||||
return response()->json(array(
|
||||
'success' => true,
|
||||
'message' => "Item is successfully deleted."
|
||||
'message' => "Announcement is successfully updated."
|
||||
));
|
||||
|
||||
// var_dump($data);
|
||||
|
||||
// $response = $UserModel->updateAnnouncement($getAnnouncement[0]->Id, $data);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -133,6 +133,11 @@ Route::group(['middleware' => 'normaluser'], function () {
|
||||
Route::get('user/my-designs/buy-design/{designCode}', 'user\UserController@buyDesign');
|
||||
|
||||
Route::get('user/store-orders', 'user\UserController@storeOrders');
|
||||
|
||||
Route::get('user/announcement', 'user\UserController@announcementIndex');
|
||||
Route::post('user/announcement/updateSave', 'user\UserController@announcementUpdateSave');
|
||||
Route::post('user/announcement/status/update', 'user\UserController@announcementUpdateStatus');
|
||||
|
||||
});
|
||||
|
||||
Route::group(['middleware' => 'auth'], function() {
|
||||
|
||||
@@ -348,4 +348,24 @@ class UserModel extends Model {
|
||||
$row = $query->fetchAll(\PDO::FETCH_OBJ);
|
||||
return $row;
|
||||
}
|
||||
|
||||
function getAnnouncement($storeId){
|
||||
$i = DB::table('store_announcement')
|
||||
->where('StoreId', $storeId)
|
||||
->get();
|
||||
return $i;
|
||||
}
|
||||
|
||||
function saveNewAnnouncement($data){
|
||||
$i = DB::table('store_announcement')
|
||||
->insert($data);
|
||||
return $i;
|
||||
}
|
||||
|
||||
function updateAnnouncement($id, $data){
|
||||
$i = DB::table('store_announcement')
|
||||
->where('Id', $id)
|
||||
->update($data);
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@if ($announcement->IsActive)
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-info">
|
||||
<p><b>Announcement:</b></p>
|
||||
{!! nl2br(e($announcement->Announcement)) !!}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@if($store_array[0]->Id == 174 || $store_array[0]->Id == 175 || $store_array[0]->Id == 178 || $store_array[0]->Id == 184 || $store_array[0]->Id == 179 || $store_array[0]->Id == 177 || $store_array[0]->Id == 189 || $store_array[0]->Id == 176 || $store_array[0]->Id == 190 || $store_array[0]->Id == 191 || $store_array[0]->Id == 192 || $store_array[0]->Id == 194)
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
|
||||
51
resources/views/user-layouts/announcement.blade.php
Normal file
51
resources/views/user-layouts/announcement.blade.php
Normal file
@@ -0,0 +1,51 @@
|
||||
@extends('user-layouts.user_template')
|
||||
@section('content')
|
||||
<div class="content-wrapper" style="min-height: 916px;">
|
||||
<!-- Content Header (Page header) -->
|
||||
<section class="content-header">
|
||||
<h1>
|
||||
Announcement
|
||||
<!-- <small>Control panel</small> -->
|
||||
</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ url ('user') }}"><i class="fa fa-home"></i> Home</a></li>
|
||||
<li class="active">Announcement</li>
|
||||
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<!-- Main content -->
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">Announcement</h3>
|
||||
<div class="pull-right">
|
||||
<input type="checkbox" id="isActiveAnnouncement" @if($data->IsActive) checked @endif data-id={{ $data->Id }} name="isActiveAnnouncement" data-toggle="toggle" data-width="100px" data-on="<i class='fa fa-check-circle'></i> Active" data-off="<i class='fa fa-ban'></i> Inactive" data-size="small">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form role="form" id="form_announcement">
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label>Current Announcement</label>
|
||||
<textarea class="form-control" rows="5" name="announcementInput" placeholder="Announcement">{{ $data->Announcement }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<button type="submit" class="btn btn-primary btn-custom-save">Save Changes</button>
|
||||
</div>
|
||||
</form>
|
||||
{{-- {!! nl2br(e($data->Announcement)) !!} --}}
|
||||
<div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!-- /.content -->
|
||||
</div>
|
||||
@endsection
|
||||
@@ -49,6 +49,11 @@
|
||||
</li>
|
||||
@endif
|
||||
@if(Auth::user()->role == "store_owner")
|
||||
<li class="{{ Request::is('user/announcement') ? 'active' : '' }}">
|
||||
<a href="{{ url('user/announcement') }}">
|
||||
<i class="fa fa-bullhorn"></i> <span>Announcement</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="treeview menu-open {{ Request::is('user/store-items', 'user/store-settings', 'user/store-orders') ? 'active' : '' }}">
|
||||
<a href="#">
|
||||
<i class="fa fa-cog"></i> <span>Team Store</span>
|
||||
|
||||
@@ -1538,6 +1538,40 @@
|
||||
}
|
||||
});
|
||||
|
||||
$('#isActiveAnnouncement').change(function() {
|
||||
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : "{{ url('user/announcement/status/update') }}",
|
||||
data : {
|
||||
Id: $(this).data('id'),
|
||||
IsActive: $(this).prop('checked')
|
||||
},
|
||||
beforeSend:function(xhr){
|
||||
var token = $('meta[name="csrf_token"]').attr('content');
|
||||
|
||||
if (token) {
|
||||
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
|
||||
}
|
||||
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
|
||||
},
|
||||
success : function(response){
|
||||
if(response.success){
|
||||
alert(response.message);
|
||||
}else{
|
||||
// $('#isActiveAnnouncement').attr('checked', false);
|
||||
|
||||
$('#isActiveAnnouncement').removeClass('btn-primary');
|
||||
// $(this).addClass('btn-default');
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("#frm_edit_store").validate({
|
||||
rules: {
|
||||
store_name: {
|
||||
@@ -1571,6 +1605,24 @@
|
||||
submitHandler: submitFormEditStore
|
||||
});
|
||||
|
||||
$("#form_announcement").validate({
|
||||
rules: {
|
||||
announcementInput: {
|
||||
required: true
|
||||
}
|
||||
},
|
||||
messages: {},
|
||||
errorPlacement: function(error, element) {
|
||||
var placement = $(element).data('error');
|
||||
if (placement) {
|
||||
$(placement).append(error);
|
||||
}else {
|
||||
error.insertAfter(element);
|
||||
}
|
||||
},
|
||||
submitHandler: submitFormAnnouncement
|
||||
});
|
||||
|
||||
$("#store_name").on('keyup',function(){
|
||||
var getsportName = $(this).val();
|
||||
getsportName = getsportName.replace(/\s+/g, '-').toLowerCase(); //new object assigned to var str
|
||||
@@ -1622,6 +1674,37 @@
|
||||
}); //end document ready
|
||||
|
||||
// function
|
||||
|
||||
|
||||
|
||||
function submitFormAnnouncement(){
|
||||
var data = $("#form_announcement").serialize();
|
||||
// console.log(data);
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : "{{ url('user/announcement/updateSave') }}",
|
||||
data : data,
|
||||
beforeSend:function(xhr){
|
||||
var token = $('meta[name="csrf_token"]').attr('content');
|
||||
|
||||
if (token) {
|
||||
return xhr.setRequestHeader('X-CSRF-TOKEN', token);
|
||||
}
|
||||
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
|
||||
},
|
||||
success : function(response){
|
||||
console.log(response);
|
||||
if(response){
|
||||
alert(response.message);
|
||||
}else{
|
||||
alert(response.message);
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
function submitFormEditStore(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
|
||||
Reference in New Issue
Block a user