Browse Source

Adaugare sync aviz, proforma, factura

Antonio Dobre 1 year ago
parent
commit
913fea1562
49 changed files with 4198 additions and 1638 deletions
  1. 2 0
      .gitignore
  2. 26 2
      Controller/FormController.php
  3. 350 2
      Controller/OrderOrProformaController.php
  4. 58 1
      Controller/SyncController.php
  5. 387 0
      Core/App/Entity/Avize.php
  6. 387 0
      Core/App/Entity/Expfactura.php
  7. 386 0
      Core/App/Entity/Invoice.php
  8. 255 0
      Core/App/Entity/Settings.php
  9. 99 0
      Core/App/Factory/AvizeFactory.php
  10. 67 0
      Core/App/Factory/AvizeItemFactory.php
  11. 99 0
      Core/App/Factory/ExpfacturaFactory.php
  12. 67 0
      Core/App/Factory/ExpfacturaItemFactory.php
  13. 99 0
      Core/App/Factory/InvoiceFactory.php
  14. 67 0
      Core/App/Factory/InvoiceItemFactory.php
  15. 45 3
      Core/App/Factory/SettingsFactory.php
  16. 31 0
      Core/App/Repository/Facturis/AvizeInterface.php
  17. 31 0
      Core/App/Repository/Facturis/ExpfacturaInterface.php
  18. 34 0
      Core/App/Repository/Facturis/InvoiceInterface.php
  19. 1 0
      Core/App/Repository/Facturis/StockInterface.php
  20. 34 0
      Core/App/Repository/Marketplace/AvizeInterface.php
  21. 34 0
      Core/App/Repository/Marketplace/ExpfacturaInterface.php
  22. 36 0
      Core/App/Repository/Marketplace/InvoiceInterface.php
  23. 2 0
      Core/App/Repository/Marketplace/ProformaInterface.php
  24. 5 2
      Core/App/Repository/Marketplace/SettingsInterface.php
  25. 109 0
      Core/App/Service/AvizeService.php
  26. 109 0
      Core/App/Service/ExpfacturaService.php
  27. 84 0
      Core/App/Service/InvoiceService.php
  28. 32 1
      Core/App/Service/ProformaService.php
  29. 21 6
      Core/App/Service/SettingsService.php
  30. 104 0
      Core/FacturisRepository/AvizeRepository.php
  31. 101 0
      Core/FacturisRepository/ExpfacturaRepository.php
  32. 57 0
      Core/FacturisRepository/InvoiceRepository.php
  33. 119 15
      Core/FacturisRepository/Repository.php
  34. 79 19
      Core/Language/English.php
  35. 82 17
      Core/Language/Romanian.php
  36. 3 0
      Database.php
  37. 121 0
      MarketplaceRepository/AvizeRepository.php
  38. 121 0
      MarketplaceRepository/ExpfacturaRepository.php
  39. 121 0
      MarketplaceRepository/InvoiceRepository.php
  40. 4 1
      MarketplaceRepository/ProformaRepository.php
  41. 40 1
      MarketplaceRepository/SettingsRepository.php
  42. 11 5
      View/css/form.css
  43. 15 2
      View/css/main.css
  44. 164 2
      View/js/tab3.js
  45. 48 2
      View/main.php
  46. 28 0
      View/tab3.php
  47. 23 0
      View/tab4.php
  48. 0 1534
      logs/file-.log
  49. 0 23
      logs/file-facturis-online-dev-2.log

+ 2 - 0
.gitignore

@@ -1 +1,3 @@
 .idea/
+logs/file-.log
+logs/file-facturis-online-dev-2.log

+ 26 - 2
Controller/FormController.php

@@ -64,9 +64,28 @@ class FormController
         $data['tab_name_3_1'] = $language->get('tab_name_3_1'); 
         $data['tab_name_3_2'] = $language->get('tab_name_3_2'); 
 
-		$data['with_discount'] = $language->get('with_discount'); 
+        $data['proforma_invoice_options_title'] = $language->get('proforma_invoice_options_title');
+        $data['add_proforma'] = $language->get('add_proforma');
+        $data['add_avize'] = $language->get('add_avize');
+        $data['add_expfactura'] = $language->get('add_expfactura');
+		$data['with_discount'] = $language->get('with_discount');
         $data['with_discount_desc'] = $language->get('with_discount_desc'); 
-        //tab4 
+        $data['add_invoice'] = $language->get('add_invoice');
+        $data['view_proforma'] = $language->get('view_proforma');
+        $data['view_invoice'] = $language->get('view_invoice');
+        $data['view_avize'] = $language->get('view_avize');
+        $data['view_expfactura'] = $language->get('view_expfactura');
+        $data['edit_proforma'] = $language->get('edit_proforma');
+        $data['edit_invoice'] = $language->get('edit_invoice');
+        $data['edit_avize'] = $language->get('edit_avize');
+        $data['edit_expfactura'] = $language->get('edit_expfactura');
+
+        $data['fosync_proforma_series2_label'] = $language->get('fosync_proforma_series2_label');
+        $data['fosync_invoice_series_label'] = $language->get('fosync_invoice_series_label');
+        $data['fosync_avize_series2_label'] = $language->get('fosync_avize_series2_label');
+        $data['fosync_expfactura_series2_label'] = $language->get('fosync_expfactura_series2_label');
+
+        //tab4
         $data['tab_name_4'] = $language->get('tab_name_4'); 
 
 		//tab 5
@@ -88,6 +107,8 @@ class FormController
         }
         $data['sync_orders_as'] = $language->get('sync_orders_as');
         $data['proforma_series'] = $language->get('proforma_series');
+        $data['avize_series'] = $language->get('avize_series');
+        $data['expfactura_series'] = $language->get('expfactura_series');
         $data['days_ago'] = $language->get('days_ago');
         $data['auto_order_sync'] = $language->get('auto_order_sync');
         $data['auto_stock_sync'] = $language->get('auto_stock_sync');
@@ -115,9 +136,12 @@ class FormController
 			}
         }
         $data['filter_stock'] = $language->get('filter_stock');
+        $data['filter_pdls'] = $language->get('filter_pdls');
         $data['loading_data_please_wait'] = $language->get('loading_data_please_wait');
 
         $data['option_proformaserie_error'] = $language->get('option_proformaserie_error');
+        $data['option_avizeserie_error'] = $language->get('option_avizeserie_error');
+        $data['option_expfacturaserie_error'] = $language->get('option_expfacturaserie_error');
         $data['option_daysago_error'] = $language->get('option_daysago_error');
         $data['version_text'] = $language->get('version_text');
         

+ 350 - 2
Controller/OrderOrProformaController.php

@@ -26,6 +26,15 @@ class OrderOrProformaController
             $this->syncProformas();
             return \Core\App\Factory\SettingsFactory::SELECT_PROFORMA;
         }
+        if ($this->settingsRepository->getOptionOrderOrProforma() == \Core\App\Factory\SettingsFactory::SELECT_EXPFACTURA) {
+            $this->syncExpfactura();
+            return \Core\App\Factory\SettingsFactory::SELECT_EXPFACTURA;
+        }
+
+        if ($this->settingsRepository->getOptionOrderOrProforma() == \Core\App\Factory\SettingsFactory::SELECT_AVIZE) {
+            $this->syncAvize();
+            return \Core\App\Factory\SettingsFactory::SELECT_AVIZE;
+        }
     }
 
     public function syncOrders()
@@ -114,7 +123,97 @@ class OrderOrProformaController
             $facturisProformaRepository,
             $this->settingsRepository
         );
-        
+
+        $service->sync();
+    }
+
+    public function syncAvize()
+    {
+        $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $marketplaceAvizeRepository = new \MarketplaceRepository\AvizeRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+
+
+        $facturisAvizeRepository = new \Core\FacturisRepository\AvizeRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $service = new \Core\App\Service\AvizeService(
+            $marketplaceAvizeRepository,
+            $marketplaceProductRepository,
+            $facturisCustomerRepository,
+            $facturisProductRepository,
+            $facturisAvizeRepository,
+            $this->settingsRepository
+        );
+
+        $service->sync();
+    }
+
+    public function syncExpfactura()
+    {
+        $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $marketplaceExpfacturaRepository = new \MarketplaceRepository\ExpfacturaRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+
+
+        $facturisExpfacturaRepository = new \Core\FacturisRepository\ExpfacturaRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $service = new \Core\App\Service\ExpfacturaService(
+            $marketplaceExpfacturaRepository,
+            $marketplaceProductRepository,
+            $facturisCustomerRepository,
+            $facturisProductRepository,
+            $facturisExpfacturaRepository,
+            $this->settingsRepository
+        );
+
         $service->sync();
     }
 
@@ -126,5 +225,254 @@ class OrderOrProformaController
         }
     }
 
+    public function addProforma($orderId)
+    {
+        $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $marketplaceProformaRepository = new \MarketplaceRepository\ProformaRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+
+        $facturisProformaRepository = new \Core\FacturisRepository\ProformaRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $service = new \Core\App\Service\ProformaService(
+            $marketplaceProformaRepository,
+            $marketplaceProductRepository,
+            $facturisCustomerRepository,
+            $facturisProductRepository,
+            $facturisProformaRepository,
+            $this->settingsRepository
+        );
+
+        $result = $service->add($orderId);
+        return $result;
+    }
+
+    public function addAvize($orderId)
+    {
+        $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
 
-}
+        $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $marketplaceAvizeRepository = new \MarketplaceRepository\AvizeRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+
+        $facturisAvizeRepository = new \Core\FacturisRepository\AvizeRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $service = new \Core\App\Service\AvizeService(
+            $marketplaceAvizeRepository,
+            $marketplaceProductRepository,
+            $facturisCustomerRepository,
+            $facturisProductRepository,
+            $facturisAvizeRepository,
+            $this->settingsRepository
+        );
+
+        $result = $service->add($orderId);
+        return $result;
+    }
+
+    public function addExpfactura($orderId)
+    {
+        $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $marketplaceExpfacturaRepository = new \MarketplaceRepository\ExpfacturaRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+
+        $facturisExpfacturaRepository = new \Core\FacturisRepository\ExpfacturaRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $service = new \Core\App\Service\ExpfacturaService(
+            $marketplaceExpfacturaRepository,
+            $marketplaceProductRepository,
+            $facturisCustomerRepository,
+            $facturisProductRepository,
+            $facturisExpfacturaRepository,
+            $this->settingsRepository
+        );
+
+        $result = $service->add($orderId);
+        return $result;
+    }
+
+    public function viewProforma($orderId)
+    {
+        $marketplaceProformaRepository = new \MarketplaceRepository\ProformaRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $factId = $marketplaceProformaRepository->getFactId($orderId);
+
+        $facturisProformaRepository = new \Core\FacturisRepository\ProformaRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisProformaRepository->view($factId);
+    }
+
+    public function viewAvize($orderId)
+    {
+        $marketplaceAvizeRepository = new \MarketplaceRepository\AvizeRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $factId = $marketplaceAvizeRepository->getFactId($orderId);
+
+        $facturisAvizeRepository = new \Core\FacturisRepository\AvizeRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisAvizeRepository->view($factId);
+    }
+
+    public function viewExpfactura($orderId)
+    {
+        $marketplaceExpfacturaRepository = new \MarketplaceRepository\ExpfacturaRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $factId = $marketplaceExpfacturaRepository->getFactId($orderId);
+
+        $facturisExpfacturaRepository = new \Core\FacturisRepository\ExpfacturaRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisExpfacturaRepository->view($factId);
+    }
+
+    public function addInvoice($orderId)
+    {
+        $facturisCustomerRepository = new \Core\FacturisRepository\CustomerRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisProductRepository = new \Core\FacturisRepository\ProductRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $marketplaceInvoiceRepository = new \MarketplaceRepository\InvoiceRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $marketplaceProductRepository = new \MarketplaceRepository\ProductRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+
+        $facturisInvoiceRepository = new \Core\FacturisRepository\InvoiceRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $service = new \Core\App\Service\InvoiceService(
+            $marketplaceInvoiceRepository,
+            $marketplaceProductRepository,
+            $facturisCustomerRepository,
+            $facturisProductRepository,
+            $facturisInvoiceRepository,
+            $this->settingsRepository
+        );
+
+        return $service->add($orderId);
+}
+
+    public function viewInvoice($orderId)
+    {
+        $marketplaceInvoiceRepository = new \MarketplaceRepository\InvoiceRepository(
+            $this->settingsRepository->getToken(),
+            $this->settingsRepository->getShop()
+        );
+        $factId = $marketplaceInvoiceRepository->getFactId($orderId);
+
+        $facturisInvoiceRepository = new \Core\FacturisRepository\InvoiceRepository(
+            $this->settingsRepository->getAuthApiKey(),
+            $this->settingsRepository->getAuthUsername(),
+            $this->settingsRepository->getAuthPassword(),
+            $this->settingsRepository->getAuthFiscalCode()
+        );
+
+        $facturisInvoiceRepository->view($factId);
+    }
+}

+ 58 - 1
Controller/SyncController.php

@@ -62,6 +62,13 @@ class SyncController
             return $this->language->get('success_sync_proforma');
         }
         
+        if ($response == \Core\App\Factory\SettingsFactory::SELECT_EXPFACTURA) {
+            return $this->language->get('success_sync_expfactura');
+        }
+
+        if ($response == \Core\App\Factory\SettingsFactory::SELECT_AVIZE) {
+            return $this->language->get('success_sync_avize');
+        }
     }
 
     public function syncStock()
@@ -87,5 +94,55 @@ class SyncController
         $stockController->autoSync();
     }
   
-    
+    public function addProforma($orderId)
+    {
+        $controller = new \Controller\OrderOrProformaController(
+            $this->settingsRepository
+        );
+
+        $result = $controller->addProforma($orderId);
+        if (isset($result['serie_fact']) && isset($result['numar_fact'])) {
+            return  $this->language->get(
+                'success_add_proforma_a',
+                array($result['serie_fact'], $result['numar_fact'], $orderId)
+            );
+        } else {
+            return $this->language->get('success_add_proforma_b', array($orderId));
+        }
+    }
+
+    public function viewProforma($orderId)
+    {
+        $controller = new \Controller\OrderOrProformaController(
+            $this->settingsRepository
+        );
+
+        $controller->viewProforma($orderId);
+    }
+
+    public function addInvoice($orderId)
+    {
+        $controller = new \Controller\OrderOrProformaController(
+            $this->settingsRepository
+        );
+
+        $result = $controller->addInvoice($orderId);
+        if (isset($result['serie_fact']) && isset($result['numar_fact'])) {
+            return $this->language->get(
+                'success_add_invoice_a',
+                array($result['serie_fact'], $result['numar_fact'], $orderId)
+            );
+        } else {
+            return  $this->language->get('success_add_invoice_b', array($orderId));
+        }
+    }
+
+    public function viewInvoice($orderId)
+    {
+        $controller = new \Controller\OrderOrProformaController(
+            $this->settingsRepository
+        );
+
+        $controller->viewInvoice($orderId);
+    }
 }

+ 387 - 0
Core/App/Entity/Avize.php

@@ -0,0 +1,387 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Entity;
+
+class Avize
+{
+    public $facturi_key;
+    public $facturi_punct_de_lucru;
+    public $facturi_gestiune;
+    public $facturi_data;
+    public $facturi_data_scadenta;
+    public $facturi_cota_tva;
+    public $facturi_moneda;
+    public $facturi_serie;
+    public $facturi_numar;
+    public $facturi_obs_up;
+    public $facturi_mod_plata;
+    public $facturi_status;
+    public $facturi_client_id;
+    public $facturi_nume_client;
+    public $facturi_tip_persoana;
+    public $facturi_codf_client;
+    public $facturi_nrreg_client;
+    public $facturi_sediu_client;
+    public $facturi_judet_client;
+    public $facturi_oras_client;
+    public $facturi_clienti_tel;
+    public $facturi_email_client;
+    public $facturi_clienti_adresa_livrare;
+    public $facturi_cont_client;
+    public $facturi_banca_client;
+    public $facturi_obs_client;
+    public $facturi_clienti_oras_livrare;
+    public $facturi_clienti_judet_livrare;
+
+    public $facturi_nume_delegat;
+    public $facturi_act_delegat;
+    public $facturi_obs_delegat;
+    public $fk_agent_name;
+    public $unique_id_insert;
+
+    public function getFacturiKey()
+    {
+        return $this->facturi_key;
+    }
+
+    public function getFacturiPunctDeLucru()
+    {
+        return $this->facturi_punct_de_lucru;
+    }
+
+    public function getFacturiGestiune()
+    {
+        return $this->facturi_gestiune;
+    }
+
+    public function getFacturiData()
+    {
+        return $this->facturi_data;
+    }
+    public function getFacturiDataScadenta()
+    {
+        return $this->facturi_data_scadenta;
+    }
+
+    public function getFacturiCotaTva()
+    {
+        return $this->facturi_cota_tva;
+    }
+
+    public function getFacturiMoneda()
+    {
+        return $this->facturi_moneda;
+    }
+
+    public function getFacturiSerie()
+    {
+        return $this->facturi_serie;
+    }
+    public function getFacturiNumar()
+    {
+        return $this->facturi_numar;
+    }
+
+    public function getFacturiObsUp()
+    {
+        return $this->facturi_obs_up;
+    }
+
+    public function getFacturiModPlata()
+    {
+        return $this->facturi_mod_plata;
+    }
+
+    public function getFacturiStatus()
+    {
+        return $this->facturi_status;
+    }
+    public function getFacturiClientId()
+    {
+        return $this->facturi_client_id;
+    }
+
+    public function getFacturiNumeClient()
+    {
+        return $this->facturi_nume_client;
+    }
+
+    public function getFacturiTipPersoana()
+    {
+        return $this->facturi_tip_persoana;
+    }
+
+    public function getFacturiCodfClient()
+    {
+        return $this->facturi_codf_client;
+    }
+
+    public function getFacturiNrregClient()
+    {
+        return $this->facturi_nrreg_client;
+    }
+
+    public function getFacturiSediuClient()
+    {
+        return $this->facturi_sediu_client;
+    }
+
+    public function getFacturiJudetClient()
+    {
+        return $this->facturi_judet_client;
+    }
+
+    public function getFacturiOrasClient()
+    {
+        return $this->facturi_oras_client;
+    }
+
+    public function getFacturiClientiTel()
+    {
+        return $this->facturi_clienti_tel;
+    }
+
+    public function getFacturiEmailClient()
+    {
+        return $this->facturi_email_client;
+    }
+
+    public function getFacturiClientiAdresaLivrare()
+    {
+        return $this->facturi_clienti_adresa_livrare;
+    }
+
+    public function getFacturiContClient()
+    {
+        return $this->facturi_cont_client;
+    }
+
+    public function getFacturiBancaClient()
+    {
+        return $this->facturi_banca_client;
+    }
+
+    public function getFacturiObsClient()
+    {
+        return $this->facturi_obs_client;
+    }
+
+    public function getFacturiClientiOrasLivrare()
+    {
+        return $this->facturi_clienti_oras_livrare;
+    }
+
+    public function getFacturiClientiJudetLivrare()
+    {
+        return $this->facturi_clienti_judet_livrare;
+    }
+
+    public function getFacturiNumeDelegat()
+    {
+        return $this->facturi_nume_delegat;
+    }
+    public function getFacturiActDelegat()
+    {
+        return $this->facturi_act_delegat;
+    }
+
+    public function getFacturiObsDelegat()
+    {
+        return $this->facturi_obs_delegat;
+    }
+
+    public function getFkAgentName()
+    {
+        return $this->fk_agent_name;
+    }
+
+    public function setFacturiKey($facturi_key)
+    {
+        $this->facturi_key = $facturi_key;
+    }
+
+    public function setFacturiPunctDeLucru($facturi_punct_de_lucru)
+    {
+        $this->facturi_punct_de_lucru = $facturi_punct_de_lucru;
+    }
+
+    public function setFacturiGestiune($facturi_gestiune)
+    {
+        $this->facturi_gestiune = $facturi_gestiune;
+    }
+
+    public function setFacturiData($facturi_data)
+    {
+        $this->facturi_data = $facturi_data;
+    }
+    public function setFacturiDataScadenta($facturi_data_scadenta)
+    {
+        $this->facturi_data_scadenta = $facturi_data_scadenta;
+    }
+
+    public function setFacturiCotaTva($facturi_cota_tva)
+    {
+        $this->facturi_cota_tva = $facturi_cota_tva;
+    }
+
+    public function setFacturiMoneda($facturi_moneda)
+    {
+        $this->facturi_moneda = $facturi_moneda;
+    }
+
+    public function setFacturiSerie($facturi_serie)
+    {
+        $this->facturi_serie = $facturi_serie;
+    }
+    public function setFacturiNumar($facturi_numar)
+    {
+        $this->facturi_numar = $facturi_numar;
+    }
+
+    public function setFacturiObsUp($facturi_obs_up)
+    {
+        $this->facturi_obs_up = $facturi_obs_up;
+    }
+
+    public function setFacturiModPlata($facturi_mod_plata)
+    {
+        $this->facturi_mod_plata = $facturi_mod_plata;
+    }
+
+    public function setFacturiStatus($facturi_status)
+    {
+        $this->facturi_status = $facturi_status;
+    }
+    public function setFacturiClientId($facturi_client_id)
+    {
+        $this->facturi_client_id = $facturi_client_id;
+    }
+
+    public function setFacturiNumeClient($facturi_nume_client)
+    {
+        $this->facturi_nume_client = $facturi_nume_client;
+    }
+
+    public function setFacturiTipPersoana($facturi_tip_persoana)
+    {
+        $this->facturi_tip_persoana = $facturi_tip_persoana;
+    }
+
+    public function setFacturiCodfClient($facturi_codf_client)
+    {
+        $this->facturi_codf_client = $facturi_codf_client;
+    }
+
+    public function setFacturiNrregClient($facturi_nrreg_client)
+    {
+        $this->facturi_nrreg_client = $facturi_nrreg_client;
+    }
+
+    public function setFacturiSediuClient($facturi_sediu_client)
+    {
+        $this->facturi_sediu_client = $facturi_sediu_client;
+    }
+
+    public function setFacturiJudetClient($facturi_judet_client)
+    {
+        $this->facturi_judet_client = $facturi_judet_client;
+    }
+
+    public function setFacturiOrasClient($facturi_oras_client)
+    {
+        $this->facturi_oras_client = $facturi_oras_client;
+    }
+
+    public function setFacturiClientiTel($facturi_clienti_tel)
+    {
+        $this->facturi_clienti_tel = $facturi_clienti_tel;
+    }
+
+    public function setFacturiEmailClient($facturi_email_client)
+    {
+        $this->facturi_email_client = $facturi_email_client;
+    }
+
+    public function setFacturiClientiAdresaLivrare($facturi_clienti_adresa_livrare)
+    {
+        $this->facturi_clienti_adresa_livrare = $facturi_clienti_adresa_livrare;
+    }
+
+    public function setFacturiContClient($facturi_cont_client)
+    {
+        $this->facturi_cont_client = $facturi_cont_client;
+    }
+
+    public function setFacturiBancaClient($facturi_banca_client)
+    {
+        $this->facturi_banca_client = $facturi_banca_client;
+    }
+
+    public function setFacturiObsClient($facturi_obs_client)
+    {
+        $this->facturi_obs_client = $facturi_obs_client;
+    }
+
+    public function setFacturiClientiOrasLivrare($facturi_clienti_oras_livrare)
+    {
+        $this->facturi_clienti_oras_livrare = $facturi_clienti_oras_livrare;
+    }
+
+    public function setFacturiClientiJudetLivrare($facturi_clienti_judet_livrare)
+    {
+        $this->facturi_clienti_judet_livrare = $facturi_clienti_judet_livrare;
+    }
+
+    public function setFacturiNumeDelegat($facturi_nume_delegat)
+    {
+        $this->facturi_nume_delegat = $facturi_nume_delegat;
+    }
+    public function setFacturiActDelegat($facturi_act_delegat)
+    {
+        $this->facturi_act_delegat = $facturi_act_delegat;
+    }
+
+    public function setFacturiObsDelegat($facturi_obs_delegat)
+    {
+        $this->facturi_obs_delegat = $facturi_obs_delegat;
+    }
+
+    public function setFkAgentName($fk_agent_name)
+    {
+        $this->fk_agent_name = $fk_agent_name;
+    }
+
+    public function getUniqueIdInsert()
+    {
+        $this->unique_id_insert;
+    }
+
+    public function setUniqueIdInsert($unique_id_insert)
+    {
+        $this->unique_id_insert = $unique_id_insert;
+    }
+}

+ 387 - 0
Core/App/Entity/Expfactura.php

@@ -0,0 +1,387 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Entity;
+
+class Expfactura
+{
+    public $facturi_key;
+    public $facturi_punct_de_lucru;
+    public $facturi_gestiune;
+    public $facturi_data;
+    public $facturi_data_scadenta;
+    public $facturi_cota_tva;
+    public $facturi_moneda;
+    public $facturi_serie;
+    public $facturi_numar;
+    public $facturi_obs_up;
+    public $facturi_mod_plata;
+    public $facturi_status;
+    public $facturi_client_id;
+    public $facturi_nume_client;
+    public $facturi_tip_persoana;
+    public $facturi_codf_client;
+    public $facturi_nrreg_client;
+    public $facturi_sediu_client;
+    public $facturi_judet_client;
+    public $facturi_oras_client;
+    public $facturi_clienti_tel;
+    public $facturi_email_client;
+    public $facturi_clienti_adresa_livrare;
+    public $facturi_cont_client;
+    public $facturi_banca_client;
+    public $facturi_obs_client;
+    public $facturi_clienti_oras_livrare;
+    public $facturi_clienti_judet_livrare;
+
+    public $facturi_nume_delegat;
+    public $facturi_act_delegat;
+    public $facturi_obs_delegat;
+    public $fk_agent_name;
+    public $unique_id_insert;
+
+    public function getFacturiKey()
+    {
+        return $this->facturi_key;
+    }
+
+    public function getFacturiPunctDeLucru()
+    {
+        return $this->facturi_punct_de_lucru;
+    }
+
+    public function getFacturiGestiune()
+    {
+        return $this->facturi_gestiune;
+    }
+
+    public function getFacturiData()
+    {
+        return $this->facturi_data;
+    }
+    public function getFacturiDataScadenta()
+    {
+        return $this->facturi_data_scadenta;
+    }
+
+    public function getFacturiCotaTva()
+    {
+        return $this->facturi_cota_tva;
+    }
+
+    public function getFacturiMoneda()
+    {
+        return $this->facturi_moneda;
+    }
+
+    public function getFacturiSerie()
+    {
+        return $this->facturi_serie;
+    }
+    public function getFacturiNumar()
+    {
+        return $this->facturi_numar;
+    }
+
+    public function getFacturiObsUp()
+    {
+        return $this->facturi_obs_up;
+    }
+
+    public function getFacturiModPlata()
+    {
+        return $this->facturi_mod_plata;
+    }
+
+    public function getFacturiStatus()
+    {
+        return $this->facturi_status;
+    }
+    public function getFacturiClientId()
+    {
+        return $this->facturi_client_id;
+    }
+
+    public function getFacturiNumeClient()
+    {
+        return $this->facturi_nume_client;
+    }
+
+    public function getFacturiTipPersoana()
+    {
+        return $this->facturi_tip_persoana;
+    }
+
+    public function getFacturiCodfClient()
+    {
+        return $this->facturi_codf_client;
+    }
+
+    public function getFacturiNrregClient()
+    {
+        return $this->facturi_nrreg_client;
+    }
+
+    public function getFacturiSediuClient()
+    {
+        return $this->facturi_sediu_client;
+    }
+
+    public function getFacturiJudetClient()
+    {
+        return $this->facturi_judet_client;
+    }
+
+    public function getFacturiOrasClient()
+    {
+        return $this->facturi_oras_client;
+    }
+
+    public function getFacturiClientiTel()
+    {
+        return $this->facturi_clienti_tel;
+    }
+
+    public function getFacturiEmailClient()
+    {
+        return $this->facturi_email_client;
+    }
+
+    public function getFacturiClientiAdresaLivrare()
+    {
+        return $this->facturi_clienti_adresa_livrare;
+    }
+
+    public function getFacturiContClient()
+    {
+        return $this->facturi_cont_client;
+    }
+
+    public function getFacturiBancaClient()
+    {
+        return $this->facturi_banca_client;
+    }
+
+    public function getFacturiObsClient()
+    {
+        return $this->facturi_obs_client;
+    }
+
+    public function getFacturiClientiOrasLivrare()
+    {
+        return $this->facturi_clienti_oras_livrare;
+    }
+
+    public function getFacturiClientiJudetLivrare()
+    {
+        return $this->facturi_clienti_judet_livrare;
+    }
+
+    public function getFacturiNumeDelegat()
+    {
+        return $this->facturi_nume_delegat;
+    }
+    public function getFacturiActDelegat()
+    {
+        return $this->facturi_act_delegat;
+    }
+
+    public function getFacturiObsDelegat()
+    {
+        return $this->facturi_obs_delegat;
+    }
+
+    public function getFkAgentName()
+    {
+        return $this->fk_agent_name;
+    }
+
+    public function setFacturiKey($facturi_key)
+    {
+        $this->facturi_key = $facturi_key;
+    }
+
+    public function setFacturiPunctDeLucru($facturi_punct_de_lucru)
+    {
+        $this->facturi_punct_de_lucru = $facturi_punct_de_lucru;
+    }
+
+    public function setFacturiGestiune($facturi_gestiune)
+    {
+        $this->facturi_gestiune = $facturi_gestiune;
+    }
+
+    public function setFacturiData($facturi_data)
+    {
+        $this->facturi_data = $facturi_data;
+    }
+    public function setFacturiDataScadenta($facturi_data_scadenta)
+    {
+        $this->facturi_data_scadenta = $facturi_data_scadenta;
+    }
+
+    public function setFacturiCotaTva($facturi_cota_tva)
+    {
+        $this->facturi_cota_tva = $facturi_cota_tva;
+    }
+
+    public function setFacturiMoneda($facturi_moneda)
+    {
+        $this->facturi_moneda = $facturi_moneda;
+    }
+
+    public function setFacturiSerie($facturi_serie)
+    {
+        $this->facturi_serie = $facturi_serie;
+    }
+    public function setFacturiNumar($facturi_numar)
+    {
+        $this->facturi_numar = $facturi_numar;
+    }
+
+    public function setFacturiObsUp($facturi_obs_up)
+    {
+        $this->facturi_obs_up = $facturi_obs_up;
+    }
+
+    public function setFacturiModPlata($facturi_mod_plata)
+    {
+        $this->facturi_mod_plata = $facturi_mod_plata;
+    }
+
+    public function setFacturiStatus($facturi_status)
+    {
+        $this->facturi_status = $facturi_status;
+    }
+    public function setFacturiClientId($facturi_client_id)
+    {
+        $this->facturi_client_id = $facturi_client_id;
+    }
+
+    public function setFacturiNumeClient($facturi_nume_client)
+    {
+        $this->facturi_nume_client = $facturi_nume_client;
+    }
+
+    public function setFacturiTipPersoana($facturi_tip_persoana)
+    {
+        $this->facturi_tip_persoana = $facturi_tip_persoana;
+    }
+
+    public function setFacturiCodfClient($facturi_codf_client)
+    {
+        $this->facturi_codf_client = $facturi_codf_client;
+    }
+
+    public function setFacturiNrregClient($facturi_nrreg_client)
+    {
+        $this->facturi_nrreg_client = $facturi_nrreg_client;
+    }
+
+    public function setFacturiSediuClient($facturi_sediu_client)
+    {
+        $this->facturi_sediu_client = $facturi_sediu_client;
+    }
+
+    public function setFacturiJudetClient($facturi_judet_client)
+    {
+        $this->facturi_judet_client = $facturi_judet_client;
+    }
+
+    public function setFacturiOrasClient($facturi_oras_client)
+    {
+        $this->facturi_oras_client = $facturi_oras_client;
+    }
+
+    public function setFacturiClientiTel($facturi_clienti_tel)
+    {
+        $this->facturi_clienti_tel = $facturi_clienti_tel;
+    }
+
+    public function setFacturiEmailClient($facturi_email_client)
+    {
+        $this->facturi_email_client = $facturi_email_client;
+    }
+
+    public function setFacturiClientiAdresaLivrare($facturi_clienti_adresa_livrare)
+    {
+        $this->facturi_clienti_adresa_livrare = $facturi_clienti_adresa_livrare;
+    }
+
+    public function setFacturiContClient($facturi_cont_client)
+    {
+        $this->facturi_cont_client = $facturi_cont_client;
+    }
+
+    public function setFacturiBancaClient($facturi_banca_client)
+    {
+        $this->facturi_banca_client = $facturi_banca_client;
+    }
+
+    public function setFacturiObsClient($facturi_obs_client)
+    {
+        $this->facturi_obs_client = $facturi_obs_client;
+    }
+
+    public function setFacturiClientiOrasLivrare($facturi_clienti_oras_livrare)
+    {
+        $this->facturi_clienti_oras_livrare = $facturi_clienti_oras_livrare;
+    }
+
+    public function setFacturiClientiJudetLivrare($facturi_clienti_judet_livrare)
+    {
+        $this->facturi_clienti_judet_livrare = $facturi_clienti_judet_livrare;
+    }
+
+    public function setFacturiNumeDelegat($facturi_nume_delegat)
+    {
+        $this->facturi_nume_delegat = $facturi_nume_delegat;
+    }
+    public function setFacturiActDelegat($facturi_act_delegat)
+    {
+        $this->facturi_act_delegat = $facturi_act_delegat;
+    }
+
+    public function setFacturiObsDelegat($facturi_obs_delegat)
+    {
+        $this->facturi_obs_delegat = $facturi_obs_delegat;
+    }
+
+    public function setFkAgentName($fk_agent_name)
+    {
+        $this->fk_agent_name = $fk_agent_name;
+    }
+
+    public function getUniqueIdInsert()
+    {
+        $this->unique_id_insert;
+    }
+
+    public function setUniqueIdInsert($unique_id_insert)
+    {
+        $this->unique_id_insert = $unique_id_insert;
+    }
+}

+ 386 - 0
Core/App/Entity/Invoice.php

@@ -0,0 +1,386 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Entity;
+
+class Invoice
+{
+    public $facturi_key;
+    public $facturi_punct_de_lucru;
+    public $facturi_gestiune;
+    public $facturi_data;
+    public $facturi_data_scadenta;
+    public $facturi_cota_tva;
+    public $facturi_moneda;
+    public $facturi_serie;
+    public $facturi_numar;
+    public $facturi_obs_up;
+    public $facturi_mod_plata;
+    public $facturi_status;
+    public $facturi_client_id;
+    public $facturi_nume_client;
+    public $facturi_tip_persoana;
+    public $facturi_codf_client;
+    public $facturi_nrreg_client;
+    public $facturi_sediu_client;
+    public $facturi_judet_client;
+    public $facturi_oras_client;
+    public $facturi_clienti_tel;
+    public $facturi_email_client;
+    public $facturi_clienti_adresa_livrare;
+    public $facturi_cont_client;
+    public $facturi_banca_client;
+    public $facturi_obs_client;
+    public $facturi_clienti_oras_livrare;
+    public $facturi_clienti_judet_livrare;
+    public $facturi_nume_delegat;
+    public $facturi_act_delegat;
+    public $facturi_obs_delegat;
+    public $fk_agent_name;
+    public $unique_id_insert;
+
+    public function getFacturiKey()
+    {
+        return $this->facturi_key;
+    }
+
+    public function getFacturiPunctDeLucru()
+    {
+        return $this->facturi_punct_de_lucru;
+    }
+
+    public function getFacturiGestiune()
+    {
+        return $this->facturi_gestiune;
+    }
+
+    public function getFacturiData()
+    {
+        return $this->facturi_data;
+    }
+    public function getFacturiDataScadenta()
+    {
+        return $this->facturi_data_scadenta;
+    }
+
+    public function getFacturiCotaTva()
+    {
+        return $this->facturi_cota_tva;
+    }
+
+    public function getFacturiMoneda()
+    {
+        return $this->facturi_moneda;
+    }
+
+    public function getFacturiSerie()
+    {
+        return $this->facturi_serie;
+    }
+    public function getFacturiNumar()
+    {
+        return $this->facturi_numar;
+    }
+
+    public function getFacturiObsUp()
+    {
+        return $this->facturi_obs_up;
+    }
+
+    public function getFacturiModPlata()
+    {
+        return $this->facturi_mod_plata;
+    }
+
+    public function getFacturiStatus()
+    {
+        return $this->facturi_status;
+    }
+    public function getFacturiClientId()
+    {
+        return $this->facturi_client_id;
+    }
+
+    public function getFacturiNumeClient()
+    {
+        return $this->facturi_nume_client;
+    }
+
+    public function getFacturiTipPersoana()
+    {
+        return $this->facturi_tip_persoana;
+    }
+
+    public function getFacturiCodfClient()
+    {
+        return $this->facturi_codf_client;
+    }
+
+    public function getFacturiNrregClient()
+    {
+        return $this->facturi_nrreg_client;
+    }
+
+    public function getFacturiSediuClient()
+    {
+        return $this->facturi_sediu_client;
+    }
+
+    public function getFacturiJudetClient()
+    {
+        return $this->facturi_judet_client;
+    }
+
+    public function getFacturiOrasClient()
+    {
+        return $this->facturi_oras_client;
+    }
+
+    public function getFacturiClientiTel()
+    {
+        return $this->facturi_clienti_tel;
+    }
+
+    public function getFacturiEmailClient()
+    {
+        return $this->facturi_email_client;
+    }
+
+    public function getFacturiClientiAdresaLivrare()
+    {
+        return $this->facturi_clienti_adresa_livrare;
+    }
+
+    public function getFacturiContClient()
+    {
+        return $this->facturi_cont_client;
+    }
+
+    public function getFacturiBancaClient()
+    {
+        return $this->facturi_banca_client;
+    }
+
+    public function getFacturiObsClient()
+    {
+        return $this->facturi_obs_client;
+    }
+
+    public function getFacturiClientiOrasLivrare()
+    {
+        return $this->facturi_clienti_oras_livrare;
+    }
+
+    public function getFacturiClientiJudetLivrare()
+    {
+        return $this->facturi_clienti_judet_livrare;
+    }
+
+    public function getFacturiNumeDelegat()
+    {
+        return $this->facturi_nume_delegat;
+    }
+    public function getFacturiActDelegat()
+    {
+        return $this->facturi_act_delegat;
+    }
+
+    public function getFacturiObsDelegat()
+    {
+        return $this->facturi_obs_delegat;
+    }
+
+    public function getFkAgentName()
+    {
+        return $this->fk_agent_name;
+    }
+
+    public function setFacturiKey($facturi_key)
+    {
+        $this->facturi_key = $facturi_key;
+    }
+
+    public function setFacturiPunctDeLucru($facturi_punct_de_lucru)
+    {
+        $this->facturi_punct_de_lucru = $facturi_punct_de_lucru;
+    }
+
+    public function setFacturiGestiune($facturi_gestiune)
+    {
+        $this->facturi_gestiune = $facturi_gestiune;
+    }
+
+    public function setFacturiData($facturi_data)
+    {
+        $this->facturi_data = $facturi_data;
+    }
+    public function setFacturiDataScadenta($facturi_data_scadenta)
+    {
+        $this->facturi_data_scadenta = $facturi_data_scadenta;
+    }
+
+    public function setFacturiCotaTva($facturi_cota_tva)
+    {
+        $this->facturi_cota_tva = $facturi_cota_tva;
+    }
+
+    public function setFacturiMoneda($facturi_moneda)
+    {
+        $this->facturi_moneda = $facturi_moneda;
+    }
+
+    public function setFacturiSerie($facturi_serie)
+    {
+        $this->facturi_serie = $facturi_serie;
+    }
+    public function setFacturiNumar($facturi_numar)
+    {
+        $this->facturi_numar = $facturi_numar;
+    }
+
+    public function setFacturiObsUp($facturi_obs_up)
+    {
+        $this->facturi_obs_up = $facturi_obs_up;
+    }
+
+    public function setFacturiModPlata($facturi_mod_plata)
+    {
+        $this->facturi_mod_plata = $facturi_mod_plata;
+    }
+
+    public function setFacturiStatus($facturi_status)
+    {
+        $this->facturi_status = $facturi_status;
+    }
+    public function setFacturiClientId($facturi_client_id)
+    {
+        $this->facturi_client_id = $facturi_client_id;
+    }
+
+    public function setFacturiNumeClient($facturi_nume_client)
+    {
+        $this->facturi_nume_client = $facturi_nume_client;
+    }
+
+    public function setFacturiTipPersoana($facturi_tip_persoana)
+    {
+        $this->facturi_tip_persoana = $facturi_tip_persoana;
+    }
+
+    public function setFacturiCodfClient($facturi_codf_client)
+    {
+        $this->facturi_codf_client = $facturi_codf_client;
+    }
+
+    public function setFacturiNrregClient($facturi_nrreg_client)
+    {
+        $this->facturi_nrreg_client = $facturi_nrreg_client;
+    }
+
+    public function setFacturiSediuClient($facturi_sediu_client)
+    {
+        $this->facturi_sediu_client = $facturi_sediu_client;
+    }
+
+    public function setFacturiJudetClient($facturi_judet_client)
+    {
+        $this->facturi_judet_client = $facturi_judet_client;
+    }
+
+    public function setFacturiOrasClient($facturi_oras_client)
+    {
+        $this->facturi_oras_client = $facturi_oras_client;
+    }
+
+    public function setFacturiClientiTel($facturi_clienti_tel)
+    {
+        $this->facturi_clienti_tel = $facturi_clienti_tel;
+    }
+
+    public function setFacturiEmailClient($facturi_email_client)
+    {
+        $this->facturi_email_client = $facturi_email_client;
+    }
+
+    public function setFacturiClientiAdresaLivrare($facturi_clienti_adresa_livrare)
+    {
+        $this->facturi_clienti_adresa_livrare = $facturi_clienti_adresa_livrare;
+    }
+
+    public function setFacturiContClient($facturi_cont_client)
+    {
+        $this->facturi_cont_client = $facturi_cont_client;
+    }
+
+    public function setFacturiBancaClient($facturi_banca_client)
+    {
+        $this->facturi_banca_client = $facturi_banca_client;
+    }
+
+    public function setFacturiObsClient($facturi_obs_client)
+    {
+        $this->facturi_obs_client = $facturi_obs_client;
+    }
+
+    public function setFacturiClientiOrasLivrare($facturi_clienti_oras_livrare)
+    {
+        $this->facturi_clienti_oras_livrare = $facturi_clienti_oras_livrare;
+    }
+
+    public function setFacturiClientiJudetLivrare($facturi_clienti_judet_livrare)
+    {
+        $this->facturi_clienti_judet_livrare = $facturi_clienti_judet_livrare;
+    }
+
+    public function setFacturiNumeDelegat($facturi_nume_delegat)
+    {
+        $this->facturi_nume_delegat = $facturi_nume_delegat;
+    }
+    public function setFacturiActDelegat($facturi_act_delegat)
+    {
+        $this->facturi_act_delegat = $facturi_act_delegat;
+    }
+
+    public function setFacturiObsDelegat($facturi_obs_delegat)
+    {
+        $this->facturi_obs_delegat = $facturi_obs_delegat;
+    }
+
+    public function setFkAgentName($fk_agent_name)
+    {
+        $this->fk_agent_name = $fk_agent_name;
+    }
+
+    public function getUniqueIdInsert()
+    {
+        $this->unique_id_insert;
+    }
+
+    public function setUniqueIdInsert($unique_id_insert)
+    {
+        $this->unique_id_insert = $unique_id_insert;
+    }
+}

+ 255 - 0
Core/App/Entity/Settings.php

@@ -11,9 +11,14 @@ class Settings
 
     public $option_auto_stock_sync;
     public $option_auto_order_sync;
+    public $option_doc_upd;
+    public $option_pdls;
+    public $option_show_obs;
     public $option_stock_filter;
     public $option_order_or_proforma;
     public $option_proforma_serie;
+    public $option_avize_serie;
+    public $option_expfactura_serie;
     public $option_ordered_days_ago;
     public $option_locations;
 
@@ -27,7 +32,27 @@ class Settings
     public $sync_data_types;
     public $order_or_proforma_options;
     public $sync_stock_filter_options;
+
+    public $option_add_proforma;
+    public $option_add_avize;
+    public $option_add_expfactura;
+    public $option_add_invoice;
+    public $option_view_proforma;
+    public $option_view_avize;
+    public $option_view_expfactura;
+    public $option_view_invoice;
+    public $option_edit_proforma;
+    public $option_edit_avize;
+    public $option_edit_expfactura;
+    public $option_edit_invoice;
+
 	public $option_with_discount;
+
+    public $option_proforma_serie2;
+    public $option_avize_serie2;
+    public $option_expfactura_serie2;
+    public $option_invoice_serie;
+
     public function getAuthApiKey()
     {
         return $this->auth_api_key;
@@ -58,6 +83,21 @@ class Settings
         return $this->option_auto_order_sync;
     }
 
+    public function getOptionDocUpd()
+    {
+        return $this->option_doc_upd;
+    }
+
+    public function getOptionPdls()
+    {
+        return $this->option_pdls;
+    }
+
+    public function getOptionShowObs()
+    {
+        return $this->option_show_obs;
+    }
+
     public function getOptionStockFilter()
     {
         return $this->option_stock_filter;
@@ -73,6 +113,16 @@ class Settings
         return $this->option_proforma_serie;
     }
 
+    public function getOptionAvizeSerie()
+    {
+        return $this->option_avize_serie;
+    }
+
+    public function getOptionExpfacturaSerie()
+    {
+        return $this->option_expfactura_serie;
+    }
+
     public function getOptionOrderedDaysAgo()
     {
         return $this->option_ordered_days_ago;
@@ -83,6 +133,26 @@ class Settings
         return $this->option_locations;
     }
 
+    public function getOptionProformaSerie2()
+    {
+        return $this->option_proforma_serie2;
+    }
+
+    public function getOptionAvizeSerie2()
+    {
+        return $this->option_avize_serie2;
+    }
+
+    public function getOptionExpfacturaSerie2()
+    {
+        return $this->option_expfactura_serie2;
+    }
+
+    public function getOptionInvoiceSerie()
+    {
+        return $this->option_invoice_serie;
+    }
+
     public function getCustomFieldBank()
     {
         return $this->custom_field_bank;
@@ -138,6 +208,21 @@ class Settings
         $this->option_auto_order_sync = $option_auto_order_sync;
     }
 
+    public function setOptionDocUpd($option_doc_upd)
+    {
+        $this->option_doc_upd = $option_doc_upd;
+    }
+
+    public function setOptionPdls($option_pdls)
+    {
+        $this->option_pdls = $option_pdls;
+    }
+
+    public function setOptionShowObs($option_show_obs)
+    {
+        $this->option_show_obs = $option_show_obs;
+    }
+
     public function setOptionStockFilter($option_stock_filter)
     {
         $this->option_stock_filter = $option_stock_filter;
@@ -153,6 +238,36 @@ class Settings
         $this->option_proforma_serie = $option_proforma_serie;
     }
 
+    public function setOptionAvizeSerie($option_avize_serie)
+    {
+        $this->option_avize_serie = $option_avize_serie;
+    }
+
+    public function setOptionExpfacturaSerie($option_expfactura_serie)
+    {
+        $this->option_expfactura_serie = $option_expfactura_serie;
+    }
+
+    public function setOptionProformaSerie2($option_proforma_serie2)
+    {
+        $this->option_proforma_serie2 = $option_proforma_serie2;
+    }
+
+    public function setOptionAvizeSerie2($option_avize_serie2)
+    {
+        $this->option_avize_serie2 = $option_avize_serie2;
+    }
+
+    public function setOptionExpfacturaSerie2($option_expfactura_serie2)
+    {
+        $this->option_expfactura_serie2 = $option_expfactura_serie2;
+    }
+
+    public function setOptionInvoiceSerie($option_invoice_serie)
+    {
+        $this->option_invoice_serie = $option_invoice_serie;
+    }
+
     public function setOptionOrderedDaysAgo($option_ordered_days_ago)
     {
         $this->option_ordered_days_ago = $option_ordered_days_ago;
@@ -193,11 +308,31 @@ class Settings
         return $this->auto_sync_options;
     }
 
+    public function getDocUpdOptions()
+    {
+        return $this->doc_upd_options;
+    }
+
+    public function getShowObsOptions()
+    {
+        return $this->show_obs_options;
+    }
+
     public function setAutoSyncOptions($auto_sync_options)
     {
         $this->auto_sync_options = $auto_sync_options;
     }
 
+    public function setDocUpdOptions($doc_upd_options)
+    {
+        $this->doc_upd_options = $doc_upd_options;
+    }
+
+    public function setShowObsOptions($show_obs_options)
+    {
+        $this->show_obs_options = $show_obs_options;
+    }
+
     public function getOrderOrProformaOptions()
     {
         return $this->order_or_proforma_options;
@@ -228,6 +363,126 @@ class Settings
         $this->sync_stock_filter_options = $sync_stock_filter_options;
     }
 
+    public function getOptionAddProforma()
+    {
+        return $this->option_add_proforma;
+    }
+
+    public function setOptionAddProforma($option_add_proforma)
+    {
+        $this->option_add_proforma = $option_add_proforma;
+    }
+
+    public function getOptionAddAvize()
+    {
+        return $this->option_add_avize;
+    }
+
+    public function setOptionAddAvize($option_add_avize)
+    {
+        $this->option_add_avize = $option_add_avize;
+    }
+
+    public function getOptionAddExpfactura()
+    {
+        return $this->option_add_expfactura;
+    }
+
+    public function setOptionAddExpfactura($option_add_expfactura)
+    {
+        $this->option_add_expfactura = $option_add_expfactura;
+    }
+
+    public function getOptionAddInvoice()
+    {
+        return $this->option_add_invoice;
+    }
+
+    public function setOptionAddInvoice($option_add_invoice)
+    {
+        $this->option_add_invoice = $option_add_invoice;
+    }
+
+    public function getOptionViewProforma()
+    {
+        return $this->option_view_proforma;
+    }
+
+    public function getOptionViewAvize()
+    {
+        return $this->option_view_avize;
+    }
+
+    public function getOptionViewExpfactura()
+    {
+        return $this->option_view_expfactura;
+    }
+
+    public function setOptionViewProforma($option_view_proforma)
+    {
+        $this->option_view_proforma = $option_view_proforma;
+    }
+
+    public function setOptionViewAvize($option_view_avize)
+    {
+        $this->option_view_avize = $option_view_avize;
+    }
+
+    public function setOptionViewExpfactura($option_view_expfactura)
+    {
+        $this->option_view_expfactura = $option_view_expfactura;
+    }
+
+    public function getOptionViewInvoice()
+    {
+        return $this->option_view_invoice;
+    }
+
+    public function setOptionViewInvoice($option_view_invoice)
+    {
+        $this->option_view_invoice = $option_view_invoice;
+    }
+
+    public function getOptionEditProforma()
+    {
+        return $this->option_edit_proforma;
+    }
+
+    public function setOptionEditProforma($option_edit_proforma)
+    {
+        $this->option_edit_proforma = $option_edit_proforma;
+    }
+
+    public function getOptionEditAvize()
+    {
+        return $this->option_edit_avize;
+    }
+
+    public function setOptionEditAvize($option_edit_avize)
+    {
+        $this->option_edit_avize = $option_edit_avize;
+    }
+
+    public function getOptionEditExpfactura()
+    {
+        return $this->option_edit_expfactura;
+    }
+
+    public function setOptionEditExpfactura($option_edit_expfactura)
+    {
+        $this->option_edit_expfactura = $option_edit_expfactura;
+    }
+
+    public function getOptionEditInvoice()
+    {
+        return $this->option_edit_invoice;
+    }
+
+    public function setOptionEditInvoice($option_edit_invoice)
+    {
+        $this->option_edit_invoice = $option_edit_invoice;
+    }
+
 	public function getOptionWithDiscount()
     {
         return $this->option_with_discount;

+ 99 - 0
Core/App/Factory/AvizeFactory.php

@@ -0,0 +1,99 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Factory;
+
+class AvizeFactory extends OrderFactory
+{
+    public function createAvize(
+        $facturi_serie,
+        $order_id,
+        $created_date,
+        $currency,
+        $customer_id,
+        $customer_first_name,
+        $customer_last_name,
+        $billing_company,
+        $email,
+
+        $billing_address_first_name,
+        $billing_address_last_name,
+        $billing_address_address1,
+        $billing_address_address2,
+        $billing_address_zip,
+        $billing_address_city,
+        $billing_address_province,
+        $billing_address_phone,
+
+        $shipping_address_first_name,
+        $shipping_address_last_name,
+        $shipping_address_address1,
+        $shipping_address_address2,
+        $shipping_address_zip,
+        $shipping_address_city,
+        $shipping_address_province,
+        $shipping_address_phone,
+
+        $payment_method,
+        $comments,
+        $fiscal_code,
+        $company,
+        $nr_inreg,
+        $facturi_cont_client,
+        $facturi_banca_client,
+        $taxRate
+    ) {
+        $proforma = new \Core\App\Entity\Avize();
+
+        $proforma->setFacturiData(date('Y-m-d H:i:s', strtotime($created_date)));
+        $proforma->setFacturiDataScadenta(date('Y-m-d H:i:s', strtotime($created_date)));
+        $proforma->setFacturiCotaTva($this->getTaxName($taxRate));
+        $proforma->setFacturiMoneda($currency);
+        $proforma->setFacturiSerie($facturi_serie);
+        $proforma->setFacturiObsUp($this->getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments));
+        $proforma->setFacturiModPlata($payment_method);
+        $proforma->setFacturiStatus('Emisa');
+        $proforma->setFacturiClientId($customer_id);
+        $proforma->setFacturiNumeClient($this->getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company));
+        $proforma->setFacturiTipPersoana(!empty($fiscal_code) ? 'juridica' : 'fizica');
+        $proforma->setFacturiCodfClient($fiscal_code);
+        $proforma->setFacturiNrregClient($nr_inreg);
+        $proforma->setFacturiSediuClient($this->getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip));
+        $proforma->setFacturiJudetClient($this->stripSpecialChars($billing_address_province));
+        $proforma->setFacturiOrasClient($this->stripSpecialChars($billing_address_city));
+        $proforma->setFacturiClientiTel($billing_address_phone);
+        $proforma->setFacturiEmailClient($email);
+        $proforma->setFacturiClientiAdresaLivrare($this->getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip));
+        $proforma->setFacturiContClient($facturi_cont_client);
+        $proforma->setFacturiBancaClient($facturi_banca_client);
+        $proforma->setFacturiObsClient('Id extern client: ' . $customer_id);
+        $proforma->setFacturiClientiOrasLivrare($this->stripSpecialChars($shipping_address_city));
+        $proforma->setFacturiClientiJudetLivrare($this->stripSpecialChars($shipping_address_province));
+        $proforma->setUniqueIdInsert($this->getPrefix() . $facturi_serie . '_' . $customer_id . '_' . $order_id . '_' . strtotime($created_date));
+
+        return $proforma;
+    }
+}

+ 67 - 0
Core/App/Factory/AvizeItemFactory.php

@@ -0,0 +1,67 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Factory;
+
+class AvizeItemFactory extends OrderItemFactory
+{
+    public function createAvizeProduct(
+        $product_ids,
+        $product_name,
+        $ean,
+        $sku,
+        $upc,
+        $currency_code,
+        $price,
+        $taxRate,
+        $quantity,
+        $taxIncluded = false
+    ) {
+        $proformaProduct = new \Core\App\Entity\OrderItem();
+
+        $taxRate = $this->getTaxRate($taxRate);
+        $pretFtva = $this->getPretftva($price, $taxRate, 0, $taxIncluded);
+        $pretCtva = $this->getPretctva($price, $taxRate, 0, $taxIncluded);
+
+        $proformaProduct->setFacturiProdNume($this->stripSpecialChars($product_name));
+        $proformaProduct->setFacturiProdMoneda($currency_code);
+        $proformaProduct->setFacturiProdPretftva($pretFtva);
+        $proformaProduct->setFacturiProdPretctva($pretCtva);
+        $proformaProduct->setFacturiProdTva($this->getTaxName($taxRate));
+        $proformaProduct->setFacturiProdCant($quantity);
+        $proformaProduct->setFacturiProdVal($pretFtva * $quantity);
+        $proformaProduct->setFacturiProdValTva(($pretCtva - $pretFtva) * $quantity);
+        $proformaProduct->setFacturiProdValTot($pretCtva * $quantity);
+        $proformaProduct->setFacturiProdUm(self::UM);
+        $proformaProduct->setProdCod($ean);
+        $proformaProduct->setProdSku($sku);
+        $proformaProduct->setProdUpc($upc);
+        $proformaProduct->setProdCod1((trim($upc) != '') ? $upc : ($this->getPrefix() . $product_ids));
+        $proformaProduct->setProdCodCautare('all');
+
+        return $proformaProduct;
+    }
+}

+ 99 - 0
Core/App/Factory/ExpfacturaFactory.php

@@ -0,0 +1,99 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Factory;
+
+class ExpfacturaFactory extends OrderFactory
+{
+    public function createExpfactura(
+        $facturi_serie,
+        $order_id,
+        $created_date,
+        $currency,
+        $customer_id,
+        $customer_first_name,
+        $customer_last_name,
+        $billing_company,
+        $email,
+
+        $billing_address_first_name,
+        $billing_address_last_name,
+        $billing_address_address1,
+        $billing_address_address2,
+        $billing_address_zip,
+        $billing_address_city,
+        $billing_address_province,
+        $billing_address_phone,
+
+        $shipping_address_first_name,
+        $shipping_address_last_name,
+        $shipping_address_address1,
+        $shipping_address_address2,
+        $shipping_address_zip,
+        $shipping_address_city,
+        $shipping_address_province,
+        $shipping_address_phone,
+
+        $payment_method,
+        $comments,
+        $fiscal_code,
+        $company,
+        $nr_inreg,
+        $facturi_cont_client,
+        $facturi_banca_client,
+        $taxRate
+    ) {
+        $proforma = new \Core\App\Entity\Expfactura();
+
+        $proforma->setFacturiData(date('Y-m-d H:i:s', strtotime($created_date)));
+        $proforma->setFacturiDataScadenta(date('Y-m-d H:i:s', strtotime($created_date)));
+        $proforma->setFacturiCotaTva($this->getTaxName($taxRate));
+        $proforma->setFacturiMoneda($currency);
+        $proforma->setFacturiSerie($facturi_serie);
+        $proforma->setFacturiObsUp($this->getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments));
+        $proforma->setFacturiModPlata($payment_method);
+        $proforma->setFacturiStatus('Emisa');
+        $proforma->setFacturiClientId($customer_id);
+        $proforma->setFacturiNumeClient($this->getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company));
+        $proforma->setFacturiTipPersoana(!empty($fiscal_code) ? 'juridica' : 'fizica');
+        $proforma->setFacturiCodfClient($fiscal_code);
+        $proforma->setFacturiNrregClient($nr_inreg);
+        $proforma->setFacturiSediuClient($this->getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip));
+        $proforma->setFacturiJudetClient($this->stripSpecialChars($billing_address_province));
+        $proforma->setFacturiOrasClient($this->stripSpecialChars($billing_address_city));
+        $proforma->setFacturiClientiTel($billing_address_phone);
+        $proforma->setFacturiEmailClient($email);
+        $proforma->setFacturiClientiAdresaLivrare($this->getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip));
+        $proforma->setFacturiContClient($facturi_cont_client);
+        $proforma->setFacturiBancaClient($facturi_banca_client);
+        $proforma->setFacturiObsClient('Id extern client: ' . $customer_id);
+        $proforma->setFacturiClientiOrasLivrare($this->stripSpecialChars($shipping_address_city));
+        $proforma->setFacturiClientiJudetLivrare($this->stripSpecialChars($shipping_address_province));
+        $proforma->setUniqueIdInsert($this->getPrefix() . $facturi_serie . '_' . $customer_id . '_' . $order_id . '_' . strtotime($created_date));
+
+        return $proforma;
+    }
+}

+ 67 - 0
Core/App/Factory/ExpfacturaItemFactory.php

@@ -0,0 +1,67 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Factory;
+
+class ExpfacturaItemFactory extends OrderItemFactory
+{
+    public function createExpfacturaProduct(
+        $product_ids,
+        $product_name,
+        $ean,
+        $sku,
+        $upc,
+        $currency_code,
+        $price,
+        $taxRate,
+        $quantity,
+        $taxIncluded = false
+    ) {
+        $proformaProduct = new \Core\App\Entity\OrderItem();
+
+        $taxRate = $this->getTaxRate($taxRate);
+        $pretFtva = $this->getPretftva($price, $taxRate, 0, $taxIncluded);
+        $pretCtva = $this->getPretctva($price, $taxRate, 0, $taxIncluded);
+
+        $proformaProduct->setFacturiProdNume($this->stripSpecialChars($product_name));
+        $proformaProduct->setFacturiProdMoneda($currency_code);
+        $proformaProduct->setFacturiProdPretftva($pretFtva);
+        $proformaProduct->setFacturiProdPretctva($pretCtva);
+        $proformaProduct->setFacturiProdTva($this->getTaxName($taxRate));
+        $proformaProduct->setFacturiProdCant($quantity);
+        $proformaProduct->setFacturiProdVal($pretFtva * $quantity);
+        $proformaProduct->setFacturiProdValTva(($pretCtva - $pretFtva) * $quantity);
+        $proformaProduct->setFacturiProdValTot($pretCtva * $quantity);
+        $proformaProduct->setFacturiProdUm(self::UM);
+        $proformaProduct->setProdCod($ean);
+        $proformaProduct->setProdSku($sku);
+        $proformaProduct->setProdUpc($upc);
+        $proformaProduct->setProdCod1((trim($upc) != '') ? $upc : ($this->getPrefix() . $product_ids));
+        $proformaProduct->setProdCodCautare('all');
+
+        return $proformaProduct;
+    }
+}

+ 99 - 0
Core/App/Factory/InvoiceFactory.php

@@ -0,0 +1,99 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Factory;
+
+class InvoiceFactory extends OrderFactory
+{
+    public function createInvoice(
+        $facturi_serie,
+        $order_id,
+        $created_date,
+        $currency,
+        $customer_id,
+        $customer_first_name,
+        $customer_last_name,
+        $billing_company,
+        $email,
+
+        $billing_address_first_name,
+        $billing_address_last_name,
+        $billing_address_address1,
+        $billing_address_address2,
+        $billing_address_zip,
+        $billing_address_city,
+        $billing_address_province,
+        $billing_address_phone,
+
+        $shipping_address_first_name,
+        $shipping_address_last_name,
+        $shipping_address_address1,
+        $shipping_address_address2,
+        $shipping_address_zip,
+        $shipping_address_city,
+        $shipping_address_province,
+        $shipping_address_phone,
+
+        $payment_method,
+        $comments,
+        $fiscal_code,
+        $company,
+        $nr_inreg,
+        $facturi_cont_client,
+        $facturi_banca_client,
+        $taxRate
+    ) {
+        $proforma = new \Core\App\Entity\Invoice();
+
+        $proforma->setFacturiData(date('Y-m-d H:i:s', strtotime($created_date)));
+        $proforma->setFacturiDataScadenta(date('Y-m-d H:i:s', strtotime($created_date)));
+        $proforma->setFacturiCotaTva($this->getTaxName($taxRate));
+        $proforma->setFacturiMoneda($currency);
+        $proforma->setFacturiSerie($facturi_serie);
+        $proforma->setFacturiObsUp($this->getObs($order_id, $shipping_address_first_name, $shipping_address_last_name, $shipping_address_phone, $billing_address_phone, $comments));
+        $proforma->setFacturiModPlata($payment_method);
+        $proforma->setFacturiStatus('Emisa');
+        $proforma->setFacturiClientId($customer_id);
+        $proforma->setFacturiNumeClient($this->getPaymentName($customer_first_name, $customer_last_name, $billing_address_first_name, $billing_address_last_name, $billing_company, $company));
+        $proforma->setFacturiTipPersoana(!empty($fiscal_code) ? 'juridica' : 'fizica');
+        $proforma->setFacturiCodfClient($fiscal_code);
+        $proforma->setFacturiNrregClient($nr_inreg);
+        $proforma->setFacturiSediuClient($this->getPaymentAddress($billing_address_address1, $billing_address_address2, $billing_address_zip));
+        $proforma->setFacturiJudetClient($this->stripSpecialChars($billing_address_province));
+        $proforma->setFacturiOrasClient($this->stripSpecialChars($billing_address_city));
+        $proforma->setFacturiClientiTel($billing_address_phone);
+        $proforma->setFacturiEmailClient($email);
+        $proforma->setFacturiClientiAdresaLivrare($this->getShippingAddress($shipping_address_address1, $shipping_address_address2, $shipping_address_zip));
+        $proforma->setFacturiContClient($facturi_cont_client);
+        $proforma->setFacturiBancaClient($facturi_banca_client);
+        $proforma->setFacturiObsClient('Id extern client: ' . $customer_id);
+        $proforma->setFacturiClientiOrasLivrare($this->stripSpecialChars($shipping_address_city));
+        $proforma->setFacturiClientiJudetLivrare($this->stripSpecialChars($shipping_address_province));
+        $proforma->setUniqueIdInsert($this->getPrefix() . $facturi_serie . '_' . $customer_id . '_' . $order_id . '_' . strtotime($created_date));
+
+        return $proforma;
+    }
+}

+ 67 - 0
Core/App/Factory/InvoiceItemFactory.php

@@ -0,0 +1,67 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Factory;
+
+class InvoiceItemFactory extends OrderItemFactory
+{
+    public function createInvoiceProduct(
+        $product_ids,
+        $product_name,
+        $ean,
+        $sku,
+        $upc,
+        $currency_code,
+        $price,
+        $taxRate,
+        $quantity,
+        $taxIncluded = false
+    ) {
+        $invoiceProduct = new \Core\App\Entity\OrderItem();
+
+        $taxRate = $this->getTaxRate($taxRate) ;
+        $pretFtva = $this->getPretftva($price, $taxRate, 0, $taxIncluded);
+        $pretCtva = $this->getPretctva($price, $taxRate, 0, $taxIncluded);
+
+        $invoiceProduct->setFacturiProdNume($this->stripSpecialChars($product_name));
+        $invoiceProduct->setFacturiProdMoneda($currency_code);
+        $invoiceProduct->setFacturiProdPretftva($pretFtva);
+        $invoiceProduct->setFacturiProdPretctva($pretCtva);
+        $invoiceProduct->setFacturiProdTva($this->getTaxName($taxRate));
+        $invoiceProduct->setFacturiProdCant($quantity);
+        $invoiceProduct->setFacturiProdVal($pretFtva * $quantity);
+        $invoiceProduct->setFacturiProdValTva(($pretCtva - $pretFtva) * $quantity);
+        $invoiceProduct->setFacturiProdValTot($pretCtva * $quantity);
+        $invoiceProduct->setFacturiProdUm(self::UM);
+        $invoiceProduct->setProdCod($ean);
+        $invoiceProduct->setProdSku($sku);
+        $invoiceProduct->setProdUpc($upc);
+        $invoiceProduct->setProdCod1((trim($upc) != '') ? $upc : ($this->getPrefix() . $product_ids));
+        $invoiceProduct->setProdCodCautare('all');
+        
+        return $invoiceProduct;
+    }
+}

+ 45 - 3
Core/App/Factory/SettingsFactory.php

@@ -6,22 +6,57 @@ class SettingsFactory extends EntityFactory
 {
     const DEFAULT_AUTO_STOCK_SYNC = 'activ';
     const DEFAULT_AUTO_ORDER_SYNC = 'activ';
+    const DEFAULT_DOC_UPD = 'inactiv';
+    const DEFAULT_PDLS = '';
+    const DEFAULT_SHOW_OBS = 'activ';
     const DEFAULT_ORDER_OR_PROFORMA = 'order';
     const DEFAULT_PROFORMA_SERIE = '';
+    const DEFAULT_AVIZE_SERIE = '';
+    const DEFAULT_EXPFACTURA_SERIE = '';
     const DEFAULT_ORDERED_DAYS_AGO = '7';
     const DEFAULT_STOCK_FILTER = '';
 
     const AUTO_SYNC_ENABLED = 'activ';
     const AUTO_SYNC_DISABLED = 'inactiv';
 
+    const DOC_UPD_ENABLED = 'activ';
+    const DOC_UPD_DISABLED = 'inactiv';
+
+    const SHOW_OBS_ENABLED = 'activ';
+    const SHOW_OBS_DISABLED = 'inactiv';
+
     const SYNC_ENABLED = 'activ';
     const SYNC_DISABLED = 'inactiv';
 
+
     const SELECT_ORDER = 'order';
     const SELECT_PROFORMA = 'proforma';
+    const SELECT_FACTURA = 'factura';
+    const SELECT_AVIZE = 'avize';
+    const SELECT_EXPFACTURA = 'expfactura';
+
+    const DEFAULT_ADD_PROFORMA = 'inactiv';
+    const DEFAULT_ADD_AVIZE = 'inactiv';
+    const DEFAULT_ADD_EXPFACTURA = 'inactiv';
+    const DEFAULT_ADD_INVOICE = 'activ';
+
+    const DEFAULT_VIEW_PROFORMA = 'activ';
+    const DEFAULT_VIEW_AVIZE = 'activ';
+    const DEFAULT_VIEW_EXPFACTURA = 'activ';
+    const DEFAULT_VIEW_INVOICE = 'activ';
+
+    const DEFAULT_EDIT_PROFORMA = 'inactiv';
+    const DEFAULT_EDIT_AVIZE = 'inactiv';
+    const DEFAULT_EDIT_EXPFACTURA = 'inactiv';
+    const DEFAULT_EDIT_INVOICE = 'inactiv';
     const DEFAULT_LOCATIONS = null;
 	const DEFAULT_WITH_DISCOUNT = 'activ';
 
+    const DEFAULT_PROFORMA_SERIE2 = '';
+    const DEFAULT_AVIZE_SERIE2 = '';
+    const DEFAULT_EXPFACTURA_SERIE2 = '';
+    const DEFAULT_INVOICE_SERIE = '';
+
     public function createSettings(
         $auth_api_key = '',
         $auth_username = '',
@@ -30,14 +65,16 @@ class SettingsFactory extends EntityFactory
 
         $option_auto_stock_sync = '',
         $option_auto_order_sync = '',
+        $option_pdls = '',
         $option_stock_filter = '',
         $option_order_or_proforma = '',
         $option_proforma_serie = '',
+        $option_avize_serie = '',
+        $option_expfactura_serie = '',
         $option_ordered_days_ago = '',
         $option_locations = null,
         $option_with_discount = ''
-    )
-    {
+    ) {
         $settings = new \Core\App\Entity\Settings();
 
         $settings->setAuthApiKey($auth_api_key);
@@ -50,6 +87,9 @@ class SettingsFactory extends EntityFactory
         $settings->setOptionStockFilter(($option_stock_filter != '') ? $option_stock_filter : self::DEFAULT_STOCK_FILTER);
         $settings->setOptionOrderOrProforma(($option_order_or_proforma != '') ? $option_order_or_proforma : self::DEFAULT_ORDER_OR_PROFORMA);
         $settings->setOptionProformaSerie(($option_proforma_serie != '') ? $option_proforma_serie : self::DEFAULT_PROFORMA_SERIE);
+        $settings->setOptionAvizeSerie(($option_avize_serie != '') ? $option_avize_serie : self::DEFAULT_AVIZE_SERIE);
+        $settings->setOptionExpfacturaSerie(($option_expfactura_serie != '') ? $option_expfactura_serie : self::DEFAULT_EXPFACTURA_SERIE);
+        $settings->setOptionPdls(($option_pdls != '') ? $option_pdls : self::DEFAULT_PDLS);
         $settings->setOptionOrderedDaysAgo(($option_ordered_days_ago != '') ? $option_ordered_days_ago : self::DEFAULT_ORDERED_DAYS_AGO);
         $settings->setOptionLocations(!is_null($option_locations) ? explode(", ", $option_locations) : self::DEFAULT_LOCATIONS);
 		$settings->setOptionWithDiscount(($option_with_discount != '') ? $option_with_discount : self::DEFAULT_WITH_DISCOUNT);
@@ -86,7 +126,9 @@ class SettingsFactory extends EntityFactory
         ));
         
         $settings->setAutoSyncOptions(array(self::AUTO_SYNC_ENABLED, self::AUTO_SYNC_DISABLED));
-        $settings->setOrderOrProformaOptions(array(self::SELECT_ORDER, self::SELECT_PROFORMA));
+//        $settings->setDocUpdOptions(array(self::DOC_UPD_ENABLED, self::DOC_UPD_DISABLED));
+//        $settings->setShowObsOptions(array(self::SHOW_OBS_ENABLED, self::SHOW_OBS_DISABLED));
+        $settings->setOrderOrProformaOptions(array(self::SELECT_ORDER, self::SELECT_PROFORMA, self::SELECT_EXPFACTURA, self::SELECT_AVIZE));
         $settings->setSyncDataTypes(array(
             'product',
             'order',

+ 31 - 0
Core/App/Repository/Facturis/AvizeInterface.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Repository\Facturis;
+
+interface AvizeInterface extends OrderInterface
+{
+}

+ 31 - 0
Core/App/Repository/Facturis/ExpfacturaInterface.php

@@ -0,0 +1,31 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Repository\Facturis;
+
+interface ExpfacturaInterface extends OrderInterface
+{
+}

+ 34 - 0
Core/App/Repository/Facturis/InvoiceInterface.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Repository\Facturis;
+
+interface InvoiceInterface
+{
+    public function add($invoice);
+    
+    public function view($factId);
+}

+ 1 - 0
Core/App/Repository/Facturis/StockInterface.php

@@ -15,6 +15,7 @@ interface StockInterface
     public function setOptionStockFilter($optionStockFilter);
 
     public function getPdlGestiuni();
+    public function getPdls();
 
     public function testAuth();
 

+ 34 - 0
Core/App/Repository/Marketplace/AvizeInterface.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Repository\Marketplace;
+
+interface AvizeInterface extends OrderInterface
+{
+    public function setAvizeSerie($avizeSerie);
+
+//    public function addAvize($marketplaceAvize, $result);
+}

+ 34 - 0
Core/App/Repository/Marketplace/ExpfacturaInterface.php

@@ -0,0 +1,34 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Repository\Marketplace;
+
+interface ExpfacturaInterface extends OrderInterface
+{
+    public function setExpfacturaSerie($expfacturaSerie);
+
+//    public function addExpfactura($marketplaceExpfactura, $result);
+}

+ 36 - 0
Core/App/Repository/Marketplace/InvoiceInterface.php

@@ -0,0 +1,36 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Repository\Marketplace;
+
+interface InvoiceInterface extends OrderInterface
+{
+    public function setInvoiceSerie($proformaSerie);
+
+//    public function getByOrderId($orderId);
+
+//    public function addInvoice($marketplaceInvoice, $result);
+}

+ 2 - 0
Core/App/Repository/Marketplace/ProformaInterface.php

@@ -5,4 +5,6 @@ namespace Core\App\Repository\Marketplace;
 interface ProformaInterface extends OrderInterface
 {
     public function setProformaSerie($proformaSerie);
+
+//    public function addProforma($marketplaceProforma, $result);
 }

+ 5 - 2
Core/App/Repository/Marketplace/SettingsInterface.php

@@ -14,6 +14,8 @@ interface SettingsInterface
     public function getOptionStockFilter();
     public function getOptionOrderOrProforma();
     public function getOptionProformaSerie();
+    public function getOptionAvizeSerie();
+    public function getOptionExpfacturaSerie();
     public function getOptionOrderedDaysAgo();
     public function getOptionLocations();
 
@@ -32,5 +34,6 @@ interface SettingsInterface
 
     public function getSyncOrdersAs();
     public function getAutoSyncOptions();
-
-}
+//    public function getDocUpdOptions();
+//    public function getShowObsOptions();
+}

+ 109 - 0
Core/App/Service/AvizeService.php

@@ -0,0 +1,109 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Service;
+
+class AvizeService
+{
+    protected $marketplaceAvizeRepository;
+    protected $marketplaceProductRepository;
+    protected $facturisAvizeRepository;
+    protected $facturisCustomerRepository;
+    protected $facturisProductRepository;
+    protected $settingsRepository;
+
+    public function __construct(
+        \Core\App\Repository\Marketplace\AvizeInterface $marketplaceAvizeRepository,
+        \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
+        \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
+        \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
+        \Core\App\Repository\Facturis\AvizeInterface $facturisAvizeRepository,
+        \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
+    ) {
+        $this->marketplaceAvizeRepository = $marketplaceAvizeRepository;
+        $this->marketplaceProductRepository = $marketplaceProductRepository;
+        $this->facturisAvizeRepository = $facturisAvizeRepository;
+        $this->facturisCustomerRepository = $facturisCustomerRepository;
+        $this->facturisProductRepository = $facturisProductRepository;
+        $this->settingsRepository = $settingsRepository;
+    }
+
+    public function sync()
+    {
+        $facturisCustomers =  $this->facturisCustomerRepository->getAll();
+        $facturisProducts =  $this->facturisProductRepository->getAll();
+        $this->marketplaceAvizeRepository->setRemoteCustomers($facturisCustomers);
+        $this->marketplaceAvizeRepository->setRemoteProducts($facturisProducts);
+        $this->marketplaceAvizeRepository->setOrderedDaysAgo($this->settingsRepository->getOptionOrderedDaysAgo());
+        $this->marketplaceAvizeRepository->setAvizeSerie(
+            $this->settingsRepository->getOptionAvizeSerie()
+        );
+
+        $withOutDiscount = true;
+        $marketplaceProducts =  $this->marketplaceProductRepository->getAll($withOutDiscount);
+        $this->marketplaceAvizeRepository->setLocalProducts((array) $marketplaceProducts);
+        $this->marketplaceAvizeRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
+
+        $marketplaceAvizes =  $this->marketplaceAvizeRepository->getAll();
+        if (!empty($marketplaceAvizes)) {
+            foreach ($marketplaceAvizes as $marketplaceAvize) {
+                $result = $this->facturisAvizeRepository->add($marketplaceAvize);
+//                $this->marketplaceAvizeRepository->addAvize($marketplaceAvize, $result);
+            }
+        }
+    }
+
+    public function add($orderId)
+    {
+        $result = array();
+        $facturisCustomers =  $this->facturisCustomerRepository->getAll();
+        $facturisProducts =  $this->facturisProductRepository->getAll();
+        $this->marketplaceAvizeRepository->setRemoteCustomers($facturisCustomers);
+        $this->marketplaceAvizeRepository->setRemoteProducts($facturisProducts);
+
+        $avizeSerie2 = $this->settingsRepository->getOptionAvizeSerie2();
+        if (!empty($avizeSerie2)) {
+            $this->marketplaceAvizeRepository->setAvizeSerie($avizeSerie2);
+        } else {
+            $this->marketplaceAvizeRepository->setAvizeSerie($this->settingsRepository->getOptionAvizeSerie());
+        }
+        
+        $withOutDiscount = true;
+        $marketplaceProducts =  $this->marketplaceProductRepository->getAll($withOutDiscount);
+        $this->marketplaceAvizeRepository->setLocalProducts((array) $marketplaceProducts);
+        $this->marketplaceAvizeRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
+        
+        $marketplaceAvize =  $this->marketplaceAvizeRepository->getByOrderId($orderId);
+        if (!empty($marketplaceAvize)) {
+            $result = $this->facturisAvizeRepository->add($marketplaceAvize);
+            $this->marketplaceAvizeRepository->addAvize($marketplaceAvize, $result);
+
+            return $result;
+        }
+
+        return $result;
+    }
+}

+ 109 - 0
Core/App/Service/ExpfacturaService.php

@@ -0,0 +1,109 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Service;
+
+class ExpfacturaService
+{
+    protected $marketplaceExpfacturaRepository;
+    protected $marketplaceProductRepository;
+    protected $facturisExpfacturaRepository;
+    protected $facturisCustomerRepository;
+    protected $facturisProductRepository;
+    protected $settingsRepository;
+
+    public function __construct(
+        \Core\App\Repository\Marketplace\ExpfacturaInterface $marketplaceExpfacturaRepository,
+        \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
+        \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
+        \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
+        \Core\App\Repository\Facturis\ExpfacturaInterface $facturisExpfacturaRepository,
+        \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
+    ) {
+        $this->marketplaceExpfacturaRepository = $marketplaceExpfacturaRepository;
+        $this->marketplaceProductRepository = $marketplaceProductRepository;
+        $this->facturisExpfacturaRepository = $facturisExpfacturaRepository;
+        $this->facturisCustomerRepository = $facturisCustomerRepository;
+        $this->facturisProductRepository = $facturisProductRepository;
+        $this->settingsRepository = $settingsRepository;
+    }
+
+    public function sync()
+    {
+        $facturisCustomers =  $this->facturisCustomerRepository->getAll();
+        $facturisProducts =  $this->facturisProductRepository->getAll();
+        $this->marketplaceExpfacturaRepository->setRemoteCustomers($facturisCustomers);
+        $this->marketplaceExpfacturaRepository->setRemoteProducts($facturisProducts);
+        $this->marketplaceExpfacturaRepository->setOrderedDaysAgo($this->settingsRepository->getOptionOrderedDaysAgo());
+        $this->marketplaceExpfacturaRepository->setExpfacturaSerie(
+            $this->settingsRepository->getOptionExpfacturaSerie()
+        );
+
+        $withOutDiscount = true;
+        $marketplaceProducts =  $this->marketplaceProductRepository->getAll($withOutDiscount);
+        $this->marketplaceExpfacturaRepository->setLocalProducts((array) $marketplaceProducts);
+        $this->marketplaceExpfacturaRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
+
+        $marketplaceExpfacturas =  $this->marketplaceExpfacturaRepository->getAll();
+        if (!empty($marketplaceExpfacturas)) {
+            foreach ($marketplaceExpfacturas as $marketplaceExpfactura) {
+                $result = $this->facturisExpfacturaRepository->add($marketplaceExpfactura);
+//                $this->marketplaceExpfacturaRepository->addExpfactura($marketplaceExpfactura, $result);
+            }
+        }
+    }
+
+    public function add($orderId)
+    {
+        $result = array();
+        $facturisCustomers =  $this->facturisCustomerRepository->getAll();
+        $facturisProducts =  $this->facturisProductRepository->getAll();
+        $this->marketplaceExpfacturaRepository->setRemoteCustomers($facturisCustomers);
+        $this->marketplaceExpfacturaRepository->setRemoteProducts($facturisProducts);
+
+        $expfacturaSerie2 = $this->settingsRepository->getOptionExpfacturaSerie2();
+        if (!empty($expfacturaSerie2)) {
+            $this->marketplaceExpfacturaRepository->setExpfacturaSerie($expfacturaSerie2);
+        } else {
+            $this->marketplaceExpfacturaRepository->setExpfacturaSerie($this->settingsRepository->getOptionExpfacturaSerie());
+        }
+        
+        $withOutDiscount = true;
+        $marketplaceProducts =  $this->marketplaceProductRepository->getAll($withOutDiscount);
+        $this->marketplaceExpfacturaRepository->setLocalProducts((array) $marketplaceProducts);
+        $this->marketplaceExpfacturaRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
+        
+        $marketplaceExpfactura =  $this->marketplaceExpfacturaRepository->getByOrderId($orderId);
+        if (!empty($marketplaceExpfactura)) {
+            $result = $this->facturisExpfacturaRepository->add($marketplaceExpfactura);
+            $this->marketplaceExpfacturaRepository->addExpfactura($marketplaceExpfactura, $result);
+
+            return $result;
+        }
+
+        return $result;
+    }
+}

+ 84 - 0
Core/App/Service/InvoiceService.php

@@ -0,0 +1,84 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\App\Service;
+
+class InvoiceService
+{
+    protected $marketplaceInvoiceRepository;
+    protected $marketplaceProductRepository;
+    protected $facturisInvoiceRepository;
+    protected $facturisCustomerRepository;
+    protected $facturisProductRepository;
+    protected $settingsRepository;
+
+    public function __construct(
+        \Core\App\Repository\Marketplace\InvoiceInterface $marketplaceInvoiceRepository,
+        \Core\App\Repository\Marketplace\ProductInterface $marketplaceProductRepository,
+        \Core\App\Repository\Facturis\CustomerInterface $facturisCustomerRepository,
+        \Core\App\Repository\Facturis\ProductInterface $facturisProductRepository,
+        \Core\App\Repository\Facturis\InvoiceInterface $facturisInvoiceRepository,
+        \Core\App\Repository\Marketplace\SettingsInterface $settingsRepository
+    ) {
+        $this->marketplaceInvoiceRepository = $marketplaceInvoiceRepository;
+        $this->marketplaceProductRepository = $marketplaceProductRepository;
+        $this->facturisInvoiceRepository = $facturisInvoiceRepository;
+        $this->facturisCustomerRepository = $facturisCustomerRepository;
+        $this->facturisProductRepository = $facturisProductRepository;
+        $this->settingsRepository = $settingsRepository;
+    }
+
+    public function add($orderId)
+    {
+        $facturisCustomers =  $this->facturisCustomerRepository->getAll();
+        $facturisProducts =  $this->facturisProductRepository->getAll();
+        $this->marketplaceInvoiceRepository->setRemoteCustomers($facturisCustomers);
+        $this->marketplaceInvoiceRepository->setRemoteProducts($facturisProducts);
+
+        /*if(!empty($series))
+        {
+            $this->marketplaceInvoiceRepository->setInvoiceSerie($series);
+        }
+        else
+        {
+            $this->marketplaceInvoiceRepository->setInvoiceSerie($this->settingsRepository->getOptionProformaSerie());
+        }*/
+        
+        $this->marketplaceInvoiceRepository->setInvoiceSerie($this->settingsRepository->getOptionInvoiceSerie());
+
+        $withOutDiscount = true;
+        $marketplaceProducts =  $this->marketplaceProductRepository->getAll($withOutDiscount);
+        $this->marketplaceInvoiceRepository->setLocalProducts((array) $marketplaceProducts);
+        $this->marketplaceInvoiceRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
+
+        $marketplaceInvoice =  $this->marketplaceInvoiceRepository->getByOrderId($orderId);
+        if (!empty($marketplaceInvoice)) {
+            $result = $this->facturisInvoiceRepository->add($marketplaceInvoice);
+//            $this->marketplaceInvoiceRepository->addInvoice($marketplaceInvoice, $result);
+            return $result;
+        }
+    }
+}

+ 32 - 1
Core/App/Service/ProformaService.php

@@ -52,4 +52,35 @@ class ProformaService {
             }
         }
     }
-}
+
+    public function add($orderId)
+        {
+        $result = array();
+        $facturisCustomers =  $this->facturisCustomerRepository->getAll();
+        $facturisProducts =  $this->facturisProductRepository->getAll();
+        $this->marketplaceProformaRepository->setRemoteCustomers($facturisCustomers);
+        $this->marketplaceProformaRepository->setRemoteProducts($facturisProducts);
+
+        $proformaSerie2 = $this->settingsRepository->getOptionProformaSerie2();
+        if (!empty($proformaSerie2)) {
+            $this->marketplaceProformaRepository->setProformaSerie($proformaSerie2);
+        } else {
+            $this->marketplaceProformaRepository->setProformaSerie($this->settingsRepository->getOptionProformaSerie());
+        }
+
+        $withOutDiscount = true;
+        $marketplaceProducts =  $this->marketplaceProductRepository->getAll($withOutDiscount);
+        $this->marketplaceProformaRepository->setLocalProducts((array) $marketplaceProducts);
+        $this->marketplaceProformaRepository->setWithDiscount($this->settingsRepository->getOptionWithDiscount());
+
+        $marketplaceProforma =  $this->marketplaceProformaRepository->getByOrderId($orderId);
+        if (!empty($marketplaceProforma)) {
+                $result = $this->facturisProformaRepository->add($marketplaceProforma);
+                $this->marketplaceProformaRepository->addProforma($marketplaceProforma, $result);
+
+            return $result;
+        }
+
+            return $result;
+            }
+        }

+ 21 - 6
Core/App/Service/SettingsService.php

@@ -23,6 +23,11 @@ class SettingsService
         return $facturisStockRepository->getPdlGestiuni();
     }
 
+    public function getPdls(\Core\App\Repository\Facturis\StockInterface $facturisStockRepository)
+    {
+        return $facturisStockRepository->getPdls();
+    }
+
     public function getOptions()
     {
         return $this->settingsRepository->getSyncOptions();
@@ -58,6 +63,21 @@ class SettingsService
         return $this->settingsRepository->getAutoSyncOptions();
     }
 
+    public function getDocUpdOptions()
+    {
+        return $this->settingsRepository->getDocUpdOptions();
+    }
+
+    public function getShowObsOptions()
+    {
+        return $this->settingsRepository->getShowObsOptions();
+    }
+
+    public function checkLatestVersion($language, $version)
+    {
+        $this->settingsRepository->checkLatestVersion($language, $version);
+    }
+
 	public function getEnabledDisabledOptions()
     {
         return $this->settingsRepository->getEnabledDisabledOptions();
@@ -80,10 +100,5 @@ class SettingsService
         {
             return false;
         }
-    } 
-
-    public function checkLatestVersion($language)
-    {
-        $this->settingsRepository->checkLatestVersion($language);
     }
-}
+    }

+ 104 - 0
Core/FacturisRepository/AvizeRepository.php

@@ -0,0 +1,104 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\FacturisRepository;
+
+class AvizeRepository extends Repository implements \Core\App\Repository\Facturis\AvizeInterface
+{
+    const DOCUMENT_TYPE = "avize";
+    const ROMANIAN_LANG_ID = "1";
+    const RON_CURRENCY = "RON";
+    const A4_FORMAT = "1";
+
+    public function add($avize)
+    {
+
+        $response = $this->insertAvize($avize);
+
+//        $marketplaceAvizeRepository = new \MarketplaceRepository\AvizeRepository(
+//            $this->settingsRepository->getToken(),
+//            $this->settingsRepository->getShop()
+//        );
+//        $factId = $marketplaceAvizeRepository->getFactId($avize['dataFact']['id_order']);
+//
+//        $values = array(
+//            "facturi_key"=> $factId
+//        );
+//
+//        $resp = $this->checkAvize($values);
+//
+//        if(\Configuration::get('fsync_option_showobs') == 'inactiv'){
+//            $avize['dataFact']['facturi_obs_up'] = '';
+//            $avize['dataFact']['facturi_obs_client'] = '';
+//        }
+//
+//        if(\Configuration::get('fsync_option_docupd') == 'activ'){
+//
+//            if($resp == null ){
+//                $response = $this->insertAvize($avize);
+//            }else{
+//                $response = [
+//                    'id_fact' => $factId,
+//                ];
+//            }
+//
+//        } else {
+//
+//            if(!$resp == null && ($resp[0]['facturi_key'] == $factId) && ($resp[0]['facturi_status'] == 'Emisa')){
+//                $avize['dataFact']['facturi_key'] = $factId;
+//                $avize['dataFact']['facturi_data'] = $resp[0]['facturi_data'];
+//                $avize['dataFact']['facturi_numar'] = $resp[0]['facturi_serie_numar'];
+//                $response = $this->updateAvize($avize);
+//            } elseif($resp == null ){
+//                $response = $this->insertAvize($avize);
+//            }else{
+//                $response = [
+//                    'id_fact' => $factId,
+//                ];
+//            }
+//
+//        }
+//
+//        return $response;
+    }
+
+    public function view($factId)
+    {
+        $params = array(
+            "id_fact" => $factId,
+            "type" => self::DOCUMENT_TYPE,
+            "select_language" => self::ROMANIAN_LANG_ID,
+            "select_currency" => self::RON_CURRENCY,
+            "select_format" => self::A4_FORMAT
+        );
+
+        if (empty($factId)) {
+            exit;
+        }
+        
+        $this->viewAvize($params);
+    }
+}

+ 101 - 0
Core/FacturisRepository/ExpfacturaRepository.php

@@ -0,0 +1,101 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\FacturisRepository;
+
+class ExpfacturaRepository extends Repository implements \Core\App\Repository\Facturis\ExpfacturaInterface
+{
+    const DOCUMENT_TYPE = "expfactura";
+    const ROMANIAN_LANG_ID = "1";
+    const RON_CURRENCY = "RON";
+    const A4_FORMAT = "1";
+
+    public function add($expfactura)
+    {
+
+        $response = $this->insertExpfactura($expfactura);
+
+//        $marketplaceExpfacturaRepository = new \MarketplaceRepository\ExpfacturaRepository();
+//        $factId = $marketplaceExpfacturaRepository->getFactId($expfactura['dataFact']['id_order']);
+//
+//        $values = array(
+//            "facturi_key"=> $factId
+//        );
+//
+//        $resp = $this->checkExpfactura($values);
+//
+//        if(\Configuration::get('fsync_option_showobs') == 'inactiv'){
+//            $expfactura['dataFact']['facturi_obs_up'] = '';
+//            $expfactura['dataFact']['facturi_obs_client'] = '';
+//        }
+//
+//        if(\Configuration::get('fsync_option_docupd') == 'activ'){
+//
+//            if($resp == null ){
+//                $response = $this->insertExpfactura($expfactura);
+//            }else{
+//                $response = [
+//                    'id_fact' => $factId,
+//                ];
+//            }
+//
+//        } else {
+//
+//            if(!$resp == null && ($resp[0]['facturi_key'] == $factId) && ($resp[0]['facturi_status'] == 'Emisa')){
+//                $expfactura['dataFact']['facturi_key'] = $factId;
+//                $expfactura['dataFact']['facturi_data'] = $resp[0]['facturi_data'];
+//                $expfactura['dataFact']['facturi_numar'] = $resp[0]['facturi_serie_numar'];
+//                $response = $this->updateExpfactura($expfactura);
+//            } elseif($resp == null ){
+//                $response = $this->insertExpfactura($expfactura);
+//            }else{
+//                $response = [
+//                    'id_fact' => $factId,
+//                ];
+//            }
+//
+//        }
+//
+//        return $response;
+    }
+
+    public function view($factId)
+    {
+        $params = array(
+            "id_fact" => $factId,
+            "type" => self::DOCUMENT_TYPE,
+            "select_language" => self::ROMANIAN_LANG_ID,
+            "select_currency" => self::RON_CURRENCY,
+            "select_format" => self::A4_FORMAT
+        );
+
+        if (empty($factId)) {
+            exit;
+        }
+        
+        $this->viewExpfactura($params);
+    }
+}

+ 57 - 0
Core/FacturisRepository/InvoiceRepository.php

@@ -0,0 +1,57 @@
+<?php
+/**
+ * 2007-2021 PrestaShop
+ *
+ * NOTICE OF LICENSE
+ *
+ * This source file is subject to the Academic Free License (AFL 3.0)
+ * that is bundled with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://opensource.org/licenses/afl-3.0.php
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@prestashop.com so we can send you a copy immediately.
+ *
+ * DISCLAIMER
+ *
+ * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
+ * versions in the future. If you wish to customize PrestaShop for your
+ * needs please refer to http://www.prestashop.com for more information.
+ *
+ *  @author    PrestaShop SA <contact@prestashop.com>
+ *  @copyright 2007-2021 PrestaShop SA
+ *  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
+ *  International Registered Trademark & Property of PrestaShop SA
+ */
+
+namespace Core\FacturisRepository;
+
+class InvoiceRepository extends Repository implements \Core\App\Repository\Facturis\InvoiceInterface
+{
+    const ROMANIAN_LANG_ID = "1";
+    const RON_CURRENCY = "RON";
+    const A4_FORMAT = "1";
+
+    public function add($invoice)
+    {
+        $response = $this->insertInvoice($invoice);
+
+        return $response;
+    }
+
+    public function view($factId)
+    {
+        $params = array(
+            "id_fact" => $factId,
+            "select_language" => self::ROMANIAN_LANG_ID,
+            "select_currency" => self::RON_CURRENCY,
+            "select_format" => self::A4_FORMAT
+        );
+
+        if (empty($factId)) {
+            exit;
+        }
+
+        $this->viewInvoice($params);
+    }
+}

+ 119 - 15
Core/FacturisRepository/Repository.php

@@ -6,7 +6,7 @@ class Repository
 {
     const URL = "https://api.facturis-online.ro/api/";
     const CONNECTTIMEOUT = "5";
-    const TIMEOUT = "300";
+    const TIMEOUT = "500";
 
     public $apiKey;
     public $username;
@@ -44,7 +44,9 @@ class Repository
         
         $postFields = array_merge($fields, $params);
 
-        curl_setopt($this->connection,CURLOPT_POSTFIELDS, "json=" . json_encode($postFields));
+        curl_setopt($this->connection, CURLOPT_POSTFIELDS, "json=" . json_encode($postFields, JSON_PARTIAL_OUTPUT_ON_ERROR));
+        curl_setopt($this->connection, CURLOPT_SSL_VERIFYHOST, 0);
+        curl_setopt($this->connection, CURLOPT_SSL_VERIFYPEER, 0);
 
         \Core\Log\FileLog::write('Facturis Request: ' . json_encode($params), \Core\Log\FileLog::DATA); 
 
@@ -58,6 +60,15 @@ class Repository
             throw new \Exception($this->printException(json_encode($curl_error)));
         }
 
+        if ($action == 'Facturi' && $method == 'FacturiHtml') {
+            header('Content-type: application/pdf');
+            header('Content-Transfer-Encoding: binary');
+            header('Accept-Ranges: bytes');
+
+            echo $response;
+            exit;
+        }
+
 		$output = json_decode($response, true);
         if(isset($output['error']))
         {
@@ -72,8 +83,8 @@ class Repository
         if(
             ($method == 'Stoc' && $action == 'Get') || 
             ($method == 'Comenzi' && $action == 'Ins') ||
-            ($method == 'Proforme' && $action == 'Ins'))
-        {
+            ($method == 'Proforme' && $action == 'Ins') ||
+            ($method == 'Facturi' && $action == 'Ins')) {
             return $output;
         }
 
@@ -94,7 +105,10 @@ class Repository
         
         $postFields = array_merge($fields, $params);
 
-        curl_setopt($this->connection,CURLOPT_POSTFIELDS, "json=" . json_encode($postFields));
+        curl_setopt($this->connection, CURLOPT_POSTFIELDS, "json=" . json_encode($postFields, JSON_PARTIAL_OUTPUT_ON_ERROR));
+        curl_setopt($this->connection, CURLOPT_SSL_VERIFYHOST, 0);
+        curl_setopt($this->connection, CURLOPT_SSL_VERIFYPEER, 0);
+
 		$response = curl_exec( $this->connection );
 
         $curl_error = curl_error($this->connection);
@@ -134,8 +148,6 @@ class Repository
         curl_setopt($this->connection, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($this->connection, CURLOPT_HEADER, false);
         curl_setopt($this->connection, CURLOPT_TIMEOUT, self::TIMEOUT);
-        curl_setopt($this->connection, CURLOPT_SSL_VERIFYHOST, 0);
-        curl_setopt($this->connection, CURLOPT_SSL_VERIFYPEER, 0);
     }
 
     private function close()
@@ -183,6 +195,62 @@ class Repository
         return $response;
     }
 
+    protected function insertAvize($params)
+    {
+        $response = $this->getResponse("Avize", "Ins", $params);
+        return $response;
+    }
+
+    protected function insertExpfactura($params)
+    {
+        $response = $this->getResponse("Facturi", "Ins", $params);
+        return $response;
+    }
+
+
+    protected function updateProforma($params)
+    {
+        $response = $this->getResponse("Proforme", "Upd", $params);
+        return $response;
+    }
+
+    protected function updateAvize($params)
+    {
+        $response = $this->getResponse("Avize", "Upd", $params);
+        return $response;
+    }
+
+    protected function updateExpfactura($params)
+    {
+        $response = $this->getResponse("Facturi", "Upd", $params);
+        return $response;
+    }
+
+
+    protected function checkProforma($params)
+    {
+        $response = $this->getResponse("Proforme", "GetProformaIdForShop", $params);
+        return $response;
+    }
+
+    protected function checkAvize($params)
+    {
+        $response = $this->getResponse("Avize", "GetAvizeIdForShop", $params);
+        return $response;
+    }
+
+    protected function checkExpfactura($params)
+    {
+        $response = $this->getResponse("Facturi", "GetFacturiIdForShop", $params);
+        return $response;
+    }
+
+    protected function insertInvoice($params)
+    {
+        $response = $this->getResponse("Facturi", "Ins", $params);
+        return $response;
+    }
+
     protected function getCustomers()
     {
         $response = $this->getResponse("Clienti", "Get", array());
@@ -195,6 +263,26 @@ class Repository
         return $response;
     }
 
+    protected function viewProforma($params)
+    {
+        $this->getResponse("FacturiHtml", "Facturi", $params);
+    }
+
+    protected function viewAvize($params)
+    {
+        $this->getResponse("FacturiHtml", "Avize", $params);
+    }
+
+    protected function viewExpfactura($params)
+    {
+        $this->getResponse("FacturiHtml", "Expfactura", $params);
+    }
+
+    protected function viewInvoice($params)
+    {
+        $this->getResponse("FacturiHtml", "Facturi", $params);
+    }
+
     public function getPdlGestiuni()
     {
         $list = array();
@@ -212,21 +300,38 @@ class Repository
                     {
                         foreach($gestiuni as $gestiune)
                         {   
-                            if(isset($pdl['name']) && isset($gestiune['name']))
-                            {
+                            if (isset($pdl['name']) && isset($gestiune['name'])) {
+                                $id  = str_replace(" ", "_", $pdl['name']);
+                                $id .= '__' . str_replace(" ", "_", $gestiune['name']);
                                 $list[] = array(
-                                    'id' => str_replace(" ", "_", $pdl['name']) . '__' . str_replace(" ", "_", $gestiune['name']),
+                                    'id' => $id,
                                     'name' => $pdl['name'] . ' - ' . $gestiune['name'] 
                                 );
                             }
-                            
+                        }
+                    }
+                }
                         }
                     }
 
+        return $list;
                 }
             
-                
-            } 
+    public function getPdls()
+    {
+        $list = array();
+
+        $pedl = $this->getPdl();
+
+        if (!empty($pedl)) {
+            foreach ($pedl as $pdl) {
+                if (isset($pdl['id'])) {
+                    $list[] = array(
+                        'id' => $pdl['id'],
+                        'name' => $pdl['name']
+                    );
+                }
+            }
         }
 
         return $list;
@@ -237,5 +342,4 @@ class Repository
     {
         return 'Err Facturis: ' . $message . ' ';
     }
-
-}
+}

+ 79 - 19
Core/Language/English.php

@@ -7,41 +7,58 @@ class English extends AnyLanguage
     {
         $this->data['home'] = 'Home';
         $this->data['back'] = 'Back';
-        $this->data['fsync_autostock_info'] = 'Note: Automatic synchronization requires a cron job with the following URL:';
+        $this->data['fsync_autostock_info'] = 'Note: Automatic synchronization requires ';
+        $this->data['fsync_autostock_info'] .= 'a cron job with the following URL:';
         $this->data['title'] = 'Facturis Online Sync';
         $this->data['description'] = 'Synchronize data between your store and your Facturis Online account.';
         $this->data['version_text'] = 'Module Version';   
         $this->data['version_link'] = 'https://facturis-online.ro/';  
-        $this->data['check_latest_version'] = 'Click here to find the latest version'; 
+        $this->data['check_latest_version'] = 'Click here to check if you have the latest version of the module';
         $this->data['version_check_error'] = 'Version check error'; 
         $this->data['version_check_success'] = 'You have the latest version!';
         $this->data['version_check_new'] = 'There is a newer version';
         $this->data['version_check_link_1'] = 'For details click';
         $this->data['version_check_link_2'] = 'here';
-        $this->data['error_auth_data'] = 'Please fill in all the fields from the authentication section of the synchronization module';
+        $this->data['error_auth_data'] = 'Please fill in all the fields from the ';
+        $this->data['error_auth_data'] .= 'authentication section of the synchronization module';
         
         //tutorial
         $this->data['tutorial_title'] = 'Setup instructions';
         $this->data['tutorial_p'] = "Let's get started by following this guide";
-        $this->data['tutorial_1'] = 'This module helps a user of the Facturis Online platform who has a Shopify store and who wants to have synchronized, in a faster and more convenient way, the products, orders and stock between the 2 online applications';
-        $this->data['tutorial_2'] = 'The first thing before using this module is the correct completion of the section Authentication with data from his account Facturis Online';
-        $this->data['tutorial_3'] = 'The second step is to set preferences in the Options section to customize subsequent synchronization processes';
-        $this->data['tutorial_4'] = 'The last step is to choose a data type from the Synchronization section and start the synchronization process';
+        $this->data['tutorial_1']  = 'This module helps a user of the Facturis Online platform ';
+        $this->data['tutorial_1'] .= 'who has a Prestashop store ';
+        $this->data['tutorial_1'] .= 'and who wants to have synchronized, in a faster and more convenient way, ';
+        $this->data['tutorial_1'] .= 'the products, orders ';
+        $this->data['tutorial_1'] .= 'and stock between the 2 online applications';
+        $this->data['tutorial_2']  = 'The first thing before using this module is the correct ';
+        $this->data['tutorial_2'] .= 'completion of the section ';
+        $this->data['tutorial_2'] .= 'Authentication with data from his account Facturis Online';
+        $this->data['tutorial_3']  = 'The second step is to set preferences in the Options ';
+        $this->data['tutorial_3'] .= 'section to customize subsequent ';
+        $this->data['tutorial_3'] .= 'synchronization processes';
+        $this->data['tutorial_4']  = 'The last step is to choose a data type from the Synchronization section ';
+        $this->data['tutorial_4'] .= 'and start the synchronization process';
 
         //tab 1
         $this->data['tab_name_1'] = 'Synchronization';
-        $this->data['tab_description_1'] = 'Select the data type you want for synchronization and then press Syncronize button';
+        $this->data['tab_description_1'] = 'Select the data type and then press Syncronize button';
         $this->data['data_type'] = '[Choose data type]';
         $this->data['product'] = 'Products';
         $this->data['order'] = 'Orders';
         $this->data['stock'] = 'Stock';
+        $this->data['avize'] = 'Goods accompanying notices';
+        $this->data['factura'] = 'Bills';
+        $this->data['expfactura'] = 'Bills';
         $this->data['proforma'] = 'Proformas';
         $this->data['sync_btn'] = 'Synchronize';
         $this->data['datatype_error'] = 'The data type is required.';
         $this->data['sync_please_wait'] = 'Synchronizing data ... Please wait ...';
-        $this->data['authform_error'] = 'The authentication form must be completed';
+        $this->data['authform_error'] = 'The authentication form must be completed correctly and saved';
         $this->data['success_sync_prod'] = 'Successfully synchronized products!';
         $this->data['success_sync_order'] = 'Successfully synchronized orders!';
+        $this->data['success_sync_expfactura'] = 'Successfully synchronized bills!';
+        $this->data['success_sync_avize'] = 'Successfully synchronized goods accompanying notices!';
+        $this->data['success_sync_expfactura'] = 'Successfully synchronized bills!';
         $this->data['success_sync_proforma'] = 'Successfully synchronized orders! (view Proforme in Facturis Online) ';
         $this->data['success_sync_stock'] = 'Successfully synchronized stock!';
 		$this->data['start_sync_prod'] = 'Products synchronization started..';
@@ -64,38 +81,61 @@ class English extends AnyLanguage
         $this->data['auth_fiscalcode_error'] = 'Fiscal code is required.';
         $this->data['success_auth'] = 'The credentials are correct and now you have access to synchronization!';
 
-        //tab 3
-        $this->data['tab_name_3'] = 'Order Options';
+        //tab 3 and tab 4
+        $this->data['tab_name_3'] = 'Order Sync Options';
+        $this->data['tab_name_4'] = 'Stock Sync Options';
         $this->data['tab_name_3_1'] = 'Order Synchronization Options';
         $this->data['tab_name_3_2'] = 'Stock Synchronization Options';
 
         $this->data['sync_orders_as'] = 'Synchronize orders as';
         $this->data['proforma_series'] = 'Proforma series';
+        $this->data['avize_series'] = 'Goods accompanying notices series';
+        $this->data['expfactura_series'] = 'Bills series';
         $this->data['days_ago'] = 'Sync only orders created in the last few days';
         $this->data['auto_order_sync'] = 'Auto order synchronization';
+        $this->data['doc_upd'] = 'Block document change';
+        $this->data['show_obs'] = 'Show document observation';
         $this->data['auto_stock_sync'] = 'Auto stock synchronization';
+        $this->data['auto_stock_link'] = 'You can place the following URL in your crontab file, or you can click it yourself regularly';
         $this->data['activ'] = 'Enabled';
         $this->data['inactiv'] = 'Disabled';
 
         $this->data['cron_job'] = 'Note: Automatic synchronization requires a cron job with the following URL:';
         $this->data['filter_stock'] = 'Filter stock by working unit and management';
+        $this->data['filter_pdls'] = 'Work points';
+        $this->data['filter_pdls_all'] = '-';
         $this->data['filter_stock_all'] = 'All working units';
         $this->data['loading_data_please_wait'] = 'Loading data ... Please wait ...';
 
-        $this->data['option_proformaserie_error'] = 'Proforma serie is required';   
-        $this->data['option_daysago_error'] = 'Field is required and must contain only digits';  
+        $this->data['option_proformaserie_error'] = 'Proforma serie is required';
+        $this->data['option_avizeserie_error'] = 'Goods serie is required';
+        $this->data['option_expfacturaserie_error'] = 'Bill serie is required';
+        $this->data['option_daysago_error'] = 'Field is required and must contain only digits';
         $this->data['success_options'] = 'You have successfully saved the selected options!';
         $this->data['success_save_data'] = 'You have successfully saved the selected data!';
         $this->data['locations'] = 'Choose the locations where the stock will be updated';
 		$this->data['success_save_options'] = 'You have successfully saved the selected options!';
         $this->data['success_save_auth'] = 'You have successfully saved the entered credentials!';
         
+        $this->data['confirm_uninstall'] = 'Are you sure you want to uninstall the module ?';
+        
+        $this->data['proforma_invoice_options_title'] = 'Enable/disable buttons for proforma ';
+        $this->data['proforma_invoice_options_title'] .= 'and invoice on the Order View page';
+        $this->data['add_proforma'] = 'Add Proforma';
+        $this->data['add_avize'] = 'Add Goods accompanying notices';
+        $this->data['add_expfactura'] = 'Add Bill';
+        $this->data['add_invoice'] = 'Add Invoice';
+        $this->data['view_proforma'] = 'View Proforma - (PDF)';
+        $this->data['view_invoice'] = 'View Invoice - (PDF)';
+        $this->data['edit_proforma'] = 'Edit Proforma';
+        $this->data['edit_invoice'] = 'Edit Invoice';
 		$this->data['with_discount'] = 'Include discount in final price';
         $this->data['with_discount_desc'] = '(valid for orders, invoices and proforms)';
 
-
-        //tab 4
-        $this->data['tab_name_4'] = 'Stock Options';
+        $this->data['fosync_proforma_series2_label'] = 'Proforma series (optional)';
+        $this->data['fosync_invoice_series_label'] = 'Invoice series (optional)';
+        $this->data['fosync_avize_series2_label'] = 'Goods series (optional)';
+        $this->data['fosync_expfactura_series2_label'] = 'Bills series (optional)';
         
         //tab 5
         $this->data['tab_name_5'] = 'Logs';
@@ -107,16 +147,36 @@ class English extends AnyLanguage
         $this->data['success_download_log'] = 'The log file was downloaded succesfully!';
         $this->data['error_download_log'] = 'There was an error downloading the log file';
         $this->data['download_log_error_1'] = 'You must complete the start date';
-        $this->data['download_log_error_2'] = 'The start date must be less than or equal to the end date';
+        $this->data['download_log_error_2'] = 'You must complete the end date';
         $this->data['confirm_clear_log'] = 'Are you sure you want to clear the log file ?';
         $this->data['success_clear_log'] = 'The log file was cleared succesfully!';
         $this->data['error_clear_log'] = 'There was an error clearing the log file';
         $this->data['log_header_date'] = 'Date';
         $this->data['log_header_type'] = 'Type';
         $this->data['log_header_description'] = 'Description';
+
+        $this->data['success_add_proforma_a']      = 'Proforma: %s1 %s2 was successfully added for order with id: %s3';
+        $this->data['success_add_proforma_b']      = 'Proforma was successfully added for order with id: %s1';
+        $this->data['success_view_proforma']      = 'Proforma successfully viewed';
+
+        $this->data['success_add_invoice_a']      = 'Invoice: %s1 %s2 was successfully added for order with id: %s3';
+        $this->data['success_add_invoice_b']      = 'Invoice was successfully added for order with id: %s1';
+        $this->data['success_view_invoice']      = 'Invoice successfully viewed';
+
+        $this->data['no_invoice_found']      = 'Sorry, no invoices were found in ';
+        $this->data['no_invoice_found']      .= 'Facturis Online for the selected order';
+        $this->data['no_proforma_found']      = 'Sorry, but no proforma was found in ';
+        $this->data['no_proforma_found']      .= 'Facturis Online for the selected order';
+
 		$this->data['success_test_auth'] = 'Authentication testing completed successfully';
         $this->data['start_sync_process'] = 'The sync process has started';
         
+        //view order sync buttons
+        $this->data['fosync_add_proforma_btn'] = 'Add proforma';
+        $this->data['fosync_view_proforma_btn'] = 'View proforma';
+        $this->data['fosync_edit_proforma_btn'] = 'Edit proforma';
+        $this->data['fosync_add_invoice_btn'] = 'Add invoice';
+        $this->data['fosync_view_invoice_btn'] = 'View invoice';
+        $this->data['fosync_edit_invoice_btn'] = 'Edit invoice';
+    }
     }
-
-}

+ 82 - 17
Core/Language/Romanian.php

@@ -7,7 +7,8 @@ class Romanian extends AnyLanguage
     {
         $this->data['home'] = 'Acasă';
         $this->data['back'] = 'Înapoi';
-        $this->data['fsync_autostock_info'] = 'Nota: Pentru sincronizarea automata este nevoie de un cron job cu urmatorul URL: ';
+        $this->data['fsync_autostock_info']  = 'Nota: Pentru sincronizarea automata ';
+        $this->data['fsync_autostock_info'] .= 'este nevoie de un cron job cu urmatorul URL: ';
         $this->data['title'] = 'Facturis Online Sync';
         $this->data['description'] = 'Sincronizați datele între magazinul dvs. și contul Facturis Online.';
         $this->data['version_text'] = 'Versiunea modulului';   
@@ -18,31 +19,48 @@ class Romanian extends AnyLanguage
         $this->data['version_check_new'] = 'Există o versiune mai nouă';
         $this->data['version_check_link_1'] = 'Pentru detalii, accesați';
         $this->data['version_check_link_2'] = 'aici';
-		$this->data['error_auth_data'] = 'Vă rugăm să completați toate câmpurile de la secțiunea autentificare a modulului pentru sincronizare';
+        $this->data['error_auth_data']  = 'Vă rugăm să completați toate câmpurile de la secțiunea autentificare ';
+        $this->data['error_auth_data'] .= 'a modulului pentru sincronizare';
 
         //tutorial
         $this->data['tutorial_title'] = 'Instrucțiuni';
         $this->data['tutorial_p'] = 'Să începem urmând acest ghid';
-        $this->data['tutorial_1'] = 'Acest modul vine în ajutorul unui utilizator al platformei Facturis Online care are un magazin Shopify și care își dorește aibă sincronizate, într-un mod mai rapid și mai comod, produsele, comenzile și stocul între cele 2 aplicații online';
-        $this->data['tutorial_2'] = 'Primul lucrul înainte de a folosi acest modul reprezintă completarea corectă a secțiunii Autentificare cu date din contul său Facturis Online';
-        $this->data['tutorial_3'] = 'Al doilea pas este setarea unor preferințe din secțiunea Opțiuni pentru a particulariza procesele de sincronizare ulterioare';
-        $this->data['tutorial_4'] = 'Ultimul pas este alegerea unui tip de date din secțiunea Sincronizare și pornirea procesului de sincronizare';
+        $this->data['tutorial_1']  = 'Acest modul vine în ajutorul unui utilizator ';
+        $this->data['tutorial_1'] .= 'al platformei Facturis Online ';
+        $this->data['tutorial_1'] .= 'care are un magazin Prestashop și care își dorește aibă sincronizate, ';
+        $this->data['tutorial_1'] .= 'într-un mod mai rapid ';
+        $this->data['tutorial_1'] .= 'și mai comod, produsele, comenzile și stocul între cele 2 aplicații online';
+        $this->data['tutorial_2']  = 'Primul lucrul înainte de a folosi acest modul reprezintă completarea corectă a ';
+        $this->data['tutorial_2'] .= 'secțiunii Autentificare ';
+        $this->data['tutorial_2'] .= 'cu date din contul său Facturis Online';
+        $this->data['tutorial_3']  = 'Al doilea pas este setarea unor preferințe din secțiunea Opțiuni ';
+        $this->data['tutorial_3'] .= 'pentru a particulariza ';
+        $this->data['tutorial_3'] .= 'procesele de sincronizare ulterioare';
+        $this->data['tutorial_4']  = 'Ultimul pas este alegerea unui tip de date din secțiunea Sincronizare ';
+        $this->data['tutorial_4'] .= 'și pornirea procesului de sincronizare';
 
         //tab 1
         $this->data['tab_name_1'] = 'Sincronizare';
-        $this->data['tab_description_1'] = 'Selectați tipul de date pe care îl doriți pentru sincronizare și apoi apăsați butonul Sincronizare';
+        $this->data['tab_description_1'] = 'Selectați tipul de date și apoi apăsați butonul Sincronizare';
         $this->data['data_type'] = '[Alegeți tipul de date]';
         $this->data['product'] = 'Produse';
         $this->data['order'] = 'Comenzi';
         $this->data['stock'] = 'Stoc';
+        $this->data['avize'] = 'Avize de insotire a marfii';
+        $this->data['factura'] = 'Facturi';
+        $this->data['expfactura'] = 'Facturi';
         $this->data['proforma'] = 'Proforme';
         $this->data['sync_btn'] = 'Sincronizare';
         $this->data['datatype_error'] = 'Tipul de date este obligatoriu.';
         $this->data['sync_please_wait'] = 'Se sincronizează datele ... Vă rugăm să așteptați ...';
-        $this->data['authform_error'] = 'Formularul de autentificare trebuie completat';
+        $this->data['authform_error'] = 'Formularul de autentificare trebuie completat corect si salvat';
         $this->data['success_sync_prod'] = 'Produse sincronizate cu succes!';
         $this->data['success_sync_order'] = 'Comenzi sincronizate cu succes!';
-        $this->data['success_sync_proforma'] = 'Comenzi sincronizate cu succes! (vizualizați Proforme în Facturis Online)';
+        $this->data['success_sync_expfactura'] = 'Facturi sincronizate cu succes!';
+        $this->data['success_sync_avize'] = 'Avize sincronizate cu succes!';
+        $this->data['success_sync_expfactura'] = 'Facturi sincronizate cu succes!';
+        $this->data['success_sync_proforma'] = 'Comenzi sincronizate cu succes! ';
+        $this->data['success_sync_proforma'] .= '(vizualizați Proforme în Facturis Online)';
         $this->data['success_sync_stock'] = 'Stoc sincronizat cu succes!';
 		$this->data['start_sync_prod'] = 'S-a început sincronizarea produselor..';
         $this->data['start_sync_order'] = 'S-a început sincronizarea comenzilor..';
@@ -65,26 +83,36 @@ class Romanian extends AnyLanguage
         $this->data['auth_fiscalcode_error'] = 'Codul fiscal este necesar.';
         $this->data['success_auth'] = 'Datele de autentificare sunt corecte și acum aveți acces la sincronizare!';
 
-        //tab 3
-        $this->data['tab_name_3'] = 'Opțiuni comenzi';
+        //tab 3 si tab 4
+        $this->data['tab_name_3'] = 'Opțiuni sinc. comandă';
+        $this->data['tab_name_4'] = 'Opțiuni sinc. stoc';
         $this->data['tab_name_3_1'] = 'Opțiuni de sincronizare a comenzii';
         $this->data['tab_name_3_2'] = 'Opțiuni de sincronizare stoc';
 
         $this->data['sync_orders_as'] = 'Sincronizați comenzile ca';
         $this->data['proforma_series'] = 'Serie Proformă';
+        $this->data['avize_series'] = 'Serie Avize';
+        $this->data['expfactura_series'] = 'Serie Facturi';
         $this->data['days_ago'] = 'Sincronizați numai comenzile create în ultimele zile';
         $this->data['auto_order_sync'] = 'Sincronizare automată a comenzilor';
+        $this->data['doc_upd'] = 'Blocare modificare document';
+        $this->data['show_obs'] = 'Afiseaza observatii document';
         $this->data['auto_stock_sync'] = 'Sincronizare automată stoc';
+        $this->data['auto_stock_link'] = 'Puteți plasa următoarea adresă URL în fișierul crontab sau puteți face clic pe ea în mod regulat';
         $this->data['activ'] = 'Activat';
         $this->data['inactiv'] = 'Dezactivat';
 
         $this->data['cron_job'] = 'Notă: Sincronizarea automată necesită un cron job cu următoarea adresă URL:';
         $this->data['filter_stock'] = 'Filtrați stocul după punct de lucru și gestiune';
+        $this->data['filter_pdls'] = 'Punct de lucru';
+        $this->data['filter_pdls_all'] = '-';
         $this->data['filter_stock_all'] = 'Toate punctele de lucru';
         $this->data['loading_data_please_wait'] = 'Se încărcă datele ... Vă rugăm să așteptați ...';
 
-        $this->data['option_proformaserie_error'] = 'Este necesară seria Proformă';   
-        $this->data['option_daysago_error'] = 'Câmpul este obligatoriu și trebuie să conțină doar cifre';  
+        $this->data['option_proformaserie_error'] = 'Este necesară seria Proformă';
+        $this->data['option_avizeserie_error'] = 'Este necesară seria Aviz';
+        $this->data['option_expfacturaserie_error'] = 'Este necesară seria Factura';
+        $this->data['option_daysago_error'] = 'Câmpul este obligatoriu și trebuie să conțină doar cifre';
         $this->data['success_options'] = 'Ați salvat cu succes opțiunile selectate!';
         $this->data['success_save_data'] = 'Ați salvat cu succes datele introduse!';
         $this->data['locations'] = 'Alegeți locațiile în care se va actualiza stocul';
@@ -95,20 +123,35 @@ class Romanian extends AnyLanguage
          $this->data['success_save_options'] = 'Ați salvat cu succes opțiunile introduse!';
         $this->data['success_save_auth'] = 'Ați salvat cu succes datele de autentificare introduse!';
 
+        $this->data['proforma_invoice_options_title'] = 'Activare/dezactivare butoane pentru proformă ';
+        $this->data['proforma_invoice_options_title'] .= 'și factură pe pagina de Vizualizare comandă';
+        $this->data['add_proforma'] = 'Adaugă proformă';
+        $this->data['add_invoice'] = 'Adaugă factură';
+        $this->data['view_proforma'] = 'Vizualizează proformă - (PDF)';
+        $this->data['view_invoice'] = 'Vizualizează factură - (PDF)';
+        $this->data['edit_proforma'] = 'Modifică proformă';
+        $this->data['edit_invoice'] = 'Modifică factură';
 		$this->data['with_discount'] = 'Includere discount în prețul final';
         $this->data['with_discount_desc'] = '(valabil pentru comenzi, facturi si proforme)';
 
+        $this->data['fosync_proforma_series2_label'] = 'Serie proformă (opțional)';
+        $this->data['fosync_invoice_series_label'] = 'Serie factură (opțional)';
+        $this->data['fosync_avize_series2_label'] = 'Serie aviz (opțional)';
+        $this->data['fosync_expfactura_series2_label'] = 'Serie factura (opțional)';
+
         //tab 5
         $this->data['tab_name_5'] = 'Jurnale de activitate';
         $this->data['datepicker'] = 'ro';
         $this->data['download_btn'] = 'Descarcă';
         $this->data['clear_btn'] = 'Golește';
-        $this->data['tab_description_5_1'] = 'Selectați intervalul de timp și apoi apăsați butonul Descărcare pentru a obține jurnalele de activitate';
+        $this->data['tab_description_5_1'] = 'Selectați intervalul de timp ';
+        $this->data['tab_description_5_1'] .= 'și apoi apăsați butonul Descărcare pentru a obține ';
+        $this->data['tab_description_5_1'] .= 'jurnalele de activitate';
         $this->data['tab_description_5_2'] = 'Apăsați Golește pentru a reseta toate jurnalele de activitate';
         $this->data['success_download_log'] = 'Fișierul de jurnal a fost descărcat cu succes!';
         $this->data['error_download_log'] = 'A apărut o eroare la descărcarea fișierului';
         $this->data['download_log_error_1'] = 'Trebuie să completați data de început';
-        $this->data['download_log_error_2'] = 'Data de început trebuie să fie mai mică sau egal decât data de sfârșit';
+        $this->data['download_log_error_2'] = 'Trebuie să completați data de sfârșit';
         $this->data['confirm_clear_log'] = 'Sunteți sigur că doriți să ștergeți fișierul jurnal ?';
         $this->data['success_clear_log'] = 'Fișierul jurnal a fost șters cu succes!';
         $this->data['error_clear_log'] = 'A apărut o eroare la ștergerea fișierului jurnal';
@@ -116,10 +159,32 @@ class Romanian extends AnyLanguage
         $this->data['log_header_type'] = 'Tip';
         $this->data['log_header_description'] = 'Descriere';
         
+        $this->data['success_add_proforma_a']      = 'Proforma: %s1 %s2 a fost adăugată cu succes ';
+        $this->data['success_add_proforma_a']      .= 'pentru comanda cu id-ul: %s3';
+        $this->data['success_add_proforma_b']      = 'Proforma a fost adăugată cu succes pentru comanda cu id-ul: %s1';
+        $this->data['success_view_proforma']      = 'Proformă vizualizată cu succes';
+
+        $this->data['success_add_invoice_a']      = 'Factura: %s1 %s2 a fost adăugată ';
+        $this->data['success_add_invoice_a']      .= 'cu succes pentru comanda cu id-ul: %s3';
+        $this->data['success_add_invoice_b']      = 'Factura a fost adăugată cu succes pentru comanda cu id-ul: %s1';
+        $this->data['success_view_invoice']      = 'Factură vizualizată cu succes';
+
+        $this->data['no_invoice_found']       = 'Ne pare rău, dar nu a fost găsită nici o factură în Facturis Online ';
+        $this->data['no_invoice_found']      .= 'pentru comanda selectată';
+        $this->data['no_proforma_found']      = 'Ne pare rău, dar nu a fost găsită nici o proformă în Facturis Online ';
+        $this->data['no_proforma_found']      .= 'pentru comanda selectată';
+
 		$this->data['success_test_auth'] = 'Testarea pentru autentificare a fost finalizată cu succes';
         $this->data['start_sync_process'] = 'A inceput procesul de sincronizare';
 
+        $this->data['confirm_uninstall'] = 'Sigur doriți să dezinstalați modulul?';
         
+        //view order sync buttons
+        $this->data['fosync_add_proforma_btn']      = 'Adaugă proformă';
+        $this->data['fosync_view_proforma_btn']      = 'Vizualizează proformă';
+        $this->data['fosync_edit_proforma_btn']      = 'Modifică proformă';
+        $this->data['fosync_add_invoice_btn']      = 'Adaugă factură';
+        $this->data['fosync_view_invoice_btn']      = 'Vizualizează factură';
+        $this->data['fosync_edit_invoice_btn']      = 'Modifică factură';
+    }
     }
-
-}

+ 3 - 0
Database.php

@@ -150,6 +150,9 @@ class Database
         if(isset($_POST['fsync_option_filterstock'])) $new['fsync_option_filterstock'] = $_POST['fsync_option_filterstock'];
         if(isset($_POST['fsync_option_syncordersas'])) $new['fsync_option_syncordersas'] = $_POST['fsync_option_syncordersas'];
         if(isset($_POST['fsync_option_proformaserie'])) $new['fsync_option_proformaserie'] = $_POST['fsync_option_proformaserie'];
+        if(isset($_POST['fsync_option_avizeserie'])) $new['fsync_option_avizeserie'] = $_POST['fsync_option_avizeserie'];
+        if(isset($_POST['fsync_option_expfacturaserie'])) $new['fsync_option_expfacturaserie'] = $_POST['fsync_option_expfacturaserie'];
+        if(isset($_POST['fsync_option_pdls'])) $new['fsync_option_pdls'] = $_POST['fsync_option_pdls'];
         if(isset($_POST['fsync_option_daysago'])) $new['fsync_option_daysago'] = $_POST['fsync_option_daysago'];
         if(isset($_POST['fsync_option_autosyncstock']) && !isset($_POST['fsync_option_daysago'])) $new['fsync_option_locations'] = '';
         if(isset($_POST['fsync_option_locations'])) $new['fsync_option_locations'] = implode(", ", $_POST['fsync_option_locations']);

+ 121 - 0
MarketplaceRepository/AvizeRepository.php

@@ -0,0 +1,121 @@
+<?php 
+
+namespace MarketplaceRepository;
+
+class AvizeRepository
+extends OrderRepository
+implements \Core\App\Repository\Marketplace\AvizeInterface
+{
+    public $proformaSerie;
+
+    public function getAll()
+    {
+        $proformas = array();
+        $proformaFactory = new \Core\App\Factory\AvizeFactory();
+        $proformaFactory->setPrefix(self::PREFIX);
+        $proformaItemFactory = new \Core\App\Factory\AvizeItemFactory();
+        $proformaItemFactory->setPrefix(self::PREFIX);
+        $proformaItemFactory->setRemoteProducts($this->remoteProducts);
+        $proformaItemFactory->setLocalProducts($this->localProducts);
+        $proformaItemFactory->setWithDiscountOption($this->withDiscount);
+
+        $orders = $this->getOrders();
+        if(!empty($orders))
+        {
+            foreach($orders as $order)
+            {
+                if($this->isValidOrder($order))
+                {
+                    $proformaObj = $this->getAvize($proformaFactory, $order);
+
+                    $proformaProducts = $this->getOrderProducts($proformaItemFactory, $order);
+                    $proformaProducts = (array) $proformaProducts;
+
+                    $proformaTaxes = $this->getOrderTaxes($proformaItemFactory, $order);
+                    $proformaTaxes = (array) $proformaTaxes;
+
+                    $result = array();
+                    $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');
+
+                    $proformas[] = $result;
+                }   
+            }
+        }
+        
+        return $proformas;
+
+    }
+
+    public function getAvize($proformaFactory, $proforma)
+    {
+        $proformaObj = $proformaFactory->createAvize(
+            $this->proformaSerie, 
+            isset($proforma['order_number']) ? $proforma['order_number'] : '', 
+            isset($proforma['created_at']) ? $proforma['created_at'] : '',  
+            isset($proforma['currency']) ? $proforma['currency'] : '', 
+
+            isset($proforma['customer']['id']) ? $proforma['customer']['id']: '',
+            isset($proforma['customer']['first_name']) ? $proforma['customer']['first_name'] : '', 
+            isset($proforma['customer']['last_name']) ? $proforma['customer']['last_name'] : '', 
+            isset($proforma['billing_address']['company']) ? $proforma['billing_address']['company'] : '', 
+            isset($proforma['email']) ? $proforma['email'] : '', 
+
+            isset($proforma['billing_address']['first_name']) ? $proforma['billing_address']['first_name'] : '', 
+            isset($proforma['billing_address']['last_name']) ? $proforma['billing_address']['last_name'] : '', 
+            isset($proforma['billing_address']['address1']) ? $proforma['billing_address']['address1'] : '', 
+            isset($proforma['billing_address']['address2']) ? $proforma['billing_address']['address2'] : '', 
+            isset($proforma['billing_address']['zip']) ? $proforma['billing_address']['zip'] : '', 
+            isset($proforma['billing_address']['city']) ? $proforma['billing_address']['city'] : '', 
+            isset($proforma['billing_address']['province']) ? $proforma['billing_address']['province'] : '', 
+            isset($proforma['billing_address']['phone']) ? $proforma['billing_address']['phone'] : '', 
+        
+            isset($proforma['shipping_address']['first_name']) ? $proforma['shipping_address']['first_name'] : '', 
+            isset($proforma['shipping_address']['last_name']) ? $proforma['shipping_address']['last_name'] : '', 
+            isset($proforma['shipping_address']['address1']) ? $proforma['shipping_address']['address1'] : '', 
+            isset($proforma['shipping_address']['address2']) ? $proforma['shipping_address']['address2'] : '', 
+            isset($proforma['shipping_address']['zip']) ? $proforma['shipping_address']['zip'] : '', 
+            isset($proforma['shipping_address']['city']) ? $proforma['shipping_address']['city'] : '', 
+            isset($proforma['shipping_address']['province']) ? $proforma['shipping_address']['province'] : '', 
+            isset($proforma['shipping_address']['phone']) ? $proforma['shipping_address']['phone'] : '', 
+
+            $this->getPaymentMethod($proforma),
+            '',//comentarii
+            $this->getCodF((isset($proforma['billing_address']['company']) ? $proforma['billing_address']['company'] : '')),
+            '',//companie 
+            '',//$nr_inreg,
+            '',//$facturi_cont_client,
+            '',//$facturi_banca_client
+            $this->getAvizeTaxRate($proforma)
+        );
+
+        return $proformaObj;
+
+    }
+
+    public function setAvizeSerie($proformaSerie)
+    {
+        $this->proformaSerie = $proformaSerie;
+    }
+
+    protected function getAvizeTaxRate($proforma)
+    {
+        if(!isset($proforma['line_items']) || empty($proforma['line_items']))
+        {
+            return 0;
+        }
+
+        foreach($proforma['line_items'] as $line_item)
+        {
+            if(isset($line_item['tax_lines'][0]['rate']))
+            {
+                return $line_item['tax_lines'][0]['rate'];
+            }
+        }
+
+        return 0;
+    }
+}

+ 121 - 0
MarketplaceRepository/ExpfacturaRepository.php

@@ -0,0 +1,121 @@
+<?php 
+
+namespace MarketplaceRepository;
+
+class ExpfacturaRepository
+extends OrderRepository
+implements \Core\App\Repository\Marketplace\ExpfacturaInterface
+{
+    public $proformaSerie;
+
+    public function getAll()
+    {
+        $proformas = array();
+        $proformaFactory = new \Core\App\Factory\ExpfacturaFactory();
+        $proformaFactory->setPrefix(self::PREFIX);
+        $proformaItemFactory = new \Core\App\Factory\ExpfacturaItemFactory();
+        $proformaItemFactory->setPrefix(self::PREFIX);
+        $proformaItemFactory->setRemoteProducts($this->remoteProducts);
+        $proformaItemFactory->setLocalProducts($this->localProducts);
+        $proformaItemFactory->setWithDiscountOption($this->withDiscount);
+
+        $orders = $this->getOrders();
+        if(!empty($orders))
+        {
+            foreach($orders as $order)
+            {
+                if($this->isValidOrder($order))
+                {
+                    $proformaObj = $this->getExpfactura($proformaFactory, $order);
+
+                    $proformaProducts = $this->getOrderProducts($proformaItemFactory, $order);
+                    $proformaProducts = (array) $proformaProducts;
+
+                    $proformaTaxes = $this->getOrderTaxes($proformaItemFactory, $order);
+                    $proformaTaxes = (array) $proformaTaxes;
+
+                    $result = array();
+                    $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');
+
+                    $proformas[] = $result;
+                }   
+            }
+        }
+        
+        return $proformas;
+
+    }
+
+    public function getExpfactura($proformaFactory, $proforma)
+    {
+        $proformaObj = $proformaFactory->createExpfactura(
+            $this->proformaSerie, 
+            isset($proforma['order_number']) ? $proforma['order_number'] : '', 
+            isset($proforma['created_at']) ? $proforma['created_at'] : '',  
+            isset($proforma['currency']) ? $proforma['currency'] : '', 
+
+            isset($proforma['customer']['id']) ? $proforma['customer']['id']: '',
+            isset($proforma['customer']['first_name']) ? $proforma['customer']['first_name'] : '', 
+            isset($proforma['customer']['last_name']) ? $proforma['customer']['last_name'] : '', 
+            isset($proforma['billing_address']['company']) ? $proforma['billing_address']['company'] : '', 
+            isset($proforma['email']) ? $proforma['email'] : '', 
+
+            isset($proforma['billing_address']['first_name']) ? $proforma['billing_address']['first_name'] : '', 
+            isset($proforma['billing_address']['last_name']) ? $proforma['billing_address']['last_name'] : '', 
+            isset($proforma['billing_address']['address1']) ? $proforma['billing_address']['address1'] : '', 
+            isset($proforma['billing_address']['address2']) ? $proforma['billing_address']['address2'] : '', 
+            isset($proforma['billing_address']['zip']) ? $proforma['billing_address']['zip'] : '', 
+            isset($proforma['billing_address']['city']) ? $proforma['billing_address']['city'] : '', 
+            isset($proforma['billing_address']['province']) ? $proforma['billing_address']['province'] : '', 
+            isset($proforma['billing_address']['phone']) ? $proforma['billing_address']['phone'] : '', 
+        
+            isset($proforma['shipping_address']['first_name']) ? $proforma['shipping_address']['first_name'] : '', 
+            isset($proforma['shipping_address']['last_name']) ? $proforma['shipping_address']['last_name'] : '', 
+            isset($proforma['shipping_address']['address1']) ? $proforma['shipping_address']['address1'] : '', 
+            isset($proforma['shipping_address']['address2']) ? $proforma['shipping_address']['address2'] : '', 
+            isset($proforma['shipping_address']['zip']) ? $proforma['shipping_address']['zip'] : '', 
+            isset($proforma['shipping_address']['city']) ? $proforma['shipping_address']['city'] : '', 
+            isset($proforma['shipping_address']['province']) ? $proforma['shipping_address']['province'] : '', 
+            isset($proforma['shipping_address']['phone']) ? $proforma['shipping_address']['phone'] : '', 
+
+            $this->getPaymentMethod($proforma),
+            '',//comentarii
+            $this->getCodF((isset($proforma['billing_address']['company']) ? $proforma['billing_address']['company'] : '')),
+            '',//companie 
+            '',//$nr_inreg,
+            '',//$facturi_cont_client,
+            '',//$facturi_banca_client
+            $this->getExpfacturaTaxRate($proforma)
+        );
+
+        return $proformaObj;
+
+    }
+
+    public function setExpfacturaSerie($proformaSerie)
+    {
+        $this->proformaSerie = $proformaSerie;
+    }
+
+    protected function getExpfacturaTaxRate($proforma)
+    {
+        if(!isset($proforma['line_items']) || empty($proforma['line_items']))
+        {
+            return 0;
+        }
+
+        foreach($proforma['line_items'] as $line_item)
+        {
+            if(isset($line_item['tax_lines'][0]['rate']))
+            {
+                return $line_item['tax_lines'][0]['rate'];
+            }
+        }
+
+        return 0;
+    }
+}

+ 121 - 0
MarketplaceRepository/InvoiceRepository.php

@@ -0,0 +1,121 @@
+<?php 
+
+namespace MarketplaceRepository;
+
+class InvoiceRepository
+extends OrderRepository
+implements \Core\App\Repository\Marketplace\InvoiceInterface
+{
+    public $proformaSerie;
+
+    public function getAll()
+    {
+        $proformas = array();
+        $proformaFactory = new \Core\App\Factory\InvoiceFactory();
+        $proformaFactory->setPrefix(self::PREFIX);
+        $proformaItemFactory = new \Core\App\Factory\InvoiceItemFactory();
+        $proformaItemFactory->setPrefix(self::PREFIX);
+        $proformaItemFactory->setRemoteProducts($this->remoteProducts);
+        $proformaItemFactory->setLocalProducts($this->localProducts);
+        $proformaItemFactory->setWithDiscountOption($this->withDiscount);
+
+        $orders = $this->getOrders();
+        if(!empty($orders))
+        {
+            foreach($orders as $order)
+            {
+                if($this->isValidOrder($order))
+                {
+                    $proformaObj = $this->getInvoice($proformaFactory, $order);
+
+                    $proformaProducts = $this->getOrderProducts($proformaItemFactory, $order);
+                    $proformaProducts = (array) $proformaProducts;
+
+                    $proformaTaxes = $this->getOrderTaxes($proformaItemFactory, $order);
+                    $proformaTaxes = (array) $proformaTaxes;
+
+                    $result = array();
+                    $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');
+
+                    $proformas[] = $result;
+                }   
+            }
+        }
+        
+        return $proformas;
+
+    }
+
+    public function getInvoice($proformaFactory, $proforma)
+    {
+        $proformaObj = $proformaFactory->createInvoice(
+            $this->proformaSerie, 
+            isset($proforma['order_number']) ? $proforma['order_number'] : '', 
+            isset($proforma['created_at']) ? $proforma['created_at'] : '',  
+            isset($proforma['currency']) ? $proforma['currency'] : '', 
+
+            isset($proforma['customer']['id']) ? $proforma['customer']['id']: '',
+            isset($proforma['customer']['first_name']) ? $proforma['customer']['first_name'] : '', 
+            isset($proforma['customer']['last_name']) ? $proforma['customer']['last_name'] : '', 
+            isset($proforma['billing_address']['company']) ? $proforma['billing_address']['company'] : '', 
+            isset($proforma['email']) ? $proforma['email'] : '', 
+
+            isset($proforma['billing_address']['first_name']) ? $proforma['billing_address']['first_name'] : '', 
+            isset($proforma['billing_address']['last_name']) ? $proforma['billing_address']['last_name'] : '', 
+            isset($proforma['billing_address']['address1']) ? $proforma['billing_address']['address1'] : '', 
+            isset($proforma['billing_address']['address2']) ? $proforma['billing_address']['address2'] : '', 
+            isset($proforma['billing_address']['zip']) ? $proforma['billing_address']['zip'] : '', 
+            isset($proforma['billing_address']['city']) ? $proforma['billing_address']['city'] : '', 
+            isset($proforma['billing_address']['province']) ? $proforma['billing_address']['province'] : '', 
+            isset($proforma['billing_address']['phone']) ? $proforma['billing_address']['phone'] : '', 
+        
+            isset($proforma['shipping_address']['first_name']) ? $proforma['shipping_address']['first_name'] : '', 
+            isset($proforma['shipping_address']['last_name']) ? $proforma['shipping_address']['last_name'] : '', 
+            isset($proforma['shipping_address']['address1']) ? $proforma['shipping_address']['address1'] : '', 
+            isset($proforma['shipping_address']['address2']) ? $proforma['shipping_address']['address2'] : '', 
+            isset($proforma['shipping_address']['zip']) ? $proforma['shipping_address']['zip'] : '', 
+            isset($proforma['shipping_address']['city']) ? $proforma['shipping_address']['city'] : '', 
+            isset($proforma['shipping_address']['province']) ? $proforma['shipping_address']['province'] : '', 
+            isset($proforma['shipping_address']['phone']) ? $proforma['shipping_address']['phone'] : '', 
+
+            $this->getPaymentMethod($proforma),
+            '',//comentarii
+            $this->getCodF((isset($proforma['billing_address']['company']) ? $proforma['billing_address']['company'] : '')),
+            '',//companie 
+            '',//$nr_inreg,
+            '',//$facturi_cont_client,
+            '',//$facturi_banca_client
+            $this->getInvoiceTaxRate($proforma)
+        );
+
+        return $proformaObj;
+
+    }
+
+    public function setInvoiceSerie($proformaSerie)
+    {
+        $this->proformaSerie = $proformaSerie;
+    }
+
+    protected function getInvoiceTaxRate($proforma)
+    {
+        if(!isset($proforma['line_items']) || empty($proforma['line_items']))
+        {
+            return 0;
+        }
+
+        foreach($proforma['line_items'] as $line_item)
+        {
+            if(isset($line_item['tax_lines'][0]['rate']))
+            {
+                return $line_item['tax_lines'][0]['rate'];
+            }
+        }
+
+        return 0;
+    }
+}

+ 4 - 1
MarketplaceRepository/ProformaRepository.php

@@ -37,7 +37,10 @@ implements \Core\App\Repository\Marketplace\ProformaInterface
                     $result = array();
                     $result['idMarketpalce'] = self::MARKETPLACE_ID;
                     $result['dataFact'] = (array) $proformaObj;
-                    $result['dataProd'] = array_merge($proformaProducts, $proformaTaxes);	
+                    $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');
+
                     $proformas[] = $result;
                 }   
             }

+ 40 - 1
MarketplaceRepository/SettingsRepository.php

@@ -2,6 +2,7 @@
 
 namespace MarketplaceRepository;
 
+
 class SettingsRepository 
 implements \Core\App\Repository\Marketplace\SettingsInterface
 {
@@ -31,9 +32,12 @@ implements \Core\App\Repository\Marketplace\SettingsInterface
 
             isset($settings['fsync_option_autosyncstock']) ? $settings['fsync_option_autosyncstock'] : '',
             isset($settings['fsync_option_autosyncorder']) ? $settings['fsync_option_autosyncorder'] : '',
+            isset($settings['fsync_option_pdls']) ? $settings['fsync_option_pdls'] : '',
             isset($settings['fsync_option_filterstock']) ? $settings['fsync_option_filterstock'] : '',
             isset($settings['fsync_option_syncordersas']) ? $settings['fsync_option_syncordersas'] : '',
             isset($settings['fsync_option_proformaserie']) ? $settings['fsync_option_proformaserie'] : '',
+            isset($settings['fsync_option_avizeserie']) ? $settings['fsync_option_avizeserie'] : '',
+            isset($settings['fsync_option_expfacturaserie']) ? $settings['fsync_option_expfacturaserie'] : '',
             isset($settings['fsync_option_daysago']) ? $settings['fsync_option_daysago'] : '',
             isset($settings['fsync_option_locations']) ? $settings['fsync_option_locations'] : null,
 			isset($settings['fsync_option_withdiscount']) ? $settings['fsync_option_withdiscount'] : ''
@@ -85,6 +89,36 @@ implements \Core\App\Repository\Marketplace\SettingsInterface
         return $this->settings->getOptionProformaSerie();
     }
 
+    public function getOptionAvizeSerie()
+    {
+        return $this->settings->getOptionAvizeSerie();
+    }
+
+    public function getOptionExpfacturaSerie()
+    {
+        return $this->settings->getOptionExpfacturaSerie();
+    }
+
+    public function getOptionProformaSerie2()
+    {
+        return $this->settings->getOptionProformaSerie2();
+    }
+
+    public function getOptionAvizeSerie2()
+    {
+        return $this->settings->getOptionAvizeSerie2();
+    }
+
+    public function getOptionExpfacturaSerie2()
+    {
+        return $this->settings->getOptionExpfacturaSerie2();
+    }
+
+    public function getOptionInvoiceSerie()
+    {
+        return $this->settings->getOptionInvoiceSerie();
+    }
+
     public function getOptionOrderedDaysAgo()
     {
         return $this->settings->getOptionOrderedDaysAgo();
@@ -133,6 +167,9 @@ implements \Core\App\Repository\Marketplace\SettingsInterface
             'fsync_option_filterstock' => $this->settings->getOptionStockFilter(),
             'fsync_option_syncordersas' =>  $this->settings->getOptionOrderOrProforma(),
             'fsync_option_proformaserie' => $this->settings->getOptionProformaSerie(),
+            'fsync_option_avizeserie' => $this->settings->getOptionAvizeSerie(),
+            'fsync_option_expfacturaserie' => $this->settings->getOptionExpfacturaSerie(),
+            'fsync_option_pdls' => $this->settings->getOptionPdls(),
             'fsync_option_daysago' => $this->settings->getOptionOrderedDaysAgo(),
             'fsync_option_locations' => $this->settings->getOptionLocations(),
         	'fsync_option_withdiscount' => $this->settings->getOptionWithDiscount()
@@ -197,7 +234,9 @@ implements \Core\App\Repository\Marketplace\SettingsInterface
     {
         return array(
             \Core\App\Factory\SettingsFactory::SELECT_ORDER,
-            \Core\App\Factory\SettingsFactory::SELECT_PROFORMA 
+            \Core\App\Factory\SettingsFactory::SELECT_PROFORMA,
+            \Core\App\Factory\SettingsFactory::SELECT_EXPFACTURA,
+            \Core\App\Factory\SettingsFactory::SELECT_AVIZE
         );
     }
 

+ 11 - 5
View/css/form.css

@@ -19,12 +19,13 @@
 }
 
 .facturissynctab__content form header div {
-    font-size: 85% !important;
+    /*font-size: 85% !important; */
     color: #999 !important;
 }
 
 .facturissynctab__content form header h2 {
     margin: 0 0 5px 0 !important;
+    font-size: 18px !important;
 }
 
 .facturissynctab__content form > div {
@@ -40,12 +41,15 @@
 
 .facturissynctab__content form > div > label,
 .facturissynctab__content legend {
-    width: 25% !important;
+    /*width: 25% !important;*/
+    width: 31% !important;
     float: left !important;
     padding-right: 10px !important;
     font-size: 14px !important;
     position: relative !important;
     top: 5px !important;
+    border-width: 0px !important;
+    font-weight: 100 !important;
 }
 
 .facturissynctab__content form#order_option_form > div > label,
@@ -57,12 +61,14 @@
 
 .facturissynctab__content form > div > div,
 .facturissynctab__content form > div > fieldset > div {
-    width: 75% !important;
+    /*width: 75% !important;*/
+    width: 69% !important;
     float: right !important;
 }
 
 .facturissynctab__content form > div > fieldset label {
     font-size: 90% !important;
+    font-weight: 300 !important;
 }
 
 .facturissynctab__content fieldset {
@@ -80,8 +86,8 @@
     border-width: 1px !important;
     border-style: solid !important;
     border-color: #c1c1c1 !important;
-    padding: 7px !important;
-    /*padding: 4px !important; */
+    /* padding: 7px !important; */
+    padding: 3px !important;
     border-radius: 5px !important;
 }
 

+ 15 - 2
View/css/main.css

@@ -178,6 +178,7 @@
     color: #444 !important;
     text-align: center !important;
     font-weight: 400 !important;
+    font-family: sans-serif !important;
 }
 
 .facturis-online-sync h2 {
@@ -197,7 +198,8 @@
 
 .facturis-online-sync .alert,
 .facturis-online-sync .notice {
-    padding: 17px !important;
+    /* padding: 17px !important; */
+    padding: 8px !important;
     color: #721c24 !important;
     background-color: #f8d7da !important;
     /*opacity: 1 !important;
@@ -215,10 +217,16 @@
     background-color: #d4edda !important;
     color: #155724 !important;
 }
+
+.facturis-online-sync .alert.success
+{
+    padding: 17px !important;
+}
+
 .facturis-online-sync .alert.info {
     color: #004085 !important;
     background-color: #cce5ff !important;
-    margin-bottom: 10px !important;
+    margin-bottom: 13px !important;
 }
 .facturis-online-sync .alert.warning {
     color: #856404 !important;
@@ -265,6 +273,11 @@
     display: none;
 }
 
+.facturis-online-sync #alert-sync
+{
+    margin: 10px 0px !important;
+}
+
 #datepicker-container input
 {
     width: 30% !important;

+ 164 - 2
View/js/tab3.js

@@ -3,6 +3,8 @@
 function validateOption()
 {
     document.getElementById("fsync_option_proformaserie_error").style.display = "none";
+    document.getElementById("fsync_option_avizeserie_error").style.display = "none";
+    document.getElementById("fsync_option_expfacturaserie_error").style.display = "none";
     document.getElementById("fsync_option_daysago_error").style.display = "none";
 
     var days = document.getElementById("fsync_option_daysago").value;
@@ -21,6 +23,16 @@ function validateOption()
                 document.getElementById("fsync_option_proformaserie_error").style.display = "block";
                 $error = true;
             }
+            if(radios[i].value == 'avize' && document.getElementById("fsync_option_avizeserie").value == '')
+            {
+                document.getElementById("fsync_option_avizeserie_error").style.display = "block";
+                $error = true;
+            }
+            if(radios[i].value == 'expfactura' && document.getElementById("fsync_option_expfacturaserie").value == '')
+            {
+                document.getElementById("fsync_option_expfacturaserie_error").style.display = "block";
+                $error = true;
+            }
         }
     }  
 
@@ -54,18 +66,168 @@ function showOrHideProformaSerie()
             if(radios[i].value == 'proforma') 
             { 
                 document.getElementById("fsync_option_proformaserie").parentElement.parentElement.style.display = 'block';
-            } 
+                document.getElementById("fsync_option_avizeserie").parentElement.parentElement.style.display = 'none';
+                document.getElementById("fsync_option_expfacturaserie").parentElement.parentElement.style.display = 'none';
+            }
+            else if(radios[i].value == 'avize')
+            {
+                document.getElementById("fsync_option_avizeserie").parentElement.parentElement.style.display = 'block';
+                document.getElementById("fsync_option_proformaserie").parentElement.parentElement.style.display = 'none';
+                document.getElementById("fsync_option_expfacturaserie").parentElement.parentElement.style.display = 'none';
+            }
+            else if(radios[i].value == 'expfactura')
+            {
+                document.getElementById("fsync_option_expfacturaserie").parentElement.parentElement.style.display = 'block';
+                document.getElementById("fsync_option_avizeserie").parentElement.parentElement.style.display = 'none';
+                document.getElementById("fsync_option_proformaserie").parentElement.parentElement.style.display = 'none';
+            }
             else 
             {  
                 document.getElementById("fsync_option_proformaserie").parentElement.parentElement.style.display = 'none';
+                document.getElementById("fsync_option_avizeserie").parentElement.parentElement.style.display = 'none';
+                document.getElementById("fsync_option_expfacturaserie").parentElement.parentElement.style.display = 'none';
             }
 
             break;
         }
-    }    
+    }
+}
+
+function showOrHideProformaSerie2()
+{
+    var radios = document.getElementsByClassName("fsync_option_addproforma");
+	for (var i = 0, length = radios.length; i < length; i++) {
+        if (radios[i].checked) {
+            var element = document.getElementById("fsync_option_proformaserie2");
+            if(radios[i].value == 'activ')
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'block';
+            }
+            else
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'none';
+            }
+
+            break;
+        }
+    }
+}
+
+function showOrHideAvizeSerie()
+{
+    var radios = document.getElementsByClassName("fsync_option_syncordersas");
+	for (var i = 0, length = radios.length; i < length; i++) {
+        if (radios[i].checked) {
+            if(radios[i].value == 'avize')
+            {
+                document.getElementById("fsync_option_avizeserie").parentElement.parentElement.style.display = 'block';
+            }
+            else
+            {
+                document.getElementById("fsync_option_avizeserie").parentElement.parentElement.style.display = 'none';
+            }
+
+            break;
+        }
+    }
+}
+
+function showOrHideExpfacturaSerie()
+{
+    var radios = document.getElementsByClassName("fsync_option_syncordersas");
+	for (var i = 0, length = radios.length; i < length; i++) {
+        if (radios[i].checked) {
+            if(radios[i].value == 'expfactura')
+            {
+                document.getElementById("fsync_option_expfacturaserie").parentElement.parentElement.style.display = 'block';
+            }
+            else
+            {
+                document.getElementById("fsync_option_expfacturaserie").parentElement.parentElement.style.display = 'none';
+            }
+
+            break;
+        }
+    }
+}
+
+function showOrHideAvizeSerie2()
+{
+    var radios = document.getElementsByClassName("fsync_option_addavize");
+	for (var i = 0, length = radios.length; i < length; i++) {
+        if (radios[i].checked) {
+            var element = document.getElementById("fsync_option_avizeserie2");
+            if(radios[i].value == 'activ')
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'block';
+            }
+            else
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'none';
+            }
+
+            break;
+        }
+    }
+}
+
+function showOrHideExpfacturaSerie2()
+{
+    var radios = document.getElementsByClassName("fsync_option_addexpfactura");
+	for (var i = 0, length = radios.length; i < length; i++) {
+        if (radios[i].checked) {
+            var element = document.getElementById("fsync_option_expfacturaserie2");
+            if(radios[i].value == 'activ')
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'block';
+            }
+            else
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'none';
+            }
+
+            break;
+        }
+    }
 }
 
+function showOrHideInvoiceSerie()
+{
+    var radios = document.getElementsByClassName("fsync_option_addinvoice");
+	for (var i = 0, length = radios.length; i < length; i++) {
+        if (radios[i].checked) {
+            var element = document.getElementById("fsync_option_invoiceserie");
+            if(radios[i].value == 'activ')
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'block';
+            }
+            else
+            {
+                element.parentElement.parentElement.parentElement.style.display = 'none';
+            }
 
+            break;
+        }
+    }    
+}
 
+function getPdls()
+{
+    var params = '';
+    params += '&fsync_option_pdls=' + document.getElementById("fsync_option_pdls_hidden").value;
+    params = encodeURI(params);
 
+    var xhttp;
+    xhttp = new XMLHttpRequest();
+    xhttp.onreadystatechange = function() {
+        if (this.readyState == 4 && this.status == 200) {
+            if( this.responseText != '')
+            {
+                document.getElementById("fsync_option_pdls").innerHTML = this.responseText;
+            }
+        }
+    };
 
+    xhttp.open("GET","ajax.php?random=" + Math.random() + "&action=getPdls" + params,true);
+    xhttp.send();
+}

+ 48 - 2
View/main.php

@@ -123,8 +123,54 @@
     <script type="text/javascript" src="View/js/tab5.js"></script>
     <script type="text/javascript" src="View/vanillajs-datepicker/dist/js/datepicker-full.min.js"></script>
     <script>
-      getPdlGestiuni();
-      showOrHideProformaSerie();
+  document.getElementById("fsync-datatype-error").style.display = "none";
+  document.getElementById("fsync-authform-error").style.display = "none";
+
+  document.getElementById("fsync_auth_apikey_error").style.display = "none";
+  document.getElementById("fsync_auth_username_error").style.display = "none";
+  document.getElementById("fsync_auth_password_error").style.display = "none";
+  document.getElementById("fsync_auth_fiscalcode_error").style.display = "none";
+  document.getElementById("authform_error").style.display = "none";
+
+  document.getElementById("fsync_option_proformaserie_error").style.display = "none";
+  document.getElementById("fsync_option_avizeserie_error").style.display = "none";
+  document.getElementById("fsync_option_expfacturaserie_error").style.display = "none";
+  document.getElementById("fsync_option_daysago_error").style.display = "none";
+
+  // document.getElementById('input-date-start').value = '';
+  //
+  // var dateFormat = "dd.mm.yy";
+  // var from = $('#input-date-start').datepicker({ dateFormat: 'dd.mm.yy', maxDate: '0' });
+  // var to = $('#input-date-stop').datepicker({ dateFormat: 'dd.mm.yy', maxDate: '0' } );
+  //
+  // from.on( "change", function() {
+  //     to.datepicker( "option", "minDate", getDate( this ) );
+  // });
+  //
+  // to.on( "change", function() {
+  //   from.datepicker( "option", "maxDate", getDate( this ) );
+  // });
+  //
+  // function getDate( element ) {
+  //   var date;
+  //   try {
+  //     date = $.datepicker.parseDate( dateFormat, element.value );
+  //   } catch( error ) {
+  //     date = null;
+  //   }
+  //
+  //   return date;
+  // }
+
+  showOrHideProformaSerie();
+  showOrHideProformaSerie2();
+  showOrHideAvizeSerie();
+  showOrHideExpfacturaSerie();
+  showOrHideAvizeSerie2();
+  showOrHideExpfacturaSerie2();
+  showOrHideInvoiceSerie();
+  getPdlGestiuni();
+  getPdls();
 
       const elem = document.getElementById('datepicker-container');
       const rangepicker = new DateRangePicker(elem, {

+ 28 - 0
View/tab3.php

@@ -27,6 +27,34 @@
     </div>
 
     <div>
+        <label class="desc" id="option_pdls_legend" for="option_pdls">
+            <?php echo $filter_pdls; ?>
+        </label>
+        <div>
+            <select id="fsync_option_pdls" name="fsync_option_pdls" class="field select medium">
+                <option value=""><?php echo $loading_data_please_wait; ?></option>
+            </select>
+            <input type="hidden" id="fsync_option_pdls_hidden" value="<?php echo $option['fsync_option_pdls']; ?>" />
+        </div>
+    </div>
+
+    <div>
+        <label class="desc" id="fsync_option_avizeserie_label" for="fsync_option_avizeserie"><?php echo $avize_series;?></label>
+        <div>
+            <input id="fsync_option_avizeserie" name="fsync_option_avizeserie" type="text" class="field text fn" value="<?php echo $option['fsync_option_avizeserie']; ?>">
+            <div id="fsync_option_avizeserie_error" class="red hide"><small><?php echo $option_avizeserie_error;?></small></div>
+        </div>
+    </div>
+
+    <div>
+        <label class="desc" id="fsync_option_expfacturaserie_label" for="fsync_option_expfacturaserie"><?php echo $expfactura_series;?></label>
+        <div>
+            <input id="fsync_option_expfacturaserie" name="fsync_option_expfacturaserie" type="text" class="field text fn" value="<?php echo $option['fsync_option_expfacturaserie']; ?>">
+            <div id="fsync_option_expfacturaserie_error" class="red hide"><small><?php echo $option_expfacturaserie_error;?></small></div>
+        </div>
+    </div>
+
+    <div>
         <label class="desc" id="fsync_option_proformaserie_label" for="fsync_option_proformaserie"><?php echo $proforma_series;?></label>
         <div>
             <input id="fsync_option_proformaserie" name="fsync_option_proformaserie" type="text" class="field text fn" value="<?php echo $option['fsync_option_proformaserie']; ?>">

+ 23 - 0
View/tab4.php

@@ -74,3 +74,26 @@
     
 </form>
 
+<!--<script>-->
+<!--    if($("#fsync_option_autosyncstockactiv").is(':checked')) {-->
+<!--        $('#fsync_option_link').show();-->
+<!--    } else {-->
+<!--        $('#fsync_option_link').hide();-->
+<!--    }-->
+<!---->
+<!--    $("#fsync_option_autosyncstockactiv").change(function() {-->
+<!--        if(this.checked) {-->
+<!--            $('#fsync_option_link').show();-->
+<!--        } else {-->
+<!--            $('#fsync_option_link').hide();-->
+<!--        }-->
+<!--    });-->
+<!---->
+<!--    $("#fsync_option_autosyncstockinactiv").change(function() {-->
+<!--        if(this.checked) {-->
+<!--            $('#fsync_option_link').hide();-->
+<!--        } else {-->
+<!--            $('#fsync_option_link').show();-->
+<!--        }-->
+<!--    });-->
+<!--</script>-->

File diff suppressed because it is too large
+ 0 - 1534
logs/file-.log


File diff suppressed because it is too large
+ 0 - 23
logs/file-facturis-online-dev-2.log