1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Service; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Device; |
|
|
|
|
6
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
7
|
|
|
use ControleOnline\Entity\Product; |
8
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
9
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
10
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
|
|
|
11
|
|
|
|
12
|
|
|
class ProductService |
13
|
|
|
{ |
14
|
|
|
public function __construct( |
15
|
|
|
private EntityManagerInterface $manager, |
16
|
|
|
private Security $security, |
17
|
|
|
private PrintService $printService, |
|
|
|
|
18
|
|
|
private PeopleService $PeopleService |
|
|
|
|
19
|
|
|
) {} |
20
|
|
|
|
21
|
|
|
public function securityFilter(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
// $this->PeopleService->checkCompany('company', $queryBuilder, $resourceClass, $applyTo, $rootAlias); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getProductsInventory(?People $company): array |
27
|
|
|
{ |
28
|
|
|
return $this->manager->getRepository(Product::class)->getProductsInventory($company); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function productsInventoryPrintData(?People $provider, string $printType, string $deviceType) |
32
|
|
|
{ |
33
|
|
|
$products = $this->getProductsInventory($provider); |
34
|
|
|
|
35
|
|
|
$groupedByInventory = []; |
36
|
|
|
foreach ($products as $product) { |
37
|
|
|
$inventoryName = $product['inventory_name']; |
38
|
|
|
if (!isset($groupedByInventory[$inventoryName])) { |
39
|
|
|
$groupedByInventory[$inventoryName] = []; |
40
|
|
|
} |
41
|
|
|
$groupedByInventory[$inventoryName][] = $product; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
foreach ($groupedByInventory as $inventoryName => $items) { |
45
|
|
|
$companyName = $items[0]['company_name'] ; |
46
|
|
|
$this->printService->addLine("", "", "-"); |
47
|
|
|
$this->printService->addLine($companyName, "", " "); |
48
|
|
|
$this->printService->addLine("INVENTARIO: " . $inventoryName, "", " "); |
49
|
|
|
$this->printService->addLine("", "", "-"); |
50
|
|
|
$this->printService->addLine("Produto", "Disponivel", " "); |
51
|
|
|
$this->printService->addLine("", "", "-"); |
52
|
|
|
|
53
|
|
|
foreach ($items as $item) { |
54
|
|
|
$productName = substr($item['product_name'], 0, 20); |
55
|
|
|
if (!empty($item['description'])) { |
56
|
|
|
$productName .= " " . substr($item['description'], 0, 10); |
57
|
|
|
} |
58
|
|
|
$productName .= " (" . $item['productUnit'] . ")"; |
59
|
|
|
$available = str_pad($item['available'], 4, " ", STR_PAD_LEFT); |
60
|
|
|
$this->printService->addLine($productName, $available, " "); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$this->printService->addLine("", "", "-"); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
return $this->printService->generatePrintData($printType, $deviceType); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
public function getPurchasingSuggestion(People $company) |
70
|
|
|
{ |
71
|
|
|
return $this->manager->getRepository(Product::class)->getPurchasingSuggestion($company); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
public function purchasingSuggestionPrintData(?People $provider, string $printType, string $deviceType) |
75
|
|
|
{ |
76
|
|
|
$products = $this->getPurchasingSuggestion($provider); |
|
|
|
|
77
|
|
|
|
78
|
|
|
$groupedByCompany = []; |
79
|
|
|
foreach ($products as $product) { |
80
|
|
|
$companyName = $product['company_name'] ; |
81
|
|
|
if (!isset($groupedByCompany[$companyName])) { |
82
|
|
|
$groupedByCompany[$companyName] = []; |
83
|
|
|
} |
84
|
|
|
$groupedByCompany[$companyName][] = $product; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
$this->printService->addLine("", "", "-"); |
88
|
|
|
$this->printService->addLine("SUGESTAO DE COMPRA", "", " "); |
89
|
|
|
$this->printService->addLine("", "", "-"); |
90
|
|
|
|
91
|
|
|
foreach ($groupedByCompany as $companyName => $items) { |
92
|
|
|
$this->printService->addLine($companyName, "", " "); |
93
|
|
|
$this->printService->addLine("", "", "-"); |
94
|
|
|
$this->printService->addLine("Produto", "Necessario", " "); |
95
|
|
|
$this->printService->addLine("", "", "-"); |
96
|
|
|
|
97
|
|
|
foreach ($items as $item) { |
98
|
|
|
$productName = substr($item['product_name'], 0, 20); |
99
|
|
|
if (!empty($item['description'])) { |
100
|
|
|
$productName .= " " . substr($item['description'], 0, 10); |
101
|
|
|
} |
102
|
|
|
if (!empty($item['unity'])) { |
103
|
|
|
$productName .= " (" . $item['unity'] . ")"; |
104
|
|
|
} |
105
|
|
|
$needed = str_pad($item['needed'], 4, " ", STR_PAD_LEFT); |
106
|
|
|
$this->printService->addLine($productName, $needed, " "); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
$this->printService->addLine("", "", "-"); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return $this->printService->generatePrintData($printType, $deviceType); |
113
|
|
|
} |
114
|
|
|
} |
115
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths