public function insert() { //echo "in insert controller"; include 'model/doctor.php'; $doctor = new Doctor($_POST["username"], $_POST["password"], $_POST["name"], $_POST["age"], $_POST["hospital"], $_POST["qualification"]); $doctor->save(); header('location: view/doctor/registered.php'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Doctor(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Doctor'])) { $model->attributes = $_POST['Doctor']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionCreate() { $model = new Doctor(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Doctor'])) { if (empty($_POST['Doctor']['id'])) { unset($_POST['Doctor']['id']); } $model->attributes = $_POST['Doctor']; if ($model->save()) { Yii::app()->user->setFlash('success', '儲存成功.'); $this->redirect(array('update', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Display a listing of the resource. * GET /accounts * * @return Response */ public function doctorsAccountCreate() { if (Auth::user()->access_level == '1') { // Build the validation constraint set. $rules = array('field_email' => 'required|email', 'field_password' => 'required|min:3|confirmed', 'field_password' => 'required|min:3', 'field_name' => 'required', 'field_dob' => 'required', 'field_gender' => 'required', 'field_specialty' => 'required', 'field_workingHours' => 'required', 'availabilty' => 'required'); $data = Input::all(); // Create a new validator instance. $validator = Validator::make($data, $rules); if ($validator->passes()) { $user = new User(); $user->email = Input::get('field_email'); $user->password = Hash::make(Input::get('field_password')); $user->access_level = '2'; if ($user->save()) { $doctor = new Doctor(); $doctor->name = Input::get('field_name'); $doctor->dob = Input::get('field_dob'); $doctor->gender = Input::get('field_gender'); $doctor->specialty = Input::get('field_specialty'); $doctor->working_hourse = Input::get('field_workingHours'); $doctor->unavailability = Input::get('availabilty'); $doctor->user_id = $user->id; if ($doctor->save()) { return Redirect::route('user.registration_form', array('whose' => 'doctors_form'))->with('success', 'Registration Successful'); } else { return Redirect::route('user.registration_form', array('whose' => 'doctors_form'))->withErrors($doctor); } } else { return Redirect::route('user.registration_form', array('whose' => 'doctors_form'))->withErrors($user); } } return Redirect::route('user.registration_form', array('whose' => 'doctors_form'))->withErrors($validator); } else { return 'You dont have access to this level'; } }
public function excelAction($path) { //phalcon向数据库导入的时候有点小问题,有default值的列需要赋值,不然这列的default值不会写入数据库 include '../app/classes/PHPExcel.php'; $this->view->disable(); $obj = new PHPExcel(); $name = '/home/sify/' . $path; $type = PHPExcel_IOFactory::identify($name); $reader = PHPExcel_IOFactory::createReader($type); $obj = $reader->load($name); //导入hospital子表 $sheet = $obj->getSheetByName('hospital'); for ($j = 2; $j <= $sheet->getHighestRow(); $j++) { $hospital = new Hospital(); $hospital->id = $sheet->getCell('A' . $j)->getValue(); $hospital->name = (string) $sheet->getCell('B' . $j)->getValue(); $hospital->intro = (string) $sheet->getCell('C' . $j)->getValue(); $hospital->cityid = $sheet->getCell('D' . $j)->getValue(); $hospital->street = (string) $sheet->getCell('E' . $j)->getValue(); $hospital->tele = (string) $sheet->getCell('F' . $j)->getValue(); $hospital->level = (string) $sheet->getCell('G' . $j)->getValue(); $hospital->notice = (string) $sheet->getCell('H' . $j)->getValue(); $hospital->img = '/img/hospital/default.img'; $hospital->save(); } //导入department子表 $sheet = $obj->getSheetByName('department'); for ($j = 2; $j <= $sheet->getHighestRow(); $j++) { $department = new Department(); $department->id = $sheet->getCell('A' . $j)->getValue(); $department->h_id = $sheet->getCell('B' . $j)->getValue(); $department->type = (string) $sheet->getCell('C' . $j)->getValue(); $department->intro = (string) $sheet->getCell('D' . $j)->getValue(); $department->name = (string) $sheet->getCell('E' . $j)->getValue(); $department->dcount = 0; $department->save(); } //导入doctor子表 $sheet = $obj->getSheetByName('doctor'); for ($j = 2; $j <= $sheet->getHighestRow(); $j++) { $doctor = new Doctor(); $doctor->id = $sheet->getCell('A' . $j)->getValue(); $doctor->name = (string) $sheet->getCell('B' . $j)->getValue(); $doctor->de_id = $sheet->getCell('C' . $j)->getValue(); $doctor->post = (string) $sheet->getCell('D' . $j)->getValue(); $doctor->intro = (string) $sheet->getCell('E' . $j)->getValue(); $doctor->specialty = (string) $sheet->getCell('F' . $j)->getValue(); $doctor->fee = $sheet->getCell('G' . $j)->getValue(); $doctor->img = '/img/doctor/default.img'; $doctor->save(); } //导入available子表 $sheet = $obj->getSheetByName('available'); for ($j = 2; $j <= $sheet->getHighestRow(); $j++) { $available = new Available(); $available->id = $sheet->getCell('A' . $j)->getValue(); $available->do_id = $sheet->getCell('B' . $j)->getValue(); $available->date = $sheet->getCell('C' . $j)->getFormattedValue(); $available->time = $sheet->getCell('D' . $j)->getValue(); $available->save(); } echo '数据导入成功!'; }
public function store() { $data = array("first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email"), "username" => Input::get("username"), "phone" => Input::get("phone"), "picture" => Input::file("picture"), "password" => Input::get("password"), "password_confirmation" => Input::get("password_confirmation")); $rules = array("first_name" => 'required|min:1|max:255', "last_name" => 'required|min:1|max:100', "email" => 'required|email|unique:users', "username" => 'required|min:5|unique:users', "phone" => 'required|min:1|max:100', "picture" => 'mimes:jpeg,gif,png', 'password' => 'confirmed|min:6'); $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :max carácteres.', 'numeric' => 'El campo :attribute debe contener solo numeros', 'mimes' => 'El formato de la imagen logo debe ser jpg, git, png', 'unique' => 'El :attribute ingresado ya esta siendo usaddo por otro usuario.', 'confirmed' => 'La confirmación del :attribute no coincide'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores //y con los campos que nos habia llenado el usuario if ($validation->fails()) { return Redirect::to('/clinic/doctors/create')->withErrors($validation)->withInput(); } else { $user = new User(); $user->first_name = Input::get("first_name"); $user->last_name = Input::get("last_name"); $user->email = Input::get("email"); $user->username = Input::get("username"); $user->password = Input::get("password"); $user->save(); $doctorUser = Sentry::getUserProvider()->findByLogin($user->email); $doctorsyGroup = Sentry::getGroupProvider()->findByName('Doctors'); $doctorUser->addGroup($doctorsyGroup); $doctor = new Doctor(); $doctor->user_id = $user->id; $doctor->clinic_id = Clinic::getClinicId(); $doctor->specialty_id = Input::get("specialty_id"); if (Input::file('picture') != NULL) { //agrega imagen de logo $file_logo = Input::file('picture'); $ext = Input::file('picture')->getClientOriginalExtension(); $nameIMG = date('YmdHis'); $logo = $nameIMG . '.' . $ext; $logo = 'assets/doctor/images/profile_pic/profile_' . $logo; $file_logo->move("assets/doctor/images/profile_pic/", $logo); $doctor->picture = $logo; } $doctor->save(); $clinic = Clinic::find(Clinic::getClinicId()); $address_id = $clinic->address_id; $agenda = new Agenda(); $agenda->doctor_id = $doctor->id; $agenda->name = "Agenda " . Input::get("first_name") . ' ' . Input::get("last_name"); $agenda->description = 'Nuevo'; $agenda->save(); $busines = new Business(); $busines->doctor_id = $doctor->id; $busines->agenda_id = $agenda->id; $busines->addresses_id = $address_id; $busines->name = 'Local # '; $busines->save(); if (!$logo) { $logo = ""; } $profile = new Profile(); $profile->user_id = $user->id; $profile->lang = Input::get("lang"); $profile->phone = Input::get("phone"); $profile->picture = $logo; $profile->save(); if ($profile) { return Redirect::to('/clinic/doctors/')->withFlash_message("Guardado Exitosamente"); } else { return Redirect::to('/clinic/doctors/create')->withErrors("Error")->withInput(); } } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('users')->truncate(); DB::table('patients')->truncate(); DB::table('doctors')->truncate(); DB::table('clinics')->truncate(); Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'diego10', 'first_name' => 'Diego', 'last_name' => 'Serras', 'activated' => 1)); $c1 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'jose10', 'first_name' => 'Jose', 'last_name' => 'Gonzalez', 'activated' => 1)); $c1_ = new Clinic(); $c1_->user_id = $c1->id; $c1_->name = "Clinica Medica Raul Ortega"; $c1_->save(); $c2 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'alber10', 'first_name' => 'Alberto', 'last_name' => 'Perdomo', 'activated' => 1)); $c2_ = new Clinic(); $c2_->user_id = $c2->id; $c2_->name = "Clinica Medica Jose Pineda"; $c2_->save(); $d1 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'martha10', 'first_name' => 'Martha', 'last_name' => 'Mendoza', 'activated' => 1)); $d1_ = new Doctor(); $d1_->user_id = $d1->id; $d1_->clinic_id = $c2_->id; $d1_->save(); $d2 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'jairo10', 'first_name' => 'Jairo', 'last_name' => 'Flores', 'activated' => 1)); $d2_ = new Doctor(); $d2_->user_id = $d2->id; $d2_->clinic_id = $c2_->id; $d2_->save(); $d3 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'gabriela10', 'first_name' => 'Gabriela', 'last_name' => 'del Cid', 'activated' => 1)); $d3_ = new Doctor(); $d3_->user_id = $d3->id; $d3_->clinic_id = $c2_->id; $d3_->save(); $d4 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'keiry10', 'first_name' => 'Keiry', 'last_name' => 'Rivas', 'activated' => 1)); $d4_ = new Doctor(); $d4_->user_id = $d4->id; $d4_->save(); $d5 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'mabel10', 'first_name' => 'Mabel', 'last_name' => 'Mendoza', 'activated' => 1)); $d5_ = new Doctor(); $d5_->user_id = $d5->id; $d5_->save(); $p1 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'John10', 'first_name' => 'Jonh', 'last_name' => 'Smith', 'activated' => 1)); $p1_ = new Patient(); $p1_->user_id = $p1->id; $p1_->save(); $p2 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Orlando10', 'first_name' => 'Orlando', 'last_name' => 'Arias', 'activated' => 1)); $p2_ = new Patient(); $p2_->user_id = $p2->id; $p2_->main = $p1_->id; $p2_->relationship = 'son'; $p2_->save(); $p3 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Alejandra10', 'first_name' => 'Alejandra', 'last_name' => 'Cerna', 'activated' => 1)); $p3_ = new Patient(); $p3_->user_id = $p3->id; $p3_->main = $p1_->id; $p3_->relationship = 'daughter'; $p3_->save(); $p4 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Maria10', 'first_name' => 'Maria', 'last_name' => 'Polio', 'activated' => 1)); $p4_ = new Patient(); $p4_->user_id = $p4->id; $p3_->main = $p1_->id; $p3_->relationship = 'wife'; $p4_->save(); $p5 = Sentry::getUserProvider()->create(array('email' => '*****@*****.**', 'password' => '123', 'username' => 'Rodrigo10', 'first_name' => 'Rodrigo', 'last_name' => 'Jandres', 'activated' => 1)); $p5_ = new Patient(); $p5_->user_id = $p5->id; $p5_->save(); }
public function actionAddDoctor() { $this->authenUser(); $this->authenManagement(); $formAddDoctor = new formAddDoctor(); $addDoctor = new Doctor(); $systemCities = SystemCity::model()->findAll(); $systemCitiesData = $this->generateSystemCities($systemCities); if (isset($_POST['formAddDoctor'])) { $addDoctor->attributes = $_POST['formAddDoctor']; $addDoctor->regDate(); print_r($_POST['formAddDoctor']); $addDoctor->save(); if ($addDoctor->did != NULL) { $doctorAddress = $_POST['formAddDoctor']['address']; $doctorCity = $_POST['formAddDoctor']['city']; if ($doctorAddress != '' || $doctorCity != '') { $addDoctorAddress = new DoctortAddress(); $addDoctorAddress->doctor_did = $addDoctor->did; if ($doctorAddress != '') { $addDoctorAddress->address = $doctorAddress; } if ($doctorCity != '') { $addDoctorAddress->system_city_id = $doctorCity; } $addDoctorAddress->save(); } } Yii::app()->end(); } $formAddDoctor->generatePassword(); $this->render('addDoctor', array('formAddDoctor' => $formAddDoctor, 'systemCitiesData' => $systemCitiesData)); }
public function save() { $nombre = Input::get('nombre'); $titulo = Input::get('titulo'); $campo_1 = Input::get('campo_1'); $campo_2 = Input::get('campo_2'); $campo_3 = Input::get('campo_3'); $campo_4 = Input::get('campo_4'); $campo_5 = Input::get('campo_5'); $campo_6 = Input::get('campo_6'); $campo_7 = Input::get('campo_7'); $campo_8 = Input::get('campo_8'); $campo_9 = Input::get('campo_9'); $campo_10 = Input::get('campo_10'); $campo_11 = Input::get('campo_11'); $campo_12 = Input::get('campo_12'); $doctor = new Doctor(); $doctor->nombre = $nombre; $doctor->titulo = $titulo; //Curriculum $doctor->campo_1 = $campo_1; $doctor->campo_2 = $campo_2; $doctor->campo_3 = $campo_3; $doctor->campo_4 = $campo_4; $doctor->campo_5 = $campo_5; $doctor->campo_6 = $campo_6; $doctor->campo_7 = $campo_7; $doctor->campo_8 = $campo_8; $doctor->campo_9 = $campo_9; $doctor->campo_10 = $campo_10; $doctor->campo_11 = $campo_11; $doctor->campo_12 = $campo_12; $doctor->save(); return Redirect::to('doctors&cols'); }
/** * 匯入醫師名單 */ public function actionDoctors() { $this->currentActive = '醫師名單'; $excel = new ExcelUploadForm(); $rows = array(); $errors = array(); if (isset($_POST['ExcelUploadForm'])) { $excel->attributes = $_POST['ExcelUploadForm']; $excel->file = CUploadedFile::getInstance($excel, 'file'); $transaction = Yii::app()->db->beginTransaction(); try { if ($excel->validate()) { $rows = $excel->getContents(); foreach ($rows as $i => $row) { if ($i != ExcelUploadForm::HEADER) { $doctor = new Doctor(); $doctor->id = $row[1]; $doctor->name = $row[2]; if (!$doctor->save()) { $errorData = array('第' . ($i + 1) . '筆,' . $row[2] => $doctor->getErrors()); $errors[] = $errorData; } } } $transaction->commit(); } else { $errors[] = array('Excel' => $excel->getErrors()); } } catch (Exception $e) { $transaction->rollBack(); $errors = $e->getMessage(); } $this->_setFlashMessage($errors); $this->redirect($this->createUrl("/excel/import/{$this->action->id}")); } $this->render('upload', array('excel' => $excel)); }