public function getByDate(Carbon $date)
 {
     $return = null;
     if (isset($this->workingDays[$date->toDateString()])) {
         $return = $this->workingDays[$date->toDateString()];
     }
     return $return;
 }
Example #2
0
 private function addSlotsForDay(Carbon $day)
 {
     $result = '';
     $courts = [3, 4, 5, 6];
     $hours = [15, 16, 17, 18];
     foreach ($courts as $key => $court) {
         foreach ($hours as $key => $hour) {
             if (!Slot::where('day', $day->toDateString())->where('court', $court)->where('hour', $hour)->count()) {
                 $result .= $day->toDateString() . ', Bana ' . $court . ', kl ' . $hour . ':00 tillagd som slot.<br/>';
                 Slot::create(['day' => $day->toDateString(), 'hour' => $hour, 'court' => $court]);
             }
         }
     }
     return $result;
 }
 public function store($projectId, Request $request)
 {
     $date = new Carbon($request->date);
     $project = Project::findOrFail($projectId);
     $project->costEstimations()->create(['settled_at' => $date]);
     return redirect()->route('projects.cost-estimations.show', [$projectId, $date->toDateString()]);
 }
 /**
  * Pay billet by billet id.
  *
  * @param  int $billet_id
  * @param  Carbon $date
  *
  * @return Billet
  */
 public function pay($billet_id, Carbon $date)
 {
     $model = $this->model;
     $billet = $model->find($billet_id);
     if (!is_null($billet->discharge_date)) {
         throw new RepositoryException("You can't pay this billet");
     }
     $billet->discharge_date = $date->toDateString();
     $billet->save();
     return $billet;
 }
 public function index(Request $request)
 {
     $now = new Carbon();
     if ($request->isMethod('post')) {
         $from = new Carbon($request->input('from', $now->toDateString()));
         $to = new Carbon($request->input('to', $now->toDateString()));
         $lessons = \App\Lesson::orderBy('given_at', 'asc')->where('given_at', '>=', $from->startOfDay()->toDateTimeString())->where('given_at', '<=', $to->endOfDay()->toDateTimeString())->get();
     } else {
         $lessons = \App\Lesson::orderBy('given_at', 'asc')->get();
     }
     $groups = \App\CustomerGroup::orderBy('groupname', 'desc')->get();
     return view('lesson.index')->with(['lessons' => $lessons, 'groups' => $groups, 'now' => $now->toDateString(), 'from' => isset($from) ? $from->toDateString() : '', 'to' => isset($to) ? $to->toDateString() : '']);
 }
Example #6
0
 public function filterByDate(Carbon $date)
 {
     $lists = $this->listService->all();
     $todayTasks = new ArrayList();
     foreach ($lists as $list) {
         $tasks = new ArrayList($this->forList($list));
         $listTasks = $tasks->filter(function (Task $task) use($date) {
             if ($task->getDueDate()) {
                 $taskDate = Carbon::instance($task->getDueDate());
                 return $taskDate->toDateString() === $date->toDateString();
             }
         });
         $todayTasks->concat($listTasks);
     }
     return $todayTasks;
 }
 public function testRegister()
 {
     $birthday = new Carbon();
     $birthday->addYear(-23);
     $this->visit('/auth/register')->type('user1', 'name')->type('*****@*****.**', 'email')->type('useruser', 'password')->type('useruser', 'password_confirmation')->type($birthday->toDateTimeString(), 'bdate')->select('1', 'gender')->type('2000', 'daily_calories');
     $map = [];
     $restrictions = Restriction::all();
     foreach ($restrictions as $restriction) {
         $val = round(mt_rand() / mt_getrandmax());
         $map[$restriction->id] = $val;
         $this->type($val + 1, 'restriction' . ($restriction->id + 1));
     }
     $this->press('Register')->seePageIs('/home');
     $this->seeInDatabase('users', ['name' => 'user1', 'email' => '*****@*****.**', 'bdate' => $birthday->toDateString(), 'gender' => '0', 'daily_calories' => '2000']);
     $user = \App\User::whereEmail('*****@*****.**')->first();
     foreach ($restrictions as $restriction) {
         if ($map[$restriction->id] == 1) {
             $this->seeInDatabase('restriction_user', ['user_id' => $user->id, 'restriction_id' => $restriction->id]);
         }
     }
 }
Example #8
0
 /**
  * Scope of date.
  *
  * @param Illuminate\Database\Query $query
  * @param Carbon                    $date
  *
  * @return Illuminate\Database\Query
  */
 public function scopeOfDate($query, Carbon $date)
 {
     $date->timezone('UTC');
     return $query->whereRaw('date(`start_at`) = ?', [$date->toDateString()]);
 }
 protected function getDate($value)
 {
     if ($value) {
         $d = new Carbon($value);
         return $d->toDateString();
     } else {
         return null;
     }
 }
Example #10
0
require_once 'vendor/autoload.php';
use Carbon\Carbon;
use Citco\Carbon as CitcoCarbon;
use CarbonExt\FiscalYear\Calculator;
// Object Instantiation
$brisbane = new Carbon('2015-12-01', 'Australia/Brisbane');
$newYorkCity = new Carbon('2015-12-01', 'America/New_York');
$dtBerlin = new Carbon('2015-12-01', 'Europe/Berlin');
$outputString = "Time difference between %s & %s: %s hours.\n";
// Date difference
printf($outputString, "Berlin", "Brisbane, Australia", $dtBerlin->diffInHours($brisbane, false));
printf($outputString, "Berlin", "New York City, America", $dtBerlin->diffInHours($newYorkCity, false));
$septEighteen2014 = Carbon::createFromDate(2014, 9, 18, $dtBerlin->getTimezone());
printf("difference between now and %s in \n\thours: %d, \n\tdays: %d, \n\tweeks: %d, \n\tweekend days: %d, \n\tweek days: %s, \n\thuman readable: %s\n", $septEighteen2014->toFormattedDateString(), $dtBerlin->diffInHours($septEighteen2014), $dtBerlin->diffInDays($septEighteen2014), $dtBerlin->diffInWeeks($septEighteen2014), $dtBerlin->diffInWeekendDays($septEighteen2014), $dtBerlin->diffInWeekDays($septEighteen2014), $dtBerlin->diffForHumans($septEighteen2014));
// Date formatting
echo $dtBerlin->toDateString() . "\n";
echo $dtBerlin->toFormattedDateString() . "\n";
echo $dtBerlin->toTimeString() . "\n";
echo $dtBerlin->toDateTimeString() . "\n";
echo $dtBerlin->toDayDateTimeString() . "\n";
echo $dtBerlin->toRfc1036String() . "\n";
echo $dtBerlin->toAtomString() . "\n";
echo $dtBerlin->toCookieString() . "\n";
echo $dtBerlin->toRssString() . "\n";
$dtBerlin->setToStringFormat('l jS \\of F Y');
echo $dtBerlin . "\n";
echo (int) $dtBerlin->isLeapYear() . "\n";
// is* range of functions test
printf("Is yesterday? %s\n", $dtBerlin->isYesterday() ? "yes" : "no");
printf("Is a Thursday? %s\n", $dtBerlin->isThursday() ? "yes" : "no");
printf("Is in the future? %s\n", $dtBerlin->isFuture() ? "yes" : "no");
 public function test_suspend_company_with_command_on_expiration_date()
 {
     $expirationDate = new Carbon('2017-06-30');
     $company = factory(Company::class)->create();
     $user = factory(User::class, 'admin')->create();
     $this->actingAs($user)->visit('/company/' . $company->id . '/edit')->see($company->name)->see('name="licence_expire_at"')->type($expirationDate->toDateString(), 'licence_expire_at')->press('Save Edit')->seeInDatabase('companies', ['id' => $company->id, 'licence_expire_at' => $expirationDate->toDateString(), 'is_suspended' => false])->seeInDatabase('schedules', ['who_object' => Company::class, 'who_id' => $company->id, 'run_at' => $expirationDate->toDateString(), 'action' => ActionCommandSuspendCompanyCommand::class]);
     // enter to testing time - set date to be expiration date
     Carbon::setTestNow($expirationDate);
     $company = Company::findOrFail($company->id);
     $this->assertEquals(false, $company->is_suspended);
     $results = \App\Model\ActionQueue\ActionCommandScheduled::run();
     $company = Company::findOrFail($company->id);
     $this->assertEquals(true, $company->is_suspended);
     // exit from testing time - reset current time
     Carbon::setTestNow();
 }
Example #12
0
 public function sendEmailContact(Request $request)
 {
     $email = userAdmin::where('identidad', $request->identidad)->first();
     $ent = entidadTuristica::where('rif', $request->identidad)->first();
     $camas = new camas();
     $hab = new habitacion();
     $email = $email->email;
     // Buscando habitaciones para el email de respaldo de la persona
     // todo este codigo deberia estar en una función aparte -- mejorar modularidad en codigo para futuros proyectos.
     $legalMessage = "";
     $f = "";
     $f2 = "";
     if ($ent->tipoentidad == "Hotel") {
         $habitaciones = habitacion::where('identidad', $request->identidad)->get();
         $camas = $camas->camasPorHabitacion($habitaciones);
         $habitaciones = $hab->serviciosOrdenados($habitaciones);
         $desde = Carbon::now();
         $desdeInicio = Carbon::create($desde->year, $desde->month, 1);
         $desdeFin = Carbon::create($desde->year, $desde->month, $desde->daysInMonth);
         $desdeInicio = $desdeInicio->toDateString();
         $desdeFin = $desdeFin->toDateString();
         $dias = 1;
         $legalMessage = "NOTA: Las tarifas son validas desde el " . $desdeInicio . " hasta el " . $desdeFin . " y las mismas estan sujetas a cambios.";
         if (Session::has('fecha')) {
             $fecha = explode(" - ", Session::get('fecha'));
             $f = new Carbon($fecha[0]);
             $f2 = new Carbon($fecha[1]);
             $dias = $f->diffInDays($f2);
             $query = " SELECT idperfilhabitacion FROM habitacionesperfil WHERE id NOT IN ( SELECT disponibilidad.idhabitacion from disponibilidad WHERE (estado = 'Habilitado')\n                AND ((disponibilidad.fecha_inicio BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n                OR (disponibilidad.fecha_fin BETWEEN '" . $fecha[0] . "' AND '" . $fecha[1] . "')\n                OR ( ('" . $fecha[0] . "' >= disponibilidad.fecha_inicio) AND ('" . $fecha[1] . "' <= disponibilidad.fecha_fin) ) ) ) ";
             $search = DB::select(DB::raw($query));
             $arraySearch = [];
             foreach ($search as $s) {
                 array_push($arraySearch, $s->idperfilhabitacion);
             }
             foreach ($habitaciones as $h) {
                 $h['disponible'] = in_array($h->id, $arraySearch);
             }
         }
         foreach ($habitaciones as $h) {
             $h['total'] = $dias * $h['tarifa'];
         }
     } else {
         $habitaciones = null;
     }
     $data = ['nombre' => $request->nombre, "email" => $request->email, "telefono" => $request->telefono, "mensaje" => $request->mensaje];
     $data2 = ['habitaciones' => $habitaciones, 'legalMessage' => $legalMessage, 'nombreEntidad' => $ent->nombre, 'f' => $f->toDateString(), 'f2' => $f2->toDateString()];
     $response;
     $statusCode;
     try {
         Mail::send('emails.contacto', $data, function ($message) use($email) {
             $message->from(env('MAIL_USERNAME'), 'AppHoteles');
             $message->subject('Contacto - AppHoteles');
             // Aqui iria el titulo...
             $message->to($email);
         });
         Mail::send('emails.usuarioContacto', $data2, function ($message) use($request) {
             $message->from(env('MAIL_USERNAME'), 'AppHoteles');
             $message->subject('Contacto - AppHoteles');
             // Aqui iria el titulo...
             $message->to($request->email);
         });
         $response = ['success' => true, 'message' => 'Email enviado.'];
         $statusCode = 200;
     } catch (Exception $e) {
         $response = ["error" => $e->getMessage()];
         $statusCode = 400;
     } finally {
         return Response::json($response, $statusCode);
     }
 }
 public function getByDate(Carbon $date)
 {
     $repo = $this->em->getRepository('JGimeno\\TaskReporter\\Domain\\Entity\\WorkingDay');
     $return = $repo->findOneByDate($date->toDateString());
     return $return;
 }
 /**
  * @param $bwDate
  * @param $ewDate
  *
  * @return string
  */
 protected function buildTimeCardRangeVar(Carbon $bwDate, Carbon $ewDate)
 {
     $timeCardRange = '( ' . $bwDate->toDateString() . ' - ' . $ewDate->toDateString() . ' )';
     return $timeCardRange;
 }
 /**
  * @param $data
  * @return array
  */
 private function buildPayload($data)
 {
     $payload = ['id' => (int) $data[0], 'name' => trim($data[1]), 'account_type_id' => (int) $data[2], 'account_status_id' => (int) $data[3], 'contact_name' => trim($data[16])];
     $unformattedAddress = ['line1' => trim($data[7]), 'line2' => trim($data[8]), 'city' => trim($data[9]), 'state' => trim($data[10]), 'county' => trim($data[11]), 'zip' => trim($data[12]), 'country' => trim($data[13]), 'latitude' => trim($data[14]), 'longitude' => trim($data[15])];
     $formattedAddress = $this->addressFormatter->formatAddress($unformattedAddress, false);
     $payload = array_merge($payload, $formattedAddress);
     /**
      * We don't do a ton of validation here, as the API call will fail if this data is invalid anyway.
      */
     if (trim($data[4])) {
         $payload['account_groups'] = explode(",", trim($data[4]));
     }
     if (trim($data[5])) {
         $payload['sub_accounts'] = explode(",", trim($data[5]));
     }
     if (trim($data[6])) {
         $carbon = new Carbon($data[6]);
         $now = Carbon::now();
         if ($carbon->gt($now)) {
             $payload['next_bill_date'] = trim($carbon->toDateString());
         }
     }
     if (trim($data[17])) {
         $payload['role'] = trim($data[17]);
     }
     if (trim($data[18])) {
         $payload['email_address'] = trim($data[18]);
     }
     if (trim($data[19])) {
         $payload['email_message_categories'] = explode(",", trim($data[19]));
     } else {
         $payload['email_message_categories'] = [];
     }
     $phoneNumbers = [];
     if (trim($data[20])) {
         $phoneNumbers['work'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[20])), 'extension' => trim($data[21])];
     }
     if (trim($data[22])) {
         $phoneNumbers['home'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[22])), 'extension' => null];
     }
     if (trim($data[23])) {
         $phoneNumbers['mobile'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[23])), 'extension' => null];
     }
     if (trim($data[24])) {
         $phoneNumbers['fax'] = ['number' => trim(preg_replace("/[^0-9]/", "", $data[24])), 'extension' => null];
     }
     if (count($phoneNumbers) > 0) {
         $payload['phone_numbers'] = $phoneNumbers;
     }
     return $payload;
 }
Example #16
0
 public function getSalesChannelReport(Request $request)
 {
     $query = PurchaseOrder::select(DB::raw('sales_channels.name'), DB::raw('count(purchase_orders.id) as pocount'), DB::raw('sum(purchase_orders.total) as pototal'));
     $reportParams = $request->input('reportParams');
     if (isset($reportParams['sales_channel_from_date']) && $reportParams['sales_channel_from_date'] !== '') {
         $sDate = new Carbon($reportParams['sales_channel_from_date']);
         $query->whereDate('purchase_orders.created_at', '>=', $sDate->toDateString());
     }
     if (isset($reportParams['sales_channel_to_date']) && $reportParams['sales_channel_to_date'] !== '') {
         $eDate = new Carbon($reportParams['sales_channel_to_date']);
         $query->whereDate('purchase_orders.created_at', '<=', $eDate->toDateString());
     }
     $query->join('sales_channels', 'purchase_orders.sales_channel_id', '=', 'sales_channels.id');
     $query->groupBy(DB::raw('purchase_orders.sales_channel_id'));
     $query->orderBy('sales_channels.name', 'asc');
     $dataPoints = $query->get();
     return response()->json($dataPoints);
 }
Example #17
0
 /**
  * Scope For Date
  *
  * @param  Illuminate\Database\Query $query
  * @param  Carbon $date  Date of inquiry
  * @return Illuminate\Database\Query Scoped query
  */
 public function scopeForDate($query, Carbon $date)
 {
     return $query->where('date', '=', $date->toDateString());
 }
Example #18
0
 public function postDonate()
 {
     date_default_timezone_set('Asia/Manila');
     $carbon = new Carbon();
     $datedonated = $carbon->toDateString();
     $usersid = Session::get('userid');
     $donation = new Donations();
     $donation->amountdonated = Input::get('amountdonated');
     $donation->datedonated = $datedonated;
     $donation->usersid = $usersid;
     $donation->campaignid = Input::get('campaignid');
     $donation->bankname = Input::get('bankname');
     $donation->bankaccount = Input::get('bankaccount');
     $donation->userbankname = Input::get('userbankname');
     $donation->save();
     $result = DB::table('campaign')->select('campaign.name')->where('campaign.id', Input::get('campaignid'))->get();
     foreach ($result as $row) {
         $name = $row->name;
     }
     $activityname = "Donated P" . Input::get('amountdonated') . ' to campaign: ' . $name;
     DB::table('activity')->insertGetId(array('name' => $activityname, 'usersid' => $usersid, 'date' => $datedonated));
 }
Example #19
0
 /**
  * метод вызывается, если в абонементе указано количество занятий
  * пробегает по рассписанию и добавляет в массив $_insertArray данные о новых оплаченных занятиях,
  * для вставки в базу данных.
  * @param array Timetable::find() $timeTableGroups
  * @param array PaidEmployment::find() $existEmployments
  * @param Carbon $currentDate
  * @param Carbon $endDate
  */
 private function addInsertArrayAmountLimit($timeTableGroups, $existEmployments, $currentDate, $endDate)
 {
     while ($endDate->timestamp >= $currentDate->timestamp) {
         foreach ($timeTableGroups as $tableRow) {
             if ($tableRow['week_day'] == $currentDate->dayOfWeek) {
                 if ($this->_ticketModel->amount < 1) {
                     goto amountEnd;
                 }
                 $findFlag = false;
                 foreach ($existEmployments as $employmentRow) {
                     if ($employmentRow['date'] == $currentDate->toDateString() && $tableRow['id'] == $employmentRow['timetable_id']) {
                         $findFlag = true;
                         break;
                     }
                 }
                 if (!$findFlag) {
                     $this->_insertArray[] = ['date' => $currentDate->toDateString(), 'pay_id' => $this->id, 'timetable_id' => $tableRow['id']];
                     --$this->_ticketModel->amount;
                 }
             }
         }
         $currentDate->addDay();
     }
     amountEnd:
     // goto amountEnd
 }
 public function getNewActionsForDate(Carbon $dateRunAt)
 {
     return Schedule::where('run_at', $dateRunAt->toDateString())->where('status', 'new')->get();
 }
Example #21
0
 /**
  * Checks if the passed in date is the same day as the instance current day.
  *
  * @param  Carbon  $dt
  * @return boolean
  */
 public function isSameDay(Carbon $dt)
 {
     return $this->toDateString() === $dt->toDateString();
 }
Example #22
0
 public function scopeShipsOn($query, $date)
 {
     if ($date == 'any') {
         return $query;
     }
     $date = new Carbon($date);
     return $query->where('collect_after', 'like', $date->toDateString() . '%');
 }