public function detailsAction($id = null)
 {
     $this->permission('index');
     if (!$id) {
         return Brightery::error404();
     }
     $this->language->load("clinic_patients");
     $patient = $this->Database->query("SELECT users.*, `user_addresses`.`address`, `user_phones`.`phone`" . "FROM `users` " . "LEFT JOIN `user_addresses` ON `user_addresses`.`user_id`=`users`.`user_id`" . "LEFT JOIN `user_phones` ON `user_phones`.`user_id`=`users`.`user_id`" . "WHERE `users`.`user_id`='{$id}'" . "")->row();
     if (!$patient) {
         Brightery::error404();
     }
     $phones = new \modules\users\models\User_phones();
     $phones->_select = "user_phone_id, phone, user_id , `primary`";
     $phones->user_id = $id;
     $res = $phones->get();
     $user_phone_id = $res[0]->user_phone_id;
     $phones->user_phone_id = $user_phone_id;
     $address = new modules\users\models\User_addresses();
     $address->select = 'user_address_id ,user_id';
     $address->user_id = $id;
     $add = $address->get();
     $info = $this->Database->query("SELECT clinic_patient_diseases.*, `clinic_disease_templates`.`title`" . "FROM `clinic_patient_diseases` " . "JOIN `clinic_disease_templates` ON `clinic_disease_templates`.`clinic_disease_template_id`=`clinic_patient_diseases`.`clinic_disease_template_id`" . "JOIN `users` ON `users`.`user_id`=`clinic_patient_diseases`.`user_id`" . "WHERE `clinic_patient_diseases`.`user_id`='{$id}'" . "")->result();
     $notes = $this->Database->query("SELECT clinic_patients_notes.*, (SELECT fullname FROM users WHERE clinic_doctors.user_id = users.user_id ) as doctor_name" . " FROM clinic_patients_notes " . " LEFT JOIN clinic_doctors ON clinic_doctors.clinic_doctor_id = clinic_patients_notes.clinic_doctor_id " . "WHERE clinic_patients_notes.user_id = '{$id}'")->result();
     $xrays = $this->Database->query("SELECT clinic_xray_negative.*" . " FROM clinic_xray_negative " . "WHERE clinic_xray_negative.user_id = '{$id}'")->result();
     return $this->render('clinic_patients/details', ['patient' => $patient, 'diseases' => $info, 'phones' => $res, 'address' => $add, 'notes' => $notes, 'xrays' => $xrays, 'id' => $id]);
 }
Esempio n. 2
0
 public function registerAction()
 {
     $model = new \modules\users\models\Users('register');
     $user_phone = new \modules\users\models\User_phones(false);
     $user_address = new \modules\users\models\User_addresses(false);
     $model->set('usergroup_id', 1);
     $model->set('fullname', $this->input->post('fullname'));
     $model->set('usergroup_id', $this->input->post('usergroup_id'));
     $model->set('email', $this->input->post('email'));
     $model->set('gender', $this->input->post('gender'));
     $model->set('password', md5($this->input->post('password')));
     $model->set('status', 'active');
     if ($r = $model->save()) {
         foreach ($this->input->post('phone') as $phone) {
             $user_phone->set('phone', $phone);
             $user_phone->set('user_id', $r);
             $user_phone->save();
         }
         foreach ($this->input->post('address') as $address) {
             $user_address->set('address', $address);
             $user_address->set('user_id', $r);
             $user_address->set('type', 'shipping');
             $user_address->save();
         }
         Uri_helper::redirect("users/thankyou");
     } else {
         return $this->render('users/register', ['menu' => ['male' => 'Male', 'female' => 'Female']]);
     }
 }
 public function deleteAddressAction($id = null)
 {
     $this->permission('deleteAddress');
     $phone = new \modules\users\models\User_addresses();
     $phone->user_address_id = $id;
     if ($phone->delete()) {
         return TRUE;
     } else {
         return FALSE;
     }
 }