diff --git a/app/Attendance.php b/app/Attendance.php index 44551a7..dcbc159 100644 --- a/app/Attendance.php +++ b/app/Attendance.php @@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model; class Attendance extends Model { protected $fillable = [ - 'classes_id', 'student_id_number', 'student_name', 'student_surname', 'seat_number' + 'classes_id', 'student_id_number', 'student_name', 'student_surname', 'seat_number', 'notes' ]; } diff --git a/app/Http/Controllers/User/UserClassesController.php b/app/Http/Controllers/User/UserClassesController.php index c8631c7..4e1448a 100644 --- a/app/Http/Controllers/User/UserClassesController.php +++ b/app/Http/Controllers/User/UserClassesController.php @@ -8,6 +8,7 @@ use Illuminate\Http\Request; use App\Subject; use App\Classes; +use App\Room; use Illuminate\Support\Facades\Auth; @@ -67,7 +68,6 @@ class UserClassesController extends Controller $classes->save(); $classes->refresh(); } - return view('map.start_map', ['classes_code' => $classes_code, 'classes' => $classes]); } @@ -79,7 +79,12 @@ class UserClassesController extends Controller $classes = Classes::find($request->get('classes_id')); $attendances = Attendance::where('classes_id', $classes->id)->get(); $seat_numbers = $attendances->pluck('seat_number')->toArray(); - return view('map.seat_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'student_id_number' => $student_id_number, 'classes_id' => $classes->id, 'seat_numbers' => $seat_numbers]); + $subject = Subject::find($classes->subject_id); + $room_arrangement = Room::find($subject->room_id)->arrangement; + if(!$room_arrangement) { + $room_arrangement = Room::where('name', 'Inna sala')->get()->arrangement; + } + return view('map.seat_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'student_id_number' => $student_id_number, 'classes_id' => $classes->id, 'seat_numbers' => $seat_numbers, 'room_arrangement' => $room_arrangement]); } public function save_classes_data(Request $request) diff --git a/app/Http/Controllers/User/UserSubjectsController.php b/app/Http/Controllers/User/UserSubjectsController.php index b206ab1..ebc72e7 100644 --- a/app/Http/Controllers/User/UserSubjectsController.php +++ b/app/Http/Controllers/User/UserSubjectsController.php @@ -18,13 +18,13 @@ class UserSubjectsController extends Controller $user_id = Auth::id(); $subjects = Subject::where('user_id', $user_id)->get(); $subjects_grouped = $subjects->groupBy($groupBy); -// $rooms = Room::all(); + $rooms = Room::all(); $weekdays = ['Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota', 'Niedziela']; // $types = ['Lecture', 'Excercises', 'Labs', 'Other']; $defaultTime = date("H:i"); $defaultWeekday = $weekdays[date('w')-1]; return view('user.user_subjects', ['subjects' => $subjects, 'weekdays' => $weekdays, - 'subjects_grouped' => $subjects_grouped, 'grouped_by' => $groupBy, 'defaultTime' => $defaultTime, 'defaultWeekday' => $defaultWeekday]); + 'subjects_grouped' => $subjects_grouped, 'grouped_by' => $groupBy, 'defaultTime' => $defaultTime, 'defaultWeekday' => $defaultWeekday, 'rooms' => $rooms]); } public function add_subject(Request $request) @@ -33,14 +33,14 @@ class UserSubjectsController extends Controller // $type = $request->input('type'); $weekday = $request->input('weekday'); $time = $request->input('time'); -// $room_id = $request->input('room_id'); + $room_id = $request->input('room_id'); $user_id_n = Auth::id(); Subject::create([ 'name' => $name, // 'type' => $type, 'weekday'=> $weekday, 'time' => $time, -// 'room_id' => $room_id, + 'room_id' => $room_id, 'user_id' => $user_id_n ]); return redirect(route('user_subjects')); diff --git a/database/migrations/2019_11_26_232906_create_subjects_table.php b/database/migrations/2019_11_26_232906_create_subjects_table.php index fd1e50a..34a7d5b 100644 --- a/database/migrations/2019_11_26_232906_create_subjects_table.php +++ b/database/migrations/2019_11_26_232906_create_subjects_table.php @@ -19,7 +19,7 @@ class CreateSubjectsTable extends Migration // $table->string('type')->nullable(); $table->string('weekday')->nullable(); $table->string('time')->nullable(); -// $table->integer('room_id'); + $table->integer('room_id'); $table->integer('user_id'); $table->timestamps(); }); diff --git a/database/migrations/2019_11_26_232945_create_rooms_table.php b/database/migrations/2019_11_26_232945_create_rooms_table.php index 0e9642b..fec74af 100644 --- a/database/migrations/2019_11_26_232945_create_rooms_table.php +++ b/database/migrations/2019_11_26_232945_create_rooms_table.php @@ -17,7 +17,7 @@ class CreateRoomsTable extends Migration $table->bigIncrements('id')->unique(); $table->string('name')->unique(); $table->integer('capacity')->nullable(); - $table->string('arrangement')->nullable(); + $table->text('arrangement')->nullable(); $table->timestamps(); }); } diff --git a/database/migrations/2019_11_26_233012_create_attendances_table.php b/database/migrations/2019_11_26_233012_create_attendances_table.php index b67e588..924f981 100644 --- a/database/migrations/2019_11_26_233012_create_attendances_table.php +++ b/database/migrations/2019_11_26_233012_create_attendances_table.php @@ -20,6 +20,7 @@ class CreateAttendancesTable extends Migration $table->string('student_name'); $table->string('student_surname'); $table->integer('seat_number'); + $table->text('notes')->nullable(); $table->timestamps(); }); } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index ab47d2e..ae23538 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -13,7 +13,7 @@ class DatabaseSeeder extends Seeder { $this->call([ UsersTableSeeder::class, -// RoomsTableSeeder::class, + RoomsTableSeeder::class, SubjectsTableSeeder::class, ClassesTableSeeder::class, AttendancesTableSeeder::class, diff --git a/database/seeds/RoomsTableSeeder.php b/database/seeds/RoomsTableSeeder.php index cbc8106..e93c313 100644 --- a/database/seeds/RoomsTableSeeder.php +++ b/database/seeds/RoomsTableSeeder.php @@ -12,61 +12,76 @@ class RoomsTableSeeder extends Seeder public function run() { $rooms = [ - array('name' => 'A0-1', 'capacity' => 30), - array('name' => 'A0-11', 'capacity' => 24), - array('name' => 'A0-12', 'capacity' => 24), - array('name' => 'A0-3', 'capacity' => 13), - array('name' => 'A0-5', 'capacity' => 13), - array('name' => 'A1-14/15', 'capacity' => 25), - array('name' => 'A1-16/17', 'capacity' => 25), - array('name' => 'A1-18', 'capacity' => 13), - array('name' => 'A1-20', 'capacity' => 13), - array('name' => 'A1-22/23', 'capacity' => 25), - array('name' => 'A1-24/25', 'capacity' => 25), - array('name' => 'A1-33 (Sala RW)', 'capacity' => 64), - array('name' => 'A2-1', 'capacity' => 24), - array('name' => 'A2-10', 'capacity' => 34), - array('name' => 'A2-11', 'capacity' => 34), - array('name' => 'A2-12', 'capacity' => 34), - array('name' => 'A2-14', 'capacity' => 48), - array('name' => 'A2-19', 'capacity' => 48), - array('name' => 'A2-2', 'capacity' => 34), - array('name' => 'A2-20', 'capacity' => 32), - array('name' => 'A2-21', 'capacity' => 48), - array('name' => 'A2-22', 'capacity' => 48), - array('name' => 'A2-23', 'capacity' => 48), - array('name' => 'A2-24', 'capacity' => 48), - array('name' => 'A2-3', 'capacity' => 24), - array('name' => 'A2-4', 'capacity' => 24), - array('name' => 'A2-5', 'capacity' => 24), - array('name' => 'A2-8', 'capacity' => 24), - array('name' => 'A2-9', 'capacity' => 34), - array('name' => 'Aula A', 'capacity' => 196), - array('name' => 'Aula B', 'capacity' => 117), - array('name' => 'Aula C', 'capacity' => 117), - array('name' => 'B1-06', 'capacity' => 4), - array('name' => 'B1-07/08', 'capacity' => 16), - array('name' => 'B1-37', 'capacity' => 18), - array('name' => 'B1-38', 'capacity' => 12), - array('name' => 'B2-08/09', 'capacity' => 16), - array('name' => 'B2-38', 'capacity' => 15), - array('name' => 'B2-39', 'capacity' => 12), - array('name' => 'B2-44', 'capacity' => 4), - array('name' => 'B3-08/09', 'capacity' => 16), - array('name' => 'B3-38', 'capacity' => 18), - array('name' => 'B3-39', 'capacity' => 18), - array('name' => 'B3-49', 'capacity' => 12), - array('name' => 'C2-3', 'capacity' => 1), - array('name' => 'D-1', 'capacity' => 22), - array('name' => 'D-2', 'capacity' => 21), - array('name' => 'D-3', 'capacity' => 22), - array('name' => 'Klub Profesorski', 'capacity' => null) + array('name' => 'A0-1', 'capacity' => 30, 'arrangement' => + 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]c[6,6]++_++c[7,7]c[8,8]c[9,9]c[10,10]c[11,11]c[12,12]++c[13,13]c[14,14]c[15,15]c[16,16]c[17,17]c[18,18]' + ), + array('name' => 'A0-11', 'capacity' => 24, 'arrangement' => + '__c[3,3]c[4,4]c[5,5]c[6,6]++c[7,7]c[8,8]_c[10,10]c[11,11]c[12,12]++c[13,13]c[14,14]c[15,15]c[16,16]c[17,17]c[18,18]' + ), + array('name' => 'A0-12', 'capacity' => 24, 'arrangement' => ''), + array('name' => 'A0-3', 'capacity' => 13, 'arrangement' => ''), + array('name' => 'A0-5', 'capacity' => 13, 'arrangement' => ''), + array('name' => 'A1-14/15', 'capacity' => 25, 'arrangement' => + 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]++_++c[6,6]c[7,7]c[8,8]c[9,9]++c[10,10]c[11,11]c[12,12]c[13,13]++_++c[14,14]c[15,15]c[16,16]c[17,17]++_++c[18,18]c[19,19]c[20,20]c[21,21]++c[22,22]c[23,23]c[24,24]c[25,25]' + ), + array('name' => 'A1-16/17', 'capacity' => 25, 'arrangement' => + 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]++_++c[6,6]c[7,7]c[8,8]c[9,9]++c[10,10]c[11,11]c[12,12]c[13,13]++_++c[14,14]c[15,15]c[16,16]c[17,17]++_++c[18,18]c[19,19]c[20,20]c[21,21]++c[22,22]c[23,23]c[24,24]c[25,25]' + ), + array('name' => 'A1-18', 'capacity' => 13, 'arrangement' => ''), + array('name' => 'A1-20', 'capacity' => 13, 'arrangement' => ''), + array('name' => 'A1-22/23', 'capacity' => 25, 'arrangement' => + 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]++_++c[6,6]c[7,7]c[8,8]c[9,9]++c[10,10]c[11,11]c[12,12]c[13,13]++_++c[14,14]c[15,15]c[16,16]c[17,17]++_++c[18,18]c[19,19]c[20,20]c[21,21]++c[22,22]c[23,23]c[24,24]c[25,25]' + ), + array('name' => 'A1-24/25', 'capacity' => 25, 'arrangement' => + 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]++_++c[6,6]c[7,7]c[8,8]c[9,9]++c[10,10]c[11,11]c[12,12]c[13,13]++_++c[14,14]c[15,15]c[16,16]c[17,17]++_++c[18,18]c[19,19]c[20,20]c[21,21]++c[22,22]c[23,23]c[24,24]c[25,25]' + ), + array('name' => 'A1-33 (Sala RW)', 'capacity' => 64, 'arrangement' => ''), + array('name' => 'A2-1', 'capacity' => 24, 'arrangement' => ''), + array('name' => 'A2-10', 'capacity' => 34, 'arrangement' => ''), + array('name' => 'A2-11', 'capacity' => 34, 'arrangement' => ''), + array('name' => 'A2-12', 'capacity' => 34, 'arrangement' => ''), + array('name' => 'A2-14', 'capacity' => 48, 'arrangement' => ''), + array('name' => 'A2-19', 'capacity' => 48, 'arrangement' => ''), + array('name' => 'A2-2', 'capacity' => 34, 'arrangement' => ''), + array('name' => 'A2-20', 'capacity' => 32, 'arrangement' => ''), + array('name' => 'A2-21', 'capacity' => 48, 'arrangement' => ''), + array('name' => 'A2-22', 'capacity' => 48, 'arrangement' => ''), + array('name' => 'A2-23', 'capacity' => 48, 'arrangement' => ''), + array('name' => 'A2-24', 'capacity' => 48, 'arrangement' => ''), + array('name' => 'A2-3', 'capacity' => 24, 'arrangement' => ''), + array('name' => 'A2-4', 'capacity' => 24, 'arrangement' => ''), + array('name' => 'A2-5', 'capacity' => 24, 'arrangement' => ''), + array('name' => 'A2-8', 'capacity' => 24, 'arrangement' => ''), + array('name' => 'A2-9', 'capacity' => 34, 'arrangement' => ''), + array('name' => 'Aula A', 'capacity' => 196, 'arrangement' => ''), + array('name' => 'Aula B', 'capacity' => 117, 'arrangement' => ''), + array('name' => 'Aula C', 'capacity' => 117, 'arrangement' => ''), + array('name' => 'B1-06', 'capacity' => 4, 'arrangement' => ''), + array('name' => 'B1-07/08', 'capacity' => 16, 'arrangement' => ''), + array('name' => 'B1-37', 'capacity' => 18, 'arrangement' => ''), + array('name' => 'B1-38', 'capacity' => 12, 'arrangement' => ''), + array('name' => 'B2-08/09', 'capacity' => 16, 'arrangement' => ''), + array('name' => 'B2-38', 'capacity' => 15, 'arrangement' => ''), + array('name' => 'B2-39', 'capacity' => 12, 'arrangement' => ''), + array('name' => 'B2-44', 'capacity' => 4, 'arrangement' => ''), + array('name' => 'B3-08/09', 'capacity' => 16, 'arrangement' => ''), + array('name' => 'B3-38', 'capacity' => 18, 'arrangement' => ''), + array('name' => 'B3-39', 'capacity' => 18, 'arrangement' => ''), + array('name' => 'B3-49', 'capacity' => 12, 'arrangement' => ''), + array('name' => 'C2-3', 'capacity' => 1, 'arrangement' => ''), + array('name' => 'D-1', 'capacity' => 22, 'arrangement' => ''), + array('name' => 'D-2', 'capacity' => 21, 'arrangement' => ''), + array('name' => 'D-3', 'capacity' => 22, 'arrangement' => ''), + array('name' => 'Klub Profesorski', 'capacity' => null, 'arrangement' => ''), + array('name' => 'Inna sala', 'capacity' => null, 'arrangement' => + 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]++_++c[6,6]c[7,7]c[8,8]c[9,9]++c[10,10]c[11,11]c[12,12]c[13,13]++_++c[14,14]c[15,15]c[16,16]c[17,17]++_++c[18,18]c[19,19]c[20,20]c[21,21]++c[22,22]c[23,23]c[24,24]c[25,25]' + ) ]; foreach ($rooms as $room) { DB::table('rooms')->insert([ 'name' => $room['name'], 'capacity' => $room['capacity'], - 'arrangement' => '' + 'arrangement' => $room['arrangement'] ]); } } diff --git a/database/seeds/SubjectsTableSeeder.php b/database/seeds/SubjectsTableSeeder.php index 96834ee..178b480 100644 --- a/database/seeds/SubjectsTableSeeder.php +++ b/database/seeds/SubjectsTableSeeder.php @@ -15,6 +15,7 @@ class SubjectsTableSeeder extends Seeder 'name' => 'Systemy Informatyczne UA0', 'weekday' => 'Poniedziałek', 'time' => '15:30', + 'room_id' => 1, 'user_id' => 2 ]); @@ -22,6 +23,7 @@ class SubjectsTableSeeder extends Seeder 'name' => 'Systemy Informatyczne UA0', 'weekday' => 'Wtorek', 'time' => '17:15', + 'room_id' => 2, 'user_id' => 3 ]); } diff --git a/public/js/map/seatchart-custom.js b/public/js/map/seatchart-custom.js index 3a90530..1392f30 100644 --- a/public/js/map/seatchart-custom.js +++ b/public/js/map/seatchart-custom.js @@ -31,7 +31,6 @@ function checkForUnavailablePlaces() { unavailablePlaces.push($(this).val()); }); - console.log(unavailablePlaces); const allPlaces = $('.seatCharts-seat.seatCharts-cell.available'); if(unavailablePlaces){ allPlaces.each(function(){ diff --git a/public/js/map/seatchart.js b/public/js/map/seatchart.js index d69e69d..5f22d2f 100644 --- a/public/js/map/seatchart.js +++ b/public/js/map/seatchart.js @@ -1,105 +1,102 @@ var firstSeatLabel = 1; - $(document).ready(function() { - var $cart = $('#selected-seats'), - seatNumber = '', - placeNumber = ('#sel-seat'), - $counter = $('#counter'), - $name = $('#studentName'), - $total = $('#total'), - sc = $('#seat-map').seatCharts({ - map: [ - 'c[1,1]c[2,2]c[3,3]c[4,4]c[5,5]c[6,6]', - '_', - 'c[7,7]c[8,8]c[9,9]c[10,10]c[11,11]c[12,12]', - 'c[13,13]c[14,14]c[15,15]c[16,16]c[17,17]c[18,18]', - ], - seats: { +$(document).ready(function() { + const seat_map = $('#room_arrangement').val().split('++'); + + var $cart = $('#selected-seats'), + seatNumber = '', + placeNumber = ('#sel-seat'), + $counter = $('#counter'), + $name = $('#studentName'), + $total = $('#total'), + sc = $('#seat-map').seatCharts({ + map: seat_map, + seats: { h: { - price : 2500, - classes : 'student-class', - category: 'Student Seat' - }, - }, - naming : { + price : 2500, + classes : 'student-class', + category: 'Student Seat' + }, + }, + naming : { rows: ['','','',''], - top : false, - getLabel : function (character, row, column) { - if (row == '1') { + top : false, + getLabel : function (character, row, column) { + if (row === '1') { return column; - } else if (row == '2') { + } else if (row === '2') { return column; - } else if (row == '3') { + } else if (row === '3') { return column; } - }, - }, - legend : { - node : $('#legend'), - items : [ + }, + }, + legend : { + node : $('#legend'), + items : [ [ 'c', 'available', 'Dostępne miejsce'], [ 'f', 'unavailable', 'Zajęte miejsce'] - ] - }, - click: function () { - if (this.status() == 'available' && recalculateTotal(sc) < 1) { - //let's create a new