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 ControleOnline\Entity\Spool; |
|
|
|
|
9
|
|
|
use Doctrine\ORM\EntityManagerInterface; |
|
|
|
|
10
|
|
|
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
|
|
|
|
11
|
|
|
as Security; |
12
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
|
|
|
13
|
|
|
|
14
|
|
|
class ProductService |
15
|
|
|
{ |
16
|
|
|
public function __construct( |
17
|
|
|
private EntityManagerInterface $manager, |
18
|
|
|
private Security $security, |
19
|
|
|
private PrintService $printService, |
|
|
|
|
20
|
|
|
private PeopleService $PeopleService |
|
|
|
|
21
|
|
|
) {} |
22
|
|
|
|
23
|
|
|
public function securityFilter(QueryBuilder $queryBuilder, $resourceClass = null, $applyTo = null, $rootAlias = null): void |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
// $this->PeopleService->checkCompany('company', $queryBuilder, $resourceClass, $applyTo, $rootAlias); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function getProductsInventory(People $company): array |
29
|
|
|
{ |
30
|
|
|
return $this->manager->getRepository(Product::class)->getProductsInventory($company); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function productsInventoryPrintData(People $provider, Device $device): Spool |
34
|
|
|
{ |
35
|
|
|
$products = $this->getProductsInventory($provider); |
36
|
|
|
|
37
|
|
|
$groupedByInventory = []; |
38
|
|
|
foreach ($products as $product) { |
39
|
|
|
$inventoryName = $product['inventory_name']; |
40
|
|
|
if (!isset($groupedByInventory[$inventoryName])) { |
41
|
|
|
$groupedByInventory[$inventoryName] = []; |
42
|
|
|
} |
43
|
|
|
$groupedByInventory[$inventoryName][] = $product; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
foreach ($groupedByInventory as $inventoryName => $items) { |
47
|
|
|
$companyName = $items[0]['company_name']; |
48
|
|
|
$this->printService->addLine("", "", "-"); |
49
|
|
|
$this->printService->addLine($companyName, "", " "); |
50
|
|
|
$this->printService->addLine("INVENTARIO: " . $inventoryName, "", " "); |
51
|
|
|
$this->printService->addLine("", "", "-"); |
52
|
|
|
$this->printService->addLine("Produto", "Disponivel", " "); |
53
|
|
|
$this->printService->addLine("", "", "-"); |
54
|
|
|
|
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); |
59
|
|
|
} |
60
|
|
|
$productName .= " (" . $item['productUnit'] . ")"; |
61
|
|
|
$available = str_pad($item['available'], 4, " ", STR_PAD_LEFT); |
62
|
|
|
$this->printService->addLine($productName, $available, " "); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
$this->printService->addLine("", "", "-"); |
66
|
|
|
} |
67
|
|
|
return $this->printService->generatePrintData($device, $provider); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function getPurchasingSuggestion(People $company) |
71
|
|
|
{ |
72
|
|
|
return $this->manager->getRepository(Product::class)->getPurchasingSuggestion($company); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function purchasingSuggestionPrintData(People $provider, Device $device): Spool |
76
|
|
|
{ |
77
|
|
|
$products = $this->getPurchasingSuggestion($provider); |
78
|
|
|
|
79
|
|
|
$groupedByCompany = []; |
80
|
|
|
foreach ($products as $product) { |
81
|
|
|
$companyName = $product['company_name']; |
82
|
|
|
if (!isset($groupedByCompany[$companyName])) { |
83
|
|
|
$groupedByCompany[$companyName] = []; |
84
|
|
|
} |
85
|
|
|
$groupedByCompany[$companyName][] = $product; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
$this->printService->addLine("", "", "-"); |
89
|
|
|
$this->printService->addLine("SUGESTAO DE COMPRA", "", " "); |
90
|
|
|
$this->printService->addLine("", "", "-"); |
91
|
|
|
|
92
|
|
|
foreach ($groupedByCompany as $companyName => $items) { |
93
|
|
|
$this->printService->addLine($companyName, "", " "); |
94
|
|
|
$this->printService->addLine("", "", "-"); |
95
|
|
|
$this->printService->addLine("Produto", "Necessario", " "); |
96
|
|
|
$this->printService->addLine("", "", "-"); |
97
|
|
|
|
98
|
|
|
foreach ($items as $item) { |
99
|
|
|
$productName = substr($item['product_name'], 0, 20); |
100
|
|
|
if (!empty($item['description'])) { |
101
|
|
|
$productName .= " " . substr($item['description'], 0, 10); |
102
|
|
|
} |
103
|
|
|
if (!empty($item['unity'])) { |
104
|
|
|
$productName .= " (" . $item['unity'] . ")"; |
105
|
|
|
} |
106
|
|
|
$needed = str_pad($item['needed'], 4, " ", STR_PAD_LEFT); |
107
|
|
|
$this->printService->addLine($productName, $needed, " "); |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
$this->printService->addLine("", "", "-"); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
return $this->printService->generatePrintData($device, $provider); |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|
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