From c330051bcf476d5267f66f8087bc38529a362706 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Jos=C3=A9?= Date: Fri, 25 Sep 2015 20:50:48 +0200 Subject: [PATCH 1/2] Posibilidad de desactivar los servicios antes de borrarlos y luego reactivarlos --- app/Http/Controllers/ClientController.php | 2 +- app/Http/Controllers/IncidenceController.php | 328 +++---- app/Http/Controllers/SMSController.php | 44 + app/Http/Controllers/ServicesController.php | 33 + app/Http/routes.php | 2 + app/Models/SMS.php | 10 + composer.json | 3 +- composer.lock | 52 +- database/migrations/2015_09_18_090441_sms.php | 32 + ...015_09_25_180516_service_client_active.php | 30 + ...015_09_25_182750_service_client_dateTo.php | 30 + public/css/custom.css | 18 +- resources/views/client/view.blade.php | 879 +++++++++--------- 13 files changed, 861 insertions(+), 602 deletions(-) create mode 100644 app/Http/Controllers/SMSController.php create mode 100644 app/Models/SMS.php create mode 100644 database/migrations/2015_09_18_090441_sms.php create mode 100644 database/migrations/2015_09_25_180516_service_client_active.php create mode 100644 database/migrations/2015_09_25_182750_service_client_dateTo.php diff --git a/app/Http/Controllers/ClientController.php b/app/Http/Controllers/ClientController.php index f3a5a57..a51f7d5 100644 --- a/app/Http/Controllers/ClientController.php +++ b/app/Http/Controllers/ClientController.php @@ -170,7 +170,7 @@ public function getView($id) $services = DB::table('service_client') ->join('service', 'service.id', '=', 'service_client.fk_service') ->where('service_client.fk_client','=',$model->id) - ->select('service_client.id','service.id as serviceId', 'service.name', 'service_client.created_at')->get(); + ->select('service_client.id','service.id as serviceId', 'service.name', 'service_client.created_at', 'service_client.active','service_client.reason','service_client.date_to')->get(); //Get the client last invoices $invoices = Invoice::where('fk_client', '=', $model->id)->orderBy('date_creation', 'asc')->get(); diff --git a/app/Http/Controllers/IncidenceController.php b/app/Http/Controllers/IncidenceController.php index 18e9dc6..311f173 100644 --- a/app/Http/Controllers/IncidenceController.php +++ b/app/Http/Controllers/IncidenceController.php @@ -12,178 +12,182 @@ use App\Models\ServiceClient; use App\Http\Controllers\Controller; use App\Http\Controllers\InvoiceController; - +use App\Http\Controllers\SMSController; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; - use App\Helpers\AngularHelper; - use Validator; use DB; /* * Aglutinates the assistance, incidence and report functions of the ERP */ -class IncidenceController extends Controller -{ - /* - * This function returns if the client has his assistance checked in or not for today - * - * @param {Integer} $id - The id of the client to check for - * @param {Integer} $fk_room_reserve - The id of the reserve - * - * @return {Boolean/Null} true if yes or false if not, also null if it's not given - */ - public static function isChekedIn($id, $fk_room_reserve) - { - $assistance = Assistance::whereRaw('fk_client = '.$id.' AND fk_room_reserve = '.$fk_room_reserve.' AND date(created_at) = "'.date('Y-m-d').'"')->first(); - if($assistance) - return $assistance->assist; - else - return null; - } - - /* - * This function check's in the client - */ - public function checkIn(Request $request) - { - $data = $request->all(); - //First of all check if exists the checkin - $checkIn = Assistance::whereRaw('fk_client = '.$data['fk_client'].' AND fk_room_reserve = '.$data['fk_room_reserve'].' AND date(created_at) = "'.date('Y-m-d').'"')->first(); - if($checkIn){ - //Update - $checkIn->assist = $data['assist']; - //Save - if($checkIn->save()) - echo 'ok'; - else - echo 'ko'; - }else { - //Create and save - $assistance = new Assistance; - $assistance->fk_user = Auth::user()->id; - $assistance->fk_company = Auth::user()->fk_company; - $assistance->fk_room_reserve = $data['fk_room_reserve']; - $assistance->fk_client = $data['fk_client']; - $assistance->assist = $data['assist']; - //Save - if($assistance->save()) - echo 'ok'; - else - echo 'ko'; + +class IncidenceController extends Controller { + /* + * This function returns if the client has his assistance checked in or not for today + * + * @param {Integer} $id - The id of the client to check for + * @param {Integer} $fk_room_reserve - The id of the reserve + * + * @return {Boolean/Null} true if yes or false if not, also null if it's not given + */ + + public static function isChekedIn($id, $fk_room_reserve) { + $assistance = Assistance::whereRaw('fk_client = ' . $id . ' AND fk_room_reserve = ' . $fk_room_reserve . ' AND date(created_at) = "' . date('Y-m-d') . '"')->first(); + if ($assistance) + return $assistance->assist; + else + return null; + } + + /* + * This function check's in the client + */ + + public function checkIn(Request $request) { + $data = $request->all(); + //First of all check if exists the checkin + $checkIn = Assistance::whereRaw('fk_client = ' . $data['fk_client'] . ' AND fk_room_reserve = ' . $data['fk_room_reserve'] . ' AND date(created_at) = "' . date('Y-m-d') . '"')->first(); + if ($checkIn) { + //Update + $checkIn->assist = $data['assist']; + //Save + if ($checkIn->save()) + echo 'ok'; + else + echo 'ko'; + }else { + //Create and save + $assistance = new Assistance; + $assistance->fk_user = Auth::user()->id; + $assistance->fk_company = Auth::user()->fk_company; + $assistance->fk_room_reserve = $data['fk_room_reserve']; + $assistance->fk_client = $data['fk_client']; + $assistance->assist = $data['assist']; + if ($data['assist'] == 0) { + //FUTURE!! + //$client = Client::find($assistance->fk_client); + //SMSController::sendAssistanceSms($client->phone_parents, $client->name); + } + //Save + if ($assistance->save()) + echo 'ok'; + else + echo 'ko'; + } + } + + /* + * This function creates a incidence for the client + */ + + public function createClientIncidence(Request $request) { + $data = $request->all(); + $incidence = new ClientIncidence; + //Set basic fk's + $incidence->fk_client = $data['fk_client']; + $incidence->fk_user = Auth::user()->id; + $incidence->fk_company = Auth::user()->fk_company; + //Other data + $incidence->concept = $data['concept']; + $incidence->observations = $data['description']; + //Save + if ($incidence->save()) + echo 'ok'; + else + echo 'ko'; } - } - - /* - * This function creates a incidence for the client - */ - public function createClientIncidence(Request $request) - { - $data = $request->all(); - $incidence = new ClientIncidence; - //Set basic fk's - $incidence->fk_client = $data['fk_client']; - $incidence->fk_user = Auth::user()->id; - $incidence->fk_company = Auth::user()->fk_company; - //Other data - $incidence->concept = $data['concept']; - $incidence->observations = $data['description']; - //Save - if($incidence->save()) - echo 'ok'; - else - echo 'ko'; - } - - /* - * This function returns the client report - */ - public function getClientReport(Request $request) - { - $data = $request->all(); - //Get the service - $roomReserve = RoomReserve::find($data['fk_service']); - $roomService = RoomService::find($roomReserve->fk_room_service); - //Execute final query - $reports = ClientReport::whereRaw('fk_client = '.$data['fk_client'].' AND fk_service = '.$roomService->fk_service)->get(); - //Print return - print_r(json_encode($reports)); - } - - /* - * This function creates a client report - */ - public function crateClientReport(Request $request) - { - $data = $request->all(); - //Create model and fill it - $report = new ClientReport; - $report->fk_user = Auth::user()->id; - $report->fk_company = Auth::user()->fk_company; - $report->fk_client = $data['fk_client']; - //Get the service + + /* + * This function returns the client report + */ + + public function getClientReport(Request $request) { + $data = $request->all(); + //Get the service + $roomReserve = RoomReserve::find($data['fk_service']); + $roomService = RoomService::find($roomReserve->fk_room_service); + //Execute final query + $reports = ClientReport::whereRaw('fk_client = ' . $data['fk_client'] . ' AND fk_service = ' . $roomService->fk_service)->get(); + //Print return + print_r(json_encode($reports)); + } + + /* + * This function creates a client report + */ + + public function crateClientReport(Request $request) { + $data = $request->all(); + //Create model and fill it + $report = new ClientReport; + $report->fk_user = Auth::user()->id; + $report->fk_company = Auth::user()->fk_company; + $report->fk_client = $data['fk_client']; + //Get the service $roomReserve = RoomReserve::find($data['fk_service']); $roomService = RoomService::find($roomReserve->fk_room_service); - // - $report->fk_service = $roomService->fk_service; - $report->concept = $data['concept']; - $report->observations = $data['observations']; - if($report->save()) - return 'ok'; - else - return 'ko'; - } - - /* - * This function get's all the client incidencies - */ - public function getClientIncidences() - { - $incidences = ClientIncidence::whereRaw('fk_company = '.Auth::user()->fk_company.' AND seen IS NULL')->get(); - return view('client.incidences',['incidences' => $incidences]); - } - - /* - * This function completes the incidence - */ - public function completeIncidence($id) - { - //Load the incidence - $incidence = ClientIncidence::find($id); - //Update the user and seen values - $incidence->seen = 1; - $incidence->fk_user = Auth::user()->id; - //Save - $incidence->save(); - //Redirect to the list - return redirect('/incidence/client'); - } - - /* - * This function returns an array with the client incidences - */ - public static function fetchClientIncidences($fk_client) - { - $incidences = ClientIncidence::where('fk_client', '=', $fk_client)->get(); - return $incidences; - } - - /* - * This function renders the client assistance list view - */ - public function getAssitanceList() - { - $assistance = Assistance::whereRaw('fk_company = '. Auth::user()->fk_company.' AND assist = 0')->get(); - return view('client.assistance',['incidences' => $assistance]); - } - - /* - * This function fetchs the list of assistances - */ - public static function fetchAssitanceList($fk_client) - { - $assistance = Assistance::whereRaw('fk_client = '. $fk_client.' AND assist = 0')->get(); - return $assistance; - } + // + $report->fk_service = $roomService->fk_service; + $report->concept = $data['concept']; + $report->observations = $data['observations']; + if ($report->save()) + return 'ok'; + else + return 'ko'; + } + + /* + * This function get's all the client incidencies + */ + + public function getClientIncidences() { + $incidences = ClientIncidence::whereRaw('fk_company = ' . Auth::user()->fk_company . ' AND seen IS NULL')->get(); + return view('client.incidences', ['incidences' => $incidences]); + } + + /* + * This function completes the incidence + */ + + public function completeIncidence($id) { + //Load the incidence + $incidence = ClientIncidence::find($id); + //Update the user and seen values + $incidence->seen = 1; + $incidence->fk_user = Auth::user()->id; + //Save + $incidence->save(); + //Redirect to the list + return redirect('/incidence/client'); + } + + /* + * This function returns an array with the client incidences + */ + + public static function fetchClientIncidences($fk_client) { + $incidences = ClientIncidence::where('fk_client', '=', $fk_client)->get(); + return $incidences; + } + + /* + * This function renders the client assistance list view + */ + + public function getAssitanceList() { + $assistance = Assistance::whereRaw('fk_company = ' . Auth::user()->fk_company . ' AND assist = 0')->get(); + return view('client.assistance', ['incidences' => $assistance]); + } + + /* + * This function fetchs the list of assistances + */ + + public static function fetchAssitanceList($fk_client) { + $assistance = Assistance::whereRaw('fk_client = ' . $fk_client . ' AND assist = 0')->get(); + return $assistance; + } + } diff --git a/app/Http/Controllers/SMSController.php b/app/Http/Controllers/SMSController.php new file mode 100644 index 0000000..867f2b5 --- /dev/null +++ b/app/Http/Controllers/SMSController.php @@ -0,0 +1,44 @@ +count(); + //If not sended up to the limit, continue + if ($sends < self::limit) { + $client = new Services_Twilio(self::account_sid, self::auth_token); + //Send the message + $client->account->messages->create(array( + 'To' => "637107315", + 'From' => "637107315", + 'Body' => "preuba", + )); + if ($client->id != null) { + return true; + } + } else { + return false; + } + } + +} diff --git a/app/Http/Controllers/ServicesController.php b/app/Http/Controllers/ServicesController.php index f7e89fb..fd2e5b2 100644 --- a/app/Http/Controllers/ServicesController.php +++ b/app/Http/Controllers/ServicesController.php @@ -7,6 +7,7 @@ use App\Models\ServiceClient; use App\Models\RoomService; use App\Models\RoomReserve; +use App\Models\Assistance; use App\Http\Controllers\Controller; use App\Helpers\AngularHelper; @@ -93,6 +94,11 @@ public function getUnlink($id) { //Get the ServiceUser object $serviceClient = ServiceClient::find($id); + //Delete all the assistance data + $assistances = Assistance::where('fk_client', '=', $serviceClient->fk_client)->get(); + foreach($assistances as $assistance){ + $assistance->delete(); + } //First of all unlink the room reserves (horario) $roomServices = RoomService::whereRaw('fk_service = '.$serviceClient->fk_service)->get(); //for every roomservice look for a coincidence in the roomReserve and delete @@ -109,6 +115,33 @@ public function getUnlink($id) //return a redirect return redirect('/client/view/'.$serviceClient->fk_client); } + /* + * Disables the link between a service and the client + */ + public function getDisable($id) + { + //Get the ServiceUser object + $serviceClient = ServiceClient::find($id); + $serviceClient->active = 0; + $serviceClient->date_to = date('Y-m-d'); + $serviceClient->save(); + //return a redirect + return redirect('/client/view/'.$serviceClient->fk_client); + } + /* + * ENABLES the link between a service and the client + */ + public function getEnable($id) + { + //Get the ServiceUser object + $serviceClient = ServiceClient::find($id); + $serviceClient->active = 1; + $serviceClient->created_at = date('Y-m-d'); + $serviceClient->date_to = null; + $serviceClient->save(); + //return a redirect + return redirect('/client/view/'.$serviceClient->fk_client); + } /* * This function updates the service based on his id diff --git a/app/Http/routes.php b/app/Http/routes.php index 45a72a0..8d05ee1 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -51,6 +51,8 @@ Route::post('/services/update', 'ServicesController@postUpdate'); Route::post('/services/ajaxGetProductInfo', 'ServicesController@ajaxGetProductInfo'); Route::get('/service/unlink/{id}', 'ServicesController@getUnlink'); + Route::get('/service/disable/{id}', 'ServicesController@getDisable'); + Route::get('/service/enable/{id}', 'ServicesController@getEnable'); Route::get('/services/delete/{id}', 'ServicesController@getDelete'); //Rooms / Horarios Route::get('/rooms', 'RoomController@getPreview'); diff --git a/app/Models/SMS.php b/app/Models/SMS.php new file mode 100644 index 0000000..ea04a69 --- /dev/null +++ b/app/Models/SMS.php @@ -0,0 +1,10 @@ +=5.5.9", - "laravel/framework": "5.1.*" + "laravel/framework": "5.1.*", + "twilio/sdk": "^4.3" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 16ba3ca..db285bb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "3d8ae4769e462f085b81b2b3cb104236", + "hash": "0b2ed3556fae2b6b67be68a3d7a09b0b", "packages": [ { "name": "classpreloader/classpreloader", @@ -1648,6 +1648,56 @@ ], "time": "2015-07-28 15:18:12" }, + { + "name": "twilio/sdk", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/twilio/twilio-php.git", + "reference": "9b83e2f1c480e3fb4e05a833b325c5afa43520fb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twilio/twilio-php/zipball/9b83e2f1c480e3fb4e05a833b325c5afa43520fb", + "reference": "9b83e2f1c480e3fb4e05a833b325c5afa43520fb", + "shasum": "" + }, + "require": { + "php": ">=5.2.1" + }, + "require-dev": { + "mockery/mockery": ">=0.7.2", + "phpunit/phpunit": "4.5.*" + }, + "type": "library", + "autoload": { + "files": [ + "Services/Twilio.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Burke", + "email": "kevin@twilio.com" + }, + { + "name": "Kyle Conroy", + "email": "kyle+pear@twilio.com" + } + ], + "description": "A PHP wrapper for Twilio's API", + "homepage": "http://github.com/twilio/twilio-php", + "keywords": [ + "api", + "sms", + "twilio" + ], + "time": "2015-08-11 17:19:55" + }, { "name": "vlucas/phpdotenv", "version": "v1.1.1", diff --git a/database/migrations/2015_09_18_090441_sms.php b/database/migrations/2015_09_18_090441_sms.php new file mode 100644 index 0000000..9017c28 --- /dev/null +++ b/database/migrations/2015_09_18_090441_sms.php @@ -0,0 +1,32 @@ +increments('id'); + $table->string('client'); + //Default timestamps + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/database/migrations/2015_09_25_180516_service_client_active.php b/database/migrations/2015_09_25_180516_service_client_active.php new file mode 100644 index 0000000..d3c5eab --- /dev/null +++ b/database/migrations/2015_09_25_180516_service_client_active.php @@ -0,0 +1,30 @@ +integer('active')->nullable(); + $table->longText('reason')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() { + // + } + +} diff --git a/database/migrations/2015_09_25_182750_service_client_dateTo.php b/database/migrations/2015_09_25_182750_service_client_dateTo.php new file mode 100644 index 0000000..aca4914 --- /dev/null +++ b/database/migrations/2015_09_25_182750_service_client_dateTo.php @@ -0,0 +1,30 @@ +timestamp('date_to')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/public/css/custom.css b/public/css/custom.css index 5097f93..b26d16c 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -1,17 +1,21 @@ .center{ - text-align: center; + text-align: center; } .text-right{ - text-align: right; + text-align: right; } .white-text{ - color: white; + color: white; } .scrollable-box{ - max-height: 300px !important; - overflow-x: scroll !important; + max-height: 300px !important; + overflow-x: scroll !important; } .label-room{ - margin-left: 11px; - margin-top: 3px; + margin-left: 11px; + margin-top: 3px; } +.disaledService{ + color:#cccccc !important; + text-decoration: line-through !important; +} \ No newline at end of file diff --git a/resources/views/client/view.blade.php b/resources/views/client/view.blade.php index cfd9479..2a4ce4e 100644 --- a/resources/views/client/view.blade.php +++ b/resources/views/client/view.blade.php @@ -2,6 +2,7 @@ @section('content')
-

- Cliente - {{$model->name}} -

- +

+ Cliente + {{$model->name}} +

+
-
- -
-
-
-

{{$model->name .' '.$model->lastname_1.' '.$model->lastname_2}}

- - @if($model->status == 1) -
- Crear recibo - -
- @endif - -
- -
- {!! csrf_field() !!} - -
- - - @if (count($errors) > 0) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - - -

Los elementos marcados con un * son de carácter obligatorio

+
-
- -
- {{$model->name}} -
- -
- -
- {{$model->lastname_1}} -
+
+
+
+

{{$model->name .' '.$model->lastname_1.' '.$model->lastname_2}}

-
- -
- {{$model->lastname_2}} -
+ @if($model->status == 1) +
+ Crear recibo + +
+ @endif -
- -
- {{$model->nif}} -
+
+ + + {!! csrf_field() !!} + +
+ + + @if (count($errors) > 0) +
+
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+ @endif + -
- -
- {{$model->parent_name}} -
+

Los elementos marcados con un * son de carácter obligatorio

-
- -
- {{$model->parent_lastname_1}} -
+
+ +
+ {{$model->name}} +
-
- -
- {{$model->parent_lastname_2}} -
+
+ +
+ {{$model->lastname_1}} +
-
- -
- {{$model->parent_nif}} -
+
+ +
+ {{$model->lastname_2}} +
-
- -
- {{$model->address}} -
+
+ +
+ {{$model->nif}} +
-
- -
- {{$model->poblation}} -
+
+ +
+ {{$model->parent_name}} +
-
- -
- {{$model->city}} -
+
+ +
+ {{$model->parent_lastname_1}} +
-
- -
- {{$model->cp}} -
+
+ +
+ {{$model->parent_lastname_2}} +
-
- - -
+
+ +
+ {{$model->parent_nif}} +
-
- - -
+
+ +
+ {{$model->address}} +
-
- -
- {{$model->phone_parents}} -
+
+ +
+ {{$model->poblation}} +
-
- -
- {{$model->phone_client}} -
+
+ +
+ {{$model->city}} +
-
- -
- {{$model->phone_whatsapp}} -
+
+ +
+ {{$model->cp}} +
-
- -
- {{$model->email_parents}} -
+
+ + +
-
- -
- {{$model->email_client}} -
+
+ + +
-
- -
- {{$model->other_address_info}} -
- -
+
+ +
+ {{$model->phone_parents}} +
- -
-
+
+ +
+ {{$model->phone_client}} +
-
+
+ +
+ {{$model->phone_whatsapp}} +
- @if($model->status == 1) +
+ +
+ {{$model->email_parents}} +
- -
+
+ +
+ {{$model->email_client}} +
- -
-
-
-

Últimos 5 recibos

-
-
- - - - - - - - - - - @foreach($invoices as $invoice) - - - - - - - @endforeach - -
RefFechaTotalEstado
{{$invoice->facnumber}}{{DateHelper::getDate($invoice->date_creation)}}{{$invoice->total}} - - @if($invoice->status == 0) - Borrador - @endif - - @if($invoice->status == 1) - Impagada - @endif - - @if($invoice->status == 2) - Pagada - @endif - - @if($invoice->status == 3) - Adeudada / Abandonada - @endif -
-
-
-
- - - -
-
-
-

Faltas / incidencias

-
-
-
-
-
-
-

Servicios

-
- -
+
+
+
+

Servicios

+
+ +
+
+
+ + + + + + + + + + + @foreach($services as $service) + + @if($service->active == 0) + + @else + + @endif + + + + + @endforeach + +
ServicioDesdeHasta
{{$service->name}}{{$service->name}}{{DateHelper::getDate($service->created_at)}} + @if(strlen($service->date_to)>4) + {{DateHelper::getDate($service->date_to)}} + @else + Aún activo + @endif + + @if($service->active == 0) + Reactivar +
+ Eliminar + @else + Desactivar + @endif +
+
-
- - - - - - - - - - @foreach($services as $service) - - - - - - @endforeach - -
ServicioContratado desde
{{$service->name}}{{DateHelper::getDate($service->created_at)}} - -
-
+
+ + +
+ + + +
+ + +
+
+
+

Horario

+
+ Leyenda:   + Grupo lleno  + Grupo casi lleno  + Grupo libre  + Alumno en este grupo +
+
+
+ +
-
- - -
- - - -
- -
-
-
-

Horario

-
- Leyenda:   - Grupo lleno  - Grupo casi lleno  - Grupo libre  - Alumno en este grupo -
-
-
-
- + +
+ + + @else +
+

¿Más datos?

+

No se pueden asignar ni consultar horarios, incidencias o recibos pendientes para clientes que no son alumnos

- - - @else -
-

¿Más datos?

-

No se pueden asignar ni consultar horarios, incidencias o recibos pendientes para clientes que no son alumnos

-
- @endif - + @endif + @include('client.modals.addService') @include('client.modals.enrolRoom') - +
@stop From 627d8bbfcf42af2a437f3348390ce3eaeb705a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Borja=20Jos=C3=A9?= Date: Fri, 25 Sep 2015 21:36:07 +0200 Subject: [PATCH 2/2] Migracion de servicios disponible y nuevo diseno del panel del alumno --- app/Http/Controllers/ServicesController.php | 12 ++++- app/Http/routes.php | 1 + .../views/client/modals/addService.blade.php | 53 +++++++++++++++++++ resources/views/client/view.blade.php | 9 ++-- 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ServicesController.php b/app/Http/Controllers/ServicesController.php index fd2e5b2..3038a9a 100644 --- a/app/Http/Controllers/ServicesController.php +++ b/app/Http/Controllers/ServicesController.php @@ -142,7 +142,17 @@ public function getEnable($id) //return a redirect return redirect('/client/view/'.$serviceClient->fk_client); } - + /* + * This function switches from service to another + */ + public function switchService(Request $request) + { + $data = $request->all(); + $serviceClient = ServiceClient::find($data['fk_origin']); + $serviceClient->fk_service = $data['fk_destiny']; + $serviceClient->save(); + return redirect('/client/view/'.$serviceClient->fk_client); + } /* * This function updates the service based on his id */ diff --git a/app/Http/routes.php b/app/Http/routes.php index 8d05ee1..826b9b1 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -53,6 +53,7 @@ Route::get('/service/unlink/{id}', 'ServicesController@getUnlink'); Route::get('/service/disable/{id}', 'ServicesController@getDisable'); Route::get('/service/enable/{id}', 'ServicesController@getEnable'); + Route::post('/service/switch/', 'ServicesController@switchService'); Route::get('/services/delete/{id}', 'ServicesController@getDelete'); //Rooms / Horarios Route::get('/rooms', 'RoomController@getPreview'); diff --git a/resources/views/client/modals/addService.blade.php b/resources/views/client/modals/addService.blade.php index dc322ad..13f7211 100644 --- a/resources/views/client/modals/addService.blade.php +++ b/resources/views/client/modals/addService.blade.php @@ -82,3 +82,56 @@ + + + + + \ No newline at end of file diff --git a/resources/views/client/view.blade.php b/resources/views/client/view.blade.php index 2a4ce4e..692cfa9 100644 --- a/resources/views/client/view.blade.php +++ b/resources/views/client/view.blade.php @@ -298,6 +298,7 @@

Servicios

+
@@ -405,19 +406,19 @@ @if(count(RoomController::getRoomsForService($service->serviceId, $i, $a))>0) @foreach(RoomController::getRoomsForService($service->serviceId, $i, $a) as $roomService) @if(count(RoomController::isClientEnroled($roomService->id, $model->id))>0) - + @else @if(($roomService->capacity - RoomController::getRoomOcupance($roomService->id, $a, $i)) > 2) - + @else @if(($roomService->capacity - RoomController::getRoomOcupance($roomService->id, $a, $i)) <= 2 && ($roomService->capacity - RoomController::getRoomOcupance($roomService->id, $a, $i)) > 0) - + @else @if(($roomService->capacity - RoomController::getRoomOcupance($roomService->id, $a, $i)) == 0) - + @endif @endif