Exemplo n.º 1
0
 public static function get_user_detail($user_id, $value)
 {
     $count_member_detail = Userdetail::where('id', '=', $user_id)->count();
     if ($count_member_detail > 0) {
         $user_detail = Userdetail::where('id', '=', $user_id)->first();
         if ($value == "grade") {
             $grade = $user_detail->grade;
             if ($grade == 0) {
                 $return_data = "N";
             } else {
                 if ($grade == 1) {
                     $return_data = "D";
                 } else {
                     if ($grade == 2) {
                         $return_data = "C";
                     } else {
                         if ($grade == 3) {
                             $return_data = "B";
                         } else {
                             if ($grade == 4) {
                                 $return_data = "A";
                             } else {
                                 $return_data = "N";
                             }
                         }
                     }
                 }
             }
         } else {
             if ($value == "sortgrade") {
                 $return_data = $user_detail->grade;
             } else {
                 $return_data = $user_detail->{$value};
             }
         }
     } else {
         $return_data = "N";
     }
     return $return_data;
 }
Exemplo n.º 2
0
 public static function update_user_form($user_id, $value_name)
 {
     if ($value_name == "permission" || $value_name == "validate" || $value_name == "status_mail") {
         $user = Member::where("id", "=", $user_id)->first();
         if ($value_name == "status_mail") {
             $return_value = $user->validate;
         } else {
             $return_value = $user->{$value_name};
         }
         if ($value_name == "permission") {
             $data_permissions = ["1" => "User - ผู้ใช้ทั่วไป", "2" => "Staff - พนักงาน", "3" => "Admin - ผู้ดูแลระบบ"];
             $return_data = "<select name='permission' id='permission' class='form-control'>";
             foreach ($data_permissions as $permission => $permission_value) {
                 $return_data .= "<option value='" . $permission . "'";
                 if ($return_value == $permission) {
                     $return_data .= " selected='selected'";
                 }
                 $return_data .= ">" . $permission_value . "</option>";
             }
             $return_data .= "</select>";
         } else {
             if ($value_name == "validate") {
                 $oldvalidate = $return_value;
                 $validate_id_status = substr($oldvalidate, 3, 1);
                 if ($validate_id_status == 1) {
                     $return_data = "checked";
                 } else {
                     $return_data = "";
                 }
             } else {
                 if ($value_name == "status_mail") {
                     $oldvalidate = $return_value;
                     $validate_id_status = substr($oldvalidate, 1, 1);
                     if ($validate_id_status == 1) {
                         $return_data = "checked";
                     } else {
                         $return_data = "";
                     }
                 }
             }
         }
     } else {
         if ($value_name == "grade" || $value_name == "training_status" || $value_name == "training_date" || $value_name == "remark") {
             $count_userdetail = Userdetail::where("id", "=", $user_id)->count();
             //===================================================================================
             if ($value_name == "grade") {
                 $data_grade = ["0" => "none", "4" => "A", "3" => "B", "2" => "C", "1" => "D"];
                 $return_data = "<select name='grade' id='grade' class='form-control'>";
                 foreach ($data_grade as $grade => $grade_value) {
                     $return_data .= "<option value='" . $grade . "'";
                     if ($count_userdetail > 0) {
                         $userdetail = Userdetail::where("id", "=", $user_id)->first();
                         if ($userdetail->grade == $grade) {
                             $return_data .= " selected='selected'";
                         }
                     }
                     $return_data .= ">" . $grade_value . "</option>";
                 }
                 $return_data .= "</select>";
             } else {
                 if ($count_userdetail > 0) {
                     $userdetail = Userdetail::where("id", "=", $user_id)->first();
                     $userdetail_value = $userdetail->{$value_name};
                     if ($value_name == "training_status") {
                         if ($userdetail_value == 1) {
                             $return_data = "checked";
                         } else {
                             $return_data = "";
                         }
                     } else {
                         if ($value_name == "training_date" && !empty($userdetail_value)) {
                             $split_training_date = explode("-", $userdetail_value);
                             $return_data = $split_training_date[2] . "/" . $split_training_date[1] . "/" . $split_training_date[0];
                         } else {
                             $return_data = $userdetail_value;
                         }
                     }
                 } else {
                     $return_data = "";
                 }
             }
         }
     }
     //===================================================================================
     echo $return_data;
 }
Exemplo n.º 3
0
 public static function getedituser($id, $value)
 {
     $profiles = Member::where('id', '=', $id)->get();
     foreach ($profiles as $record) {
         $vdata = $record->{$value};
     }
     if ($value == 'education') {
         $education = education::orderBy('id')->get();
         echo "<select name='education' id='education' class='form-control'>";
         foreach ($education as $recode) {
             echo "<option value='" . $recode->id . "'";
             if ($vdata == $recode->id) {
                 echo " selected='selected'";
             }
             echo ">" . $recode->name . "</option>";
         }
         echo "</select>";
     } else {
         if ($value == 'bank') {
             $bank = bank::orderBy('name')->get();
             if (empty($vdata) || $vdata == 0) {
                 $vdata = 3;
             }
             echo "<select name='bank' id='bank' class='form-control'>";
             foreach ($bank as $recode) {
                 echo "<option value='" . $recode->id . "'";
                 if ($vdata == $recode->id) {
                     echo " selected='selected'";
                 }
                 echo ">" . $recode->name . "</option>";
             }
             echo "</select>";
         } else {
             if ($value == 'birthday') {
                 $split_birthday = explode("-", $vdata);
                 $vdata = $split_birthday[2] . "/" . $split_birthday[1] . "/" . $split_birthday[0];
                 echo $vdata;
             } else {
                 if ($value == 'shirts') {
                     $shirts = Userdetail::where('id', '=', $id)->first();
                     if (count($shirts) > 0) {
                         $shirts = $shirts->shirts;
                     } else {
                         $shirts = "";
                     }
                     $size = ["1" => "MS", "2" => "MM", "3" => "ML", "4" => "WS", "5" => "WM", "6" => "WL"];
                     echo '<select class="form-control" id="shirts" name="shirts">';
                     foreach ($size as $recode) {
                         echo "<option value='" . $recode . "'";
                         if ($shirts == $recode) {
                             echo " selected='selected'";
                         }
                         echo ">" . $recode . "</option>";
                     }
                     echo '</select>';
                 } else {
                     echo $vdata;
                 }
             }
         }
     }
 }