Esempio n. 1
0
 public function postJustificar(Request $request)
 {
     $text = $request->razon;
     $tabla = $request->contenido;
     $texto2 = $request->contable;
     $id = $request->id;
     $diff = Diferencias::find($id);
     $contr = $request->contribuyente;
     if ($diff) {
         $diff->solucion = true;
         if (strlen($text) == 0) {
             $diff->solucion = false;
         }
         $diff->obser = $text;
         $diff->aspectos = $tabla;
         $diff->aspectos_texto = $texto2;
         $time = time();
         if ($request->hasFile('anexos')) {
             $anexos = $request->allFiles('anexos')['anexos'];
             $count = 0;
             foreach ($anexos as $anexo) {
                 $rules = array('file' => 'required');
                 //'required|mimes:png,gif,jpeg,txt,pdf,doc'
                 $validator = Validator::make(array('file' => $anexo), $rules);
                 if ($validator->passes()) {
                     $destinationPath = storage_path("anexos/{$contr}");
                     $filenameOrig = $anexo->getClientOriginalName();
                     $filename = "{$id}" . "_" . "{$count}" . "_{$time}" . "_" . $filenameOrig;
                     if (!file_exists($destinationPath)) {
                         File::makeDirectory($destinationPath, $mode = 0777, true, true);
                     }
                     $upload_success = $anexo->move($destinationPath, $filename);
                     Comprobante::create(['file' => "{$destinationPath}/{$filename}", 'diferencia_id' => $id]);
                     $count++;
                 }
             }
         }
         $nombre = session('name');
         $notification = new NotHelper(session('id'), "{$nombre} ha justificado una diferencia para el contribuyente {$contr}", 0, url('cargas'));
         $notification->toMoreLevelThan(session('level'));
         $diff->save();
     }
     Session::flash('message', 'Cambio realizado exitosamente');
     return redirect()->back();
 }
 public function getJust($id)
 {
     $not = Comprobante::find($id);
     return response()->download($not->file);
 }