D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
stage
/
app
/
Http
/
Controllers
/
Filename :
AjaxtimeController.php
back
Copy
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Schedule; use App\ShceduleDay; use App\ScheduleExcept; use App\Orders; use App\Size; use Datetime; use Auth; class AjaxtimeController extends Controller { public function postHours(Request $request) { if (isset($_COOKIE['artist_id'])) { $artist_id = (int)$_COOKIE['artist_id']; } else { $artist_id = 0; } $date = new DateTime(); $dat = $date->format('d-m-Y'); $saloon_id = $request->saloon_id; if (!$saloon_id) { $saloon_id = $_POST['saloon_id']; } if ($_POST) { $date = $_POST['date']; if (!$artist_id) { $artist_id = (int)$_POST['artist_id']; } $day = date("D", strtotime($date)); $sche = ShceduleDay::where('day', $date)->where('artist_id', $artist_id)->orderBy('id', 'DESC')->first(); if(!$sche){ $sche = ScheduleExcept::where('artist_id', $artist_id)->where('day', $day)->orderBy('id', 'DESC')->first(); } if(!$sche){ $sche = ShceduleDay::where('day', $date)->where('saloon_id', $saloon_id)->where('artist_id', 0)->orderBy('id', 'DESC')->first(); } if(!$sche){ $sche = ScheduleExcept::where('saloon_id', $saloon_id)->where('day', $day)->orderBy('id', 'DESC')->first(); } if(!$sche){ $sche = Schedule::where('artist_id', $artist_id)->orderBy('id', 'DESC')->first(); } if(!$sche){ $sche = Schedule::where('saloon_id', $saloon_id)->where('artist_id', 0)->orderBy('id', 'DESC')->first(); } $hours = unserialize($sche->hours); $date = new DateTime($date); $dat = $date->format('d-m-Y'); if ($dat == date('d-m-Y')) { foreach ($hours as $one) { $in = (int)$one; $da = (int)date('H') + 1; if ($in < $da) { if (($key = array_search($one, $hours)) !== false) { unset($hours[$key]); } } } } $ord = Orders::where('putdate', 'LIKE', $dat . '%')->where('artist_id', $artist_id)->where('status', 'client_change')->get(); foreach ($ord as $one) { $dates = new DateTime($one->putdate); $dat_h = (int)$dates->format('H'); if ($dat_h == 0) { $dat_h = 24; } $dat_i = $dates->format('i'); $dats = $dat_h . ':' . $dat_i; //echo $dats . '<br />'; $h = \App::make('\App\Libs\Hour')->get($one->width, $one->height, $one->catalogs_id); if (($key = array_search($dats, $hours)) !== false) { unset($hours[$key]); } $hint = $h * 2 - 1; for ($i = 1; $i <= $hint; $i++) { unset($hours[$key + $i]); } } return view('templates.hours')->with('hours', $hours)->with('dat', $dat); } } }