public function Data(Request $request) { $vouchers = Voucher::select(['id', 'affiliate_id', 'voucher_type_id', 'code', 'created_at', 'total', 'payment_date']); if ($request->has('code')) { $vouchers->where(function ($vouchers) use($request) { $code = trim($request->get('code')); $vouchers->where('code', 'like', "%{$code}%"); }); } if ($request->has('affiliate_name')) { $vouchers->where(function ($vouchers) use($request) { $affiliate_name = trim($request->get('affiliate_name')); $vouchers->where('affiliate_name', 'like', "%{$affiliate_name}%"); }); } if ($request->has('creation_date')) { $vouchers->where(function ($vouchers) use($request) { $creation_date = Util::datePick($request->get('creation_date')); $vouchers->where('created_at', 'like', "%{$creation_date}%"); }); } if ($request->has('voucher_type')) { $vouchers->where(function ($vouchers) use($request) { $voucher_type = trim($request->get('voucher_type')); $vouchers->where('voucher_type_id', 'like', "%{$voucher_type}%"); }); } if ($request->has('payment_date')) { $vouchers->where(function ($vouchers) use($request) { $payment_date = Util::datePick($request->get('payment_date')); $vouchers->where('payment_date', 'like', "%{$payment_date}%"); }); } return Datatables::of($vouchers)->addColumn('affiliate_name', function ($voucher) { return $voucher->affiliate->getTittleName(); })->editColumn('voucher_type', function ($voucher) { return $voucher->voucher_type->name; })->addColumn('total', function ($voucher) { return Util::formatMoney($voucher->total); })->editColumn('created_at', function ($voucher) { return $voucher->getCreationDate(); })->addColumn('status', function ($voucher) { return $voucher->payment_date ? 'Pagado' : 'Pendiente'; })->editColumn('payment_date', function ($voucher) { return $voucher->payment_date ? Util::getDateShort($voucher->payment_date) : '-'; })->addColumn('action', function ($voucher) { return '<div class="btn-group" style="margin:-3px 0;"> <a href="voucher/' . $voucher->id . '" class="btn btn-primary btn-raised btn-sm"> <i class="glyphicon glyphicon-eye-open"></i> </a> <a href="" class="btn btn-primary btn-raised btn-sm dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </a> <ul class="dropdown-menu"> <li><a href="voucher/delete/ ' . $voucher->id . ' " style="padding:3px 10px;"><i class="glyphicon glyphicon-ban-circle"></i> Anular</a></li> </ul> </div>'; })->make(true); }
public function getCreationDate() { return Util::getDateShort($this->created_at); }
public function getShortDateDeath() { return Util::getDateShort($this->date_death); }
public static function getViewModel($affiliate_id, $year, $category_id = null, $last_contribution = null) { $affiliate = Affiliate::idIs($affiliate_id)->first(); $categories = Category::where('name', '<>', 'S/N')->get(); $list_categories = array('' => ''); foreach ($categories as $item) { $list_categories[$item->id] = $item->name; } $now = Carbon::now(); $from = Carbon::parse($affiliate->date_entry); $to = Carbon::createFromDate($now->year, $now->month, 1)->subMonth(); $ipc_actual = IpcRate::select('index')->where('month_year', '=', Carbon::createFromDate($now->year, $now->month, 1)->toDateString())->first(); $months = new Collection(); $month = array(); for ($j = 1; $j <= 12; $j++) { $contribution = Contribution::select(['month_year'])->where('affiliate_id', $affiliate_id)->where('month_year', '=', Carbon::createFromDate($year, $j, 1)->toDateString())->first(); $contribution_rate = ContributionRate::where('month_year', '=', Carbon::createFromDate($year, $j, 1)->toDateString())->first(); $ipc_rate = IpcRate::where('month_year', '=', Carbon::createFromDate($year, $j, 1)->toDateString())->first(); if (!$contribution) { if ($year == $from->year) { if ($j >= $from->month) { $month["id"] = $j; $month["name"] = Util::getMes($j); $month["retirement_fund"] = $contribution_rate ? $contribution_rate->retirement_fund : '0'; $month["mortuary_quota"] = $contribution_rate ? $contribution_rate->mortuary_quota : '0'; $month["ipc_rate"] = $contribution_rate ? $ipc_rate->index : '0'; $months->push($month); } } elseif ($year == $to->year) { if ($j <= $to->month) { $month["id"] = $j; $month["name"] = Util::getMes($j); $month["retirement_fund"] = $contribution_rate ? $contribution_rate->retirement_fund : '0'; $month["mortuary_quota"] = $contribution_rate ? $contribution_rate->mortuary_quota : '0'; $month["ipc_rate"] = $contribution_rate ? $ipc_rate->index : '0'; $months->push($month); } } else { $month["id"] = $j; $month["name"] = Util::getMes($j); $month["retirement_fund"] = $contribution_rate ? $contribution_rate->retirement_fund : '0'; $month["mortuary_quota"] = $contribution_rate ? $contribution_rate->mortuary_quota : '0'; $month["ipc_rate"] = $contribution_rate ? $ipc_rate->index : '0'; $months->push($month); } } } if (!$last_contribution) { $date = Carbon::createFromDate($year, $months[0]["id"], 1); $last_contribution = Contribution::affiliateidIs($affiliate->id)->where('month_year', '<', $date->toDateString())->first(); if (!$last_contribution) { $last_contribution = new Contribution(); $base_wage = BaseWage::whereYear('month_year', '<=', $year)->first(); $last_contribution->base_wage = $base_wage->amount; $last_contribution->study_bonus = 0; $last_contribution->position_bonus = 0; $last_contribution->border_bonus = 0; $last_contribution->east_bonus = 0; } $last_contribution->date = Util::getDateShort($last_contribution->month_year); } if ($category_id) { $affiliate->category_id = $category_id; } return ['affiliate' => $affiliate, 'list_categories' => $list_categories, 'categories' => Category::where('name', '<>', 'S/N')->orderBy('id', 'asc')->get(array('percentage', 'name', 'id')), 'ipc_actual' => $ipc_actual, 'months' => $months, 'year' => $year, 'last_contribution' => $last_contribution, 'direct_contribution' => '']; }
public function getShortDateEntry() { return Util::getDateShort($this->date_entry); }