@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | $this->middleware('auth'); |
24 | 24 | } |
25 | 25 | |
26 | - public function index(Request $request) |
|
26 | + public function index(Request $request) |
|
27 | 27 | { |
28 | 28 | |
29 | - $payment_details = Payment_detail::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
30 | - $paymentTotal = Payment_detail::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
31 | - $count = $paymentTotal->sum('payment_amount'); |
|
29 | + $payment_details = Payment_detail::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
30 | + $paymentTotal = Payment_detail::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
31 | + $count = $paymentTotal->sum('payment_amount'); |
|
32 | 32 | |
33 | 33 | |
34 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
35 | - { |
|
34 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
35 | + { |
|
36 | 36 | $drp_placeholder = "Select daterange filter"; |
37 | - } |
|
38 | - else |
|
39 | - { |
|
37 | + } |
|
38 | + else |
|
39 | + { |
|
40 | 40 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
41 | - } |
|
41 | + } |
|
42 | 42 | |
43 | - $request->flash(); |
|
43 | + $request->flash(); |
|
44 | 44 | |
45 | - return view('payments.index', compact('payment_details','count','drp_placeholder')); |
|
45 | + return view('payments.index', compact('payment_details','count','drp_placeholder')); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -64,16 +64,16 @@ discard block |
||
64 | 64 | |
65 | 65 | if($request->mode == \constPaymentMode::Cheque) |
66 | 66 | { |
67 | - // Store Cheque Details |
|
68 | - $chequeData = array('payment_id'=> $payment_detail->id, |
|
69 | - 'number'=> $request->number, |
|
70 | - 'date'=> $request->date, |
|
71 | - 'status'=> \constChequeStatus::Recieved); |
|
67 | + // Store Cheque Details |
|
68 | + $chequeData = array('payment_id'=> $payment_detail->id, |
|
69 | + 'number'=> $request->number, |
|
70 | + 'date'=> $request->date, |
|
71 | + 'status'=> \constChequeStatus::Recieved); |
|
72 | 72 | |
73 | - $cheque_details = new Cheque_detail($chequeData); |
|
74 | - $cheque_details->createdBy()->associate(Auth::user()); |
|
75 | - $cheque_details->updatedBy()->associate(Auth::user()); |
|
76 | - $cheque_details->save(); |
|
73 | + $cheque_details = new Cheque_detail($chequeData); |
|
74 | + $cheque_details->createdBy()->associate(Auth::user()); |
|
75 | + $cheque_details->updatedBy()->associate(Auth::user()); |
|
76 | + $cheque_details->save(); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | elseif($request->mode == \constPaymentMode::Cash) |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | |
155 | 155 | if($request->mode == \constPaymentMode::Cheque) |
156 | 156 | { |
157 | - // Store Cheque Details |
|
158 | - $cheque_detail = Cheque_detail::where('payment_id',$id)->first(); |
|
159 | - $cheque_detail->update(['number' => $request->number, |
|
160 | - 'date' => $request->date |
|
157 | + // Store Cheque Details |
|
158 | + $cheque_detail = Cheque_detail::where('payment_id',$id)->first(); |
|
159 | + $cheque_detail->update(['number' => $request->number, |
|
160 | + 'date' => $request->date |
|
161 | 161 | ]); |
162 | - $cheque_detail->updatedBy()->associate(Auth::user()); |
|
163 | - $cheque_detail->save(); |
|
162 | + $cheque_detail->updatedBy()->associate(Auth::user()); |
|
163 | + $cheque_detail->save(); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | elseif($request->mode == \constPaymentMode::Cash) |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | |
208 | 208 | $invoice_total = $invoice->total; |
209 | 209 | $payment_total = Payment_detail::leftJoin('trn_cheque_details','trn_payment_details.id','=','trn_cheque_details.payment_id') |
210 | - ->whereRaw("trn_payment_details.invoice_id = $invoice->id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
211 | - ->sum('trn_payment_details.payment_amount'); |
|
210 | + ->whereRaw("trn_payment_details.invoice_id = $invoice->id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
211 | + ->sum('trn_payment_details.payment_amount'); |
|
212 | 212 | |
213 | 213 | $amount_due = $invoice_total - $payment_total; |
214 | 214 | |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | $invoice_total = $payment_detail->invoice->total; |
255 | 255 | |
256 | 256 | $payment_total = Payment_detail::leftJoin('trn_cheque_details','trn_payment_details.id','=','trn_cheque_details.payment_id') |
257 | - ->whereRaw("trn_payment_details.invoice_id = $payment_detail->invoice_id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
258 | - ->sum('trn_payment_details.payment_amount'); |
|
257 | + ->whereRaw("trn_payment_details.invoice_id = $payment_detail->invoice_id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
258 | + ->sum('trn_payment_details.payment_amount'); |
|
259 | 259 | |
260 | 260 | $amount_due = $invoice_total - $payment_total; |
261 | 261 |
@@ -30,23 +30,23 @@ discard block |
||
30 | 30 | public function index(Request $request) |
31 | 31 | { |
32 | 32 | |
33 | - $subscriptions = Subscription::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end,$request->plan_name)->search('"'.$request->input('search').'"')->paginate(10); |
|
34 | - $subscriptionTotal = Subscription::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end,$request->plan_name)->search('"'.$request->input('search').'"')->get(); |
|
35 | - $count = $subscriptionTotal->count(); |
|
33 | + $subscriptions = Subscription::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end,$request->plan_name)->search('"'.$request->input('search').'"')->paginate(10); |
|
34 | + $subscriptionTotal = Subscription::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end,$request->plan_name)->search('"'.$request->input('search').'"')->get(); |
|
35 | + $count = $subscriptionTotal->count(); |
|
36 | 36 | |
37 | 37 | |
38 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
39 | - { |
|
38 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
39 | + { |
|
40 | 40 | $drp_placeholder = "Select daterange filter"; |
41 | - } |
|
42 | - else |
|
43 | - { |
|
41 | + } |
|
42 | + else |
|
43 | + { |
|
44 | 44 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - $request->flash(); |
|
47 | + $request->flash(); |
|
48 | 48 | |
49 | - return view('subscriptions.index', compact('subscriptions','count','drp_placeholder')); |
|
49 | + return view('subscriptions.index', compact('subscriptions','count','drp_placeholder')); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | |
59 | 59 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
60 | 60 | { |
61 | - $drp_placeholder = "Select daterange filter"; |
|
61 | + $drp_placeholder = "Select daterange filter"; |
|
62 | 62 | } |
63 | 63 | else |
64 | 64 | { |
65 | - $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
|
65 | + $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | $request->flash(); |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | |
79 | 79 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
80 | 80 | { |
81 | - $drp_placeholder = "Select daterange filter"; |
|
81 | + $drp_placeholder = "Select daterange filter"; |
|
82 | 82 | } |
83 | 83 | else |
84 | 84 | { |
85 | - $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
|
85 | + $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $request->flash(); |
@@ -92,29 +92,29 @@ discard block |
||
92 | 92 | |
93 | 93 | public function create() |
94 | 94 | { |
95 | - // For Tax calculation |
|
96 | - JavaScript::put([ |
|
97 | - 'taxes' => \Utilities::getSetting('taxes'), |
|
98 | - 'gymieToday' => Carbon::today()->format('Y-m-d'), |
|
99 | - 'servicesCount' => Service::count(), |
|
100 | - ]); |
|
101 | - |
|
102 | - //Get Numbering mode |
|
103 | - $invoice_number_mode = \Utilities::getSetting('invoice_number_mode'); |
|
104 | - |
|
105 | - //Generating Invoice number |
|
106 | - if ($invoice_number_mode == \constNumberingMode::Auto ) { |
|
95 | + // For Tax calculation |
|
96 | + JavaScript::put([ |
|
97 | + 'taxes' => \Utilities::getSetting('taxes'), |
|
98 | + 'gymieToday' => Carbon::today()->format('Y-m-d'), |
|
99 | + 'servicesCount' => Service::count(), |
|
100 | + ]); |
|
101 | + |
|
102 | + //Get Numbering mode |
|
103 | + $invoice_number_mode = \Utilities::getSetting('invoice_number_mode'); |
|
104 | + |
|
105 | + //Generating Invoice number |
|
106 | + if ($invoice_number_mode == \constNumberingMode::Auto ) { |
|
107 | 107 | $invoiceCounter = \Utilities::getSetting('invoice_last_number') + 1; |
108 | 108 | $invoicePrefix = \Utilities::getSetting('invoice_prefix'); |
109 | 109 | $invoice_number = $invoicePrefix.$invoiceCounter; |
110 | - } |
|
110 | + } |
|
111 | 111 | |
112 | - else { |
|
112 | + else { |
|
113 | 113 | $invoice_number = ''; |
114 | 114 | $invoiceCounter = ''; |
115 | - } |
|
115 | + } |
|
116 | 116 | |
117 | - return view('subscriptions.create',compact('invoice_number','invoiceCounter','invoice_number_mode')); |
|
117 | + return view('subscriptions.create',compact('invoice_number','invoiceCounter','invoice_number_mode')); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | public function store(Request $request) |
@@ -123,43 +123,43 @@ discard block |
||
123 | 123 | DB::beginTransaction(); |
124 | 124 | |
125 | 125 | try { |
126 | - //Helper function to set Payment status |
|
127 | - $invoice_total = $request->admission_amount + $request->subscription_amount + $request->taxes_amount - $request->discount_amount; |
|
128 | - $paymentStatus = \constPaymentStatus::Unpaid; |
|
129 | - $pending = $invoice_total - $request->payment_amount; |
|
126 | + //Helper function to set Payment status |
|
127 | + $invoice_total = $request->admission_amount + $request->subscription_amount + $request->taxes_amount - $request->discount_amount; |
|
128 | + $paymentStatus = \constPaymentStatus::Unpaid; |
|
129 | + $pending = $invoice_total - $request->payment_amount; |
|
130 | 130 | |
131 | - if($request->mode == 1) |
|
132 | - { |
|
131 | + if($request->mode == 1) |
|
132 | + { |
|
133 | 133 | if ($request->payment_amount == $invoice_total) |
134 | 134 | { |
135 | - $paymentStatus = \constPaymentStatus::Paid; |
|
135 | + $paymentStatus = \constPaymentStatus::Paid; |
|
136 | 136 | } |
137 | 137 | elseif($request->payment_amount > 0 && $request->payment_amount < $invoice_total) |
138 | 138 | { |
139 | - $paymentStatus = \constPaymentStatus::Partial; |
|
139 | + $paymentStatus = \constPaymentStatus::Partial; |
|
140 | 140 | } |
141 | 141 | elseif($request->payment_amount == 0) |
142 | 142 | { |
143 | - $paymentStatus = \constPaymentStatus::Unpaid; |
|
143 | + $paymentStatus = \constPaymentStatus::Unpaid; |
|
144 | 144 | } |
145 | 145 | else |
146 | 146 | { |
147 | - $paymentStatus = \constPaymentStatus::Overpaid; |
|
147 | + $paymentStatus = \constPaymentStatus::Overpaid; |
|
148 | + } |
|
148 | 149 | } |
149 | - } |
|
150 | 150 | |
151 | - // Storing Invoice |
|
151 | + // Storing Invoice |
|
152 | 152 | $invoiceData = array('invoice_number'=> $request->invoice_number, |
153 | - 'member_id'=> $request->member_id, |
|
154 | - 'total'=> $invoice_total, |
|
155 | - 'status'=> $paymentStatus, |
|
156 | - 'pending_amount'=> $pending, |
|
157 | - 'discount_amount'=> $request->discount_amount, |
|
158 | - 'discount_percent'=> $request->discount_percent, |
|
159 | - 'discount_note'=> $request->discount_note, |
|
160 | - 'tax'=> $request->taxes_amount, |
|
161 | - 'additional_fees'=> $request->additional_fees, |
|
162 | - 'note'=>' '); |
|
153 | + 'member_id'=> $request->member_id, |
|
154 | + 'total'=> $invoice_total, |
|
155 | + 'status'=> $paymentStatus, |
|
156 | + 'pending_amount'=> $pending, |
|
157 | + 'discount_amount'=> $request->discount_amount, |
|
158 | + 'discount_percent'=> $request->discount_percent, |
|
159 | + 'discount_note'=> $request->discount_note, |
|
160 | + 'tax'=> $request->taxes_amount, |
|
161 | + 'additional_fees'=> $request->additional_fees, |
|
162 | + 'note'=>' '); |
|
163 | 163 | |
164 | 164 | $invoice = new Invoice($invoiceData); |
165 | 165 | $invoice->createdBy()->associate(Auth::user()); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | // Storing subscription |
170 | 170 | foreach($request->plan as $plan) |
171 | 171 | { |
172 | - $subscriptionData = array('member_id'=> $request->member_id, |
|
172 | + $subscriptionData = array('member_id'=> $request->member_id, |
|
173 | 173 | 'invoice_id'=> $invoice->id, |
174 | 174 | 'plan_id'=> $plan['id'], |
175 | 175 | 'start_date'=> $plan['start_date'], |
@@ -177,35 +177,35 @@ discard block |
||
177 | 177 | 'status'=> \constSubscription::onGoing, |
178 | 178 | 'is_renewal'=>'0'); |
179 | 179 | |
180 | - $subscription = new Subscription($subscriptionData); |
|
181 | - $subscription->createdBy()->associate(Auth::user()); |
|
182 | - $subscription->updatedBy()->associate(Auth::user()); |
|
183 | - $subscription->save(); |
|
180 | + $subscription = new Subscription($subscriptionData); |
|
181 | + $subscription->createdBy()->associate(Auth::user()); |
|
182 | + $subscription->updatedBy()->associate(Auth::user()); |
|
183 | + $subscription->save(); |
|
184 | 184 | |
185 | - //Adding subscription to invoice(Invoice Details) |
|
186 | - $detailsData = array('invoice_id'=> $invoice->id, |
|
187 | - 'plan_id'=> $plan['id'], |
|
188 | - 'item_amount'=> $plan['price']); |
|
185 | + //Adding subscription to invoice(Invoice Details) |
|
186 | + $detailsData = array('invoice_id'=> $invoice->id, |
|
187 | + 'plan_id'=> $plan['id'], |
|
188 | + 'item_amount'=> $plan['price']); |
|
189 | 189 | |
190 | - $invoice_details = new Invoice_detail($detailsData); |
|
191 | - $invoice_details->createdBy()->associate(Auth::user()); |
|
192 | - $invoice_details->updatedBy()->associate(Auth::user()); |
|
193 | - $invoice_details->save(); |
|
190 | + $invoice_details = new Invoice_detail($detailsData); |
|
191 | + $invoice_details->createdBy()->associate(Auth::user()); |
|
192 | + $invoice_details->updatedBy()->associate(Auth::user()); |
|
193 | + $invoice_details->save(); |
|
194 | 194 | } |
195 | 195 | |
196 | - //Payment Details |
|
197 | - $paymentData = array('invoice_id'=> $invoice->id, |
|
198 | - 'payment_amount'=> $request->payment_amount, |
|
199 | - 'mode'=> $request->mode, |
|
200 | - 'note'=> ' '); |
|
196 | + //Payment Details |
|
197 | + $paymentData = array('invoice_id'=> $invoice->id, |
|
198 | + 'payment_amount'=> $request->payment_amount, |
|
199 | + 'mode'=> $request->mode, |
|
200 | + 'note'=> ' '); |
|
201 | 201 | |
202 | - $payment_details = new Payment_detail($paymentData); |
|
203 | - $payment_details->createdBy()->associate(Auth::user()); |
|
204 | - $payment_details->updatedBy()->associate(Auth::user()); |
|
205 | - $payment_details->save(); |
|
202 | + $payment_details = new Payment_detail($paymentData); |
|
203 | + $payment_details->createdBy()->associate(Auth::user()); |
|
204 | + $payment_details->updatedBy()->associate(Auth::user()); |
|
205 | + $payment_details->save(); |
|
206 | 206 | |
207 | - if($request->mode == 0) |
|
208 | - { |
|
207 | + if($request->mode == 0) |
|
208 | + { |
|
209 | 209 | // Store Cheque Details |
210 | 210 | $chequeData = array('payment_id'=> $payment_details->id, |
211 | 211 | 'number'=> $request->number, |
@@ -216,98 +216,98 @@ discard block |
||
216 | 216 | $cheque_details->createdBy()->associate(Auth::user()); |
217 | 217 | $cheque_details->updatedBy()->associate(Auth::user()); |
218 | 218 | $cheque_details->save(); |
219 | - } |
|
219 | + } |
|
220 | 220 | |
221 | - // Set the subscription status of the 'Renewed' subscription to Renew |
|
222 | - if ($request->has('previousSubscriptions')) |
|
223 | - { |
|
221 | + // Set the subscription status of the 'Renewed' subscription to Renew |
|
222 | + if ($request->has('previousSubscriptions')) |
|
223 | + { |
|
224 | 224 | Subscription::where('invoice_id',$invoice->id)->update(['is_renewal' => '1']); |
225 | 225 | |
226 | 226 | foreach($request->previousSubscriptions as $subscriptionId) |
227 | 227 | { |
228 | - $oldSubscription=Subscription::findOrFail($subscriptionId); |
|
229 | - $oldSubscription->status = \constSubscription::renewed; |
|
230 | - $oldSubscription->updatedBy()->associate(Auth::user()); |
|
231 | - $oldSubscription->save(); |
|
228 | + $oldSubscription=Subscription::findOrFail($subscriptionId); |
|
229 | + $oldSubscription->status = \constSubscription::renewed; |
|
230 | + $oldSubscription->updatedBy()->associate(Auth::user()); |
|
231 | + $oldSubscription->save(); |
|
232 | 232 | } |
233 | - } |
|
233 | + } |
|
234 | 234 | |
235 | - //Updating Numbering Counters |
|
236 | - Setting::where('key', '=','invoice_last_number')->update(['value' => $request->invoiceCounter]); |
|
237 | - $sender_id = \Utilities::getSetting('sms_sender_id'); |
|
238 | - $gym_name = \Utilities::getSetting('gym_name'); |
|
235 | + //Updating Numbering Counters |
|
236 | + Setting::where('key', '=','invoice_last_number')->update(['value' => $request->invoiceCounter]); |
|
237 | + $sender_id = \Utilities::getSetting('sms_sender_id'); |
|
238 | + $gym_name = \Utilities::getSetting('gym_name'); |
|
239 | 239 | |
240 | - //SMS Trigger |
|
241 | - if ($invoice->status == \constPaymentStatus::Paid) |
|
242 | - { |
|
240 | + //SMS Trigger |
|
241 | + if ($invoice->status == \constPaymentStatus::Paid) |
|
242 | + { |
|
243 | 243 | if($request->mode == 0) |
244 | 244 | { |
245 | - $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
|
246 | - $message = $sms_trigger->message; |
|
247 | - $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
|
248 | - $sms_status = $sms_trigger->status; |
|
245 | + $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
|
246 | + $message = $sms_trigger->message; |
|
247 | + $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
|
248 | + $sms_status = $sms_trigger->status; |
|
249 | 249 | |
250 | - \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
250 | + \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
251 | 251 | } |
252 | 252 | else |
253 | 253 | { |
254 | - $sms_trigger = Sms_trigger::where('alias','=','subscription_renewal_with_paid_invoice')->first(); |
|
255 | - $message = $sms_trigger->message; |
|
256 | - $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$invoice->invoice_number); |
|
257 | - $sms_status = $sms_trigger->status; |
|
254 | + $sms_trigger = Sms_trigger::where('alias','=','subscription_renewal_with_paid_invoice')->first(); |
|
255 | + $message = $sms_trigger->message; |
|
256 | + $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$invoice->invoice_number); |
|
257 | + $sms_status = $sms_trigger->status; |
|
258 | 258 | |
259 | - \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
259 | + \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
260 | 260 | } |
261 | 261 | |
262 | - } |
|
263 | - elseif($invoice->status == \constPaymentStatus::Partial) |
|
264 | - { |
|
262 | + } |
|
263 | + elseif($invoice->status == \constPaymentStatus::Partial) |
|
264 | + { |
|
265 | 265 | if($request->mode == 0) |
266 | 266 | { |
267 | - $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
|
268 | - $message = $sms_trigger->message; |
|
269 | - $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
|
270 | - $sms_status = $sms_trigger->status; |
|
267 | + $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
|
268 | + $message = $sms_trigger->message; |
|
269 | + $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
|
270 | + $sms_status = $sms_trigger->status; |
|
271 | 271 | |
272 | - \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
272 | + \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
273 | 273 | } |
274 | 274 | else |
275 | 275 | { |
276 | - $sms_trigger = Sms_trigger::where('alias','=','subscription_renewal_with_partial_invoice')->first(); |
|
277 | - $message = $sms_trigger->message; |
|
278 | - $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$invoice->invoice_number,$invoice->pending_amount); |
|
279 | - $sms_status = $sms_trigger->status; |
|
276 | + $sms_trigger = Sms_trigger::where('alias','=','subscription_renewal_with_partial_invoice')->first(); |
|
277 | + $message = $sms_trigger->message; |
|
278 | + $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$invoice->invoice_number,$invoice->pending_amount); |
|
279 | + $sms_status = $sms_trigger->status; |
|
280 | 280 | |
281 | - \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
281 | + \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
282 | 282 | } |
283 | 283 | |
284 | - } |
|
285 | - elseif($invoice->status == \constPaymentStatus::Unpaid) |
|
286 | - { |
|
284 | + } |
|
285 | + elseif($invoice->status == \constPaymentStatus::Unpaid) |
|
286 | + { |
|
287 | 287 | if($request->mode == 0) |
288 | 288 | { |
289 | - $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
|
290 | - $message = $sms_trigger->message; |
|
291 | - $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
|
292 | - $sms_status = $sms_trigger->status; |
|
289 | + $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
|
290 | + $message = $sms_trigger->message; |
|
291 | + $sms_text = sprintf($message,$subscription->member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
|
292 | + $sms_status = $sms_trigger->status; |
|
293 | 293 | |
294 | - \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
294 | + \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - $sms_trigger = Sms_trigger::where('alias','=','subscription_renewal_with_unpaid_invoice')->first(); |
|
299 | - $message = $sms_trigger->message; |
|
300 | - $sms_text = sprintf($message,$subscription->member->name,$invoice->total,$invoice->invoice_number); |
|
301 | - $sms_status = $sms_trigger->status; |
|
298 | + $sms_trigger = Sms_trigger::where('alias','=','subscription_renewal_with_unpaid_invoice')->first(); |
|
299 | + $message = $sms_trigger->message; |
|
300 | + $sms_text = sprintf($message,$subscription->member->name,$invoice->total,$invoice->invoice_number); |
|
301 | + $sms_status = $sms_trigger->status; |
|
302 | 302 | |
303 | - \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
303 | + \Utilities::Sms($sender_id,$subscription->member->contact,$sms_text,$sms_status); |
|
304 | 304 | } |
305 | 305 | |
306 | - } |
|
306 | + } |
|
307 | 307 | |
308 | - DB::commit(); |
|
309 | - flash()->success('Subscription was successfully created'); |
|
310 | - return redirect (action('SubscriptionsController@index')); |
|
308 | + DB::commit(); |
|
309 | + flash()->success('Subscription was successfully created'); |
|
310 | + return redirect (action('SubscriptionsController@index')); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | catch (\Exception $e) |
@@ -322,20 +322,20 @@ discard block |
||
322 | 322 | |
323 | 323 | public function edit($id) |
324 | 324 | { |
325 | - $subscription = Subscription::findOrFail($id); |
|
326 | - // $carbonToday = Carbon::today()->format('Y-m-d'); |
|
327 | - // $subscriptionEndDate = $subscription->end_date->format('Y-m-d'); |
|
328 | - $diff = Carbon::today()->diffInDays($subscription->end_date); |
|
329 | - //$gymieDiff = $diff->format('Y-m-d'); |
|
330 | - $gymieDiff = $subscription->end_date->addDays($diff); |
|
325 | + $subscription = Subscription::findOrFail($id); |
|
326 | + // $carbonToday = Carbon::today()->format('Y-m-d'); |
|
327 | + // $subscriptionEndDate = $subscription->end_date->format('Y-m-d'); |
|
328 | + $diff = Carbon::today()->diffInDays($subscription->end_date); |
|
329 | + //$gymieDiff = $diff->format('Y-m-d'); |
|
330 | + $gymieDiff = $subscription->end_date->addDays($diff); |
|
331 | 331 | |
332 | - JavaScript::put([ |
|
333 | - 'gymieToday' => Carbon::today()->format('Y-m-d'), |
|
334 | - 'gymieEndDate' => $subscription->end_date->format('Y-m-d'), |
|
335 | - 'gymieDiff' => $gymieDiff->format('Y-m-d'), |
|
336 | - ]); |
|
332 | + JavaScript::put([ |
|
333 | + 'gymieToday' => Carbon::today()->format('Y-m-d'), |
|
334 | + 'gymieEndDate' => $subscription->end_date->format('Y-m-d'), |
|
335 | + 'gymieDiff' => $gymieDiff->format('Y-m-d'), |
|
336 | + ]); |
|
337 | 337 | |
338 | - return view('subscriptions.edit', compact('subscription')); |
|
338 | + return view('subscriptions.edit', compact('subscription')); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | public function update($id, Request $request) |
@@ -358,14 +358,14 @@ discard block |
||
358 | 358 | |
359 | 359 | //Generating Invoice number |
360 | 360 | if ($invoice_number_mode == \constNumberingMode::Auto) { |
361 | - $invoiceCounter = \Utilities::getSetting('invoice_last_number') + 1; |
|
362 | - $invoicePrefix = \Utilities::getSetting('invoice_prefix'); |
|
363 | - $invoice_number = $invoicePrefix.$invoiceCounter; |
|
361 | + $invoiceCounter = \Utilities::getSetting('invoice_last_number') + 1; |
|
362 | + $invoicePrefix = \Utilities::getSetting('invoice_prefix'); |
|
363 | + $invoice_number = $invoicePrefix.$invoiceCounter; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | else { |
367 | - $invoice_number = ''; |
|
368 | - $invoiceCounter = ''; |
|
367 | + $invoice_number = ''; |
|
368 | + $invoiceCounter = ''; |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $subscriptions = Subscription::where('invoice_id',$id)->get(); |
@@ -384,9 +384,9 @@ discard block |
||
384 | 384 | |
385 | 385 | public function cancelSubscription($id) |
386 | 386 | { |
387 | - DB::beginTransaction(); |
|
388 | - try |
|
389 | - { |
|
387 | + DB::beginTransaction(); |
|
388 | + try |
|
389 | + { |
|
390 | 390 | $subscription = Subscription::findOrFail($id); |
391 | 391 | |
392 | 392 | $subscription->update(['status' => \constSubscription::cancelled]); |
@@ -396,22 +396,22 @@ discard block |
||
396 | 396 | DB::commit(); |
397 | 397 | flash()->success('Subscription was successfully cancelled'); |
398 | 398 | return redirect('subscriptions/expired'); |
399 | - } |
|
400 | - catch (Exception $e) |
|
401 | - { |
|
399 | + } |
|
400 | + catch (Exception $e) |
|
401 | + { |
|
402 | 402 | DB::rollback(); |
403 | 403 | flash()->error('Error while cancelling the Subscription'); |
404 | 404 | return redirect('subscriptions/expired'); |
405 | - } |
|
405 | + } |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
409 | 409 | public function delete($id) |
410 | 410 | { |
411 | - DB::beginTransaction(); |
|
411 | + DB::beginTransaction(); |
|
412 | 412 | |
413 | - try |
|
414 | - { |
|
413 | + try |
|
414 | + { |
|
415 | 415 | $subscription = Subscription::findOrFail($id); |
416 | 416 | $invoice = Invoice::where('id',$subscription->invoice_id)->first(); |
417 | 417 | $invoice_details = Invoice_detail::where('invoice_id',$invoice->id)->get(); |
@@ -419,13 +419,13 @@ discard block |
||
419 | 419 | |
420 | 420 | foreach($invoice_details as $invoice_detail) |
421 | 421 | { |
422 | - $invoice_detail->delete(); |
|
422 | + $invoice_detail->delete(); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | foreach($payment_details as $payment_detail) |
426 | 426 | { |
427 | - Cheque_detail::where('payment_id',$payment_detail->id)->delete(); |
|
428 | - $payment_detail->delete(); |
|
427 | + Cheque_detail::where('payment_id',$payment_detail->id)->delete(); |
|
428 | + $payment_detail->delete(); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | $subscription->delete(); |
@@ -433,39 +433,39 @@ discard block |
||
433 | 433 | |
434 | 434 | DB::commit(); |
435 | 435 | return back(); |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - catch(\Exception $e) |
|
439 | - { |
|
438 | + catch(\Exception $e) |
|
439 | + { |
|
440 | 440 | DB::rollback(); |
441 | 441 | return back(); |
442 | - } |
|
442 | + } |
|
443 | 443 | |
444 | 444 | } |
445 | 445 | |
446 | 446 | public function change($id) |
447 | 447 | { |
448 | - $subscription = Subscription::findOrFail($id); |
|
448 | + $subscription = Subscription::findOrFail($id); |
|
449 | 449 | |
450 | - $already_paid = Payment_detail::leftJoin('trn_cheque_details','trn_payment_details.id','=','trn_cheque_details.payment_id') |
|
451 | - ->whereRaw("trn_payment_details.invoice_id = $subscription->invoice_id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
452 | - ->sum('trn_payment_details.payment_amount'); |
|
450 | + $already_paid = Payment_detail::leftJoin('trn_cheque_details','trn_payment_details.id','=','trn_cheque_details.payment_id') |
|
451 | + ->whereRaw("trn_payment_details.invoice_id = $subscription->invoice_id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
452 | + ->sum('trn_payment_details.payment_amount'); |
|
453 | 453 | |
454 | - JavaScript::put([ |
|
455 | - 'taxes' => \Utilities::getSetting('taxes'), |
|
456 | - 'gymieToday' => Carbon::today()->format('Y-m-d'), |
|
457 | - 'servicesCount' => Service::count(), |
|
458 | - ]); |
|
454 | + JavaScript::put([ |
|
455 | + 'taxes' => \Utilities::getSetting('taxes'), |
|
456 | + 'gymieToday' => Carbon::today()->format('Y-m-d'), |
|
457 | + 'servicesCount' => Service::count(), |
|
458 | + ]); |
|
459 | 459 | |
460 | - return view('subscriptions.change',compact('subscription','already_paid')); |
|
460 | + return view('subscriptions.change',compact('subscription','already_paid')); |
|
461 | 461 | } |
462 | 462 | |
463 | 463 | public function modify($id, Request $request) |
464 | 464 | { |
465 | - $subscription = Subscription::findOrFail($id); |
|
465 | + $subscription = Subscription::findOrFail($id); |
|
466 | 466 | |
467 | - try |
|
468 | - { |
|
467 | + try |
|
468 | + { |
|
469 | 469 | DB::beginTransaction(); |
470 | 470 | //Helper function to set Payment status |
471 | 471 | $invoice_total = $request->admission_amount + $request->subscription_amount + $request->taxes_amount - $request->discount_amount; |
@@ -475,62 +475,62 @@ discard block |
||
475 | 475 | |
476 | 476 | if($request->mode == 1) |
477 | 477 | { |
478 | - if ($total_paid == $invoice_total) |
|
479 | - { |
|
478 | + if ($total_paid == $invoice_total) |
|
479 | + { |
|
480 | 480 | $paymentStatus = \constPaymentStatus::Paid; |
481 | - } |
|
482 | - elseif($total_paid > 0 && $total_paid < $invoice_total) |
|
483 | - { |
|
481 | + } |
|
482 | + elseif($total_paid > 0 && $total_paid < $invoice_total) |
|
483 | + { |
|
484 | 484 | $paymentStatus = \constPaymentStatus::Partial; |
485 | - } |
|
486 | - elseif($total_paid == 0) |
|
487 | - { |
|
485 | + } |
|
486 | + elseif($total_paid == 0) |
|
487 | + { |
|
488 | 488 | $paymentStatus = \constPaymentStatus::Unpaid; |
489 | - } |
|
490 | - else |
|
491 | - { |
|
489 | + } |
|
490 | + else |
|
491 | + { |
|
492 | 492 | $paymentStatus = \constPaymentStatus::Overpaid; |
493 | - } |
|
493 | + } |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | Invoice::where('id',$subscription->invoice_id)->update(['invoice_number'=> $request->invoice_number, |
497 | - 'total'=> $invoice_total, |
|
498 | - 'status'=> $paymentStatus, |
|
499 | - 'pending_amount'=> $pending, |
|
500 | - 'discount_amount'=> $request->discount_amount, |
|
501 | - 'discount_percent'=> $request->discount_percent, |
|
502 | - 'discount_note'=> $request->discount_note, |
|
503 | - 'tax'=> $request->taxes_amount, |
|
504 | - 'additional_fees'=> $request->additional_fees, |
|
505 | - 'note'=>' ']); |
|
497 | + 'total'=> $invoice_total, |
|
498 | + 'status'=> $paymentStatus, |
|
499 | + 'pending_amount'=> $pending, |
|
500 | + 'discount_amount'=> $request->discount_amount, |
|
501 | + 'discount_percent'=> $request->discount_percent, |
|
502 | + 'discount_note'=> $request->discount_note, |
|
503 | + 'tax'=> $request->taxes_amount, |
|
504 | + 'additional_fees'=> $request->additional_fees, |
|
505 | + 'note'=>' ']); |
|
506 | 506 | |
507 | 507 | foreach($request->plan as $plan) |
508 | 508 | { |
509 | - $subscription->update(['plan_id'=> $plan['id'], |
|
509 | + $subscription->update(['plan_id'=> $plan['id'], |
|
510 | 510 | 'start_date'=> $plan['start_date'], |
511 | 511 | 'end_date'=> $plan['end_date'], |
512 | 512 | 'status'=> \constSubscription::onGoing, |
513 | 513 | 'is_renewal'=>'0']); |
514 | 514 | |
515 | - //Adding subscription to invoice(Invoice Details) |
|
515 | + //Adding subscription to invoice(Invoice Details) |
|
516 | 516 | |
517 | - Invoice_detail::where('invoice_id',$subscription->invoice_id)->update(['plan_id'=> $plan['id'], |
|
518 | - 'item_amount'=> $plan['price']]); |
|
517 | + Invoice_detail::where('invoice_id',$subscription->invoice_id)->update(['plan_id'=> $plan['id'], |
|
518 | + 'item_amount'=> $plan['price']]); |
|
519 | 519 | } |
520 | 520 | |
521 | - //Payment Details |
|
522 | - $paymentData = array('invoice_id'=> $subscription->invoice_id, |
|
523 | - 'payment_amount'=> $request->payment_amount, |
|
524 | - 'mode'=> $request->mode, |
|
525 | - 'note'=> ' '); |
|
521 | + //Payment Details |
|
522 | + $paymentData = array('invoice_id'=> $subscription->invoice_id, |
|
523 | + 'payment_amount'=> $request->payment_amount, |
|
524 | + 'mode'=> $request->mode, |
|
525 | + 'note'=> ' '); |
|
526 | 526 | |
527 | - $payment_details = new Payment_detail($paymentData); |
|
528 | - $payment_details->createdBy()->associate(Auth::user()); |
|
529 | - $payment_details->updatedBy()->associate(Auth::user()); |
|
530 | - $payment_details->save(); |
|
527 | + $payment_details = new Payment_detail($paymentData); |
|
528 | + $payment_details->createdBy()->associate(Auth::user()); |
|
529 | + $payment_details->updatedBy()->associate(Auth::user()); |
|
530 | + $payment_details->save(); |
|
531 | 531 | |
532 | - if($request->mode == 0) |
|
533 | - { |
|
532 | + if($request->mode == 0) |
|
533 | + { |
|
534 | 534 | // Store Cheque Details |
535 | 535 | $chequeData = array('payment_id'=> $payment_details->id, |
536 | 536 | 'number'=> $request->number, |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | $cheque_details->createdBy()->associate(Auth::user()); |
542 | 542 | $cheque_details->updatedBy()->associate(Auth::user()); |
543 | 543 | $cheque_details->save(); |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | 546 | DB::commit(); |
547 | 547 | flash()->success('Subscription was successfully changed'); |
548 | 548 | return redirect (action('MembersController@show', ['id' => $subscription->member_id])); |
549 | - } |
|
549 | + } |
|
550 | 550 | |
551 | - catch(\Exception $e) |
|
552 | - { |
|
551 | + catch(\Exception $e) |
|
552 | + { |
|
553 | 553 | DB::rollback(); |
554 | 554 | flash()->error('Error while changing the Subscription'); |
555 | 555 | return back(); |
556 | - } |
|
556 | + } |
|
557 | 557 | |
558 | 558 | } |
559 | 559 |
@@ -30,138 +30,138 @@ discard block |
||
30 | 30 | public function index(Request $request) |
31 | 31 | { |
32 | 32 | |
33 | - $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
34 | - $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
35 | - $count = $invoicesTotal->count(); |
|
33 | + $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
34 | + $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
35 | + $count = $invoicesTotal->count(); |
|
36 | 36 | |
37 | 37 | |
38 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
39 | - { |
|
38 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
39 | + { |
|
40 | 40 | $drp_placeholder = "Select daterange filter"; |
41 | - } |
|
42 | - else |
|
43 | - { |
|
41 | + } |
|
42 | + else |
|
43 | + { |
|
44 | 44 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - $request->flash(); |
|
47 | + $request->flash(); |
|
48 | 48 | |
49 | - return view('invoices.index', compact('invoices','count','drp_placeholder')); |
|
49 | + return view('invoices.index', compact('invoices','count','drp_placeholder')); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
53 | 53 | public function unpaid(Request $request) |
54 | 54 | { |
55 | - $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',0)->paginate(10); |
|
56 | - $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',0)->get(); |
|
57 | - $count = $invoicesTotal->count(); |
|
55 | + $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',0)->paginate(10); |
|
56 | + $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',0)->get(); |
|
57 | + $count = $invoicesTotal->count(); |
|
58 | 58 | |
59 | 59 | |
60 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
61 | - { |
|
60 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
61 | + { |
|
62 | 62 | $drp_placeholder = "Select daterange filter"; |
63 | - } |
|
64 | - else |
|
65 | - { |
|
63 | + } |
|
64 | + else |
|
65 | + { |
|
66 | 66 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
67 | - } |
|
67 | + } |
|
68 | 68 | |
69 | - $request->flash(); |
|
69 | + $request->flash(); |
|
70 | 70 | |
71 | - return view('invoices.unpaid', compact('invoices','count','drp_placeholder')); |
|
71 | + return view('invoices.unpaid', compact('invoices','count','drp_placeholder')); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function paid(Request $request) |
75 | 75 | { |
76 | - $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',1)->paginate(10); |
|
77 | - $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',1)->get(); |
|
78 | - $count = $invoicesTotal->count(); |
|
76 | + $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',1)->paginate(10); |
|
77 | + $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',1)->get(); |
|
78 | + $count = $invoicesTotal->count(); |
|
79 | 79 | |
80 | 80 | |
81 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
82 | - { |
|
81 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
82 | + { |
|
83 | 83 | $drp_placeholder = "Select daterange filter"; |
84 | - } |
|
85 | - else |
|
86 | - { |
|
84 | + } |
|
85 | + else |
|
86 | + { |
|
87 | 87 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
88 | - } |
|
88 | + } |
|
89 | 89 | |
90 | - $request->flash(); |
|
90 | + $request->flash(); |
|
91 | 91 | |
92 | - return view('invoices.paid', compact('invoices','count','drp_placeholder')); |
|
92 | + return view('invoices.paid', compact('invoices','count','drp_placeholder')); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | public function partial(Request $request) |
96 | 96 | { |
97 | - $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',2)->paginate(10); |
|
98 | - $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',2)->get(); |
|
99 | - $count = $invoicesTotal->count(); |
|
97 | + $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',2)->paginate(10); |
|
98 | + $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',2)->get(); |
|
99 | + $count = $invoicesTotal->count(); |
|
100 | 100 | |
101 | 101 | |
102 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
103 | - { |
|
102 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
103 | + { |
|
104 | 104 | $drp_placeholder = "Select daterange filter"; |
105 | - } |
|
106 | - else |
|
107 | - { |
|
105 | + } |
|
106 | + else |
|
107 | + { |
|
108 | 108 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
109 | - } |
|
109 | + } |
|
110 | 110 | |
111 | - $request->flash(); |
|
111 | + $request->flash(); |
|
112 | 112 | |
113 | - return view('invoices.partial', compact('invoices','count','drp_placeholder')); |
|
113 | + return view('invoices.partial', compact('invoices','count','drp_placeholder')); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function overpaid(Request $request) |
117 | 117 | { |
118 | - $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',3)->paginate(10); |
|
119 | - $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',3)->get(); |
|
120 | - $count = $invoicesTotal->count(); |
|
118 | + $invoices = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',3)->paginate(10); |
|
119 | + $invoicesTotal = Invoice::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->where('trn_invoice.status',3)->get(); |
|
120 | + $count = $invoicesTotal->count(); |
|
121 | 121 | |
122 | 122 | |
123 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
124 | - { |
|
123 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
124 | + { |
|
125 | 125 | $drp_placeholder = "Select daterange filter"; |
126 | - } |
|
127 | - else |
|
128 | - { |
|
126 | + } |
|
127 | + else |
|
128 | + { |
|
129 | 129 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | - $request->flash(); |
|
132 | + $request->flash(); |
|
133 | 133 | |
134 | - return view('invoices.overpaid', compact('invoices','count','drp_placeholder')); |
|
134 | + return view('invoices.overpaid', compact('invoices','count','drp_placeholder')); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | public function show($id) |
138 | 138 | { |
139 | - $invoice = Invoice::findOrFail($id); |
|
140 | - $settings = \Utilities::getSettings(); |
|
139 | + $invoice = Invoice::findOrFail($id); |
|
140 | + $settings = \Utilities::getSettings(); |
|
141 | 141 | |
142 | - return view('invoices.show', compact('invoice','settings')); |
|
142 | + return view('invoices.show', compact('invoice','settings')); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | public function createPayment($id, Request $request) |
146 | 146 | { |
147 | - $invoice = Invoice::findOrFail($id); |
|
147 | + $invoice = Invoice::findOrFail($id); |
|
148 | 148 | |
149 | - return view('payments.create', compact('invoice')); |
|
149 | + return view('payments.create', compact('invoice')); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | public function delete($id) |
153 | 153 | { |
154 | - DB::beginTransaction(); |
|
154 | + DB::beginTransaction(); |
|
155 | 155 | |
156 | - try |
|
157 | - { |
|
156 | + try |
|
157 | + { |
|
158 | 158 | Invoice_detail::where('invoice_id',$id)->delete(); |
159 | 159 | $payment_details = Payment_detail::where('invoice_id',$id)->get(); |
160 | 160 | |
161 | 161 | foreach($payment_details as $payment_detail) |
162 | 162 | { |
163 | - Cheque_detail::where('payment_id',$payment_detail->id)->delete(); |
|
164 | - $payment_detail->delete(); |
|
163 | + Cheque_detail::where('payment_id',$payment_detail->id)->delete(); |
|
164 | + $payment_detail->delete(); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | Subscription::where('invoice_id',$id)->delete(); |
@@ -169,64 +169,64 @@ discard block |
||
169 | 169 | |
170 | 170 | DB::commit(); |
171 | 171 | return back(); |
172 | - } |
|
173 | - catch(\Exception $e) |
|
174 | - { |
|
172 | + } |
|
173 | + catch(\Exception $e) |
|
174 | + { |
|
175 | 175 | DB::rollback(); |
176 | 176 | return back(); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | |
181 | 181 | public function discount($id) |
182 | 182 | { |
183 | - $invoice = Invoice::findOrFail($id); |
|
183 | + $invoice = Invoice::findOrFail($id); |
|
184 | 184 | |
185 | - JavaScript::put([ |
|
185 | + JavaScript::put([ |
|
186 | 186 | 'taxes' => \Utilities::getSetting('taxes'), |
187 | 187 | 'gymieToday' => Carbon::today()->format('Y-m-d'), |
188 | 188 | 'servicesCount' => Service::count(), |
189 | 189 | ]); |
190 | 190 | |
191 | - return view('invoices.discount',compact('invoice')); |
|
191 | + return view('invoices.discount',compact('invoice')); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | public function applyDiscount($id, Request $request) |
195 | 195 | { |
196 | - DB::beginTransaction(); |
|
196 | + DB::beginTransaction(); |
|
197 | 197 | |
198 | - try |
|
199 | - { |
|
198 | + try |
|
199 | + { |
|
200 | 200 | $invoice_total = $request->admission_amount + $request->subscription_amount + $request->taxes_amount - $request->discount_amount; |
201 | 201 | $already_paid = Payment_detail::leftJoin('trn_cheque_details','trn_payment_details.id','=','trn_cheque_details.payment_id') |
202 | - ->whereRaw("trn_payment_details.invoice_id = $id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
203 | - ->sum('trn_payment_details.payment_amount'); |
|
202 | + ->whereRaw("trn_payment_details.invoice_id = $id AND (trn_cheque_details.`status` = 2 or trn_cheque_details.`status` IS NULL)") |
|
203 | + ->sum('trn_payment_details.payment_amount'); |
|
204 | 204 | |
205 | 205 | $pending = $invoice_total - $already_paid; |
206 | 206 | |
207 | 207 | $status = \Utilities::setInvoiceStatus($pending,$invoice_total); |
208 | 208 | |
209 | 209 | Invoice::where('id',$id)->update(['invoice_number'=> $request->invoice_number, |
210 | - 'total'=> $invoice_total, |
|
211 | - 'status'=> $status, |
|
212 | - 'pending_amount'=> $pending, |
|
213 | - 'discount_amount'=> $request->discount_amount, |
|
214 | - 'discount_percent'=> $request->discount_percent, |
|
215 | - 'discount_note'=> $request->discount_note, |
|
216 | - 'tax'=> $request->taxes_amount, |
|
217 | - 'additional_fees'=> $request->additional_fees, |
|
218 | - 'note'=>' ']); |
|
210 | + 'total'=> $invoice_total, |
|
211 | + 'status'=> $status, |
|
212 | + 'pending_amount'=> $pending, |
|
213 | + 'discount_amount'=> $request->discount_amount, |
|
214 | + 'discount_percent'=> $request->discount_percent, |
|
215 | + 'discount_note'=> $request->discount_note, |
|
216 | + 'tax'=> $request->taxes_amount, |
|
217 | + 'additional_fees'=> $request->additional_fees, |
|
218 | + 'note'=>' ']); |
|
219 | 219 | |
220 | 220 | DB::commit(); |
221 | 221 | flash()->success('Discount was successfully updated'); |
222 | 222 | return redirect(action('InvoicesController@show', ['id' => $id])); |
223 | - } |
|
224 | - catch(\Exception $e) |
|
225 | - { |
|
223 | + } |
|
224 | + catch(\Exception $e) |
|
225 | + { |
|
226 | 226 | DB::rollback(); |
227 | 227 | flash()->error('Error while updating discount. Please try again'); |
228 | 228 | return back(); |
229 | - } |
|
229 | + } |
|
230 | 230 | |
231 | 231 | } |
232 | 232 |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | |
25 | 25 | public function triggersIndex(Request $request) |
26 | 26 | { |
27 | - $triggers = Sms_trigger::search($request->input('search'))->get(); |
|
27 | + $triggers = Sms_trigger::search($request->input('search'))->get(); |
|
28 | 28 | |
29 | - return view('sms.triggers.index',compact('triggers')); |
|
29 | + return view('sms.triggers.index',compact('triggers')); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function triggerUpdate(Request $request) |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | $Clienttriggers = collect($request->triggers); |
36 | 36 | //dd($request->triggers); |
37 | 37 | |
38 | - foreach ($DBtriggers as $trigger) |
|
38 | + foreach ($DBtriggers as $trigger) |
|
39 | 39 | { |
40 | 40 | $status = ($Clienttriggers->contains($trigger->id) ? 1 : 0); |
41 | 41 | |
42 | 42 | Sms_trigger::where('id','=',$trigger['id'])->update(['status' => $status]); |
43 | 43 | } |
44 | 44 | |
45 | - flash()->success('Message triggers were successfully updated'); |
|
46 | - return redirect('sms/triggers'); |
|
45 | + flash()->success('Message triggers were successfully updated'); |
|
46 | + return redirect('sms/triggers'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | public function eventsIndex(Request $request) |
@@ -17,29 +17,29 @@ discard block |
||
17 | 17 | { |
18 | 18 | $this->middleware('auth'); |
19 | 19 | } |
20 | - /* Display a listing of the resource. |
|
20 | + /* Display a listing of the resource. |
|
21 | 21 | * |
22 | 22 | * @return Response |
23 | 23 | */ |
24 | 24 | public function index(Request $request) |
25 | 25 | { |
26 | - $expenses = Expense::indexQuery($request->category_id,$request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
27 | - $expenseTotal = Expense::indexQuery($request->category_id,$request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
28 | - $count = $expenseTotal->sum('amount'); |
|
26 | + $expenses = Expense::indexQuery($request->category_id,$request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
27 | + $expenseTotal = Expense::indexQuery($request->category_id,$request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
28 | + $count = $expenseTotal->sum('amount'); |
|
29 | 29 | |
30 | 30 | |
31 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
32 | - { |
|
31 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
32 | + { |
|
33 | 33 | $drp_placeholder = "Select daterange filter"; |
34 | - } |
|
35 | - else |
|
36 | - { |
|
34 | + } |
|
35 | + else |
|
36 | + { |
|
37 | 37 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
38 | - } |
|
38 | + } |
|
39 | 39 | |
40 | - $request->flash(); |
|
40 | + $request->flash(); |
|
41 | 41 | |
42 | - return view('expenses.index', compact('expenses','count','drp_placeholder')); |
|
42 | + return view('expenses.index', compact('expenses','count','drp_placeholder')); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -50,34 +50,34 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function show() |
52 | 52 | { |
53 | - $expense = Expense::findOrFail($id); |
|
53 | + $expense = Expense::findOrFail($id); |
|
54 | 54 | |
55 | - return view('expenses.show', compact('expense')); |
|
55 | + return view('expenses.show', compact('expense')); |
|
56 | 56 | } |
57 | 57 | |
58 | - /** |
|
59 | - * Show the form for creating a new resource. |
|
60 | - * |
|
61 | - * @return Response |
|
62 | - */ |
|
58 | + /** |
|
59 | + * Show the form for creating a new resource. |
|
60 | + * |
|
61 | + * @return Response |
|
62 | + */ |
|
63 | 63 | public function create() |
64 | 64 | { |
65 | - return view('expenses.create'); |
|
65 | + return view('expenses.create'); |
|
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Store a newly created resource in storage. |
|
70 | - * |
|
71 | - * @return Response |
|
72 | - */ |
|
68 | + /** |
|
69 | + * Store a newly created resource in storage. |
|
70 | + * |
|
71 | + * @return Response |
|
72 | + */ |
|
73 | 73 | public function store(Request $request) |
74 | 74 | { |
75 | 75 | $expenseData = array('name' => $request->name, |
76 | - 'category_id' => $request->category_id, |
|
77 | - 'due_date' => $request->due_date, |
|
78 | - 'repeat' => $request->repeat, |
|
79 | - 'note' => $request->note, |
|
80 | - 'amount' => $request->amount); |
|
76 | + 'category_id' => $request->category_id, |
|
77 | + 'due_date' => $request->due_date, |
|
78 | + 'repeat' => $request->repeat, |
|
79 | + 'note' => $request->note, |
|
80 | + 'amount' => $request->amount); |
|
81 | 81 | |
82 | 82 | $expense = new Expense($expenseData); |
83 | 83 | $expense->createdBy()->associate(Auth::user()); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | |
98 | 98 | $expense->save(); |
99 | 99 | flash()->success('Expense was successfully added'); |
100 | - return redirect('expenses/all'); |
|
100 | + return redirect('expenses/all'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | public function edit($id) |
@@ -11,46 +11,46 @@ |
||
11 | 11 | |
12 | 12 | class UsersController extends Controller |
13 | 13 | { |
14 | - /** |
|
14 | + /** |
|
15 | 15 | * Display a listing of the resource. |
16 | 16 | * |
17 | 17 | * @return Response |
18 | 18 | */ |
19 | 19 | public function index() |
20 | 20 | { |
21 | - $users = user::excludeArchive()->paginate(10); |
|
21 | + $users = user::excludeArchive()->paginate(10); |
|
22 | 22 | |
23 | - return view('users.index', compact('users')); |
|
23 | + return view('users.index', compact('users')); |
|
24 | 24 | } |
25 | 25 | |
26 | - /** |
|
27 | - * Display the specified resource. |
|
28 | - * |
|
29 | - * @param int $id |
|
30 | - * @return Response |
|
31 | - */ |
|
26 | + /** |
|
27 | + * Display the specified resource. |
|
28 | + * |
|
29 | + * @param int $id |
|
30 | + * @return Response |
|
31 | + */ |
|
32 | 32 | public function show() |
33 | 33 | { |
34 | - $user = user::findOrFail($id); |
|
34 | + $user = user::findOrFail($id); |
|
35 | 35 | |
36 | - return view('users.show', compact('user')); |
|
36 | + return view('users.show', compact('user')); |
|
37 | 37 | } |
38 | 38 | |
39 | - /** |
|
40 | - * Show the form for creating a new resource. |
|
41 | - * |
|
42 | - * @return Response |
|
43 | - */ |
|
39 | + /** |
|
40 | + * Show the form for creating a new resource. |
|
41 | + * |
|
42 | + * @return Response |
|
43 | + */ |
|
44 | 44 | public function create() |
45 | 45 | { |
46 | - return view('users.create'); |
|
46 | + return view('users.create'); |
|
47 | 47 | } |
48 | 48 | |
49 | - /** |
|
50 | - * Store a newly created resource in storage. |
|
51 | - * |
|
52 | - * @return Response |
|
53 | - */ |
|
49 | + /** |
|
50 | + * Store a newly created resource in storage. |
|
51 | + * |
|
52 | + * @return Response |
|
53 | + */ |
|
54 | 54 | public function store(Request $request) |
55 | 55 | { |
56 | 56 | $this->validate($request, ['email' => 'unique:mst_users,email']); |
@@ -10,23 +10,23 @@ |
||
10 | 10 | |
11 | 11 | class SettingsController extends Controller |
12 | 12 | { |
13 | - public function __construct() |
|
13 | + public function __construct() |
|
14 | 14 | { |
15 | 15 | $this->middleware('auth'); |
16 | 16 | } |
17 | 17 | |
18 | 18 | public function show() |
19 | 19 | { |
20 | - $settings = \Utilities::getSettings(); |
|
20 | + $settings = \Utilities::getSettings(); |
|
21 | 21 | |
22 | - return view('settings.show',compact('settings')); |
|
22 | + return view('settings.show',compact('settings')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function edit() |
26 | 26 | { |
27 | - $settings = \Utilities::getSettings(); |
|
27 | + $settings = \Utilities::getSettings(); |
|
28 | 28 | |
29 | - return view('settings.edit',compact('settings')); |
|
29 | + return view('settings.edit',compact('settings')); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function save(Request $request) |
@@ -82,7 +82,7 @@ |
||
82 | 82 | */ |
83 | 83 | public function postLogin(LoginRequest $request) |
84 | 84 | { |
85 | - if($this->auth->attempt(['email'=> $request->email, 'password'=> $request->password , 'status'=> 1],$request->remember)) |
|
85 | + if($this->auth->attempt(['email'=> $request->email, 'password'=> $request->password , 'status'=> 1],$request->remember)) |
|
86 | 86 | |
87 | 87 | { |
88 | 88 | return redirect()->intended('/dashboard'); |
@@ -27,92 +27,92 @@ discard block |
||
27 | 27 | { |
28 | 28 | $this->middleware('auth'); |
29 | 29 | } |
30 | - /** |
|
30 | + /** |
|
31 | 31 | * Display a listing of the resource. |
32 | 32 | * |
33 | 33 | * @return Response |
34 | 34 | */ |
35 | 35 | public function index(Request $request) |
36 | 36 | { |
37 | - $members = Member::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
38 | - $memberTotal = Member::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
39 | - $count = $memberTotal->count(); |
|
37 | + $members = Member::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
38 | + $memberTotal = Member::indexQuery($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
39 | + $count = $memberTotal->count(); |
|
40 | 40 | |
41 | 41 | |
42 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
43 | - { |
|
42 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
43 | + { |
|
44 | 44 | $drp_placeholder = "Select daterange filter"; |
45 | - } |
|
46 | - else |
|
47 | - { |
|
45 | + } |
|
46 | + else |
|
47 | + { |
|
48 | 48 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
49 | - } |
|
49 | + } |
|
50 | 50 | |
51 | - $request->flash(); |
|
51 | + $request->flash(); |
|
52 | 52 | |
53 | - return view('members.index', compact('members','count','drp_placeholder','old_sort')); |
|
53 | + return view('members.index', compact('members','count','drp_placeholder','old_sort')); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function active(Request $request) |
57 | 57 | { |
58 | - $members = Member::active($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
59 | - $Totalmembers = Member::active($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
60 | - $count = $Totalmembers->count(); |
|
58 | + $members = Member::active($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
59 | + $Totalmembers = Member::active($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
60 | + $count = $Totalmembers->count(); |
|
61 | 61 | |
62 | 62 | |
63 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
64 | - { |
|
63 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
64 | + { |
|
65 | 65 | $drp_placeholder = "Select daterange filter"; |
66 | - } |
|
67 | - else |
|
68 | - { |
|
66 | + } |
|
67 | + else |
|
68 | + { |
|
69 | 69 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
70 | - } |
|
70 | + } |
|
71 | 71 | |
72 | - $request->flash(); |
|
72 | + $request->flash(); |
|
73 | 73 | |
74 | - return view('members.active', compact('members','count','drp_placeholder','old_sort')); |
|
74 | + return view('members.active', compact('members','count','drp_placeholder','old_sort')); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | public function inactive(Request $request) |
78 | 78 | { |
79 | - $members = Member::inactive($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
80 | - $Totalmembers = Member::inactive($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
81 | - $count = $Totalmembers->count(); |
|
79 | + $members = Member::inactive($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->paginate(10); |
|
80 | + $Totalmembers = Member::inactive($request->sort_field,$request->sort_direction,$request->drp_start,$request->drp_end)->search('"'.$request->input('search').'"')->get(); |
|
81 | + $count = $Totalmembers->count(); |
|
82 | 82 | |
83 | 83 | |
84 | - if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
85 | - { |
|
84 | + if (!$request->has('drp_start') or !$request->has('drp_end')) |
|
85 | + { |
|
86 | 86 | $drp_placeholder = "Select daterange filter"; |
87 | - } |
|
88 | - else |
|
89 | - { |
|
87 | + } |
|
88 | + else |
|
89 | + { |
|
90 | 90 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
91 | - } |
|
91 | + } |
|
92 | 92 | |
93 | - $request->flash(); |
|
93 | + $request->flash(); |
|
94 | 94 | |
95 | - return view('members.inactive', compact('members','count','drp_placeholder','old_sort')); |
|
95 | + return view('members.inactive', compact('members','count','drp_placeholder','old_sort')); |
|
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Display the specified resource. |
|
100 | - * |
|
101 | - * @param int $id |
|
102 | - * @return Response |
|
103 | - */ |
|
98 | + /** |
|
99 | + * Display the specified resource. |
|
100 | + * |
|
101 | + * @param int $id |
|
102 | + * @return Response |
|
103 | + */ |
|
104 | 104 | public function show($id) |
105 | 105 | { |
106 | - $member = Member::findOrFail($id); |
|
106 | + $member = Member::findOrFail($id); |
|
107 | 107 | |
108 | - return view('members.show', compact('member')); |
|
108 | + return view('members.show', compact('member')); |
|
109 | 109 | } |
110 | 110 | |
111 | - /** |
|
112 | - * Show the form for creating a new resource. |
|
113 | - * |
|
114 | - * @return Response |
|
115 | - */ |
|
111 | + /** |
|
112 | + * Show the form for creating a new resource. |
|
113 | + * |
|
114 | + * @return Response |
|
115 | + */ |
|
116 | 116 | public function create() |
117 | 117 | { |
118 | 118 | // For Tax calculation |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | $memberCounter = ''; |
151 | 151 | } |
152 | 152 | |
153 | - return view('members.create',compact('invoice_number','invoiceCounter','member_code','memberCounter','member_number_mode','invoice_number_mode')); |
|
153 | + return view('members.create',compact('invoice_number','invoiceCounter','member_code','memberCounter','member_number_mode','invoice_number_mode')); |
|
154 | 154 | } |
155 | 155 | |
156 | - /** |
|
157 | - * Store a newly created resource in storage. |
|
158 | - * |
|
159 | - * @return Response |
|
160 | - */ |
|
156 | + /** |
|
157 | + * Store a newly created resource in storage. |
|
158 | + * |
|
159 | + * @return Response |
|
160 | + */ |
|
161 | 161 | public function store(Request $request) |
162 | 162 | { |
163 | 163 | // Member Model Validation |
164 | 164 | $this->validate($request, ['email' => 'unique:mst_members,email', |
165 | - 'contact' => 'unique:mst_members,contact', |
|
166 | - 'member_code' => 'unique:mst_members,member_code']); |
|
165 | + 'contact' => 'unique:mst_members,contact', |
|
166 | + 'member_code' => 'unique:mst_members,member_code']); |
|
167 | 167 | |
168 | 168 | // Start Transaction |
169 | 169 | DB::beginTransaction(); |
@@ -195,12 +195,12 @@ discard block |
||
195 | 195 | // Adding media i.e. Profile & proof photo |
196 | 196 | if($request->hasFile('photo')) |
197 | 197 | { |
198 | - $member->addMedia($request->file('photo'))->usingFileName('profile_'.$member->id.$request->photo->getClientOriginalExtension())->toCollection('profile'); |
|
198 | + $member->addMedia($request->file('photo'))->usingFileName('profile_'.$member->id.$request->photo->getClientOriginalExtension())->toCollection('profile'); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | if($request->hasFile('proof_photo')) |
202 | 202 | { |
203 | - $member->addMedia($request->file('proof_photo'))->usingFileName('proof_'.$member->id.$request->proof_photo->getClientOriginalExtension())->toCollection('proof'); |
|
203 | + $member->addMedia($request->file('proof_photo'))->usingFileName('proof_'.$member->id.$request->proof_photo->getClientOriginalExtension())->toCollection('proof'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | // Helper function for calculating payment status |
@@ -210,36 +210,36 @@ discard block |
||
210 | 210 | |
211 | 211 | if($request->mode == 1) |
212 | 212 | { |
213 | - if ($request->payment_amount == $invoice_total) |
|
214 | - { |
|
213 | + if ($request->payment_amount == $invoice_total) |
|
214 | + { |
|
215 | 215 | $paymentStatus = \constPaymentStatus::Paid; |
216 | - } |
|
217 | - elseif($request->payment_amount > 0 && $request->payment_amount < $invoice_total) |
|
218 | - { |
|
216 | + } |
|
217 | + elseif($request->payment_amount > 0 && $request->payment_amount < $invoice_total) |
|
218 | + { |
|
219 | 219 | $paymentStatus = \constPaymentStatus::Partial; |
220 | - } |
|
221 | - elseif($request->payment_amount == 0) |
|
222 | - { |
|
220 | + } |
|
221 | + elseif($request->payment_amount == 0) |
|
222 | + { |
|
223 | 223 | $paymentStatus = \constPaymentStatus::Unpaid; |
224 | - } |
|
225 | - else |
|
226 | - { |
|
224 | + } |
|
225 | + else |
|
226 | + { |
|
227 | 227 | $paymentStatus = \constPaymentStatus::Overpaid; |
228 | - } |
|
228 | + } |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // Storing Invoice |
232 | 232 | $invoiceData = array('invoice_number'=> $request->invoice_number, |
233 | - 'member_id'=> $member->id, |
|
234 | - 'total'=> $invoice_total, |
|
235 | - 'status'=> $paymentStatus, |
|
236 | - 'pending_amount'=> $pending, |
|
237 | - 'discount_amount'=> $request->discount_amount, |
|
238 | - 'discount_percent'=> $request->discount_percent, |
|
239 | - 'discount_note'=> $request->discount_note, |
|
240 | - 'tax'=> $request->taxes_amount, |
|
241 | - 'additional_fees'=> $request->additional_fees, |
|
242 | - 'note'=>' '); |
|
233 | + 'member_id'=> $member->id, |
|
234 | + 'total'=> $invoice_total, |
|
235 | + 'status'=> $paymentStatus, |
|
236 | + 'pending_amount'=> $pending, |
|
237 | + 'discount_amount'=> $request->discount_amount, |
|
238 | + 'discount_percent'=> $request->discount_percent, |
|
239 | + 'discount_note'=> $request->discount_note, |
|
240 | + 'tax'=> $request->taxes_amount, |
|
241 | + 'additional_fees'=> $request->additional_fees, |
|
242 | + 'note'=>' '); |
|
243 | 243 | |
244 | 244 | $invoice = new Invoice($invoiceData); |
245 | 245 | $invoice->createdBy()->associate(Auth::user()); |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | // Storing subscription |
250 | 250 | foreach($request->plan as $plan) |
251 | 251 | { |
252 | - $subscriptionData = array('member_id'=> $member->id, |
|
252 | + $subscriptionData = array('member_id'=> $member->id, |
|
253 | 253 | 'invoice_id'=> $invoice->id, |
254 | 254 | 'plan_id'=> $plan['id'], |
255 | 255 | 'start_date'=> $plan['start_date'], |
@@ -257,27 +257,27 @@ discard block |
||
257 | 257 | 'status'=> \constSubscription::onGoing, |
258 | 258 | 'is_renewal'=>'0'); |
259 | 259 | |
260 | - $subscription = new Subscription($subscriptionData); |
|
261 | - $subscription->createdBy()->associate(Auth::user()); |
|
262 | - $subscription->updatedBy()->associate(Auth::user()); |
|
263 | - $subscription->save(); |
|
260 | + $subscription = new Subscription($subscriptionData); |
|
261 | + $subscription->createdBy()->associate(Auth::user()); |
|
262 | + $subscription->updatedBy()->associate(Auth::user()); |
|
263 | + $subscription->save(); |
|
264 | 264 | |
265 | - //Adding subscription to invoice(Invoice Details) |
|
266 | - $detailsData = array('invoice_id'=> $invoice->id, |
|
267 | - 'plan_id'=> $plan['id'], |
|
268 | - 'item_amount'=> $plan['price']); |
|
265 | + //Adding subscription to invoice(Invoice Details) |
|
266 | + $detailsData = array('invoice_id'=> $invoice->id, |
|
267 | + 'plan_id'=> $plan['id'], |
|
268 | + 'item_amount'=> $plan['price']); |
|
269 | 269 | |
270 | - $invoice_details = new Invoice_detail($detailsData); |
|
271 | - $invoice_details->createdBy()->associate(Auth::user()); |
|
272 | - $invoice_details->updatedBy()->associate(Auth::user()); |
|
273 | - $invoice_details->save(); |
|
270 | + $invoice_details = new Invoice_detail($detailsData); |
|
271 | + $invoice_details->createdBy()->associate(Auth::user()); |
|
272 | + $invoice_details->updatedBy()->associate(Auth::user()); |
|
273 | + $invoice_details->save(); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | // Store Payment Details |
277 | 277 | $paymentData = array('invoice_id'=> $invoice->id, |
278 | - 'payment_amount'=> $request->payment_amount, |
|
279 | - 'mode'=> $request->mode, |
|
280 | - 'note'=> ' '); |
|
278 | + 'payment_amount'=> $request->payment_amount, |
|
279 | + 'mode'=> $request->mode, |
|
280 | + 'note'=> ' '); |
|
281 | 281 | |
282 | 282 | $payment_details = new Payment_detail($paymentData); |
283 | 283 | $payment_details->createdBy()->associate(Auth::user()); |
@@ -286,16 +286,16 @@ discard block |
||
286 | 286 | |
287 | 287 | if($request->mode == 0) |
288 | 288 | { |
289 | - // Store Cheque Details |
|
290 | - $chequeData = array('payment_id'=> $payment_details->id, |
|
291 | - 'number'=> $request->number, |
|
292 | - 'date'=> $request->date, |
|
293 | - 'status'=> \constChequeStatus::Recieved); |
|
289 | + // Store Cheque Details |
|
290 | + $chequeData = array('payment_id'=> $payment_details->id, |
|
291 | + 'number'=> $request->number, |
|
292 | + 'date'=> $request->date, |
|
293 | + 'status'=> \constChequeStatus::Recieved); |
|
294 | 294 | |
295 | - $cheque_details = new Cheque_detail($chequeData); |
|
296 | - $cheque_details->createdBy()->associate(Auth::user()); |
|
297 | - $cheque_details->updatedBy()->associate(Auth::user()); |
|
298 | - $cheque_details->save(); |
|
295 | + $cheque_details = new Cheque_detail($chequeData); |
|
296 | + $cheque_details->createdBy()->associate(Auth::user()); |
|
297 | + $cheque_details->updatedBy()->associate(Auth::user()); |
|
298 | + $cheque_details->save(); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // On member transfer update enquiry Status |
@@ -316,69 +316,69 @@ discard block |
||
316 | 316 | //SMS Trigger |
317 | 317 | if ($invoice->status == \constPaymentStatus::Paid) |
318 | 318 | { |
319 | - $sms_trigger = Sms_trigger::where('alias','=','member_admission_with_paid_invoice')->first(); |
|
320 | - $message = $sms_trigger->message; |
|
321 | - $sms_text = sprintf($message,$member->name,$gym_name,$payment_details->payment_amount,$invoice->invoice_number); |
|
322 | - $sms_status = $sms_trigger->status; |
|
319 | + $sms_trigger = Sms_trigger::where('alias','=','member_admission_with_paid_invoice')->first(); |
|
320 | + $message = $sms_trigger->message; |
|
321 | + $sms_text = sprintf($message,$member->name,$gym_name,$payment_details->payment_amount,$invoice->invoice_number); |
|
322 | + $sms_status = $sms_trigger->status; |
|
323 | 323 | |
324 | - \Utilities::Sms($sender_id,$member->contact,$sms_text,$sms_status); |
|
324 | + \Utilities::Sms($sender_id,$member->contact,$sms_text,$sms_status); |
|
325 | 325 | } |
326 | 326 | elseif($invoice->status == \constPaymentStatus::Partial) |
327 | 327 | { |
328 | - $sms_trigger = Sms_trigger::where('alias','=','member_admission_with_partial_invoice')->first(); |
|
329 | - $message = $sms_trigger->message; |
|
330 | - $sms_text = sprintf($message,$member->name,$gym_name,$payment_details->payment_amount,$invoice->invoice_number,$invoice->pending_amount); |
|
331 | - $sms_status = $sms_trigger->status; |
|
328 | + $sms_trigger = Sms_trigger::where('alias','=','member_admission_with_partial_invoice')->first(); |
|
329 | + $message = $sms_trigger->message; |
|
330 | + $sms_text = sprintf($message,$member->name,$gym_name,$payment_details->payment_amount,$invoice->invoice_number,$invoice->pending_amount); |
|
331 | + $sms_status = $sms_trigger->status; |
|
332 | 332 | |
333 | - \Utilities::Sms($sender_id,$member->contact,$sms_text,$sms_status); |
|
333 | + \Utilities::Sms($sender_id,$member->contact,$sms_text,$sms_status); |
|
334 | 334 | } |
335 | 335 | elseif($invoice->status == \constPaymentStatus::Unpaid) |
336 | 336 | { |
337 | - if($request->mode == 0) |
|
338 | - { |
|
337 | + if($request->mode == 0) |
|
338 | + { |
|
339 | 339 | $sms_trigger = Sms_trigger::where('alias','=','payment_with_cheque')->first(); |
340 | 340 | $message = $sms_trigger->message; |
341 | 341 | $sms_text = sprintf($message,$member->name,$payment_details->payment_amount,$cheque_details->number,$invoice->invoice_number,$gym_name); |
342 | 342 | $sms_status = $sms_trigger->status; |
343 | 343 | |
344 | 344 | \Utilities::Sms($sender_id,$member->contact,$sms_text,$sms_status); |
345 | - } |
|
346 | - else |
|
347 | - { |
|
345 | + } |
|
346 | + else |
|
347 | + { |
|
348 | 348 | $sms_trigger = Sms_trigger::where('alias','=','member_admission_with_unpaid_invoice')->first(); |
349 | 349 | $message = $sms_trigger->message; |
350 | 350 | $sms_text = sprintf($message,$member->name,$gym_name,$invoice->pending_amount,$invoice->invoice_number); |
351 | 351 | $sms_status = $sms_trigger->status; |
352 | 352 | |
353 | 353 | \Utilities::Sms($sender_id,$member->contact,$sms_text,$sms_status); |
354 | - } |
|
354 | + } |
|
355 | 355 | |
356 | 356 | } |
357 | 357 | |
358 | 358 | if($subscription->start_date < $member->created_at) |
359 | 359 | { |
360 | - $member->created_at = $subscription->start_date; |
|
361 | - $member->updated_at = $subscription->start_date; |
|
362 | - $member->save(); |
|
360 | + $member->created_at = $subscription->start_date; |
|
361 | + $member->updated_at = $subscription->start_date; |
|
362 | + $member->save(); |
|
363 | 363 | |
364 | - $invoice->created_at = $subscription->start_date; |
|
365 | - $invoice->updated_at = $subscription->start_date; |
|
366 | - $invoice->save(); |
|
364 | + $invoice->created_at = $subscription->start_date; |
|
365 | + $invoice->updated_at = $subscription->start_date; |
|
366 | + $invoice->save(); |
|
367 | 367 | |
368 | - foreach($invoice->invoice_details as $invoice_detail) |
|
369 | - { |
|
368 | + foreach($invoice->invoice_details as $invoice_detail) |
|
369 | + { |
|
370 | 370 | $invoice_detail->created_at = $subscription->start_date; |
371 | 371 | $invoice_detail->updated_at = $subscription->start_date; |
372 | 372 | $invoice_detail->save(); |
373 | - } |
|
373 | + } |
|
374 | 374 | |
375 | - $payment_details->created_at = $subscription->start_date; |
|
376 | - $payment_details->updated_at = $subscription->start_date; |
|
377 | - $payment_details->save(); |
|
375 | + $payment_details->created_at = $subscription->start_date; |
|
376 | + $payment_details->updated_at = $subscription->start_date; |
|
377 | + $payment_details->save(); |
|
378 | 378 | |
379 | - $subscription->created_at = $subscription->start_date; |
|
380 | - $subscription->updated_at = $subscription->start_date; |
|
381 | - $subscription->save(); |
|
379 | + $subscription->created_at = $subscription->start_date; |
|
380 | + $subscription->updated_at = $subscription->start_date; |
|
381 | + $subscription->save(); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | DB::commit(); |
@@ -426,14 +426,14 @@ discard block |
||
426 | 426 | |
427 | 427 | if($request->hasFile('photo')) |
428 | 428 | { |
429 | - $member->clearMediaCollection('profile'); |
|
430 | - $member->addMedia($request->file('photo'))->usingFileName('profile_'.$member->id.$request->photo->getClientOriginalExtension())->toCollection('profile'); |
|
429 | + $member->clearMediaCollection('profile'); |
|
430 | + $member->addMedia($request->file('photo'))->usingFileName('profile_'.$member->id.$request->photo->getClientOriginalExtension())->toCollection('profile'); |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | if($request->hasFile('proof_photo')) |
434 | 434 | { |
435 | - $member->clearMediaCollection('proof'); |
|
436 | - $member->addMedia($request->file('proof_photo'))->usingFileName('proof_'.$member->id.$request->proof_photo->getClientOriginalExtension())->toCollection('proof'); |
|
435 | + $member->clearMediaCollection('proof'); |
|
436 | + $member->addMedia($request->file('proof_photo'))->usingFileName('proof_'.$member->id.$request->proof_photo->getClientOriginalExtension())->toCollection('proof'); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | $member->updatedBy()->associate(Auth::user()); |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | |
459 | 459 | foreach($invoices as $invoice) |
460 | 460 | { |
461 | - Invoice_detail::where('invoice_id',$invoice->id)->delete(); |
|
462 | - $payment_details = Payment_detail::where('invoice_id',$invoice->id)->get(); |
|
461 | + Invoice_detail::where('invoice_id',$invoice->id)->delete(); |
|
462 | + $payment_details = Payment_detail::where('invoice_id',$invoice->id)->get(); |
|
463 | 463 | |
464 | - foreach($payment_details as $payment_detail) |
|
465 | - { |
|
464 | + foreach($payment_details as $payment_detail) |
|
465 | + { |
|
466 | 466 | Cheque_detail::where('payment_id',$payment_detail->id)->delete(); |
467 | 467 | $payment_detail->delete(); |
468 | - } |
|
468 | + } |
|
469 | 469 | |
470 | - $invoice->delete(); |
|
470 | + $invoice->delete(); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | $member = Member::findOrFail($id); |