public function ReportAffiliate($token) { $header = array(array('INSTITUCION DE PREVISION SOCIAL DEL PERIODISTA'), array('Carnet: ', '', ' Fecha Nacimiento: ', ' ', 'Edad: ', 'Fecha Ingreso: '), array('Nombre: '), array('Tiempo de jubilación Voluntaria: '), array('Tiempo de jubilación Obligatorio: '), array('Pago de Cuotas Sector Privado '), array(''), array('Año', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')); $dues = $this->duesRepository->getModel()->where('affiliate_id', $affiliate->id)->orderBy('date_payment', 'ASC')->get(); if (!$dues->isEmpty()) { //"01/01/1995" $old_year = Carbon::format($dues[0]->date_payment)->getFullYear(); //1995 $last_year = Carbon::format($dues[count($dues) - 1])->getFullYear(); //2014 for ($i = $old_year; $i <= $last_year; $i++) { $row[] = $i; for ($j = 1; $j <= 12; $j++) { # code... foreach ($dues as $key => $value) { if ($value->date_payment == "01/" . $j . "/" . $i) { array_push($row, $value->amount); } else { array_push($row, ""); } } } array_push($header, $row); } } echo json_encode($header); die; /* foreach ($dues as $due) { $duesYear = $this->duesRepository->getModel()->where('date_payment',$affiliate->id)->where('affiliate_id',$affiliate->id)->orderBy('date_payment','ASC')->get(); foreach(){ $header[] = ['Año','Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre']; } }*/ }
public function niceDateRange(Carbon $date1 = null, Carbon $date2 = null, $ordinalSuffixRequired = false) { $ordinalSuffix = ""; $day1 = $date1->day; $day2 = $date2->day; $month1 = $date1->month; $month2 = $date2->month; //$ordinalSuffix = FormatMe::toOrdinalSuffix($day2); $restOfDate = $date2->format('F Y'); $myDateString = "{$day1}-{$day2}" . $ordinalSuffix; // if months are not the same, display both months in range if ($month1 !== $month2) { return "{$day1} " . $date1->format('F') . " – " . "{$day2} " . $date2->format('F Y'); } return $myDateString . ' ' . $restOfDate; }
public function dueDate() { $settings = APSetting::first(); $generated_on = new Carbon($this->generated_on); $generated_on->addDays($settings->payment_due_in_days); return $generated_on->format('d M y'); }
private function calculateHolidays($country, $fromYear, $toYear) { $return = []; if ($fromYear == $toYear) { $years = [$fromYear]; } else { $years = [$fromYear, $toYear]; } foreach ($years as $year) { $country_file = dirname(__DIR__) . '/data/' . $country . '.json'; $countryHolidays = json_decode(file_get_contents($country_file), true); foreach ($countryHolidays as $countryHoliday) { if (strstr($countryHoliday['rule'], '%Y')) { $rule = str_replace('%Y', $year, $countryHoliday['rule']); } elseif (strstr($countryHoliday['rule'], '%EASTER')) { $date = new Carbon($year . '-03-21 +' . easter_days($year) . ' days'); $rule = str_replace('%EASTER', $date->format('Y-m-d'), $countryHoliday['rule']); } elseif (in_array($country, ['BR', 'US']) && strstr($countryHoliday['rule'], '%ELECTION')) { $rule = $this->calculateElectionDay($country, $years, $year, $countryHoliday); } else { $rule = $countryHoliday['rule'] . ' ' . $year; } if ($rule) { $return[] = ['name' => $countryHoliday['name'], 'date' => new Carbon($rule)]; } } } return $return; }
/** * Check if its the birthday. Compares the date/month values of the two dates. * * @param Carbon $dt * * @return boolean */ public function isBirthday(Carbon $dt) { return $this->format('md') === $dt->format('md'); }
private function migrarRecaudosSolicitud() { $this->info("Migrando recaudos de la solicitud"); $this->getTable('recaudos_solicitud')->chunk(1000, function ($recaudos) { foreach ($recaudos as $recaudo) { $this->info("Migrando recaudo de la solicitud: " . $recaudo->codrecaudo); $recaudoNuevo = new RecaudoSolicitud(); $recaudoNuevo->recaudo_id = $recaudo->codrecaudo; $recaudoNuevo->solicitud_id = $recaudo->idsolicitud; $recaudoNuevo->ind_recibido = $recaudo->indrecibido == 'S'; if ($recaudo->fecvencimiento != '') { $carbon = new Carbon($recaudo->fecvencimiento); $recaudoNuevo->fecha_vencimiento = $carbon->format('d/m/Y'); } $recaudoNuevo->save(); } }); }
function formatTime(Carbon $time) { return $time->format('H:i'); }