Beispiel #1
0
 public static function get_all_member($user_not_include, $event_id)
 {
     $query_data = [];
     $array_data = [];
     foreach ($user_not_include as $data => $value) {
         $query_data[] = [$value];
     }
     $user_detail = Member::whereNotIn('id', $query_data)->get();
     foreach ($user_detail as $data) {
         $user_id = $data->id;
         $event_date = AS_Requestjob::get_event_date($event_id);
         $userstatus = Check_busy::main($user_id, $event_date);
         $usernameall = $data->nickname . " - " . $data->name . " " . $data->surname;
         $usergrade = AS_Member::get_user_detail($user_id, 'grade');
         $sortgrade = AS_Member::get_user_detail($user_id, 'sortgrade');
         $assign_id = "";
         $category = "all_user";
         $array_data[] = ["user_id" => $user_id, "usernameall" => $usernameall, "usergrade" => $usergrade, "sortgrade" => $sortgrade, "userstatus" => $userstatus, "assign_id" => $assign_id, "category" => $category];
     }
     usort($array_data, function ($a, $b) {
         return $b["sortgrade"] - $a["sortgrade"];
     });
     return $array_data;
 }
Beispiel #2
0
 public static function Get_assign_user($event_id)
 {
     $array_data = [];
     $count_result = Assignment::where('event_id', '=', $event_id)->count();
     if ($count_result > 0) {
         $user_list = Assignment::where('event_id', '=', $event_id)->get();
         foreach ($user_list as $data) {
             $user_id = $data->user_id;
             $event_date = AS_Requestjob::get_event_date($event_id);
             $userstatus = Check_busy::main($user_id, $event_date);
             $usernameall = AS_Member::get_user_data($user_id, 'fullname');
             $usergrade = AS_Member::get_user_detail($user_id, 'grade');
             $sortgrade = AS_Member::get_user_detail($user_id, 'sortgrade');
             $assign_id = $data->id;
             $category = "assignment_user";
             $array_data[] = ["user_id" => $user_id, "usernameall" => $usernameall, "usergrade" => $usergrade, "sortgrade" => $sortgrade, "userstatus" => $userstatus, "assign_id" => $assign_id, "category" => $category];
             //array_push($array_data,$data->user_id);
         }
         usort($array_data, function ($a, $b) {
             return $b["sortgrade"] - $a["sortgrade"];
         });
         return $array_data;
     } else {
         //return "ไม่มีผู้สมัครทำงานนี้";
     }
 }
Beispiel #3
0
 public static function main($method, $value)
 {
     if ($method == "Get_request_event") {
         $Udata = AS_Requestjob::get_request_event($value);
         $return_html = Assign::generate_html($Udata, "");
         echo $return_html;
     } else {
         if ($method == "Get_request_date") {
             $Udata = AS_Requestjob::get_request_day($value);
             $return_html = Assign::generate_html($Udata, "");
             echo $return_html;
         } else {
             if ($method == "Get_all_user") {
                 $Udata = AS_Requestjob::get_all_user($value);
                 $return_html = Assign::generate_html($Udata, "");
                 echo $return_html;
             } else {
                 if ($method == "Get_assign_user") {
                     $Udata = AS_Requestjob::Get_assign_user($value);
                     $return_html = Assign::generate_html($Udata, "assignment_user");
                     echo $return_html;
                 } else {
                     if ($method == "remove_from_assign") {
                         $remove_type = $value["type"];
                         $event_id = $value["event_id"];
                         $user_id = $value["user_id"];
                         $not_include = $value["not_include"];
                         $include = $value["include"];
                         if ($remove_type == "assignment_user") {
                             if (!empty($user_id)) {
                                 $Moveto = AS_Requestjob::find_user_request_type($event_id, $user_id);
                                 if ($Moveto == "request_event_user") {
                                     $Udata = AS_Requestjob::get_request_event($event_id);
                                 } else {
                                     if ($Moveto == "request_job_user") {
                                         $Udata = AS_Requestjob::get_request_day($event_id);
                                     } else {
                                         $Udata = AS_Requestjob::get_all_user($event_id);
                                     }
                                 }
                                 $event = event::where("id", "=", $event_id)->first();
                                 $event_date = $event->event_date;
                                 $usernameall = AS_Member::get_user_data($user_id, 'fullname');
                                 $usergrade = AS_Member::get_user_detail($user_id, 'grade');
                                 $sortgrade = AS_Member::get_user_detail($user_id, 'sortgrade');
                                 $userstatus = Check_busy::main($user_id, $event_date);
                                 $assign_id = "";
                                 $category = "assignment_user";
                                 $Udata[] = ["user_id" => $user_id, "usernameall" => $usernameall, "usergrade" => $usergrade, "sortgrade" => $sortgrade, "userstatus" => $userstatus, "assign_id" => $assign_id, "category" => $category];
                             }
                         } else {
                             if ($remove_type == "request_event_user") {
                                 $Udata = AS_Requestjob::get_request_event($event_id);
                                 $Moveto = "request_event_user";
                             } else {
                                 if ($remove_type == "request_job_user") {
                                     $Udata = AS_Requestjob::get_request_day($event_id);
                                     $Moveto = "request_job_user";
                                 } else {
                                     $Udata = AS_Requestjob::get_all_user($event_id);
                                     $Moveto = "all_user";
                                 }
                             }
                         }
                         if (!empty($not_include)) {
                             for ($i = 0; $i < count($not_include); $i++) {
                                 foreach ($Udata as $key => $value) {
                                     if ($value["user_id"] == $not_include[$i]) {
                                         unset($Udata[$key]);
                                     }
                                 }
                             }
                         }
                         usort($Udata, function ($a, $b) {
                             return $b["sortgrade"] - $a["sortgrade"];
                         });
                         $return_html = Assign::generate_html($Udata, "");
                         $arr = array("code_return" => $return_html, "moveto" => $Moveto);
                         echo json_encode($arr);
                     }
                 }
             }
         }
     }
 }