D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
tattooscyy
/
stage
/
app
/
Http
/
Controllers
/
Manager
/
Filename :
AbstractController.php
back
Copy
<?php namespace App\Http\Controllers\Manager; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use DateTime; use DateInterval; use Calendar; use App\Artist; use App\Size; use App\Schedule; use Auth; abstract class AbstractController extends Controller { protected $artistsArray; protected $saloon; protected function artists($request) { $saloon = $request->saloon; $this->saloon = $saloon; if (Auth::user()->role_id == 1) { $all = Artist::where('showhide', 'show')->get(); } else { $all = Artist::where('saloon_id', $saloon->id)->where('showhide', 'show')->get(); } $artists = []; foreach ($all as $one) { $artists[] = ['id' => $one->id, 'title' => $one->name]; } $artists[] = ['id' => 0, 'title' => 'Perceur']; $this->artistsArray = $artists; return $all; } protected function events($objs = null) { $events = []; foreach ($objs as $one) { if (isset($one->type)) { if ($one->type == 'client') { $color = '#5cb85c'; } elseif ($one->type == 'manager_new') { $color = '#d9534f'; } else { $color = '#337ab7'; } } else { $color = '#337ab7'; } if (isset($one->user->name)) { $username = $one->user->name; } else { $username = 'manager'; } $sd = \App::make('\App\Libs\Sum')->getPrice($one->width, $one->height); $price = Size::where('size', $sd)->where('catalogs_id', $one->catalogs_id)->first(); if (!$price) { $price = new Size(); } $h = ceil($price->price / 80) / 2; if ($h > 4) { $h = 4; } $hm = $h * 3600; $h_str = $hm . ' seconds'; if (isset($one->artists->name)) { $artist_name = $one->artists->name; } else { $artist_name = '-'; $h_str = '1800 seconds'; } $title = '#' . $one->id . ', ' . $artist_name . ' (client ' . $username . ')'; $start = new DateTime($one->putdate); $end = new DateTime($one->putdate); $end->add(DateInterval::createFromDateString($h_str)); $events[] = Calendar::event( "$title", //event title false, //full day event? $start, //start time (you can also use Carbon instead of DateTime) $end, //end time (you can also use Carbon instead of DateTime) 1, //optionally, you can specify an event ID [ 'resourceId' => $one->artist_id, 'url' => '#modal' . $one->id, 'className' => 'modal_day', 'id' => $one->id, 'color' => $color ] ); } return $events; } protected function traitOptions() { if (isset($this->saloon)) { $sid = $this->saloon->id; } else { $sid = 1; } $obj_sal = Schedule::where('status', 'saloon')->where('saloon_id', $sid)->orderBy('id', 'DESC')->first(); if (isset($obj_sal)) { $hours_sal = unserialize($obj_sal->hours); } else { $hours_sal = ['0:00', '23:30']; } $minTime = '8:00'; $maxTime = '17:30'; if (isset($hours_sal[0])) { $minTime = $hours_sal[0]; $maxTime = end($hours_sal); } //dd($hours_sal[0], end($hours_sal)); return [ //set fullcalendar options 'minTime' => $minTime, 'maxTime' => $maxTime, 'schedulerLicenseKey' => 'GPL-My-Project-Is-Open-Source', 'editable' => true, // enable draggable events 'droppable' => true, // this allows things to be dropped onto the calendar 'selectable' => true, 'defaultView' => 'agendaDay', 'header' => [ 'left' => 'today prev,next', 'center' => 'title', 'right' => 'agendaDay,agendaTwoDay,agendaWeek,month' ], 'resourceGroupField' => 'room', 'resourceLabelText' => 'Rooms', 'axisFormat' => 'HH:mm', 'timeFormat' => 'H:mm', 'hour12' => false, 'views' => [ 'agendaTwoDay' => [ 'type' => 'agenda', 'duration' => ['days' => 2], 'groupByResource' => true, 'timeFormat' => 'H:mm', ], 'timelineDay' => [ 'timeFormat' => 'H:mm', 'type' => 'timeline', 'duration' => ['days' => 1], ], ], 'resources' => $this->artistsArray, ]; } protected function traitCallbacks() { return [ 'select' => 'function(start, end, jsEvent, view, resource) { console.log("select", start.format(), end.format(), resource ? resource.id : "(no resource)" ); }', 'viewRender' => 'function() { $.ajaxSetup({ headers: { "X-CSRF-TOKEN": $("meta[name=csrf-token]").attr("content") } }); $(".modal_day").attr({ "data-toggle": "modal", "data-target": "#myModal" }); }', 'eventDrop' => 'function(event, delta, revertFunc) { if (!confirm("Are you sure to dropped " + event.title + " to date " + event.start.format() + "?")) { revertFunc(); }else{ $.ajax({ data: "putdate=" + event.start.format() + "&id=" + event.id, url: "/manager/ajax/startformat", type: "post", success: function (data) { //alert("Ok"); }, error: function (msg) { console.log("error"); } }); } }', 'eventClick' => 'function() { var data = $(this).attr("href"); var res = data.replace("#modal", ""); console.log(res); $.ajax({ data: "id=" + res, url: "/manager/ajax", type: "post", success: function (data) { $(".modal-content").html(data); $("#myModal").modal("show"); }, error: function (msg) { $(".modal-content").text("Some error! Please, try again with small picture or crop this one."); } }); }', ]; } protected function traitarr_old() { return [ 'viewRender' => 'function() { $.ajaxSetup({ headers: { "X-CSRF-TOKEN": $("meta[name=csrf-token]").attr("content") } }); $(".modal_day").attr({ "data-toggle": "modal", "data-target": "#myModal" }); }', 'editable' => 'true', 'eventClick' => 'function() { var data = $(this).attr("href"); var res = data.replace("#modal", ""); console.log(res); $.ajax({ data: "id=" + res, url: "/manager/ajax", type: "post", success: function (data) { $(".modal-content").html(data); $("#myModal").modal("toggle"); }, error: function (msg) { $(".modal-content").text("Some error! Please, try again with small picture or crop this one."); } }); }', 'eventMouseover' => 'function(){ }', 'eventDrop' => 'function(event, delta, revertFunc) { if (!confirm("Are you sure to dropped " + event.title + " to date " + event.start.format() + "?")) { revertFunc(); }else{ // $.ajax({ // data: "putdate=" + event.start.format() + "&id=" + event.id, // url: "/manager/ajax/startformat", // type: "post", // success: function (data) { // // }, // error: function (msg) { // console.log("error"); // } // }); } }', 'dayClick' => 'function(date, jsEvent, view) { // view.name , jsEvent.pageX + jsEvent.pageY, date.format(); $.ajax({ data: "putdate=" + date.format(), url: "/manager/addnew", type: "get", success: function (data) { $(".modal-content").html(data); $("#myModal").modal("toggle"); }, error: function (msg) { console.log("error"); } }); $(this).css(\'background-color\', \'#d9534f\'); }' ]; } }