Browse Source

Adaugat PDLs

Antonio Dobre 1 year ago
parent
commit
407edbc4e9

+ 32 - 0
Controller/FormController.php

@@ -220,6 +220,38 @@ class FormController
         echo $result;
     }
 
+    public function getPdls($db, $language)
+    {
+        $settingsRepository = new \MarketplaceRepository\SettingsRepository($db);
+        $settingsService = new \Core\App\Service\SettingsService(
+            $settingsRepository
+        );
+
+        $remoteStockRepository = new \Core\FacturisRepository\StockRepository(
+            $settingsRepository->getAuthApiKey(),
+            $settingsRepository->getAuthUsername(),
+            $settingsRepository->getAuthPassword(),
+            $settingsRepository->getAuthFiscalCode()
+        );
+
+        $pdl_gestiuni = $settingsService->getPdls($remoteStockRepository);
+
+        $result = '';
+        $result .= '<option value=""';
+        $result .= (isset($_GET['fsync_option_pdls']) && $_GET['fsync_option_pdls'] == '') ? ' selected="selected" ' : '';
+        $result .= ' >' . $language->get('filter_pdls_all') . '</option>';
+
+        if (!empty($pdl_gestiuni)) {
+            foreach ($pdl_gestiuni as $pdl_gestiune) {
+                $result .= '<option value=' . $pdl_gestiune['id'] . ' ';
+                $result .= (isset($_GET['fsync_option_pdls']) && $_GET['fsync_option_pdls'] == $pdl_gestiune['id']) ? ' selected="selected" ' : '';
+                $result .= ' >' . $pdl_gestiune['name'] . '</option>';
+            }
+        }
+
+        echo $result;
+    }
+
     public function checkLatestVersion($db, $language)
     {
         $settingsRepository = new \MarketplaceRepository\SettingsRepository($db);  

+ 2 - 2
Core/App/Service/SettingsService.php

@@ -73,9 +73,9 @@ class SettingsService
         return $this->settingsRepository->getShowObsOptions();
     }
 
-    public function checkLatestVersion($language, $version)
+    public function checkLatestVersion($language)
     {
-        $this->settingsRepository->checkLatestVersion($language, $version);
+        $this->settingsRepository->checkLatestVersion($language);
     }
 
 	public function getEnabledDisabledOptions()

+ 14 - 0
FacturisSync.php

@@ -66,6 +66,20 @@ class FacturisSync
         } 
     }
 
+    function getPdls()
+    {
+        try{
+            $formController = new \Controller\FormController();
+            $result = $formController->getPdls($this->db, $this->language);
+
+            echo $result;exit;
+        }
+        catch(\Exception $e) {
+			\Core\Log\FileLog::write($e->getMessage(), \Core\Log\FileLog::ERROR);
+            echo '';exit;
+        }
+    }
+
     function checkLatestVersion()
     {
         try{

+ 8 - 2
MarketplaceRepository/AvizeRepository.php

@@ -2,6 +2,8 @@
 
 namespace MarketplaceRepository;
 
+use Database;
+
 class AvizeRepository
 extends OrderRepository
 implements \Core\App\Repository\Marketplace\AvizeInterface
@@ -10,6 +12,10 @@ implements \Core\App\Repository\Marketplace\AvizeInterface
 
     public function getAll()
     {
+
+        $db = new Database();
+        $settings = $db->getSettings();
+
         $proformas = array();
         $proformaFactory = new \Core\App\Factory\AvizeFactory();
         $proformaFactory->setPrefix(self::PREFIX);
@@ -38,8 +44,8 @@ implements \Core\App\Repository\Marketplace\AvizeInterface
                     $result['idMarketpalce'] = self::MARKETPLACE_ID;
                     $result['dataFact'] = (array) $proformaObj;
                     $result['dataProd'] = array_merge($proformaProducts, $proformaTaxes);
-//TODO aici mai trebuie sa vedem cu PDLS ca este functie de presta mai jos nu shopi
-//                    $result['dataFact']['facturi_punct_de_lucru'] = \Configuration::get('fsync_option_pdls');
+
+                    $result['dataFact']['facturi_punct_de_lucru'] = isset($settings['fsync_option_pdls']) ? $settings['fsync_option_pdls'] : '';
 
                     $proformas[] = $result;
                 }   

+ 8 - 2
MarketplaceRepository/ExpfacturaRepository.php

@@ -2,6 +2,8 @@
 
 namespace MarketplaceRepository;
 
+use Database;
+
 class ExpfacturaRepository
 extends OrderRepository
 implements \Core\App\Repository\Marketplace\ExpfacturaInterface
@@ -10,6 +12,10 @@ implements \Core\App\Repository\Marketplace\ExpfacturaInterface
 
     public function getAll()
     {
+
+        $db = new Database();
+        $settings = $db->getSettings();
+
         $proformas = array();
         $proformaFactory = new \Core\App\Factory\ExpfacturaFactory();
         $proformaFactory->setPrefix(self::PREFIX);
@@ -38,8 +44,8 @@ implements \Core\App\Repository\Marketplace\ExpfacturaInterface
                     $result['idMarketpalce'] = self::MARKETPLACE_ID;
                     $result['dataFact'] = (array) $proformaObj;
                     $result['dataProd'] = array_merge($proformaProducts, $proformaTaxes);
-//TODO aici mai trebuie sa vedem cu PDLS ca este functie de presta mai jos nu shopi
-//                    $result['dataFact']['facturi_punct_de_lucru'] = \Configuration::get('fsync_option_pdls');
+
+                    $result['dataFact']['facturi_punct_de_lucru'] = isset($settings['fsync_option_pdls']) ? $settings['fsync_option_pdls'] : '';
 
                     $proformas[] = $result;
                 }   

+ 8 - 2
MarketplaceRepository/InvoiceRepository.php

@@ -2,6 +2,8 @@
 
 namespace MarketplaceRepository;
 
+use Database;
+
 class InvoiceRepository
 extends OrderRepository
 implements \Core\App\Repository\Marketplace\InvoiceInterface
@@ -10,6 +12,10 @@ implements \Core\App\Repository\Marketplace\InvoiceInterface
 
     public function getAll()
     {
+
+        $db = new Database();
+        $settings = $db->getSettings();
+
         $proformas = array();
         $proformaFactory = new \Core\App\Factory\InvoiceFactory();
         $proformaFactory->setPrefix(self::PREFIX);
@@ -38,8 +44,8 @@ implements \Core\App\Repository\Marketplace\InvoiceInterface
                     $result['idMarketpalce'] = self::MARKETPLACE_ID;
                     $result['dataFact'] = (array) $proformaObj;
                     $result['dataProd'] = array_merge($proformaProducts, $proformaTaxes);
-//TODO aici mai trebuie sa vedem cu PDLS ca este functie de presta mai jos nu shopi
-//                    $result['dataFact']['facturi_punct_de_lucru'] = \Configuration::get('fsync_option_pdls');
+
+                    $result['dataFact']['facturi_punct_de_lucru'] = isset($settings['fsync_option_pdls']) ? $settings['fsync_option_pdls'] : '';
 
                     $proformas[] = $result;
                 }   

+ 9 - 3
MarketplaceRepository/ProformaRepository.php

@@ -1,7 +1,9 @@
-<?php 
+<?php
 
 namespace MarketplaceRepository;
 
+use Database;
+
 class ProformaRepository 
 extends OrderRepository
 implements \Core\App\Repository\Marketplace\ProformaInterface
@@ -10,6 +12,10 @@ implements \Core\App\Repository\Marketplace\ProformaInterface
 
     public function getAll()
     {
+
+        $db = new Database();
+        $settings = $db->getSettings();
+
         $proformas = array();
         $proformaFactory = new \Core\App\Factory\ProformaFactory();
         $proformaFactory->setPrefix(self::PREFIX);
@@ -38,8 +44,8 @@ implements \Core\App\Repository\Marketplace\ProformaInterface
                     $result['idMarketpalce'] = self::MARKETPLACE_ID;
                     $result['dataFact'] = (array) $proformaObj;
                     $result['dataProd'] = array_merge($proformaProducts, $proformaTaxes);
-//TODO aici mai trebuie sa vedem cu PDLS ca este functie de presta mai jos nu shopi
-//                    $result['dataFact']['facturi_punct_de_lucru'] = \Configuration::get('fsync_option_pdls');
+
+                    $result['dataFact']['facturi_punct_de_lucru'] = isset($settings['fsync_option_pdls']) ? $settings['fsync_option_pdls'] : '';
 
                     $proformas[] = $result;
                 }   

+ 1 - 0
View/js/tab3.js

@@ -215,6 +215,7 @@ function getPdls()
 {
     var params = '';
     params += '&fsync_option_pdls=' + document.getElementById("fsync_option_pdls_hidden").value;
+    params += '&shop=' + document.getElementById("fsync_shop_hidden").value;
     params = encodeURI(params);
 
     var xhttp;

+ 5 - 0
ajax.php

@@ -17,6 +17,11 @@ if(isset($_GET['action']))
         $facturisSync->getPdlGestiuni();
     }
 
+    if($_GET['action'] == 'getPdls')
+    {
+        $facturisSync->getPdls();
+    }
+
     if($_GET['action'] == 'checkLatestVersion')
     {
         $facturisSync->checkLatestVersion();