Add possibility to synchronize deleted entries
1 files added
4 files modified
| | |
| | | die(); |
| | | } |
| | | |
| | | if ($event['changeType'] === 'delete') { |
| | | if($synchronizer->delete($event['extraData']['entity'])) { |
| | | echo 'Object deleted'; |
| | | } else { |
| | | echo 'Nothing to do'; |
| | | } |
| | | } else { |
| | | if ($synchronizer->synchronize($event['entityId'])) { |
| | | echo 'Object synchronized'; |
| | | } else { |
| | | echo 'Nothing to do'; |
| | | } |
| | | } |
| | | } catch (Exception $e) { |
| | | header('HTTP/1.1 500 Internal Server Error'); |
| | | echo $e; |
| | |
| | | use \Webit\WFirmaSDK\Contractors as Contractors; |
| | | use \Webit\WFirmaSDK\Payments as Payments; |
| | | |
| | | class ContractorSynchronizer { |
| | | protected $wfirma; |
| | | protected $helper; |
| | | |
| | | function __construct(\Webit\WFirmaSDK\Entity\ModuleApiFactory $wFirmaApi, UcrmHelper $ucrmHelper) { |
| | | $this->wfirma = $wFirmaApi; |
| | | $this->helper = $ucrmHelper; |
| | | } |
| | | |
| | | function synchronize($ucrmClientId) { |
| | | class ContractorSynchronizer extends Synchronizer { |
| | | function synchronize(int $ucrmClientId) { |
| | | $crm = $this->helper->getApi(); |
| | | $wFirmaContractors = $this->wfirma->contractorsApi(); |
| | | |
| | |
| | | use \Webit\WFirmaSDK\Invoices as Invoices; |
| | | use \Webit\WFirmaSDK\Payments as Payments; |
| | | |
| | | class InvoiceSynchronizer { |
| | | protected $wfirma; |
| | | protected $helper; |
| | | |
| | | function __construct(\Webit\WFirmaSDK\Entity\ModuleApiFactory $wFirmaApi, UcrmHelper $ucrmHelper) { |
| | | $this->wfirma = $wFirmaApi; |
| | | $this->helper = $ucrmHelper; |
| | | } |
| | | |
| | | class InvoiceSynchronizer extends Synchronizer { |
| | | function getContractorId($clientId, $synchronize = TRUE) { |
| | | if ($synchronize) { |
| | | $synchronizer = new ContractorSynchronizer($this->wfirma, $this->helper); |
| | |
| | | [$c2->name(), $c2->unit(), $c2->count(), $c2->price(), $c2->vat(), $c2->discount()]; |
| | | } |
| | | |
| | | function synchronize($ucrmInvoiceId) { |
| | | function synchronize(int $ucrmInvoiceId) { |
| | | $crm = $this->helper->getApi(); |
| | | $wFirmaInvoices = $this->wfirma->invoicesApi(); |
| | | |
| | |
| | | use \Webit\WFirmaSDK\Invoices as Invoices; |
| | | use \Webit\WFirmaSDK\Payments as Payments; |
| | | |
| | | class PaymentSynchronizer { |
| | | protected $wfirma; |
| | | protected $helper; |
| | | class PaymentSynchronizer extends Synchronizer { |
| | | protected $ucrmMainDir; |
| | | |
| | | function __construct(\Webit\WFirmaSDK\Entity\ModuleApiFactory $wFirmaApi, UcrmHelper $ucrmHelper) { |
| | | $this->wfirma = $wFirmaApi; |
| | | $this->helper = $ucrmHelper; |
| | | parent::__construct($wFirmaApi, $ucrmHelper); |
| | | |
| | | $backtrace = debug_backtrace(); |
| | | $backtrace = end($backtrace); |
| | |
| | | [$p2->objectName(), $p2->objectId(), $p2->amount()->value(), $p2->date()->format('Y-m-d'), $p2->paymentMethod()]; |
| | | } |
| | | |
| | | function synchronize($ucrmPaymentId) { |
| | | function synchronize(int $ucrmPaymentId) { |
| | | $crm = $this->helper->getApi(); |
| | | $wFirmaPaymentsApi = $this->wfirma->paymentsApi(); |
| | | |
| New file |
| | |
| | | <?php |
| | | |
| | | namespace SIPL\UCRM\wFirma; |
| | | |
| | | abstract class Synchronizer { |
| | | protected $wfirma; |
| | | protected $helper; |
| | | |
| | | function __construct(\Webit\WFirmaSDK\Entity\ModuleApiFactory $wFirmaApi, UcrmHelper $ucrmHelper) { |
| | | $this->wfirma = $wFirmaApi; |
| | | $this->helper = $ucrmHelper; |
| | | } |
| | | |
| | | public function synchronize(int $entityId) { |
| | | return FALSE; |
| | | } |
| | | |
| | | public function delete(array $entity) { |
| | | return FALSE; |
| | | } |
| | | } |