@@ -25,25 +25,25 @@ discard block |
||
25 | 25 | |
26 | 26 | ) {} |
27 | 27 | |
28 | - #[Route('/products/purchasing-suggestion', name: 'purchasing_suggestion', methods: ['GET'])] |
|
29 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
28 | + #[Route('/products/purchasing-suggestion', name: 'purchasing_suggestion', methods: [ 'GET' ]) ] |
|
29 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
30 | 30 | public function getPurchasingSuggestion(Request $request): JsonResponse |
31 | 31 | { |
32 | - $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
32 | + $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
33 | 33 | $data = $this->productService->getPurchasingSuggestion($company); |
34 | 34 | return new JsonResponse($data); |
35 | 35 | } |
36 | 36 | |
37 | - #[Route('/products/purchasing-suggestion/print', name: 'purchasing_suggestion_print', methods: ['POST'])] |
|
38 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
37 | + #[Route('/products/purchasing-suggestion/print', name: 'purchasing_suggestion_print', methods: [ 'POST' ]) ] |
|
38 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
39 | 39 | public function printPurchasingSuggestion(Request $request): JsonResponse |
40 | 40 | { |
41 | 41 | try { |
42 | 42 | $data = json_decode($request->getContent(), true); |
43 | 43 | $device = $this->manager->getRepository(Device::class)->findOneBy([ |
44 | - 'device' => $data['device'] |
|
44 | + 'device' => $data[ 'device' ] |
|
45 | 45 | ]); |
46 | - $company = $this->manager->getRepository(People::class)->find($data['people']); |
|
46 | + $company = $this->manager->getRepository(People::class)->find($data[ 'people' ]); |
|
47 | 47 | $printData = $this->productService->purchasingSuggestionPrintData($company, $device); |
48 | 48 | |
49 | 49 | return new JsonResponse($this->hydratorService->item(Spool::class, $printData->getId(), "spool_item:read"), Response::HTTP_OK); |
@@ -52,25 +52,25 @@ discard block |
||
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - #[Route('/products/inventory', name: 'products_inventory', methods: ['GET'])] |
|
56 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
55 | + #[Route('/products/inventory', name: 'products_inventory', methods: [ 'GET' ]) ] |
|
56 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
57 | 57 | public function getProductsInventory(Request $request): JsonResponse |
58 | 58 | { |
59 | - $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
59 | + $company = $this->manager->getRepository(People::class)->find($request->get('company')); |
|
60 | 60 | $data = $this->productService->getProductsInventory($company); |
61 | 61 | return new JsonResponse($data); |
62 | 62 | } |
63 | 63 | |
64 | - #[Route('/products/inventory/print', name: 'products_inventory_print', methods: ['POST'])] |
|
65 | - #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')")] |
|
64 | + #[Route('/products/inventory/print', name: 'products_inventory_print', methods: [ 'POST' ]) ] |
|
65 | + #[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_CLIENT')") ] |
|
66 | 66 | public function print(Request $request): JsonResponse |
67 | 67 | { |
68 | 68 | try { |
69 | 69 | $data = json_decode($request->getContent(), true); |
70 | 70 | $device = $this->manager->getRepository(Device::class)->findOneBy([ |
71 | - 'device' => $data['device'] |
|
71 | + 'device' => $data[ 'device' ] |
|
72 | 72 | ]); |
73 | - $company = $this->manager->getRepository(People::class)->find($data['people']); |
|
73 | + $company = $this->manager->getRepository(People::class)->find($data[ 'people' ]); |
|
74 | 74 | $printData = $this->productService->productsInventoryPrintData($company, $device); |
75 | 75 | |
76 | 76 | return new JsonResponse($this->hydratorService->item(Spool::class, $printData->getId(), "spool_item:read"), Response::HTTP_OK); |
@@ -34,31 +34,31 @@ discard block |
||
34 | 34 | { |
35 | 35 | $products = $this->getProductsInventory($provider); |
36 | 36 | |
37 | - $groupedByInventory = []; |
|
37 | + $groupedByInventory = [ ]; |
|
38 | 38 | foreach ($products as $product) { |
39 | - $inventoryName = $product['inventory_name']; |
|
40 | - if (!isset($groupedByInventory[$inventoryName])) { |
|
41 | - $groupedByInventory[$inventoryName] = []; |
|
39 | + $inventoryName = $product[ 'inventory_name' ]; |
|
40 | + if (!isset($groupedByInventory[ $inventoryName ])) { |
|
41 | + $groupedByInventory[ $inventoryName ] = [ ]; |
|
42 | 42 | } |
43 | - $groupedByInventory[$inventoryName][] = $product; |
|
43 | + $groupedByInventory[ $inventoryName ][ ] = $product; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | foreach ($groupedByInventory as $inventoryName => $items) { |
47 | - $companyName = $items[0]['company_name']; |
|
47 | + $companyName = $items[ 0 ][ 'company_name' ]; |
|
48 | 48 | $this->printService->addLine("", "", "-"); |
49 | 49 | $this->printService->addLine($companyName, "", " "); |
50 | - $this->printService->addLine("INVENTARIO: " . $inventoryName, "", " "); |
|
50 | + $this->printService->addLine("INVENTARIO: ".$inventoryName, "", " "); |
|
51 | 51 | $this->printService->addLine("", "", "-"); |
52 | 52 | $this->printService->addLine("Produto", "Disponivel", " "); |
53 | 53 | $this->printService->addLine("", "", "-"); |
54 | 54 | |
55 | 55 | foreach ($items as $item) { |
56 | - $productName = substr($item['product_name'], 0, 20); |
|
57 | - if (!empty($item['description'])) { |
|
58 | - $productName .= " " . substr($item['description'], 0, 10); |
|
56 | + $productName = substr($item[ 'product_name' ], 0, 20); |
|
57 | + if (!empty($item[ 'description' ])) { |
|
58 | + $productName .= " ".substr($item[ 'description' ], 0, 10); |
|
59 | 59 | } |
60 | - $productName .= " (" . $item['productUnit'] . ")"; |
|
61 | - $available = str_pad($item['available'], 4, " ", STR_PAD_LEFT); |
|
60 | + $productName .= " (".$item[ 'productUnit' ].")"; |
|
61 | + $available = str_pad($item[ 'available' ], 4, " ", STR_PAD_LEFT); |
|
62 | 62 | $this->printService->addLine($productName, $available, " "); |
63 | 63 | } |
64 | 64 | |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | { |
78 | 78 | $products = $this->getPurchasingSuggestion($provider); |
79 | 79 | |
80 | - $groupedByCompany = []; |
|
80 | + $groupedByCompany = [ ]; |
|
81 | 81 | foreach ($products as $product) { |
82 | - $companyName = $product['company_name']; |
|
83 | - if (!isset($groupedByCompany[$companyName])) { |
|
84 | - $groupedByCompany[$companyName] = []; |
|
82 | + $companyName = $product[ 'company_name' ]; |
|
83 | + if (!isset($groupedByCompany[ $companyName ])) { |
|
84 | + $groupedByCompany[ $companyName ] = [ ]; |
|
85 | 85 | } |
86 | - $groupedByCompany[$companyName][] = $product; |
|
86 | + $groupedByCompany[ $companyName ][ ] = $product; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | $this->printService->addLine("", "", "-"); |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | $this->printService->addLine("", "", "-"); |
98 | 98 | |
99 | 99 | foreach ($items as $item) { |
100 | - $productName = substr($item['product_name'], 0, 20); |
|
101 | - if (!empty($item['description'])) { |
|
102 | - $productName .= " " . substr($item['description'], 0, 10); |
|
100 | + $productName = substr($item[ 'product_name' ], 0, 20); |
|
101 | + if (!empty($item[ 'description' ])) { |
|
102 | + $productName .= " ".substr($item[ 'description' ], 0, 10); |
|
103 | 103 | } |
104 | - if (!empty($item['unity'])) { |
|
105 | - $productName .= " (" . $item['unity'] . ")"; |
|
104 | + if (!empty($item[ 'unity' ])) { |
|
105 | + $productName .= " (".$item[ 'unity' ].")"; |
|
106 | 106 | } |
107 | - $needed = str_pad($item['needed'], 4, " ", STR_PAD_LEFT); |
|
107 | + $needed = str_pad($item[ 'needed' ], 4, " ", STR_PAD_LEFT); |
|
108 | 108 | $this->printService->addLine($productName, $needed, " "); |
109 | 109 | } |
110 | 110 |