public function save($request, $retirement_fund_id = false) { $rules = ['identity_card' => 'min:4', 'last_name' => 'min:3|regex:/^[a-záéíóúàèìòùäëïöüñ\\s]+$/i', 'first_name' => 'min:3|regex:/^[a-záéíóúàèìòùäëïöüñ\\s]+$/i', 'home_phone_number' => 'numeric', 'home_cell_phone_number' => 'numeric']; $messages = ['identity_card.min' => 'El mínimo de caracteres permitidos para Carnet de Identidad es 4', 'last_name.min' => 'El mínimo de caracteres permitidos para apellido paterno es 3', 'last_name.regex' => 'Sólo se aceptan letras para apellido paterno', 'first_name.min' => 'El mínimo de caracteres permitidos para nombres es 3', 'first_name.regex' => 'Sólo se aceptan letras para primer nombre', 'home_phone_number.numeric' => 'Sólo se aceptan números para teléfono', 'home_cell_phone_number.numeric' => 'Sólo se aceptan números para celular']; $validator = Validator::make($request->all(), $rules, $messages); if ($validator->fails()) { return redirect('retirement_fund/' . $retirement_fund_id)->withErrors($validator)->withInput(); } else { $RetirementFund = RetirementFund::afiIs($retirement_fund_id)->where('deleted_at', '=', null)->orderBy('id', 'desc')->first(); $applicant = Applicant::retirementFundIs($RetirementFund->id)->orderBy('id', 'asc')->first(); if (!$applicant) { $applicant = new Applicant(); } $applicant_type = ApplicantType::where('id', '=', $request->type_applicant)->first(); $applicant->applicant_type_id = $applicant_type->id; $applicant->retirement_fund_id = $RetirementFund->id; $applicant->identity_card = trim($request->identity_card); $applicant->last_name = trim($request->last_name); $applicant->mothers_last_name = trim($request->mothers_last_name); $applicant->first_name = trim($request->first_name); $applicant->kinship = trim($request->kinship); $applicant->home_address = trim($request->home_address); $applicant->home_phone_number = trim($request->home_phone_number); $applicant->home_cell_phone_number = trim($request->home_cell_phone_number); $applicant->work_address = trim($request->work_address); $applicant->save(); $message = "Información de Solicitante actualizada con éxito"; } Session::flash('message', $message); return redirect('retirement_fund/' . $retirement_fund_id); }
public function getYearsAndMonths_fech_ini_reco() { return Util::getYearsAndMonths($this->fech_ini_reco, $this->fech_fin_reco); } public function getNumberTram() { if ($this->code) { return $this->code . "/" . Carbon::parse($this->created_at)->year; } } public function getStatus() { if ($this->fech_ven && $this->fech_arc && $this->fech_cal && $this->fech_dic) { return "FINALIZADO"; } elseif ($this->fech_ven && $this->fech_arc && $this->fech_cal) { return "DICTAMEN LEGAL"; } elseif ($this->fech_ven && $this->fech_arc) { return "CALIFICACIÓN"; } elseif ($this->fech_ven) { return "ARCHIVO"; } else { return "VENTANILLA"; } } } RetirementFund::created(function ($retirementfund) { Activity::createdRetirementFund($retirementfund); }); RetirementFund::updating(function ($retirementfund) { Activity::updateRetirementFund($retirementfund); });
public function destroy($afid) { $retirement_fund = RetirementFund::afiIs($afid)->first(); $retirement_fund->delete(); $message = "Trámite de Fondo de Retiro Eliminado"; Session::flash('message', $message); return redirect('afiliado/' . $afid); }
/** * Show the application dashboard to the user. * * @return Response */ public function showIndex() { $AfiServ = DB::table('affiliates')->select(DB::raw('COUNT(*) totalAfiS'))->where('affiliates.affiliate_state_id', '=', 1)->get(); foreach ($AfiServ as $item) { $totalAfiServ = $item->totalAfiS; } $AfiComi = DB::table('affiliates')->select(DB::raw('COUNT(*) totalAfiC'))->where('affiliates.affiliate_state_id', '=', 2)->get(); foreach ($AfiComi as $item) { $totalAfiComi = $item->totalAfiC; } $affiliateState = AffiliateState::all(); $affiliateType = AffiliateType::all(); $district = DB::table('units')->select(DB::raw('DISTINCT (units.district) as district'))->get(); $year = Carbon::now()->year; foreach ($affiliateState as $item) { $TotalAffiliates = Affiliate::afibyState($item->id, $year)->first(); $Total_AffiliatebyState[$item->id] = $TotalAffiliates->total; } foreach ($affiliateType as $item) { $Afitype = Affiliate::afibyType($item->id, $year)->first(); $Total_AffiliatebyType[$item->id] = $Afitype->type; } //Total Contributions of last five year, disaggregated by year. $lastContribution = DB::table('contributions')->orderBy('month_year', 'desc')->first(); if ($lastContribution) { $date_contribution = Carbon::parse($lastContribution->month_year)->subYears(5); $yearc = Carbon::parse($date_contribution)->year; $listYear = DB::table('contributions')->select(DB::raw('DISTINCT(year(contributions.month_year)) as year'))->whereYear('contributions.month_year', '>', $yearc)->orderBy('contributions.month_year', 'asc')->get(); foreach ($listYear as $item) { $totalContribution = Contribution::afiContribution($item->year)->first(); $list_totalcontribution[] = $totalContribution->total; $list_year[] = $totalContribution->month_year; } $totalContributionByYear = array($list_year, $list_totalcontribution); } else { $list_totalcontribution[] = 0; $list_year[] = 0; $totalContributionByYear = array($list_year, $list_totalcontribution); } // Total Affiliates disaggregated by district. foreach ($district as $item) { $afiDistrict = Affiliate::afiDistrict($item->district, $year)->first(); $list_affiliateByDisctrict[$item->district] = $afiDistrict->district; } //Total Retirement Fund of current year, disaggregated by month. $current_date = Carbon::now(); $current_year = Carbon::parse($current_date)->year; $monthRetirementFund = DB::table('retirement_funds')->select(DB::raw('DISTINCT(month(retirement_funds.reception_date)) as month'))->whereYear('retirement_funds.reception_date', '=', $current_year)->orderBy('retirement_funds.reception_date', 'asc')->get(); if ($monthRetirementFund) { foreach ($monthRetirementFund as $item) { $totalRetirementFundByMonth = RetirementFund::totalRetirementFund($item->month, $current_year)->first(); $list_month[] = Util::getMes($totalRetirementFundByMonth->month); $list_totalRetirementFundByMonth[] = $totalRetirementFundByMonth->total; } $total_retirementFundByMonth = array($list_month, $list_totalRetirementFundByMonth); } else { $list_month[] = 0; $list_totalRetirementFundByMonth[] = 0; $total_retirementFundByMonth = array($list_month, $list_totalRetirementFundByMonth); } //voluntary contribution by current year $monthVoluntaryContribution = DB::table('contributions')->select(DB::raw('DISTINCT(month(contributions.month_year)) as month'))->where('contributions.contribution_type_id', '=', 2)->whereYear('contributions.month_year', '=', $current_year)->orderBy('contributions.month_year', 'asc')->get(); if ($monthVoluntaryContribution) { foreach ($monthVoluntaryContribution as $item) { $totalVoluntaryContributionByMonth = Contribution::voluntaryContribution($item->month, $current_year)->first(); $list_monthVoluntaryContribution[] = Util::getMes($totalVoluntaryContributionByMonth->month); $list_amountVoluntaryContribution[] = $totalVoluntaryContributionByMonth->total; } $total_voluntayContributionByMonth = array($list_monthVoluntaryContribution, $list_amountVoluntaryContribution); } else { $list_monthVoluntaryContribution[] = 0; $list_amountVoluntaryContribution[] = 0; $total_voluntayContributionByMonth = array($list_monthVoluntaryContribution, $list_amountVoluntaryContribution); } $activities = Activity::orderBy('created_at', 'desc')->take(10)->get(); $totalAfi = $totalAfiServ + $totalAfiComi; $data = ['activities' => $activities, 'totalAfiServ' => $totalAfiServ, 'totalAfiComi' => $totalAfiComi, 'totalAfi' => $totalAfi, 'Total_AffiliatebyState' => $Total_AffiliatebyState, 'Total_AffiliatebyType' => $Total_AffiliatebyType, 'totalContributionByYear' => $totalContributionByYear, 'list_affiliateByDisctrict' => $list_affiliateByDisctrict, 'total_retirementFundByMonth' => $total_retirementFundByMonth, 'total_voluntayContributionByMonth' => $total_voluntayContributionByMonth, 'current_year' => $current_year]; return view('dashboard.index', $data); //return response()->json($totalAfiServ); }
public static function createdApplicant($applicant) { if (Auth::user()) { $RetirementFund = RetirementFund::findOrFail($applicant->retirement_fund_id); $affiliate = Affiliate::findOrFail($RetirementFund->affiliate_id); $activity = new Activity(); $activity->user_id = Auth::user()->id; $activity->affiliate_id = $affiliate->id; $activity->applicant_id = $applicant->id; $activity->retirement_fund_id = $applicant->retirement_fund_id; $activity->activity_type_id = ACTIVITY_TYPE_CREATE_APPLICANT; $activity->message = Util::encodeActivity(Auth::user(), 'Creó al Solicitante', $applicant); $activity->save(); } }