Beispiel #1
0
 /**
  * Validate user update
  * 
  * @param int $id
  * @return \Redirect
  */
 public function postEdit($id = false)
 {
     if (!$id) {
         return App::abort(404);
     }
     $item = User::find($id);
     if (!$item) {
         return App::abort(404);
     }
     $fields = ["lastname" => Input::get("lastname"), "firstname" => Input::get("firstname"), "passport_serial" => Input::get("passport_serial"), "passport_number" => Input::get("passport_number"), "login" => Input::get("login"), "email" => Input::get("email")];
     $rules = ["lastname" => "required|max:250", "firstname" => "required|max:500", "passport_serial" => "numeric", "passport_number" => "numeric", "email" => "email|unique:users,email," . $id, "login" => "alpha_num|unique:users,login," . $id];
     $customMessages = ["lastname.required" => "Поле \"Фамилия\" обязательно для заполнения", "firstname.required" => "Поле \"Имя\" обязательно для заполнения", "passport_serial.numeric" => "Серия паспорта может содержать только цифры", "passport_number.numeric" => "Номер паспорта может содержать только цифры", "email.email" => "Поле \"E-mail\" должно содержать правильный адрес электронной почты", "email.unique" => "Указанный вами email уже есть у другого сотрудника", "login.alpha_num" => "Логин может содержать только буквы, цифры, дефис, символ подчеркивания", "login.unique" => "Указанный вами логин уже есть у другого сотрудника"];
     $validator = Validator::make($fields, $rules, $customMessages);
     if ($validator->fails()) {
         $error = "";
         foreach (array_keys($fields) as $k) {
             $message = $validator->messages()->first($k);
             if ($message) {
                 $error .= "<div>" . $message . "</div>";
             }
         }
         return Redirect::to($_SERVER["HTTP_REFERER"])->with("error", $error)->withInput();
     }
     $item->login = Input::get("login", NULL) ? Input::get("login") : NULL;
     $item->email = Input::get("email", NULL) ? Input::get("email") : NULL;
     $item->password = Input::get("password", NULL) ? Hash::make(Input::get("password")) : $item->password;
     $item->position_id = Input::get("position", NULL) ? Input::get("position") : NULL;
     $item->firstname = Input::get("firstname");
     $item->lastname = Input::get("lastname");
     $item->patronymincname = Input::get("patronymincname");
     $item->birthday = Input::get("day") && Input::get("month") && Input::get("year") ? Input::get("year") . "-" . Input::get("month") . "-" . Input::get("day") : NULL;
     $item->birthplace = Input::get("birthplace");
     $item->address_legal = Input::get("address_legal");
     $item->address_living = Input::get("address_living");
     $item->passport_serial = Input::get("passport_serial");
     $item->passport_number = Input::get("passport_number");
     $item->passport_issuer = Input::get("passport_issuer");
     $item->passport_date = Mydate::convertDate(Input::get("passport_date"));
     $item->gender = Input::get("gender", NULL) ? Input::get("gender") : NULL;
     $item->phone_mobile = Input::get("phone_mobile");
     $item->phone_home = Input::get("phone_home");
     $item->inn_number = Input::get("inn");
     $item->snils_number = Input::get("snils_number");
     $item->comment = Input::get("comment");
     //$item->is_active = Input::get("is_active") ? 1 : 0;
     $item->is_hired = Input::get("is_hired") ? 1 : 0;
     $item->save();
     return Redirect::to("/users")->with("message", "Пользователь обновлен.");
 }
Beispiel #2
0
		<label for="birthday" class="col-lg-2 control-label">Дата рождения</label>
		<div class="col-lg-10">
			<select name="day" class="form-control" style="width:70px;float:left;">
				<?for($i = 1; $i <= 31; $i++):?>
				<?$d = $i < 10 ? '0'.$i : $i;?>
				<option value="<?php 
echo $d;
?>
"<?if($item->birthday && date("d",strtotime($item->birthday)) == $d):?> selected<?endif;?>><?php 
echo $d;
?>
</option>
				<?endfor;?>
			</select>
			<select name="month" class="form-control" style="width:150px;float:left;margin-left:20px;">
				<?foreach(Mydate::monthsArray() as $mid => $mname):?>
				<option value="<?php 
echo $mid;
?>
"<?if($item->birthday && date("m",strtotime($item->birthday)) == $mid):?> selected<?endif;?>><?php 
echo $mname;
?>
</option>
				<?endforeach;?>
			</select>
			<select name="year" class="form-control" style="width:100px;float:left;margin-left:20px;">
				<?foreach(array_reverse(range(date("Y") - 100, date("Y") - 14)) as $year):?>
				<option value="<?php 
echo $year;
?>
"<?if($item->birthday && date("Y",strtotime($item->birthday)) == $year):?> selected<?endif;?>><?php 
Beispiel #3
0
 private function makeDeadlineDate()
 {
     if (!Input::get("deadline_at", NULL)) {
         return;
     }
     $date = Mydate::convertDate(Input::get("deadline_at"));
     if ($date) {
         return $date . " " . Input::get("hours") . ":" . Input::get("minutes") . ":00";
     }
 }
Beispiel #4
0
 public static function eventsListLabel($date)
 {
     $time = strtotime($date);
     if ($date == date("Y-m-d")) {
         $str = "Сегодня, " . date("j") . " " . Mydate::month($time) . " " . Mydate::weekday($time);
     } elseif ($date == date("Y-m-d", strtotime("+1 day"))) {
         $str = "Завтра, " . date("j", $time) . " " . Mydate::month($time) . " " . Mydate::weekday($time);
     } else {
         $str = Mydate::weekday($time) . ", " . date("j", $time) . " " . Mydate::month($time);
     }
     return $str;
 }