source: resources/views/web/offer/offer.blade.php@ dfae77e

Last change on this file since dfae77e was dfae77e, checked in by Igor Danilovski <igor_danilovski@…>, 2 years ago
  • Initial commit;
  • Property mode set to 100644
File size: 14.1 KB
Line 
1@extends('layouts.app')
2
3@section('content')
4 <div class="container">
5 <div class="row justify-content-center">
6 <div class="offer-details">
7 <div class="d-flex justify-content-between mb-3">
8 <h3 class="d-flex align-items-center mr-3">Offer Details</h3>
9 <div class="d-flex btn-container">
10 @auth
11 @if($offer->status === \App\Enum\OfferStatus::IN_PROGRESS->value && (isset($offer->price) || !is_null($offer->price)))
12 <form action="/offers/decline" class="d-inline-flex" method="POST">
13 @csrf
14 <input type="hidden" name="offer_id" value="{{ $offer->id }}">
15 <br>
16 <button type="submit" class="me-2 btn btn-danger">Decline Offer</button>
17 </form>
18 @endif
19
20 @if(Auth::user()->type === \App\Enum\UserType::ORGANIZER->value && $offer->status === \App\Enum\OfferStatus::IN_PROGRESS->value && (isset($offer->price) || !is_null($offer->price)))
21 <form action="/offers/accept" class="d-inline-flex" method="POST">
22 @csrf
23 <input type="hidden" name="offer_id" value="{{ $offer->id }}">
24 <br>
25 <button type="submit" class="btn btn-success">Accept Offer</button>
26 </form>
27 @endif
28 @endauth
29 </div>
30 </div>
31 <table class="table">
32 <thead>
33 <tr>
34 <th scope="col">Property</th>
35 <th scope="col">Value</th>
36 </tr>
37 </thead>
38 <tbody>
39 <tr>
40 <td><strong>From Organizer</strong></td>
41 <td>{{ $offer->event->organizer->user->name }}</td>
42 </tr>
43 <tr>
44 <td><strong>To Artist</strong></td>
45 <td>{{ $offer->artist->user->name }}</td>
46 </tr>
47 <tr>
48 <td><strong>For Event</strong></td>
49 <td>
50 <a href="/events/{{ $offer->event->slug }}">
51 {{ $offer->event->title }}
52 </a>
53 <td>
54 </tr>
55 <tr>
56 <td><strong>Current Offer Status</strong></td>
57 @if($offer->status === \App\Enum\OfferStatus::IN_PROGRESS->value)
58 <td><p class="badge bg-warning">In Progress</p></td>
59 @elseif($offer->status === \App\Enum\OfferStatus::COMPLETED->value)
60 <td><p class="badge bg-success">Completed</p></td>
61 @elseif($offer->status === \App\Enum\OfferStatus::DECLINED->value)
62 <td><p class="badge bg-danger">Declined</p></td>
63 @elseif($offer->status === \App\Enum\OfferStatus::WAITING_FOR_PAYMENT->value)
64 <td><p class="badge bg-warning">Waiting for payment</p></td>
65 @endif
66 </tr>
67 <tr>
68 <td><strong>Current Offer Price (USD)</strong></td>
69 <td>@if($offer->price != null)
70 @currency($offer->price)
71 @else
72 Not yet defined
73 @endif
74 </td>
75 </tr>
76 <tr>
77 <td><strong>Created At</strong></td>
78 <td>{{ $offer->created_at->isoFormat('dddd, DD-MMM-Y H:mm') }}</td>
79 </tr>
80 <tr>
81 <td><strong>Last Updated/Modified At</strong></td>
82 <td>
83 @if($offer->updated_at != null)
84 {{ $offer->updated_at->isoFormat('dddd, DD-MMM-Y H:mm') }}
85 @else
86 Never
87 @endif
88 </td>
89 </tr>
90 <tr>
91 <td><strong>Completed At</strong></td>
92 <td>
93 @if($offer->completed_at != null)
94 {{ $offer->completed_at->isoFormat('dddd, DD-MMM-Y H:mm') }}
95 @else
96 Not yet completed
97 @endif
98 </td>
99 </tr>
100 <tr>
101 <td><strong>Payment Type</strong></td>
102 <td>{{ $offer->payment_type }}</td>
103 </tr>
104 </tbody>
105 </table>
106 </div>
107 </div>
108 @auth
109 @if(Auth::user()->type === \App\Enum\UserType::ORGANIZER->value)
110 @if(!is_null($offer->price))
111 <div class="row">
112 <div class="col-lg-6">
113 <h3 class="mb-3 mt-5">Proposed price</h3>
114 <h4>@currency($offer->price)</h4>
115 </div>
116
117 @if($offer->status === \App\Enum\OfferStatus::WAITING_FOR_PAYMENT->value)
118 <div class="col-lg-6 stripe-payment">
119 <h3 class="mb-3 mt-5">Payment</h3>
120 <form method="POST" action="{{ route('payments.purchase', $offer->id) }}"
121 class="card-form mt-3 mb-3">
122 @csrf
123 <input type="hidden" name="payment_method" class="payment-method">
124 <input class="StripeElement mb-3" name="card_holder_name"
125 placeholder="Card holder name"
126 required>
127 <div class="col-lg-4 col-md-6">
128 <div id="card-element"></div>
129 </div>
130 <div id="card-errors" role="alert"></div>
131 <div class="form-group mt-3">
132 <button type="submit" class="btn btn-primary pay">
133 Pay
134 </button>
135 </div>
136 </form>
137 </div>
138 @endif
139
140 @if($offer->status === \App\Enum\OfferStatus::COMPLETED->value)
141 @php
142 $invoice = Auth::user()->findInvoice($offer->transactions->get(0)->invoice_id);
143 @endphp
144 <div class="col-lg-6">
145 <h3 class="mb-3 mt-5">Invoice</h3>
146 <a href="/invoices/{{ $invoice->id }}">
147 <button type="button" class="btn btn-primary">Download</button>
148 </a>
149 </div>
150 @endif
151 </div>
152 @endif
153 @endif
154
155 @if(Auth::user()->type !== \App\Enum\UserType::ORGANIZER->value && $offer->status === \App\Enum\OfferStatus::IN_PROGRESS->value)
156 <div class="row justify-content-center">
157 <h3 class="mb-3 mt-5">Propose new price</h3>
158 <form action="/offers/set-price" method="POST">
159 @csrf
160 <input type="hidden" name="offer_id" value="{{ $offer->id }}">
161
162 <div class="input-group">
163 <div class="input-group-prepend">
164 <span class="input-group-text" id="price-input">USD $</span>
165 </div>
166 <input type="number" name="price" class="form-control"
167 value="{{ $offer->price ?? '' }}" placeholder="Enter value"
168 aria-label="Price" aria-describedby="price-input">
169 </div>
170 <br>
171 <button type="submit" class="btn btn-primary">Propose price</button>
172 </form>
173 </div>
174 @endif
175 @endauth
176
177 <div class="row justify-content-center">
178 <div class="offer-discussion">
179 <h3 class="mb-3 mt-5">Offer discussion</h3>
180 <form action="/offers/reply" method="POST">
181 @csrf
182 <input type="hidden" name="offer_id" value="{{ $offer->id }}">
183 <textarea name="comment" id="" cols="30" rows="5" placeholder="Reply to thread..."
184 class="form-control mb-3 w-100"></textarea>
185 <button type="submit" class="btn btn-success">Reply to thread</button>
186 </form>
187
188 @if(count($offer->comments) > 0)
189 <table class="table mt-4">
190 <thead>
191 <tr>
192 <th><strong>Comment</strong></th>
193 <th><strong>Posted By</strong></th>
194 <th><strong>Role</strong></th>
195 <th><strong>Created At</strong></th>
196 </tr>
197 </thead>
198 <tbody>
199 @foreach($offer->comments as $comment)
200 <tr>
201 <td>
202 {{ $comment->content }}
203 </td>
204 <td>
205 {{ $comment->author->name }}
206 </td>
207 <td>
208 <span
209 class="badge bg-success">as {{ ucfirst(strtolower($comment->author->type)) }}</span>
210 </td>
211 <td>
212 {{ $comment->created_at->isoFormat('dddd, DD-MMM-Y H:mm') }}
213 </td>
214 </tr>
215 @endforeach
216 </tbody>
217 </table>
218 @endif
219 </div>
220 </div>
221 </div>
222
223 @auth
224 @if (Auth::user()->type === \App\Enum\UserType::ORGANIZER->value && $offer->status === \App\Enum\OfferStatus::WAITING_FOR_PAYMENT->value)
225 <style>
226 .StripeElement {
227 box-sizing: border-box;
228 height: 40px;
229 padding: 10px 12px;
230 width: 100%;
231 border: 1px solid transparent;
232 border-radius: 4px;
233 background-color: white;
234 box-shadow: 0 1px 3px 0 #e6ebf1;
235 -webkit-transition: box-shadow 150ms ease;
236 transition: box-shadow 150ms ease;
237 }
238
239 .StripeElement--focus {
240 box-shadow: 0 1px 3px 0 #cfd7df;
241 }
242
243 .StripeElement--invalid {
244 border-color: #fa755a;
245 }
246
247 .StripeElement--webkit-autofill {
248 background-color: #fefde5 !important;
249 }
250
251 .stripe-payment .col-lg-4.col-md-6 {
252 width: 100% !important;
253 }
254 </style>
255
256 <script src="https://js.stripe.com/v3/"></script>
257 <script>
258 let stripe = Stripe("{{ env('STRIPE_KEY') }}")
259 let elements = stripe.elements()
260 let style = {
261 base: {
262 color: '#32325d',
263 fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
264 fontSmoothing: 'antialiased',
265 fontSize: '16px',
266 '::placeholder': {
267 color: '#aab7c4'
268 }
269 },
270 invalid: {
271 color: '#fa755a',
272 iconColor: '#fa755a'
273 }
274 }
275 let card = elements.create('card', {style: style})
276 card.mount('#card-element')
277 let paymentMethod = null
278 $('.card-form').on('submit', function (e) {
279 $('button.pay').attr('disabled', true)
280 if (paymentMethod) {
281 return true
282 }
283 stripe.confirmCardSetup(
284 "{{ $intent->client_secret }}",
285 {
286 payment_method: {
287 card: card,
288 billing_details: {name: $('.card_holder_name').val()}
289 }
290 }
291 ).then(function (result) {
292 if (result.error) {
293 $('#card-errors').text(result.error.message)
294 $('button.pay').removeAttr('disabled')
295 } else {
296 paymentMethod = result.setupIntent.payment_method
297 $('.payment-method').val(paymentMethod)
298 $('.card-form').submit()
299 }
300 })
301 return false
302 })
303 </script>
304 @endif
305 @endauth
306@endsection
Note: See TracBrowser for help on using the repository browser.