Esempio n. 1
0
 public function findInactiveArticles(Request $request)
 {
     $desde = date_format(date_create($request->fechaDesde), "Y/m/d H:i:s");
     $hasta = date_format(date_create($request->fechaHasta), "Y/m/d 23:59:99");
     $inactivos = 0;
     $active = Movement::select('article_id')->distinct()->where('created_at', '>', $desde)->where('created_at', '<', $hasta)->get();
     $activos = $active->count();
     $articles = Article::whereNotIn('id', $active)->get();
     //        dd($articles);
     foreach ($articles as $article) {
         $inactivos++;
         $article->update(['active' => 0]);
         //            dd($article);
     }
     return view('settings.findInactiveArticles', compact('activos', 'inactivos'));
 }
Esempio n. 2
0
 /**
  * Recibe el ID de un articulo y devuelve arreglo con los seriales de ese articulo que se encuentran
  * en el almacén actual
  * @param $art
  * @return array
  */
 private function buscarSeriales($art)
 {
     // status 1: Aprobado, Status 2: por aprobar
     if ($art->serializable == '1') {
         $out = Movement::select(DB::raw('DISTINCT(serial)'))->whereIn('status_id', [1, 2])->where('origin_id', '=', $this->id)->where('article_id', $art->id)->orderBy('id', 'asc')->get()->toArray();
         foreach ($out as $movOut) {
             $seriales[] = $movOut['serial'];
         }
         if (count($out) > 0) {
             $s = DB::table('movements')->select(DB::raw('DISTINCT(serial)'))->whereIn('status_id', [1, 2])->whereNotIn('serial', $seriales)->where('destination_id', '=', $this->id)->where('article_id', $art->id)->orderBy('id', 'asc')->get();
         } else {
             $s = DB::table('movements')->select(DB::raw('DISTINCT(serial)'))->whereIn('status_id', [1, 2])->where('destination_id', '=', $this->id)->where('article_id', $art->id)->orderBy('id', 'asc')->get();
         }
     } else {
         $s[] = '';
     }
     return $s;
 }
Esempio n. 3
0
 public function showMovimientosPorTicket()
 {
     $companies = Company::lists('name', 'id');
     //       1) Traigo todos los almacenes que pertenecen a la compañía del usuario
     $arrayW = collect(DB::table('warehouses')->select('id')->where('company_id', Auth::user()->current_company_id)->get());
     //      2) Traigo el campo "ticket" de los movimientos sobre los almacenes seleccionados
     //        para pre cargar el dropdown
     $tickets = Movement::select('ticket')->distinct()->whereIn('origin_id', $arrayW->lists('id')->toArray())->whereIn('status_id', [1, 2, 4])->orderBy('id', 'desc')->lists('ticket', 'ticket');
     return view('reports.movimientosPorTicketForm', compact('companies', 'tickets'));
 }