Merge branch 'feature-label2' into develop

This commit is contained in:
cram42 2023-02-01 18:01:46 +11:00
commit 0f3c5d10ba
3 changed files with 29 additions and 33 deletions

View file

@ -444,7 +444,7 @@ class AssetsController extends Controller
* @since [v3.0] * @since [v3.0]
* @return Redirect * @return Redirect
*/ */
public function getAssetByTag($tag=null, Request $request) public function getAssetByTag(Request $request, $tag=null)
{ {
$tag = $tag ? $tag : $request->get('assetTag'); $tag = $tag ? $tag : $request->get('assetTag');
$topsearch = ($request->get('topsearch') == 'true'); $topsearch = ($request->get('topsearch') == 'true');

View file

@ -24,42 +24,38 @@ class LabelsController extends Controller
*/ */
public function show(string $labelName) public function show(string $labelName)
{ {
$this->authorize('view', Label::class);
$labelName = str_replace('/', '\\', $labelName); $labelName = str_replace('/', '\\', $labelName);
$template = Label::find($labelName); $template = Label::find($labelName);
$this->authorize('view', $template); $exampleAsset = new Asset();
$testAsset = new Asset(); $exampleAsset->id = 999999;
$exampleAsset->name = 'AST-AB-CD-1234';
$exampleAsset->asset_tag = 'TCA-00001';
$exampleAsset->serial = 'SN9876543210';
$testAsset->id = 999999; $exampleAsset->company = new Company();
$testAsset->name = 'AST-AB-CD-1234'; $exampleAsset->company->id = 999999;
$testAsset->asset_tag = 'TCA-00001'; $exampleAsset->company->name = 'Test Company Limited';
$testAsset->serial = 'SN9876543210'; $exampleAsset->company->image = 'company-image-test.png';
$testAsset->company = new Company(); $exampleAsset->assignedto = new User();
$testAsset->company->id = 999999; $exampleAsset->assignedto->id = 999999;
$testAsset->company->name = 'Test Company Limited'; $exampleAsset->assignedto->first_name = 'Test';
$testAsset->company->image = 'company-image-test.png'; $exampleAsset->assignedto->last_name = 'Person';
$exampleAsset->assignedto->username = 'Test.Person';
$exampleAsset->assignedto->employee_num = '0123456789';
$testAsset->assignedto = new User(); $exampleAsset->model = new AssetModel();
$testAsset->assignedto->id = 999999; $exampleAsset->model->id = 999999;
$testAsset->assignedto->first_name = 'Test'; $exampleAsset->model->name = 'Test Model';
$testAsset->assignedto->last_name = 'Person'; $exampleAsset->model->model_number = 'MDL5678';
$testAsset->assignedto->username = 'Test.Person'; $exampleAsset->model->manufacturer = new Manufacturer();
$testAsset->assignedto->employee_num = '0123456789'; $exampleAsset->model->manufacturer->id = 999999;
$exampleAsset->model->manufacturer->name = 'Test Manufacturing Inc.';
$testAsset->model = new AssetModel(); $exampleAsset->model->category = new Category();
$testAsset->model->id = 999999; $exampleAsset->model->category->id = 999999;
$testAsset->model->name = 'Test Model'; $exampleAsset->model->category->name = 'Test Category';
$testAsset->model->model_number = 'MDL5678';
$testAsset->model->manufacturer = new Manufacturer();
$testAsset->model->manufacturer->id = 999999;
$testAsset->model->manufacturer->name = 'Test Manufacturing Inc.';
$testAsset->model->category = new Category();
$testAsset->model->category->id = 999999;
$testAsset->model->category->name = 'Test Category';
$settings = Setting::getSettings(); $settings = Setting::getSettings();
if (request()->has('settings')) { if (request()->has('settings')) {
@ -70,7 +66,7 @@ class LabelsController extends Controller
} }
return (new LabelView()) return (new LabelView())
->with('assets', collect([$testAsset])) ->with('assets', collect([$exampleAsset]))
->with('settings', $settings) ->with('settings', $settings)
->with('template', $template) ->with('template', $template)
->with('bulkedit', false) ->with('bulkedit', false)

View file

@ -124,9 +124,9 @@ class Label implements View
if ($template->getSupport2DBarcode()) { if ($template->getSupport2DBarcode()) {
$barcode2DType = $settings->label2_2d_type; $barcode2DType = $settings->label2_2d_type;
$barcode2DType = ($barcode2DType == 'default') ? $barcode2DType = ($barcode2DType == 'default') ?
(($settings->qr_code) ? $settings->barcode_type : null) : $settings->barcode_type :
$barcode2DType; $barcode2DType;
if ($barcode2DType != 'none') { if (($barcode2DType != 'none') && (!is_null($barcode2DType))) {
switch ($settings->label2_2d_target) { switch ($settings->label2_2d_target) {
case 'ht_tag': $barcode2DTarget = route('ht/assetTag', $asset->asset_tag); break; case 'ht_tag': $barcode2DTarget = route('ht/assetTag', $asset->asset_tag); break;
case 'hardware_id': case 'hardware_id':