-
المساهمات
386 -
تاريخ الانضمام
-
تاريخ آخر زيارة
-
عدد الأيام التي تصدر بها
1
نوع المحتوى
ريادة الأعمال
البرمجة
التصميم
DevOps
التسويق والمبيعات
العمل الحر
البرامج والتطبيقات
آخر التحديثات
قصص نجاح
أسئلة وأجوبة
كتب
دورات
كل منشورات العضو ايمن ميلاد
-
- 17 اجابة
-
- 2
-
-
هل هذا ينطبق علي جميع انواع اجازات حسب كود
- 17 اجابة
-
- 1
-
-
السلام عليكم اعمل علي نظام شؤون موظفين كيف يتم حساب اجازة موظف بناء علي كود تالي <?php namespace App\Http\Controllers; use Carbon\Carbon; use App\Models\Log; use App\Models\File; use App\Models\Employee; use App\Models\Vacation; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Storage; class VacationController extends Controller { function __construct() { $this->middleware('permission:vacation-list', ['only' => ['index','show','search']]); $this->middleware('permission:vacation-create', ['only' => ['create','createAll','store']]); $this->middleware('permission:vacation-edit', ['only' => ['edit','update','endVecation']]); $this->middleware('permission:vacation-delete', ['only' => ['destroy']]); } /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $vacations = Vacation::paginate(25); return view('admin.Vacation.index',compact('vacations')); } public function print(Request $request) { $vacations = Vacation::all(); return view('admin.Vacation.print', compact('vacations')); } function calculateVacationBalance($startDate, $usedDays) { $start = Carbon::parse($startDate); $now = Carbon::now(); $totalAccruedDays = 0; // ضبط تاريخ البداية ليتوافق مع أول فترة نصف سنوية بعد التاريخ المحدد if ($start->month > 6) { $start->month(1)->addYear()->day(1); // الانتقال إلى 1 يناير من العام التالي } elseif ($start->month < 6 || ($start->month == 6 && $start->day > 1)) { $start->month(6)->day(1); // الانتقال إلى 1 يونيو من نفس العام } else if ($start->month == 1 && $start->day > 1) { $start->month(6)->day(1); // إذا كان بعد 1 يناير، ننتقل إلى 1 يونيو } // حساب عدد الفترات نصف السنوية المؤهلة حتى الآن while ($start->lessThanOrEqualTo($now)) { $totalAccruedDays += 15; // إضافة 15 يوم لكل فترة نصف سنوية $start->addMonths(6); // الانتقال إلى الفترة نصف السنوية التالية } $totalAccruedDays -= $usedDays; // طرح الأيام المستخدمة return $totalAccruedDays; } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create($id) { $employee = Employee::find($id); $date = Carbon::createFromFormat('Y-m-d', $employee->start_date); $date = $date->addYear(); $date = $date->toDateString(); if($employee->vacations){ $vacationBalance = $this->calculateVacationBalance($date, $employee->vacations->where('accept', true)->sum("days")); }else{ $vacationBalance = $this->calculateVacationBalance($date, 0); } return view('admin.Vacation.create',compact('employee','vacationBalance')); } public function createAll() { $employees = Employee::where('startout_data', NULL)->get(); return view('admin.Vacation.createAll',compact('employees')); } public function endVecation($id) { $vac = Vacation::find($id); if($vac->start_date == $vac->end_date){ $vac->end_date = now()->format('Y-m-d'); $vac->days = now()->diffInDays($vac->start_date); $vac->update(); return redirect()->back()->with('success','تم إنهاء الإجازة بنجاح'); }else{ return redirect()->back()->with('error','عذرآ هذا الإجراء غير مسموح به حاليآ'); } } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request,$id) { request()->validate( [ 'type' => "required", 'start_date' => "required", 'end_date' => 'required', ], [ 'type.required' => 'يجب تحديد نوع الاجازة', 'start_date.required' => 'يجب إدخال تاريخ بداية الإجازة', 'end_date.required' => 'يجب ادخال تاريخ المباشرة', ]); DB::beginTransaction(); try { $vac = new Vacation; if($id == 0){ $emp = Employee::find(request('emp_id')); }else{ $emp = Employee::find($id); } if(Vacation::where([['emp_id', $emp->id],['accept', false]])->exists()){ DB::rollback(); return redirect()->back()->with('error','عذرآ ولكن هنالك أجازة قيد الاجراء للموظف الحالي الرجاء التحقق'); } if(!request('years') && !request('months') && !request('days')){ DB::rollback(); return redirect()->back()->with('error','عذرآ ولكن يجب تعبئة إحدي الخانات علي الاقل (السنوات ,الاشهر ,الايام)'); } if(request('type') == "إجازة وضع" && $emp->gender == 1 && $emp->status == 1){ DB::rollback(); return redirect()->back()->with('error','عذرآ ولكن لا يمكن أعطاء هذا النوع من الاجازة للموظف المختار'); } if(request('type') == "إجازة زواج" && $emp->vacations()->where("type", "إجازة زواج")->count() != 0 && $emp->status == 0 ){ DB::rollback(); return redirect()->back()->with('error','عذرآ الموظف المختار قد تحصل علي أجاة زواج مسبقآ'); } $vac->emp_id = $emp->id; $vac->type = request('type'); if(request('type') == "إجازة سنوية"){ $vac->days = request('days'); $date = Carbon::createFromFormat('Y-m-d', $emp->start_date); $date = $date->addYear(); $date = $date->toDateString(); if($emp->vacations){ $vacationBalance = $this->calculateVacationBalance($date, $emp->vacations->where('accept', true)->sum("days")); }else{ $vacationBalance = $this->calculateVacationBalance($date, 0); } if($vacationBalance < $vac->days){ DB::rollback(); return redirect()->back()->with('error','عذرآ لايمكن أنشاء إجازة وذلك لعدم توفر الرصيد الكافي...'); } }elseif(request('type') == "إجازة بدون مرتب" && !$request->has('person')){ $vac->days = 365; }else{ $vac->days = NULL; } $vac->created_id = auth()->user()->id; $start_date = request('start_date'); $vac->start_date = $start_date; $end_date = request('end_date'); $vac->end_date = $end_date; if($request->has('person')){ $vac->companion = true; }else{ $vac->companion = false; } if($request->has('approve')){ $vac->accept = true; } $vac->reason = request('reason'); $vac->save(); if (request()->hasFile('files')) { $files = request()->file('files'); // Get the files $finalArray = []; foreach ($files as $file) { // Use foreach for simpler syntax $fileName = time() . '.' . $file->getClientOriginalExtension(); $file->storeAs('VACATION', $fileName, 'public'); // Store the file $filePath = 'VACATION/' . $fileName; // Generate the file path $finalArray[] = [ 'type' => 'vacation', 'procedure_id' => $vac->id, 'path' => $filePath, ]; } if (!empty($finalArray)) { File::insert($finalArray); // Insert the file references } } $log = new Log; $log->user_id = auth()->user()->id; $log->type = 7; $log->emp_id = $emp->id; $log->title = " اضافة إجازة جديدة (".request('type').")"; $log->log = " تمت إضافة إجازة جديدة (".request('type').")"; $log->save(); if(request('type') =="إجازة زواج") { $emp->status=1; $emp->save(); } DB::commit(); return redirect()->route('vacations.show',[$emp->id])->with('success','تــمــت إضــافــة إجــازة الــموظــف بــنــجــاح'); // all good } catch (\Exception $e) { DB::rollback(); return redirect()->back()->with('error', 'للاسف حدث خطأ ما الرجاء اعادة المحاولة'); } } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { $employee = Employee::find($id); $vacations = Vacation::where('emp_id', $id)->paginate(20); $date = Carbon::createFromFormat('Y-m-d', $employee->start_date); $date = $date->addYear(); $date = $date->toDateString(); if($employee->vacations){ $vacationBalance = $this->calculateVacationBalance($date, $employee->vacations->where('accept', true)->sum("days")); }else{ $vacationBalance = $this->calculateVacationBalance($date, 0); } return view('admin.Vacation.show',compact('employee','vacations','vacationBalance')); } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $vac = Vacation::find($id); return view('admin.Vacation.edit',compact('vac')); } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request) { DB::beginTransaction(); try { $vac = Vacation::find(request('id')); $vac->accept = true; $vac->update(); if (request()->hasFile('files')) { $files = request()->file('files'); // Get the files $finalArray = []; foreach ($files as $file) { // Use foreach for simpler syntax $fileName = time() . '.' . $file->getClientOriginalExtension(); $file->storeAs('VACATION', $fileName, 'public'); // Store the file $filePath = 'VACATION/' . $fileName; // Generate the file path $finalArray[] = [ 'type' => 'vacation', 'procedure_id' => $vac->id, 'path' => $filePath, ]; } if (!empty($finalArray)) { File::insert($finalArray); // Insert the file references } } $log = new Log; $log->user_id = auth()->user()->id; $log->type = 7; $log->emp_id = $vac->emp_id; $log->title = " الموافقة علي الإجازة (".request('type').")"; $log->log = " تمت الموافقة علي الإجازة (".request('type').")"; $log->save(); DB::commit(); return redirect()->back()->with('success','تــمــت الــمـوافــقـة عـلـي إجــازة الــموظــف بــنــجــاح'); // all good } catch (\Exception $e) { DB::rollback(); return redirect()->back()->with('error', 'للاسف حدث خطأ ما الرجاء اعادة المحاولة'); } } public function destroy($id) { DB::beginTransaction(); try { $files = File::where('procedure_id', $id) ->where('type', 'vacation') ->update(['delete_at'=> now()]); $abs = Vacation::find($id); $abs->delete_at = now(); $abs->delete(); $log = new Log; $log->user_id = auth()->user()->id; $log->type = 11; $log->emp_id = $abs->emp_id; $log->title = " حذف بيانات إجــازة (".$abs->type.")"; $log->log = " تم حذف بيانات إجــازة (".$abs->type.")"; $log->save(); DB::commit(); return redirect()->back()->with('success','تـم حـذفـ إجــازة الـمـوظـف بـنـجـاح'); // all good } catch (\Exception $e) { DB::rollback(); return redirect()->back()->with('error', 'للاسف حدث خطأ ما الرجاء اعادة المحاولة'); } } }
- 17 اجابة
-
- 1
-
-
السلام عليكم اقوم بتحديث البيانات في جدول people وجدول employees لماذا لم يتم تحديث البيانات <?php include('header.php'); $employee_id = $_GET['id']; $sql = "SELECT people.*, employees.* FROM people INNER JOIN employees ON people.id = employees.person_id WHERE people.id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("i", $employee_id); $stmt->execute(); $result = $stmt->get_result(); $employee = $result->fetch_assoc(); ?> <head> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <style> .rak { width: 400px; height: 300px; font-size: 14px !important; } </style> </head> <div class="col-md-9 pan1"> <ol class="breadcrumb" style="background-color: #fff; padding: 8px; color: #000; font-size: 16px;"> <li><a href="student.php">الموظفين</a></li> <li class="active">تعديل بيانات الموظف</li> </ol> </div> <div class="row"> <div class="col-md-9 pan1"> <div class="panel" style="color: #000;"> <div class="panel-body" style="padding: 25px 40px;"> <form method="POST" enctype="multipart/form-data"> <input type="hidden" name="id" value="<?php echo $employee['id']; ?>"> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>اسم الموظف</label> <input name="name" type="text" class="form-control" value="<?php echo $employee['name']; ?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>الرقم الوطني</label> <input name="N_id" type="text" class="form-control" value="<?php echo $employee['N_id']; ?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>تاريخ الميلاد</label> <input name="birth_date" type="date" class="form-control" value="<?php echo $employee['birth_date']; ?>" required> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>البلد</label> <input name="country" type="text" class="form-control" value="<?php echo $employee['country']; ?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>المدينة</label> <input name="city" type="text" class="form-control" value="<?php echo $employee['city']; ?>" required> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>المنطقة</label> <input name="street_address" type="text" class="form-control" value="<?php echo $employee['street_address']; ?>" required> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>الجنس</label> <select name="gender" class="form-control" required> <option value="ذكر" <?php echo ($employee['gender'] == 'ذكر') ? 'selected' : ''; ?>>ذكر</option> <option value="انثي" <?php echo ($employee['gender'] == 'انثي') ? 'selected' : ''; ?>>انثي</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>الحالة الاجتماعية</label> <select name="marital_status" class="form-control" required> <option value="أعزب" <?php echo ($employee['marital_status'] == 'أعزب') ? 'selected' : ''; ?>>أعزب</option> <option value="متزوج" <?php echo ($employee['marital_status'] == 'متزوج') ? 'selected' : ''; ?>>متزوج</option> <option value="مطلق" <?php echo ($employee['marital_status'] == 'مطلق') ? 'selected' : ''; ?>>مطلق</option> <option value="ارمل" <?php echo ($employee['marital_status'] == 'ارمل') ? 'selected' : ''; ?>>ارمل</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>البريد الالكتروني</label> <input name="email" type="email" class="form-control" value="<?php echo $employee['email']; ?>"> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>رقم الهاتف</label> <input name="phone" type="text" class="form-control" value="<?php echo $employee['phone']; ?>"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>نوع التوظيف</label> <select name="type" class="form-control" required> <option value="تعيين" <?php echo ($employee['type'] == 'تعيين') ? 'selected' : ''; ?>>تعيين</option> <option value="عقد" <?php echo ($employee['type'] == 'عقد') ? 'selected' : ''; ?>>عقد</option> <option value="إعارة" <?php echo ($employee['type'] == 'إعارة') ? 'selected' : ''; ?>>إعارة</option> <option value="ندب" <?php echo ($employee['type'] == 'ندب') ? 'selected' : ''; ?>>ندب</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>الدرجة الوظيفية</label> <input name="degree" type="number" class="form-control" value="<?php echo $employee['degree']; ?>"> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>تاريخ الحصول علي الدرجة</label> <input name="degree_date" type="date" class="form-control" value="<?php echo $employee['degree_date']; ?>"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>حالة الموظف</label> <select name="status" class="form-control" required> <option value="يعمل" <?php echo ($employee['status'] == 'يعمل') ? 'selected' : ''; ?>>يعمل</option> <option value="مفصول" <?php echo ($employee['status'] == 'مفصول') ? 'selected' : ''; ?>>مفصول</option> <option value="مستقيل" <?php echo ($employee['status'] == 'مستقيل') ? 'selected' : ''; ?>>مستقيل</option> <option value="متقاعد" <?php echo ($employee['status'] == 'متقاعد') ? 'selected' : ''; ?>>متقاعد</option> <option value="موقوف" <?php echo ($employee['status'] == 'موقوف') ? 'selected' : ''; ?>>موقوف</option> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>تاريخ استحقاق الشهادة</label> <input name="due" type="date" class="form-control" value="<?php echo $employee['due']; ?>"> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>المؤهل في القرار</label> <input name="qualification" type="text" class="form-control" value="<?php echo $employee['qualification']; ?>" placeholder="ادخل اسم المؤهل"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>تاريخ المباشرة</label> <input name="start_date" type="date" class="form-control" value="<?php echo $employee['start_date']; ?>"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>رقم القرار</label> <input name="res_num" type="text" class="form-control" value="<?php echo $employee['res_num']; ?>" placeholder=""> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>الإدارة</label> <select name="section_id" id="section_id" class="form-control" onchange="loadSubSections(this.value)" required> <?php $sql_sections = "SELECT id, name FROM sub_sections WHERE parent_id IS NULL"; $result_sections = $con->query($sql_sections); while ($row = $result_sections->fetch_assoc()) { $selected = ($row['id'] == $employee['section_id']) ? 'selected' : ''; echo '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>'; } ?> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>القسم</label> <select name="sub_section_id" id="sub_section_id" class="form-control" required> <option value="">اختر قسم</option> <?php $sql_sub_sections = "SELECT id, name FROM sub_sections WHERE parent_id = ?"; $stmt_sub_sections = $con->prepare($sql_sub_sections); $stmt_sub_sections->bind_param("i", $employee['section_id']); $stmt_sub_sections->execute(); $result_sub_sections = $stmt_sub_sections->get_result(); while ($row = $result_sub_sections->fetch_assoc()) { $selected = ($row['id'] == $employee['sub_section_id']) ? 'selected' : ''; echo '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>'; } ?> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>التخصص</label> <select name="specialties_id" id="specialties_id" class="form-control" required> <?php // استعلام لجلب التخصصات $sql_specialties = "SELECT id, name FROM specialties"; $result_specialties = $con->query($sql_specialties); // عرض خيارات التخصصات while ($row = $result_specialties->fetch_assoc()) { $selected = ($row['id'] == $employee['specialty_id']) ? 'selected' : ''; echo '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>'; } ?> </select> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <label>اسم المصرف</label> <select name="bank_id" id="bank_id" class="form-control" required> <?php $sql_banks = "SELECT id, name FROM banks"; $result_banks = $con->query($sql_banks); while ($row = $result_banks->fetch_assoc()) { $selected = ($row['id'] == $employee['bank_id']) ? 'selected' : ''; echo '<option value="' . $row['id'] . '" ' . $selected . '>' . $row['name'] . '</option>'; } ?> </select> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>فرع المصرف</label> <input type="text" name="branch" class="form-control" value="<?php echo $employee['branch']; ?>"> </div> </div> <div class="col-md-4"> <div class="form-group"> <label>رقم الحساب</label> <input type="text" name="account_num" class="form-control" value="<?php echo $employee['account_num']; ?>"> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group"> <button name="submit" type="submit" class="btn btn-primary">تحديث <span class="ion-android-update"></span></button> <button type="reset" class="btn btn-danger">إلغاء <span class="ion-android-delete"></span></button> </div> </div> </div> </form> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $id = $_POST['id']; $name = $_POST['name']; $N_id = $_POST['N_id']; $birth_date = $_POST['birth_date']; $country = $_POST['country']; $city = $_POST['city']; $street_address = $_POST['street_address']; $gender = $_POST['gender']; $marital_status = $_POST['marital_status']; $email = $_POST['email']; $phone = $_POST['phone']; $type = $_POST['type']; $degree = $_POST['degree']; $degree_date = $_POST['degree_date']; $status = $_POST['status']; $due = $_POST['due']; $qualification = $_POST['qualification']; $start_date = $_POST['start_date']; $res_num = $_POST['res_num']; $section_id = $_POST['section_id']; $sub_section_id = $_POST['sub_section_id']; $specialties_id = $_POST['specialties_id']; $bank_id = $_POST['bank_id']; $branch = $_POST['branch']; $account_num = $_POST['account_num']; // تحديث بيانات الشخص $sql_update = "UPDATE people SET name = ?, N_id = ?, birth_date = ?, country = ?, city = ?, street_address = ?, gender = ?, marital_status = ?, email = ?, phone = ? WHERE id = ?"; $stmt_update = $con->prepare($sql_update); $stmt_update->bind_param("ssssssssssi", $name, $N_id, $birth_date, $country, $city, $street_address, $gender, $marital_status, $email, $phone, $id); if ($stmt_update->execute()) { // تحديث بيانات الموظف $sql_update_employee = "UPDATE employees SET person_id = ?, `type` = ?, degree = ?, degree_date = ?, status = ?, due = ?, qualification = ?, start_date = ?, res_num = ?, section_id = ?, sub_section_id = ?, specialty_id = ?, bank_id = ?, branch = ?, account_num = ? WHERE person_id = ?"; $stmt_update_employee = $con->prepare($sql_update_employee); // تأكد من أن لديك 16 متغيرًا هنا $stmt_update_employee->bind_param("ssssssssssssssss", $person_id, $type, $degree, $degree_date, $status, $due, $qualification, $start_date, $res_num, $section_id, $sub_section_id, $specialties_id, $bank_id, $branch, $account_num, $id); if ($stmt_update_employee->execute()) { echo "<script> Swal.fire({ title: 'رسالة تأكيد', text: 'تم تحديث بيانات الموظف بنجاح!', icon: 'success', customClass: 'rak', }); </script>"; echo '<meta http-equiv="refresh" content="2;url=people.php" />'; } else { echo "خطأ في تحديث بيانات الموظف: " . $stmt_update_employee->error; } } else { echo "خطأ في تحديث البيانات: " . $stmt_update->error; } } ?> </div> </div> </div> </div> <script> function loadSubSections(parentId) { var xhr = new XMLHttpRequest(); xhr.open("GET", "get_sub_sections.php?parent_id=" + parentId, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { document.getElementById("sub_section_id").innerHTML = xhr.responseText; } }; xhr.send(); } </script> <?php include('footer.php'); ?> قمت بحل مشكلة
- 1 جواب
-
- 1
-
-
هذا جدول قاعدة بيانات مثلا إدارة الموارد البشرية به 2 اقسام اريد عند ضغط علي تعديل يظهر الذي ضغط عليه تعديل في اسم القسم وليس الاخير ممكن تعديل كود تالي <?php include('header.php'); // Assuming you have the course ID passed via GET for the update $sections = $_GET['id']; // Fetch existing course data from the database $sql = "SELECT * FROM sub_sections where id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("i", $sections); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); ?> <!--------------------------------------------------------------------------------> <!------------------------------------header--------------------------------------> <!--------------------------------------------------------------------------------> <head> <!-- مكتبة SweetAlert2 --> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <style> .rak { width: 400px; height: 300px; font-size: 14px !important; } </style> </head> <div class="col-md-9 pan1"> <ol class="breadcrumb" style="background-color: #fff; padding-top: 8px; padding-bottom: 8px; color: #000; font-size: 16px;"> <li><a href="student.php">الاقسام</a></li> <li class="active">تعديل بيانات الاقسام تابعه للاداره</li> </ol> </div> <?php $q = "SELECT d.id as id, d.name AS d_name, s.name AS section_name FROM sub_sections s JOIN sub_sections d ON s.parent_id = d.id WHERE s.parent_id IS NOT NULL and d.id=".$sections; $row2=mysqli_query($con,$q); ?> <div class="row"> <div class="col-md-9 pan1"> <div class="panel" style="color: #000;"> <div class="panel-body" style="font-size: 14px; padding: 25px 40px;"> <form method="POST" enctype="multipart/form-data"> <div class="row"> <div class="col-md-4"> <div class="form-group" style="margin-top: 10px;"> <label>اختر الإدارة</label> <select name="department" class="form-control"> <?php // استعلام لجلب أسماء الإدارات من جدول sub_sections $sql = "SELECT d.id as id, d.name AS d_name, s.name AS section_name FROM sub_sections s JOIN sub_sections d ON s.parent_id = d.id WHERE s.parent_id IS NOT NULL and d.id=" .$sections; $result = $con->query($sql); while ($row2 = $result->fetch_assoc()) { echo "<option value='" . $row2['id'] . "'>" . $row2['d_name'] . "</option>"; if ($row2['id'] == $sections) { $section_name = $row2['section_name']; } $section_name = $row2['section_name']; } ?> </select> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group" style="margin-top: 10px;"> <label>اسم القسم </label> </div> <input name="name" type="text" class="form-control" value="<?php echo isset($section_name) ? $section_name : ''; ?>"> </div> <div></div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group" style="margin-top: 10px;"> <button name="submit" type="submit" class="btn btn-primary">تحديث <span class="ion-android-add"></span></button> <button type="reset" class="btn btn-danger">إلغاء <span class="ion-android-delete"></span></button> </div> </div> </div> </form> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = $_POST['department']; $section_name=$_POST['name']; $updated_at= date('Y-m-d H:i:s'); if (empty($name) ) { echo "<div class='alert alert-danger'>الرجاء إدخال كافة البيانات</div>"; exit(); } $sql = "UPDATE sub_sections SET name = ?, updated_at = ? WHERE parent_id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("ssi", $department,$name ,$updated_at, $sections); if ($stmt->execute()) { echo "<script> Swal.fire({ title: 'رسالة تأكيد', text: 'تم تحديث بيانات القسم تابع للادارة بنجاح!', icon: 'success', customClass: 'rak', }); </script>"; echo '<meta http-equiv="refresh" content="2;url=Sections.php" />'; } else { echo "خطأ في تحديث بيانات قسم تابع لادارة: " . $stmt->error; } } ?> </div> </div> </div> </div> <!--------------------------------------------------------------------------------> <!------------------------------------Footer--------------------------------------> <!--------------------------------------------------------------------------------> <?php include('footer.php'); ?>
-
السلام عليكم كل عام وانتم بخير لدي كود ادخال قسم تابع للادارة <?php include('header.php'); include("../config.php"); ?> <head> <!-- مكتبة SweetAlert2 --> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <style> .rak { width: 400px; height: 300px; font-size: 14px !important; } </style> </head> <div class="col-md-9 pan1"> <ol class="breadcrumb" style="background-color: #fff;padding-top:8px;padding-bottom:8px;color:#000;font-size:16px;"> <li>القسم التابع للإدارة </li> </ol> </div> <div class="row"> <div class="col-md-9 pan1"> <div class="panel" style="color:#000;"> <div class="panel-body" style="font-size:14px; padding-left:40px;padding-right:40px;padding-bottom:25px;padding-top:25px;"> <p style="margin-bottom: 20px;"> <a class="btn-add" href="add-sections.php"> إضافة قسم <span class="ion-android-add"></span></a> </p> <?php // عدد العناصر في الصفحة $post_at_page = 8; // تحقق من الصفحة الحالية if (!isset($_GET['page'])) { $page = 1; } else { $page = (int)$_GET['page']; } // استعلام لحساب عدد العناصر $q = "SELECT COUNT(*) AS count FROM sub_sections"; $result = mysqli_query($con, $q); $row = mysqli_fetch_assoc($result); $total_posts = $row['count']; $total_pages = ceil($total_posts / $post_at_page); // تحقق من رقم الصفحة if ($page > $total_pages || $page <= 0) { echo '<div class="alert alert-danger" role="alert">خطأ: لم يتم العثور على صفحة</div>'; echo '<meta http-equiv="refresh" content="2;url=Sections.php" />'; exit; } // حساب بداية الاستعلام $start = ($page - 1) * $post_at_page; // استعلام لاسترجاع العناصر للصفحة الحالية // $q = "SELECT * FROM sub_sections LIMIT $start, $post_at_page"; $q = "SELECT d.id as id, d.name AS d_name, s.name AS section_name FROM sub_sections s JOIN sub_sections d ON s.parent_id = d.id WHERE s.parent_id IS NOT NULL LIMIT $start, $post_at_page"; $result = mysqli_query($con, $q); echo '<div class="table-responsive"> <table class="table table-bordered table-hover"> <tr> <td> # </td> <td> اسم لادارة </td> <td> اسم القسم التابع للادارة</td> <td> تعديل </td> </tr>'; while ($rows = mysqli_fetch_array($result)) { echo ' <tr> <td>' . $rows['id'] . '</td> <td>' . $rows['d_name'] . '</td> <td>' . $rows['section_name'] . '</td> <td style="padding: 10px;"><a href="edit-Sections.php?id=' . $rows['id'] . '" class="btn btn-success"><span class="glyphicon glyphicon-pencil"></span> تعديل </a></td> </tr>'; } echo "</table>"; ?> <nav> <ul class="pager"> <?php if ($page > 1): ?> <li><a href="Sections.php?page=<?php echo ($page - 1); ?>" style="color:#000;">الصفحة السابقة</a></li> <?php endif; ?> <?php if ($page < $total_pages): ?> <li><a href="Sections.php?page=<?php echo ($page + 1); ?>" style="color:#000;">الصفحة التالية</a></li> <?php endif; ?> </ul> </nav> </div> </div> </div> </div> <script> function confirmDelete(bankId) { Swal.fire({ title: 'هل أنت متأكد من عملية الحذف؟', text: "لن تتمكن من استعادة هذه البيانات!", icon: 'warning', customClass: 'rak', showCancelButton: true, confirmButtonColor: '#3085d6', cancelButtonColor: '#d33', confirmButtonText: 'نعم, احذفها!', cancelButtonText: "الغاء", }).then((result) => { if (result.isConfirmed) { window.location.href = 'delete-banks.php?id=' + bankId; } }); } </script> <?php include('footer.php'); ?> لماذا في صفحة تعديل بيانات لايظهر اسم الادارة وقسم تابع لها في خانة مخصصة لها عند ضغط علي زر تعديل <?php include('header.php'); // Assuming you have the course ID passed via GET for the update $sections = $_GET['id']; // Fetch existing course data from the database $sql = "SELECT * FROM sub_sections WHERE id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("i", $sections); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); ?> <!--------------------------------------------------------------------------------> <!------------------------------------header--------------------------------------> <!--------------------------------------------------------------------------------> <head> <!-- مكتبة SweetAlert2 --> <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script> <style> .rak { width: 400px; height: 300px; font-size: 14px !important; } </style> </head> <div class="col-md-9 pan1"> <ol class="breadcrumb" style="background-color: #fff; padding-top: 8px; padding-bottom: 8px; color: #000; font-size: 16px;"> <li><a href="student.php">الاقسام</a></li> <li class="active">تعديل بيانات الاقسام تابعه للاداره</li> </ol> </div> <?php $q = "SELECT d.id as id, d.name AS d_name, s.name AS section_name FROM sub_sections s JOIN sub_sections d ON s.parent_id = d.id WHERE s.parent_id IS NOT NULL "; $row=mysqli_query($con,$q); ?> <div class="row"> <div class="col-md-9 pan1"> <div class="panel" style="color: #000;"> <div class="panel-body" style="font-size: 14px; padding: 25px 40px;"> <form method="POST" enctype="multipart/form-data"> <div class="row"> <div class="col-md-4"> <div class="form-group" style="margin-top: 10px;"> <label>اختر الإدارة</label> <select name="department" class="form-control"> <?php // استعلام لجلب أسماء الإدارات من جدول sub_sections $sql = "SELECT id, name FROM sub_sections where parent_id is null"; $result = $con->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<option value='" . $row2['id'] . "'>" . $row2['name'] . "</option>"; } } else { echo "<option value=''>لا توجد إدارات متاحة</option>"; } ?> </select> </div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group" style="margin-top: 10px;"> <label>اسم القسم </label> <input name="name" type="text" class="form-control" value="<?php echo $row['section_name']; ?>"> </div> <div></div> </div> </div> <div class="row"> <div class="col-md-4"> <div class="form-group" style="margin-top: 10px;"> <button name="submit" type="submit" class="btn btn-primary">تحديث <span class="ion-android-add"></span></button> <button type="reset" class="btn btn-danger">إلغاء <span class="ion-android-delete"></span></button> </div> </div> </div> </form> <?php if ($_SERVER["REQUEST_METHOD"] == "POST") { $name = $_POST['name']; $updated_at= date('Y-m-d H:i:s'); if (empty($name) ) { echo "<div class='alert alert-danger'>الرجاء إدخال كافة البيانات</div>"; exit(); } $sql = "UPDATE banks SET name = ?, updated_at = ? WHERE id = ?"; $stmt = $con->prepare($sql); $stmt->bind_param("ssi", $name, $updated_at, $sections); if ($stmt->execute()) { echo "<script> Swal.fire({ title: 'رسالة تأكيد', text: 'تم تحديث بيانات المصرف بنجاح!', icon: 'success', customClass: 'rak', }); </script>"; echo '<meta http-equiv="refresh" content="2;url=banks.php" />'; } else { echo "خطأ في تحديث بيانات المصرف: " . $stmt->error; } } ?> </div> </div> </div> </div> <!--------------------------------------------------------------------------------> <!------------------------------------Footer--------------------------------------> <!--------------------------------------------------------------------------------> <?php include('footer.php'); ?>
-
-
بالخط حدفت Pause Update sstartTime ماذا افعل
-
هل حتا default امسحه
-
-
- 9 اجابة
-
- 2
-
-
السلام عليكم كيف نفعل خيار line wrap في متصفح كروم مثل في صورة تم حل مشكلة وهيا الصفحة التي انا فيه اعمل ctrl+u
- 2 اجابة
-
- 2
-
-
-
جربت كل طرق ما نفعت لزالت تظهر
-
-
عملتها لزالت نفس المشكلة
-
قمت بإعادة التشغيل لزالت اللغة الانجليزية موجودة
- 8 اجابة
-
- 1
-
-
السلام عليكم لدي ويندوز 11 كل شي باللغةالعربية كم هو موضح في عرض نظام العربية ليبيا لماذا بعض خيارات لاتظهر بالعربي
- 8 اجابة
-
- 1
-
-
السلام عليكم لدي مشكلة انطفاء جهاز لاب توب عند عمل إعادة تشغيل جهاز بدون شاحن لكن في شاحن يعمل إعادة تشغيل للعلم بطارية شاحن جديدة
- 3 اجابة
-
- 1
-
-
اخ محمد عاطف حل مشكلة في مرة سابقة
-
لماذا عند الضغط علي زر حفظ تظهر مشكلة 419 Page Expired @extends('layouts.master') @section('title') الاقسام @stop @section('css') <style> .form-group { display: flex; flex-direction: column; align-items: center; margin-top: 20px; } #name { width: 50%; } </style> @stop @section('title_page1') الاقسام @stop @section('title_page2') اضافة قسم @stop @section('content') <form action="{{ route('Department.index') }}" method="post"> @csrf <div class="form-group"> <label for="name">اسم القسم</label> <input type="text" name="name" id="name" class="form-control"> </div> <div class="form-group"> <button type="submit" class="btn btn-primary">حفظ</button> </div> </form> @stop @section('scripts') @stop
- 3 اجابة
-
- 1
-