public function store() { if (Request::ajax()) { $data = array("agenda_id" => Input::get("agenda_id"), "patient" => Input::get("patient"), "reason" => Input::get("reason"), "fecha" => Input::get("fecha"), "start" => Input::get("start"), "end" => Input::get("end")); $rules = array("agenda_id" => 'required', "patient" => 'required|min:2|max:100', "reason" => 'required|min:2|max:200', "fecha" => 'required|min:1|max:100', "start" => 'required|min:1|max:100', "end" => 'required|min:1|max:100'); $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'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores if ($validation->fails()) { return Response::json(array('success' => false, 'errors' => $validation->getMessageBag()->toArray())); } else { $agenda = Agenda::find(Input::get('agenda_id')); $user = User::where('email', Input::get('patient'))->orWhere('username', Input::get('patient'))->first(); if ($user) { $patient = Patient::where('user_id', $user->id)->first(); if (!$patient) { $patient = new Patient(); $patient->user_id = $user->id; $patient->save(); } $docPatient = DoctorPatient::where('patient_id', $patient->id)->where('doctor_id', $agenda->doctor_id)->first(); if (!$docPatient) { $docPatient = new DoctorPatient(); $docPatient->patient_id = $patient->id; $docPatient->doctor_id = $agenda->doctor_id; $docPatient->save(); } $apo = new Appointment(); $apo->patient_id = $patient->id; $apo->agenda_id = $agenda->id; $apo->day = Input::get("fecha"); $apo->start_date = Input::get('start'); $apo->end_date = Input::get('end'); $apo->reason = Input::get('reason'); if ($agenda->appointment_state == 0) { $apo->state = 'confirmed'; } else { $apo->state = 'pending'; } $apo->save(); if ($apo) { if ($agenda->appointment_state == 0) { $mgs = new MgsAppointment(); $mgs->appointment_id = $apo->id; $mgs->text = "Su cita fue Confirmada"; $mgs->save(); } return Response::json(array('success' => true)); } } else { return Response::json(array('success' => false, 'errors' => 'El usuario no existe')); } } } }
public static function getVeryAgenda($agenda_id) { $user = Sentry::getUser(); $doctor = Doctor::where('user_id', $user->id)->first(); $agenda = Agenda::find($agenda_id); if ($agenda->doctor_id == $doctor->id) { return true; } else { return false; } }
public function postaddPatient() { if (Request::ajax()) { $data = array("agenda_id" => Input::get("agenda_id"), "first_name" => Input::get("first_name"), "last_name" => Input::get("last_name"), "email" => Input::get("email")); $rules = array("agenda_id" => 'required', "first_name" => 'required|min:2|max:50', "last_name" => 'required|min:2|max:50', "email" => 'required|email|min:1|max:50'); $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'); $validation = Validator::make(Input::all(), $rules, $messages); //si la validación falla redirigimos al formulario de registro con los errores if ($validation->fails()) { return Response::json(array('success' => false, 'errors' => $validation->getMessageBag()->toArray())); } else { $password = $this->generaPass(); $agenda = Agenda::find(Input::get('agenda_id')); $user = new User(); $user->first_name = Input::get("first_name"); $user->last_name = Input::get("last_name"); $user->email = Input::get("email"); $user->password = $password; $user->username = Input::get("first_name") . Input::get("last_name"); $user->activated = 1; $user->save(); if ($user) { $doctorUser = Sentry::getUserProvider()->findByLogin($user->email); $doctorsyGroup = Sentry::getGroupProvider()->findByName('Patients'); $doctorUser->addGroup($doctorsyGroup); $profile = new Profile(); $profile->user_id = $user->id; $profile->save(); $patient = new Patient(); $patient->user_id = $user->id; $patient->save(); $docPatient = new DoctorPatient(); $docPatient->patient_id = $patient->id; $docPatient->doctor_id = $agenda->doctor_id; $docPatient->save(); $subject = 'Registro por Clinica | smartdoctorappointments.com'; $name = $user->first_name; $email = $user->email; $data = array('name' => $user->first_name . " " . $user->last_name, 'password' => $password, 'email' => $user->email); Mail::send('email.userpatiendadd', $data, function ($message) use($name, $email, $subject) { $message->to($email, $name); $message->subject($subject); }); return Response::json(array('success' => true, 'email' => Input::get("email"))); } else { return Response::json(array('success' => false, 'errors' => 'Error al registrar este usuario.')); } } } }
public function actareunion_delete2($codcampeonato, $id, $id2) { //elimiminar primero todas las conclusiones de la agenda //$category=Agenda::find($id2); $todoconclusion = Conclusion::where('codAgenda', '=', $id2)->get(); foreach ($todoconclusion as $value) { $conclusion = Conclusion::find($value->codConclusion); $conclusion->delete(); } $category = Agenda::find($id2); //luego recien la agenda $category->delete(); return Redirect::to('campeonato/detail/' . $codcampeonato . '/abriracta/' . $id); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $proveedor = 1; $data = Input::all(); $agenda = Agenda::find($id); $agenda->nombre_completo = $data['nombre_completo']; $agenda->profesion = $data['profesion']; $agenda->telefono = $data['telefono']; $agenda->celular = $data['celular']; $agenda->extension = $data['extension']; $agenda->correo = $data['correo']; $agenda->ruc = $data['ruc']; $agenda->detalle = $data['detalle']; if (empty($data['proveedor'])) { $proveedor = 0; } $agenda->proveedor = $proveedor; $agenda->save(); return Redirect::route('datos.agenda.index'); }
public function vistaTurnos($id) { $turnos = Agenda::find($id)->vistaTurnos(); return Response::json(array('error' => false, 'listado' => $turnos), 200); }
echo "<div id='alert-message' class='alert alert-success'>\n <strong>Sucesso!</strong> Compromisso Atualizado!\n </div>"; #abaixo, chamamos a função header() #sua vez aponta para o endereço de onde ocorrerá o redirecionamento header('Refresh: 3; URL=consultaAgenda.php'); } } ?> <?php # RESGATA O ID PASSADO PELO HREF RESGATADO PELO METHOD GET if (isset($_GET['acao']) && $_GET['acao'] == 'editar') { # GUARDA O ID DENTRO DA VARIÁVEL ID $id = (int) $_GET['id']; # A VARIÁVEL RESULTADO GUARDA O VALOR DA VARIÁVEL ID QUE É ESTANCIADA PELA CLASSE EPIS CHAMANDO A FUNÇÃO FIND # DA CLASSE CRUD.PHP $resultado = $agenda->find($id); } ?> <div class="widget-box"> <div class="widget-title"> <span class="icon"> <i class="icon-user"></i> </span> <h5>Cadastro de Compromissos</h5> </div> <div class="widget-content nopadding"> <form action="" id="formAgenda" method="post" class="form-horizontal" > <input type="hidden" name="id" value="<?php