tetapan ubah margin operasi

This commit is contained in:
Amirah22
2023-04-17 11:39:38 +08:00
parent 9cb1c50c9d
commit a23db93284
9 changed files with 294 additions and 2 deletions
@@ -11,10 +11,25 @@ use Carbon\Carbon;
class TetapanController extends Controller
{
public function home(){
$auth_user = Auth::user();
return view('tetapan.home',compact('auth_user'));
}
public function index(){
$api_url = config('api.url');
$auth_user = Auth::user();
return view('tetapan.index',compact('api_url','auth_user'));
}
public function margin(){
$api_url = config('api.url');
$auth_user = Auth::user();
return view('tetapan.margin',compact('api_url','auth_user'));
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

+182
View File
@@ -0,0 +1,182 @@
<template>
<div>
<h1 class="font-bold p-2">Tetapan Ubah Margin</h1>
<div id="tabs-1" v-if="this.showprofile">
<table class="min-w-full leading-normal">
<thead class="text-center">
<tr>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Bil
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Pengguna
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Margin %
</th>
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
Tindakan
</th>
</tr>
</thead>
<tbody>
<tr v-for="(margin,i) in datamargin.data" :key="i">
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div class="flex items-center">
<div class="ml-3">
<p class="text-gray-900 whitespace-no-wrap" v-text="(datamargin.from + i)">
</p>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div class="flex items-center">
<div class="ml-3">
<p class="text-gray-900 whitespace-no-wrap" v-text="margin.user_type">
</p>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div class="flex items-center">
<div class="ml-3">
<p class="text-gray-900 whitespace-no-wrap" v-text="formatexchange(margin.max)">
</p>
</div>
</div>
</td>
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div class="flex items-center ml-3">
<button @click="ubahmargin(margin.id)" class="border border-blue-600 text-blue-600 font-montserrat py-2 px-4 font-medium rounded-xl hover:bg-blue-600 hover:text-white transition-all duration-300 mr-1">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-pencil-square" viewBox="0 0 16 16">
<path d="M15.502 1.94a.5.5 0 0 1 0 .706L14.459 3.69l-2-2L13.502.646a.5.5 0 0 1 .707 0l1.293 1.293zm-1.75 2.456-2-2L4.939 9.21a.5.5 0 0 0-.121.196l-.805 2.414a.25.25 0 0 0 .316.316l2.414-.805a.5.5 0 0 0 .196-.12l6.813-6.814z"/>
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z"/>
</svg>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script>
import pagination from '../components/pagination.vue'
const formatter = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 2
});
export default {
components: {
pagination,
},
data() {
return {
showprofile: true,
showsag: false,
datamargin: {},
currentPage: 1,
}
},
mounted() {
this.getMarginData(this.currentPage);
},
methods: {
formatexchange: function(value){
return formatter.format(value)
},
getMarginData: function (pageNumber) {
this.axios.get(this.$hostname + '/admin/tetapan/penggunamargin', {
}).then(response => {
this.datamargin = response.data;
});
},
async ubahmargin(id) {
let refer = this;
const {
value: max
} = await this.$swal({
title: 'Masukkan Nilai Margin',
input: 'number',
inputPlaceholder: 'Margin',
confirmButtonText: 'Hantar',
showCancelButton: true,
cancelButtonText: 'Batal',
allowOutsideClick: false,
inputValidator: (value) => {
if (!value) {
return 'Isikan nilai margin diatas!'
}
}
});
if(max !== undefined){
this.axios.put(this.$hostname + '/admin/tetapan/penggunamargin/update', {
id: id,
max: max
}).then(response => {
if(response.data ==1){
this.$swal({
icon: 'success',
title: 'Berjaya',
text: 'Berjaya mengemaskini',
allowOutsideClick: false
}).then(function () {
refer.getMarginData(refer.currentPage);
});
}
else{
this.$swal({
icon: 'error',
title: 'Tidak Berjaya',
text: 'Sila Cuba Semula',
allowOutsideClick: false
}).then(function () {
refer.getMarginData(refer.currentPage);
});
}
});
} else{
(function () {
refer.getMarginData(refer.currentPage);
});
}
},
}
}
</script>
+1
View File
@@ -254,6 +254,7 @@ Vue.component('audit-component', require('./Audit/Home.vue').default)
//Tetapan
Vue.component('tetapan-component', require('./Tetapan/index.vue').default)
Vue.component('pengguna-component', require('./Pengguna/index.vue').default)
Vue.component('margin-component', require('./Tetapan/margin.vue').default)
+17 -1
View File
@@ -218,7 +218,7 @@
</li>
</a>
<a href="{{ route('tetapan') }}"
{{-- <a href="{{ route('tetapan') }}"
class="rounded mb-2 mr-2
{{ Route::is('tetapan') || Route::is('tetapan.*') ? 'bg-gray-200 rounded text-white-500' : 'hover:bg-yellow-300 ' }}">
<li class="flex w-full justify-between text-gray-600 hover:text-gray-500 cursor-pointer items-center ">
@@ -232,6 +232,22 @@
<span class="text-sm ml-2 text-lg">Tetapan</span>
</div>
</li>
</a> --}}
<a href="{{ route('tetapan.home') }}"
class="rounded mb-2 mr-2
{{ Route::is('tetapan.home') || Route::is('tetapan.home.*') ? 'bg-gray-200 rounded text-white-500' : 'hover:bg-yellow-300 ' }}">
<li class="flex w-full justify-between text-gray-600 hover:text-gray-500 cursor-pointer items-center ">
<div class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
<span class="text-sm ml-2 text-lg">Tetapan</span>
</div>
</li>
</a>
+57
View File
@@ -0,0 +1,57 @@
@extends('layouts.app')
@section('content')
<div class="bg-gray-900 opacity-50 hidden fixed inset-0 z-10" id="sidebarBackdrop"></div>
<div id="main-content" class="h-full w-full bg-gray-50 relative overflow-y-auto">
<main>
<div class="pt-6 px-4">
<breadcrumb :items="[{'title' : 'Tetapan', 'icon' : 'fas fa-file-invoice'}]"></breadcrumb>
@if (Session::has('type'))
<div class="@if(Session::get('type') == 'error') bg-red-100 border-red-500 text-red-900 @else bg-yellow-100 border-green-500 text-green-900 @endif border-t-4 rounded-b px-4 py-3 shadow-md w-96 mx-auto mb-5" role="alert">
<div class="flex">
<div class="py-1">
@if(Session::get('type') == 'error')
<svg class="fill-current h-6 w-6 text-red-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M2.93 17.07A10 10 0 1 1 17.07 2.93 10 10 0 0 1 2.93 17.07zm12.73-1.41A8 8 0 1 0 4.34 4.34a8 8 0 0 0 11.32 11.32zM9 11V9h2v6H9v-4zm0-6h2v2H9V5z"/></svg>
@else
<svg xmlns="http://www.w3.org/2000/svg" class="fill-current h-6 w-6 text-green-500 mr-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4M7.835 4.697a3.42 3.42 0 001.946-.806 3.42 3.42 0 014.438 0 3.42 3.42 0 001.946.806 3.42 3.42 0 013.138 3.138 3.42 3.42 0 00.806 1.946 3.42 3.42 0 010 4.438 3.42 3.42 0 00-.806 1.946 3.42 3.42 0 01-3.138 3.138 3.42 3.42 0 00-1.946.806 3.42 3.42 0 01-4.438 0 3.42 3.42 0 00-1.946-.806 3.42 3.42 0 01-3.138-3.138 3.42 3.42 0 00-.806-1.946 3.42 3.42 0 010-4.438 3.42 3.42 0 00.806-1.946 3.42 3.42 0 013.138-3.138z" />
</svg>
@endif
</div>
<div>
<p class="font-bold">{{ Session::get('message') }}</p>
<p class="text-sm">{{ Session::get('title') }}</p>
</div>
</div>
</div>
@endif
<div class=" flex justify-center items-center mx-auto">
<a href="{{ route('tetapan') }}" class="bg-white shadow px-6 py-4 border border-solid rounded-lg w-1/6 mr-3 hover:bg-yellow-300 hover:transition-all cursor-pointer transition transform hover:-translate-y-1 ">
<img src="{{ asset('img/barcode.png') }}" class="h-40 mx-auto text-center" alt="Windster Logo">
<h2 class="mx-auto text-center font-bold text-2xl mt-4 uppercase">Scan Barcode</h2>
</a>
@if ($auth_user->id == 355)
<a href="{{ route('tetapan.margin') }}" class="bg-white shadow px-6 py-4 border border-solid rounded-lg w-1/6 hover:bg-yellow-300 hover:transition-all cursor-pointer transition transform hover:-translate-y-1 ">
<img src="{{ asset('img/margin.png') }}" class="h-40 mx-auto text-center" alt="Windster Logo">
<h2 class="mx-auto text-center font-bold text-2xl mt-4 uppercase">Ubah Margin</h2>
</a>
@else
@endif
</div>
</div>
</main>
@include('layouts.footer')
@endsection
+18
View File
@@ -0,0 +1,18 @@
@extends('layouts.app')
@section('content')
<div class="bg-gray-900 opacity-50 hidden fixed inset-0 z-10" id="sidebarBackdrop"></div>
<div id="main-content" class="h-full w-full bg-gray-50 relative overflow-y-auto">
<main>
<div class="pt-6 px-4">
<breadcrumb :items="[{ 'title' : 'Ubah Margin', 'icon' : 'fas fa-globe-asia' }]"></breadcrumb>
<margin-component></margin-component>
</div>
</main>
@include('layouts.footer')
@endsection
+3
View File
@@ -143,6 +143,9 @@ Route::get('/audit/cetakan', ['as'=>'audit.cetak','uses'=>'App\Http\Controllers\
//Tetapan Server
Route::get('/tetapan',['as'=>'tetapan','uses'=>'App\Http\Controllers\TetapanController@index'])->middleware(['roleChecker:null,null,operasi,null']);
Route::get('/tetapanhome',['as'=>'tetapan.home','uses'=>'App\Http\Controllers\TetapanController@home'])->middleware(['roleChecker:null,null,operasi,null']);
Route::get('/tetapanmargin',['as'=>'tetapan.margin','uses'=>'App\Http\Controllers\TetapanController@margin'])->middleware(['roleChecker:null,null,operasi,null']);
//Pengguna
Route::get('/pengguna',['as'=>'pengguna','uses'=>'App\Http\Controllers\PenggunaController@index'])->middleware(['roleChecker:admin,akaun,operasi,kpo']);