public function listado_gf()
 {
     $validator = Validator::make(Input::all(), Guardias::$rules);
     if ($validator->passes()) {
         $profesional = Profesional::find(Input::get('profesional'));
         $sede = Sedes::find(Input::get('sede'));
         $fecha_inicio = explode('/', Input::get('fecha_inicio'));
         $fecha_inicio = $fecha_inicio[2] . "-" . $fecha_inicio[1] . "-" . $fecha_inicio[0];
         $fecha_fin = explode('/', Input::get('fecha_fin'));
         $fecha_fin = $fecha_fin[2] . "-" . $fecha_fin[1] . "-" . $fecha_fin[0];
         $guardias = Guardias::whereBetween('fecha_guardia', array($fecha_inicio, $fecha_fin))->where('sede_id', $sede->id)->where('profesional_id', $profesional->id)->select(DB::raw("DATE_FORMAT(fecha_guardia, '%d/%m/%Y') as fecha"), DB::raw("DATE_FORMAT(fecha_guardia, '%w') as dow"))->get();
         $opciones = Opciones::where('nombre', 'guardia_finde')->orWhere('nombre', 'guardia_laborable')->lists('valor', 'nombre');
         var_dump($opciones);
         $suma = 0;
         foreach ($guardias as $guardia) {
             if ($guardia->dow != 0) {
                 $guardia->euros = number_format($opciones['guardia_laborable'], 2, ',', '.');
             } else {
                 $guardia->euros = number_format($opciones['guardia_finde'], 2, ',', '.');
             }
             $suma = number_format($suma + $guardia->euros, 2, ',', '.');
         }
         //var_dump($guardias);die;
         return View::make('guardias.listado_gf')->with('guardias', $guardias)->with('profesional', $profesional)->with('sede', $sede)->with('fecha_inicio', $fecha_inicio)->with('fecha_fin', $fecha_fin)->with('opciones', $opciones)->with('suma', $suma);
     } else {
         return Redirect::to('guardia/listado')->with('message', '<h3 style="color: red"> Debe de indicar una fecha de inicio y de fin válidas.</h3>')->withErrors($validator)->withInput();
     }
 }
Example #2
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $sede = Sedes::find($id);
     $sede->update(Input::all());
     return Redirect::action('SedesController@index')->with('message', 'Sede modificada con éxito.');
 }
 private function _imprimirPresupuesto($numerohistoria, $id)
 {
     $presupuesto = Presupuestos::leftJoin('profesionales', 'profesionales.id', '=', 'presupuestos.profesional_id')->select('presupuestos.*', DB::raw("DATE_FORMAT(presupuestos.created_at, '%d/%m/%Y') as creado"), 'profesionales.nombre as p_n', 'profesionales.apellido1 as p_a1', 'profesionales.apellido2 as p_a2')->find($id);
     $paciente = Pacientes::where('numerohistoria', $numerohistoria)->firstOrFail();
     $tratamientos = $presupuesto->tratamientos()->get(array('presupuestos_tratamientos.*', 'tratamientos.nombre', 'tratamientos.imagen', 'tratamientos.tipostratamientos_id'));
     $companias_list = Companias::lists('nombre', 'id');
     $total = 0;
     $sede = Sedes::find($presupuesto->sede_id);
     $todaslaspiezas = array();
     $todaslaspiezas['muestraOdontograma'] = false;
     for ($i = 11; $i <= 18; $i++) {
         $todaslaspiezas[$i] = "/imagenes/piezas/{$i}.jpg";
     }
     for ($i = 21; $i <= 28; $i++) {
         $todaslaspiezas[$i] = "/imagenes/piezas/{$i}.jpg";
     }
     for ($i = 31; $i <= 38; $i++) {
         $todaslaspiezas[$i] = "/imagenes/piezas/{$i}.jpg";
     }
     for ($i = 41; $i <= 48; $i++) {
         $todaslaspiezas[$i] = "/imagenes/piezas/{$i}.jpg";
     }
     foreach ($tratamientos as $t) {
         $t->precio_unidad = $t->precio_final / $t->unidades;
         if ($t->tipodescuento == 'P') {
             $descuento = $t->descuento * $t->precio_final / 100;
             if ($descuento > 0) {
                 $descuentotext = number_format($t->descuento, 2, ',', '.') . ' %';
             } else {
                 $descuentotext = '';
             }
         } else {
             $descuento = $t->descuento;
             if ($descuento > 0) {
                 $descuentotext = number_format($t->descuento, 2, ',', '.') . ' €';
             } else {
                 $descuentotext = '';
             }
         }
         $t->precio_final -= $descuento;
         $t->descuento_text = $descuentotext;
         $t->compania_text = $companias_list[$t->compania_id];
         if (!in_array($t->imagen, array('c', 'i', 'en', 'em', 'ex'))) {
             $todaslaspiezas['muestraOdontograma'] = true;
             $todaslaspiezas['custom'] = $t->imagen;
         } elseif ($t->piezas !== null) {
             $this->_marcaPiezas($t->piezas, $t->imagen, $todaslaspiezas);
             $todaslaspiezas['muestraOdontograma'] = true;
         }
         $total += $t->precio_final;
     }
     $total = number_format($total, 2, ',', '.');
     $validez = Opciones::where('nombre', 'validez_presupuesto_meses')->select('valor')->first();
     return array('presupuesto' => $presupuesto, 'tratamientos' => $tratamientos, 'total' => $total, 'paciente' => $paciente, 'HTTP_HOST' => Request::server("HTTP_HOST"), 'todaslaspiezas' => $todaslaspiezas, 'sede' => $sede, 'validez' => $validez);
 }