Пример #1
0
 /**
  * Handles the individual Catalog page control.
  *
  * @param int $irn
  *  The IRN of the EMu Catalogue record.
  *
  * @return view
  */
 public function showCatalog($irn)
 {
     $catalog = new Catalog();
     $record = $catalog->getRecord($irn);
     $view = view('catalog-detail', ['record' => $record])->render();
     return $view;
 }
 public function searchProduct($query)
 {
     $q = substr($query, 2);
     $this->ViewTemplate['title'] .= ' - Produkty';
     $searchView = ['catalog' => Catalog::getProductsLike($q), 'fraza' => $q];
     return view('template', $this->ViewTemplate)->nest('content', 'search', $searchView);
 }
Пример #3
0
 public function addCatalog(Request $request)
 {
     log::info('add catalog');
     log::info($request);
     try {
         if ($request->get("img") != null) {
             log::info('if');
             $base64data = $request->get("img");
             $filename = str_random(60);
             $uri = substr($base64data, strpos($base64data, ",") + 1);
             $url = public_path() . '/fm_user/images/fm/catalog/' . $request->get('shop_id') . '/';
             if (!File::exists($url)) {
                 File::makeDirectory($url, $mode = 0777, true, true);
             }
             File::put($url . $filename . '.jpg', base64_decode($uri));
             $catalogData = array('media_url' => $url . $filename . '.jpg');
         }
         $catalogData['location_id'] = $request->get('location_id');
         $catalogData['description'] = $request->get('description');
         $catalogData['name'] = $request->get('name');
         $catalogId = Catalog::create($catalogData)->id;
         return Response::json($catalogId);
     } catch (Exception $e) {
         log::info($e);
         return Response::json('ERROR');
     }
 }
 public function index()
 {
     $this->ViewTemplate['index'] = true;
     $recommended = Catalog::getRecommended(0);
     $view = view('template', $this->ViewTemplate)->nest('content', 'home', ['recommended' => $recommended]);
     Cookie::queue(Cookie::make('dayProduct', '1', 4800));
     return $view;
 }
 public function search()
 {
     if (!Request::ajax()) {
         return Redirect::to('/');
     }
     $q = Request::input('q');
     $products = Catalog::searchProduct($q);
     return view('ajax/ajaxSearch', ['products' => $products]);
 }
 public function productsChangeDisplay()
 {
     $this->view['title'] .= 'Panel administracyjny - Produkty';
     $categoryId = Request::input('category');
     $productsView = ['cID' => $categoryId, 'products' => Catalog::getProductList($categoryId)];
     $view = view('admin/template', $this->view)->nest('content', 'admin/products', $productsView);
     $cookie = Cookie::forever('display', Request::input('category'));
     return Response::make($view)->withCookie($cookie);
 }
Пример #7
0
 /**
  * Parse excel data and insert it in database
  * 
  * @param  array $excelData
  * @return void
  */
 protected function parseExcelData($excelData)
 {
     foreach ($excelData as $key => $data) {
         /* Skip first row */
         if (1 == $key) {
             continue;
         }
         $Category = Category::firstOrCreate(['parent_id' => null, 'name' => $data['A']]);
         $SubCategory = Category::firstOrCreate(['parent_id' => (int) $Category->id, 'name' => $data['B']]);
         Catalog::create(['category_id' => $SubCategory->id, 'part_number' => $data['C'], 'description' => $data['D']]);
     }
 }
Пример #8
0
 public function isValid($data)
 {
     $tamanio = 0;
     $valor = 1;
     if ($data['entrada'] == 1) {
         $campo = 'pk_referencia';
     } else {
         $campo = 'folio_ds';
     }
     $consulta = \DB::connection('users')->table($data['tabla'])->where($campo, $data['referencia'])->get();
     if ($consulta != null) {
         foreach ($consulta as $query) {
             //============================== Validaciones ================================
             if ($data['attr_id'] == 4) {
                 if ($query->{$data}['campos'] == '') {
                     $valor = 0;
                 }
             }
             if ($data['attr_id'] == 2) {
                 $campo = explode(",", $data['campos']);
                 if ($data['attr_id'] == 2) {
                     for ($i = 0; $i < count($campo); $i++) {
                         $tamanio += strlen($query->{$campo}[$i]);
                     }
                     if ($tamanio != $data['data_val']) {
                         $valor = 0;
                     }
                 } else {
                     $campos = $campo[0];
                 }
             }
             if ($data['attr_id'] == 6 || $data['attr_id'] == 5) {
                 $catalogo = explode("|", $data['data_val']);
                 $tablaval = $catalogo[0];
                 $campoval = $catalogo[1];
                 Session::put('tablacat', $tablaval);
                 if ($data['attr_id'] == 5) {
                     $formula = explode(',', $catalogo[1]);
                     $campobd = $formula[0];
                     $operador = $formula[1];
                     $result = $formula[2];
                     $camposwh = Anexo22::find($result)->relationships->where('origin_id', $data['entrada'])->first();
                     $campowh = explode(',', $camposwh->field);
                     $val_campo = Catalog::where($catalogo[2], 'LIKE', '%' . $query->{$data}['campos'] . '%')->where($campobd, $query->{$campowh}[0])->count();
                 }
                 if ($data['attr_id'] == 6) {
                     $campo = explode(',', $data['campos']);
                     $campocat = $campo[0];
                     $val_campo = Catalog::where($campoval, $query->{$campocat})->count();
                 }
                 if ($val_campo == 0) {
                     $valor = 0;
                 }
             }
             if ($data['attr_id'] == 3) {
                 $camposval = explode(",", $data['data_val']);
                 $valanexo = Anexo22::find($camposval[0]);
                 $campanx = $valanexo->a22_field;
                 if ($query->{$campanx} != $camposval[1]) {
                     $valor = 0;
                 }
             }
             if ($data['attr_id'] == 8) {
                 //$camposval = explode(",", $data['campos']);
                 $valores = explode("|", $data['data_val']);
                 $identif = $valores[1];
                 $docum = $valores[0];
                 $documentos = \DB::connection('users')->table('opauimg')->where('pk_referencia', $data['referencia'])->where('imgtipodoc', $docum)->count();
                 if ($query->{$data}['campos'] != $identif && $documentos == 0) {
                     $valor = 0;
                 }
             }
         }
     }
     return $valor;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy(Request $request, $id)
 {
     $catalog = Catalog::find($id);
     if ($catalog && $catalog->user_id == $request->user()->id) {
         $catalog->delete();
         return response()->json(['result' => 'success', 'message' => 'Запись успешно удалена']);
     } else {
         return response(['message' => 'Не найдено записи'], 422)->header('Content-Type', 'application/json');
     }
 }