Silent 6 gadi atpakaļ
vecāks
revīzija
9f3bd0a693

+ 2 - 1
app/Http/Controllers/Admin/Student/CourseController.php

xqd
@@ -44,7 +44,8 @@ class CourseController extends Controller
         $list = $list->paginate();
 
         foreach($list as $item) {
-            $item->end_date = Carbon::createFromTimestamp(strtotime($item->apply_date))->addDays($item->duration)->toDateString();
+//            $item->end_date = Carbon::createFromTimestamp(strtotime($item->apply_date))->addDays($item->duration)->toDateString();
+            $item->end_date = $item->computeEndDate();
             $now = Carbon::now()->toDateString();
             if($now > $item->end_date) {
                 $item->remain_days = 0;

+ 1 - 1
app/Http/Controllers/Teacher/Student/CourseController.php

xqd
@@ -44,7 +44,7 @@ class CourseController extends Controller
         $list = $list->paginate();
 
         foreach($list as $item) {
-            $item->end_date = Carbon::createFromTimestamp(strtotime($item->apply_date))->addDays($item->duration)->toDateString();
+            $item->end_date = $item->computeEndDate();
             $now = Carbon::now()->toDateString();
             if($now > $item->end_date) {
                 $item->remain_days = 0;

+ 1 - 5
app/Models/Student.php

xqd
@@ -79,11 +79,7 @@ class Student extends Model
         }
 
         $apply_date = $student_course->apply_date;
-        if(empty($apply_date) || empty($student_course->duration)) {
-            $end_date = '';
-        } else {
-            $end_date = Carbon::createFromTimestamp(strtotime($apply_date))->addDays($student_course->duration)->toDateString();
-        }
+        $end_date = $student_course->computeEndDate();
         $teacher_names = $student_course->getTeacherFullNames();
         return [
             'course_name' => $course_name,

+ 14 - 0
app/Models/StudentCourse.php

xqd xqd
@@ -2,6 +2,7 @@
 
 namespace App\Models;
 
+use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Model;
 
 class StudentCourse extends Model
@@ -69,4 +70,17 @@ class StudentCourse extends Model
             ]);
         }
     }
+
+    public function computeEndDate()
+    {
+        $apply_date = $this['apply_date'];
+        if(empty($apply_date) || empty($this['duration'])) {
+            return '';
+        } else {
+            $days = $this['duration'];
+            $leave_days = (int)Leave::where('student_id', $this['id'])->get()->count('days');
+            $days += $leave_days;
+            return Carbon::createFromTimestamp(strtotime($apply_date))->addDays($days)->toDateString();
+        }
+    }
 }

+ 2 - 2
wechat/pages/form/index.wxml

xqd
@@ -1,7 +1,7 @@
 <!--pages/form/index.wxml-->
 <view class='form-contaienr'>
-  <form bindsubmit="formSubmit">
-    <image wx:if="{{ data.top_image }}" src='{{ data.top_image }}' class='top-image'></image>
+  <form bindsubmit="formSubmit" id='sg-form'>
+    <image wx:if="{{ data.top_image }}" src='{{ data.top_image }}' class='top-image' mode='widthFix'></image>
     <view class='top-desp' wx:if="{{ data.top_desp }}">{{ data.top_desp }}</view>
     <view class='{{ formContainerClass }}'>
       <view class='form-body'>

+ 1 - 1
wechat/pages/form/index.wxss

xqd
@@ -2,7 +2,7 @@
 .form-contaienr {
   margin-bottom: 15px;
 }
-.top-image {
+#sg-form image {
   width: 100%;
 }
 .top-desp {