public function index(Request $request)
 {
     if ($request->ajax()) {
         $client_id = Input::get('filter-client');
         $debtor_id = Input::get('filter-debtor');
         $registry = Input::get('filter-registry');
         $choice = Input::get('filter-choice');
         $commissions = DailyChargeCommission::query();
         $commissions->where('handler', true);
         if ($client_id != 0) {
             $commissions->whereHas('delivery', function ($q) use($client_id) {
                 $q->where('client_id', '=', $client_id);
             });
         }
         if ($debtor_id != 0) {
             $commissions->whereHas('delivery', function ($q) use($debtor_id) {
                 $q->where('debtor_id', '=', $debtor_id);
             });
         }
         if ($registry != 0) {
             $commissions->whereHas('delivery', function ($q) use($registry) {
                 $q->where('registry', '=', $registry);
             });
         }
         if ($choice != 0) {
             $before = Input::get('filter-before');
             $after = Input::get('filter-after');
             $arratBetween = [$before, $after];
             if ($choice == 1) {
                 $commissions->whereHas('delivery', function ($q) use($arratBetween) {
                     $q->whereBetween('date_of_registry', $arratBetween);
                 });
             } elseif ($choice == 2) {
                 $commissions->whereBetween('created_at', $arratBetween);
             }
         }
         $commissions = $commissions->get();
         return view('reportRepayment.tableRow', ['commissions' => $commissions]);
     } else {
         $clients = Client::Where('active', true)->get();
         $debtors = Debtor::all();
         $debtors = Debtor::all();
         $registries = ChargeCommission::Distinct('registry')->lists('registry');
         return view('reportRepayment.index', ['clients' => $clients, 'debtors' => $debtors, 'registries' => $registries]);
     }
 }
Beispiel #2
0
 public function index(Request $request)
 {
     $sort = Input::get('sort') == null ? 'relation_id' : Input::get('sort');
     $client_id_select = Input::get('client_id_select') == null ? 'all' : Input::get('client_id_select');
     $countCongestion = Input::get('count_congestion') == null ? 'balance_owed' : Input::get('count_congestion');
     $sortDirection = Input::get('sortDirection') == null ? 'DESC' : Input::get('sortDirection');
     $clients = Client::all();
     $debtors = Debtor::all();
     $limits = Limit::whereHas('relation', function ($query) use($client_id_select) {
         if ($client_id_select !== 'all') {
             $query->where('client_id', '=', $client_id_select);
         }
     })->get();
     $usedLimit = array();
     foreach ($limits as $key => $limit) {
         $usedLimitItem = 0;
         foreach ($limit->relation->deliveries as $value) {
             if ($value->status == 'Профинансирована') {
                 if ($countCongestion == 'remainder_of_the_debt_first_payment') {
                     $usedLimitItem += $value->remainder_of_the_debt_first_payment;
                 } else {
                     $usedLimitItem += $value->balance_owed;
                 }
             }
         }
         $usedLimit[$key] = $usedLimitItem;
     }
     $relations = Relation::select('client_id')->distinct()->get();
     if ($request->ajax()) {
         if ($sort == 'client_id') {
             return view('limits.indexAjaxClient', ['clients' => $clients, 'countCongestion' => $countCongestion]);
         } else {
             if ($sort == 'debtor_id') {
                 return view('limits.indexAjaxDebtor', ['countCongestion' => $countCongestion, 'debtors' => $debtors]);
             } else {
                 return view('limits.indexAjax', ['limits' => $limits, 'relations' => $relations, 'usedLimit' => $usedLimit]);
             }
         }
     } else {
         return view('limits.index', ['limits' => $limits, 'relations' => $relations, 'usedLimit' => $usedLimit, 'clients' => $clients]);
     }
 }
 public function index()
 {
     $clients = Client::all();
     $debtors = Debtor::all();
     return view('chargeCommission.index', ['debtors' => $debtors, 'clients' => $clients]);
 }
 public function getIndexRepayment()
 {
     $repayments = Repayment::OrderBy('date')->get();
     $clients = Client::all();
     $debtors = Debtor::all();
     return view('repayment.tableRepaymentRow', ['repayments' => $repayments, 'clients' => $clients, 'debtors' => $debtors]);
 }
Beispiel #5
0
 public function index()
 {
     $debtors = Debtor::all();
     return view('debtors.index', ['debtors' => $debtors]);
 }