Bladeren bron

feat: history purchases

Muhammad Iqbal Afandi 3 jaren geleden
bovenliggende
commit
e5212de488

+ 19
- 2
app/Http/Controllers/CustomerController.php Bestand weergeven

@@ -2,9 +2,10 @@
2 2
 
3 3
 namespace App\Http\Controllers;
4 4
 
5
+use App\Models\Sale;
6
+use App\Models\Customer;
5 7
 use App\Http\Requests\Customer\StoreCustomerRequest;
6 8
 use App\Http\Requests\Customer\UpdateCustomerRequest;
7
-use App\Models\Customer;
8 9
 
9 10
 class CustomerController extends Controller
10 11
 {
@@ -70,7 +71,23 @@ class CustomerController extends Controller
70 71
      */
71 72
     public function show(Customer $customer)
72 73
     {
73
-        //
74
+        return inertia("Customers/Show", [
75
+            "customer" => $customer,
76
+            "historyPurchase" => $customer
77
+                ->sales()
78
+                ->latest()
79
+                ->paginate(10)
80
+                ->withQueryString()
81
+                ->through(
82
+                    fn($sale) => [
83
+                        "id" => $sale->id,
84
+                        "createdAt" => $sale->created_at,
85
+                        "number" => $sale->number,
86
+                        "status" => $sale->status,
87
+                        "ppn" => $sale->ppn,
88
+                    ]
89
+                ),
90
+        ]);
74 91
     }
75 92
 
76 93
     /**

+ 22
- 13
resources/js/pages/Customers/Index.vue Bestand weergeven

@@ -76,20 +76,29 @@ const onDelete = (data) => {
76 76
 
77 77
       <Column>
78 78
         <template #body="{ data }">
79
-          <AppButtonLink
80
-            icon="pi pi-pencil"
81
-            class="p-button-icon-only p-button-rounded p-button-text"
82
-            v-tooltip.bottom="'Ubah Pelanggan'"
83
-            :href="route('customers.edit', data.id)"
84
-          />
79
+          <div class="grid gap-2">
80
+            <AppButtonLink
81
+              icon="pi pi-list"
82
+              class="p-button-icon-only p-button-rounded p-button-text"
83
+              v-tooltip.bottom="'History Pembelian'"
84
+              :href="route('customers.show', data.id)"
85
+            />
86
+
87
+            <AppButtonLink
88
+              icon="pi pi-pencil"
89
+              class="p-button-icon-only p-button-rounded p-button-text"
90
+              v-tooltip.bottom="'Ubah Pelanggan'"
91
+              :href="route('customers.edit', data.id)"
92
+            />
85 93
 
86
-          <Button
87
-            v-if="!data.isUsed"
88
-            icon="pi pi-trash"
89
-            class="p-button-icon-only p-button-rounded p-button-text"
90
-            v-tooltip.bottom="'Hapus Pelanggan'"
91
-            @click="onDelete(data)"
92
-          />
94
+            <Button
95
+              v-if="!data.isUsed"
96
+              icon="pi pi-trash"
97
+              class="p-button-icon-only p-button-rounded p-button-text"
98
+              v-tooltip.bottom="'Hapus Pelanggan'"
99
+              @click="onDelete(data)"
100
+            />
101
+          </div>
93 102
         </template>
94 103
       </Column>
95 104
     </DataTable>

+ 77
- 0
resources/js/pages/Customers/Show.vue Bestand weergeven

@@ -0,0 +1,77 @@
1
+<script setup>
2
+import { detailTable } from './config'
3
+import AppButtonLink from '@/components/AppButtonLink.vue'
4
+import DashboardLayout from '@/layouts/Dashboard/DashboardLayout.vue'
5
+
6
+defineProps({
7
+  customer: Object,
8
+  historyPurchase: Object,
9
+})
10
+</script>
11
+
12
+<template>
13
+  <DashboardLayout title="">
14
+    <div class="grid">
15
+      <div class="col-12">
16
+        <Card>
17
+          <template #title>
18
+            <h2 class="text-2xl font-bold">History Pembelian</h2>
19
+          </template>
20
+          <template #content>
21
+            <div class="grid">
22
+              <div class="col-12">
23
+                <div class="grid">
24
+                  <div class="col">
25
+                    <h3 class="text-base">Nama</h3>
26
+                    <span>{{ customer.name }}</span>
27
+                  </div>
28
+                  <div class="col">
29
+                    <h3 class="text-base">Alamat</h3>
30
+                    <span>{{ customer.address }}</span>
31
+                  </div>
32
+                  <div class="col">
33
+                    <h3 class="text-base">No HP</h3>
34
+                    <span>{{ customer.phone }}</span>
35
+                  </div>
36
+                  <div class="col">
37
+                    <h3 class="text-base">NPWP</h3>
38
+                    <span>{{ customer.npwp }}</span>
39
+                  </div>
40
+                </div>
41
+              </div>
42
+            </div>
43
+          </template>
44
+        </Card>
45
+      </div>
46
+
47
+      <div class="col-12">
48
+        <DataTable
49
+          responsiveLayout="scroll"
50
+          columnResizeMode="expand"
51
+          :value="historyPurchase.data"
52
+          :rowHover="true"
53
+          :stripedRows="true"
54
+          @row-click="detail($event.data)"
55
+        >
56
+          <Column
57
+            v-for="value in detailTable"
58
+            :key="value.field"
59
+            :field="value.field"
60
+            :header="value.header"
61
+          />
62
+
63
+          <Column>
64
+            <template #body="{ data }">
65
+              <AppButtonLink
66
+                icon="pi pi-eye"
67
+                class="p-button-icon-only p-button-rounded p-button-text"
68
+                v-tooltip.bottom="'Lihat Detail Penjualan'"
69
+                :href="route('sales.show', data.id)"
70
+              />
71
+            </template>
72
+          </Column>
73
+        </DataTable>
74
+      </div>
75
+    </div>
76
+  </DashboardLayout>
77
+</template>

+ 7
- 0
resources/js/pages/Customers/config.js Bestand weergeven

@@ -4,3 +4,10 @@ export const indexTable = [
4 4
   { field: 'phone', header: 'No HP' },
5 5
   { field: 'npwp', header: 'NPWP' },
6 6
 ]
7
+
8
+export const detailTable = [
9
+  { field: 'createdAt', header: 'Tanggal' },
10
+  { field: 'number', header: 'Nomor Pembelian' },
11
+  { field: 'ppn', header: 'PPN' },
12
+  { field: 'status', header: 'Status' },
13
+]

+ 2
- 2
resources/js/pages/Sales/Show.vue Bestand weergeven

@@ -29,7 +29,7 @@ const { cart, totalCartPrice } = useCart(form, props.saleDetail)
29 29
 </script>
30 30
 
31 31
 <template>
32
-  <DashboardLayout title="Lihat Pembelian">
32
+  <DashboardLayout title="Detail Penjualan">
33 33
     <DynamicDialog />
34 34
 
35 35
     <div class="grid">
@@ -38,7 +38,7 @@ const { cart, totalCartPrice } = useCart(form, props.saleDetail)
38 38
           <div class="col-12">
39 39
             <Card>
40 40
               <template #title>
41
-                <h2 class="text-2xl font-bold">Detail Pembelian</h2>
41
+                <h2 class="text-2xl font-bold">Detail Penjualan</h2>
42 42
               </template>
43 43
               <template #content>
44 44
                 <div class="grid">