Changeset 7e9dadd
- Timestamp:
- 02/12/24 14:17:23 (11 months ago)
- Branches:
- main
- Children:
- 2bd3041
- Parents:
- 92df8cd
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
app/Http/Controllers/OfficerController.php
r92df8cd r7e9dadd 17 17 return view('login'); 18 18 } 19 $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;'); 19 if(Session::get('is_policeman')){ 20 $police_station = DB::select('select * from police_station where p_id=:p_id;',['p_id'=> Session::get('p_id')]); 21 } else { 22 $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]); 23 } 24 $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id where p_id=:p_id;',['p_id'=> $police_station[0]->p_id]); 25 // $results = DB::select('select * from policeman join people on policeman.pe_id = people.pe_id;'); 26 20 27 return view('employees', [ 21 'employees' => $results 28 'employees' => $results, 29 'p_address'=>$police_station[0]->p_address 22 30 ]); 23 31 } … … 36 44 ]); 37 45 46 47 $police_station = DB::select('select * from police_station where pe_id=:pe_id;',['pe_id'=> Session::get('pe_id')]); 48 38 49 $pe_id = DB::select('select pe_id from people where embg = :embg;', ['embg' => $policeman["embg"]]); 39 DB::insert('INSERT INTO policeman (pe_id, badge_no, p_date_of_employment, rank, p_id, p_password) VALUES (?, ?, ?, ?, ?, ?)', [$pe_id[0]->pe_id, $policeman["badge_no"], Carbon::now()->format('Y-m-d'), $policeman["rank"], $police STATION,$policeman["password"]]);40 return view('register-policeman');50 DB::insert('INSERT INTO policeman (pe_id, badge_no, p_date_of_employment, rank, p_id, p_password) VALUES (?, ?, ?, ?, ?, ?)', [$pe_id[0]->pe_id, $policeman["badge_no"], Carbon::now()->format('Y-m-d'), $policeman["rank"], $police_station[0]->p_id,$policeman["password"]]); 51 return redirect()->back()->with('message',"Додадено"); 41 52 } 42 53 -
app/Http/Controllers/PeopleController.php
r92df8cd r7e9dadd 23 23 return view('login'); 24 24 } 25 // $credentials = request()->validate([ 26 // 'embg' => 'required' 27 // ]); 28 // $embg = $credentials['embg']; 29 // 30 // $peoples = DB::select('SELECT * FROM people WHERE embg ~ :embg', ['embg' => '^' . $embg]); 31 25 32 $credentials = request()->validate([ 26 'embg' => 'required' 33 'embg' => 'nullable', // Assuming embg is not always required 34 'gender' => 'nullable', 35 'age' => 'nullable', 27 36 ]); 28 $ embg = $credentials['embg'];37 $query = 'SELECT * FROM people WHERE true'; 29 38 30 $peoples = DB::select('SELECT * FROM people WHERE embg ~ :embg', ['embg' => '^' . $embg]); 39 $embg = '^' . $credentials['embg']; 40 if ($credentials['embg']) { 41 $query .= " AND embg LIKE '{$credentials['embg']}%'"; 42 } 31 43 32 return view('filter', [ 33 'peoples' => $peoples 34 ]); 44 // Check if $credentials['gender'] is an array and handle accordingly 45 if (isset($credentials['gender']) && (is_array($credentials['gender']) && count($credentials['gender']) > 0)) { 46 $genderConditions = implode(" OR ", array_map(function ($gender) { 47 return "gender = '{$gender}'"; 48 }, $credentials['gender'])); 49 50 $query .= " AND ({$genderConditions})"; 51 } elseif (isset($credentials['gender']) && !is_array($credentials['gender'])) { 52 $query .= " AND gender = '{$credentials['gender']}'"; 53 } 54 55 // Check if $credentials['age'] is an array and handle accordingly 56 if (isset($credentials['age']) && is_array($credentials['age']) && count($credentials['age']) > 0) { 57 $ageConditions = []; 58 59 foreach ($credentials['age'] as $ageRange) { 60 // Extract minimum and maximum ages from the range 61 list($minAge, $maxAge) = explode('-', $ageRange); 62 63 // Add condition for the age range 64 $ageConditions[] = "EXTRACT(YEAR FROM AGE(current_date, date_of_birth)) BETWEEN {$minAge} AND {$maxAge}"; 65 } 66 67 $query .= " AND (" . implode(" OR ", $ageConditions) . ")"; 68 } 69 // Use a raw SQL query with the built conditions 70 71 $peoples = DB::select($query); 72 return view('filter', ['peoples' => $peoples]); 35 73 } 36 74 public function getPerson(Request $request) -
app/Http/Controllers/SessionsController.php
r92df8cd r7e9dadd 46 46 Session::put('pe_id', $exists[0]->pe_id); 47 47 } 48 return redirect()->intended('/');48 return view('welcome'); 49 49 } 50 50 -
resources/views/employees.blade.php
r92df8cd r7e9dadd 165 165 <div class="w-full overflow-x-hidden border-t flex flex-col"> 166 166 <main class="w-full flex-grow p-6"> 167 <h1 class="text-3xl text-black pb-6"> Контролна табла</h1>167 <h1 class="text-3xl text-black pb-6">Вработени во {{$p_address}}</h1> 168 168 169 169 170 170 <div class="w-full mt-12"> 171 171 <p class="text-xl pb-3 flex items-center"> 172 <i class="fas fa-list mr-3"></i> Вработени во станица Карпош - Скопје172 <i class="fas fa-list mr-3"></i> 173 173 </p> 174 174 <div class="bg-white overflow-auto"> -
resources/views/filter.blade.php
r92df8cd r7e9dadd 29 29 .flex-child-element { 30 30 flex: 1; 31 margin: 10px;31 margin: 4px; 32 32 } 33 33 … … 218 218 <main class="w-full flex-grow p-6"> 219 219 220 <h1 class="text-3xl text-black pb-6"> Контролна табла</h1>220 <h1 class="text-3xl text-black pb-6">Филтрирај граѓани</h1> 221 221 <div style="width: 600px"> 222 222 <form action="/filter" method="post"> … … 230 230 231 231 <label for="embg" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Search</label> 232 <input type="text" id="embg" name="embg" class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Пребарај матичен број..." required>232 <input type="text" id="embg" name="embg" class="block w-full p-4 ps-10 text-sm text-gray-900 border border-gray-300 rounded-lg bg-gray-50 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" placeholder="Пребарај матичен број..." > 233 233 <button type="submit" class="text-white absolute end-2.5 bottom-2.5 bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-4 py-2 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Search</button> 234 234 </div> 235 <div class="flex-parent-element"> 236 <h3>Возраст</h3> 237 238 <div class="flex-child-element"> 239 <label class="container"><18 240 <input type="checkbox" name="age[]" value="0-18"> 241 <span class="checkmark"></span> 242 </label> 243 244 <label class="container">19-25 245 <input type="checkbox" name="age[]" value="19-25"> 246 <span class="checkmark"></span> 247 </label> 248 249 <label class="container">26-60 250 <input type="checkbox" name="age[]" value="26-60"> 251 <span class="checkmark"></span> 252 </label> 253 254 <label class="container">60+ 255 <input type="checkbox" name="age[]" value="60-120"> 256 <span class="checkmark"></span> 257 </label> 258 </div> 259 260 <h3>Пол</h3> 261 <div class="flex-child-element"> 262 <label class="container">М 263 <input type="checkbox" name="gender[]" value="M"> 264 <span class="checkmark"></span> 265 </label> 266 267 <label class="container">Ж 268 <input type="checkbox" name="gender[]" value="F"> 269 <span class="checkmark"></span> 270 </label> 271 </div> 272 273 </div> 235 274 </form> 236 275 </div> 237 276 238 <div class="flex-parent-element"> 239 <h3>Возраст</h3> 240 241 <div class="flex-child-element"> <label class="container"><18 год 242 <input type="checkbox" checked="checked"> 243 <span class="checkmark"></span> 244 </label> 245 246 <label class="container"> 19-25 247 <input type="checkbox"> 248 <span class="checkmark"></span> 249 </label> 250 251 <label class="container">26-60 252 <input type="checkbox"> 253 <span class="checkmark"></span> 254 </label> 255 256 <label class="container">60+ 257 <input type="checkbox"> 258 <span class="checkmark"></span> 259 </label> 260 </div> 261 <h3>Пол</h3> 262 <div class="flex-child-element"> 263 <label class="container">М 264 <input type="checkbox" checked="checked"> 265 <span class="checkmark"></span> 266 </label> 267 268 <label class="container">Ж 269 <input type="checkbox"> 270 <span class="checkmark"></span> 271 </label> 272 </div> 273 </div> 277 {{-- <div class="flex-parent-element">--}} 278 {{-- <h3>Возраст</h3>--}} 279 280 {{-- <div class="flex-child-element"> <label class="container"><18 год--}} 281 {{-- <input type="checkbox" checked="checked">--}} 282 {{-- <span class="checkmark"></span>--}} 283 {{-- </label>--}} 284 285 {{-- <label class="container"> 19-25--}} 286 {{-- <input type="checkbox">--}} 287 {{-- <span class="checkmark"></span>--}} 288 {{-- </label>--}} 289 290 {{-- <label class="container">26-60--}} 291 {{-- <input type="checkbox">--}} 292 {{-- <span class="checkmark"></span>--}} 293 {{-- </label>--}} 294 295 {{-- <label class="container">60+--}} 296 {{-- <input type="checkbox">--}} 297 {{-- <span class="checkmark"></span>--}} 298 {{-- </label>--}} 299 {{-- </div>--}} 300 {{-- <h3>Пол</h3>--}} 301 {{-- <div class="flex-child-element">--}} 302 {{-- <label class="container">М--}} 303 {{-- <input type="checkbox" checked="checked">--}} 304 {{-- <span class="checkmark"></span>--}} 305 {{-- </label>--}} 306 307 {{-- <label class="container">Ж--}} 308 {{-- <input type="checkbox">--}} 309 {{-- <span class="checkmark"></span>--}} 310 {{-- </label>--}} 311 {{-- </div>--}} 312 {{-- </div>--}} 274 313 275 314 … … 306 345 </table> 307 346 </div> 308 </div>309 347 </main> 310 348 </div> -
resources/views/register-policeman.blade.php
r92df8cd r7e9dadd 112 112 } 113 113 114 .alert-success { 115 color: #3c763d; 116 background-color: #dff0d8; 117 border-color: #d6e9c6; 118 } 119 .alert { 120 padding: 15px; 121 margin-bottom: 20px; 122 border: 1px solid transparent; 123 border-radius: 4px; 124 width: 200px; 125 float: right; 126 } 114 127 </style> 115 128 <script src="https://cdn.tailwindcss.com"></script> … … 131 144 <a href="/" class="flex items-center text-white opacity-75 hover:opacity-100 py-4 pl-6 nav-item"> 132 145 <i class="fas fa-tachometer-alt mr-3"></i> 133 Сортирај граѓани146 Контролна табла 134 147 </a> 135 148 <a href="/employees" class="flex items-center text-white opacity-75 hover:opacity-100 py-4 pl-6 nav-item"> … … 232 245 233 246 234 235 247 <div class="w-full mt-12"> 236 248 <p class="text-xl pb-3 flex items-center"> … … 351 363 </div> 352 364 </form> 365 @if(session()->has('message')) 366 <div class="alert alert-success"> 367 <strong>{{ session()->get('message') }}</strong> 368 </div> 369 @endif 370 353 371 </div> 354 372 </div> -
resources/views/welcome.blade.php
r92df8cd r7e9dadd 72 72 <div x-data="{ isOpen: false }" class="relative w-1/2 flex justify-end"> 73 73 <button @click="isOpen = !isOpen" class="realtive z-10 w-12 h-12 rounded-full overflow-hidden border-4 border-gray-400 hover:border-gray-300 focus:border-gray-300 focus:outline-none"> 74 <img src="https:// source.unsplash.com/uJ8LNVCBjFQ/400x400">74 <img src="https://ui-avatars.com/api/?name={{ Session::get('badge_no') }}"> 75 75 </button> 76 76 <button x-show="isOpen" @click="isOpen = false" class="h-full w-full fixed inset-0 cursor-default"></button>
Note:
See TracChangeset
for help on using the changeset viewer.