Loading app/Http/Controllers/ManualPalanqueeController.php +14 −1 Changes for app/Http/Controllers/ManualPalanqueeController.php: 14 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ namespace App\Http\Controllers; use App\Models\DivingGroup; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; class ManualPalanqueeController extends Controller { Loading @@ -16,7 +19,17 @@ public function index(){ } public function store(Request $request){ try { $data = $request->json()->all(); return response()->json(['message' => 'Data received successfully'], 200); DB::insert('insert into CAR_DIVING_GROUP (DS_CODE, DG_NUMBER) values (?,?)', ['200', '200']); $responseData = ['message' => 'Data received successfully', 'additionalData' => $data[count($data) - 1]]; return response()->json($responseData); } catch (\Illuminate\Database\QueryException $e) { return response()->json(['error' => 'Internal Server Error'], 500); } } public function test(){ } } app/Models/DivingGroup.php +1 −0 Changes for app/Models/DivingGroup.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ class DivingGroup extends Model { protected $table = 'CAR_DIVING_GROUP'; protected $fillable = 'DS_CODE'; use HasFactory; Loading public/js/Palanque/manualPalanque.js +11 −14 Changes for public/js/Palanque/manualPalanque.js: 11 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ function isElementInList(element, list){ addPalanque.addEventListener("click", function(){ countZone++; let palanque = document.createElement("div"); palanque.setAttribute("class", "border-2 p-4"); palanque.setAttribute("class", "border-2 p-4 zone"); palanque.setAttribute("id", "zone " + (countZone)); palanque.setAttribute("ondrop", "drop(event)"); palanque.setAttribute("ondragover", "allowDrop(event)"); Loading Loading @@ -113,11 +113,11 @@ function proccessDiverData(data){ for(let i = 0; i < data.length; i++){ countDiver++; let diver = document.createElement("div"); diver.setAttribute("class", "w-fit h-8 border-2 zone"); diver.setAttribute("id", 'item' + countDiver +',' + data[i].PRE_CODE); diver.setAttribute("class", "w-fit h-8 border-2"); diver.setAttribute("id", 'item' + countDiver +',' + data[i].PRE_CODE + ',E' + data[i].US_TEACHING_LEVEL + ',' + data[i].US_ID); diver.setAttribute("draggable", "true"); diver.setAttribute("ondragstart", "drag(event)"); diver.innerHTML = data[i].US_FIRST_NAME + " " + data[i].US_NAME; diver.innerHTML = data[i].US_FIRST_NAME + " " + data[i].US_NAME + " " + data[i].PRE_CODE + " " + data[i].US_TEACHING_LEVEL; zoneStart.appendChild(diver); } } Loading Loading @@ -164,23 +164,25 @@ validatePalanque.addEventListener("click", function(){ sendPalanque(); }); function returnValueToPhp() { function returnValueToPhp(ds_code) { let palanque = document.querySelectorAll("div.zone"); console.log(palanque); let palanqueList = []; for (let i = 0; i < palanque.length; i++) { let zoneList = []; for (let j = 0; j < palanque[i].childElementCount; j++) { let item = palanque[i].childNodes[j]; zoneList.push(item.id.split(',')[1]); zoneList.push(item.id.split(',')[3]); } palanqueList.push(zoneList); } palanqueList.push(ds_code); console.log(palanqueList); return palanqueList; } function sendPalanque() { let palanqueList = returnValueToPhp(); let palanqueList = returnValueToPhp('DS10'); let palanqueListJson = JSON.stringify(palanqueList); let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); Loading @@ -194,13 +196,8 @@ function sendPalanque() { console.log("Request successful"); const responseData = JSON.parse(xhr.responseText); // Check if a 'redirect' property exists in the response if (responseData.redirect) { // Redirect to the URL specified in the response window.location.href = responseData.redirect; } else { console.error("Invalid response format - missing 'redirect' property"); } // Log the additional data in the console console.log("Additional Data:", responseData.additionalData); } else { console.error("Request failed"); } Loading resources/views/palanque_manuel.blade.php +2 −15 Changes for resources/views/palanque_manuel.blade.php: 2 added lines, 15 removed lines. Original line number Diff line number Diff line <meta name="csrf-token" content="{{ $token }}"> <x-layout> <div class="flex justify-around m-5"> <div class="p-2 grid grid-cols-5"> <div class="grid grid-cols-1"> <h3>Zone 1</h3> <div class="border-2 p-4" id="zoneStart" ondrop="drop(event)" ondragover="allowDrop(event)"> <div class="w-fit h-8 border-2" id="item1,PA" draggable="true" ondragstart="drag(event)">PA</div> <div class="w-fit h-8 border-2" id="item2,PB" draggable="true" ondragstart="drag(event)">PB</div> <div class="w-fit h-8 border-2" id="item3,PO" draggable="true" ondragstart="drag(event)">PO</div> <div class="w-fit h-8 border-2" id="item4,PA-12" draggable="true" ondragstart="drag(event)">PA-12</div> <div class="w-fit h-8 border-2" id="item5,PE-20" draggable="true" ondragstart="drag(event)">PE-20</div> <div class="w-fit h-8 border-2" id="item6,PE-40" draggable="true" ondragstart="drag(event)">PE-40</div> <div class="w-fit h-8 border-2" id="item7,PA-40" draggable="true" ondragstart="drag(event)">PA-40</div> <div class="w-fit h-8 border-2" id="item8,PA-60" draggable="true" ondragstart="drag(event)">PA-60</div> <div class="w-fit h-8 border-2" id="item9,PE-60" draggable="true" ondragstart="drag(event)">PE-60</div> <div class="w-fit h-8 border-2" id="item10,E1" draggable="true" ondragstart="drag(event)">E1</div> <div class="w-fit h-8 border-2" id="item11,E2" draggable="true" ondragstart="drag(event)">E2</div> <div class="w-fit h-8 border-2" id="item12,E3" draggable="true" ondragstart="drag(event)">E3</div> <div class="w-fit h-8 border-2" id="item13,E4" draggable="true" ondragstart="drag(event)">P4</div> <div class="border-2" id="zoneStart" ondrop="drop(event)" ondragover="allowDrop(event)"> </div> </div> Loading routes/web.php +1 −0 Changes for routes/web.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -88,3 +88,4 @@ DivingSession::find($id)->disable(); return redirect('/'); }); Loading
app/Http/Controllers/ManualPalanqueeController.php +14 −1 Changes for app/Http/Controllers/ManualPalanqueeController.php: 14 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -2,7 +2,10 @@ namespace App\Http\Controllers; use App\Models\DivingGroup; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; class ManualPalanqueeController extends Controller { Loading @@ -16,7 +19,17 @@ public function index(){ } public function store(Request $request){ try { $data = $request->json()->all(); return response()->json(['message' => 'Data received successfully'], 200); DB::insert('insert into CAR_DIVING_GROUP (DS_CODE, DG_NUMBER) values (?,?)', ['200', '200']); $responseData = ['message' => 'Data received successfully', 'additionalData' => $data[count($data) - 1]]; return response()->json($responseData); } catch (\Illuminate\Database\QueryException $e) { return response()->json(['error' => 'Internal Server Error'], 500); } } public function test(){ } }
app/Models/DivingGroup.php +1 −0 Changes for app/Models/DivingGroup.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ class DivingGroup extends Model { protected $table = 'CAR_DIVING_GROUP'; protected $fillable = 'DS_CODE'; use HasFactory; Loading
public/js/Palanque/manualPalanque.js +11 −14 Changes for public/js/Palanque/manualPalanque.js: 11 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -83,7 +83,7 @@ function isElementInList(element, list){ addPalanque.addEventListener("click", function(){ countZone++; let palanque = document.createElement("div"); palanque.setAttribute("class", "border-2 p-4"); palanque.setAttribute("class", "border-2 p-4 zone"); palanque.setAttribute("id", "zone " + (countZone)); palanque.setAttribute("ondrop", "drop(event)"); palanque.setAttribute("ondragover", "allowDrop(event)"); Loading Loading @@ -113,11 +113,11 @@ function proccessDiverData(data){ for(let i = 0; i < data.length; i++){ countDiver++; let diver = document.createElement("div"); diver.setAttribute("class", "w-fit h-8 border-2 zone"); diver.setAttribute("id", 'item' + countDiver +',' + data[i].PRE_CODE); diver.setAttribute("class", "w-fit h-8 border-2"); diver.setAttribute("id", 'item' + countDiver +',' + data[i].PRE_CODE + ',E' + data[i].US_TEACHING_LEVEL + ',' + data[i].US_ID); diver.setAttribute("draggable", "true"); diver.setAttribute("ondragstart", "drag(event)"); diver.innerHTML = data[i].US_FIRST_NAME + " " + data[i].US_NAME; diver.innerHTML = data[i].US_FIRST_NAME + " " + data[i].US_NAME + " " + data[i].PRE_CODE + " " + data[i].US_TEACHING_LEVEL; zoneStart.appendChild(diver); } } Loading Loading @@ -164,23 +164,25 @@ validatePalanque.addEventListener("click", function(){ sendPalanque(); }); function returnValueToPhp() { function returnValueToPhp(ds_code) { let palanque = document.querySelectorAll("div.zone"); console.log(palanque); let palanqueList = []; for (let i = 0; i < palanque.length; i++) { let zoneList = []; for (let j = 0; j < palanque[i].childElementCount; j++) { let item = palanque[i].childNodes[j]; zoneList.push(item.id.split(',')[1]); zoneList.push(item.id.split(',')[3]); } palanqueList.push(zoneList); } palanqueList.push(ds_code); console.log(palanqueList); return palanqueList; } function sendPalanque() { let palanqueList = returnValueToPhp(); let palanqueList = returnValueToPhp('DS10'); let palanqueListJson = JSON.stringify(palanqueList); let csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content'); Loading @@ -194,13 +196,8 @@ function sendPalanque() { console.log("Request successful"); const responseData = JSON.parse(xhr.responseText); // Check if a 'redirect' property exists in the response if (responseData.redirect) { // Redirect to the URL specified in the response window.location.href = responseData.redirect; } else { console.error("Invalid response format - missing 'redirect' property"); } // Log the additional data in the console console.log("Additional Data:", responseData.additionalData); } else { console.error("Request failed"); } Loading
resources/views/palanque_manuel.blade.php +2 −15 Changes for resources/views/palanque_manuel.blade.php: 2 added lines, 15 removed lines. Original line number Diff line number Diff line <meta name="csrf-token" content="{{ $token }}"> <x-layout> <div class="flex justify-around m-5"> <div class="p-2 grid grid-cols-5"> <div class="grid grid-cols-1"> <h3>Zone 1</h3> <div class="border-2 p-4" id="zoneStart" ondrop="drop(event)" ondragover="allowDrop(event)"> <div class="w-fit h-8 border-2" id="item1,PA" draggable="true" ondragstart="drag(event)">PA</div> <div class="w-fit h-8 border-2" id="item2,PB" draggable="true" ondragstart="drag(event)">PB</div> <div class="w-fit h-8 border-2" id="item3,PO" draggable="true" ondragstart="drag(event)">PO</div> <div class="w-fit h-8 border-2" id="item4,PA-12" draggable="true" ondragstart="drag(event)">PA-12</div> <div class="w-fit h-8 border-2" id="item5,PE-20" draggable="true" ondragstart="drag(event)">PE-20</div> <div class="w-fit h-8 border-2" id="item6,PE-40" draggable="true" ondragstart="drag(event)">PE-40</div> <div class="w-fit h-8 border-2" id="item7,PA-40" draggable="true" ondragstart="drag(event)">PA-40</div> <div class="w-fit h-8 border-2" id="item8,PA-60" draggable="true" ondragstart="drag(event)">PA-60</div> <div class="w-fit h-8 border-2" id="item9,PE-60" draggable="true" ondragstart="drag(event)">PE-60</div> <div class="w-fit h-8 border-2" id="item10,E1" draggable="true" ondragstart="drag(event)">E1</div> <div class="w-fit h-8 border-2" id="item11,E2" draggable="true" ondragstart="drag(event)">E2</div> <div class="w-fit h-8 border-2" id="item12,E3" draggable="true" ondragstart="drag(event)">E3</div> <div class="w-fit h-8 border-2" id="item13,E4" draggable="true" ondragstart="drag(event)">P4</div> <div class="border-2" id="zoneStart" ondrop="drop(event)" ondragover="allowDrop(event)"> </div> </div> Loading
routes/web.php +1 −0 Changes for routes/web.php: 1 added line, 0 removed lines. Original line number Diff line number Diff line Loading @@ -88,3 +88,4 @@ DivingSession::find($id)->disable(); return redirect('/'); });