| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
- class SellProduct
- {
- private $user;
- private $db;
- public function __construct()
- {
- global $db, $user;
-
- $this->db = $db;
- $this->user = $user;
- }
- /**
- *
- */
- public function getProductByBarcode(string $barcode): ?Product
- {
- $result = null;
- $product = new Product($this->db);
- if ($product->fetch('', '', '', $barcode, 0, 0, 1) > 0) {
- $result = $product;
- }
- return $result;
- }
- /**
- *
- */
- public function getProductLot(int $productId, string $batchNumber): ?Productlot
- {
- $result = null;
- $productLot = new Productlot($this->db);
- if ($productLot->fetch(0, $productId, $batchNumber) > 0) {
- $result = $productLot;
- }
- return $result;
- }
- /**
- *
- */
- public function sellProductLot(Productlot $productLot): void
- {
- $productLot->array_options['options_usedat'] = time();
- $productLot->update($this->user);
- }
- }
|