App\Helpers\Helper Class Reference

Static Public Member Functions

static parseEmailList ($emails)
 
static trim_value (&$value)
 
static ParseFloat ($floatString)
 
static modelList ()
 
static companyList ()
 
static categoryList ()
 
static suppliersList ()
 
static statusLabelList ()
 
static locationsList ()
 
static manufacturerList ()
 
static statusTypeList ()
 
static managerList ()
 
static depreciationList ()
 
static categoryTypeList ()
 
static usersList ()
 
static assetsList ()
 
static customFieldsetList ()
 
static predefined_formats ()
 
static barcodeDimensions ($barcode_type= 'QRCODE')
 
static generateRandomString ($length=10)
 
static checkLowInventory ()
 This nasty little method gets the low inventory info for the alert dropdown. More...
 
static checkUploadIsImage ($file)
 

Detailed Description

Definition at line 25 of file Helper.php.

Member Function Documentation

static App\Helpers\Helper::assetsList ( )
static

Definition at line 149 of file Helper.php.

150  {
151  $assets_list = array('' => trans('general.select_asset')) + Asset::orderBy('name', 'asc')
152  ->whereNull('deleted_at')
153  ->pluck('name', 'id')->toArray();
154  return $assets_list;
155  }
static App\Helpers\Helper::barcodeDimensions (   $barcode_type = 'QRCODE')
static

Definition at line 171 of file Helper.php.

172  {
173  if ($barcode_type == 'C128') {
174  $size['height'] = '-1';
175  $size['width'] = '-10';
176  } elseif ($barcode_type == 'PDF417') {
177  $size['height'] = '-3';
178  $size['width'] = '-10';
179  } else {
180  $size['height'] = '-3';
181  $size['width'] = '-3';
182  }
183  return $size;
184  }
static App\Helpers\Helper::categoryList ( )
static

Definition at line 70 of file Helper.php.

71  {
72  $category_list = array('' => '') + Category::orderBy('name', 'asc')
73  ->whereNull('deleted_at')
74  ->orderBy('name', 'asc')
75  ->pluck('name', 'id')->toArray();
76  return $category_list;
77  }
static App\Helpers\Helper::categoryTypeList ( )
static

Definition at line 132 of file Helper.php.

133  {
134  $category_types = array('' => '','accessory' => 'Accessory', 'asset' => 'Asset', 'consumable' => 'Consumable','component' => 'Component');
135  return $category_types;
136  }
static App\Helpers\Helper::checkLowInventory ( )
static

This nasty little method gets the low inventory info for the alert dropdown.

Definition at line 201 of file Helper.php.

202  {
203  $consumables = Consumable::with('users')->whereNotNull('min_amt')->get();
204  $accessories = Accessory::with('users')->whereNotNull('min_amt')->get();
205  $components = Component::with('assets')->whereNotNull('min_amt')->get();
206 
207  $avail_consumables = 0;
208  $items_array = array();
209  $all_count = 0;
210 
211  foreach ($consumables as $consumable) {
212  $avail = $consumable->numRemaining();
213  if ($avail < ($consumable->min_amt) + 3) {
214  $percent = number_format((($consumable->numRemaining() / $consumable->qty) * 100), 0);
215  $items_array[$all_count]['id'] = $consumable->id;
216  $items_array[$all_count]['name'] = $consumable->name;
217  $items_array[$all_count]['type'] = 'consumables';
218  $items_array[$all_count]['percent'] = $percent;
219  $items_array[$all_count]['remaining']=$consumable->numRemaining();
220  $items_array[$all_count]['min_amt']=$consumable->min_amt;
221  $all_count++;
222  }
223 
224 
225  }
226 
227  foreach ($accessories as $accessory) {
228  $avail = $accessory->numRemaining();
229  if ($avail < ($accessory->min_amt) + 3) {
230  $percent = number_format((($accessory->numRemaining() / $accessory->qty) * 100), 0);
231  $items_array[$all_count]['id'] = $accessory->id;
232  $items_array[$all_count]['name'] = $accessory->name;
233  $items_array[$all_count]['type'] = 'accessories';
234  $items_array[$all_count]['percent'] = $percent;
235  $items_array[$all_count]['remaining']=$accessory->numRemaining();
236  $items_array[$all_count]['min_amt']=$accessory->min_amt;
237  $all_count++;
238  }
239 
240  }
241 
242  foreach ($components as $component) {
243  $avail = $component->numRemaining();
244  if ($avail < ($component->min_amt) + 3) {
245  $percent = number_format((($component->numRemaining() / $component->total_qty) * 100), 0);
246  $items_array[$all_count]['id'] = $component->id;
247  $items_array[$all_count]['name'] = $component->name;
248  $items_array[$all_count]['type'] = 'components';
249  $items_array[$all_count]['percent'] = $percent;
250  $items_array[$all_count]['remaining']=$component->numRemaining();
251  $items_array[$all_count]['min_amt']=$component->min_amt;
252  $all_count++;
253  }
254 
255  }
256 
257 
258 
259  return $items_array;
260 
261 
262  }
static App\Helpers\Helper::checkUploadIsImage (   $file)
static

Definition at line 265 of file Helper.php.

266  {
267  // Check if the file is an image, so we can show a preview
268  $finfo = @finfo_open(FILEINFO_MIME_TYPE); // return mime type ala mimetype extension
269  $filetype = @finfo_file($finfo, $file);
270  finfo_close($finfo);
271 
272  if (($filetype=="image/jpeg") || ($filetype=="image/jpg") || ($filetype=="image/png") || ($filetype=="image/bmp") || ($filetype=="image/gif")) {
273  return $filetype;
274  }
275 
276  return false;
277  }
static App\Helpers\Helper::companyList ( )
static

Definition at line 61 of file Helper.php.

62  {
63  $company_list = array('0' => trans('general.select_company')) + DB::table('companies')
64  ->orderBy('name', 'asc')
65  ->pluck('name', 'id');
66  return $company_list;
67  }
static App\Helpers\Helper::customFieldsetList ( )
static

Definition at line 158 of file Helper.php.

159  {
160  $customfields = array('' => trans('admin/models/general.no_custom_field')) + CustomFieldset::pluck('name', 'id')->toArray();
161  return $customfields;
162  }
static App\Helpers\Helper::depreciationList ( )
static

Definition at line 125 of file Helper.php.

126  {
127  $depreciation_list = ['' => 'Do Not Depreciate'] + Depreciation::orderBy('name', 'asc')
128  ->pluck('name', 'id')->toArray();
129  return $depreciation_list;
130  }
static App\Helpers\Helper::generateRandomString (   $length = 10)
static

Definition at line 186 of file Helper.php.

187  {
188  $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
189  $charactersLength = strlen($characters);
190  $randomString = '';
191  for ($i = 0; $i < $length; $i++) {
192  $randomString .= $characters[rand(0, $charactersLength - 1)];
193  }
194  return $randomString;
195  }
static App\Helpers\Helper::locationsList ( )
static

Definition at line 94 of file Helper.php.

95  {
96  $location_list = array('' => trans('general.select_location')) + Location::orderBy('name', 'asc')
97  ->pluck('name', 'id')->toArray();
98  return $location_list;
99  }
static App\Helpers\Helper::managerList ( )
static

Definition at line 115 of file Helper.php.

116  {
117  $manager_list = array('' => '') + User::select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
118  ->whereNull('deleted_at', 'and')
119  ->orderBy('last_name', 'asc')
120  ->orderBy('first_name', 'asc')
121  ->pluck('full_name', 'id')->toArray();
122  return $manager_list;
123  }
static App\Helpers\Helper::manufacturerList ( )
static

Definition at line 101 of file Helper.php.

102  {
103  $manufacturer_list = array('' => 'Select One') +
104  Manufacturer::orderBy('name', 'asc')
105  ->pluck('name', 'id')->toArray();
106  return $manufacturer_list;
107  }
static App\Helpers\Helper::modelList ( )
static

Definition at line 51 of file Helper.php.

52  {
53  $model_list = array('' => trans('general.select_model')) + DB::table('models')
54  ->select(DB::raw('IF (modelno="" OR modelno IS NULL,name,concat(name, " / ",modelno)) as name, id'))
55  ->orderBy('name', 'asc')
56  ->whereNull('deleted_at')
57  ->pluck('name', 'id');
58  return $model_list;
59  }
static App\Helpers\Helper::parseEmailList (   $emails)
static

Definition at line 29 of file Helper.php.

30  {
31  $emails_array = explode(',', $emails);
32  return array_walk($emails_array, 'trim_value');
33  }
static App\Helpers\Helper::ParseFloat (   $floatString)
static

Definition at line 41 of file Helper.php.

42  {
43  // use comma for thousands until local info is property used
44  $LocaleInfo = localeconv();
45  $floatString = str_replace(",", "", $floatString);
46  $floatString = str_replace($LocaleInfo["decimal_point"], ".", $floatString);
47  return floatval($floatString);
48  }
static App\Helpers\Helper::predefined_formats ( )
static

Definition at line 164 of file Helper.php.

165  {
166  $keys=array_keys(CustomField::$PredefinedFormats);
167  $stuff=array_combine($keys, $keys);
168  return $stuff+["" => "Custom Format..."];
169  }
static App\Helpers\Helper::statusLabelList ( )
static

Definition at line 87 of file Helper.php.

88  {
89  $statuslabel_list = array('' => trans('general.select_statuslabel')) + Statuslabel::orderBy('name', 'asc')
90  ->pluck('name', 'id')->toArray();
91  return $statuslabel_list;
92  }
static App\Helpers\Helper::statusTypeList ( )
static

Definition at line 109 of file Helper.php.

110  {
111  $statuslabel_types = array('' => trans('admin/hardware/form.select_statustype')) + array('undeployable' => trans('admin/hardware/general.undeployable')) + array('pending' => trans('admin/hardware/general.pending')) + array('archived' => trans('admin/hardware/general.archived')) + array('deployable' => trans('admin/hardware/general.deployable'));
112  return $statuslabel_types;
113  }
static App\Helpers\Helper::suppliersList ( )
static

Definition at line 79 of file Helper.php.

80  {
81  $supplier_list = array('' => trans('general.select_supplier')) + Supplier::orderBy('name', 'asc')
82  ->orderBy('name', 'asc')
83  ->pluck('name', 'id')->toArray();
84  return $supplier_list;
85  }
static App\Helpers\Helper::trim_value ( $value)
static

Definition at line 36 of file Helper.php.

37  {
38  return trim($value);
39  }
static App\Helpers\Helper::usersList ( )
static

Definition at line 138 of file Helper.php.

139  {
140  $users_list = array('' => trans('general.select_user')) + DB::table('users')
141  ->select(DB::raw('concat(last_name,", ",first_name," (",username,")") as full_name, id'))
142  ->whereNull('deleted_at')
143  ->orderBy('last_name', 'asc')
144  ->orderBy('first_name', 'asc')
145  ->pluck('full_name', 'id');
146  return $users_list;
147  }

The documentation for this class was generated from the following file: