ALTER TABLE `sales_header`   ADD `synced` TINYINT NOT NULL DEFAULT '0' AFTER `customer_pin`, ADD `synced_on` DATETIME NULL AFTER `synced`; 
ALTER TABLE `vendorinvoices` ADD `synced` TINYINT NOT NULL DEFAULT '0' AFTER `totalAmount`,  ADD `synced_on` DATETIME NULL AFTER `synced`; 

CREATE TABLE `sync_data` (
  `id` int(11) NOT NULL,
  `sync_type` varchar(50) NOT NULL,
  `server_time` datetime NOT NULL,
  `added_on` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

ALTER TABLE `sync_data`
  ADD PRIMARY KEY (`id`);
ALTER TABLE `sync_data`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

UPDATE `sales_header` SET `doc_no` = CONCAT('SA',doc_no);
UPDATE `express_sale_payments` SET sales_code = CONCAT('SA',sales_code);
UPDATE `sales_lines` SET header_no = CONCAT('SA',header_no);
UPDATE `numberseries` SET prefix = 'SA' ,length = length+2, lastNumberUsed= CONCAT('SA',lastNumberUsed) WHERE code = 41;

UPDATE `vendorinvoicelines` SET invoiceNo = CONCAT('PSA',invoiceNo);
UPDATE `vendorinvoices` set invoiceNo = CONCAT('PSA',invoiceNo);
UPDATE `numberseries` SET prefix = 'PSA' ,length = length+3, lastNumberUsed= CONCAT('PSA',lastNumberUsed) WHERE code = 32;


INSERT INTO `submodules` ( `moduleId`, `description`, `selectionCode`, `enabled`, `data_url`, `icon`) VALUES
(12, 'Local Purchase Orders', 1401, 1, 'masterfetch?type=vendor', NULL);

/*
http://localhost/kisajushops/sync.php
900000
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe C:\sync\Debug\KuzaERPSyncService.exe

SELECT * FROM `sales_header` where synced = 0 and posted = 1
http://localhost/kisajushops/functions?mode=dev

*/
