lubusIN /
laravel-gymie
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace App\Http\Controllers; |
||||
| 4 | |||||
| 5 | use Illuminate\Http\Request; |
||||
| 6 | use Auth; |
||||
| 7 | use DB; |
||||
| 8 | use JavaScript; |
||||
|
0 ignored issues
–
show
|
|||||
| 9 | use Carbon\Carbon; |
||||
| 10 | use App\Invoice; |
||||
| 11 | use App\Setting; |
||||
| 12 | use App\Subscription; |
||||
| 13 | use App\Plan; |
||||
| 14 | use App\Member; |
||||
| 15 | use App\Payment; |
||||
| 16 | use App\Service; |
||||
| 17 | use App\Invoice_detail; |
||||
| 18 | use App\Payment_detail; |
||||
| 19 | use App\Cheque_detail; |
||||
| 20 | use App\Http\Requests; |
||||
| 21 | use App\Http\Controllers\Controller; |
||||
| 22 | |||||
| 23 | class InvoicesController extends Controller |
||||
| 24 | { |
||||
| 25 | public function __construct() |
||||
| 26 | { |
||||
| 27 | $this->middleware('auth'); |
||||
| 28 | } |
||||
| 29 | |||||
| 30 | public function index(Request $request) |
||||
| 31 | { |
||||
| 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(); |
||||
| 36 | |||||
| 37 | |||||
| 38 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
||||
| 39 | { |
||||
| 40 | $drp_placeholder = "Select daterange filter"; |
||||
| 41 | } |
||||
| 42 | else |
||||
| 43 | { |
||||
| 44 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
||||
| 45 | } |
||||
| 46 | |||||
| 47 | $request->flash(); |
||||
| 48 | |||||
| 49 | return view('invoices.index', compact('invoices','count','drp_placeholder')); |
||||
| 50 | |||||
| 51 | } |
||||
| 52 | |||||
| 53 | public function unpaid(Request $request) |
||||
| 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(); |
||||
| 58 | |||||
| 59 | |||||
| 60 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
||||
| 61 | { |
||||
| 62 | $drp_placeholder = "Select daterange filter"; |
||||
| 63 | } |
||||
| 64 | else |
||||
| 65 | { |
||||
| 66 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
||||
| 67 | } |
||||
| 68 | |||||
| 69 | $request->flash(); |
||||
| 70 | |||||
| 71 | return view('invoices.unpaid', compact('invoices','count','drp_placeholder')); |
||||
| 72 | } |
||||
| 73 | |||||
| 74 | public function paid(Request $request) |
||||
| 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(); |
||||
| 79 | |||||
| 80 | |||||
| 81 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
||||
| 82 | { |
||||
| 83 | $drp_placeholder = "Select daterange filter"; |
||||
| 84 | } |
||||
| 85 | else |
||||
| 86 | { |
||||
| 87 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
||||
| 88 | } |
||||
| 89 | |||||
| 90 | $request->flash(); |
||||
| 91 | |||||
| 92 | return view('invoices.paid', compact('invoices','count','drp_placeholder')); |
||||
| 93 | } |
||||
| 94 | |||||
| 95 | public function partial(Request $request) |
||||
| 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(); |
||||
| 100 | |||||
| 101 | |||||
| 102 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
||||
| 103 | { |
||||
| 104 | $drp_placeholder = "Select daterange filter"; |
||||
| 105 | } |
||||
| 106 | else |
||||
| 107 | { |
||||
| 108 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
||||
| 109 | } |
||||
| 110 | |||||
| 111 | $request->flash(); |
||||
| 112 | |||||
| 113 | return view('invoices.partial', compact('invoices','count','drp_placeholder')); |
||||
| 114 | } |
||||
| 115 | |||||
| 116 | public function overpaid(Request $request) |
||||
| 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(); |
||||
| 121 | |||||
| 122 | |||||
| 123 | if (!$request->has('drp_start') or !$request->has('drp_end')) |
||||
| 124 | { |
||||
| 125 | $drp_placeholder = "Select daterange filter"; |
||||
| 126 | } |
||||
| 127 | else |
||||
| 128 | { |
||||
| 129 | $drp_placeholder = $request->drp_start. ' - ' .$request->drp_end; |
||||
| 130 | } |
||||
| 131 | |||||
| 132 | $request->flash(); |
||||
| 133 | |||||
| 134 | return view('invoices.overpaid', compact('invoices','count','drp_placeholder')); |
||||
| 135 | } |
||||
| 136 | |||||
| 137 | public function show($id) |
||||
| 138 | { |
||||
| 139 | $invoice = Invoice::findOrFail($id); |
||||
| 140 | $settings = \Utilities::getSettings(); |
||||
| 141 | |||||
| 142 | return view('invoices.show', compact('invoice','settings')); |
||||
| 143 | } |
||||
| 144 | |||||
| 145 | public function createPayment($id, Request $request) |
||||
|
0 ignored issues
–
show
The parameter
$request is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||
| 146 | { |
||||
| 147 | $invoice = Invoice::findOrFail($id); |
||||
| 148 | |||||
| 149 | return view('payments.create', compact('invoice')); |
||||
| 150 | } |
||||
| 151 | |||||
| 152 | public function delete($id) |
||||
| 153 | { |
||||
| 154 | DB::beginTransaction(); |
||||
| 155 | |||||
| 156 | try |
||||
| 157 | { |
||||
| 158 | Invoice_detail::where('invoice_id',$id)->delete(); |
||||
| 159 | $payment_details = Payment_detail::where('invoice_id',$id)->get(); |
||||
| 160 | |||||
| 161 | foreach($payment_details as $payment_detail) |
||||
| 162 | { |
||||
| 163 | Cheque_detail::where('payment_id',$payment_detail->id)->delete(); |
||||
| 164 | $payment_detail->delete(); |
||||
| 165 | } |
||||
| 166 | |||||
| 167 | Subscription::where('invoice_id',$id)->delete(); |
||||
| 168 | Invoice::destroy($id); |
||||
| 169 | |||||
| 170 | DB::commit(); |
||||
| 171 | return back(); |
||||
| 172 | } |
||||
| 173 | catch(\Exception $e) |
||||
| 174 | { |
||||
| 175 | DB::rollback(); |
||||
| 176 | return back(); |
||||
| 177 | } |
||||
| 178 | |||||
| 179 | } |
||||
| 180 | |||||
| 181 | public function discount($id) |
||||
| 182 | { |
||||
| 183 | $invoice = Invoice::findOrFail($id); |
||||
| 184 | |||||
| 185 | JavaScript::put([ |
||||
| 186 | 'taxes' => \Utilities::getSetting('taxes'), |
||||
| 187 | 'gymieToday' => Carbon::today()->format('Y-m-d'), |
||||
| 188 | 'servicesCount' => Service::count(), |
||||
| 189 | ]); |
||||
| 190 | |||||
| 191 | return view('invoices.discount',compact('invoice')); |
||||
| 192 | } |
||||
| 193 | |||||
| 194 | public function applyDiscount($id, Request $request) |
||||
| 195 | { |
||||
| 196 | DB::beginTransaction(); |
||||
| 197 | |||||
| 198 | try |
||||
| 199 | { |
||||
| 200 | $invoice_total = $request->admission_amount + $request->subscription_amount + $request->taxes_amount - $request->discount_amount; |
||||
| 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'); |
||||
| 204 | |||||
| 205 | $pending = $invoice_total - $already_paid; |
||||
| 206 | |||||
| 207 | $status = \Utilities::setInvoiceStatus($pending,$invoice_total); |
||||
| 208 | |||||
| 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'=>' ']); |
||||
| 219 | |||||
| 220 | DB::commit(); |
||||
| 221 | flash()->success('Discount was successfully updated'); |
||||
| 222 | return redirect(action('InvoicesController@show', ['id' => $id])); |
||||
| 223 | } |
||||
| 224 | catch(\Exception $e) |
||||
| 225 | { |
||||
| 226 | DB::rollback(); |
||||
| 227 | flash()->error('Error while updating discount. Please try again'); |
||||
| 228 | return back(); |
||||
| 229 | } |
||||
| 230 | |||||
| 231 | } |
||||
| 232 | |||||
| 233 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths