/**
  * Handle an incoming request.
  * Determines if the user is the administrator of the website.
  * The administrator is the first user of the database.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     $itemtypes = Itemtype::all();
     Session::forget('itemtypes');
     Session::put('itemtypes', $itemtypes);
     $biblios = Biblio::all();
     Session::forget('biblios');
     Session::put('biblios', $biblios);
     return $next($request);
 }
 public function hasextrafields($id)
 {
     $itemtype = Itemtype::find($id);
     if ($itemtype->extra_fields == null) {
         return false;
     } else {
         return true;
     }
     //return ($itemtype->extra_fields != null ? true : false);
 }
Пример #3
0
 /**
  * Sets the session variable itemtype
  */
 public function change($id)
 {
     $itemtype = Itemtype::findOrFail($id);
     Session::put('itemtype_id', $id);
     Session::put('itemtype_name', $itemtype->name);
     return redirect('admin/records/create');
 }
 /**
  * Bootstrap the application services.
  *
  * @return void
  */
 public function boot()
 {
     // itemList
     view()->composer(array('product.bomitems.createitem', 'product.bomitems.edit', 'sales.soitems.create', 'sales.soitems.edit'), function ($view) {
         $view->with('itemList', \App\models\Product\Item::orderby('id', 'asc')->lists('item_number', 'id'));
     });
     // itemclassList
     view()->composer(array('items.create', 'items.edit', 'product.items.create', 'product.items.edit'), function ($view) {
         $view->with('itemclassList', \App\models\Product\Itemclass::orderby('id', 'asc')->lists('name', 'id'));
     });
     // itemtypeList
     view()->composer(array('items.create', 'items.edit', 'product.items.create', 'product.items.edit'), function ($view) {
         $view->with('itemtypeList', \App\Itemtype::orderby('id', 'asc')->lists('name', 'id'));
     });
     // provinceList
     view()->composer(array('addr.citys.create', 'addr.citys.edit', 'addr.addrs.create', 'addr.addrs.edit'), function ($view) {
         $view->with('provinceList', \App\Province::orderby('id', 'asc')->lists('name', 'id'));
     });
     // cityList
     view()->composer(array('addr.addrs.create', 'addr.addrs.edit'), function ($view) {
         $view->with('cityList', \App\City::orderby('id', 'asc')->lists('name', 'id'));
     });
     // addrList
     view()->composer(array('contacts.create', 'contacts.edit', 'inventory.warehouses.create', 'inventory.warehouses.edit', 'purchase.vendinfos.create', 'purchase.vendinfos.edit'), function ($view) {
         $view->with('addrList', \App\Addr::orderby('id', 'asc')->lists('line1', 'id'));
     });
     // contactList
     view()->composer(array('custinfos.create', 'custinfos.edit', 'inventory.warehouses.create', 'inventory.warehouses.edit', 'purchase.vendinfos.create', 'purchase.vendinfos.edit', 'purchase.purchaseorders.create', 'purchase.purchaseorders.edit'), function ($view) {
         $view->with('contactList', \App\Contact::orderby('id', 'asc')->lists('name', 'id'));
     });
     // deptList
     view()->composer(array('system.employees.create', 'system.employees.edit'), function ($view) {
         $view->with('deptList', \App\System\Dept::orderby('id', 'asc')->lists('name', 'id'));
     });
     // imageList
     view()->composer(array('system.employees.create', 'system.employees.edit'), function ($view) {
         $view->with('imageList', \App\System\Image::orderby('id', 'asc')->lists('name', 'id'));
     });
     // custinfoList
     view()->composer(array('sales.salesorders.create', 'sales.salesorders.edit'), function ($view) {
         $view->with('custinfoList', \App\Custinfo::orderby('id', 'asc')->lists('name', 'id'));
     });
     // salesrepList
     view()->composer(array('sales.salesorders.create', 'sales.salesorders.edit'), function ($view) {
         $view->with('salesrepList', \App\Sales\Salesrep::orderby('id', 'asc')->lists('name', 'id'));
     });
     // termList
     view()->composer(array('purchase.vendinfos.create', 'purchase.vendinfos.edit', 'purchase.purchaseorders.create', 'purchase.purchaseorders.edit'), function ($view) {
         $view->with('termList', \App\Sales\Term::orderby('id', 'asc')->lists('code', 'id'));
     });
     // vendtypeList
     view()->composer(array('purchase.vendinfos.create', 'purchase.vendinfos.edit'), function ($view) {
         $view->with('vendtypeList', \App\Purchase\Vendtype::orderby('id', 'asc')->lists('code', 'id'));
     });
     // vendinfoList
     view()->composer(array('purchase.purchaseorders.create', 'purchase.purchaseorders.edit'), function ($view) {
         $view->with('vendinfoList', \App\Purchase\Vendinfo::orderby('id', 'asc')->lists('number', 'id'));
     });
     // soheadList
     view()->composer(array('purchase.purchaseorders.create', 'purchase.purchaseorders.edit'), function ($view) {
         $view->with('soheadList', \App\Sales\Salesorder::orderby('id', 'asc')->lists('number', 'id'));
     });
     // itemsiteList
     view()->composer(array('purchase.poitems.create', 'purchase.poitems.edit'), function ($view) {
         //             $items = \App\Inventory\Itemsite::orderby('itemsites.id', 'asc')->leftJoin('items', 'itemsites.item_id', '=', 'items.id')->select('item_number', 'itemsites.id')->get();
         $view->with('itemsiteList', \App\Inventory\Itemsite::orderby('itemsites.id', 'asc')->leftJoin('items', 'itemsites.item_id', '=', 'items.id')->select('item_number', 'itemsites.id')->lists('item_number', 'id'));
         //             $view->with('itemsiteList', DB::table('itemsites')->leftJoin('items', 'itemsites.item_id', '=', 'items.id')->select('item_number', 'itemsites.id')->lists('item_number', 'itemsites.id'));
         //             $view->with('itemsiteList', \App\Inventory\Itemsite::orderby('itemsites.id', 'asc')->lists('item_id', 'id'));
     });
     // roleList
     view()->composer(array('system.users.editrole'), function ($view) {
         $view->with('roleList', \App\Role::orderby('id', 'asc')->lists('name', 'id'));
     });
     // charIList: item char list
     view()->composer(array('items.create', 'items.edit', 'product.items.create', 'product.items.edit'), function ($view) {
         $view->with('charIList', \App\Product\Characteristic::orderby('id', 'asc')->where('bitems', true)->lists('name', 'id'));
     });
 }
Пример #5
0
 /**
  * Shows the view to edit a Record
  * 
  * @param  $id the id of the Record to view
  */
 public function edit($id)
 {
     $record = Record::with('itemtype')->with('fields')->findOrFail($id);
     $itemtype = Itemtype::with(array('marcfields' => function ($query) {
         $query->with('marcsubfields')->get();
     }))->find($record->itemtype()->first()->id);
     return view('admin.records.edit', ['record' => $record, 'itemtype' => $itemtype, 'biblio_id' => $record->biblio]);
 }
 /**
  * Addd the specified resource.
  *
  * @return Response
  */
 public function addfield(Request $request)
 {
     $Title = $request->input('name');
     $Type = $request->input('type');
     $itemtype = $request->input('item_type');
     $newField = Itemtype::find($itemtype);
     $newField->count += 1;
     if ($newField->count == 1) {
         $rootXML = new \SimpleXMLElement("<root></root>");
         $fieldXML = $rootXML->addChild('field');
         $fieldXML->addAttribute('name', $Title);
         $fieldXML->addAttribute('type', $Type);
     } else {
         $rootXML = simplexml_load_string($newField->extra_fields) or die("Error: Cannot create object");
         for ($x = 0; $x < $newField->count; $x++) {
             if ($rootXML->field[$x]['name'] == $Title) {
                 return response()->json(["Response" => "duplicate"]);
             }
         }
         //$rootXML = new \SimpleXMLElement($newField->extra_fields);
         $fieldXML = $rootXML->addChild('field');
         $fieldXML->addAttribute('name', $Title);
         $fieldXML->addAttribute('type', $Type);
     }
     $newField->extra_fields = $rootXML->asXML();
     //$newField->extra_fields = $newField->extra_fields . "<field><name>".$Title."</name><type>".$Type."</type></field>";
     if ($newField->save() === true) {
         return response()->json(["Response" => "success"]);
     } else {
         return response()->json(["Response" => "fail"]);
     }
 }