D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
test
/
app
/
Http
/
Controllers
/
Manager
/
Filename :
CalculatorController.php
back
Copy
<?php namespace App\Http\Controllers\Manager; use Illuminate\Http\Request; use App\Libs\Calendar; use App\Libs\Mailer; use Auth; use App\Client; use App\PictureManager; use App\Saloon; use App\Artist; use App\Catalogs; use App\Schedule; use App\Size; use App\Orders; use App\ShceduleDay; use App\Libs\Endhour; class CalculatorController extends AbstractController { public function getIndex(Request $request) { return view('manager.client'); } public function postClient() { $obj = new Client; $obj->manager_id = Auth::user()->id; $obj->name = $_POST['name']; $obj->email = $_POST['email']; $obj->phone = $_POST['phone']; $obj->save(); return redirect('manager/calculator/order/' . $obj->id); } public function getOrder($id = null) { $this->middleware('coockieclear'); $client = Client::find($id); if (isset($_GET['calc'])) { if ($_GET['calc'] == 'true') { $calc = true; } } else { $calc = false; } return view('manager.calculator', compact('calc', 'client')); } public function getPicture($id = null) { $pic = PictureManager::find($id); $arr = getimagesize($pic->picture); if ($arr[0]) { $width_c = $arr[0] / 38; } else { $width_c = 3; } if ($arr[1]) { $height_c = $arr[1] / 38; } else { $height_c = 3; } return view('manager.picture', compact('pic', 'width_c', 'height_c')); } public function getArtist($id = null) { $client = Client::find($id); $picture_id = (int)$_GET['picture_id']; $width_m = (int)$_GET['width']; $height_m = (int)$_GET['height']; return view('manager.artist_select', compact('client', 'picture_id', 'height_m', 'width_m')); } public function getCalendar($id = null) { if (isset($_GET['artist_id'])) { $artist_id = (int)$_GET['artist_id']; if ($artist_id == 0) { if (isset($_GET['artist_name'])) { $arti = Artist::where('name', $_GET['artist_name'])->first(); $artist_id = $arti->id; } else { $artist_id = 0; } } } else { $artist_id = 0; } if (isset($_GET['saloon_id'])) { $saloon_id = (int)$_GET['saloon_id']; } else { $saloon_id = Artist::find($artist_id)->first()->saloon_id; } $catalogs_id = (int)$_GET['catalogs_id']; $picture_id = (int)$_GET['picture_id']; $width_m = (int)$_GET['width_m']; $height_m = (int)$_GET['height_m']; $catalog = Catalogs::find($catalogs_id); $artist = Artist::find($artist_id); $saloon_obj = Saloon::find($saloon_id); $client = Client::find($id); $clients = Client::where('manager_id', Auth::user()->id)->get(); $days = array(); $hours = array(); $obj = Schedule::where('artist_id', $artist_id)->orderBy('id', 'DESC')->first(); if (isset($obj)) { $days = unserialize($obj->days); $hours = unserialize($obj->hours); } $obj_sal = Schedule::where('status', 'saloon')->where('saloon_id', $saloon_id)->orderBy('id', 'DESC')->first(); if (isset($obj_sal)) { $days_sal = unserialize($obj_sal->days); } else { $days_sal = []; } $real_days = []; foreach ($days as $one) { if (in_array($one, $days_sal)) { $real_days[] = $one; } } $picture = PictureManager::find($picture_id); $h = \App::make('\App\Libs\Hour')->get($width_m, $height_m, $catalogs_id); $sd = \App::make('\App\Libs\Sum')->getPrice($width_m, $height_m); $prices = Size::where('size', $sd)->where('catalogs_id', $catalogs_id)->first(); //echo $price->price; //dd($sd, $catalogs_id, $price->price); $calendar_obj = new Calendar(); $calendar = $calendar_obj->show($real_days, $hours); return view('manager.calendar', compact('client', 'clients', 'calendar', 'artist', 'saloon_id', 'catalog', 'picture', 'saloon_obj', 'hours', 'picture', 'width_m', 'height_m', 'h', 'prices')); } public function postOrderlast(Request $request) { $width_m = $_POST['width_m']; $height_m = $_POST['height_m']; $picture_id = $_POST['picture_id']; if (isset($_POST['saloon_id'])) { $saloon_id = $_POST['saloon_id']; } else { $saloon_id = 0; } if (isset($_POST['artist_id'])) { $artist_id = $_POST['artist_id']; } else { $artist_id = 0; } $client_id = (int)$_POST['cli_id']; if ($client_id == 0) { $obj = new Client; $obj->manager_id = Auth::user()->id; $obj->name = $_POST['name']; $obj->email = $_POST['email']; $obj->phone = $_POST['phone']; $obj->save(); $client_id = $obj->id; } $obj = new Orders; $obj->user_id = 0; $obj->manager_id = Auth::user()->id; $obj->client_id = $client_id; $obj->width = (int)$width_m; $obj->height = (int)$height_m; $obj->size = (int)((int)$width_m * (int)$height_m); $obj->catalogs_id = (int)$_POST['catalog_id']; $obj->artist_id = (int)$artist_id; $obj->saloon_id = (int)$saloon_id; $obj->picture = $picture_id; $obj->putdate = $_POST['days'] . ' ' . $_POST['hour']; $obj->payd = $_POST['payd']; $obj->status = 'payd20'; $obj->type = 'manager_new'; $obj->typeshow = 'manager'; $obj->save(); $mail = new Mailer(); $mail->sendEmail($obj->id, $request); $obj_t = new Endhour(); $obj_t->orderObj($obj); $t_arr = $obj_t->arr; $dat = $obj_t->dat; $e = ShceduleDay::where('day', $dat)->where('saloon_id', $obj->saloon_id)->where('artist_id', $obj->artist_id)->first(); //dd($t_arr, $obj); if (isset($e)) { // dd($e); $e->hours = serialize($t_arr); $e->update(); } else { $enew = new ShceduleDay; $enew->saloon_id = $obj->saloon_id; $enew->artist_id = $obj->artist_id; $enew->day = $dat; $enew->hours = serialize($t_arr); $enew->status = 'except'; $enew->save(); } return redirect('/manager'); } public function postAjaxPrice3() { if ($_POST) { $dat = str_replace(" ", "+", $_POST['data']); $client_id = (int)$_POST['client_id']; $type = time(); if (Auth::guest()) { $ur_id = ''; $pp = '/pictures/'; } else { $ur_id = Auth::user()->id; $pp = '/pictures/' . $ur_id . '/'; } $name = time(); $pic = \App::make('\App\Libs\Imag')->url($dat, public_path() . $pp, $name); $obj = new PictureManager; $obj->picture = asset($pp . $pic); $obj->picture_small = asset($pp . 's_' . $pic); $obj->ip = $_SERVER['REMOTE_ADDR']; $obj->type = $type; $obj->manager_id = $ur_id; $obj->client_id = $client_id; $obj->showhide = 'show'; $obj->save(); echo $obj->id; } } }