﻿#Date 04-07-2008

CREATE TABLE `purchasesjvdt` (
  `PurchaseJVDt_Id` DOUBLE,
  `PurchaseJV_Id` DOUBLE,
  `Supplier_Code` VARCHAR(10),
  `ledger_number` VARCHAR(10),
  PRIMARY KEY (`PurchaseJVDt_Id`)
)
ENGINE = InnoDB;
ALTER TABLE `purchasesjvdt` ADD COLUMN `ledger_number` VARCHAR(20) ;

ALTER TABLE `adjustmentdt` ADD COLUMN `Invcreditaccount` VARCHAR(20) ;
ALTER TABLE `productionrm` ADD COLUMN `ProductionDt_DirectStkCrd` VARCHAR(20) ;
ALTER TABLE `clients` ADD COLUMN `ledger_number` VARCHAR(20) ;
ALTER TABLE `clients` ADD COLUMN `Client_InvLanguage` VARCHAR(20) ;

CREATE TABLE `purchasesjv` (
  `PurchaseJV_Id` DOUBLE NOT NULL AUTO_INCREMENT,
  `PurchaseJV_Reference` DOUBLE,
  `PurchaseJV_Date` DATETIME,
  `Supplier_Code` VARCHAR(10),
  PRIMARY KEY (`PurchaseJV_Id`)
)
ENGINE = InnoDB;

ALTER TABLE `transactionrate` DROP FOREIGN KEY `adjusttransactionraterelated_id`,
 DROP FOREIGN KEY `delivtransactionraterelated_id`,
 DROP FOREIGN KEY `purchtransactionraterelated_id`,
 DROP FOREIGN KEY `salestransactionraterelated_id`;

 
ALTER TABLE `purchasesetup` MODIFY COLUMN `DefaultPrice_FobORLast` INTEGER DEFAULT NULL;

#Date 12-07-2008
ALTER TABLE `clients` MODIFY COLUMN `client_compownertitle` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `client_referedbytitle` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `client_GCIno` DOUBLE,
 MODIFY COLUMN `client_dlvareacode` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `client_invrounded` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `client_paytermtype` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `client_activated` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `client_pobox` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `client_dlvfax` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `client_dlvworktitle` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;


ALTER TABLE `clients` ADD COLUMN `Client_InvLanguage` VARCHAR(20) ;

ALTER TABLE `salesmen` ADD COLUMN `Manager_Code` VARCHAR(10) ,
 ADD COLUMN `Salesman_IsManager` BOOLEAN ;

CREATE TABLE `Banks` (
  `Bank_ID` INTEGER NOT NULL,
  `bank_Name` VARCHAR(50),
  `Bank_Branch` VARCHAR(50),
  `Bank_InterestRate` DOUBLE,
  `Bank_CrdLimit` DOUBLE,
  `Currency_Code` VARCHAR(6),
  PRIMARY KEY (`Bank_ID`)
);

CREATE TABLE `BankLoan` (
  `Loan_ID` INTEGER NOT NULL,
  `Bank_ID` INTEGER,
  `Loan_Desc` VARCHAR(50),
  `Loan_RePaymentTerms` VARCHAR(100),
  `Loan_RepaymentAmnt` DOUBLE,
  `Loan_Amount` DOUBLE,
  `Loan_SubSidyRate` DOUBLE,
  `Loan_CommissionRate` DOUBLE,
  `Loan_Guarantee` VARCHAR(100),
  `Loan_GracePeriod` VARCHAR(30),
  `Loan_Purpose` VARCHAR(100),
  PRIMARY KEY (`Loan_ID`),
  CONSTRAINT `BankBank_ID` FOREIGN KEY `BankBank_ID` (`Bank_ID`)
    REFERENCES `banks` (`Bank_ID`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
);

ALTER TABLE `sequence` ADD COLUMN `Bank_ID` INTEGER,
 ADD COLUMN `Bank_Loan` INTEGER ;
 
ALTER TABLE `banks` 
  ADD UNIQUE INDEX `NameBranch`(`Bank_Name`,`Bank_Branch`);




ALTER TABLE `accesslabelsrocky`.`login`
 Add Column `FA_Banks` BOOLEAN default 0,
 Add COLUMN `FA_BankApp` BOOLEAN default 0,
 Add COLUMN `FA_BankDel` BOOLEAN default 0,
 Add COLUMN `FA_BankMod` BOOLEAN default 0 ;
	
alter table journaldt
  add constraint `journaldtLedger_Number` foreign key `journaldtLedger_Number`(`ledger_Number`)
    references `ledger`(`ledger_number`)
    On Delete Restrict
    On Update Restrict;

#Date 22.07.2008
DELIMITER $$

DROP PROCEDURE IF EXISTS `DeleteChecksInJournal` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteChecksInJournal`(IN jid DOUBLE)
BEGIN
  declare jdtid double;
  declare done tinyint(1);

  declare cur cursor for select journaldt_id from journaldt where journal_id = jid;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  set done = 0;

  open cur;

  REPEAT
    fetch cur into jdtid;
    if not done then
      call DeleteChecks(jdtid);
    end if;
  UNTIL done END REPEAT;
	
	close cur;


END $$

DELIMITER ;

DELIMITER $$

DROP PROCEDURE IF EXISTS `DeleteChecks` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteChecks`(IN Jdtid DOUBLE)
BEGIN
  declare chknumber varchar(20);
  declare lnumber varchar(10);
  declare done tinyint(1);
  declare cur cursor for
    Select chk_number,ledger_number from chkjour where journaldt_id = Jdtid;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  Set done = false;
  open cur;

  REPEAT

    fetch cur into chknumber,lnumber;

    if not done then
        delete from checks where chk_number = chknumber and ledger_number = lnumber;

    end if;

  UNTIL done END REPEAT;
	
	close cur;


END $$

DELIMITER ;

######################################################################################

DELIMITER $$

DROP FUNCTION IF EXISTS `CanDeleteChkJour` $$
CREATE DEFINER=`root`@`localhost` FUNCTION `CanDeleteChkJour`(JournaldtId double) RETURNS tinyint(1)
BEGIN



  declare j_id double;
  declare checks int;
  declare chtype char;
  declare done tinyint(1);


  Declare chkcur cursor for select Journaldt_id2,checks.chk_increment,chkjour.chk_type from checks
    inner join chkjour on (checks.Ledger_Number = chkJour.Ledger_Number) and (checks.Chk_Number = chkjour.Chk_Number)
  where (chkjour.Journaldt_id = journaldtID);


  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  set done = 0;


  open chkcur;


  REPEAT

    fetch chkcur into j_id,checks,chtype;


    if NOT done then

      if (j_id != 0)  and (chtype = 'A') then
        return false;
      end if;

      update checks set Journaldt_id2 = 0 where chk_increment = checks  and (chtype != 'A');

    end if;

   UNTIL done END REPEAT;

  CLOSE chkcur;

  return true;

END $$

DELIMITER ;

DELIMITER $$

DROP FUNCTION IF EXISTS `CanDeleteJournalDt` $$
CREATE DEFINER=`root`@`localhost` FUNCTION `CanDeleteJournalDt`(JournalID double) RETURNS tinyint(1)
BEGIN

  Declare done tinyint(1);
  Declare jdt_id double;

  DECLARE jdtcur cursor for select journaldt_id from journaldt where journal_id = JournalID;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  set done = 0;

  open jdtcur;

  repeat

    fetch jdtcur into jdt_id;

    if not done then

      if not CanDeleteChkJour(jdt_id) or not CanDeleteBillJour(jdt_id) then
        return false;

      end if;

    end if;

  until done end repeat;

  return true;


END $$

DELIMITER ;

DELIMITER $$

DROP FUNCTION IF EXISTS `CanDeleteBillJour` $$
CREATE DEFINER=`root`@`localhost` FUNCTION `CanDeleteBillJour`(JournaldtId double) RETURNS int(11)
BEGIN

  
  declare j_id double;
  declare bills int;
  declare billtype char;
  declare done tinyint(1);

  
  Declare billcur cursor for

    select Journaldt_id2,bills.bill_increment,billjour.bill_type from bills
      inner join billjour on (bills.Ledger_Number = billjour.Ledger_Number) and (Bills.Bill_Number = Billjour.bill_Number)
    where (billjour.Journaldt_id = journaldtID);

  
  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  set done = 0;

  
  open billcur;

  
  REPEAT

    fetch billcur into j_id,bills,billtype;

    
    if NOT done then

       if j_id != 0   and (billtype = 'A') then
          return false;
       end if;


      update bills set Journaldt_id2 = 0 where bill_increment = bills and (billtype = 'A');

    end if;

   UNTIL done END REPEAT;

  CLOSE billcur;

  return true;


END $$

DELIMITER ;

DELIMITER $$

DROP PROCEDURE IF EXISTS `DeleteBillsInJournal` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteBillsInJournal`(IN jid DOUBLE)
BEGIN
  declare jdtid double;
  declare done tinyint(1);

  declare cur cursor for select journaldt_id from journaldt where journal_id = jid;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  set done = 0;

  open cur;

  REPEAT
    fetch cur into jdtid;
    if not done then
      call DeleteBills(jdtid);
    end if;
  UNTIL done END REPEAT;

	close cur;


END $$

DELIMITER ;

DELIMITER $$

DROP PROCEDURE IF EXISTS `DeleteBills` $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `DeleteBills`(IN Jdtid DOUBLE)
BEGIN
  declare billnumber varchar(20);
  declare lnumber varchar(10);
  declare done tinyint(1);
  declare cur cursor for
    Select bill_number,ledger_number from billjour where journaldt_id = Jdtid;

  DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

  Set done = false;
  open cur;

  REPEAT

    fetch cur into billnumber,lnumber;

    if not done then
        delete from bills where bill_number = billnumber and ledger_number = lnumber;

    end if;

  UNTIL done END REPEAT;

	close cur;


END $$

DELIMITER ;

######################################################################################

#DATE 23-07-2008
ALTER TABLE `budget` MODIFY COLUMN `Ledger_number` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT null;
ALTER TABLE `budget` MODIFY COLUMN `Project_Code` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT null;
ALTER TABLE `budget`  MODIFY COLUMN `CostCenter_Code` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT null;
ALTER TABLE `budget`  MODIFY COLUMN `Budget_DBCD` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT null;
ALTER TABLE `budget`  ADD COLUMN `Budget_ID` INTEGER NOT NULL ;
#AUTO_INCREMENT ;
ALTER TABLE `budget`  DROP PRIMARY KEY;
ALTER TABLE `budget`  ADD PRIMARY KEY (`Budget_ID`);
ALTER TABLE `budget`  ADD UNIQUE INDEX `InitialIndex`(`Ledger_number`, `Project_Code`, `CostCenter_Code`, `Budget_DBCD`);



CREATE TABLE `PRequest` (
  `PRqst_id` DOUBLE NOT NULL,
  `PRqst_reference` DOUBLE NOT NULL,
  `PRqst_date` DATETIME NOT NULL,
  `PRqst_RequestDate` DATETIME,
  `PRqst_RequestBy` VARCHAR(50),
  `PRqst_remark` VARCHAR(100),
  `Supplier_Code` VARCHAR(10),
  `PRqst_SupplierContract` VARCHAR(50),
  `Currency_Code` VARCHAR(6),
  `Costcent_Code` VARCHAR(15),
  `PRqst_warranty` VARCHAR(150),
  `PRqst_document` VARCHAR(150),
  `PRqst_DeliveryDate` DATETIME,
  `PRqst_DeliveryPlace` VARCHAR(50),
  `PRqst_DeliveryContact` VARCHAR(50),
  `PRqst_DeliveryTelephone` VARCHAR(15),
  `PRqst_DeliveryFax` VARCHAR(15),
  `PRqst_PaymentTerm` VARCHAR(150),
  `PRqst_PorderDepartment` VARCHAR(40),
  `PRqst_InspectionPlace` VARCHAR(50),
  `PRqst_InspectionDate` DATETIME,
  `PRqst_Inspectionby` VARCHAR(50),
  `Project_Code` VARCHAR(15),
  `PRqst_TotalQuantity` DOUBLE,
  `PRqst_TotalQuantityUsed` DOUBLE,
  `PRqst_QuantityEqual` TINYINT(1),
  `PRqst_Posted` TINYINT(1),
  `CostCenter_Code` VARCHAR(15),
  `User_Name` VARCHAR(30),
  `PRqst_BelongsToGroup` INTEGER,
  `PRqst_BelongsToGrp` INTEGER,
  `PRqst_CarNo` VARCHAR(30),
  `PRqst_ReducedQuantity` DOUBLE,
  `PRqst_Quantity` DOUBLE,
  `SendReceive_Reference` DOUBLE,
  `Synchronized` TINYINT(1),
  PRIMARY KEY (`PRqst_id`),
  INDEX `CostCenter`(`Costcent_Code`),
  INDEX `Date`(`PRqst_date`),
  INDEX `DateRef`(`PRqst_date`, `PRqst_reference`),
  INDEX `PrjCst`(`Project_Code`, `Costcent_Code`),
  INDEX `Project`(`Project_Code`),
  INDEX `Reference`(`PRqst_reference`),
  INDEX `Supplier`(`Supplier_Code`),
  INDEX `SupplierDate`(`Supplier_Code`, `PRqst_date`),
  INDEX `SupplierDateRef`(`Supplier_Code`, `PRqst_date`, `PRqst_reference`),
  INDEX `SupplierRef`(`PRqst_reference`)
)
ENGINE = InnoDB;

CREATE TABLE `PRequestDt` (
  `PRqstDt_id` DOUBLE NOT NULL AUTO_INCREMENT,
  `PRqst_id` DOUBLE NOT NULL,
  `PRqst_Date` DATETIME NOT NULL,
  `Item_Code` VARCHAR(20) NOT NULL,
  `PRqstDt_Quantity` DOUBLE,
  `PRqstDt_QuantityUsed` DOUBLE,
  `PRqstDt_QuantityEqual` TINYINT(1),
  `PRqstDt_Remark` VARCHAR(100),
  `Project_Code` VARCHAR(15),
  `CostCent_Code` VARCHAR(15),
  `Item_Barcode` VARCHAR(40),
  `Currency_Code` VARCHAR(6),
  `Supplier_Code` VARCHAR(10),
  `PRqstDt_PrintRemark` TINYINT(1),
  `PRqstDt_PrintRow` TINYINT(1),
  `Warehouse_Code` VARCHAR(15),
  `Porder_References` VARCHAR(50),
  `Synchronized` TINYINT(1),
  PRIMARY KEY (`PRqstDt_id`),
  INDEX `id`(`PRqst_id`),
  INDEX `IdItemWhCst`(`PRqst_id`, `Item_Code`, `Warehouse_Code`, `CostCent_Code`),
  INDEX `Item`(`Item_Code`)
)
ENGINE = InnoDB;

CREATE TABLE `PRequestSetup` (
  `PrintReceiptVoucher` TINYINT(1),
  `Warehouse_Code` VARCHAR(15),
  `Synchronized` TINYINT(1),
  `Barcode` TINYINT(1),
  `PRqst_DefaultType` VARCHAR(2),
  `WithPriceDefault` TINYINT(1)
)
ENGINE = InnoDB;


ALTER TABLE `sequence` ADD COLUMN `PRequest_Id` DOUBLE,
 ADD COLUMN `PRequestDt_Id` DOUBLE,
 ADD COLUMN `PRequest_Reference` DOUBLE;

ALTER TABLE `porderdt` ADD COLUMN `RelatedDt_ID` DOUBLE;


#Date 24.07.2008
ALTER TABLE `banks` DROP COLUMN `Bank_InterestRate`,
 DROP COLUMN `Bank_CrdLimit`,
 DROP COLUMN `Currency_Code`,
 ADD COLUMN `Bank_Telephone1` VARCHAR(25),
 ADD COLUMN `Bank_Telephone2` VARCHAR(25) ,
 ADD COLUMN `Bank_Fax` VARCHAR(25) ,
 ADD COLUMN `Bank_Address` VARCHAR(100) ,
 ADD COLUMN `Bank_Email` VARCHAR(30) ,
 ADD COLUMN `Bank_Website` VARCHAR(30);



 CREATE TABLE `BankLedger` (
  `BankLedger_ID` INTEGER NOT NULL AUTO_INCREMENT,
  `Bank_ID` INTEGER NOT NULL,
  `Ledger_Number` VARCHAR(10) NOT NULL,
  `Bank_InterestRate` DOUBLE,
  `Bank_CrdLimit` DOUBLE,
  `Currency_Code` VARCHAR(6),
  PRIMARY KEY (`BankLedger_ID`),
  UNIQUE INDEX `BankLedNumber`(`Bank_ID`, `Ledger_Number`)
)
ENGINE = InnoDB;

ALTER TABLE `bankloan`
 DROP FOREIGN KEY `BankBank_ID`;

ALTER TABLE `bankloan` ADD CONSTRAINT `BankBank_ID` FOREIGN KEY `BankBank_ID` (`Bank_ID`)
    REFERENCES `bankledger` (`BankLedger_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

ALTER TABLE `bankledger` ADD CONSTRAINT `BankLedgerBank_ID` FOREIGN KEY `BankLedgerBank_ID` (`Bank_ID`)
    REFERENCES `banks` (`Bank_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
 ADD CONSTRAINT `BankLedgerLedger_Number` FOREIGN KEY `BankLedgerLedger_Number` (`Ledger_Number`)
    REFERENCES `ledger` (`Ledger_number`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;		

#Date 26.07.2008
ALTER TABLE `acctypedetail` DROP FOREIGN KEY `acctypedetailledger_number`;
ALTER TABLE `telephoneno` DROP FOREIGN KEY `clientstelephonenoledger_number`,
 DROP FOREIGN KEY `custtelephonenoledger_number`;

ALTER TABLE `telephoneno` ADD COLUMN `Client_Type` VARCHAR(1);

#Date 30.07.2008 AYMAN
ALTER TABLE `clients` ADD COLUMN `User_Account` VARCHAR(10);

#Date 31.07.2008 Akiki
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `RA_AgingOfClientInvoices` BOOLEAN DEFAULT 0,
 ADD COLUMN `RA_FinancialAccounts` BOOLEAN DEFAULT 0;

ALTER TABLE `accesslabelsrocky`.`login` CHANGE COLUMN `Edit` `Login_Edit` TINYINT(1) DEFAULT 0;

#Date 01.08.2008 
ALTER TABLE `items` MODIFY COLUMN `Item_SysDateTime` DATETIME;

#Date 01.08.2008  AFTER THE UPDATE
ALTER TABLE `retail` DROP FOREIGN KEY `retailsale_id`;

#Date 02.08.2008
ALTER TABLE `acctypedetail` DROP FOREIGN KEY `acctypedetailledger_number`;

#Date 04.08.2008
ALTER TABLE `trans` ADD COLUMN `Trans_ManualNo` DOUBLE;

ALTER TABLE `sorder` ADD COLUMN `Sorder_Package` VARCHAR(1),
 ADD COLUMN `Sorder_SysDate` DATETIME,
 ADD COLUMN `Sorder_SysTime` DATETIME,
 ADD COLUMN `User_Account` VARCHAR(10),
 ADD COLUMN `Sorder_Repetitive` BOOLEAN,
 ADD COLUMN `Sorder_DieCutAmnt` DOUBLE,
 ADD COLUMN `Sorder_DieCutAmnt1` DOUBLE,
 ADD COLUMN `Sorder_DieCutAmnt2` DOUBLE,
 ADD COLUMN `Sorder_ClichetAmnt` DOUBLE,
 ADD COLUMN `Sorder_ClichetAmnt1` DOUBLE,
 ADD COLUMN `Sorder_ClichetAmnt2` DOUBLE,
 ADD COLUMN `Sorder_ArtWorkAmnt` DOUBLE,
 ADD COLUMN `Sorder_ArtWorkAmnt1` DOUBLE,
 ADD COLUMN `Sorder_ArtWorkAmnt2` DOUBLE;

ALTER TABLE `sordersetup` ADD COLUMN `QtyApproximate` BOOLEAN;

ALTER TABLE `sorderdt` ADD COLUMN `SorderDt_ApproximateQty` DOUBLE,
 ADD COLUMN `SorderDt_DeliveryWay` VARCHAR(1),
 ADD COLUMN `SorderDt_DeliveryLocation` VARCHAR(100),
 ADD COLUMN `SorderDt_Document` DOUBLE;

ALTER TABLE `accesslabelsrocky`.`module` ADD COLUMN `Module_AdvancedProduction` TINYINT(1) DEFAULT 0;

ALTER TABLE `sequence` ADD COLUMN `Sorder_TypeRef` DOUBLE;

ALTER TABLE `accesslabelsrocky`.`module` ADD COLUMN `Module_GenerateSorderJV` TINYINT(1);

ALTER TABLE `sorder` ADD COLUMN `Sorder_Confirmed` BOOLEAN,
 ADD COLUMN `Journal_Type` VARCHAR(2),
 ADD COLUMN `Journal_Id` DOUBLE,
 ADD COLUMN `Sorder_CreditCur` VARCHAR(6),
 ADD COLUMN `Sorder_CreditAccount` VARCHAR(10),
 ADD COLUMN `Sorder_CreditAccountVat` VARCHAR(10),
 ADD COLUMN `Sorder_Rate` DOUBLE,
 ADD COLUMN `Sorder_RateBase1` DOUBLE,
 ADD COLUMN `Sorder_RateBase2` DOUBLE;

ALTER TABLE `sorderdt` ADD COLUMN `TransferDT_ID` DOUBLE,
 ADD COLUMN `SorderDt_ItemAccount` VARCHAR(10);

ALTER TABLE `sordersetup` ADD COLUMN `VatAccount` VARCHAR(10),
 ADD COLUMN `CreditCur` VARCHAR(6),
 ADD COLUMN `CreditCurdefault` BOOLEAN,
 ADD COLUMN `CreditAccount` VARCHAR(10),
 ADD COLUMN `CreditAccountVAT` VARCHAR(10);

#Date 06.08.2008
ALTER TABLE `sorderpend`
 DROP FOREIGN KEY `sorderpendsorder_id`;

ALTER TABLE `sorderpend` ADD CONSTRAINT `sorderpendsorder_id` FOREIGN KEY `sorderpendsorder_id` (`Sorder_id`)
    REFERENCES `sorder` (`Sorder_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

ALTER TABLE `deliverypend`
 DROP FOREIGN KEY `deliverypenddelivery_id`;

ALTER TABLE `deliverypend` ADD CONSTRAINT `deliverypenddelivery_id` FOREIGN KEY `deliverypenddelivery_id` (`Delivery_Id`)
    REFERENCES `deliveries` (`Delivery_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
		
ALTER TABLE `prequestdt` ADD CONSTRAINT `PRequestPrequestId` FOREIGN KEY `PRequestPrequestId` (`PRqst_id`)
    REFERENCES `prequest` (`PRqst_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;


ALTER TABLE `ledger` ADD COLUMN `Ledger_RequiredDetail` TINYINT(1) UNSIGNED;

#DAte 07.08.2008
ALTER TABLE `production` DROP FOREIGN KEY `production_item_code`;

#Date 08.08.2008
ALTER TABLE `rma`
 DROP FOREIGN KEY `rmaadjustment_id`;

ALTER TABLE `rma` ADD CONSTRAINT `rmaadjustment_id` FOREIGN KEY `rmaadjustment_id` (`Adjustment_Id`)
    REFERENCES `adjustment` (`Adjustment_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
		
ALTER TABLE `deliverydt`
 DROP FOREIGN KEY `deliverydtdelivery_id`;

ALTER TABLE `deliverydt` ADD CONSTRAINT `deliverydtdelivery_id` FOREIGN KEY `deliverydtdelivery_id` (`Delivery_id`)
    REFERENCES `deliveries` (`Delivery_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

ALTER TABLE `items` ADD COLUMN `Item_QtyToBeProduced` DOUBLE;

#Date 13.08.2008
ALTER TABLE `transferdt`
 ADD COLUMN `Transferdt_DirectStkDbt` VARCHAR(10),
 ADD COLUMN `TransferDt_DirectStkCrd` VARCHAR(10),
 ADD COLUMN `TransferDt_DirectStkCur` VARCHAR(10);

CREATE TABLE `Titles` (
  `Title_ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `Title_Name` VARCHAR(4),
  `Title_Description` VARCHAR(45),
  PRIMARY KEY (`Title_ID`)
);

ALTER TABLE `titles` ADD UNIQUE INDEX `TitleName`(`Title_Name`);
delete from `titles`;
insert into titles(Title_Name) (select distinct TelephoneNo_ContactTitle from TelephoneNo);
ALTER TABLE `telephoneno` ADD CONSTRAINT `TitleTelephone_Titles` FOREIGN KEY `TitleTelephone_Titles` (`TelephoneNo_ContactTitle`)
    REFERENCES `titles` (`Title_Name`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

#Date 14.08.2008
ALTER TABLE journaldt ADD COLUMN Reconciliation_Sysdate DATETIME DEFAULT NULL;

ALTER TABLE `porderdt` ADD COLUMN `Item_Vat` DOUBLE;

#Date 19.08.2008
ALTER TABLE `porder` MODIFY COLUMN `Porder_TotalQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_TotalQuantityUsed` DOUBLE DEFAULT 0;

ALTER TABLE `items` MODIFY COLUMN `Item_PorderQty` DOUBLE DEFAULT 0;
ALTER TABLE `items per warehouse` MODIFY COLUMN `Item_PorderQty` DOUBLE DEFAULT 0;

ALTER TABLE `purchases` ADD COLUMN `Purchase_VatChkbx` TINYINT(1);

#Date 20.08.2008
ALTER TABLE `setup` ADD COLUMN `RMA_In` VARCHAR(15),
 ADD COLUMN `RMA_Out` VARCHAR(15);

#Date 20.08.2008
ALTER TABLE `clients` ADD COLUMN `CostCenter_Code` VARCHAR(15) ;
ALTER TABLE `suppliers` ADD COLUMN `Costcenter_Code` VARCHAR(15) ;

alter table setup add column accesslabelsrocky varchar(64) default null;

ALTER TABLE `ledger` ADD COLUMN `CostCenter_code` VARCHAR(15);

#Date 26.08.2008
ALTER TABLE `deliveries` DROP FOREIGN KEY `deliveriespurchase_id`;

ALTER TABLE `setup` ADD COLUMN `RMA_In` VARCHAR(15),
 ADD COLUMN `RMA_Out` VARCHAR(15);

insert into sordertype (Sorder_Type,Sorder_TypeName,FormType) values
  ('SO','Sales Order','Sorder'),('OF','Offer','Sorder'),('PF','Proforma Invoice','Sorder'),
  ('QO','Quotation','Sorder'),('PO','Purchase Order','Porder'),('PQ','Purchase Request','Porder');

ALTER TABLE `checks`
 DROP FOREIGN KEY `checksledger_number`;

ALTER TABLE `checks` ADD CONSTRAINT `checksledger_number` FOREIGN KEY `checksledger_number` (`Ledger_number`)
    REFERENCES `ledger` (`Ledger_number`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

ALTER TABLE `setup` ADD COLUMN `Ledger_ValidateProject` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `JVModeAsLedger` TINYINT(1) DEFAULT 0;

ALTER TABLE `setup` ADD COLUMN `Supplier_ValidateProject` TINYINT(1) DEFAULT 0;

#Date 28.08.2008
ALTER TABLE `purchasesdt` MODIFY COLUMN `PurchaseDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_QuantityReturn` DOUBLE DEFAULT 0;
ALTER TABLE `purchases` MODIFY COLUMN `Purchase_TotalQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_TotalQuantityRet` DOUBLE DEFAULT 0;


#Date 1.09.2008

ALTER TABLE `productionsetup` ADD COLUMN `GenerateWasteAccount` TINYINT(1);

ALTER TABLE `transactionsetup`
 ADD COLUMN `Trans_wasteDebitAcc` VARCHAR(10),
 ADD COLUMN `Trans_wasteCreditAcc` VARCHAR(10),
 ADD COLUMN `Trans_wasteDifferenceAcc` VARCHAR(10);

ALTER TABLE `production` 
 ADD COLUMN `Production_WasteDebit` VARCHAR(10),
 ADD COLUMN `Production_WasteCredit` VARCHAR(10),
 ADD COLUMN `Production_WasteDiff` VARCHAR(10);

ALTER TABLE `productiondt` 
 ADD COLUMN `ProductionDt_WasteDebit` VARCHAR(10) ,
 ADD COLUMN `ProductionDt_WasteCredit` VARCHAR(10),
 ADD COLUMN `ProductionDt_Waste` DOUBLE DEFAULT 0 ;


ALTER TABLE `clients`
 ADD COLUMN `Client_DeliveryAddress2` VARCHAR(50),
 ADD COLUMN `Client_BusinessSector` VARCHAR(1),
 ADD COLUMN `Client_BusinessSectorDesc` VARCHAR(10),
 ADD COLUMN `Client_BType2` VARCHAR(50),
 ADD COLUMN `Client_BType3` VARCHAR(50),
 ADD COLUMN `Client_TOBcode` DOUBLE DEFAULT 0,
 ADD COLUMN `Client_MultipleSales` BOOLEAN DEFAULT 0;

ALTER TABLE `clients` ADD COLUMN `Client_SysDate` DATETIME,
 ADD COLUMN `Client_SysTime` TIMESTAMP;

#Date 2.09.2008
ALTER TABLE `purchasesjv`
  ADD COLUMN `PurchaseJV_type` VARCHAR(20) ,
  ADD COLUMN `PurchaseJV_OriginType` VARCHAR(20);


ALTER TABLE `sorder` MODIFY COLUMN `Sorder_TotalQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Sorder_TotalQuantityUsed` DOUBLE DEFAULT 0;

ALTER TABLE `sorderdt` MODIFY COLUMN `SorderDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SorderDt_QuantityUsed` DOUBLE DEFAULT 0;

ALTER TABLE `rma` MODIFY COLUMN `RMA_TotalQuantityUsed` DOUBLE DEFAULT 0,
 MODIFY COLUMN `RMA_TotalQuantity` DOUBLE DEFAULT 0;

ALTER TABLE `rmadt` MODIFY COLUMN `RMADt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `RMADT_QuantityUsed` DOUBLE DEFAULT 0;

ALTER TABLE `purchasesjvdt`
ADD COLUMN `PurchaseJVDt_Description2` VARCHAR(100);

ALTER TABLE `salesmen` ADD COLUMN `Salesman_IsLedger` BOOLEAN DEFAULT 0,
  MODIFY COLUMN `Salesman_IsManager` TINYINT(1) DEFAULT 0;

ALTER TABLE `salessetup` ADD COLUMN `AutoGenerateSizeMeasure` TINYINT(1);
ALTER TABLE `porder` ADD COLUMN `Porder_Confirmed` TINYINT(1);
ALTER TABLE `pordersetup` ADD COLUMN `EnablePorderConfirmed` TINYINT(1);
ALTER TABLE `deliveries` ADD COLUMN `Delivery_confirmed` TINYINT(1);
ALTER TABLE `salessetup` ADD COLUMN `EnableDeliveryConfirmed` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`login`
 ADD COLUMN `FI_DeliveryConfirmed` TINYINT(1),
 ADD COLUMN `FI_PorderConfirmed` TINYINT(1);

#DAte 04.09.2008
alter table accesslabelsrocky.users
  add column User_LogedIntoInventory Boolean Default 0,
  Add Column User_LogedIntoAccounting Boolean Default 0;

alter table accesslabelsrocky.login
  add column Login_ShowLoggedUser Boolean Default 0;

#Date 05.09.2008
alter table preproduction drop column totaltime,drop column totalcounter;
alter table production drop column totaltime,drop column totalcounter;

alter table preproduction modify column timestart datetime default null,
      modify column timestop datetime default null;

ALTER TABLE `accesslabelsrocky`.`module` ADD COLUMN `Module_SuperMarket` TINYINT(1);

#DAte 06.09.2008
ALTER TABLE `titles` ADD INDEX `TitleName`(`Title_Name`);

#DAte 08.09.2008
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Login_modAdjIsInvoice` tinyint(1) DEFAULT 0;

ALTER TABLE `ledger` MODIFY COLUMN `Ledger_Deactivate` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `ledger_type` INTEGER DEFAULT 0,
 MODIFY COLUMN `Ledger_RequiredDetail` TINYINT(1) DEFAULT NULL;

alter table subgroup add column group_code varchar(15) default null;
alter table subgroup add constraint `subgroupGroup_Code` foreign key `subgroupGroup_Code`(group_code) references `grouping`(group_code);

alter table ledger modify column ledger_type integer null default 0;
alter table setup add column Salesman_IsLedger tinyint(1) default 0;
ALTER TABLE sorder ADD COLUMN `Sorder_Title` VARCHAR(25) NOT NULL;

ALTER TABLE `sordersetup` ADD COLUMN `Item_Cliche` VARCHAR(20),
 ADD COLUMN `Item_DieCut` VARCHAR(20),
 ADD COLUMN `Item_ArtWork` VARCHAR(20),
 ADD COLUMN `Item_transport` VARCHAR(20);
 ALTER TABLE `sorder` ADD COLUMN `SorderFlag` VARCHAR(1);
 ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_approximate` VARCHAR(1);
 ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_deliveryDate` datetime;
 ALTER TABLE `items` ADD COLUMN `item_grammage` DOUBLE;

ALTER TABLE `deliverydt` ADD COLUMN `DeliveryDt_PricePerUnit` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_QtyUnit` DOUBLE DEFAULT 0;

ALTER TABLE `salessetup` ADD COLUMN `EnablePricePerUnit` TINYINT(1) DEFAULT 0;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_PricePerUnit` TINYINT(1) DEFAULT 0;

CREATE TABLE `CashRegisterFKey` (
  `Auto` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `CashRegFkey_FKey` VARCHAR(5),
  `CashRegFkey_Description` VARCHAR(10),
  `CashRegFkey_ItemBarcode` VARCHAR(40),
  PRIMARY KEY (`Auto`),
  INDEX `Key`(`CashRegFkey_FKey`)
)
ENGINE = InnoDB;

ALTER TABLE `cashregister` ADD COLUMN `EnableFunctionKeys` TINYINT(1) DEFAULT 0;


#toni habshi 9.09.2008
ALTER TABLE `purchases`
 MODIFY COLUMN `Purchase_Freight` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_FreightBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_FreightBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Commissions` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_CommissionBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_CommissionBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Others` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_OthersBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_OthersBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Insurance` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_InsuranceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_InsuranceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Clearing` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_ClearingBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_ClearingBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Customs` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_CustomsBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_CustomsBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Transport` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_TransportBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_TransportBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_ChargesPer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Posted` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Purchase_estimatedSell` INTEGER DEFAULT 5,
 MODIFY COLUMN `Purchase_delivered` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Purchase_DiscountPer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_Edit` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Purchase_VatChkbx` TINYINT(1) DEFAULT 1,
 MODIFY COLUMN `Purchase_Rate` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_RateBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchase_RateBase2` DOUBLE DEFAULT 0;



ALTER TABLE `purchasesdt` 
 MODIFY COLUMN `PurchaseDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_Charges` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargePer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesAmnt` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_QuantityEqual` TINYINT(1) DEFAULT 0, 
 MODIFY COLUMN `PurchaseDt_SubjToCharge` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_SubjToCharge1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_SubjToCharge2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_TotalCalc` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_DiscountPer` DOUBLE DEFAULT 0;

#ram 9.9.08 setting default values

ALTER TABLE `deliveries`
 MODIFY COLUMN `Delivery_Promotion` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Delivery_Edit` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Delivery_posted` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Journal_Type` VARCHAR(2) DEFAULT 'DI',
 MODIFY COLUMN `Delivery_QuantityEqual` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountTTC` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountPer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Rate` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_RateBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_RateBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax1Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax2Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax3Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax4Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax5Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax1Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax2Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax3Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax4Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Tax5Base2` DOUBLE DEFAULT 0;
 
ALTER TABLE `deliverydt` 
 MODIFY COLUMN `Deliverydt_posted` TINYINT(1) DEFAULT 0, 
 MODIFY COLUMN `Journal_Type` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'DI',
 MODIFY COLUMN `DeliveryDt_DeliveriedQty` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_DelQtyEqual` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_QtyUnit` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_QuantityFiscal` DOUBLE DEFAULT 0;

ALTER TABLE `sales`
MODIFY COLUMN `sale_posted` TINYINT(1) DEFAULT 0, 
MODIFY COLUMN `journal_type` varchar(2) DEFAULT 'SI', 
MODIFY COLUMN `sale_quantityequal` TINYINT(1) DEFAULT 0, 
MODIFY COLUMN `sale_discountamount` double DEFAULT 0, 
MODIFY COLUMN `sale_rate` double DEFAULT 0, 
MODIFY COLUMN `sale_ratebase1` double DEFAULT 0, 
MODIFY COLUMN `sale_ratebase2` double DEFAULT 0, 
MODIFY COLUMN `sale_discountper` double DEFAULT 0,
MODIFY COLUMN `sale_edit` tinyint(1) DEFAULT 0, 
 MODIFY COLUMN `sale_Tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax1Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax2Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax3Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax4Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax5Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax1Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax2Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax3Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax4Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `sale_Tax5Base2` DOUBLE DEFAULT 0;

 ALTER TABLE `salesdt`
 MODIFY COLUMN `journal_type` varchar(2) DEFAULT 'SI', 
 MODIFY COLUMN `saledt_quantityequal` tinyint(1) DEFAULT 0; 
 
 
 
 
 
 
ALTER TABLE `sorder` 
MODIFY COLUMN `Sorder_VATChckbx` tinyint(1) DEFAULT 1, 
MODIFY COLUMN `Sorder_posted` tinyint(1) DEFAULT 0,    
MODIFY COLUMN `Sorder_quantityequal` tinyint(1) DEFAULT 0,    
MODIFY COLUMN `Sorder_nonetaxable` double DEFAULT 0,    
MODIFY COLUMN `Sorder_taxable` double DEFAULT 0,    
MODIFY COLUMN `Sorder_vat` double DEFAULT 0,    
MODIFY COLUMN `sorder_Tax1` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax2` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax3` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax4` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax5` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax1Base1` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax2Base1` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax3Base1` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax4Base1` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax5Base1` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax1Base2` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax2Base2` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax3Base2` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax4Base2` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_Tax5Base2` DOUBLE DEFAULT 0,
MODIFY COLUMN `sorder_paymentmode` double DEFAULT 0,    
MODIFY COLUMN `Sorder_discountamount` double DEFAULT 0,    
MODIFY COLUMN `Sorder_discountper` double DEFAULT 0,
MODIFY COLUMN `Sorder_type` varchar(2) DEFAULT 'SO',    
MODIFY COLUMN `journal_type` varchar(2) DEFAULT 'SO',    
MODIFY COLUMN `Sorder_rate` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ratebase1` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ratebase2` double DEFAULT 0,    
MODIFY COLUMN `Sorder_confirmed` tinyint(1) DEFAULT 0,    
MODIFY COLUMN `Sorder_DieCutAmnt` double DEFAULT 0,    
MODIFY COLUMN `Sorder_DieCutAmnt1` double DEFAULT 0,    
MODIFY COLUMN `Sorder_DieCutAmnt2` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ClichetAmnt` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ClichetAmnt1` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ClichetAmnt2` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ArtWorkAmnt` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ArtWorkAmnt1` double DEFAULT 0,    
MODIFY COLUMN `Sorder_ArtWorkAmnt2` double DEFAULT 0,

#toni habshi 11.09.2008
MODIFY COLUMN `sorder_CreditCur` VARCHAR(6),
MODIFY COLUMN `sorder_CreditAccount` VARCHAR(10),
MODIFY COLUMN `sorder_CreditAccountVat` VARCHAR(10),
MODIFY COLUMN `Sorder_Title` VARCHAR(25);

  

ALTER TABLE `sorderdt` 
MODIFY COLUMN `Sorderdt_posted` tinyint(1) DEFAULT 0,
MODIFY COLUMN `Sorderdt_price` double DEFAULT 0,
MODIFY COLUMN `Sorderdt_discount` double DEFAULT 0,
MODIFY COLUMN `SorderDt_DiscountBase1` double DEFAULT 0,
MODIFY COLUMN `Sorderdt_quantityequal` tinyint(1) DEFAULT 0,
MODIFY COLUMN `SorderDt_DiscountAmount` double DEFAULT 0,
MODIFY COLUMN `SorderDt_DiscountBase2` double DEFAULT 0;







alter table `rma` modify column `rma_type` varchar(2) default 'MI';



alter table `production` 
modify column Production_MeanOrLastCost integer default 0,
modify column Production_edit tinyint(1) default 0,
modify column Production_quantity double default 1,
modify column Production_idealqty double default 1,
modify column Production_posted tinyint(1) default 0,
modify column Production_waste double default 0;

alter table `productiondt` 
modify column Production_DefaultSerial tinyint(1) default 0,
modify column Productiondt_idealqty double default 1,
modify column ProductionDt_Waste double default 0;




alter table `preproduction` 
modify column Production_MeanOrLastCost integer default 0,
modify column Production_edit tinyint(1) default 0,
modify column Production_quantity double default 1,
modify column Production_idealqty double default 1,
modify column Production_posted tinyint(1) default 0,
modify column PreProduction_finished tinyint(1) default 0,
modify column PreProduction_used tinyint(1) default 0;


alter table `preproductiondt` 
modify column Productiondt_transfered tinyint(1) default 0,
modify column Productiondt_idealqty double default 1,
modify column ProductionDt_quantity double default 0;

alter table trans
modify column Trans_AmountDb1 double default 0,
modify column Trans_AmountDb2 double default 0,
modify column Trans_Amountcd1 double default 0,
modify column Trans_Amountcd2 double default 0,
modify column Trans_Posted tinyint(1) default 0,
modify column acctrx_Posted tinyint(1) default 0;

alter table transdt
modify column Transdt_Amount double default 0,
modify column Transdt_Amount1 double default 0,
modify column Transdt_Amount2 double default 0;







alter table purchasesjv
modify column purchasejv_vatcheck tinyint(1) default 0,
modify column journal_type varchar(2) default 'JP',
modify column purchasejv_discamount double default 0,
modify column purchasejv_edit tinyint(1) default 0,
modify column purchasejv_chargeamount double default 0,
modify column purchasejv_percharge double default 0,
modify column purchase_mode double default 0,
modify column purchasejv_taxable double default 0,
modify column purchasejv_nonetaxable double default 0,
modify column purchasejv_posted tinyint(1) default 0;


alter table purchasesjvdt
modify column purchasejvdt_quantity double default 0,
modify column purchasejvdt_price double default 0,
modify column purchasejvdt_discper double default 0,
modify column purchasejvdt_posted tinyint(1) default 0,
modify column purchasejvdt_discount double default 0,
modify column purchasejvdt_discount1 double default 0,
modify column purchasejvdt_discount2 double default 0,
modify column purchasejvdt_charge double default 0,
modify column purchasejvdt_charge1 double default 0,
modify column purchasejvdt_charge2 double default 0;



alter table salesjv
modify column salesjv_type varchar(1) default 'N',
modify column salesjv_paid tinyint(1) default 0,
modify column salesjv_vatcheck tinyint(1) default 0,
modify column salesjv_taxable double default 0,
modify column journal_type varchar(2) default 'JS',
modify column salesjv_discountamount double default 0,
modify column salesjv_edit tinyint(1) default 0,
modify column salesjv_posted tinyint(1) default 0,
modify column sales_mode double default 0,
modify column salesjv_nonetaxable double default 0,
modify column salesjv_downpayment double default 0,
modify column generatedinvoice_ref double default 0,
modify column salesjv_DiscountPer double default 0;

alter table salesjvdt
modify column journal_type varchar(2) default 'JS',
modify column salesjvdt_quantity double default 1,
modify column salesjvdt_price double default 0,
modify column salesjvdt_DiscountPer double default 0;



alter table prepaymentm modify column PrePayment_Edit tinyint(1) default 0;

alter table prepaymentd
modify column amount double default 0,
modify column amountbase1 double default 0,
modify column amountbase2 double default 0,
modify column amountgenerate double default 0,
modify column amountgeneratebase1 double default 0,
modify column amountgeneratebase2 double default 0,
modify column division double default 0,
modify column divisiongenerate double default 0,
modify column generate tinyint(1) default 1;

alter table fleet
modify column journal_type varchar(2) default 'FL';


alter table fleetdt
modify column journal_type varchar(2) default 'FL',
modify column fleetdt_quantity double default 1,
modify column fleetdt_price double default 0,
modify column fleetdt_discper double default 0,
modify column fleetdt_posted tinyint(1) default 0,
modify column fleetdt_discount double default 0,
modify column fleetdt_discount1 double default 0,
modify column fleetdt_discount2 double default 0;




#Ayman 09.09.2008 default values for porder and porderdt
ALTER TABLE `porder` MODIFY COLUMN `Porder_QuantityEqual` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Porder_VATChckbx` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Porder_NoneTaxable` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Taxable` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_DiscountPer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Vat` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_BelongsToGroup` INTEGER DEFAULT 0,
 MODIFY COLUMN `Porder_Tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax1Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax2Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax3Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax4Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax5Base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax1Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax2Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax3Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax4Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Tax5Base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Porder_Confirmed` TINYINT(1) DEFAULT 0;

ALTER TABLE `porderdt` MODIFY COLUMN `PorderDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_QuantityEqual` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `PorderDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `ProderDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_Discount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_Discountbase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_Discountbase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_PrintRow` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `PorderDt_POQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PorderDt_PQQtyEqual` TINYINT(1) DEFAULT 0;

#toni habshi 10.09.2008
ALTER TABLE `adjustment` 
 MODIFY COLUMN `Adjustment_posted` TINYINT(1)  DEFAULT 0,
 MODIFY COLUMN `Adjustment_isInvoice` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Adjustment_RateBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Adjustment_RateBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Adjustment_Rate` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Adjustment_Amount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Adjustment_AmountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Adjustment_AmountBase2` DOUBLE DEFAULT 0;


#toni habshi 10.09.2008
ALTER TABLE `adjustmentdt` 
 MODIFY COLUMN `AdjustmentDt_Quantity` DOUBLE DEFAULT 1,
 MODIFY COLUMN `AdjustmentDt_Posted` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `AdjustmentDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `AdjustmentDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `AdjustmentDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `AdjustmentDt_PhysicalQty` DOUBLE DEFAULT 0;

#toni habshi 10.09.2008
ALTER TABLE `transfer` 
MODIFY COLUMN `Transfer_Posted` TINYINT(1) DEFAULT 0,
MODIFY COLUMN `Transfer_Edit` TINYINT(1) DEFAULT 0;

#toni habshi 10.09.2008
ALTER TABLE `transferdt` 
MODIFY COLUMN `TransferDt_Quantity` DOUBLE DEFAULT 1;

#toni habshi 10.09.2008
ALTER TABLE `prodmatrixheader` 
 MODIFY COLUMN `Posted` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Synchronized` TINYINT(1) DEFAULT 0;

#toni habshi 10.09.2008
ALTER TABLE `productionmatrix` 
 MODIFY COLUMN `QtyR1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR6` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF6` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR7` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF7` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR8` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF8` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR9` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF9` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyR10` DOUBLE DEFAULT 0,
 MODIFY COLUMN `QtyF10` DOUBLE DEFAULT 0;

#toni habshi 10.09.2008
ALTER TABLE `productionmtom` MODIFY COLUMN `Production_IdealQty` DOUBLE DEFAULT 0;
ALTER TABLE `productionmtomdt` MODIFY COLUMN `Production_IdealQty` DOUBLE DEFAULT 0;

#toni habshi 10.09.2008
ALTER TABLE `deliveriedqty` 
  MODIFY COLUMN `DeliveriedQty_Qty` DOUBLE DEFAULT 0,
  MODIFY COLUMN `DeliveriedQty_Posted` TINYINT(1) DEFAULT 0;


ALTER TABLE `journal`
 MODIFY COLUMN `Journal_Flag` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT 'N',
MODIFY COLUMN `Journal_Edit` TINYINT(1) DEFAULT 0,
MODIFY COLUMN `Journal_posted` TINYINT(1) DEFAULT 0,
MODIFY COLUMN `Journal_dtincr` DOUBLE DEFAULT 1,
MODIFY COLUMN `Journal_FolioFlag` DOUBLE DEFAULT 0;


ALTER TABLE `journaldt` 
MODIFY COLUMN `Journaldt_ccenter` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `Journaldt_posted` TINYINT(1) DEFAULT 0,
MODIFY COLUMN `Journaldt_amount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Journal_JVRef` DOUBLE DEFAULT 0,
MODIFY COLUMN `JournalDt_IsVat` TINYINT(1) DEFAULT 0;


ALTER TABLE `assets` 
MODIFY COLUMN `Assets_Edit` TINYINT(1) DEFAULT 0;

ALTER TABLE `paymentrqst`
 MODIFY COLUMN `PaymentRqst_AmntModified` DOUBLE DEFAULT 0,
MODIFY COLUMN `PaymentRqst_Edit` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `PaymentRqst_posted` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `PaymentRqst_amountC1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PaymentRqst_amountC2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PaymentRqst_amountD1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PaymentRqst_amountD2` DOUBLE DEFAULT 0;

ALTER TABLE `paymentrqstdt` 
MODIFY COLUMN `PaymentRqstdt_amount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PaymentRqstdt_amount1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PaymentRqstdt_amount2` DOUBLE DEFAULT 0;

ALTER TABLE `budget` 
 MODIFY COLUMN `Month1_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month2_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month3_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month4_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month5_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month6_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month7_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month8_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month9_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month10_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month11_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month12_base1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month1_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month2_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month3_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month4_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month5_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month6_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month7_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month8_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month9_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month10_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month11_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Month12_base2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Budget_Posted` TINYINT(1) DEFAULT 0;


ALTER TABLE `costcent` ADD COLUMN `CostCent_Reference` DOUBLE DEFAULT 0;
ALTER TABLE `salessetup` ADD COLUMN `Sale_SequentialRefViaCST` TINYINT(1) DEFAULT 0;

ALTER TABLE `sorder` MODIFY COLUMN `JOURNAL_ID` DOUBLE DEFAULT NULL;

#15.09.2008

CREATE TABLE  `stktransaction` (
  `Item_code` varchar(20) DEFAULT NULL,
  `Warehouse_code` varchar(15) DEFAULT NULL,
  `InitialQuantity` double DEFAULT '0',
  `QuantityProduceIn` double DEFAULT '0',
  `QuantityProduceOut` double DEFAULT '0',
  `QuantityEntered` double DEFAULT '0',
  `QuantityDelivered` double DEFAULT '0',
  `QuantitySold` double DEFAULT '0',
  `QuantityPOrdered` double DEFAULT '0',
  `QuantityCurrentSold` double DEFAULT '0',
  `QuantityLastyearSold` double DEFAULT '0',
  `QuantitySordered` double DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `Transaction_ID` double NOT NULL,
  `Transaction_Date` datetime DEFAULT NULL,
  `Transaction_Type` varchar(4) NOT NULL,
  PRIMARY KEY (`Transaction_ID`,`Transaction_Type`),
  KEY `ItemCode` (`Item_code`),
  KEY `WhCode` (`Warehouse_code`),
  KEY `TDate` (`Transaction_Date`),
  KEY `ItemWh` (`Item_code`,`Warehouse_code`),
  KEY `ItemDate` (`Item_code`,`Transaction_Date`),
  KEY `WhDate` (`Warehouse_code`,`Transaction_Date`),
  KEY `ItemWhDate` (`Item_code`,`Warehouse_code`,`Transaction_Date`)
);

ALTER TABLE `items` MODIFY COLUMN `item_grammage` DOUBLE;

#toni habshi 16.09.2008
ALTER TABLE `Items`
  MODIFY COLUMN `Item_FixedAsset` BOOLEAN DEFAULT 0,
  MODIFY COLUMN `Item_production` BOOLEAN DEFAULT 0,
  MODIFY COLUMN `Item_NonStock`   BOOLEAN DEFAULT 0,
  MODIFY COLUMN `ITEM_ACTIVE`     BOOLEAN DEFAULT 1,
  MODIFY COLUMN `ITEM_MAXQTY`     DOUBLE  DEFAULT 1,
  MODIFY COLUMN `ITEM_MINQTY`     DOUBLE  DEFAULT 1,
  MODIFY COLUMN `Item_Unit`       DOUBLE  DEFAULT 1,
  MODIFY COLUMN `Item_SellingPrice1` DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice2` DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice3` DOUBLE DEFAULT 0, 
  MODIFY COLUMN `Item_SellingPrice4` DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice5` DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice6` DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice1Base1`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice2Base1`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice3Base1`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice4Base1`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice5Base1`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice6Base1`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice1Base2`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice2Base2`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice3Base2`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice4Base2`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice5Base2`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_SellingPrice6Base2`  DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QuantityInitiate`    DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QuantityPurchase`    DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_RMAQty`              DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_PorderQty`           DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QtyTransferedToRMA`    DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QuantityProdIn`        DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QuantityProdOUT`       DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QuantityDelivered`     DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_QuantitySales`         DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueInitiate`         DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValuePurchase`         DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueProdIn`           DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueProdOut`          DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueSales`            DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueInitiateBase1`    DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValuePurchaseBase1`    DOUBLE DEFAULT 0,    
  MODIFY COLUMN `Item_ValueProdInBase1`      DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueProdOutBase1`      DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueSalesBase1`       DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueInitiateBase2`    DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValuePurchaseBase2`   DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueProdInBase2`      DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueProdOutBase2`     DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_ValueSalesBase2`       DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_Transfer`              DOUBLE DEFAULT 0,
  MODIFY COLUMN `Item_pack`                  BOOLEAN DEFAULT 0,
  MODIFY COLUMN `Item_posted`                BOOLEAN DEFAULT 0,
  MODIFY COLUMN `Item_Printed`               BOOLEAN DEFAULT 1,
  MODIFY COLUMN `Item_TTCInclude`            BOOLEAN DEFAULT 0, 
  MODIFY COLUMN `Item_CostMethod`            INTEGER DEFAULT 0,
  MODIFY COLUMN `Item_QtyToBeProduced`       DOUBLE DEFAULT 1;

ALTER TABLE `porderdt` MODIFY COLUMN `PorderDt_QuantityUsed` DOUBLE DEFAULT 0;

#toni habshi 17.09.2008 removing access and module fields for removed units
alter table `accesslabelsrocky`.Login Drop column FI_Contract;
alter table `accesslabelsrocky`.Login Drop column FI_ContractApp;
alter table `accesslabelsrocky`.Login Drop column FI_ContractDel;
alter table `accesslabelsrocky`.Login Drop column FI_ContractMod;
alter table `accesslabelsrocky`.Login Drop column FI_CustomerF;
alter table `accesslabelsrocky`.Login Drop column FI_CustomerApp;
alter table `accesslabelsrocky`.Login Drop column FI_CustomerMod;
alter table `accesslabelsrocky`.Login Drop column FI_CustomerDel;
alter table `accesslabelsrocky`.Login Drop column FI_OfferF;
alter table `accesslabelsrocky`.Login Drop column FI_OfferDel;
alter table `accesslabelsrocky`.Login Drop column FI_OfferApp;
alter table `accesslabelsrocky`.Login Drop column FI_OfferMod;
alter table `accesslabelsrocky`.Login Drop column FI_OfferPrint;
alter table `accesslabelsrocky`.Login Drop column FI_Offersetup;
alter table `accesslabelsrocky`.Login Drop column FI_Invoice;
alter table `accesslabelsrocky`.Login Drop column FI_InvoiceDel;
alter table `accesslabelsrocky`.Login Drop column FI_InvoiceApp;
alter table `accesslabelsrocky`.Login Drop column FI_InvoiceMod;
alter table `accesslabelsrocky`.Login Drop column FI_ProductionMtoM;
alter table `accesslabelsrocky`.Login Drop column FI_ProductionMtoMApp;
alter table `accesslabelsrocky`.Login Drop column FI_ProductionMtoMDel;
alter table `accesslabelsrocky`.Login Drop column FI_ProductionMtoMMod;


alter table `accesslabelsrocky`.Module
Drop column Module_Contract,
Drop column Module_ClientOffer,
Drop column Module_Invoice,
Drop column Module_ProductionMatrix;

#*majd abou akar 18/9/2008 
ALTER TABLE `accesslabelsrocky`.`viewer` MODIFY COLUMN `View_form` VARCHAR(30) CHARACTER
 SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#toni habshi 18.09.2008 
ALTER TABLE `accesslabelsrocky`.`module` ADD COLUMN `Module_SecureLogin` TINYINT(1) DEFAULT 0;

#Ghaith 19.09.2008
ALTER TABLE `subgroup`
 DROP FOREIGN KEY `subgroupGroup_Code`;

ALTER TABLE `subgroup` ADD CONSTRAINT `subgroupGroup_Code` FOREIGN KEY `subgroupGroup_Code` (`group_code`)
    REFERENCES `grouping` (`Group_Code`)
    ON DELETE RESTRICT
    ON UPDATE CASCADE;

#toni habshi 19.09.2008 
ALTER TABLE `setup` ADD COLUMN `CashReg_LastClosingDate` DATETIME;

#toni habshi 19.09.2008 
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_CashRegisterSearch` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_CashRegisterPosting` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_CashRegScrollOk` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_CashRegScrollPrint` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_CashRegisterCancel`TINYINT(1) DEFAULT 0 ;


#toni habshi 19.09.2008 
ALTER TABLE `cashregister` ADD COLUMN `EnableFunctionKeys` TINYINT(1) DEFAULT 0 ;





#toni habshi 22.09.2008 


ALTER TABLE `shippingway` MODIFY COLUMN `ShippingWayName` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 ADD PRIMARY KEY (`ShippingWayName`);

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `User_LogedIntoPayroll` TINYINT(1) DEFAULT 0;

alter table accesslabelsrocky.viewer modify column user_account varchar(20);

ALTER TABLE `clients` ADD COLUMN `Client_VAtDAte` DATETIME Default Null;

ALTER TABLE `suppliers` ADD COLUMN `Supplier_VAtDate` DATETIME Default Null;

#Ayman 26.09.2008
Alter table suppliers
add Supplier_GCINO double precision,
add Supplier_CompOwnerTitle varchar(20),
add Supplier_CompOwner varchar(50),
add Supplier_ReferedByTitle VarChar(1),
add Supplier_ReferedBy varchar(30),
add Supplier_BusinessSector  VarChar(1),
add Supplier_BusinessSectorDesc VarChar(10);
#majd 26/9/2008
alter table `stktransaction` add constraint`stktransactionitem_code`foreign key `stktransaction`(item_code)
references `items`(item_code)
on delete restrict
on update restrict;
alter table `stktransaction` add constraint `stktaransactionwarehouse_code`foreign key `stktransactionwarehouse_code`(warehouse_code)
references `warehouse`(warehouse_code)
on delete restrict
on update restrict ;

#Ghaith 29.09.2008
ALTER TABLE `sales`
 DROP FOREIGN KEY `salessalesman_code`;

ALTER TABLE `sales` ADD CONSTRAINT `salessalesman_code` FOREIGN KEY `salessalesman_code` (`Salesman_Code`)
    REFERENCES `salesmen` (`Ledger_number`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

#Ghaith 01.10.2008
#drop table deliverypend;
#drop table sorderpend;

#Ghaith 05.10.2008 NOTE: This might not be dropped
alter table clients
add column Client_BusinessType varchar(20);


#14.10.2008
#Default Values that were not added in items.
alter table items
modify column item_reverseProduction boolean default 0,
modify column Synchronized boolean default 0,
modify column item_discountpercent double default 0,
modify column item_semifinished boolean default  0,
modify column item_BelongsToGroup int(11) default  0,
modify column item_TargetDays int(11) default  0,
modify column item_lastfobprice double default 0,
modify column item_Transfer double default 0;

#Changed the Client emal and homepage size
alter table clients
modify column client_Email Varchar(100),
modify column Client_homepage varchar(100);

alter table accesslabelsrocky.login modify column login_belongstogrp int(11) default 0;

######17.10.2008
alter table setup
add column PagePath varchar(255),
add column UsePagePath boolean default 0;

###20.10.2008
alter table stktransaction add column project_code varchar(15),add column costcent_code varchar(15);

##22.10.2008
alter table stkTransaction
Add Column Currency_Code Varchar(6),
Add Column Price Double Default 0,
Add Column PriceBase1 Double default 0,
Add Column PriceBase2 Double default 0;

##24.10.08
ALTER TABLE `adjustment` MODIFY COLUMN `adjustment_isinv_dstk` TINYINT(1) NOT NULL DEFAULT 0;

##28.10.08, ram
ALTER TABLE `sorder` ADD COLUMN `Sorder_Problematic` VARCHAR(10) NOT NULL default 0;

##28.10.2008,  akiki
ALTER TABLE `adjustmentsetup` ADD COLUMN `NoneStandardBarcode` TINYINT(1) DEFAULT 0;
ALTER TABLE `salessetup` ADD COLUMN `NoneStandardBarcode` TINYINT(1) DEFAULT 0;
ALTER TABLE `transfersetup` ADD COLUMN `NoneStandardBarcode` TINYINT(1) DEFAULT 0;

###29.10.2008 Ghaith
create table ProjectLevels(
  LevelID Integer Auto_increment, Level_Type Integer ,
  Level_Code Varchar(3),Level_Name Varchar(50), Primary Key (LevelID)
  );
alter table setup add column LedgerDeactivateInAcc Boolean Default false;

###29.10.2008 Ayman
ALTER TABLE `accesslabelsrocky`.`documentreport_label` ADD COLUMN `Total` VARCHAR(25),
 ADD COLUMN `TotalReconciled` VARCHAR(25);
 
#30.10.2008
alter table setup
  ADD Column UseApproximateQty Boolean Default 0,
  ADD Column ApproximatePercentage Double Default 0,
  Add Column ApproximateQty Double Default 0;
  
#30.10.08 ram

CREATE TABLE `ProdQuality` (
  `ProdQuality_code` VARCHAR(7) NOT NULL,
  `ProdQuality_Description` VARCHAR(20),
  PRIMARY KEY (`ProdQuality_code`)
);

#31.10.08 ram
ALTER TABLE `sorder` MODIFY COLUMN `Sorder_Repetitive` VARCHAR(1) DEFAULT NULL; 
  
# ram 31.10.08
ALTER TABLE `sorderdt`
  ADD COLUMN `SorderDt_CorrQuantity` integer,
  ADD COLUMN `SorderDt_ConvQuantity` integer,
  ADD COLUMN `SorderDt_Grammage` DOUBLE,
  ADD COLUMN `Sorderdt_specification` varchar(1),
  ADD COLUMN `SorderDt_Base` DOUBLE,
  ADD COLUMN `SorderDt_EffectiveBase` DOUBLE,
  ADD COLUMN `SorderDt_UCostbase` DOUBLE,
  ADD COLUMN `Sorderdt_Flag` VARCHAR(1),
  ADD COLUMN `Sorderdt_insQty` integer,
  ADD COLUMN `SorderDt_itemQty` integer,
  ADD COLUMN `SorderDt_itemSeq` integer,
  ADD COLUMN `ProdQuality_Code` varchar(7),
  ADD COLUMN `ProdQuality_Description` varchar(20);
  
#akiki 31.10.2008
ALTER TABLE accesslabelsrocky.`loginaccess3` ADD COLUMN `FPr_MonthlyProduction` TINYINT(1) DEFAULT 0;

#01.11.2008
Alter Table accesslabelsrocky.Login Add Column FA_SkipReference TinyInt(1) Default 0;

#3.11.08 ram
ALTER TABLE `salessetup` ADD COLUMN `Sale_SeperateLines` TINYINT(1) UNSIGNED DEFAULT 0 ;

#Ghaith 05.11.2008
ALTER TABLE `telephoneno` ADD COLUMN `Client_Code` VARCHAR(10),
 ADD COLUMN `Supplier_Code` VARCHAR(10),
 ADD COLUMN `Salesman_Code` VARCHAR(10),
 ADD CONSTRAINT `TelephoneNoClient_Code` FOREIGN KEY `TelephoneNoClient_Code` (`Client_Code`)
    REFERENCES `clients` (`Ledger_number`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
 ADD CONSTRAINT `TelephoneNoSupplier_Code` FOREIGN KEY `TelephoneNoSupplier_Code` (`Supplier_Code`)
    REFERENCES `suppliers` (`Ledger_number`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
 ADD CONSTRAINT `TelephoneNoSalesman_Code` FOREIGN KEY `TelephoneNoSalesman_Code` (`Salesman_Code`)
    REFERENCES `salesmen` (`Ledger_number`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
	
#7.11.08 ram
ALTER TABLE `clientsip` ADD COLUMN `client_TC` VARCHAR(10);	
ALTER TABLE `clientsip` ADD COLUMN `client_Category` VARCHAR(20);

#12/11/2008 Ghaith

CREATE TABLE  `receiptbooks` (
  `ReceiptBook_ID` int(11) NOT NULL AUTO_INCREMENT,
  `ReceiptBook_SerialNo` int(11) DEFAULT NULL,
  `Ledger_Number` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `ReceiptBook_FromDate` datetime DEFAULT NULL,
  `ReceiptBook_ToDate` datetime DEFAULT NULL,
  `ReceiptBook_FromSequence` int(11) DEFAULT NULL,
  `ReceiptBook_ToSequence` int(11) DEFAULT NULL,
  PRIMARY KEY (`ReceiptBook_ID`)
);

ALTER TABLE `transdt` ADD COLUMN `ReceiptBook_SerialNo` INTEGER DEFAULT Null,
 ADD COLUMN `Receipt_Reference` INTEGER DEFAULT Null;

alter table ProjectLevels add column Form Varchar(50);

alter table purchasesserialno
add column DeliveryDt_ID Double Default nUll;
alter table purchasesserialno
add column AdjustmentDt_ID Double Default nUll;
alter table purchasesserialno
add column TransferDt_ID Double Default nUll;
alter table purchasesserialno
add column SaleDt_ID Double Default nUll;
alter table purchasesserialno
add column ProductionDt_ID Double Default nUll;
alter table purchasesserialno
add column RPurchaseDt_ID Double Default nUll;
alter table purchasesserialno
add column Production_ID double default null;

ALTER TABLE `purchasesserialno` ADD CONSTRAINT `ProductionProduction_ID` FOREIGN KEY `ProductionProduction_ID` (`Production_ID`)
    REFERENCES `Production` (`Production_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;
ALTER TABLE `purchasesserialno` ADD CONSTRAINT `PurchasesDtPurchasesDT_ID` FOREIGN KEY `PurchasesdtPurchaseDT_ID` (`RPurchaseDt_ID`)
    REFERENCES `Purchasesdt` (`PurchaseDt_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;
	
ALTER TABLE `purchasesserialno` ADD CONSTRAINT `DeliverydtDeliveryDT_ID` FOREIGN KEY `DeliverydtDeliveryDT_ID` (`DeliveryDt_ID`)
    REFERENCES `deliverydt` (`DeliveryDt_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT,
 ADD CONSTRAINT `AdjustmentDtAdjustmentDT_ID` FOREIGN KEY `AdjustmentDtAdjustmentDT_ID` (`AdjustmentDt_ID`)
    REFERENCES `adjustmentdt` (`AdjustmentDt_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT,
 ADD CONSTRAINT `TransferDtTransferDt_ID` FOREIGN KEY `TransferDtTransferDt_ID` (`TransferDt_ID`)
    REFERENCES `transferdt` (`TransferDt_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT,
 ADD CONSTRAINT `SalesDTSalesDt_id` FOREIGN KEY `SalesDTSalesDt_id` (`SalesDt_ID`)
    REFERENCES `salesdt` (`SaleDt_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT,
 ADD CONSTRAINT `ProductionDtProductionDt_ID` FOREIGN KEY `ProductionDtProductionDt_ID` (`ProductionDt_ID`)
    REFERENCES `productiondt` (`ProductionDt_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

#Ayman 18.11.2008
ALTER TABLE `setup` ADD COLUMN `NbrOfDigitInLedgerSupplier` INTEGER;
ALTER TABLE `setup` ADD COLUMN `NbrOfDigitInLedgerSalesmen` INTEGER;

#20.11.2008
ALTER TABLE `sendreceivehistory` MODIFY COLUMN `SndRec_date` DATETIME,
 MODIFY COLUMN `SndRec_Ref` DOUBLE,
 MODIFY COLUMN `Station_Name` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `SndRec_Sender` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 ADD COLUMN `SendRec_ID` INTEGER NOT NULL DEFAULT NULL AUTO_INCREMENT,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY  USING BTREE(`SendRec_ID`);

ALTER TABLE `sendreceivehistoryrec` MODIFY COLUMN `SndRec_date` DATETIME,
 MODIFY COLUMN `SndRec_Ref` DOUBLE,
 MODIFY COLUMN `Station_Name` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `SndRec_Sender` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 ADD COLUMN `SendRec_ID` INTEGER NOT NULL DEFAULT NULL AUTO_INCREMENT,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY  USING BTREE(`SendRec_ID`);


#21.11.2008
ALTER TABLE `adjustmentsetup` ADD COLUMN `ShowItemSelling1Base1` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `transfersetup` ADD COLUMN `ShowItemSelling1Base1` TINYINT(1) DEFAULT 0 ;

#24.11.2008
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_PurchaseRequest` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_PurchaseRequestApp` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_PurchaseRequestMod` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_PurchaseRequestDel` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_RepostRequest` TINYINT(1) DEFAULT 0;


#26.11.2008
ALTER TABLE `adjustment` ADD COLUMN `Adjustment_EntryType` VARCHAR(1) ;

#27.11.2008
ALTER TABLE `module` ADD COLUMN `Module_InOut` TINYINT(1) DEFAULT 0 ;
ALTER TABLE accesslabelsrocky.`module` ADD COLUMN `Module_InOut` TINYINT(1) DEFAULT 0 ;

#ram 2.12.08
ALTER TABLE `stktransaction` ADD COLUMN `Quantity_PQR` DOUBLE DEFAULT 0;

#Ghaith 02.12.2008
alter table rma add index RMaReference(Rma_Reference);
alter table items add column Project_Code varchar(15) default null;
ALTER TABLE `items` ADD CONSTRAINT `itemsProject_Code` FOREIGN KEY `itemsProject_Code` (`project_code`)
    REFERENCES `project` (`Project_Code`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

#Ghaith 03.12.2008
alter table adjustmentdt add column Currency_Code Varchar(6) default null;

# ram 4.12.08
ALTER TABLE `sorderdt` ADD COLUMN `Sorderdt_OldData` TINYINT(1) DEFAULT 0;
ALTER TABLE `porderdt` ADD COLUMN `Porderdt_OldData` TINYINT(1) DEFAULT 0;


# akiki 09.12.2008
ALTER TABLE `module` ADD COLUMN `Module_SendTransferToAdj` TINYINT(1) DEFAULT 0 ;
ALTER TABLE accesslabelsrocky.`module` ADD COLUMN `Module_SendTransferToAdj` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `transfer` ADD COLUMN `Adjustment_id` DOUBLE ;
ALTER TABLE accesslabelsrocky.`loginaccess3` ADD COLUMN `FP_ShowGenANDFilter` TINYINT(1) DEFAULT 0 ;

# akiki 12.12.2008
ALTER TABLE `prequest` ADD COLUMN `PRqst_Price` DOUBLE ,
 ADD COLUMN `PRqst_PriceBase1` DOUBLE ,
 ADD COLUMN `PRqst_PriceBase2` DOUBLE ;

ALTER TABLE `prequestdt` ADD COLUMN `PRqstDt_Price` DOUBLE ,
 ADD COLUMN `PRqstDt_PriceBase1` DOUBLE ,
 ADD COLUMN `PRqstDt_PriceBase2` DOUBLE ;

ALTER TABLE `sequence` ADD COLUMN `IN_Reference` DOUBLE,
 ADD COLUMN `OUT_Reference` DOUBLE;

# akiki 20.12.2008
ALTER TABLE `setup` DROP COLUMN `MaxRecordCount`;

ALTER TABLE `accesslabelsrocky`.`Login` DROP COLUMN `RI_UpdatedMeanCost`;
ALTER TABLE `accesslabelsrocky`.`Login` DROP COLUMN `RI_SoldbySalesman`;

#ram 23.12.08

create table `StkEval`(
  `StkEval_id` double not null,
  `StkEval_reference` integer,
  `StkEval_Date` datetime,
  `StkEval_Remark` varchar(30),
  `Currency_code` varchar(6),
  `Journal_Type` varchar(2),
  `journal_id` double,
  primary key (`StkEval_id`)
  );


create table `StkEvalDt`(
  `StkEvaldt_id` double not null,
  `StkEval_id` double not null,
  `Item_code` varchar(20),
  `Costcent_code` varchar(30),
  `Project_Code` varchar(30),
  `StkEvaldt_OldCost` double,
  `StkEvaldt_NewCost` double,
  `StkEval_Date` datetime,
  `StkEvalDt_value` double,
  `StkEvalDt_Percentage` Double,
  `Journal_Type` Varchar(2),
  `StkEvalDt_DirectStkDbt` varchar(10),
  `StkEvalDt_DirectStkCrd` varchar(10),
  `StkEvalDt_DirectStkCur` varchar(6),
  primary key (`StkEvaldt_id`)
  );#ram

#ram 26.12.08  
ALTER TABLE `sequence` ADD COLUMN `StkEval_id` DOUBLE,
 ADD COLUMN `STkEvalDt_id` DOUBLE,
 ADD COLUMN `StkEval_reference` INTEGER;

#Ayman 27.12.2008
ALTER TABLE `sales` ADD COLUMN `Sale_FtsiSRF` DOUBLE DEFAULT 0,
 ADD COLUMN `Sale_FtsiPaletts` DOUBLE DEFAULT 0,
 ADD COLUMN `Sale_FTSISRFDVL` CHAR(1);

ALTER TABLE `salesdt` ADD COLUMN `SaleDt_FtsiItemRef` VARCHAR(14),
 ADD COLUMN `SaleDt_FtsiItmDes` VARCHAR(60),
 ADD COLUMN `SaleDt_FtsiExtint` VARCHAR(1),
 ADD COLUMN `SaleDt_FtsiLGH` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiWDH` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiHGT` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiBND` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiOF` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiPCE` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiFREE` VARCHAR(1),
 ADD COLUMN `SaleDt_FtsiCLH` VARCHAR(1),
 ADD COLUMN `SaleDt_FtsiDCT` VARCHAR(1),
 ADD COLUMN `SaleDt_FtsiAW` VARCHAR(1),
 ADD COLUMN `SaleDt_FtsiTRP` VARCHAR(1),
 ADD COLUMN `SaleDt_FtsiCLAAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiDCTAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiAWAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `SaleDt_FtsiTRPAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `Saledt_FTsiSOF` DOUBLE DEFAULT 0;

ALTER TABLE `Deliveries` ADD COLUMN `Delivery_FtsiSRF` DOUBLE DEFAULT 0,
 ADD COLUMN `Delivery_FtsiPaletts` DOUBLE DEFAULT 0,
 ADD COLUMN `Delivery_FTSISRFDVL` CHAR(1);

ALTER TABLE `Deliverydt` ADD COLUMN `DeliveryDt_FtsiItemRef` VARCHAR(14),
 ADD COLUMN `DeliveryDt_FtsiItmDes` VARCHAR(60),
 ADD COLUMN `DeliveryDt_FtsiExtint` VARCHAR(1),
 ADD COLUMN `DeliveryDt_FtsiLGH` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiWDH` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiHGT` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiBND` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiOF` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiPCE` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiFREE` VARCHAR(1),
 ADD COLUMN `DeliveryDt_FtsiCLH` VARCHAR(1),
 ADD COLUMN `DeliveryDt_FtsiDCT` VARCHAR(1),
 ADD COLUMN `DeliveryDt_FtsiAW` VARCHAR(1),
 ADD COLUMN `DeliveryDt_FtsiTRP` VARCHAR(1),
 ADD COLUMN `DeliveryDt_FtsiCLAAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiDCTAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiAWAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FtsiTRPAMT` DOUBLE DEFAULT 0,
 ADD COLUMN `DeliveryDt_FTsiSOF` DOUBLE DEFAULT 0;
 
#ram 27.12.08
Insert Into Jourtype (TYPE_NAME, Type_Visible, Journal_typeRef, Synchronized) values('SE',1,0,0);

#Ayman 02.01.2009
ALTER TABLE `setup` ADD COLUMN `Setup_ItemLoad` VARCHAR(255);
ALTER TABLE `setup` ADD COLUMN `Path_LoadSales` VARCHAR(255);

#ram 5.1.09
alter table `itemsparam`
      add column `Group_code` varchar(15),
      add column `Subgroup_Code` varchar(15);

create table `itemsparamdt` (
`itemParam_Code` varchar(10),
`itemParam_value` varchar(10)
);

#accesslabelsrocky
create table `accesslabelsrocky`.`LoginStk`(
`user_account` varchar(10),
`project_code` varchar(15),
`costcent_code` varchar(15),
`group_code` varchar(15),
`subGroup_code` varchar (15),
primary key (`user_account`)
);
#>	  

#ram 8.1.09
alter table `itemsdt`
   add column `group_code` varchar(30),
   add column `subgroup_code` varchar(30);

#ram 9.1.09   
alter table `accesslabelsrocky`.`loginstk`
    add column `project` boolean default 0,
    add column `costcenter` boolean default 0,
    add column `groups` boolean default 0,
    add column `subgroup` boolean default 0;   

#ram 9.1.08	
alter table `accesslabelsrocky`.`login`
    add column `FI_IN` boolean,
    add column `FI_OUT` boolean,
  	add column `FI_INDel` boolean,
    add column `FI_OUTDel` boolean,
    add column `FI_INMod` boolean,
  	add column `FI_OUTMod` boolean,
    add column `FI_INapp` boolean,
    add column `FI_Outapp` boolean;

ALTER TABLE `sales` ADD COLUMN `Sale_TotalCLAAmt` DOUBLE DEFAULT 0 ,
 ADD COLUMN `Sale_TotalDCTAmt` DOUBLE DEFAULT 0,
 ADD COLUMN `Sale_TotalAWAmt` DOUBLE DEFAULT 0 ,
 ADD COLUMN `Sale_TotalTRPAmt` DOUBLE DEFAULT 0;

 #ram 13.1.08
alter table `itemsdt`
   drop column `group_code` ,
   drop column `subgroup_code`;
#Ghaith 15.01.2008
alter table accesslabelsrocky.login add column login_AllowTimer boolean default 0;
alter table setup add column setup_GCIExp varchar(250);

#ram 19.1.09
alter table `stkevaldt` add column `currency_code` varchar(6);

	alter table `stkevaldt`
    add constraint `stkevaldtstkeval_id` foreign key `stkevaldtstkeval_id`(`stkeval_id`)
    references `stkeval`(`stkeval_id`)
    on delete cascade
    on update cascade;

    alter table `stkevaldt`
    add constraint `stkevaldtproject_code` foreign key `stkevaldtproject_code`(`project_code`)
    references `project`(`project_code`)
    on delete restrict
    on update restrict;

    alter table `stkevaldt`
    add constraint `stkevaldtitem_code` foreign key `stkevaldtitem_code`(`item_code`)
    references `items`(`item_code`)
    on delete restrict
    on update restrict;

    alter table `stkevaldt`
    add constraint `stkevaldtcostcent_code` foreign key `stkevaldtcostcent_code`(`costcent_code`)
    references `costcent`(`costcent_code`)
    on delete restrict
    on update restrict;

#Ayman 19.01.2009
ALTER TABLE `clients` MODIFY COLUMN `CEPsale_BelongsToGroup` INTEGER;

#ram 21.1.09
alter table `stkevaldt` add column `StkEvaldt_ExistingQty` double,
                        add column `StkEvaldt_TotalEval` double;
						
						
#Ghaith 22.01.2008 Only for Converted Data (Not GF or new clients)
alter table Production Modify Column TimeStart TimeStamp,
Modify Column TimeStop TimeStamp;
alter table PreProduction Modify Column TimeStart TimeStamp,
Modify Column TimeStop TimeStamp;

#23.01.2009
ALTER TABLE `setup` ADD COLUMN `Path_ExportPrjGrpSub` VARCHAR(255) DEFAULT Null;
#Ghaith 23.01.2009
Alter TAble setup add column `Variant_Mode` Integer Default 0;
Alter Table CstJour Add Column `Variant_Code` Varchar(30);

alter table ProjectLevels add Column Level_Title Varchar(64);

#Ayman 29.01.2009
CREATE TABLE `RankTable` (
  `TopNth` INTEGER NOT NULL DEFAULT 1,
  PRIMARY KEY (`TopNth`)
)
ENGINE = InnoDB;

#Ayman 03.02.2009
ALTER TABLE `clients` ADD COLUMN `Client_Instruments` VARCHAR(50) DEFAULT Null,
 ADD COLUMN `Client_InstrumentsAmnt` DOUBLE DEFAULT 0;
 
#Ghaith 03.02.2009
alter table adjustment add column Tag_Reference Varchar(15);
alter table adjustmentdt add column Tag_Reference Varchar(15);

#Ghaith 04.02.2009
alter table Items add column Item_ReverseProduction Boolean Default 0;
alter table Production add column Production_Reversed Integer Default 0;
#Ghaith 05.02.2009
alter table TransConfirm Add Column User_Name Varchar(30);

#Charbel 06.02.2009
ALTER TABLE project ADD COLUMN Project_Memo TEXT;

#Ayman 06.02.2009
ALTER TABLE `sales` ADD COLUMN `Sale_CreditCLA` VARCHAR(10),
 ADD COLUMN `Sale_CreditDCT` VARCHAR(10),
 ADD COLUMN `Sale_CreditAW` VARCHAR(10),
 ADD COLUMN `Sale_CreditTRP` VARCHAR(10);

#Charbel 06.02.2009
ALTER TABLE `porder` ADD COLUMN `Porder_CauseToEliminate` VARCHAR(150),
 ADD COLUMN `Porder_DateToEliminate` DATETIME ,
 ADD COLUMN `Porder_ToEliminate` BOOLEAN DEFAULT 0 ,
 ADD COLUMN `Porder_Eliminated` BOOLEAN DEFAULT 0 ,
 ADD COLUMN `Porder_DateEliminated` DATETIME;

#Charbel 06.02.2009
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_ModConfirmedPO` BOOLEAN DEFAULT 0 ,
 ADD COLUMN `FI_DelConfirmedPO` BOOLEAN DEFAULT 0 ;

#Ayman 10.02.2009
ALTER TABLE `SalesSetup` ADD COLUMN `Sale_CLAAccount` VARCHAR(10),
 ADD COLUMN `Sale_DCTAccount` VARCHAR(10),
 ADD COLUMN `Sale_AWAccount` VARCHAR(10),
 ADD COLUMN `Sale_TRPAccount` VARCHAR(10);

#Ayman 16.02.2009
ALTER TABLE `clients` ADD COLUMN `Client_CreditPolicy` VARCHAR(20);

#Charbel 16.02.2009
ALTER TABLE `purchases` ADD COLUMN `Porder_Ref` Double;

#Charbel 16.02.2009
ALTER TABLE `accesslabelsrocky`.`clientform_label` ADD COLUMN `TC` VARCHAR(25) ;

#Ghaith 21.02.2009
alter table productionsetup add column DisableIdeal Boolean Default false;

#Ghaith 23.02.2009
ALTER TABLE `accesslabelsrocky`.`loginstk` ADD COLUMN `ID` INTEGER UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY (`ID`);
 
alter table filename modify column id_file int(11) not null auto_increment;

#Ayman 26.02.2009
ALTER TABLE `trans` MODIFY COLUMN `Trans_Remark` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#Ghaith 04.03.2009
alter table PURCHASESJVDT add column PurchaseJVDTCalcTotal Double Default 0;

#Ayman 05.03.2009
ALTER TABLE `checks` MODIFY COLUMN `Chk_bank_in` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `setup` ADD COLUMN `Path_LoadSOF` VARCHAR(255);

#Ayman 10.03.2009
ALTER TABLE `sorder` MODIFY COLUMN `Sorder_Problematic` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT Null;
ALTER TABLE `sordersetup` ADD COLUMN `journal_Type` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT Null;

ALTER TABLE `sorder` ADD COLUMN `Sorder_TransportAmnt` DOUBLE DEFAULT 0,
 ADD COLUMN `Sorder_TransportAmnt1` DOUBLE DEFAULT 0,
 ADD COLUMN `Sorder_TransportAmnt2` DOUBLE DEFAULT 0;

ALTER TABLE `PRequest`
ADD COLUMN `PRqst_Taxable` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_TaxableBase1` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_TaxableBase2` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_NoneTaxable` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_NoneTaxableBase1` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_NoneTaxableBase2` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_DiscountAmount` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_DiscountBase1` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_DiscountBase2` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_Vat` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_VatBase1` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_VatBase2` DOUBLE DEFAULT 0,
ADD COLUMN `PRqst_DiscountPer` DOUBLE DEFAULT 0;

ALTER TABLE `PRequestDt`
ADD COLUMN `PRqstDt_Discount` DOUBLE DEFAULT 0,
ADD COLUMN `PRqstDt_DiscountAmount` DOUBLE DEFAULT 0,
ADD COLUMN `PRqstDt_DiscountBase1` DOUBLE DEFAULT 0,
ADD COLUMN `PRqstDt_DiscountBase2` DOUBLE DEFAULT 0;

#Ayman 13.03.2009
ALTER TABLE `machine` ADD COLUMN `Mach_Priority` DOUBLE DEFAULT 0;

#ram 14.3.09
alter table accesslabelsrocky.login
 add column FI_StkEval boolean default 0,
 add column FI_StkEvalMod boolean default 0,
 add column FI_StkEvalApp boolean default 0,
 add column Fi_StkEvalDel boolean default 0;
 
#Ghaith 16.03.2009
ALTER TABLE `accesslabelsrocky`.`loginstk`
 CHANGE COLUMN `project` `Enable_project` TINYINT(1) DEFAULT 0,
 CHANGE COLUMN `costcenter` `Enable_costcenter` TINYINT(1) DEFAULT 0,
 CHANGE COLUMN `groups` `Enable_groups` TINYINT(1) DEFAULT 0,
 CHANGE COLUMN `subgroup` `Enable_subgroup` TINYINT(1) DEFAULT 0,
 ADD COLUMN `Default_Project` BOOLEAN DEFAULT 0,
 ADD COLUMN `Default_Costcenter` BOOLEAN DEFAULT 0;

#Ayman 16.03.2009
CREATE TABLE `Vat2Template` (
  `Ledger_Number` VARCHAR(10) NOT NULL,
  `Ledger_Name` VARCHAR(50),
  PRIMARY KEY (`Ledger_Number`)
)
ENGINE = InnoDB;

ALTER TABLE `Salesdt`
ADD COLUMN `Saledt_PriceTTC` DOUBLE DEFAULT 0;

ALTER TABLE `Sales`
ADD COLUMN `Sale_TaxableTTC` DOUBLE DEFAULT 0,
ADD COLUMN `Sale_DiscountTTC` DOUBLE DEFAULT 0;

#Ghaith 21.03.2009
ALTER TABLE `accesslabelsrocky`.`loginstk` DROP COLUMN `Enable_project`,
 DROP COLUMN `Enable_costcenter`,
 DROP COLUMN `Enable_groups`,
 DROP COLUMN `Enable_subgroup`;

#Ghaith 23.03.2009  
#Only for the restrict project/costcenter modifications : 
#ALTER TABLE `sorderdt` MODIFY COLUMN `CostCenter_code` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;
Alter table sorderdt drop column Costcenter_Code;###NOT used, the field Costcent_Code is the one in use.

#Ghaith 24.03.2009
alter table deliverydt add column DeliveryDt_OldData Boolean Default 0;

#Ghaith 26.03.2009
ALTER TABLE clients DROP INDEX `clientscategory_code`,
 DROP FOREIGN KEY `clientscategory_code`;
alter table clients drop column category_code;
#Ghaith 30.03.2009
alter table PURCHASESJV add column LPO_Number Varchar(20);
alter table Porder add column LPO_Number Varchar(20);
#Ghaith 01.04.2009
ALTER TABLE `dexpcostcenter` MODIFY COLUMN `key` INTEGER NOT NULL DEFAULT NULL AUTO_INCREMENT;
#Ghaith 07.04.2009
Alter table RetailDt Modify column `Item_Vat` Double Default 0;
Insert Into Jourtype (TYPE_NAME, Type_Visible, Journal_typeRef, Synchronized) values('CH',1,0,0);
ALTER TABLE `retail` DROP FOREIGN KEY `retailsale_id`;

#Ghaith 08.04.2009
CREATE TABLE `StkTransactionSizes` (
  `TransactionDT_ID` INTEGER NOT NULL,
  `Transaction_ID` DOUBLE NOT NULL,
  `Transaction_Type` VARCHAR(3) NOT NULL,
  `Size_Measure` VARCHAR(10),
  `Color_Code` VARCHAR(10),
  `Quantity` DOUBLE,
  PRIMARY KEY (`TransactionDT_ID`, `Transaction_Type`)
)
ENGINE = InnoDB;

#Ayman 15.04.2009
ALTER TABLE `acclink` ADD COLUMN `PayJournal_ID` DOUBLE;
ALTER TABLE `acclink` ADD COLUMN `TraJournal_ID` DOUBLE;

ALTER TABLE `acclink` DROP FOREIGN KEY `paymacclinkjournal_id`,
 DROP FOREIGN KEY `transacclinkjournal_id`;

ALTER TABLE `acclink` ADD CONSTRAINT `PaymAcclinkJournal_id` FOREIGN KEY `PaymAcclinkJournal_id` (`PayJournal_ID`)
    REFERENCES `paymentrqst` (`PaymentRqst_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
ALTER TABLE `acclink` ADD CONSTRAINT `TransAcclinkJournal_id` FOREIGN KEY `TransAcclinkJournal_id` (`TraJournal_ID`)
    REFERENCES `TransDt` (`TransDt_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
	
# ram 21.4.09
alter table deliverydt add column Deliverydt_promotion tinyint(1) default 0;	

#Ghaith 22.04.2009
ALTER TABLE `stktransactionsizes` MODIFY COLUMN `Transaction_Type` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

update financialtemplate set Financial_type='Income'  where Financial_type=' Income';
alter table transactionsetup add column Trans_DiscountAcc Varchar(10) default null;

#Ayman 23.04.2009
ALTER TABLE `accesslabelsrocky`.`login` MODIFY COLUMN `production` TINYINT(1) DEFAULT 0;

#Ghaith 23.04.2009
alter table salessetup add column ExportDiscPerJV boolean default 0;

#Ayman 23.04.2009
ALTER TABLE `prequest` ADD COLUMN `PRqst_Application` VARCHAR(150) DEFAULT Null,
 ADD COLUMN `PRqst_Approved` TINYINT(1) DEFAULT 0,
 ADD COLUMN `PRqst_ApprovedBy` VARCHAR(10) DEFAULT Null;

 ALTER TABLE `prequest` MODIFY COLUMN `PRqst_TotalQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqst_TotalQuantityUsed` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqst_QuantityEqual` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `PRqst_ReducedQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqst_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqst_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqst_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqst_PriceBase2` DOUBLE DEFAULT 0;

ALTER TABLE `prequestdt` MODIFY COLUMN `PRqstDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqstDt_QuantityEqual` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `PRqstDt_QuantityUsed` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqstDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqstDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PRqstDt_PriceBase2` DOUBLE DEFAULT 0,
 ADD COLUMN `Synchronized` TINYINT(1) DEFAULT 0;

ALTER TABLE `checks` ADD COLUMN `Chk_BankInDate` DATETIME DEFAULT Null;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `PRqst_Approvedby` TINYINT(1) DEFAULT 0;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FPr_QCFP` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FPr_QCFPApp` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FPr_QCFPMod` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FPr_QCFPDel` TINYINT(1) DEFAULT 0;

#Ghaith 24.04.2009
alter table financialtemplate add column GrpLedNum varchar(10) default null;

#Ghaith 27.04.2009
alter table salessetup add column Sales_DiscountAcc Varchar(10) default null;
alter table transactionsetup modify column Trans_DiscountAcc Varchar(10) default null;
alter table deliverydt add column deliverydt_discountacc varchar(10) default null;

#ram 28.4.09
alter table accesslabelsrocky.login add column RI_SoldbySalesman boolean default 0;
alter table deliveries add column delivery_commissionper double;

#Ayman 29.04.2009
ALTER TABLE accesslabelsrocky.`purchasereport_label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE accesslabelsrocky.`sorderreport_label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE accesslabelsrocky.`deliveryreport_label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE accesslabelsrocky.`transferreport_label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#Ghaith 02.05.2009
alter table setup add column DefaultBase int default 1;

CREATE VIEW `ItemsPerWhSizesView` AS
  select StkTransaction.warehouse_Code,StkTransaction.Item_Code,Size_Measure,Color_Code,SUM(Quantity) As Size_Quantity
  from stktransactionsizes
  inner join StkTransaction on StkTransaction.Transaction_ID = StkTransactionSizes.Transaction_ID and StkTransaction.Transaction_Type = StkTransactionsizes.Transaction_Type
  group by StkTransaction.warehouse_Code,StkTransaction.Item_Code,Size_Measure,Color_Code
  having size_Quantity <> 0;


#akiki 02.05.2009
ALTER TABLE `setup` MODIFY COLUMN `NbrOfDigitInLedger` INTEGER DEFAULT NULL;

#Ayman 06.05.2009
ALTER TABLE `clients` ADD COLUMN `Client_TotPrvSales` DOUBLE DEFAULT 0,
 ADD COLUMN `Client_TotDaysNumber` DOUBLE DEFAULT 0;
ALTER TABLE `daysofyear` ADD INDEX `Date`(`Date`);

#Ghaith 06.05.2009
ALTER TABLE `stktransactionsizes`
 ADD INDEX `TransactionID`(`Transaction_ID`),
 ADD INDEX `SizeMeasure`(`Size_Measure`),
 ADD INDEX `ColorCode`(`Color_Code`),
 ADD INDEX `SizeColor`(`Size_Measure`, `Color_Code`);
 
#Ghaith 09.05.2009
alter table salesSetup add column LoadItems Boolean Default 0;
#Ghaith 11.05.2009 This is missing in some data.
alter table DExpCostCenter modify column `Key` Integer Not Null auto_increment;

#Ghaith 12.05.2009 TrackingHistory modification
CREATE TABLE `TrackingHistory` (
  `ID` INTEGER NOT NULL AUTO_INCREMENT,
  `RMA_ID` DOUBLE,
  `TrackingDate` DATETIME,
  `TrackingTime` DATETIME,
  `Description` VARCHAR(100),
  `Items_Required` VARCHAR(100),
  `Completed` BOOLEAN DEFAULT 0,
  `User_ID` varchar(30),
  PRIMARY KEY (`ID`)
);

alter table rmadt add column Outside_Item Boolean default 0;

#Ghaith 13.05.2009 ItemsSizes replacement
Drop VIEW `ItemsSizesView`;
CREATE VIEW `ItemsSizesView` AS
Select Item_Code,Size_Measure,Color_Code,sum(Quantity) As Item_Quantity
from StkTransactionSizes
inner join StkTransaction on StkTransaction.Transaction_ID = StkTransactionSizes.Transaction_ID and StkTransaction.Transaction_Type = StktransactionSizes.Transaction_Type
Where (not Size_Measure is null) OR (not Color_Code is null)
Group By Item_Code,Size_Measure,Color_Code
Order By Item_Code,Size_Measure,Color_Code;

#Ayman 14.05.2009
ALTER TABLE `sales` ADD COLUMN `Sale_OldData` BOOLEAN DEFAULT 0;

#Ayman 16.05.2009
ALTER TABLE `vatsubdttemplate` MODIFY COLUMN `VatDT_ID` INTEGER NOT NULL;
ALTER TABLE `vatsubdttemplate`
ADD CONSTRAINT `VaTDTID` FOREIGN KEY `VaTDTID` (`VaTDT_ID`)
    REFERENCES `vatdttemplate` (`AutoInc`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
	
#Ghaith 21.05.2009
alter table module add column Module_DirectStockSO Boolean Default 0;
alter table accesslabelsrocky.module add column Module_DirectStockSO Boolean Default 0;

#Ghaith 22.05.2009
alter table sorderdt
add column Sorderdt_DirectStkDbt Varchar(10) default Null,
add column Sorderdt_DirectStkCrd Varchar(10) default Null,
add column Sorderdt_DirectStkCur Varchar(10) default Null;

#Ghaith 27.05.2009
alter table salesdt
add column SaleDt_PricePerUnit double default 0,
add column SaleDt_QtyUnit double default 0;
alter table Transferdt
add column TransferDt_PricePerUnit double default 0,
add column TransferDt_QtyUnit double default 0;
alter table Adjustmentdt
add column AdjustmentDt_PricePerUnit double default 0,
add column AdjustmentDt_QtyUnit double default 0;

alter table transfersetup add column EnablePricePerUnit Boolean Default false;
alter table Adjustmentsetup add column EnablePricePerUnit Boolean Default false;

alter table StkTransaction
add column PricePerUnit double default 0,
add column QtyUnit double default 0;
#>

#Ghaith 28.05.2009
alter table items add column EvaluateQtyUnit Boolean default false;

#ram 2.6.09
alter table accesslabelsrocky.loginaccess3 add column FPr_QCFPRep tinyint(1) default 0;

CREATE TABLE accesslabelsrocky.`stkmovementr_label` (
  `Language` varchar(25) NOT NULL,
  `Caption` varchar(30) DEFAULT NULL,
  `Title` varchar(30) DEFAULT NULL,
  `ItemCode` varchar(25) DEFAULT NULL,
  `Total` varchar(25) DEFAULT NULL,
  `TotalGroup` varchar(25) DEFAULT NULL,
  `TotalQuantity` varchar(25) DEFAULT NULL,
  `TotalValue` varchar(25) DEFAULT NULL,
  `AverageCost` varchar(25) DEFAULT NULL,
  `CostCenter` varchar(25) DEFAULT NULL,
  `To` varchar(25) DEFAULT NULL,
  `DateFrom` varchar(25) DEFAULT NULL,
  `ItemFrom` varchar(25) DEFAULT NULL,
  `Project` varchar(25) DEFAULT NULL,
  `GroupFrom` varchar(25) DEFAULT NULL,
  `SubGroupFrom` varchar(25) DEFAULT NULL,
  `CategoryFrom` varchar(25) DEFAULT NULL,
  `GroupBy` varchar(25) DEFAULT NULL,
  PRIMARY KEY (`Language`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `stkmovementr_label`
--

INSERT INTO accesslabelsrocky.`stkmovementr_label` (`Language`,`Caption`,`Title`,`ItemCode`,`Total`,`TotalGroup`,`TotalQuantity`,`TotalValue`,`AverageCost`,`CostCenter`,`To`,`DateFrom`,`ItemFrom`,`Project`,`GroupFrom`,`SubGroupFrom`,`CategoryFrom`,`GroupBy`) VALUES
 ('English','Stock Movement','Stock Movement by Costcenter','Item code','Total','Total group','Total quantity','Total value','Average cost','Cost Center','to','Date from','Item from','project','Group from','Sub group from ','Category from ','Group by');

#Ghaith 03.06.2009
Alter table accesslabelsrocky.login
Add Column `FI_CustomerF` tinyint(1) Default 0,
add column `FI_CustomerDel` tinyint(1) Default 0,
add column `FI_CustomerApp` tinyint(1) Default 0,
add column `FI_CustomerMod` tinyint(1) Default 0;

#Ghaith 05.06.2009
alter table salessetup add column CheckQuantity boolean default false;
alter table deliveries add column DreturnIsDirect boolean default false;

#Ziad 09.06.2009
ALTER TABLE Area 
ADD Column Area_Tariff DOUBLE, 
Add Column Currency_code VarChar(6);

CREATE TABLE Transp
(
Transp_ID DOUBLE NOT NULL,
Transp_date Date,
Transp_Reference DOUBLE,
Transp_Remark VarChar(100),
Currency_Code VarChar(6),
PRIMARY KEY (Transp_ID)
);

CREATE TABLE TranspDT
(
TranspDT_ID DOUBLE NOT NULL,
Transp_ID DOUBLE NOT NULL,
Ledger_number VarChar(10),
TranspDT_Tariff DOUBLE,
TranspDT_Tariff1 DOUBLE,
TranspDT_Tariff2 DOUBLE,
TranspDT_Remark VarChar(100),
Area_Code VarChar(30),
Project_Code VarChar(30),
CostCenter_Code VarChar(30), 

PRIMARY KEY (TranspDT_ID),
FOREIGN KEY (Transp_ID) REFERENCES Transp(Transp_ID) 
ON UPDATE CASCADE 
ON DELETE CASCADE
);

ALTER TABLE accesslabelsrocky.login
ADD COLUMN FI_Transportation BOOL DEFAULT 0,
ADD COLUMN FI_TransportationApp BOOL DEFAULT 0,
ADD COLUMN FI_TransportationMod BOOL DEFAULT 0,
ADD COLUMN FI_TransportationDel BOOL DEFAULT 0;

#Ziad 10.06.2009

ALTER TABLE sequence
ADD COLUMN Transp_ID DOUBLE,
ADD COLUMN TranspDT_ID DOUBLE,
ADD COLUMN Transp_Reference DOUBLE;


ALTER TABLE `transpdt`
 DROP FOREIGN KEY `transpdt_ibfk_1`;

ALTER TABLE `transpdt` ADD CONSTRAINT `transpdt_ibfk_1` FOREIGN KEY `transpdt_ibfk_1` (`Transp_ID`)
    REFERENCES `transp` (`Transp_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

#Ghaith 11.06.2009
Alter table vatsubdttemplate
ADD Column Excluded Boolean Default 0;

#Ghaith 12.06.2009
ALTER TABLE Deliveries
ADD COLUMN Delivery_TransportAccount VARCHAR(10),
ADD COLUMN Delivery_transportAmount DOUBLE DEFAULT 0,
ADD COLUMN Delivery_TransportAmountBase1 DOUBLE DEFAULT 0,
ADD COLUMN Delivery_TransportAmountBase2 DOUBLE DEFAULT 0;

alter table DeliveryDt
add column DeliveryDt_TransportAmount Double default 0,
add column DeliveryDt_TransportAmountBase1 Double default 0,
add column DeliveryDt_TransportAmountBase2 Double default 0;

alter table salessetup add column TransportAccount Varchar(10);
alter table salessetup add column ExportTransportToJV Boolean Default 0;

#Ziad 16.06.2009
ALTER TABLE Cltcar
ADD COLUMN Cltcar_Owner varchar(50);

ALTER TABLE Cltcar
ADD PRIMARY KEY (Cltcar_code);


ALTER TABLE TranspDT
ADD COLUMN Delivery_Reference DOUBLE;

ALTER TABLE TranspDT
DROP COLUMN Ledger_number;

ALTER TABLE Transp
ADD COLUMN Driver_number varchar(10);

ALTER TABLE Transp
ADD COLUMN Transp_Time DATETIME;

ALTER TABLE Transp
ADD COLUMN Transp_CarCode varchar(10);

#Ziad 18.06.2009
ALTER TABLE `Transp`
CHANGE COLUMN `Transp_Time` `Transp_TimeFrom` DATETIME DEFAULT NULL;

ALTER TABLE `Transp`
ADD COLUMN `Transp_TimeTo` DATETIME DEFAULT NULL;


#Ghaith 18.06.2009
alter table Salesdt add column Saledt_promotion tinyint(1) default 0;
alter table Sales add column Sale_PromotionAcc Varchar(10);

#Ziad 19.06.2009
ALTER TABLE cltcar
MODIFY COLUMN cltCar_chassis_No varchar(20) UNIQUE;

#ram 18.6.09
create table DistPer(
DistPer_ID double not null,
DistPer_code varchar(15),
DistPer_Desc varchar(100),
DistPer_FromDate datetime,
DistPer_ToDate datetime,
Primary key (DistPer_ID)
);

create table DistPerDt (
DistPer_ID double not null,
DistPerDt_ID double not null,
Project_code varchar(15),
Costcenter_Code varchar(15),
DistPerDt_Percentage double,
primary key (DistPerDt_ID)
);

ALTER TABLE `sequence` ADD COLUMN `DistPer_id` DOUBLE,
 ADD COLUMN `DistPerDt_id` DOUBLE;
 
alter table DistperDt
add constraint DistPerID foreign key DistPerID (Distper_id)
references Distper (DistPer_id)
on delete cascade
on update cascade;

#Ghaith 23.06.2009
ALTER TABLE `deliverydtsizes` ADD INDEX `RelatedDtID`(`RelatedDt_ID`);

#Ziad 23.06.2009
CREATE TABLE CarType (
  carType_code VARCHAR(30),
  carType_desc VARCHAR(50),
  carType_ID INTEGER NOT NULL DEFAULT NULL AUTO_INCREMENT,
  PRIMARY KEY (carType_ID)
);

ALTER TABLE cltcar
ADD COLUMN carType_code varchar(30);

CREATE TABLE AreaTransp (
  AreaTransp_ID INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  IsTransfer BOOLEAN,
  Currency VARCHAR(10),
  Area_Code VARCHAR(30),
  CarType_code VARCHAR(30),
  Area_Tariff DOUBLE,
  PRIMARY KEY (AreaTransp_ID)
);

/*ALTER TABLE area
DROP COLUMN Area_Tariff;*/


#Elie 23.06.2009
ALTER TABLE `adjustment` ADD COLUMN `Adjustment_RequestBy` VARCHAR(100);
ALTER TABLE `transfer` ADD COLUMN `documentrefno` VARCHAR(45) ;
ALTER TABLE `transfer` ADD COLUMN `Driver_Name` VARCHAR(100);
ALTER TABLE `transfer` ADD COLUMN `Vehicle_No` VARCHAR(100);
ALTER TABLE `porder` ADD COLUMN `Expirydate` Datetime;

#Ziad 24.06.2009
ALTER TABLE areatransp
CHANGE COLUMN IsTransfer Transfer_Amount DOUBLE;

ALTER TABLE transp
ADD COLUMN Transp_SumBase2 DOUBLE;

#ram 24.6.09
alter table grosstitle add column grosstitle_displayonForm tinyint(1) default 0;

#Ziad 25.06.2009
ALTER TABLE Area
DROP COLUMN Currency_code;

ALTER TABLE Transp
CHANGE COLUMN Transp_SumBase2 Transp_AmountSum DOUBLE;

#Ghaith 25.06.2009
ALTER TABLE Transfer
ADD COLUMN Driver_Name VARCHAR(100),
ADD COLUMN Vehicle_No VARCHAR(50);

ALTER TABLE porder ADD COLUMN ExpiryDate DATETIME;

#Ziad 29.06.2009
alter table areatransp add index areaCode(area_code);

alter table area add index areaCode(area_code);

ALTER TABLE AreaTransp
ADD FOREIGN KEY area(Area_Code) REFERENCES Area(Area_Code)
ON DELETE CASCADE
ON UPDATE CASCADE;

#Ziad 30.06.2009
ALTER TABLE transpdt
ADD FOREIGN KEY (Area_Code) REFERENCES area (Area_Code)
ON DELETE RESTRICT
ON UPDATE CASCADE;


#Elie 30.06.2009
ALTER TABLE `rma` ADD COLUMN `RMAClient_Name` VARCHAR(100) ,
 ADD COLUMN `Client_Tel` VARCHAR(45) ,
 ADD COLUMN `Client_Email` VARCHAR(100) ,
 ADD COLUMN  `Rma_Remark` VARCHAR(120) ;

#02.07.2009
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Login_Decimal` INTEGER DEFAULT 0;

#Ziad 03.07.2009
ALTER TABLE `setup` MODIFY COLUMN `NbrOfDigitInLedgerSalesmen` INTEGER DEFAULT 0;

#Ziad 07.07.2009
ALTER TABLE `grouping` ADD COLUMN `Group_color` BLOB;
ALTER TABLE `porderdt` MODIFY COLUMN `PorderDt_SecondTime` DATETIME;

#Ayman 09.07.2009
ALTER TABLE accesslabelsrocky.`SReturnForm_label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE accesslabelsrocky.`SaleReport_Label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE accesslabelsrocky.`POrderReport_Label` CHANGE COLUMN `Date` `f_Date` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE accesslabelsrocky.`SOrderReport_Label` CHANGE COLUMN `By` `f_By` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#Ayman 10.07.2009
ALTER TABLE `purchases` ADD COLUMN `SrvNo` VARCHAR(25),
 ADD COLUMN `WaybillNo` VARCHAR(25);
ALTER TABLE `transfer` ADD COLUMN `Requestedby` VARCHAR(45);

#Ziad 15.07.2009
alter table retaildt add column serialNo_Code varchar(20) default null;

#Ayman 21.07.2009
ALTER TABLE `warehouse` ADD COLUMN `Warehouse_Category` INTEGER DEFAULT 0;
ALTER TABLE `module` ADD COLUMN `Module_WhSellingPrice` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`module` ADD COLUMN `Module_WhSellingPrice` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Unmodify_SellingPrice` TINYINT(1) DEFAULT 0;

#Ayman 25.07.2009
ALTER TABLE `transactionsetup` ADD COLUMN `Trans_PromotionAcc` VARCHAR(10);
ALTER TABLE `deliverydt` ADD COLUMN `DeliveryDt_PromoAcc` VARCHAR(10);

#Ziad 29.07.2009
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `RI_StkMovement` TINYINT(1) DEFAULT 0;

#Ayman 31.07.2009
ALTER TABLE `salesmen` ADD COLUMN `Salesman_MRef` VARCHAR(15);

#Ayman 03.08.2009
ALTER TABLE `Sorder` ADD COLUMN `Salesman_Code` VARCHAR(10);
ALTER TABLE `Sorder` DROP FOREIGN KEY `SorderSalesman_Code`;

ALTER TABLE `Sorder` ADD CONSTRAINT `SorderSalesman_Code` FOREIGN KEY `SorderSalesman_Code` (`Salesman_Code`)
    REFERENCES `Salesmen` (`Ledger_number`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;
ALTER TABLE `Porder` ADD COLUMN `Porder_Hide` TINYINT(1) DEFAULT 0;
ALTER TABLE `Sorder` ADD COLUMN `Sorder_Hide` TINYINT(1) DEFAULT 0;

ALTER TABLE accesslabelsrocky.`sorderreport_label` CHANGE COLUMN `Desc` `f_Desc` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `purchases` ADD COLUMN `User_Account` VARCHAR(10);

ALTER TABLE `cashtype` DROP PRIMARY KEY,
 ADD PRIMARY KEY  USING BTREE(`Auto`, `CashType_Code`, `Journal_Type`);
ALTER TABLE `packdt` ADD COLUMN `PackDt_PromoQty` DOUBLE DEFAULT 0;
ALTER TABLE `salesdt` ADD COLUMN `SaleDt_DiscountAcc` VARCHAR(10);
ALTER TABLE `financialtemplate` ADD COLUMN `Ledger_ShowDT` TINYINT(1) DEFAULT 0;

#ram 21.8.09
alter table `module` add column module_base2 tinyint(1) default 0;
alter table accesslabelsrocky.`module` add column module_base2 tinyint(1) default 0;

#Ayman 26.08.2009
ALTER TABLE `sales` ADD COLUMN `Print_count` INTEGER DEFAULT 0;
ALTER TABLE `trans` ADD INDEX `Type Reference`(`Trans_CashReference`);

#Ayman 03.09.2009
ALTER TABLE `prequest` MODIFY COLUMN `User_Name` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `sales` ADD COLUMN `sale_memo` BLOB;

#ram 7.9.09
alter table clientsip add column Client_inst_Month datetime,
 add column Clientip_OldTransDate datetime,
 add column Collection_Name varchar(51),
 add column IPCode varchar(16),
 add column OldAmount double;

#Ayman 16.09.2009
ALTER TABLE `rma` MODIFY COLUMN `RMA_Reference` VARCHAR(45) DEFAULT NULL;

#ram 22.9.09
alter table module add column module_serialnoVal tinyint(1) default 0;

alter table accesslabelsrocky.module add column module_serialnoVal tinyint(1) default 0;

#Ayman29.09.2009
#ALTER TABLE `Unit` ADD COLUMN `QtyUnit1` DOUBLE DEFAULT 0,
# ADD COLUMN `Unit2` VARCHAR(10),
# ADD COLUMN `QtyUnit2` Double DEFAULT 0;
ALTER TABLE `trans` MODIFY COLUMN `Trans_ManualNo` VARCHAR(20) DEFAULT NULL;

ALTER TABLE `accesslabelsrocky`.`stockadjustreport_label`
 CHANGE COLUMN `Date` `f_Date` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `accesslabelsrocky`.`porderreport_label`
CHANGE COLUMN `Code` `f_Code` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#ram 1.10.09, for fusion to use them in search mode
alter table sales add index deliveryRef(Sale_RelatedID);
alter table journal add index typeRef(journal_TypeRef);

#Ayman 05.10.2009 elie nigeria
ALTER TABLE `module` ADD COLUMN `module_negativeSorder` BOOLEAN;
ALTER TABLE accesslabelsrocky.`module` ADD COLUMN `module_negativeSorder` BOOLEAN ;

#ram 8.10.09
alter table PRequest
  add column PRqst_Status varchar(1),
  add column Status_Remark Varchar(100) ;

alter table POrder
  add column POrder_Status varchar(1),
  add column Status_Remark varchar(100);

#alter table items add column Item_ManufactureCode varchar(20);
alter table Porderdt add column Item_ManufacturedCode varchar(20);
alter table PRequestdt add column Item_ManufacturedCode varchar(20);
#>

#Ayman 09.10.2009
ALTER TABLE `sequence` ADD COLUMN `Prod_Ref` DOUBLE;
ALTER TABLE `sequence` MODIFY COLUMN `Prod_Ref` DOUBLE DEFAULT NULL;

# ram 10.10.09
alter table prequest add column Prqst_VatChkBox tinyint(1) default 0;

#ram 12.10.09
alter table clients add column Client_paymentTerms2 double;

#ram 15.10.09
alter table porder add column Prequest_Ref double;
alter table porderdt add column Prequest_Ref double;
alter table prequestdt add column item_vat double;

#Ayman 15.10.09
alter table GrossTitle add column Grosstitle_IsParent tinyint(1) default 0;

# ram 21.10.09
alter table prequest add column Prqst_Print tinyint(1) default 0;

#Ayman 22.10.09
ALTER TABLE `module` ADD COLUMN `Module_InBeforeOut` TINYINT(1) DEFAULT 0;
ALTER TABLE accesslabelsrocky.`module` ADD COLUMN `Module_InBeforeOut` TINYINT(1) DEFAULT 0;

#Ayman 26.10.09
ALTER TABLE `accesslabelsrocky`.`loginaccess3` ADD COLUMN `FPr_LoadSuppliers` TINYINT(1) DEFAULT 0;
ALTER TABLE `prodqcfp` MODIFY COLUMN `ProdQCFP_ID` DOUBLE NOT NULL,
 ADD PRIMARY KEY (`ProdQCFP_ID`);
ALTER TABLE `prodqcfpdt` MODIFY COLUMN `ProdQCFPDt_ID` DOUBLE NOT NULL,
 ADD PRIMARY KEY (`ProdQCFPDt_ID`);
ALTER TABLE `prodqcfpitem` MODIFY COLUMN `ProdQCFPITEM_ID` DOUBLE NOT NULL,
 ADD PRIMARY KEY (`ProdQCFPITEM_ID`);

#ram 27.10.09
alter table VatDtTemplate
  add column operator varchar(1),
  add column operator2 varchar(1),
  add column Debit varchar(1),
  add column Debit2 varchar(1),
  add column Number double,
  add column Number2 double;

alter table VatTemplate add column Amnt_Round double;

#Ayman 02.11.2009
ALTER TABLE `StkTransaction` ADD COLUMN `CostBase1` DOUBLE DEFAULT 0,
   ADD COLUMN `CostBase2` DOUBLE DEFAULT 0;

#ram 4.11.09
alter table sorderdt
  add column sorderdt_GrossModel varchar(4) default null, 
  add column sorderdt_GrossBLen double default 0,
  add column sorderdt_GrossBWid double default 0,
  add column sorderdt_Outs double default 0,
  add column sorderdt_Pces double default 0,
  add column sorderdt_SOITSAI varchar(1) default null,
  add column sorderdt_Unit varchar(1) default null;

#ram 9.11.09
alter table sorderdt
  add column sorderdt_PcesPerItem integer default 0,
  add column sorderdt_ManType varchar(1) default null,
  add column sorderdt_PcsModel varchar(4) default null,
  add column sorderdt_NumOfColor integer default 0,
  add column sorderdt_Colors varchar(3) default null,
  add column sorderdt_coverLayer varchar(1) default null,
  add column sorderdt_SpecialInsQty varchar(1) default null,
  add column sorderdt_CorrugatorQty integer default 0,
  add column sorderdt_Fluting varchar(3) default null,
  add column sorderdt_Length double default 0,
  add column sorderdt_Width double default 0,
  add column sorderdt_height double default 0,
  add column sorderdt_Bonding varchar(1) default null,
  add column sorderdt_packagePrice double default 0,
  add column sorderdt_SalvagePrice double default 0,
  add column sorderdt_ExtraPrice double default 0,
  add column sorderdt_UCostPrice double default 0;

#wissam 09/11/2009
ALTER TABLE `accesslabelsrocky`.`reportoptionsinv_label`
 ADD COLUMN `PRequest` VARCHAR(25);
update `accesslabelsrocky`.`reportoptionsinv_label` set PRequest = "Purchase Request";

#ram 9.11.09
alter table Purchasesdt add column Item_ManufacturedCode varchar(20);

#wissam 09/11/2009
ALTER TABLE `accesslabelsrocky`.`purchaselistreport_label`
 ADD COLUMN `Title11` VARCHAR(25);
update `accesslabelsrocky`.`purchaselistreport_label` set Title11 = "Purchase Request"
  where `Language` = "English";

#Wissam 09/11/2009
ALTER TABLE `salessetup`
 ADD COLUMN `Sale_CLAAccount2` VARCHAR(10),
 ADD COLUMN `Sale_DCTAccount2` VARCHAR(10),
 ADD COLUMN `Sale_AWAccount2` VARCHAR(10),
 ADD COLUMN `Sale_TRPAccount2` VARCHAR(10),
 ADD COLUMN `Sales_DiscountAcc2` VARCHAR(10);

#wissam 10/11/2009
ALTER TABLE `prequest`
 ADD COLUMN `Prqst_Tax1` DOUBLE,
 ADD COLUMN `Prqst_Tax2` DOUBLE,
 ADD COLUMN `Prqst_Tax3` DOUBLE,
 ADD COLUMN `Prqst_Tax4` DOUBLE,
 ADD COLUMN `Prqst_Tax5` DOUBLE,
 ADD COLUMN `Prqst_Tax1Base1` DOUBLE,
 ADD COLUMN `Prqst_Tax2Base1` DOUBLE,
 ADD COLUMN `Prqst_Tax3Base1` DOUBLE,
 ADD COLUMN `Prqst_Tax4Base1` DOUBLE,
 ADD COLUMN `Prqst_Tax5Base1` DOUBLE,
 ADD COLUMN `Prqst_Tax1Base2` DOUBLE,
 ADD COLUMN `Prqst_Tax2Base2` DOUBLE,
 ADD COLUMN `Prqst_Tax3Base2` DOUBLE,
 ADD COLUMN `Prqst_Tax4Base2` DOUBLE,
 ADD COLUMN `Prqst_Tax5Base2` DOUBLE;

#Ayman 13.11.2009
ALTER TABLE `purchasesdt` ADD COLUMN `PurchaseDt_OldData` TINYINT(1) DEFAULT 0;

#wissam 13/11/2009
CREATE TABLE ItemManufacture (
  Item_ManufactureCode VARCHAR(20),
  Item_ManufactureDesc VARCHAR(60),
  Item_Code VARCHAR(20),
  PRIMARY KEY (Item_ManufactureCode)
);

ALTER TABLE `module` ADD COLUMN `Module_DoubleUnit` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`module` ADD COLUMN `Module_DoubleUnit` TINYINT(1) DEFAULT 0;

#Ayman 17.11.2009
ALTER TABLE `unit` DROP COLUMN `QtyUnit1`,
 DROP COLUMN `Unit2`,
 DROP COLUMN `QtyUnit2`;

CREATE TABLE `UnitConverge` (
  `Unit1` VARCHAR(10) NOT NULL,
  `Unit2` VARCHAR(10) NOT NULL,
  `Coefficient` DOUBLE NOT NULL,
  `Coeff_Date` DATETIME NOT NULL,
  PRIMARY KEY (`Unit1`, `Unit2`, `Coefficient`, `Coeff_Date`)
)
ENGINE = InnoDB;

#Ayman 17.11.2009 : Elie Request Nigeria
ALTER TABLE `SorderDt` ADD COLUMN `SorderDt_Promotion` BOOLEAN Default 0;
ALTER TABLE `Deliveries` ADD COLUMN `Sorder_Reference` DOUBLE;
ALTER TABLE `Deliveries` ADD INDEX `SorderRef`(`Sorder_Reference`);
ALTER TABLE `Sales` ADD COLUMN `sorder_reference` DOUBLE;

#wissam 24/11/2009
ALTER TABLE `sorderdt` ADD COLUMN `Item_ManufacturedCode` VARCHAR(20);
ALTER TABLE `deliverydt` ADD COLUMN `Item_ManufacturedCode` VARCHAR(20);
ALTER TABLE `salesdt` ADD COLUMN `Item_ManufacturedCode` VARCHAR(20);
ALTER TABLE `adjustmentdt` ADD COLUMN `Item_ManufacturedCode` VARCHAR(20);
ALTER TABLE `transferdt` ADD COLUMN `Item_ManufacturedCode` VARCHAR(20);

#ram 25.11.09
alter table module add column module_manufacturedCode tinyint(1) default 0;
alter table accesslabelsrocky.module add column module_manufacturedCode tinyint(1) default 0;

#Ayman 25.11.09
ALTER TABLE `Sequence` ADD COLUMN `StockEval_TypeRef` DOUBLE;

#Wissam 30/11/2009
ALTER TABLE `purchasesdt` ADD COLUMN `PurchaseDt_DirectConsumption` TINYINT(1) DEFAULT 0;

#Ayman 01.12.09
ALTER TABLE `Prequestdt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `PorderDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `PurchasesDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;

#ram 3.12.09
Alter table items
    modify column Item_ReverseProduction tinyint(1) default 0,
    modify column Item_Production tinyint(1) default 0,
    modify column Item_Pack tinyint(1) default 0,
    modify column Item_NonStock tinyint(1) default 0,
    modify column Item_TTCInclude tinyint(1) default 0,
    modify column Item_SemiFinished tinyint(1) default 0,
    modify column Item_Active tinyint(1) default 0,
    modify column Item_FixedAsset tinyint(1) default 0,
    modify column Item_Printed tinyint(1) default 0;

#Ayman 04.12.09
ALTER TABLE `DeliveryDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `SorderDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `SalesDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `TransferDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `AdjustmentDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `ProductionDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `Production` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `PreProductionDt` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `PreProduction` ADD COLUMN `Item_UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Item_Unit2Qty` DOUBLE DEFAULT 0;
ALTER TABLE `StkTransaction` ADD COLUMN `UnitCoef` DOUBLE DEFAULT 0,
 ADD COLUMN `Unit2Qty` DOUBLE DEFAULT 0;


#nabil 07.12.2009
alter table areatransp add column area_tarrifvisit tinyint DEFAULT 1;
alter table transpdt add column transpdt_tarrifvisit tinyint DEFAULT 1;

#WISSAM 17/12/2009
ALTER TABLE `setup` ADD COLUMN `Iso_Logo` BLOB DEFAULT NULL;
ALTER TABLE `salessetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `sordersetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `purchasesetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `prequestsetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `pordersetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `paymentsetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `adjustmentsetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `dbtnotesetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `crdnotesetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `receiptsetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `transfersetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `transactionsetup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `setup` ADD COLUMN `IsoDescription` VARCHAR(100);
ALTER TABLE `salessetup` ADD COLUMN `IsoDlvDescription` VARCHAR(100);

alter table accesslabelsrocky.loginaccess3 add column FPr_LoadSuppliers TINYINT(1);
alter table ProdTransChdt add column Costcenter_Code varchar(25);
alter table ProdTrans add column Costcenter_Code varchar(25);

ALTER TABLE `prodtranschdt` ADD COLUMN `ProdTransChDt_FromTime` DATETIME AFTER `Costcenter_Code`,
 ADD COLUMN `ProdTransChDt_ToTime` DATETIME AFTER `ProdTransChDt_FromTime`,
 ADD COLUMN `ProdTransChDt_Quantity2` DOUBLE AFTER `ProdTransChDt_ToTime`,
 ADD COLUMN `ProdTransChDt_AmendQty` DOUBLE AFTER `ProdTransChDt_Quantity2`;

alter table sequence
add column  ProdTransChDt_Id double,
add column  ProdTransCh_ID double,
add column  ProdTransCh_Reference double,
add column  ProdAmendCh_ID double;

alter table sequence
add column  ProdAmendCh_ID double,
add column  ProdAmendChdt_ID double,
add column  ProdAmendCh_Reference double;

CREATE TABLE `ProdAmendCH` (
  `ProdAmendCH_ID` DOUBLE NOT NULL AUTO_INCREMENT,
  `ProdAmendCH_date` DATETIME,
  `ProdAmendCH_fromDate` DATETIME,
  `ProdAmendCH_toDate` DATETIME,
  `ProdAmendCH_Reference` DOUBLE,
  `ProdAmendCH_Remark` VARCHAR(100),
  PRIMARY KEY (`ProdAmendCH_ID`)
)
ENGINE = InnoDB;

CREATE TABLE `ProdAmendCHdt` (
  `ProdAmendCHdt_id` DOUBLE NOT NULL AUTO_INCREMENT,
  `ProdAmendCH_id` DOUBLE,
  `item_code` VARCHAR(25),
  `ProdAmendCHDT_AmendQty` DOUBLE,
  `ProdAmendCHDT_NbCons` INTEGER UNSIGNED,
  PRIMARY KEY (`ProdAmendCHdt_id`),
  CONSTRAINT `FK_ProdAmendCHdt_1` FOREIGN KEY `FK_ProdAmendCHdt_1` (`ProdAmendCH_id`)
  REFERENCES `prodamendch` (`ProdAmendCH_ID`)
  ON DELETE CASCADE
  ON UPDATE CASCADE
);

ALTER TABLE `prodtransfu` ADD COLUMN `ProdTransFu_AmndQty` DOUBLE AFTER `Synchronized`;
ALTER TABLE `prodtransfu` ADD COLUMN `Mach_code` VARCHAR(25) AFTER `ProdTransFu_AmndQty`;

CREATE TABLE `ProdAmendFu` (
  `ProdAmendFu_ID` DOUBLE NOT NULL AUTO_INCREMENT,
  `ProdAmendFu_Date` DATETIME,
  `ProdAmendFu_FromDate` DATETIME,
  `ProdAmendFu_ToDate` DATETIME,
  `ProdAmendFu_Qqty` DOUBLE,
  `Item_Code` VARCHAR(25),
  `User_Account` VARCHAR(10),
  `ProdAmendFU_Reference` DOUBLE,
  PRIMARY KEY (`ProdAmendFu_ID`)
)
ENGINE = InnoDB;

ALTER TABLE `prodamendfu` MODIFY COLUMN `ProdAmendFu_ID` INTEGER UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT;
alter table sequence add column ProdAmendFU_Reference double;
ALTER TABLE `prodtransfu` ADD COLUMN `Project_code` VARCHAR(25) AFTER `Mach_code`;


#nabil 23.12.2009

alter table salesdt add column saledt_pqty double;
alter table deliverydt add column deliverydt_pqty double;

#wissam 26/12/2009
ALTER TABLE `ledger` ADD COLUMN `Ledger_inactive` TINYINT(1) UNSIGNED DEFAULT 0,
 ADD COLUMN `Ledger_inactivedate` DATETIME;

#Ayman 28.12.2009
ALTER TABLE `acclink` ADD COLUMN `Trans_Ref` DOUBLE;

#Ayman 07.01.2010
ALTER TABLE `clients` ADD COLUMN `Client_TotPrvSumBal` DOUBLE DEFAULT 0,
 ADD COLUMN `Client_ActualBal` DOUBLE DEFAULT 0;

#Wissam 11/01/2010
ALTER TABLE `accesslabelsrocky`.`listuserdir` ADD COLUMN `LockViewPeriod` TINYINT(1) UNSIGNED,
 ADD COLUMN `ViewPeriodDate` DATETIME,
 ADD COLUMN `ViewLockDaily` TINYINT(1) UNSIGNED,
 ADD COLUMN `ViewNumberOfDays` TINYINT UNSIGNED;

#wissam 21/01/2010
CREATE TABLE `transpdtPrjCst` (
  `transpdtPrjCst_id` INTEGER NOT NULL AUTO_INCREMENT,
  `transpdt_id` DOUBLE NOT NULL,
  `CostCent_Code` VARCHAR(30),
  `Project_Code` VARCHAR(30),
  `transpdtPrjCst_Amount` DOUBLE,
  `transpdtPrjCst_Amount1` DOUBLE,
  `transpdtPrjCst_Amount2` DOUBLE,
  `transpdtPrjCst_Percentage` DOUBLE,
  PRIMARY KEY (`transpdtPrjCst_id`),
  CONSTRAINT `transpdtPrjCsttranspdt_id` FOREIGN KEY `transpdtPrjCsttranspdt_id` (`transpdt_id`)
    REFERENCES `transpdt` (`TranspDT_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `transpdtPrjCstCostCent_code` FOREIGN KEY `transpdtPrjCstCostCent_code` (`CostCent_Code`)
    REFERENCES `costcent` (`Costcent_code`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT,
  CONSTRAINT `transpdtPrjCstProject_Code` FOREIGN KEY `transpdtPrjCstProject_Code` (`Project_Code`)
    REFERENCES `project` (`Project_Code`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
);
#nabil 31.jan.2010
update salesdt set saledt_discountper = 0 where saledt_discountper is null;

ALTER TABLE `salesdt` MODIFY COLUMN `SaleDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_QuantityReturn` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_DiscountPer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_DiscountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_DiscountBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Vat` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_tax` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `saledt_pqty` DOUBLE DEFAULT 0;

alter table stktransaction add column Item_CodePacked varchar(20);


ALTER TABLE accesslabelsrocky.loginstk ADD COLUMN `warehouse_code` VARCHAR(20) ;
CREATE TABLE accesslabelsrocky.ledgerstk (`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,`user_account` VARCHAR(10),
  `ledger_number` VARCHAR(10),
  `ledger_include` BOOLEAN,
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;


ALTER TABLE `costcent` ADD COLUMN `CostCent_Reference` DOUBLE  ;
ALTER TABLE `costcent` ADD COLUMN `CostCent_ReferenceD` DOUBLE ;
ALTER TABLE `costcent` ADD COLUMN `CostCent_ReferenceS` DOUBLE ;

ALTER TABLE `sordersetup` ADD COLUMN `Changerefernce` TINYINT(1) DEFAULT 0;
ALTER TABLE `purchasesdt` ADD COLUMN `PurchaseDt_PriceTTC` DOUBLE ;

alter table journal add column manual_no varchar(30);
alter table checks add column manual_no varchar(30);
alter table checkscollected add column manual_no varchar(30);
alter table checkscollected add column journaldt_desc varchar(100);

#nabil 2010-02-23
ALTER TABLE `clients` MODIFY COLUMN `Ledger_name` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;

ALTER TABLE `sales` ADD COLUMN `sale_activevat` boolean NOT NULL DEFAULT 1 ;
ALTER TABLE `deliveries` ADD COLUMN `delivery_activevat` boolean NOT NULL DEFAULT 1 ;
	
#nabil 2010-02-27
#ALTER TABLE `sorderdt` MODIFY COLUMN `sorderdt_cqty` DOUBLE NOT NULL DEFAULT 0;
ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_oqty` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_cqty` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_cqtydate` DATETIME ;
ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_cqtyuser` VARCHAR(30) ;
update sorderdt set sorderdt_oqty=sorderdt_quantity+sorderdt_cqty;

#nabil 2010-03-03
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `RA_AvgDays` TINYINT(1) DEFAULT NULL,
 ADD COLUMN `RA_SalesJV` TINYINT(1) DEFAULT NULL,
 ADD COLUMN `RA_PurchasesJV` TINYINT(1) DEFAULT NULL;

#nabil 2010-03-10
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SorderCanceledQty` TINYINT(1) DEFAULT NULL;

#nabil 2010-03-15
alter table acctypedt add column costcenter_code varchar(30);

#nabil 2010-03-10
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `ShowTransaction` TINYINT(1) DEFAULT NULL;

#elie 2010-03-15
alter table journaldt add column Manual_no varchar(45);


#Elie 2010-03-15
ALTER TABLE `transfer` ADD COLUMN `User_account` VARCHAR(30) ;
ALTER TABLE `adjustment` ADD COLUMN `User_account` VARCHAR(30) ;
ALTER TABLE `production` ADD COLUMN `User_account` VARCHAR(30) ;
ALTER TABLE `preproduction` ADD COLUMN `User_account` VARCHAR(30) ;


ALTER TABLE accesslabelsrocky.login add COLUMN ShowTransaction TINYINT(1) DEFAULT 1;

#nabil 2010/04/13
alter table items add column `item_inactivedate` datetime;
alter table jourtype add column `confirmed_visible` tinyint(1) ;


#nabil 2010-04-23
ALTER TABLE `sales` ADD COLUMN `sale_chkvat` BOOLEAN NOT NULL DEFAULT 0 ;
update sales set sale_chkvat=1 where sale_vat<>0 and sale_Vat is not null;

ALTER TABLE 	`module` ADD COLUMN `module_creditlimit` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1 ;

#nabil 2010-04-26
ALTER TABLE `clients` ADD COLUMN `Client_budgetlimit` DOUBLE   default 0;
ALTER TABLE `module` ADD COLUMN `module_budgetlimit` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;

ALTER TABLE `items` ADD COLUMN `item_longdescription` varchar(1000) ;

#nabil 2010-04-27
alter table items modify column item_active tinyint(1) default 1;
alter table items modify column item_printed tinyint(1) default 1;

#nabil 2010-04-28
ALTER TABLE `module` ADD COLUMN `module_longdescription` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;

#nabil 2010-05-02
ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_LastSellingPrice` DOUBLE ;
alter table `deliverydt` add COLUMN `deliverydt_lastsellingdiscount` double;
alter table `deliverydt` add COLUMN `deliverydt_lastsellingdate` datetime;

alter table `salesdt` add column `saledt_lastsellingprice` double;
alter table `salesdt` add column  `saledt_lastsellingdiscount` double;
alter table `salesdt` add COLUMN `saledt_lastsellingdate` datetime;


ALTER TABLE `transactionsetup` ADD COLUMN `Trans_VATAccount` VARCHAR(10) ;


ALTER TABLE `purchasesdt` ADD COLUMN `PurchaseDt_VATAccount` VARCHAR(10) ;

create table purchases_temp like purchases;

insert into purchases_temp (purchase_id,purchase_vataccount) select purchase_id , purchase_vataccount from purchases;


#drop table purchases_temp;




#nabil 2010-05-06
ALTER TABLE `sorder` DROP FOREIGN KEY `SorderSalesman_Code`;


CREATE TABLE `cashflowtemplate` (
  `cashflowtemplate_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `cashflowtemplate_level` varchar(5) NOT NULL,
  `cashflowtemplate_desc` varchar(50) NOT NULL,
  `related_id` bigint(20) unsigned DEFAULT NULL,
  `label_order` int(10) unsigned NOT NULL,
  PRIMARY KEY (`cashflowtemplate_id`)
) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8;


CREATE TABLE `cashflowdttemplate` (
  `cashflowdttemplate_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `cashflowtemplate_id` bigint(20) unsigned NOT NULL,
  `ledger_number` varchar(45) DEFAULT NULL,
  `journal_type` varchar(2) ,
  PRIMARY KEY (`cashflowdttemplate_id`),
  KEY `FK_cashflowdttemplate_1` (`cashflowtemplate_id`),
  CONSTRAINT `FK_cashflowdttemplate_1` FOREIGN KEY (`cashflowtemplate_id`) REFERENCES `cashflowtemplate` (`cashflowtemplate_id`)
) ENGINE=InnoDB AUTO_INCREMENT=181 DEFAULT CHARSET=utf8;



ALTER TABLE `cashflowdttemplate`
 DROP FOREIGN KEY `FK_cashflowdttemplate_1`;

ALTER TABLE `cashflowdttemplate` ADD CONSTRAINT `FK_cashflowdttemplate_1` FOREIGN KEY `FK_cashflowdttemplate_1` (`cashflowtemplate_id`)
    REFERENCES `cashflowtemplate` (`cashflowtemplate_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

#nabil 2010-05-14
alter table `cashflowtemplate`  add column  `cashtemplate_header` tinyint(1) DEFAULT NULL;

#nabil 2010-05-18
ALTER TABLE `transpdt` ADD COLUMN `transpdt_debit` VARCHAR(10) ;
ALTER TABLE `transp` ADD COLUMN `journal_id` DOUBLE;

#ALTER TABLE `sequence` ADD COLUMN `transport_type` DOUBLE NOT NULL ;
ALTER TABLE `sequence` ADD COLUMN `transport_typeref` DOUBLE NOT NULL ;



ALTER TABLE `transp` ADD COLUMN `transp_jvdate` datetime;

#nabil 2010-05-21
ALTER TABLE `items` ADD COLUMN `item_lastcostprice` DOUBLE default 0 ,
 ADD COLUMN `item_lastcostpricebase1` DOUBLE default 0 ,
 ADD COLUMN `item_lastcostpricebase2` DOUBLE default 0 ;

ALTER TABLE `purchasesdt` MODIFY COLUMN `PurchaseDt_id` DOUBLE NOT NULL DEFAULT 0,
 MODIFY COLUMN `Purchase_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesReturn` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesBase1R` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesBase2R` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_DiscountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_DiscountBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `RelatedDt_Id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PreceiptDt_Id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_VAT` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Purchasedt_estimatedSell` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_Volume` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_BelongsToGroup` INTEGER DEFAULT 0,
 MODIFY COLUMN `Porder_ref` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesAmntB1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_ChargesAmntB2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_VatCharge` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_VatChargeBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_VatChargeBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_qtyPacked` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `PurchaseDt_PriceTTC` DOUBLE DEFAULT 0;

ALTER TABLE `trans` ADD INDEX `Manualno`(`Trans_ManualNo`);


#nabil 2010-05-31
ALTER TABLE `prequest` 
 ADD COLUMN `Prqst_lstordsupp` VARCHAR(45) AFTER `Prqst_Tax5Base2`,
 ADD COLUMN `Prqst_lstordpayterm` VARCHAR(45) AFTER `Prqst_lstordsupp`,
 ADD COLUMN `Prqst_lstorddeliveryterms` VARCHAR(45) AFTER `Prqst_lstordpayterm`,
 ADD COLUMN `Prqst_otherSupplier` VARCHAR(45) AFTER `Prqst_lstorddeliveryterms`;


ALTER TABLE `prequestdt` ADD COLUMN `PRqstDt_QuantityExist` DOUBLE AFTER `Item_Unit2Qty`,
 ADD COLUMN `PRqstDt_LastPrice` DOUBLE AFTER `PRqstDt_QuantityExist`,
 ADD COLUMN `PRqstDt_LastCurrency_code` VARCHAR(6) AFTER `PRqstDt_LastPrice`,
 ADD COLUMN `PRqstDt_LastSupplier_code` VARCHAR(10) AFTER `PRqstDt_LastCurrency_code`;

#ALTER TABLE `prequestdt` ADD COLUMN `PRqstDt_monthlyconsumption` DOUBLE

ALTER TABLE `prequest` ADD COLUMN `Prqst_monthlyconsumption` DOUBLE;


#GEO 2010-06-01
Alter table ProdTrans add column ProdTrans_Cost1 double;
Alter table ProdTrans add column ProdTrans_Cost2 double;
Alter table ProdTransChDt add column ProdTranschdt_Cost1 double;
Alter table ProdTransChDt add column ProdTransCHDT_Cost2 double;
Alter table ProdTransFU add column ProdTransFU_Cost1 double;
Alter table ProdTransFU add column ProdTransFU_Cost2 double;

alter table ProdTrans add column ProdTrans_ToDate Datetime;
Alter table accesslabelsrocky.Login add column FPR_ChangeWeight boolean;

#nabil 2010-06-07
ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_quantitydelivered` DOUBLE DEFAULT 0 ;
ALTER TABLE `sorderdt` ADD COLUMN `sorderDt_QtyUnit` DOUBLE DEFAULT 0 ;

#nabil 2010-06-09
alter table clients add column warehouse_code varchar(15);

ALTER TABLE `module` ADD COLUMN `module_DeliveryWithSorder` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `module` ADD COLUMN `module_deliverytransfer` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `module` ADD COLUMN `module_deliverySales` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;




#nabil 2010-06-17
ALTER TABLE `transp` ADD COLUMN `transp_taxper` DOUBLE NOT NULL DEFAULT 0 ,
 ADD COLUMN `transp_taxamount` DOUBLE NOT NULL DEFAULT 0 ,
 ADD COLUMN `taxledger_number` VARCHAR(10) ;

#nabil 2010-06-25

CREATE TABLE `BUDGETINVSETUP` (
  `BUDGETINVSETUP_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BUDGETINVSETUP_MAXPERCENTAGE` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  `BUDGETINVSETUP_MINPERCENTAGE` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  `BUDGETINVSETUP_PERIOD` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  `BUDGETINVSETUP_SDATE` DATETIME NOT NULL,
  `BUDGETINVSETUP_EDATE` DATETIME NOT NULL,
  `BUDGETINVSETUP_DESCRIPTION` VARCHAR(100) NOT NULL,
  `BUDGETINVSETUP_DEFAULT` TINYINT NOT NULL DEFAULT 1,
  PRIMARY KEY (`BUDGETINVSETUP_ID`)
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;


CREATE TABLE `BUDGETINV` (
  `BUDGETINV_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BUDGETINVSETUP_ID` BIGINT UNSIGNED NOT NULL,
  `BUDGETINV_Reference` BIGINT UNSIGNED NOT NULL ,
  `BUDGETINV_DATE` DATETIME NOT NULL,
  `PROJECT_CODE` VARCHAR(15) ,
  `COSTCENT_CODE` VARCHAR(15) ,
  `CURRENCY_CODE` VARCHAR(6),
  `BUDGETINV_DESCRIPTION` VARCHAR(45),
  `BUDGETINV_REMARK` VARCHAR(45),
  `BUDGETINV_SYSDATE` TIMESTAMP DEFAULT NOW(),
  PRIMARY KEY (`BUDGETINV_ID`),
  CONSTRAINT `FK_BUDGETINV_BUDGETINVSETUP` FOREIGN KEY `FK_BUDGETINVDT_BUDGETINVSETUP` (`BUDGETINVSETUP_ID`)
    REFERENCES `BUDGETINVSETUP` (`BUDGETINVSETUP_ID`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;


ALTER TABLE `budgetinv` ADD CONSTRAINT `FK_budgetinv_PROJECT` FOREIGN KEY `FK_budgetinv_PROJECT` (`PROJECT_CODE`)
    REFERENCES `project` (`Project_Code`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

ALTER TABLE `budgetinv` ADD CONSTRAINT `FK_budgetinv_COSTCENT` FOREIGN KEY `FK_budgetinv_COSTCENT` (`COSTCENT_CODE`)
    REFERENCES `COSTCENT` (`COSTCENT_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

ALTER TABLE `budgetinv` ADD CONSTRAINT `FK_budgetinv_CURRENCY` FOREIGN KEY `FK_budgetinv_CURRENCY` (`CURRENCY_CODE`)
    REFERENCES `CURRENCY` (`CURRENCY_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


CREATE TABLE `BUDGETINVDT` (
  `BUDGETINVDT_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BUDGETINV_ID` BIGINT UNSIGNED NOT NULL,
  `ITEM_CODE` VARCHAR(20) NOT NULL,
  `BUDGETINVDT_QUANTITY` DOUBLE NOT NULL DEFAULT 0,
  `BUDGETINVDT_AMOUNT` DOUBLE NOT NULL DEFAULT 0,
  `BUDGETINVDT_AMOUNTBASE1` DOUBLE NOT NULL DEFAULT 0,
  `BUDGETINVDT_AMOUNTBASE2` DOUBLE NOT NULL DEFAULT 0,
  `BUDGETINVDT_REMARK` VARCHAR(100),
  `JOURNAL_TYPE` VARCHAR(2) NOT NULL,
  `BUDGETINVDT_DEACTIVATE` TINYINT NOT NULL DEFAULT 0,
  `BUDGETINVDT_DEACTIVATEDATE` DATETIME ,
  `BUDGETINVDT_SYSDATE` TIMESTAMP DEFAULT NOW(),
  PRIMARY KEY (`BUDGETINVDT_ID`),
  CONSTRAINT `FK_BUDGETINVDT_BUDGETDTINV` FOREIGN KEY `FK_BUDGETINVDT_BUDGETDTINV` (`BUDGETINV_ID`)
    REFERENCES `BUDGETINV` (`BUDGETINV_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;



#nabil 2010-06-28
ALTER TABLE `sequence` MODIFY COLUMN `transport_typeref` DOUBLE DEFAULT 0,
 ADD COLUMN `BUDGETINV_REFERENCE` BIGINT UNSIGNED DEFAULT 0 AFTER `transport_typeref`;


ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FA_ClientPaymentTerms` TINYINT(1) UNSIGNED  default 0 ;
ALTER TABLE `module` ADD COLUMN `module_paymentterms` TINYINT(1) UNSIGNED NOT NULL  default 0;
ALTER TABLE `module` ADD COLUMN `module_budgetinv` TINYINT(1) UNSIGNED NOT NULL default 0 ;
ALTER TABLE `accesslabelsrocky`.`messages_label` ADD COLUMN `Error68` VARCHAR(50) AFTER `Display68`;



#maroun 2010-06-29
ALTER TABLE `rma` ADD COLUMN `Rmacharge_amount` DOUBLE  default 0;
ALTER TABLE `rma` ADD COLUMN `Rmacharge_amountbase1` DOUBLE default 0;
ALTER TABLE `rma` ADD COLUMN `Rmacharge_amountbase2` DOUBLE default 0;
ALTER TABLE `rma` ADD COLUMN `Currency_code` VARCHAR(6) ;





ALTER TABLE `purchasesserialno` ADD COLUMN `SerialNo_Quantity` DOUBLE NOT NULL DEFAULT 1 ;
ALTER TABLE  `purchasesserialno` ADD COLUMN `SerialNo_QuantitySold` DOUBLE NOT NULL DEFAULT 0 ;

ALTER TABLE `porderserialno` ADD COLUMN `SerialNo_Quantity` DOUBLE NOT NULL DEFAULT 1 ;
ALTER TABLE  `porderserialno` ADD COLUMN `SerialNo_QuantityUsed` DOUBLE NOT NULL DEFAULT 0 ;


ALTER TABLE `itemsdt` ADD COLUMN `itemdt_value2` double AFTER `itemdt_value`;
ALTER TABLE  `itemsdt`  ADD COLUMN `itemdt_sign` VARCHAR(1) AFTER `itemdt_value`;



#nabil 2010-07-09
ALTER TABLE `porderdt` ADD COLUMN `Item_QtyPacked` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE  `porderdt`ADD COLUMN `Item_CodePacked` VARCHAR(21) ;

#nabil 2010-07-10
ALTER TABLE CASHFLOWDTTEMPLATE ADD COLUMN previous_balance tinyint(1) NOT NULL default 0;

ALTER TABLE `cashflowdttemplate` MODIFY COLUMN `journal_type` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `budgetinvsetup` ADD COLUMN `PROJECT_CODE` VARCHAR(15) AFTER `BUDGETINVSETUP_DEFAULT`,
 ADD CONSTRAINT `FK_budgetinvsetup_PROJECT` FOREIGN KEY `FK_budgetinvsetup_PROJECT` (`PROJECT_CODE`)
    REFERENCES `project` (`Project_Code`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

ALTER TABLE `budgetinvsetup` ADD COLUMN `COSTCENT_CODE` VARCHAR(15) AFTER `PROJECT_CODE`,
 ADD CONSTRAINT `FK_budgetinvsetup_COSTCENT` FOREIGN KEY `FK_budgetinvsetup_COSTCENT` (`COSTCENT_CODE`)
    REFERENCES `costcent` (`Costcent_code`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


#maroun 2010-07-12

CREATE TABLE `ProductionMaster` (
  `ProductionMaster_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `production_id` DOUBLE,
  `item_code` VARCHAR(20),
  `Warehouse_code` VARCHAR(15),
  `ProductionMaster_quantity` DOUBLE,
  `project_code` VARCHAR(15),
  `costcent_code` VARCHAR(15),
  `ProductionMaster_Amount` DOUBLE,
  `ProductionMaster_Amount1` DOUBLE,
  `ProductionMaster_Amount2` DOUBLE,
  `ProductionMaster_remark` VARCHAR(100),
  `ProductionMaster_idealqty` DOUBLE,
  `Item_UnitCoef` DOUBLE,
  `Item_Unit2Qty` DOUBLE,
  `ProductionMaster_Posted` TINYINT(1) UNSIGNED DEFAULT 0,
  `Synchronized` TINYINT(1) UNSIGNED DEFAULT 0,
  `Currency_code` VARCHAR(6) ,
   `ProductionMaster_date` datetime,
  PRIMARY KEY (`ProductionMaster_id`),
  CONSTRAINT `FK_PRODUCTIONID` FOREIGN KEY `FK_PRODUCTIONID` (`production_id`)
    REFERENCES `production` (`Production_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_ITEMCODE` FOREIGN KEY `FK_ITEMCODE` (`item_code`)
    REFERENCES `items` (`Item_Code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_WAREHOUSECODE` FOREIGN KEY `FK_WAREHOUSECODE` (`Warehouse_code`)
    REFERENCES `warehouse` (`Warehouse_code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_PROJECTCODE` FOREIGN KEY `FK_PROJECTCODE` (`project_code`)
    REFERENCES `project` (`Project_Code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_COSTCENTER` FOREIGN KEY `FK_COSTCENTER` (`costcent_code`)
    REFERENCES `costcent` (`Costcent_code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
) ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `items` ADD COLUMN `item_ratio` DOUBLE default 1;
ALTER TABLE `module` ADD COLUMN `module_productionmm` TINYINT(1) UNSIGNED NOT NULL default 0;
ALTER TABLE `rma` ADD COLUMN `Client_Cell` VARCHAR(45) ;


ALTER TABLE `productionmaster` ADD COLUMN `Productionmaster_DirectStkDbt` VARCHAR(11);
ALTER TABLE `productionmaster` ADD COLUMN `Productionmaster_DirectStkCrd` VARCHAR(11) AFTER `Productionmaster_DirectStkDbt`;
ALTER TABLE `productionmaster` ADD COLUMN `Productionmaster_DirectStkCur` VARCHAR(7) AFTER `Productionmaster_DirectStkCrd`;
ALTER TABLE `productionmaster` ADD COLUMN `Productionmaster_WasteDebit` VARCHAR(10) AFTER `Productionmaster_DirectStkCur`;
ALTER TABLE `productionmaster` ADD COLUMN  `Productionmaster_WasteCredit` VARCHAR(10) AFTER `Productionmaster_WasteDebit`;
ALTER TABLE `productionmaster` ADD COLUMN  `Productionmaster_WasteDiff` VARCHAR(10) AFTER `Productionmaster_WasteCredit`;



ALTER TABLE `productionmaster` ADD COLUMN `Productionmaster_totalideal` DOUBLE ;

ALTER TABLE `productionMaster` ADD COLUMN `productionMaster_ratio` DOUBLE default 1;





ALTER TABLE `rmadt` ADD COLUMN `Rmadt_Warranty` BOOLEAN NOT NULL ;


ALTER TABLE `rma` ADD INDEX `ClientName`(`RMAClient_Name`);
ALTER TABLE `rma` ADD INDEX `Remark`(`Rma_Remark`);
ALTER TABLE `rma` ADD INDEX `Client_Cell`(`Client_Cell`);

ALTER TABLE `rmasetup` ADD COLUMN `Default_Currency` VARCHAR(6) ;


#NABIL 2010-07-19
ALTER TABLE `budgetinvsetup`  ADD COLUMN `BUDGETINVSETUP_LOADBEFOREMONTH` INTEGER UNSIGNED NOT NULL DEFAULT 15 ;



#NABIL 2010-07-21
ALTER TABLE `paymentrqst` ADD COLUMN `PaymentRqst_manualno` VARCHAR(20) ;
#activate laster ALTER TABLE `paymentrqst` MODIFY COLUMN `PaymentRqst_Remark` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci;

#NABIL 2010-08-06
CREATE TABLE `payrequest` (
  `payrequest_number` int(10) NOT NULL,
  `payrequest_date` date DEFAULT NULL,
  `payrequest_from` varchar(100) DEFAULT NULL,
  `payrequest_to` varchar(100) DEFAULT NULL,
  `payrequest_toorde` varchar(100) DEFAULT NULL,
  `payrequest_remark` varchar(100) DEFAULT NULL,
  `payrequest_reference` varchar(100) DEFAULT NULL,
  `payrequest_percentage` int(10) NOT NULL DEFAULT '9',
  `payrequest_stoppay` int(10) NOT NULL DEFAULT '15',
  `payrequest_datefrom` date DEFAULT NULL,
  `payrequest_dateto` date DEFAULT NULL,
  `currency_code` varchar(50) DEFAULT NULL,
  `payment_duepayement` int(11) NOT NULL,
  `ledger_number` varchar(10) NOT NULL,
  PRIMARY KEY (`payrequest_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


alter table paymentrqst add column paymentrqst_include tinyint(1);

#NABIL 2010-08-07
ALTER TABLE COSTCENT ADD COLUMN (ITEM_CODE VARCHAR(20));

#NABIL 2010-08-16
ALTER TABLE `budgetinvdt` ADD COLUMN `BUDGETINVSTATUS_ID` BIGINT UNSIGNED  NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt` ADD COLUMN `BUDGETINVDT_ACTIVATEDATE` DATETIME  ;




CREATE TABLE `BUDGETINVSTATUS` (
  `BUDGETINVSTATUS_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BUDGETINVSTATUS_CODE` VARCHAR(5) NOT NULL,
  `BUDGETINVSTATUS_DESCRIPTION` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`BUDGETINVSTATUS_ID`)
)
ENGINE = InnoDB 
CHARACTER SET utf8 COLLATE utf8_general_ci;



ALTER TABLE `budgetinvdt` ADD CONSTRAINT `FK_budgetinvdt_STATUS` FOREIGN KEY `FK_budgetinvdt_STATUS` (`BUDGETINVSTATUS_ID`)
    REFERENCES `budgetinvstatus` (`BUDGETINVSTATUS_ID`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE `budgetinv` MODIFY COLUMN `BUDGETINV_Reference` BIGINT(20) UNSIGNED;


CREATE TABLE `BudgetInvAmendment` (
  `BudgetInvAmendment_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `item_code` VARCHAR(20) NOT NULL,
  `BudgetInvStatus_id` BIGINT UNSIGNED NOT NULL DEFAULT 0,
  `BudgetInvAmendment_quantity` DOUBLE NOT NULL DEFAULT 0,
  `CURRENCY_CODE` VARCHAR(6), 
  `BudgetInvAmendment_amount` DOUBLE NOT NULL DEFAULT 0,
  `BudgetInvAmendment_amountBase1` DOUBLE NOT NULL DEFAULT 0,
  `BudgetInvAmendment_AmountBase2` DOUBLE NOT NULL DEFAULT 0,
  `BudgetInvAmendment_sysdate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `BudgetInvdt_id` DOUBLE,
  `BudgetInvdt_id2` DOUBLE,
  `BudgetInvAmendment_remark` varchar(100),
  `BudgetInvAmendment_activatedate` DATETIME NOT NULL,
  `budgetinvamendment_deactivatedate` DATETIME NOT NULL,
  `BudgetInv_id` BIGINT UNSIGNED NOT NULL ,
  `JOURNAL_TYPE` VARCHAR(2)  NOT NULL ,
  PRIMARY KEY (`BudgetInvAmendment_id`),
  CONSTRAINT `FK_budgetinvamendment_budgetinvid` FOREIGN KEY `FK_budgetinvamendment_budgetinvid` (`BudgetInv_id`)
    REFERENCES `budgetinv` (`BUDGETINV_ID`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;


ALTER TABLE `budgetinv` ADD COLUMN `JOURNAL_TYPE` VARCHAR(2) NOT NULL;

ALTER TABLE  `budgetinv` ADD UNIQUE INDEX `Index_SETUPIDJOURTYPE` USING BTREE(`BUDGETINVSETUP_ID`, `JOURNAL_TYPE`);


ALTER TABLE `budgetinvdt` ADD COLUMN `BUDGETINVAMENDMENT_ID` BIGINT(20) UNSIGNED ;

ALTER TABLE `budgetinvdt`  ADD COLUMN `self_id` BIGINT ;

ALTER TABLE `budgetinvstatus` ADD COLUMN `BUDGETINVSTATUS_DEACTIVATE` TINYINT(1) UNSIGNED NOT NULL ;

ALTER TABLE `budgetinvsetup`  ADD COLUMN `BUDGETINVSETUP_LOCKAfterMONTH` INTEGER UNSIGNED NOT NULL DEFAULT 15 ;
ALTER TABLE `budgetinvsetup` CHANGE COLUMN `BUDGETINVSETUP_LOADBEFORMONTH` `BUDGETINVSETUP_LOADBEFOREMONTH` INTEGER UNSIGNED NOT NULL DEFAULT 15;
ALTER TABLE `budgetinvamendment` ADD COLUMN `BudgetInvAmendment_deactivate` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt` MODIFY COLUMN `BUDGETINVDT_DEACTIVATE` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;

#NABIL 2010-08-26
ALTER TABLE `budgetinvdt`  ADD COLUMN `BudgetInvdt_prvquantity` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BudgetInvdt_prvamount` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BUDGETINVDT_PRVAMOUNTBASE1` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BUDGETINVDT_PRVAMOUNTBASE2` DOUBLE NOT NULL DEFAULT 0 ;


#elie 2010-08-30
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FA_Transformation` TINYINT(1) ,
 ADD COLUMN `FA_TransformationAPP` BOOLEAN ,
 ADD COLUMN `FA_TransformationMod` BOOLEAN ,
 ADD COLUMN `FA_TransformationDel` BOOLEAN ,
 ADD COLUMN `FA_ProdRatio` BOOLEAN ,
 ADD COLUMN `FA_ProdRatioAPP` BOOLEAN ,
 ADD COLUMN `FA_ProdRatioMod` BOOLEAN ,
 ADD COLUMN `FA_ProdRatioDEL` BOOLEAN ,
 ADD COLUMN `Login_negativeQty` BOOLEAN default 0;


ALTER TABLE `module` ADD COLUMN `module_productiontransf` BOOLEAN NOT NULL;
ALTER TABLE `module` ADD COLUMN `module_productionRatio` BOOLEAN NOT NULL ;
ALTER TABLE `module` ADD COLUMN `module_directstockITrans` BOOLEAN NOT NULL ;

ALTER TABLE `accesslabelsrocky`.`loginstk` ADD COLUMN `towarehouse_code` VARCHAR(20) ;

ALTER TABLE `sorder` ADD COLUMN `Sorder_disapproved` BOOLEAN DEFAULT 0 ;

#NABIL 2010-08-30
ALTER TABLE `budgetinvdt` ADD COLUMN `BUDGETINVDT_LASTTRANSDATE` DATETIME ;


#johnny 2010-08-31
alter table accesslabelsrocky.login add column FI_BudgetInvDel tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvMod tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvApp tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_FBudgetInv tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvSetupDel tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvSetupMod tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvSetupApp tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_FBudgetInvSetup tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvAmendmentDel tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvAmendmentMod tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_BudgetInvAmendmentApp tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FI_FBudgetInvAmendment tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column EDataCom tinyint(1) not null default 0;
alter table accesslabelsrocky.login add column FA_transactionpaymnetrqst tinyint(1) default  0;
alter table accesslabelsrocky.login add column FA_transactionpaymnetrqstdel tinyint(1) default 0;
alter table accesslabelsrocky.login add column FA_transactionpaymnetrqstapp  tinyint(1) default 0;
alter table accesslabelsrocky.login add column FA_transactionpaymnetrqstmod tinyint(1)  default 0;
alter table accesslabelsrocky.login add column FI_stockeval tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_stockevalapp tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_stockevaldel tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_stockevalmod tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_CEPtable tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_CEPtableapp tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_CEPtabledel tinyint(1) default 0 ;
alter table accesslabelsrocky.login add column FI_CEPtablemod tinyint(1) default 0 ;
alter table accesslabelsrocky.loginstk add column default_warehouse tinyint(1) default 0 ;


#nabil 2010-09-01
alter table costcent add column costcent_name2 varchar(50);

#nabil 2010-09-07
ALTER TABLE `module` ADD COLUMN `Module_deliverydtautoincrement` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;


#nabil 2010-09-14
ALTER TABLE `porderdt` ADD INDEX `Index_relateddt`(`RelatedDt_ID`);

#maroun 2010-09-17
ALTER TABLE `rma`  ADD COLUMN `Rma_Remark2` VARCHAR(120);

ALTER TABLE `rmadt` MODIFY COLUMN `Rmadt_Warranty` TINYINT(1);

ALTER TABLE `rma` ADD INDEX `rma_reference` USING BTREE(`RMA_Reference`);

#nabil 2010-09-27
CREATE TABLE `BankType` (
  `BankType_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Banktype_code` VARCHAR(20) NOT NULL,
   `Banktype_Description` VARCHAR(100),
  PRIMARY KEY (`BankType_id`)
)
ENGINE = InnoDB;
ALTER TABLE `banktype` ADD INDEX `Index_banktypecode`(`Banktype_code`);

ALTER TABLE `bankledger` ADD COLUMN `BankType_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 ;

ALTER TABLE `module` ADD COLUMN `module_school` TINYINT(1) UNSIGNED DEFAULT 0 ;


CREATE TABLE `BankLedgerType` (
  `BankLedgerType_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BankLedgerType_code` VARCHAR(20) NOT NULL,
   `BankLedgerType_Description` VARCHAR(100),
  PRIMARY KEY (`BankLedgerType_id`)
)
ENGINE = InnoDB;

#JOHNNY 2010-10-08
ALTER TABLE accesslabelsrocky.login ADD COLUMN U_costcentertransfer TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE accesslabelsrocky.login ADD COLUMN U_projecttransfer TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;

#fady 2010-10-14
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Unmodify_SorderPrice` TINYINT(1) DEFAULT 0 ;




#marounn 2010-10-15
CREATE TABLE `BankType` (
  `BankType_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Banktype_code` VARCHAR(20) NOT NULL,
   `Banktype_Description` VARCHAR(100),
  PRIMARY KEY (`BankType_id`)
)
ENGINE = InnoDB;
ALTER TABLE `banktype` ADD INDEX `Index_banktypecode`(`Banktype_code`);

ALTER TABLE `bankledger` ADD COLUMN `BankType_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 ;



CREATE TABLE `BankLedgerType` (
  `BankLedgerType_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BankLedgerType_code` VARCHAR(20) NOT NULL,
   `BankLedgerType_Description` VARCHAR(100),
  PRIMARY KEY (`BankLedgerType_id`)
)
ENGINE = InnoDB;

ALTER TABLE `bankledger` ADD COLUMN `BankLedgerType_id` BIGINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `bankledgertype` ADD COLUMN `Bankledgertype_order` INTEGER UNSIGNED;

ALTER TABLE `bankledger` ADD COLUMN `bankledger_outstandingcheck` tinyint UNSIGNED NOT NULL DEFAULT 0 ;


ALTER TABLE `banktype` ADD INDEX `Index_banktypecode`(`Banktype_code`);

ALTER TABLE `bankledger` ADD COLUMN `BankType_id` BIGINT UNSIGNED NOT NULL DEFAULT 0 ;



#nabil 2010-10-25
ALTER TABLE `salesdt` MODIFY COLUMN `Salesdt_Remark` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;


#maroun 2010-10-29

#DROP TABLE IF EXISTS `dlvrls`;
CREATE TABLE  `dlvrls` (
  `dlvrls_id` double NOT NULL,
  
              `dlvrls_reference` double DEFAULT NULL,
  
               `dlvrls_date` datetime DEFAULT NULL,
  
               `client_code` varchar(10) DEFAULT NULL,
  
               `delvrls_remark` varchar(100) DEFAULT NULL,
  
               `project_code` varchar(15) DEFAULT NULL,
 
               	costcent_code varchar(15) DEFAULT NULL,
  
		PRIMARY KEY (`dlvrls_id`),
  
		KEY `FK_dlvrls_clientcode` (`client_code`),
  
		CONSTRAINT `FK_dlvrls_clientcode` 
		FOREIGN KEY (`client_code`) 
		REFERENCES `clients` (`Ledger_number`)
) 
		ENGINE=InnoDB DEFAULT CHARSET=utf8;

#DROP TABLE IF EXISTS `dlvrlsdt`;
CREATE TABLE  `dlvrlsdt` (
  `dlvrlsdt_id` double NOT NULL AUTO_INCREMENT,
 
 `dlvrls_id` double DEFAULT NULL,

  `Project_code` varchar(15) DEFAULT NULL,

  `CostCent_Code` varchar(15) DEFAULT NULL,

  `item_code` varchar(20) DEFAULT NULL,

  `warehouse_code` varchar(15) DEFAULT NULL,

  `dlvrlsdt_quantity` double DEFAULT NULL,

  `dlvrlsdt_Remark` varchar(50) DEFAULT NULL,

  `sorderdt_id` double DEFAULT NULL,
  
  PRIMARY KEY (`dlvrlsdt_id`),
  
  KEY `FK_dlvrlsdt_itemcode` (`item_code`),
  
  KEY `FK_dlvrlsdt_warehousecode` (`warehouse_code`),
  
  KEY `FK_dlvrlsdt_dlvrlsdtid` (`dlvrls_id`),
  
  KEY `FK_dlvrlsdt_sorderdtid` (`sorderdt_id`),
  
  CONSTRAINT `FK_dlvrlsdt_sorderdtid` 
  FOREIGN KEY (`sorderdt_id`) REFERENCES `sorderdt` (`SorderDt_id`),
  
  CONSTRAINT `FK_dlvrlsdt_dlvrlsdtid` FOREIGN KEY (`dlvrls_id`) REFERENCES `dlvrls` (`dlvrls_id`),
  
  CONSTRAINT `FK_dlvrlsdt_itemcode` FOREIGN KEY (`item_code`) REFERENCES `items` (`Item_Code`),
  
  CONSTRAINT `FK_dlvrlsdt_warehousecode` FOREIGN KEY (`warehouse_code`) REFERENCES `warehouse` (`Warehouse_code`)
) 
  ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `sequence` ADD COLUMN `dlvrls_id` DOUBLE ,
 ADD COLUMN `dlvrlsdt_id` DOUBLE ;


alter table accesslabelsrocky.login add column FI_deliveryrelease tinyint(1) default 0;


ALTER TABLE `sequence` ADD COLUMN `dlvrls_reference` DOUBLE ;
ALTER TABLE `sorderdt` ADD COLUMN `deliveryrelease` TINYINT UNSIGNED DEFAULT 0 ;


#nabil 2010-10-30
ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_priceTTC` DOUBLE DEFAULT 0 ;
ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_priceTTCBase1` DOUBLE DEFAULT 0 ;
ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_priceTTCBase2` DOUBLE DEFAULT 0 ;

ALTER TABLE `salesdt` ADD COLUMN `saledt_priceTTCBase1` DOUBLE DEFAULT 0 ;
ALTER TABLE  `salesdt` ADD COLUMN `saledt_priceTTCBase2` DOUBLE DEFAULT 0 ;

ALTER TABLE `module` ADD COLUMN `module_DeliveryRelease` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;


ALTER TABLE `stktransaction`
ADD COLUMN `PriceTTC` DOUBLE DEFAULT 0 ,
ADD COLUMN `PriceTTCBase1` DOUBLE DEFAULT 0 ,
ADD COLUMN `PriceTTCBase2` DOUBLE DEFAULT 0 ;


# maroun 20101028
ALTER TABLE `ledger` ADD COLUMN `Currency_code` VARCHAR(6) NULL ;

#elie 2010-11-01
CREATE TABLE  `accesslabelsrocky`.`ledgerrepstk` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_account` varchar(10) DEFAULT NULL,
  `ledger_number` varchar(10) DEFAULT NULL,
  `ledger_include` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


alter table `accesslabelsrocky`.login add column login_disapprovesorder tinyint(1) default 0;


#nabil 2010-10-03
ALTER TABLE `costcent` ADD COLUMN `costcent_Debit` VARCHAR(10) AFTER `T`,
 ADD COLUMN `costcent_credit` VARCHAR(10) AFTER `costcent_Debit`;

#joh 2010-11-05
alter table `accesslabelsrocky`.login add column FI_DeliveryRelease tinyint(1) default 0;
alter table `accesslabelsrocky`.login add column FI_DeliveryReleaseMod tinyint(1) default 0;
alter table `accesslabelsrocky`.login add column FI_DeliveryReleaseDel tinyint(1) default 0;
alter table `accesslabelsrocky`.login add column FI_DeliveryReleaseApp tinyint(1) default 0;

alter table accesslabelsrocky.users add column user_groupacc tinyint(1) default 0;
ALTER TABLE accesslabelsrocky.users DROP COLUMN UserGroup_name;


#nabil 2010-11-08
ALTER TABLE `budgetinvdt` ADD COLUMN `BUDGETINVDT_QTYEXIST` DOUBLE DEFAULT 0 ;



alter table setup add column grid_color1 varchar(45) default '#F7F7F7';
alter table setup add column grid_color2 varchar(45) default '#E6E6E6';

#nabil 2010-11-12 //sonit
ALTER TABLE `module` ADD COLUMN `Module_SerialNoQuantity` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;

#NABIL 2010-11-15
ALTER TABLE `budgetinvdt`  ADD COLUMN `BudgetInvdt_prv2quantity` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BudgetInvdt_prv2amount` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BUDGETINVDT_PRV2AMOUNTBASE1` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BUDGETINVDT_PRV2AMOUNTBASE2` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BudgetInvdt_prv3quantity` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BudgetInvdt_prv3amount` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BUDGETINVDT_PRV3AMOUNTBASE1` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `budgetinvdt`  ADD COLUMN `BUDGETINVDT_PRV3AMOUNTBASE2` DOUBLE NOT NULL DEFAULT 0 ;

#nabil 2010-11-17
ALTER TABLE `cashregister` ADD COLUMN `RetailSerialNo` TINYINT(1) UNSIGNED ;


#ALTER TABLE `retaildt` ADD COLUMN `sale_taxableTTC` DOUBLE DEFAULT 0 AFTER `serialNo_Code`,
# ADD COLUMN `sale_discountamountTTc` DOUBLE DEFAULT 0 AFTER `sale_taxableTTC`;



#Elie Njeim 2010-11-21 

ALTER TABLE `sordersetup` ADD COLUMN `Sorder_Confirmed` BOOLEAN DEFAULT 0 ;
ALTER TABLE `sordersetup` ADD COLUMN `Sorder_ReservedQty` BOOLEAN DEFAULT 0 ;
ALTER TABLE `sordersetup` ADD COLUMN `Sorder_packPrice` BOOLEAN DEFAULT 0 ;
ALTER TABLE `Salessetup` ADD COLUMN `Delivery_packPrice` BOOLEAN DEFAULT 0 ;
ALTER TABLE `Salessetup` ADD COLUMN `show_QtySorder` BOOLEAN DEFAULT 0 ;
ALTER TABLE `items` ADD COLUMN `item_promotion` BOOLEAN  DEFAULT 0 ;
ALTER TABLE `items` ADD COLUMN `item_withserialno` BOOLEAN DEFAULT 0 ;
ALTER TABLE `items` ADD COLUMN `item_specialproduction` BOOLEAN  DEFAULT 0;
ALTER TABLE `purchases` ADD COLUMN `Ledger_Number` VARCHAR(10) ;
ALTER TABLE `deliverydt`  ADD COLUMN `Deliverydt_QtySorder` DOUBLE  DEFAULT 0 ;






#maroun 2010-11-17
ALTER TABLE `budget` ADD COLUMN `Prv3Month1_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month2_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month3_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month4_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month5_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month6_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month7_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month8_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month9_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month10_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month11_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month12_base1` DOUBLE;


ALTER TABLE `budget` ADD COLUMN `Prv3Month1_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month2_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month3_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month4_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month5_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month6_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month7_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month8_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month9_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month10_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month11_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv3Month12_base2` DOUBLE;



ALTER TABLE `budget` ADD COLUMN `Prv2Month1_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month2_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month3_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month4_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month5_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month6_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month7_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month8_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month9_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month10_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month11_base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month12_base1` DOUBLE;



ALTER TABLE `budget` ADD COLUMN `Prv2Month1_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month2_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month3_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month4_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month5_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month6_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month7_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month8_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month9_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month10_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month11_base2` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `Prv2Month12_base2` DOUBLE;


ALTER TABLE `budget` ADD COLUMN `BudgetInvStatus_ID` BIGINT UNSIGNED ,
 ADD CONSTRAINT `FK_budget_Status` FOREIGN KEY `FK_budget_Status` (`BudgetInvStatus_ID`)
    REFERENCES `budgetinvstatus` (`BUDGETINVSTATUS_ID`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE `budget` ADD COLUMN `Budget_Sdate` DATE ,
 ADD COLUMN `Budget_Edate` DATE AFTER `Budget_Sdate`;


ALTER TABLE `budget`
ADD COLUMN `NMonth1_base1` DOUBLE ,
ADD COLUMN `NMonth2_base1` DOUBLE ,
ADD COLUMN `NMonth3_base1` DOUBLE ,
ADD COLUMN `NMonth4_base1` DOUBLE ,
ADD COLUMN `NMonth5_base1` DOUBLE ,
ADD COLUMN `NMonth6_base1` DOUBLE ,
ADD COLUMN `NMonth7_base1` DOUBLE ,
ADD COLUMN `NMonth8_base1` DOUBLE ,
ADD COLUMN `NMonth9_base1` DOUBLE ,
ADD COLUMN `NMonth10_base1` DOUBLE ,
ADD COLUMN `NMonth11_base1` DOUBLE ,
ADD COLUMN `NMonth12_base1` DOUBLE ,


ADD COLUMN `NMonth1_base2` DOUBLE ,
ADD COLUMN `NMonth2_base2` DOUBLE ,
ADD COLUMN `NMonth3_base2` DOUBLE ,
ADD COLUMN `NMonth4_base2` DOUBLE ,
ADD COLUMN `NMonth5_base2` DOUBLE ,
ADD COLUMN `NMonth6_base2` DOUBLE ,
ADD COLUMN `NMonth7_base2` DOUBLE ,
ADD COLUMN `NMonth8_base2` DOUBLE ,
ADD COLUMN `NMonth9_base2` DOUBLE ,
ADD COLUMN `NMonth10_base2` DOUBLE ,
ADD COLUMN `NMonth11_base2` DOUBLE ,
ADD COLUMN `NMonth12_base2` DOUBLE

;


ALTER TABLE `budget` ADD COLUMN `budget_id` BIGINT UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT AFTER `NMonth12_base2`,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY (`budget_id`);

ALTER TABLE `budget` MODIFY COLUMN `Project_Code` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `CostCenter_Code` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `budget` MODIFY COLUMN `Budget_DBCD` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci;

#nabil 2010-11-29
ALTER TABLE `deliverydt` MODIFY COLUMN `Deliverydt_remark` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;



#maroun 01-12-2010
ALTER TABLE `suppliers` ADD COLUMN `Supplier_CreationDate` DATETIME DEFAULT NULL;
ALTER TABLE `suppliers` ADD COLUMN `Supplier_MotherCompany` VARCHAR(10);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_Export` Integer(11)  DEFAULT 0 ;
ALTER TABLE `suppliers` ADD COLUMN `Supplier_BType2` VARCHAR(50) ;
ALTER TABLE `suppliers` ADD COLUMN `Supplier_BType3` VARCHAR(50) ;

ALTER TABLE `suppliers` ADD COLUMN `Supplier_SubContractor` TINYINT(1) UNSIGNED DEFAULT 0;
ALTER TABLE `suppliers` ADD COLUMN `Supplier_TaxPercantage` DOUBLE ;

#Johnny 01-12-2010
alter table clients add column client_local tinyint(1) default 0;
alter table clients add column client_export tinyint(1) default 0;


#nabil 2010-12-07
ALTER TABLE `retaildt` ADD CONSTRAINT `FK_retaildt_saleid` FOREIGN KEY `FK_retaildt_saleid` (`Sale_id`)
    REFERENCES `retail` (`Sale_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

ALTER TABLE `coupon` MODIFY COLUMN `Coupon_Amount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Coupon_AmountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Coupon_AmountBase2` DOUBLE DEFAULT 0;


#tarek 2010-12-14

ALTER TABLE `purchasesdt` ADD COLUMN `PurchaseDt_PriceTTCBase1` DOUBLE DEFAULT 0 ,
 ADD COLUMN `PurchaseDt_PriceTTCBase2` DOUBLE DEFAULT 0 ;


alter table accesslabelsrocky.login add FI_PurchasesVATMod tinyint(1) default 0 after FI_PurchasesVAT;

alter table clients add client_invdlv varchar(10);

#nabil 2010-12-20
CREATE TABLE `clientsngcifin` (
  `clientsngcifin_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `ledger_number` VARCHAR(10),
  `done` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`clientsngcifin_id`)
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;



#maroun 12-01-2011
Alter table accesslabelsrocky.configurationemail
Add column CompanyName VARCHAR(25) after databasename;

#maroun 19-01-2011
ALTER TABLE `salesmen` ADD COLUMN `salesman_CreationDate` DATETIME DEFAULT NULL;
ALTER TABLE `area` ADD COLUMN `Area_CreationDate` DATETIME DEFAULT NULL;


#maroun 25-02-2011
ALTER TABLE accesslabelsrocky.`configurationemail`
ADD COLUMN `ExcellSheet_Group_of_Items` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_Clients` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_NewClient` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_NewItem` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_NewSalesmen` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_NewArea` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_Summary` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_Detail_Bank_Situation` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_Summary_Banks_Situation` INTEGER UNSIGNED ,
ADD COLUMN `ExcellSheet_RRR` INTEGER UNSIGNED;

#DROP TABLE IF EXISTS `commission`;
CREATE TABLE  `commission` (
  `Commission_Number` varchar(10) NOT NULL,
  PRIMARY KEY (`Commission_Number`)
) ENGINE = InnoDB;


#maroun 2011-01-2011
alter table jourtype
add column jourtype_group varchar(30);

#nabil run below only one time
#update jourtype set jourtype_group = SUBSTRING_INDEX(type_desc,' ',1);
#update jourtype set jourtype_group = null where type_desc = 'Sales Voucher(FA)';

#NABIL 2011-02-23
ALTER TABLE `warehouse` ADD COLUMN `Warehouse_transit` TINYINT(1) UNSIGNED DEFAULT 0 ;
#NABIL 2011-02-23 RUN BELOW ONE TIME
#update warehouse set Warehouse_transit=1 where warehouse_name like '%TRANSIT%';



#FADY MOUSSA 12/03/2011
ALTER TABLE `items` 
 ADD COLUMN `item_height` DOUBLE DEFAULT 0 ,
 ADD COLUMN `item_length` DOUBLE DEFAULT 0 ,
 ADD COLUMN `item_width`  DOUBLE DEFAULT 0 ;



ALTER TABLE `porder` 
 ADD COLUMN `Porder_formM` VARCHAR(45) ,
 ADD COLUMN `Porder_bol` VARCHAR(45) ,
 ADD COLUMN `porder _etd` DATETIME ,
 ADD COLUMN `porder_eta` DATETIME ,
 ADD COLUMN `porder_actualdate` DATETIME ,
 ADD COLUMN `Porder_agentname` VARCHAR(45) ,
 ADD COLUMN `porder_modeoftransport` VARCHAR(45) ,
 ADD COLUMN `porder_orginecountry` VARCHAR(45) ,
 ADD COLUMN `porder_nbofcontainer` DOUBLE DEFAULT 0,
 ADD COLUMN `Porder_situation` TEXT;

ALTER TABLE `porder` 
 ADD COLUMN `Porder_portofdischarge` VARCHAR(45) ,
 ADD COLUMN `Porder_portofloading` VARCHAR(45) ,
 ADD COLUMN `Porder_40foot` DOUBLE DEFAULT 0 ,
 ADD COLUMN `Porder_20foot` DOUBLE DEFAULT 0 ;



alter table accesslabelsrocky.loginstk
 add column  default_warehouse_code varchar(20);


ALTER TABLE `transfer` ADD COLUMN `transfer_warehousefrom` VARCHAR(15) ,
 ADD COLUMN `transfer_warehouseto` VARCHAR(15) ;
ALTER TABLE `transferdt` ADD COLUMN `relateddt_id` double UNSIGNED ;

#maroun 16-03-2011
ALTER TABLE `accesslabelsrocky`.`login`  ADD COLUMN `FA_DailyReport` TINYINT(1) UNSIGNED DEFAULT 0 ;

#nabil 2010-03-17
ALTER TABLE `prodplandetail` CHANGE COLUMN `ProdPlanDt_id` `ProdPlan_id` DOUBLE DEFAULT NULL;
ALTER TABLE `prodplandetail` ADD COLUMN `ProdPlan_date` DATE AFTER `Synchronized`;

ALTER TABLE `prodplandetail` ADD CONSTRAINT `FK_prodplandetail_1` FOREIGN KEY `FK_prodplandetail_1` (`ProdPlan_id`)
    REFERENCES `prodplan` (`ProdPlan_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;


ALTER TABLE `prodplandetail` CHANGE COLUMN `ProdPlan_id` `ProdPlanDT_id` DOUBLE DEFAULT NULL
, DROP INDEX `FK_prodplandetail_1`,
 ADD CONSTRAINT `FK_prodplandetail_1` FOREIGN KEY `FK_prodplandetail_1` (`ProdPlanDT_id`)
    REFERENCES `prodplandt` (`ProdPlanDt_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;


ALTER TABLE `prodplandt` ADD CONSTRAINT `FK_prodplandt_1` FOREIGN KEY `FK_prodplandt_1` (`ProdPlan_Id`)
    REFERENCES `prodplan` (`ProdPlan_ID`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

ALTER TABLE `prodplandetail` DROP COLUMN `ProdPlan_date`;



#tarek 2011-03-03

ALTER TABLE accesslabelsrocky.loginstk ADD COLUMN `MasterProject` VARCHAR(20) ;
ALTER TABLE accesslabelsrocky.loginstk  ADD COLUMN `MasterCostCenter` VARCHAR(20);
ALTER TABLE accesslabelsrocky.loginstk  ADD COLUMN `ClientSalesmen` VARCHAR(20) ;

#maroun 29-03-2011
ALTER TABLE `budget` ADD COLUMN `Journal_Type` VARCHAR(2);

#nabil 2011-03-30
alter table clients add column client_financialno varchar(20);

#nabil 2011-04-04
ALTER TABLE `proddt` ADD COLUMN `client_code2` VARCHAR(10) ;
ALTER TABLE `proddt` ADD INDEX `Index_clientcode2`(`client_code2`);


#maroun 07.04.2011
ALTER TABLE `transfer` ADD COLUMN `ToCostcenter_Code` VARCHAR(15);
ALTER TABLE `temp_transfer` ADD COLUMN `ToCostcenter_Code` VARCHAR(15);
ALTER TABLE `transferdt` ADD COLUMN `ToCostcent_Code` VARCHAR(15);
ALTER TABLE `temp_transferdt` ADD COLUMN `ToCostcent_Code` VARCHAR(15);
## Modify function copydata_temptransfer



#nabil 2011-04-07
CREATE TABLE  `proddtparent` (
  `ProddtParent_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `ProddtParent_date` datetime NOT NULL,
  `costcent_code` varchar(30) CHARACTER SET latin1 NOT NULL,
  `warehouse_code` varchar(15) ,
  `item_code` varchar(20) CHARACTER SET latin1 NOT NULL,
  `ProddtParent_quantity` float NOT NULL,
  `SerialNo_code` varchar(20) CHARACTER SET latin1 NOT NULL,
  `ProddtParent_conform` tinyint(1) unsigned  ,
  `ProddtParent_status` tinyint(3) unsigned ,
  `relateddt_id` bigint(20) unsigned  NULL,
  PRIMARY KEY (`ProddtParent_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `proddtparent` ADD COLUMN `ProddtParent_posted` TINYINT(1) UNSIGNED default 0 ;
ALTER TABLE `proddt` ADD COLUMN `ProddtParent_id` BIGINT UNSIGNED ;

#maroun 09.04.2010
ALTER TABLE `budget` MODIFY COLUMN `Project_Code` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;


#nabil 2011-04-13 for solicar production station
#ALTER TABLE `proddtparent` AUTO_INCREMENT = 20000;



#nabil 2011-04-14 for solicar production station (this field is specaily for serial number to define in or out)
alter table adjustmentdt add column journal_type2 varchar(2);


#maroun 14.04.2011
ALTER TABLE `accesslabelsrocky`.`loginaccess3` ADD COLUMN `FPr_ParentRoll` TINYINT(1) DEFAULT 0 ;
#maroun 19.04.2011
ALTER TABLE `proddtparent` MODIFY COLUMN `ProddtParent_conform` TINYINT(1) UNSIGNED;
ALTER TABLE `proddtparent` ADD COLUMN `ProddtParent_Reason` VARCHAR(200) ;



CREATE TABLE  `groupdt` (
  `Groupdt_Code` varchar(15) NOT NULL,
  `Group_Code` varchar(15) DEFAULT NULL,
  `Groupdt_Id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`Groupdt_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `proddtparent` ADD COLUMN `Group_code` VARCHAR(15) ,
ADD COLUMN `SubGroup_code` VARCHAR(15) ;

#maroun 20.04.2011
ALTER TABLE accesslabelsrocky.`loginaccess3` ADD COLUMN `FPr_ParentRollQualityControl` TINYINT(1) DEFAULT 0 ;
ALTER TABLE `proddtparent` MODIFY COLUMN `ProddtParent_status` TINYINT(3) UNSIGNED;
ALTER TABLE `proddtparent` MODIFY COLUMN `warehouse_code` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `proddtparent` add COLUMN `ProdDtItemType_id` bigint(11) ;
ALTER TABLE `proddtparent` MODIFY COLUMN `ProddtParent_conform` TINYINT(1) UNSIGNED ;

ALTER TABLE `proddtparent` DROP COLUMN `ProddtParent_Reason`;



ALTER TABLE `machine` ADD COLUMN `Mach_Trim` DOUBLE DEFAULT 0 ;
ALTER TABLE `machine` ADD COLUMN `Mach_ExtraTrim` DOUBLE DEFAULT 0 ;









#fady 2011-04-29

ALTER TABLE `sequence` ADD COLUMN `productionmaster_id` DOUBLE ;
ALTER TABLE `productiondt` ADD COLUMN `Productionmaster_id` DOUBLE;
ALTER TABLE `production` ADD COLUMN `production_type` VARCHAR(10) ;
ALTER TABLE `production` ADD COLUMN `subgroup_code` VARCHAR(10) ;



CREATE TABLE  `productionmaster` (
  `ProductionMaster_id` double NOT NULL DEFAULT '0',
  `production_id` double DEFAULT NULL,
  `item_code` varchar(20) DEFAULT NULL,
  `Warehouse_code` varchar(15) DEFAULT NULL,
  `ProductionMaster_quantity` double DEFAULT NULL,
  `project_code` varchar(15) DEFAULT NULL,
  `costcent_code` varchar(15) DEFAULT NULL,
  `ProductionMaster_Amount` double DEFAULT NULL,
  `ProductionMaster_Amount1` double DEFAULT NULL,
  `ProductionMaster_Amount2` double DEFAULT NULL,
  `ProductionMaster_remark` varchar(100) DEFAULT NULL,
  `ProductionMaster_idealqty` double DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT NULL,
  `Item_Unit2Qty` double DEFAULT NULL,
  `ProductionMaster_Posted` tinyint(1) unsigned DEFAULT '0',
  `Synchronized` tinyint(1) unsigned DEFAULT '0',
  `Currency_code` varchar(6) DEFAULT NULL,
  `ProductionMaster_date` datetime DEFAULT NULL,
  `Productionmaster_DirectStkDbt` varchar(15) DEFAULT NULL,
  `Productionmaster_DirectStkCrd` varchar(15) DEFAULT NULL,
  `Productionmaster_DirectStkCur` varchar(10) DEFAULT NULL,
  `Productionmaster_WasteDebit` varchar(15) DEFAULT NULL,
  `Productionmaster_WasteCredit` varchar(15) DEFAULT NULL,
  `Productionmaster_WasteDiff` varchar(15) DEFAULT NULL,
  `Productionmaster_totalideal` double DEFAULT NULL,
  `productionMaster_ratio` double DEFAULT NULL,
  PRIMARY KEY (`ProductionMaster_id`),
  KEY `FK_PRODUCTIONID` (`production_id`),
  KEY `FK_ITEMCODE` (`item_code`),
  KEY `FK_WAREHOUSECODE` (`Warehouse_code`),
  KEY `FK_PROJECTCODE` (`project_code`),
  KEY `FK_COSTCENTER` (`costcent_code`),
  CONSTRAINT `FK_COSTCENTER` FOREIGN KEY (`costcent_code`) REFERENCES `costcent` (`Costcent_code`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_ITEMCODE` FOREIGN KEY (`item_code`) REFERENCES `items` (`Item_Code`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_PRODUCTIONID` FOREIGN KEY (`production_id`) REFERENCES `production` (`Production_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_PROJECTCODE` FOREIGN KEY (`project_code`) REFERENCES `project` (`Project_Code`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `FK_WAREHOUSECODE` FOREIGN KEY (`Warehouse_code`) REFERENCES `warehouse` (`Warehouse_code`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;




#maroun 03-05-2011
ALTER TABLE `budget` ADD COLUMN `Budget_Description` VARCHAR(60);

#nabil 2011-05-06
CREATE TABLE  `jourtypebutton` (
  `JourTypeButton_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `JourTypeButton_Name` varchar(45) CHARACTER SET latin1 NOT NULL,
  `JourType_code` varchar(2) CHARACTER SET latin1 NOT NULL,
  `Ledger_numberFrom` varchar(10) CHARACTER SET latin1 NOT NULL,
  `Ledger_NumberTo` varchar(10) CHARACTER SET latin1 NOT NULL,
  `JourTypeButton_DBCD` varchar(1) CHARACTER SET latin1 NOT NULL,
  `JourTypeButton_Order` tinyint(3) unsigned NOT NULL,
  `JourTypeButton_CashType` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`JourTypeButton_id`),
  KEY `Index_jourtypecode` (`JourType_code`) USING BTREE,
  KEY `Index_jourtypeOrder` (`JourTypeButton_Order`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

#ALTER TABLE `jourtypebutton` ADD COLUMN `JourTypeButton_CashType` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `JourTypeButton_Order`;


#johnny 2011-05-06

alter table accesslabelsrocky.login add column RA_TabSheetPaymentRqst tinyint(1) default 0;
alter table accesslabelsrocky.login add column RA_TabSheetBudget tinyint(1) default 0;
alter table accesslabelsrocky.login add column RA_unmovedAcounts tinyint(1) default 0;
alter table accesslabelsrocky.login add column RA_TabSheetMonthlyAmount tinyint(1) default 0;
alter table accesslabelsrocky.login add column RA_InterrestRate tinyint(1) default 0;
alter table  accesslabelsrocky.login add column RI_PurchaseCategory int(1) not null default 0;  # 0-all   1-local   2-export

alter table accesslabelsrocky.login add column RI_TranspPage tinyint(1) default 0;
alter table accesslabelsrocky.login add column RI_TabSheetexport tinyint(1) default 0;
alter table accesslabelsrocky.login add column RI_TabSheetrma tinyint(1) default 0;
alter table accesslabelsrocky.login add column RI_TabSheetBooksBalance tinyint(1) default 0;
alter table accesslabelsrocky.login add column RI_BudgetInvTabSheet tinyint(1) default 0;

#maroun 12-05-2011
#nabil stopped it ALTER TABLE `bankledger` ADD COLUMN `Bank_CrdLimit2` DOUBLE AFTER `bankledger_outstandingcheck`;

#nabil 2011-05-12
ALTER TABLE `sorder` MODIFY COLUMN `Sorder_ClientContact` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `sorder` MODIFY COLUMN `Sorder_DeliveryPlace` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;


#maroun 16-05-2011
ALTER TABLE `bankledger` ADD COLUMN `Bank_InterestRate2` DOUBLE;
ALTER TABLE `bankledger` ADD COLUMN `Bank_CrdLimit2` DOUBLE;

#nabil 2011-05-18
#ALTER TABLE `financialtotlabel` CHANGE COLUMN `FinancialTot_id` `FinancialTot_code2` DOUBLE DEFAULT NULL;

ALTER TABLE `prodplandetail` ADD COLUMN `ProdPlanDetail_Width` DOUBLE AFTER `sorderdt_id`;
ALTER TABLE `prodplandetail` CHANGE COLUMN `ProdPlan_id` `ProdPlanDT_id` DOUBLE DEFAULT NULL;
, DROP INDEX `FK_prodplandetail_1`,
 ADD CONSTRAINT `FK_prodplandetail_1` FOREIGN KEY `FK_prodplandetail_1` (`ProdPlanDT_id`)
    REFERENCES `prodplandt` (`ProdPlanDt_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
ALTER TABLE `prodplandetail` ADD CONSTRAINT `FK_prodplandetail_1` FOREIGN KEY `FK_prodplandetail_1` (`ProdPlandt_id`)
    REFERENCES `prodplandt` (`ProdPlanDt_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE `prodplandetail` CHANGE COLUMN `ProdPlan_id` `ProdPlandt_id` DOUBLE DEFAULT NULL,
 DROP INDEX `FK_prodplandetail_1`,
 ADD INDEX `FK_prodplandetail_1` USING BTREE(`ProdPlandt_id`),
 DROP FOREIGN KEY `FK_prodplandetail_1`;

ALTER TABLE `prodplan` ADD COLUMN `mach_code` VARCHAR(15) NOT NULL AFTER `Synchronized`;
alter table grouping add column grouph_code varchar(50);

ALTER TABLE `prodplandt` ADD COLUMN `ProdPlanDt_speed` DOUBLE NOT NULL ;
ALTER TABLE `prodplandt` ADD COLUMN `ProdPlanDt_confirm` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `prodplandt` ADD COLUMN `ProdPlanDt_ExtraTrim` DOUBLE NOT NULL DEFAULT 0 ;

ALTER TABLE `prodplandt` ADD COLUMN `group_code` VARCHAR(15) NOT NULL ;
ALTER TABLE `prodplandetail` ADD COLUMN `item_code` VARCHAR(20) NOT NULL ;
ALTER TABLE `prodplandt` ADD COLUMN `subgroup_code` VARCHAR(15) NOT NULL ;
ALTER TABLE `prodplandt` ADD COLUMN `ProdPlanDt_GSM` DOUBLE NOT NULL ;
ALTER TABLE `prodplandetail` ADD COLUMN `ProdPlanDetail_MQty` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;

ALTER TABLE `prodplandetail` ADD COLUMN `ProdPlan_partition` CHAR(1) NOT NULL DEFAULT 'A' ;

ALTER TABLE `prodplandetail` ADD COLUMN `sorderdt_id` BIGINT UNSIGNED NOT NULL ;




ALTER TABLE `prodplandt` ADD COLUMN `ProdPlanDetailM_width` DOUBLE AFTER `ProdPlanDt_GSM`,
 ADD COLUMN `ProdPlanDetailM_quantity` DOUBLE AFTER `ProdPlanDetailM_width`;


ALTER TABLE `prod` ADD COLUMN `ProdPlandt_id` BIGINT UNSIGNED ;
ALTER TABLE `prod` ADD COLUMN `ProdPlan_id` BIGINT UNSIGNED NOT NULL;
ALTER TABLE `prod` MODIFY COLUMN `ProdPlan_id` DOUBLE ;
ALTER TABLE `prodplandetail` MODIFY COLUMN `ProdPlanDetail_id` BIGINT UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT;

ALTER TABLE `proddt` ADD CONSTRAINT `FK_prodid` FOREIGN KEY `FK_prodid` (`Prod_id`)
    REFERENCES `prod` (`Prod_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

ALTER TABLE `proddtitem` ADD CONSTRAINT `FK_proddtitemid` FOREIGN KEY `FK_proddtitemid` (`ProdDt_id`)
    REFERENCES `proddt` (`ProdDt_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

#ALTER TABLE `acctypedt` DROP FOREIGN KEY `acctypedtacctype_increment`;
#ALTER TABLE `acctype` MODIFY COLUMN `Acctype_increment` BIGINT UNSIGNED NOT NULL;
#ALTER TABLE `acctypedt` MODIFY COLUMN `Acctype_increment` BIGINT UNSIGNED DEFAULT NULL;



#ALTER TABLE `acctypedt` ADD CONSTRAINT `acctypedtacctype_increment` FOREIGN KEY `acctypedtacctype_increment` (`Acctype_increment`)
#   REFERENCES `acctype` (`Acctype_increment`)
#   ON DELETE RESTRICT
#   ON UPDATE RESTRICT;


#ALTER TABLE `ledger` MODIFY COLUMN `Acctype_increment` BIGINT UNSIGNED DEFAULT NULL;


#nabil 2011-06-20
ALTER TABLE `itemjour` MODIFY COLUMN `CostCent_CodeDebit` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_codeDebit` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `CostCent_CodeCredit` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_CodeCredit` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `CostCent_CodeCash` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_CodeCash` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;





#nabil 2011-06-31
ALTER TABLE `deliveries` MODIFY COLUMN `Delivery_Reference` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalQuantityRet` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalQuantitySld` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalNoOfItem` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_Id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Sale_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Transfer_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Journal_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoCarton` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CartonGrossWt` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CartonNetWeight` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Total` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_VAT` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_VATBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_VATBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Taxable` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TaxableBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TaxableBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoneTaxable` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoneTaxableBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoneTaxableBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Cash` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashInBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashInBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashOutBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashOutBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TipsBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Mode` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Printed` INTEGER DEFAULT 0,
 MODIFY COLUMN `Journalsec_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TaxableTTC` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CouponAmt` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CouponAmt1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CouponAmt2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SendReceive_Reference` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_creditamount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_creditamount1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_creditamount2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_BelongsToGroup` INTEGER DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalTax` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalTaxBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalTaxBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_qtypacked` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_returnRef` DOUBLE DEFAULT 0,
 MODIFY COLUMN `delivery_commissionper` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Sorder_Reference` DOUBLE DEFAULT 0,
 MODIFY COLUMN `delivery_activeVAT` TINYINT(1) DEFAULT 0,
 MODIFY COLUMN `deliveies_activevat` TINYINT(1) DEFAULT 0;


ALTER TABLE `deliverydt` MODIFY COLUMN `Delivery_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_Quantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_QuantityReturn` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_QuantitySld` DOUBLE DEFAULT 0,
 MODIFY COLUMN `RelatedDt_Id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Sale_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SaleDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Transferdt_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Related_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Deliverydt_cost` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Deliverydt_costbase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Deliverydt_costbase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Vat` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SorderDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SorderDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `SorderDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_Price` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_PriceBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_PriceBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_DiscountPer` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_DiscountAmount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_DiscountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_DiscountBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_PriceTTC` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_QtyPacked` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Deliverydt_BelongsToGroup` INTEGER DEFAULT 0,
 MODIFY COLUMN `Item_tax` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Journalsec_id` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_discountTTC` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_taxableTTC` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax3` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax4` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_Tax5` DOUBLE DEFAULT 0,
 MODIFY COLUMN `DeliveryDt_PricePerUnit` DOUBLE DEFAULT 0;


#nabil 2011-07-07
alter table journaldt
modify Journaldt_desc varchar(100);

alter table journaldt
modify Journaldt_desc1 varchar(100);

ALTER TABLE `financialtotlabel` MODIFY COLUMN `FinancialTot_code` BIGINT AUTO_INCREMENT;
Alter table financialtemplate modify column FinancialTot_Code bigint;



ALTER TABLE `deliveries` MODIFY COLUMN `Delivery_TotalQuantity` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalQuantityRet` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalQuantitySld` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalNoOfItem` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CartonGrossWt` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CartonNetWeight` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_DiscountBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Total` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_VAT` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_VATBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_VATBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Taxable` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TaxableBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TaxableBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoneTaxable` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoneTaxableBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_NoneTaxableBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Cash` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashInBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashInBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashOutBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CashOutBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TipsBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Mode` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_Printed` INTEGER DEFAULT 0,
 MODIFY COLUMN `Delivery_TaxableTTC` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CouponAmt` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CouponAmt1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_CouponAmt2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_creditamount` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_creditamount1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_creditamount2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Item_qtypacked` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_BelongsToGroup` INTEGER DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalTax` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalTaxBase1` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_TotalTaxBase2` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Delivery_returnRef` DOUBLE DEFAULT 0,
 MODIFY COLUMN `delivery_commissionper` DOUBLE DEFAULT 0,
 MODIFY COLUMN `Sorder_Reference` DOUBLE DEFAULT 0,
 MODIFY COLUMN `delivery_activevat` TINYINT(1) UNSIGNED DEFAULT 0;


update stktransaction set pricebase1=0 where pricebase1 is null;
update stktransaction set pricebase2=0 where pricebase2 is null;
update stktransaction set costbase2=0 where costbase2 is null;
update stktransaction set costbase1=0 where costbase1 is null;
update stktransaction set priceperunit=0 where priceperunit is null;



alter table module  add column module_ReferenceByCostcenter tinyint(1);

ALTER TABLE sequence MODIFY COLUMN PRODUCTION_SERIALNOREF DOUBLE,
 MODIFY COLUMN Costcenter VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#SELECT COSTCENTER,PURCHASE_REFERENCE,journal_refgovernment,preturn_reference FROM SEQUENCE;



ALTER TABLE `proddtparent` ADD INDEX `Index_itemcode`(`item_code`),
 ADD INDEX `Index_relateddtid`(`relateddt_id`),
 ADD INDEX `Index_groupcode`(`Group_code`),
 ADD INDEX `Index_subgroupcode`(`SubGroup_code`);



ALTER TABLE `proddtparent` ADD COLUMN `proddtparent_overrun` TINYINT(1) UNSIGNED DEFAULT 0 ;


ALTER TABLE `journal` MODIFY COLUMN `Journal_ConfirmedUser` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `proddt` ADD COLUMN `proddt_hide` TINYINT(1) UNSIGNED DEFAULT 0 ;


alter table clients add column client_invdlv           varchar(10);
alter table clients add column client_financialno      varchar(20);
alter table clients add column client_companyname      varchar(60);
alter table clients add column client_address3         varchar(50);
alter table clients add column Client_BusinessType2    varchar(50);
alter table clients add column Client_BusinessType3    varchar(50);
alter table clients add column Client_DeliveryAddress3 varchar(50);
alter table clients add column Client_Tips2            varchar(50);
alter table clients add column Client_Tips3            varchar(50);
alter table clients add column client_Weakness2        varchar(50);
alter table clients add column client_Weakness3        varchar(50);


ALTER TABLE `rma` MODIFY COLUMN `Rma_Remark` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `rma`
MODIFY COLUMN `Rma_Remark2` VARCHAR(300)
CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;



alter table sorder add column sorder_deliverytype varchar(60);


ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SorderPosQty` TINYINT(1) default 0;

alter table sorderdt add column `sorderdt_meancost` double default 0;





CREATE TABLE  `checkscollectedtrans` (
  `AutoInc` int(11) NOT NULL AUTO_INCREMENT,
  `Chk_ValueDate` date NOT NULL,
  `Ledger_number` varchar(10) NOT NULL,
  `Chk_bank` varchar(30) NOT NULL,
  `Chk_amount` double NOT NULL,
  `Currency_code` varchar(6) NOT NULL,
  `Chk_number` varchar(20) NOT NULL,
  `checkscollectiontrans_posted` tinyint(1) DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `Manual_no` varchar(30) DEFAULT NULL,
  `trans_id` double DEFAULT NULL,
  `TransDt_Description` varchar(150) DEFAULT NULL,
  `trans_reference` bigint(20) DEFAULT NULL,
  `checkscollectedtrans_DATE` datetime NOT NULL,
  PRIMARY KEY (`AutoInc`),
  KEY `LedgerBankNumber` (`Ledger_number`,`Chk_bank`,`Chk_number`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;



alter table module add column Module_AcctrxPostGenRV tinyint(1);
ALTER TABLE `checkscollected` ADD COLUMN `trans_id` BIGINT UNSIGNED ;



#tarek 31/11/2011
alter table journaldt add
Detail_Code varchar(50);

alter table transdt add
Detail_Code varchar(50);





ALTER TABLE `receiptsetup` ADD COLUMN `Chk_CommissionAcc` VARCHAR(10) ;
ALTER TABLE `accesslabelsrocky`.`configurationemail` ADD COLUMN `configurationemail_id` BIGINT UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT ,
 ADD PRIMARY KEY (`configurationemail_id`);

ALTER TABLE `accesslabelsrocky`.`configurationemail` ADD COLUMN `ReceivermailBCC` VARCHAR(100) ;
ALTER TABLE `accesslabelsrocky`.`configurationemail` MODIFY COLUMN `hostname` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

alter table module add column module_email tinyint(1);

ALTER TABLE `temp` ADD COLUMN `client_paymentmode` VARCHAR(30) ;
ALTER TABLE `sequence` ADD COLUMN `Check_TypeRef` DOUBLE ;



ALTER TABLE `financialtemplate` ADD COLUMN `Financial_acctrxposted` TINYINT(1) UNSIGNED DEFAULT 0 ;




CREATE TABLE  `accesslabelsrocky`.`configurationemail` (
  `hostname` varchar(45) DEFAULT NULL,
  `MailAgent` varchar(45) DEFAULT NULL,
  `Port` int(10) unsigned DEFAULT NULL,
  `UserName` varchar(45) DEFAULT NULL,
  `Password` varchar(100) DEFAULT NULL,
  `SenderEmail` varchar(100) DEFAULT NULL,
  `Receivermail` varchar(100) DEFAULT NULL,
  `TimerCheck` varchar(45) DEFAULT NULL,
  `WorksheetPath` varchar(100) DEFAULT NULL,
  `SentTime` time DEFAULT NULL,
  `DatabaseName` varchar(45) DEFAULT NULL,
  `CompanyName` varchar(25) DEFAULT NULL,
  `Subject` varchar(200) DEFAULT NULL,
  `Body` blob,
  `ReceiverMailCC` varchar(100) DEFAULT NULL,
  `ExcellSheet_Group_of_Items` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_Clients` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_NewClient` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_NewItem` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_NewSalesmen` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_NewArea` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_Summary` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_Detail_Bank_Situation` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_Summary_Banks_Situation` int(10) unsigned DEFAULT NULL,
  `ExcellSheet_RRR` int(10) unsigned DEFAULT NULL,
  `ReceivermailBCC` varchar(100) DEFAULT NULL,
  `configurationemail_id` bigint(10) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`configurationemail_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;


ALTER TABLE `accesslabelsrocky`.`cashregister` ADD COLUMN `cashregister_id` BIGINT UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT AFTER `RetailSerialNo`,
 ADD PRIMARY KEY (`cashregister_id`);


alter table deliveries add Detail_Code varchar(50);
alter table temp_deliveries add Detail_Code varchar(50);
alter table sorder add Detail_Code varchar(50);
alter table temp_sorder add Detail_Code varchar(50);

#TOOK FROM TAREK 11/11/2011
#Maroun 2011-03-04


ALTER TABLE accesslabelsrocky.`loginstk` ADD COLUMN `MasterProject` VARCHAR(20) ;
ALTER TABLE accesslabelsrocky.`loginstk` ADD COLUMN `MasterCostCenter` VARCHAR(20);
ALTER TABLE accesslabelsrocky.`loginstk` ADD COLUMN `ClientSalesmen` VARCHAR(20) ;


#Gilbert 2011-02-20
ALTER TABLE suppliers MODIFY COLUMN Supplier_ReferedByTitle VARCHAR(15)  DEFAULT NULL;




#Tarek 2011-03-07

ALTER TABLE `packdt` 
  DROP INDEX `Code`
, DROP INDEX `SwitchedKeys`
, DROP INDEX `packdtitem_code`;

ALTER TABLE `packdt` 
 ADD INDEX `IdxPackDt_ItemCode`(`Item_Code`),
 ADD INDEX `IdxPackDt_ItemCodePack`(`Item_CodePackDt`);

ALTER TABLE `packdt` DROP INDEX `packdtwarehouse_code`,
 ADD INDEX `IdxpackDt_WhCode` USING BTREE(`Warehouse_Code`);

ALTER TABLE `items` 
 ADD INDEX `IdxItems_ItemPack`(`Item_Pack`);





#Christelle 2011-03-11
Alter table costcent add column Costcent_CreationDate datetime;
Alter table grouping add column Group_CreationDate datetime;
Alter table warehouse add column Warehouse_CreationDate datetime;

Alter table subgroup add column Subgroup_CreationDate datetime;
Alter table Ledgergrp add column LedgerGrp_CreationDate datetime;
Alter table Category add column Category_CreationDate datetime;
Alter table Currency add column Currency_CreationDate datetime ;
ALTER TABLE `area` ADD UNIQUE INDEX `AreaCode_UK`(`Area_Code`);
ALTER TABLE `grouping` ADD UNIQUE INDEX `GroupCode_UK`(`Group_Code`);
ALTER TABLE `subgroup` ADD UNIQUE INDEX `SubgroupCode_UK`(`SubGroup_Code`);



#maroun 16-03-2011
ALTER TABLE `accesslabelsrocky`.`login`  ADD COLUMN `FA_DailyReport` TINYINT(1) UNSIGNED DEFAULT 0 ;


#Tarek 2011-04-28
alter table jourtype add Type_Cash tinyint(1) default 0;
alter table jourtype add Type_dbcd varchar(1);

update jourtype set type_cash = 1 where type_name in ('PV','RV');
update jourtype set type_dbcd = 'D' where type_name in ('PV','DV');
update jourtype set type_dbcd = 'C' where type_name in ('RV','CV');

create table transsetup like paymentsetup;
alter table transsetup add JournalType varchar(2);

insert into transsetup (VatAccount, AUXAccount, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, JournalType )
select VatAccount, AUXAccount, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, 'PV'
from paymentsetup;

insert into transsetup (VatAccount, AUXAccount, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, JournalType )
select VATAccount, AUXAccount, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, 'RV'
from receiptsetup;

insert into transsetup (VatAccount, AUXAccount, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, JournalType )
select Null, Null, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, 'DV'
from dbtnotesetup;

insert into transsetup (VatAccount, AUXAccount, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, JournalType )
select Null, Null, DebitAccountFrom, DebitAccountTo, CreditAccountFrom, CreditAccountTo, DefaultCur, Voucher_PrintFolio, Voucher_PrintJVRef, Voucher_PrintDateTime, Voucher_AutoCalcAmnt, Voucher_ShowDescription2, SeparateAccounts, Synchronized, DefaultCostcenter, DefaultProject, IsoDescription, 'CV'
from crdnotesetup;


CREATE TABLE  `jourtypebutton` (

  `JourTypeButton_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,

  `JourTypeButton_Name` varchar(45) CHARACTER SET latin1 NOT NULL,

  `JourType_code` varchar(2) CHARACTER SET latin1 NOT NULL,

  `Ledger_numberFrom` varchar(10) CHARACTER SET latin1 NOT NULL,

  `Ledger_NumberTo` varchar(10) CHARACTER SET latin1 NOT NULL,

 `JourTypeButton_DBCD` varchar(1) CHARACTER SET latin1 NOT NULL,

  `JourTypeButton_Order` tinyint(3) unsigned NOT NULL,

  `JourTypeButton_CashType` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,

  PRIMARY KEY (`JourTypeButton_id`),

  KEY `Index_jourtypecode` (`JourType_code`) USING BTREE,

  KEY `Index_jourtypeOrder` (`JourTypeButton_Order`)

) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;




alter table module add Module_TransStandardView tinyint(1) default 0;
#update module set Module_TransStandardView = 1;


alter table  accesslabelsrocky.login add column FI_PurchaseCategory tinyint(1) default 0;  # 0-all   1-local   2-export

alter table purchases add Purchase_Import tinyint(1) default 0;
alter table temp_purchases add Purchase_Import tinyint(1) default 0;

alter table accesslabelsrocky.login add column FI_DeliverySalesPrice tinyint(1) default 1;


alter table financialtotlabel
add ( FinancialTot_RelatedCode double,
      FinancialTot_Level double,
      FinancialTot_LevelCode varchar(10),
      FinancialTot_TreeCode double,
      FinancialTot_Sign Int(11) Default 1,
      FinancialTot_ShowResult Tinyint(1) Default 0
);


#Tarek 2011-05-30
alter table module
add Module_PrintWaybill tinyint(1) default 0;

#update module set Module_PrintWaybill = 0;

#Tarek 2011-06-03
alter table retaildt add
(SaleDt_PriceTTC      double default 0,
 SaleDt_PriceTTCBase1 double default 0,
 SaleDt_PriceTTCBase2 double default 0
);

#update retaildt set SaleDt_PriceTTC = SaleDt_PriceVat;

#update retaildt
#set SaleDt_PriceTTCBase1 = convertcurfunc(retaildt.currency_code,(select BASE1 from setup),Sale_Date,0,0,'','',ifNull(SaleDt_PriceTTC,0));

#update retaildt
#set SaleDt_PriceTTCBase2 = convertcurfunc(retaildt.currency_code,(select BASE2 from setup),Sale_Date,0,0,'','',ifNull(SaleDt_PriceTTC,0));

alter table sequence
add RetailDt_Id double  after Retail_Id;

alter table retaildt add
(SaleDt_DirectStkDbt  varchar(10),
 SaleDt_DirectStkCrd  varchar(10),
 SaleDt_DirectStkCur  varchar(10),
 SaleDt_DiscountAcc   varchar(10),
 SaleDt_ItemAccount   varchar(10),
 SaleDt_PromoAcc      varchar(10)
);

alter table temp_retaildt add
(SaleDt_PriceTTC      double default 0,
 SaleDt_PriceTTCBase1 double default 0,
 SaleDt_PriceTTCBase2 double default 0
);

alter table temp_retaildt add
(SaleDt_DirectStkDbt  varchar(10),
 SaleDt_DirectStkCrd  varchar(10),
 SaleDt_DirectStkCur  varchar(10),
 SaleDt_DiscountAcc   varchar(10),
 SaleDt_ItemAccount   varchar(10),
 SaleDt_PromoAcc      varchar(10)
);


alter table retail
add Sale_DiscountPer double;

alter table temp_retail
add Sale_DiscountPer double;

alter table retaildt add
Item_CodePacked varchar(20) after item_code;

alter table temp_retaildt add
Item_CodePacked varchar(20) after item_code;

# Tarek 2011-06-17
alter table purchasesserialno
add RetailDt_ID double;

alter table temp_purchasesserialno
add RetailDt_ID double;

alter table accesslabelsrocky.login
add FI_SorderRejectUnconfirmed tinyint(1) default 0;


#Tarek 2011-06-28
alter table cashregister add
CashRegister_PCName varchar(100);

alter table retaildt
modify Item_barcode varchar(40);

alter table temp_retaildt
modify Item_barcode varchar(40);


#Tarek 2011-07-07
alter table deliveries add
Delivery_SorderReferences varchar(200);

alter table temp_deliveries add
Delivery_SorderReferences varchar(200);

alter table sales add
(Sale_SorderReferences varchar(200),
 Sale_DeliveryReferences varchar(200)
);

alter table temp_sales add
(Sale_SorderReferences varchar(200),
 Sale_DeliveryReferences varchar(200)
) ;

#Gilbert 2011-07-16
Alter Table items add column items_type varchar(20) default null;


#create table warehouseqty (
#warehouseqty_id  bigint primary key auto_increment,
#item_id bigint,
#warehouse_code varchar(20) default null,
#minqty double  default 0,
#maxqty double  default 0,
#warehouse_percentage double default 0);

# Gilbert 2011-07-23
alter table subgroup add column subgroup_parent bigint default null;
alter table subgroup add column subgroup_sequentialnumber varchar(10) default null;
alter table subgroup add column subgroup_updatedate Date;
alter table subgroup add column subgroup_type varchar(10) default null;
alter table subgroup add column subgroup_policy varchar(10) default null;

#Tarek 2011-07-25
create table ReportsOptions_Templates (
Template_Id  bigint primary key auto_increment,
Template_Name varchar(100),
Report_Name   varchar(100),
Groupby_Level1Value varchar(10),
Groupby_Level2Value varchar(10),
Groupby_Level3Value varchar(50),
Groupby_Level1Name varchar(100),
Groupby_Level2Name varchar(100),
Groupby_Level3Name varchar(200),
JournalType_alltypes tinyint(1) default 0,
JournalType_exclude  tinyint(1) default 0,
JournalType_types varchar(200),
JournalType_db varchar(100),
JournalType_cr varchar(100),
FromLedger_Number varchar(10),
ToLedger_Number varchar(10),
FromClient_Code varchar(10),
ToClient_Code varchar(10),
FromSupplier_Code varchar(10),
ToSupplier_Code varchar(10),
FromSalesman_Code varchar(10),
ToSalesman_Code varchar(10),
FromItem_Code varchar(20),
ToItem_Code varchar(20),
FromWarehouse_Code varchar(15),
ToWarehouse_Code varchar(15),
FromGroup_Code varchar(15),
ToGroup_Code varchar(15),
FromSubgroup_Code varchar(15),
ToSubgroup_Code varchar(15),
FromProject_Code varchar(20),
ToProject_Code varchar(20),
FromMasterProject_Code varchar(20),
ToMasterProject_Code varchar(20),
FromCostcent_Code varchar(20),
ToCostcent_Code varchar(20),
FromMasterCostcent_Code varchar(20),
ToMasterCostcent_Code varchar(20),
FromArea_Code varchar(20),
ToArea_Code varchar(20),
User_Account varchar(45)
);

#Gilbert 2011-07-26
create table attributes (attribute_id bigint primary key auto_increment  ,
                          attribute_parent varchar(30),
                          attribute_child varchar(30),
                          attribute_policy varchar(10),
						  item_id bigint);

#alter table items drop primary key;
#alter table items add column item_id bigint auto_increment not null primary key;						  

#Gilbert 2011-08-05
create table subgrouppolicy (subgrouppolicy_id bigint primary key  auto_increment,
                            subgrouppolicy_name varchar(20),
                             subgrouppolicy_startchar integer,
                            subgrouppolicy_endchar integer);
alter table subgroup modify column subgroup_policy BIGINT DEFAULT NULL;

#Gilbert 2011-08-08
alter table grouping add COLUMN inventory_ledger VARCHAR(10);
alter table grouping add COLUMN Charge_ledger VARCHAR(10);
alter table grouping add COLUMN Revenue_ledger VARCHAR(10);
alter table grouping add COLUMN Promotion_ledger VARCHAR(10);
alter table grouping add COLUMN Discount_Ledger VARCHAR(10);
alter table grouping add COLUMN Vat_ledger VARCHAR(10);



#Tarek 2011-08-08
alter table purchases add
Purchase_Grn Tinyint(1) default 0 after Purchase_Import;

alter table temp_purchases add
Purchase_Grn Tinyint(1) default 0 after Purchase_Import;

alter table module add
Module_Grn tinyint(1) default 0;

alter table accesslabelsrocky.login add
Login_AllowPrice TinyInt(1) default 1;

alter table accesslabelsrocky.login add
( FI_Grn    Tinyint(1) default 0,
  FI_GrnDel Tinyint(1) default 0,
  FI_GrnMod Tinyint(1) default 0,
  FI_GrnApp Tinyint(1) default 0
);


alter table module add
Module_SorderWithOneWh tinyint(1) default 0;

#Gilbert 2011-08-10
alter table transactionsetup add column trans_Purchasepromotionacc varchar(10);
alter table transactionsetup add column trans_Purchasediscountacc varchar(10);

#Gilbert 2011-08-12
alter table items add column item_policy varchar(10);


#Maroun 2011-08-16
ALTER TABLE `trans` ADD INDEX `Index_Journal` (`Journal_id`);
ALTER TABLE `adjustment` ADD INDEX `Index_Journal`(`Journal_id`);
ALTER TABLE `purchases` ADD INDEX `Index_Journal`(`Journal_Id`);
ALTER TABLE `sales` ADD INDEX `Index_Journal`(`Journal_Id`);
ALTER TABLE `deliveries` ADD INDEX `Index_Journal`(`Journal_id`);

#Tarek 2011-08-17
alter table module add
Module_SorderAutoConfirm tinyint(1) default 0;

#Tarek 2011-08-18
alter table items add
Item_Visible tinyint(1) default 1;

#Tarek 2011-08-24
alter table sordertype add
(Sorder_TypePrintPrice tinyint(1),
 Sorder_TypeReference  double
);


#Tarek 2011-08-29
alter table accesslabelsrocky.login add
FC_CashRegisterAskPrint  tinyint(1) default 0;

#Tarek 2011-08-31
alter table accesslabelsrocky.login add
FC_PostingByCashRegister tinyint(1) default 0;

#Tarek 2011-09-02
alter table accesslabelsrocky.login add
(FI_RepRestrictProject    tinyint(1) default 1,
 FI_RepRestrictCostcenter tinyint(1) default 1,
 FI_RepRestrictWarehouse  tinyint(1) default 1
);

#Tarek 2011-09-03
alter table journal modify Journal_ConfirmedUser varchar(30);


#Tarek 2011-09-15
alter table porder add Porder_Import tinyint(1) default 0;
alter table temp_porder add Porder_Import tinyint(1) default 0;


alter table PorderDt add
( PorderDt_PriceTTC       double default 0
, PorderDt_PriceTTCBase1  double default 0
, PorderDt_PriceTTCBase2  double default 0
);

alter table module add
Module_PorderConfirm  tinyint(1) default 1;

alter table Porder add
( Porder_TotalBase1  double default 0,
  Porder_TotalBase2  double default 0
);


alter table purchases add
Purchase_PorderReferences varchar(200);

alter table temp_purchases add
Purchase_PorderReferences varchar(200);



#Tarek 2011-09-22
alter table module add
Module_InvoiceCheckLimit tinyint(1) default 0;

alter table accesslabelsrocky.login add
Login_ModifyAllPending tinyint(1) default 0;

#Tarek 2011-10-03
alter table accesslabelsrocky.login add
FC_CashRegisterCoupon   tinyint(1) default 0 after FC_CashRegisterCheck;

alter table accesslabelsrocky.login add
FC_CashRegisterCustomer tinyint(1) default 0 after FC_CashRegisterCoupon;


#Tarek 2011-10-06
alter table clients add
Client_Detail tinyint(1) default 0;

#Tarek 2011-10-07
alter table Temp_TransDt add
Detail_Code varchar(50);

#Tarek 2011-10-12
alter table clients add
Client_SeqCode varchar(30);

alter table clientsdetail add
Detail_ID varchar(30);

alter table journaldt add
Detail_Code varchar(50);


alter table transdt add
Detail_Code varchar(50);

#Tarek 2011-10-13
alter table module add
Module_ReferenceByCostcenter tinyint(1) default 0;

alter table module add
Module_PostRetailOneToOne tinyint(1) default 0;

#Tarek 2011-10-24
alter table retaildt modify serialNo_Code varchar(40);
alter table temp_retaildt modify serialNo_Code varchar(40);


#Tarek 2011-10-25
alter table sequence add
(Grn_Id double,
 Grn_Reference double,
 GrnDt_Id double
);

alter table purchasesserialno add GrnDt_ID double;
alter table temp_purchasesserialno add GrnDt_ID double;


ALTER TABLE `sequence` ADD COLUMN `Check_TypeRef` DOUBLE ;




#FADY
ALTER TABLE `productiondt` ADD COLUMN `item_special` TINYINT(1) DEFAULT 0;
ALTER TABLE `items` ADD COLUMN `item_specialProduction` TINYINT(1) DEFAULT 0;


#nabil 2011-11-18
ALTER TABLE `checkscollected` ADD COLUMN `chk_date` DATE ;


#nabil  2011-11-23
ALTER TABLE `financialtotlabel` ADD COLUMN `FinancialTot_skiprows` TINYINT UNSIGNED DEFAULT 0 ;
ALTER TABLE `financialtotlabel`  ADD COLUMN `FinancialTot_bold` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `financialtotlabel`  ADD COLUMN `FinancialTot_background` TINYINT(1) UNSIGNED DEFAULT 0 ;


#Tarek 2011-11-25
alter table module add
(Module_RestrictCost   tinyint(1) default 0,
 Module_ShowLayoutProj tinyint(1) default 0,
 Module_ShowLayoutCost tinyint(1) default 0,
 Module_ShowBalance    tinyint(1) default 0
);



#nabil 2011-11-24
ALTER TABLE `accesslabelsrocky`.`login`  ADD COLUMN `RI_Aging` TINYINT(1) UNSIGNED DEFAULT 0 ;

#nabil 2011-11-28
ALTER TABLE `rmadt` ADD COLUMN `rmadt_notes` VARCHAR(45) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_received` VARCHAR(45);
ALTER TABLE `rmadt` ADD COLUMN `rmadt_problem` VARCHAR(45) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_solution` VARCHAR(45) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_price` float ;


ALTER TABLE `clients` ADD COLUMN `client_technicalemail` VARCHAR(100);
ALTER TABLE `clients` ADD COLUMN `client_technicalRepresentative` VARCHAR(60) ;


#Tarek 2011-11-29
alter table suppliers add
Supplier_Import tinyint(1) default 0;

#Tarek 2011-11-30
alter table deliverydt add Related_Ref double;
alter table temp_deliverydt add Related_Ref double;

#nabil 2011-11-30
ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_email` VARCHAR(100) ;

#nabil 2011-12-05
ALTER TABLE `prequestdt` MODIFY COLUMN `Project_code` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;


#Tarek 2011-12-08
alter table cashregister add
CashRegister_ItemsWithoutSerial tinyint(1) default 0;

#Nabil 2011-12-09
ALTER TABLE `purchasesserialno` ADD COLUMN `SerialNo_olddata` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `proddtitem` ADD COLUMN `serialno_code` VARCHAR(20) ;

#Shukri 2011-12-09
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `fastprintarchive` TINYINT(1) DEFAULT 1;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `fastprinttransaction` TINYINT(1) DEFAULT 1;


#Tarek 2011-12-09
alter table salessetup add
( BonusAccount varchar(10),
  ExportBonusToJV tinyint(1) default 0
);

alter table sales add
(Sale_TransportAccount  varchar(10),
 Sale_TransportAmount   double default 0,
 Sale_TransportBase1    double default 0,
 Sale_TransportBase2    double default 0,
 Sale_TransportTTC      double default 0,
 Sale_BonusAccount      varchar(10),
 Sale_BonusAmount       double default 0,
 Sale_BonusBase1        double default 0,
 Sale_BonusBase2        double default 0,
 Sale_BonusTTC          double default 0
);

alter table temp_sales add
(Sale_TransportAccount  varchar(10),
 Sale_TransportAmount   double default 0,
 Sale_TransportBase1    double default 0,
 Sale_TransportBase2    double default 0,
 Sale_TransportTTC      double default 0,
 Sale_BonusAccount      varchar(10),
 Sale_BonusAmount       double default 0,
 Sale_BonusBase1        double default 0,
 Sale_BonusBase2        double default 0,
 Sale_BonusTTC          double default 0
);


alter table salesdt add
(SaleDt_TransportAmount   double default 0,
 SaleDt_TransportBase1    double default 0,
 SaleDt_TransportBase2    double default 0,
 SaleDt_BonusAmount       double default 0,
 SaleDt_BonusBase1        double default 0,
 SaleDt_BonusBase2        double default 0
);

alter table temp_salesdt add
(SaleDt_TransportAmount   double default 0,
 SaleDt_TransportBase1    double default 0,
 SaleDt_TransportBase2    double default 0,
 SaleDt_BonusAmount       double default 0,
 SaleDt_BonusBase1        double default 0,
 SaleDt_BonusBase2        double default 0
);


#Tarek 2011-12-13
alter table accesslabelsrocky.login
add Login_ModifyDiscount tinyint(1) default 1;


#Shukri 2011-12-14
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `fastprintarchive` TINYINT(1) DEFAULT 1;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `fastprinttransaction` TINYINT(1) DEFAULT 1;

#nabil 2011-12-16
alter table itemjour add itemjour_location varchar(60);

#Tarek 2011-12-16
alter table module add Module_AutoReturnSales tinyint(1) default 0;

#nabil 2011-12-20 updating clients inactive like ledger - for new data only
#update clients,ledger set Client_deactivate=Ledger_inactive where clients.ledger_number=ledger.ledger_number;


#Tarek 2011-12-29
alter table accesslabelsrocky.login add
(FA_Contra     tinyint(1) default 0,
 FA_ContraApp  tinyint(1) default 0,
 FA_ContraMod  tinyint(1) default 0,
 FA_ContraDel  tinyint(1) default 0
);

alter table sequence add column Contra_RefGovernment double;
alter table sequence add column Contra_TypeRef double;


#Tarek 2012-01-09  -- Created By Nabil
Alter table itemjour add itemjour_barcode  varchar(20);
Alter table itemjour add itemjour_location  varchar(60);


#Tarek 2012-01-10  -- Created By Nabil
CREATE TABLE `ClientsGroup` (
  `ClientsGroup_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `client_code` VARCHAR(10) NOT NULL,
  `Group_code` VARCHAR(15) NOT NULL,
  PRIMARY KEY (`ClientsGroup_id`)
)

ENGINE = InnoDB;


ALTER TABLE `clientsgroup` ADD CONSTRAINT `FK_clientsgroup_ClientCode` FOREIGN KEY `FK_clientsgroup_ClientCode` (`client_code`)
    REFERENCES `clients` (`Ledger_number`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;


ALTER TABLE `clientsgroup` ADD CONSTRAINT `FK_clientsgroup_GroupCode` FOREIGN KEY `FK_clientsgroup_GroupCode` (`group_code`)
    REFERENCES `grouping` (`group_code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
 

CREATE TABLE `SalesmenGroup` (
  `SalesmenGroup_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `salesman_code` VARCHAR(10) NOT NULL,
  `group_code` VARCHAR(15) NOT NULL,
  PRIMARY KEY (`SalesmenGroup_id`),
  CONSTRAINT `FK_SalesmenGroup_SalesmanCode` FOREIGN KEY `FK_SalesmenGroup_SalesmanCode` (`salesman_code`)
    REFERENCES `salesmen` (`Ledger_number`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,

  CONSTRAINT `FK_SalesmenGroup_GroupCode` FOREIGN KEY `FK_SalesmenGroup_GroupCode` (`group_code`)
    REFERENCES `grouping` (`group_code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE

)

ENGINE = InnoDB;



#maroun 2012-01-10
ALTER TABLE `reportsoptions_templates` ADD COLUMN `LedgersPerType` VARCHAR(200),
 ADD COLUMN `AllTypesCredit` TINYINT UNSIGNED ,
 ADD COLUMN `AllTypesDebit` TINYINT UNSIGNED ;


#Tarek 2012-01-11  -- Created By Nabil
ALTER TABLE `grouping` ADD COLUMN `Group_Commission2` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `module` ADD COLUMN `Module_CommissionByGroup` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;

#Gilbert 2012-01-12
ALTER TABLE `financialtemplate` 
 ADD CONSTRAINT `financialtemplate_code` FOREIGN KEY `financialtemplate_code` (`FinancialTot_Code`)
    REFERENCES `financialtotlabel` (`FinancialTot_code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

#Tarek 2012-01-12  -- Created By Nabil
CREATE TABLE `GroupComissionMA` (
  `GroupComissionMA_id` BIGINT UNSIGNED AUTO_INCREMENT,
  `GroupComissionMA_FromDate` DATE NOT NULL, 
  `GroupComissionMA_ToDate` DATE NOT NULL, 
  PRIMARY KEY (`GroupComissionMA_id`)

)

ENGINE = InnoDB;
 

CREATE TABLE `GroupComission` (
  `GroupComission_id` BIGINT UNSIGNED AUTO_INCREMENT,
  `GroupComissionMA_id` BIGINT UNSIGNED,
  `GroupComission_FromDate` DATE NOT NULL, 
  `GroupComission_ToDate` DATE NOT NULL, 
  `GroupComission_FromGP` DOUBLE NOT NULL DEFAULT 0,
  `GroupComission_ToGP` DOUBLE NOT NULL DEFAULT 0,
  `GroupComission_comission` DOUBLE NOT NULL DEFAULT 0,
  PRIMARY KEY (`GroupComission_id`)

)

ENGINE = InnoDB;

 

ALTER TABLE `groupcomission`
ADD CONSTRAINT `FK_groupcomission_MAID` FOREIGN KEY `FK_groupcomission_MAID` (`GroupComissionMA_id`)
    REFERENCES `groupcomissionma` (`GroupComissionMA_id`)
    ON DELETE cascade
    ON UPDATE cascade;



CREATE TABLE `GroupComissionTarget` (
  `GroupComissionTarget_id` BIGINT UNSIGNED AUTO_INCREMENT,
  `Group_code` varchar(15) NOT NULL, 
  `GroupComissionTarget_FromDate` DATE NOT NULL, 
  `GroupComissionTarget_ToDate` DATE NOT NULL, 
  `currency_code` varchar(6) NOT NULL ,
  `GroupComissionTarget_amount` DOUBLE NOT NULL DEFAULT 0,
  `GroupComissionTarget_amountbase1` DOUBLE NOT NULL DEFAULT 0,
  `GroupComissionTarget_amountbase2` DOUBLE NOT NULL DEFAULT 0,
  PRIMARY KEY (`GroupComissionTarget_id`)

)

ENGINE = InnoDB;

 

CREATE TABLE `GroupComissionTargetdt` (
  `GroupComissionTargetdt_id` BIGINT UNSIGNED AUTO_INCREMENT,
  `GroupComissionTarget_id` BIGINT UNSIGNED ,
  `GroupComissionTargetdt_FromGP` DOUBLE NOT NULL DEFAULT 0,
  `GroupComissionTargetdt_ToGP` DOUBLE NOT NULL DEFAULT 0,
  `GroupComissionTargetdt_comission` DOUBLE NOT NULL DEFAULT 0,
  `GroupComissionTargetdt_Bonus` DOUBLE NOT NULL DEFAULT 0,
  PRIMARY KEY (`GroupComissionTargetdt_id`)

)

ENGINE = InnoDB;


ALTER TABLE `groupcomissiontargetdt` ADD CONSTRAINT `FK_groupcomissiontargetdt_1` FOREIGN KEY `FK_groupcomissiontargetdt_1` (`GroupComissionTarget_id`)
    REFERENCES `groupcomissiontarget` (`GroupComissionTarget_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;


ALTER TABLE `groupcomissiontarget` ADD CONSTRAINT `FK_groupcomissiontarget_GroupCode` FOREIGN KEY `FK_groupcomissiontarget_GroupCode` (`Group_code`)
    REFERENCES `grouping` (`Group_Code`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;



ALTER TABLE `financialtotlabel` MODIFY COLUMN `FinancialTot_LevelCode` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#nabil 2012-01-19
ALTER TABLE `banks` ADD COLUMN `Bank_creditlimit1` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `banks` ADD COLUMN `Bank_creditlimit2` DOUBLE NOT NULL DEFAULT 0 ;


#nabil 2012-01-23
ALTER TABLE `rmadt` MODIFY COLUMN `rmadt_notes` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `rmadt` MODIFY COLUMN `rmadt_received` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `rmadt` MODIFY COLUMN `rmadt_problem` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rmadt` MODIFY COLUMN `rmadt_solution` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#nabil 2012-01-24
ALTER TABLE `rmadt` ADD COLUMN `rmadt_status` VARCHAR(1);
#C:Credit Note , R:Replace or X:Reject

ALTER TABLE `rmadt` ADD COLUMN `rmadt_DateReceived` DATETIME;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_DateDelivered` DATETIME ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_UserRecieved` VARCHAR(45) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_UserDelivered` VARCHAR(45);
ALTER TABLE `rmadt` ADD COLUMN `item_codeRep` VARCHAR(20) ;
ALTER TABLE `rmadt` ADD COLUMN `serial_numberRep` VARCHAR(40);
ALTER TABLE `rmadt` ADD COLUMN `rmadt_ReturnInvNo` VARCHAR(45) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_ReturnDate` DATE ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_ReturnCur` VARCHAR(6) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_ReturnAmount` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_NewInvNo` VARCHAR(45) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_NewDate` DATE ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_NewCur` VARCHAR(6) ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_NewAmount` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_RejectedRemark` VARCHAR(100);




#maroun 2012-01-25
ALTER TABLE `Transfer` ADD COLUMN `Company_Name` VARCHAR(45) ;
ALTER TABLE `Transfer` ADD COLUMN `f_Date` VARCHAR(45) ;
ALTER TABLE `Transferdt` ADD COLUMN `Date` VARCHAR(45) ;
ALTER TABLE `Purchasesserialno` ADD COLUMN `flagunique` DOUBLE ;

ALTER TABLE `Temp_Transfer` ADD COLUMN `Company_Name` VARCHAR(45) ;
ALTER TABLE `Temp_Transfer` ADD COLUMN `f_Date` VARCHAR(45) ;
ALTER TABLE `Temp_Transferdt` ADD COLUMN `Date` VARCHAR(45) ;
ALTER TABLE `Temp_Purchasesserialno` ADD COLUMN `flagunique` DOUBLE ;



#Tarek 2012-01-30
create table grnpurchases like purchases;
create table grnpurchasesdt like purchasesdt;

alter table accesslabelsrocky.login add
( FI_RmGrn    Tinyint(1) default 0,
  FI_RmGrnDel Tinyint(1) default 0,
  FI_RmGrnMod Tinyint(1) default 0,
  FI_RmGrnApp Tinyint(1) default 0
);


alter table grnpurchases add
(Purchase_PackingListRef  varchar(50)
,Purchase_FormMNo         varchar(50)
);

alter table temp_grnpurchases add
(Purchase_PackingListRef  varchar(50)
,Purchase_FormMNo         varchar(50)
);

alter table sequence add column RmGrn_Reference double;

#maroun 2012-02-27
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RmTransfer` TINYINT(1) UNSIGNED  DEFAULT 0;
ALTER TABLE `transfer` ADD COLUMN `Document_RefNo` VARCHAR(50) ;
ALTER TABLE `Temp_transfer` ADD COLUMN `Document_RefNo` VARCHAR(50) ;

#maroun 2012-02-30
 ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_IRmTransferDel` TINYINT(1) UNSIGNED DEFAULT 0 ,
 ADD COLUMN `FI_RmTransferMod` TINYINT(1) UNSIGNED DEFAULT 0 ;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Fi_RmTransferapp` TINYINT(1) UNSIGNED DEFAULT 0 ;

#maroun 2012-01-31
ALTER TABLE `sequence` ADD COLUMN `RmTransfer_Reference` DOUBLE;
ALTER TABLE `transfer` ADD COLUMN `Transfer_Type` VARCHAR(2);
ALTER TABLE `temp_transfer` ADD COLUMN `Transfer_Type` VARCHAR(2);

#Tarek 2012-02-02
alter table cashregister add column CashRegister_AutoPost tinyint(1) default 0;

ALTER TABLE `purchasesserialno` ADD INDEX `RetailDt_ID`(`RetailDt_ID`);


#nabil 2012-02-06 old field is missing
ALTER TABLE `module` ADD COLUMN `Module_PreProduction` TINYINT(1) UNSIGNED DEFAULT 0 ;
alter table module add `Module_DirectStockPI` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectStockPR` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectStockDI` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectStockDR` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectStockAI` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectStockPD` tinyint(1) DEFAULT '0';
alter table module add   `Module_WayBill` tinyint(1) DEFAULT '0';
alter table module add   `Module_RepostTransaction` tinyint(1) DEFAULT '0';
alter table module add   `Module_AttendanceMachine` tinyint(1) DEFAULT '0';
alter table module add   `Module_SendReceive` tinyint(1) DEFAULT '0';
alter table module add   `Module_TransInact` tinyint(1) DEFAULT '0';
alter table module add   `Module_FieldsSetup` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectConsumption` tinyint(1) DEFAULT '0';
alter table module add   `Module_LoadExcelToSales` tinyint(1) DEFAULT '0';
alter table module add   `Module_VoucherSign` tinyint(1) DEFAULT '0';
alter table module add   `Module_LedgerGrp` tinyint(1) DEFAULT '0';
alter table module add   `Module_ClientDiscount` tinyint(1) DEFAULT '0';
alter table module add   `Module_IsInvoice` tinyint(1) DEFAULT '0';
alter table module add   `Module_Fleet` tinyint(1) DEFAULT '0';
alter table module add   `Module_AcctrxPost` tinyint(1) DEFAULT '0';
alter table module add   `Module_ConfirmJV` tinyint(1) DEFAULT '0';
alter table module add   `Module_AdditionalTaxes` tinyint(1) DEFAULT '0';
alter table module add   `Module_ClosingPeriod` tinyint(1) DEFAULT '0';
alter table module add   `Module_TransferItem` tinyint(1) DEFAULT '0';
alter table module add   `Module_Synchro` tinyint(1) DEFAULT '0';
alter table module add   `Module_TransConfirm` tinyint(1) DEFAULT '0';
alter table module add   `Module_ForSolicar` tinyint(1) DEFAULT '0';
alter table module add   `Module_BudProject` tinyint(1) DEFAULT '0';
alter table module add   `Module_CashPrinterChoice` tinyint(1) DEFAULT '0';
alter table module add   `Module_PurchaseRequest` tinyint(1) DEFAULT '0';
alter table module add   `Module_JVMode` tinyint(1) DEFAULT '0';
alter table module add   `Module_AutoTransSorder` tinyint(1) DEFAULT '0';
alter table module add   `Module_CEPTable` tinyint(1) DEFAULT '0';
alter table module add   `Module_AcctrxPostPV` tinyint(1) DEFAULT '0';
alter table module add   `Module_AcctrxPostRV` tinyint(1) DEFAULT '0';
alter table module add   `Module_AcctrxPostDV` tinyint(1) DEFAULT '0';
alter table module add   `Module_AcctrxPostCV` tinyint(1) DEFAULT '0';
alter table module add   `Module_CounterPart` tinyint(1) DEFAULT '0';
alter table module add   `Module_AdvancedProduction` tinyint(1) DEFAULT '0';
alter table module add   `Module_GenerateSorderJV` tinyint(1) DEFAULT '0';
alter table module add   `Module_SuperMarket` tinyint(1) DEFAULT '0';
alter table module add   `Module_SecureLogin` tinyint(1) DEFAULT '0';
alter table module add   `Module_InOut` tinyint(1) DEFAULT '0';
alter table module add   `Module_SendTransferToAdj` tinyint(1) DEFAULT '0';
alter table module add   `Module_DirectStockSO` tinyint(1) DEFAULT '0';
alter table module add   `Module_WhSellingPrice` tinyint(1) DEFAULT '0';
alter table module add   `module_base2` tinyint(1) DEFAULT '0';
alter table module add   `module_serialnoVal` tinyint(1) DEFAULT '0';
alter table module add   `module_negativeSorder` tinyint(1) DEFAULT NULL;
alter table module add   `Module_InBeforeOut` tinyint(1) DEFAULT '0';
alter table module add   `Module_DoubleUnit` tinyint(1) DEFAULT '0';
alter table module add   `module_manufacturedCode` tinyint(1) DEFAULT '0';
alter table module add   `module_creditlimit` tinyint(1) unsigned NOT NULL DEFAULT '1';
alter table module add   `module_budgetlimit` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_longdescription` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_DeliveryWithSorder` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_deliverytransfer` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_deliverysale` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_deliverySales` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_paymentterms` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_budgetinv` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_productionmm` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_productiontransf` tinyint(1) NOT NULL;
alter table module add   `module_productionRatio` tinyint(1) NOT NULL;
alter table module add   `module_directstockITrans` tinyint(1) NOT NULL;
alter table module add   `Module_deliverydtautoincrement` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `module_school` tinyint(1) unsigned DEFAULT '0';
alter table module add   `module_DeliveryRelease` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `Module_SerialNoQuantity` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   `Module_PrintWaybill` tinyint(1) DEFAULT '0';
alter table module add   `Module_referencebycostcenter` tinyint(1) DEFAULT NULL;
alter table module add   `Module_AcctrxPostGenRV` tinyint(1) DEFAULT NULL;
alter table module add   `module_email` tinyint(1) DEFAULT NULL;
alter table module add   `Module_RestrictCost` tinyint(1) DEFAULT '0';
alter table module add   `Module_ShowLayoutProj` tinyint(1) DEFAULT '0';
alter table module add   `Module_ShowLayoutCost` tinyint(1) DEFAULT '0';
alter table module add   `Module_ShowBalance` tinyint(1) DEFAULT '0';
alter table module add   `Module_TransStandardView` tinyint(1) DEFAULT '0';
alter table module add   `Module_Grn` tinyint(1) DEFAULT '0';
alter table module add   `Module_SorderWithOneWh` tinyint(1) DEFAULT '0';
alter table module add   `Module_SorderAutoConfirm` tinyint(1) DEFAULT '0';
alter table module add   `Module_PorderConfirm` tinyint(1) DEFAULT '1';
alter table module add   `Module_InvoiceCheckLimit` tinyint(1) DEFAULT '0';
alter table module add   `Module_PostRetailOneToOne` tinyint(1) DEFAULT '0';
alter table module add   `Module_CommissionByGroup` tinyint(1) unsigned NOT NULL DEFAULT '0';
alter table module add   Expiry_date datetime;
alter table module add   Module_MultiCashType tinyint(1) unsigned NOT NULL DEFAULT '0';
ALTER TABLE `purchasesjv` ADD COLUMN `PurchaseJV_manualVat` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `purchasesjv` ADD COLUMN `PurhchaseJV_VATPER` FLOAT NOT NULL DEFAULT 0 ;
ALTER TABLE `purchasesjv` ADD COLUMN `PurchaseJV_manualVat` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `purchasesjv` ADD COLUMN `PurchaseJV_VATPER` FLOAT NOT NULL DEFAULT 0 ;


#nabil 2012-02-10
altER TABLE `rmadt` ADD COLUMN `rmadt_transferno` VARCHAR(20);
ALTER TABLE `rmadt` ADD COLUMN `rmadt_RetRMADateRecieved` DATETIME;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_RetRMAUserRecieved` VARCHAR(45) ;
alter table accesslabelsrocky.login add FI_SellingPriceModifyInItems tinyint(1) default 0;


#maroun 22-02-2012
ALTER TABLE `transferdt` ADD COLUMN `Item_CodeFinished` VARCHAR(20) ,
 ADD COLUMN `Item_CodeSemiFinished` VARCHAR(20) ;
ALTER TABLE `temp_transferdt` ADD COLUMN `Item_CodeFinished` VARCHAR(20) ,
 ADD COLUMN `Item_CodeSemiFinished` VARCHAR(20) ;
alter table module add Module_TransferWithOneWh tinyint(1) default 0;

#Tarek 2012-02-22
alter table grnpurchasesdt add
(Item_CodeFinished     varchar(20),
 Item_CodeSemiFinished varchar(20)
);


alter table temp_grnpurchasesdt add
(Item_CodeFinished     varchar(20),
 Item_CodeSemiFinished varchar(20)
);


#Tarek 2012-02-24
alter table deliveries add column Delivery_VatChkbx tinyint(1) default 1;
alter table temp_deliveries add column Delivery_VatChkbx tinyint(1) default 1;

#Nabil 2012-02-28
alter table module add module_ExternalImportExport tinyint(1) default 0;

#Nabil 2012-03-02
#sonit
ALTER TABLE `sales` ADD INDEX `Remark`(`Sale_Remark`);
ALTER TABLE `deliveries` ADD INDEX `Remark`(`Delivery_Remark`);

#Nabil 2012-03-07
ALTER TABLE `telephoneno` ADD COLUMN `telephoneno_fname` VARCHAR(45) ,
 ADD COLUMN `telephoneno_lname` VARCHAR(45) ,
 ADD COLUMN `telephoneno_email` VARCHAR(45) ,
 ADD COLUMN `telephoneno_reference` VARCHAR(15);
ALTER TABLE `telephoneno` ADD COLUMN `telephoneno_city1` VARCHAR(45) ;
ALTER TABLE `telephoneno` ADD COLUMN `telephoneno_city2` VARCHAR(45) ;
ALTER TABLE `telephoneno` ADD COLUMN `telephoneno_city3` VARCHAR(45) ;


#Tarek 2012-03-05
alter table accesslabelsrocky.login add
(FI_ReturnGrn     tinyint(1) default 0,
 FI_ReturnGrnDel  tinyint(1) default 0,
 FI_ReturnGrnMod  tinyint(1) default 0,
 FI_ReturnGrnApp  tinyint(1) default 0
);


alter table GrnPurchasesdt add Related_Ref double;
alter table Temp_GrnPurchasesdt add Related_Ref double;

alter table GrnPurchases add Purchase_ReturnRef double;
alter table Temp_GrnPurchases add Purchase_ReturnRef double;

alter table sequence add GrnReturn_Reference double;

#Tarek 2012-03-13
alter table jourtype add Related_Type varchar(2);

#nabil 2012-03-16
ALTER TABLE `module` ADD COLUMN `module_saleprintoption` TINYINT(1) UNSIGNED DEFAULT 0 ;
#ALTER TABLE `stktransaction` ADD COLUMN `stktransaction_id` BIGINT NOT NULL DEFAULT NULL AUTO_INCREMENT ,
# DROP PRIMARY KEY,
# ADD PRIMARY KEY  USING BTREE(`stktransaction_id`);

#ALTER TABLE `stktransaction` ADD UNIQUE INDEX `indsStk_TypeTransID`(`Transaction_ID`, `Transaction_Type`);

CREATE TABLE `ItemsTrans` (
  `Item_code` VARCHAR(20) NOT NULL,
  `ItemTrans_LastDatePurchase` DATETIME NOT NULL,
  `ItemTrans_LastPricePurchase` DOUBLE NOT NULL DEFAULT 0,
  `itemTrans_lastcostprice` DOUBLE NOT NULL DEFAULT 0,
  `itemTrans_lastcostpriceBase1` DOUBLE NOT NULL DEFAULT 0,
  `itemTrans_lastcostpriceBase2` DOUBLE NOT NULL DEFAULT 0,
  PRIMARY KEY (`Item_code`)
)
ENGINE = InnoDB;


#Tarek 2012-03-28
alter table salessetup add
( InvoiceComment  varchar(500),
  WaybillComment  varchar(500)
);

#Update salessetup set
#InvoiceComment = 'NOTE TO DEALERS AND CORPORATE CUSTOMERS: NO CASH PAYMENT SHOULD BE MADE TO ANY DAJCOM STAFF AND/OR SALES REPRESENTATIVE. PAYMENTS SHOULD BE MADE BY CHEQUES, BANKERS DRAFTS OR ELECTRONIC TRANSFERS ONLY.';

#update salessetup set
#WaybillComment = 'Dear Customer by signing this, you acknowledge that goods have been delivered to your premises packaged, intact, in brand new condition (no scratches, dents, broken\ missing parts & accessories etc. have been noted), and therefore, any future claims for the same are null and void.';


#Nabil 2012-03-28
CREATE TABLE  `eventemail` (
  `EventEmail_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `EventEmail_SentDate` datetime DEFAULT NULL,
  `EventEmail_TransactionDate` datetime DEFAULT NULL,
  `EventEmail_Status` varchar(1) DEFAULT NULL,
  `EventEmail_TransactionId` bigint(20) unsigned DEFAULT NULL,
  `EventEmail_TransactionCount` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`EventEmail_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `scheduleemail` (
  `ScheduleEmail_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `ScheduleEmail_day` varchar(10) DEFAULT NULL,
  `ScheduleEmail_Time` varchar(8) DEFAULT NULL,
  PRIMARY KEY (`ScheduleEmail_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;


#insert into scheduleemail (ScheduleEmail_id,ScheduleEmail_day,ScheduleEmail_Time) values (1, 'Monday', '17:05:00');
#insert into scheduleemail (ScheduleEmail_id,ScheduleEmail_day,ScheduleEmail_Time) values (2, 'Tuesday ', '17:05:00');
#insert into scheduleemail (ScheduleEmail_id,ScheduleEmail_day,ScheduleEmail_Time) values (3, 'Wednesday', '17:05:00');
#insert into scheduleemail (ScheduleEmail_id,ScheduleEmail_day,ScheduleEmail_Time) values (4, 'Thursday ', '17:05:00');
#insert into scheduleemail (ScheduleEmail_id,ScheduleEmail_day,ScheduleEmail_Time) values (5, 'Friday ', '17:05:00');
#insert into scheduleemail (ScheduleEmail_id,ScheduleEmail_day,ScheduleEmail_Time) values (6, 'Saturday ', '17:05:00');

#Nabil 2012-03-30
alter table accesslabelsrocky.configurationemail add  `AutoReceivermail` varchar(100) DEFAULT NULL;
alter table accesslabelsrocky.configurationemail add  `ReceiverAutoMailCC` varchar(100) DEFAULT NULL;

alter table accesslabelsrocky.login add Default_Project varchar(30);
alter table accesslabelsrocky.login add Default_Costcent varchar(30);
alter table accesslabelsrocky.login add FI_ReturnGrn tinyint(1);
alter table accesslabelsrocky.login add FI_ReturnGrnDel tinyint(1);
alter table accesslabelsrocky.login add FI_ReturnGrnMod tinyint(1);
alter table accesslabelsrocky.login add FI_ReturnGrnApp   tinyint(1);
alter table accesslabelsrocky.login add production tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add  RP_generate tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add  RP_TaxeDeclare tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add  FI_ReturnGrn tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add  FI_ReturnGrnDel  tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add  FI_ReturnGrnMod  tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add  FI_ReturnGrnApp  tinyint(1);


#maroun 30-03-2012
ALTER TABLE `accesslabelsrocky`.`login` MODIFY COLUMN `FC_CashRegisterSearch` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_IN` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_OUT` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_INDel` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_OUTDel` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_INMod` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_OUTMod` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_INapp` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_Outapp` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `RA_AvgDays` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `RA_SalesJV` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `RA_PurchasesJV` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_SorderCanceledQty` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `ShowTransaction` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_Transformation` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_TransformationAPP` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_TransformationMod` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_TransformationDel` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_ProdRatio` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_ProdRatioAPP` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_ProdRatioMod` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FA_ProdRatioDEL` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `fpr_changeweight` TINYINT(1) UNSIGNED DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `login_disapprovesorder` TINYINT(1) UNSIGNED DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `RI_tabsheetbooksbalance` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `Default_Project` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `Default_Costcent` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_ReturnGrn` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_ReturnGrnDel` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_ReturnGrnMod` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `FI_ReturnGrnApp` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login`  MODIFY COLUMN `production` TINYINT(1) DEFAULT 0;

#Nabil 2012-04-04
ALTER TABLE `groupcomissiontarget` ADD COLUMN `GroupComission_ProfitMargin` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `RI_CommissionByGroup` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RMASheetRMA` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RMASheetPending` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RMAReturnSheetReturnRMA` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RMAReturnSheetRMA` TINYINT(1) UNSIGNED DEFAULT 0 ;


#Nabil 2012-04-17
ALTER TABLE `salesjv` ADD COLUMN `SalesJV_DiscountAccount` VARCHAR(10);


#Tarek 2012-05-03
alter table module add Module_ReferenceByProject tinyint(1) default 0;
alter table sequence add Project varchar(30);
alter table sequence modify column Costcenter varchar(30);

#Tarek 2012-05-07
alter table accesslabelsrocky.login add Login_FastPrint tinyint(1) default 1;

#Tarek 2012-05-08
alter table module add Module_AcctrxPostCT tinyint(1) default 0;


#NABIL 2012-05-09 FOR TPRO
ALTER TABLE `rmadt` MODIFY COLUMN `rmadt_problem` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;





#Tarek 2012-05-10
CREATE TABLE `ClientsCreditLimit` (
  `ClientsCreditLimit_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Client_Code` VARCHAR(10) NOT NULL,
  `Project_Code` VARCHAR(30) NOT NULL,
  `Client_CreditLimit` DOUBLE NOT NULL,
  PRIMARY KEY (`ClientsCreditLimit_ID`)
);


alter table module add Module_CreditLimitByProj tinyint(1) default 0;


#Nabil 2012-05-14  //cct load physical quantity from MSSQL (BMB)
alter table adjustment add column document_code varchar(30);
create table adjustment_temp like  adjustment;
create table adjustmentdt_temp like  adjustmentdt;

ALTER TABLE `adjustmentdt_temp` ADD CONSTRAINT `FK_adjustmentdt_temp_id` FOREIGN KEY `FK_adjustmentdt_temp_id` (`Adjustment_Id`)
    REFERENCES `adjustment_temp` (`Adjustment_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;
	
ALTER TABLE `adjustmentdt_temp`
 DROP FOREIGN KEY `FK_adjustmentdt_temp_id`;

ALTER TABLE `adjustmentdt_temp` ADD CONSTRAINT `FK_adjustmentdt_temp_id` FOREIGN KEY `FK_adjustmentdt_temp_id` (`Adjustment_Id`)
    REFERENCES `adjustment_temp` (`Adjustment_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;

alter table items add item_discount double default 0;


#Tarek 2012-05-17
alter table module add Module_RestrictCashType  tinyint(1) default 1;
alter table accesslabelsrocky.login add Login_ModifySellingPrice tinyint(1) default 1;
alter table accesslabelsrocky.login add FI_SorderAskConfirm tinyint(1) default 1;


#Nabil 2012-05-17 
CREATE TABLE  `clients2` (
  `ledger_number` varchar(10) NOT NULL,
  `ledger_name` varchar(50) NOT NULL,
  `Client_Telephone1` varchar(25) DEFAULT NULL,
  `Client_Address` varchar(100) DEFAULT NULL,
  `Client_Reference` varchar(45) DEFAULT NULL,
  `Client_calldate` datetime DEFAULT NULL,
  `client_Email` varchar(100) DEFAULT NULL,
  `Client_Fax` varchar(25) DEFAULT NULL,
  `Client_Telephone2` varchar(25) DEFAULT NULL,
  `bussiness_code` varchar(20) DEFAULT NULL,
  `Client_municipality` bigint(20) DEFAULT NULL,
  `Client_Bankfilenumber` varchar(20) DEFAULT NULL,
  `client_dob` datetime DEFAULT NULL,
  `client_registrationId` double DEFAULT NULL,
  `client_registrationplace` varchar(50) DEFAULT NULL,
  `client_motherfullname` varchar(100) DEFAULT NULL,
  `client_fathername` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`ledger_number`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `clients` MODIFY COLUMN `Client_TC` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;
alter table clients2 add column client_tc VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SalebelowCost` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SaleBelowDiscount` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SaleDiscountPer` double UNSIGNED DEFAULT 0 ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SalesOrderModDelConfirmed` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `module` ADD COLUMN `Module_Confirmedmessaging` TINYINT(1) UNSIGNED DEFAULT 0 ;



CREATE TABLE  `messagetrans` (
  `MessageTrans_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `MessageTrans_date` datetime NOT NULL,
  `MessageTrans_User` varchar(45) DEFAULT NULL,
  `MessageTrans_read` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1-Confirmed, 0 - not confirmed',
  `MessageTrans_status` int(10) unsigned NOT NULL DEFAULT '0',
  `type_code` varchar(2) NOT NULL,
  `trans_id` bigint(20) unsigned NOT NULL,
  `trans_reference` bigint(20) unsigned NOT NULL,
  `trans_date` datetime NOT NULL,
  `Trans_user` varchar(45) DEFAULT NULL,
  `MessageTrans_Description` blob,
  PRIMARY KEY (`MessageTrans_id`)
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8;

CREATE TABLE  `messagetransdt` (
  `MessageTransdt_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `MessageTrans_id` bigint(20) unsigned NOT NULL,
  `MessageTransDt_Description` blob NOT NULL,
  PRIMARY KEY (`MessageTransdt_id`),
  KEY `FK_messagetransid` (`MessageTrans_id`),
  CONSTRAINT `FK_messagetransid` FOREIGN KEY (`MessageTrans_id`) REFERENCES `messagetrans` (`MessageTrans_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=91 DEFAULT CHARSET=utf8;

#nabil 2012-05-25
ALTER TABLE `module` ADD COLUMN `Module_RMA` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `module` ADD COLUMN `Module_RMATabSheet` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_expectedDate` DATETIME ;


#Tarek 2012-05-22
alter table project add Parent_Code varchar(30);
alter table costcent add Parent_Code varchar(30);
alter table warehouse add Parent_Code varchar(30);
alter table grouping add Parent_Code varchar(15);
alter table subgroup add Parent_Code varchar(15);
alter table area add Parent_Code varchar(20);

#Nabil 2012-05-31
ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_offer` TINYINT(1) UNSIGNED DEFAULT 0 ;

#Tarek 2012-05-31
alter table cashregister add CashRegister_RestSerialNo tinyint(1) default 1;
alter table retail add Salesman_Code varchar(10);
alter table temp_retail add Salesman_Code varchar(10);

#nABIL 2012-06-06
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice1Base1` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice1Base2` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice2Base1` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice2Base2` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice3Base1` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice3Base2` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice4Base1` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice4Base2` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice5Base1` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice5Base2` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice6Base1` DOUBLE default 0;
ALTER TABLE vieweritem ADD COLUMN `Item_NewSellingPrice6Base2` DOUBLE default 0;




ALTER TABLE `transp` ADD COLUMN `transp_posalter table  sales add column cltcar_code varchar(10);
ALTER TABLE `accesslabelsrocky`.`login` add column FI_Shipment tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add column FI_Shipmentconfirmed tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add column FI_ShipmentMod tinyint(1);
ALTER TABLE `accesslabelsrocky`.`login` add column FI_ShipmentDel tinyint(1);
ted` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 ;
#update transp set transp_posted =true;  WHITE CITY(first time on implmentation)

#Gilbert 2012-06-07



#maroun 2012-06-11
ALTER TABLE `salesdt` ADD COLUMN `salesdt_offer` TINYINT(1) UNSIGNED DEFAULT 0 ;
ALTER TABLE `deliveries` ADD COLUMN `CashRegister_Name` VARCHAR(20) ;
ALTER TABLE `sales` ADD COLUMN `CashRegister_Name` VARCHAR(20) ;

#maroun 2012-06-11
ALTER TABLE `vendors` MODIFY COLUMN `Vendor_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
 ALTER TABLE `vendors` ADD COLUMN `Vender_id` BIGINT UNSIGNED NOT NULL DEFAULT NULL AUTO_INCREMENT AFTER `Synchronized`,
 ADD PRIMARY KEY (`Vender_id`);

 #NABIL 2012-06-12
 alter table transpdt add transpdt_date datetime;
 alter table transpdt add related_id double;
 alter table transp add related_id double;


#Tarek 2012-06-16
alter table module add Module_LoadSerials tinyint(1) default 0;


#NABIL 2012-06-18
alter table setup add setup_branch varchar(20);
#update setup set setup_branch='TRIPOLI';

#Tarek 2012-06-26
alter table deliveries add column Delivery_DirectReturn tinyint(1) default 0;
alter table temp_deliveries add column Delivery_DirectReturn tinyint(1) default 0;


#maroun 2012-06-27
alter table warehouse add warehouse_production tinyint(1) default 0;

#Tarek 2012-06-30
alter table PackDt add PackDt_PreCosting tinyint(1) default 0;


#nabil 2012-07-04  //gemayel
alter table accesslabelsrocky.login add  `RI_QUERIES` tinyint(1) DEFAULT 0;
alter table accesslabelsrocky.login add  `RI_QUERY1` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY2` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY3` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY4` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY5` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY6` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY7` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY8` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY9` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY10` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY11` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY12` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY13` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY14` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY15` tinyint(1)  DEFAULT 0;
  alter table accesslabelsrocky.login add `RI_QUERY16` tinyint(1)  DEFAULT 0;
  
#nabil 2012-07-18  //Global sky
alter table salesjvdt add salesjvdt_tax float default 0;
alter table salesjvdt add salesjvdt_taxbase1 float default 0;
alter table salesjvdt add salesjvdt_taxbase2 float default 0;

alter table purchasesjvdt add purchasesjvdt_tax float default 0;
alter table purchasesjvdt add purchasesjvdt_taxbase1 float default 0;
alter table purchasesjvdt add purchasesjvdt_taxbase2 float default 0;

alter table setup add setup_salesjvtax varchar(10);
alter table setup add setup_purchasesjvtax varchar(10);
alter table module add module_transJVTax tinyint(1) default 0;
alter table purchasesjvdt add purchasejvdt_description3 varchar(100);
alter table purchasesjvdt add purchasesjvdt_date date;

#mikel 2012-08-02
ALTER TABLE `accesslabelsrocky`.`deliveryreport_label` ADD COLUMN `Credit` VARCHAR(25) AFTER `CartonUnit`;
ALTER TABLE `accesslabelsrocky`.`deliveryreport_label` ADD COLUMN `Cash` VARCHAR(25) AFTER `Credit`;
ALTER TABLE `accesslabelsrocky`.`deliveryreport_label` ADD COLUMN `F_Check` VARCHAR(25) AFTER `Cash`;


#Tarek 2012-08-28
alter table accesslabelsrocky.login add RI_GrnReports tinyint(1) default 0;

#maroun 29.08.2012
alter table module add column Module_StockEval tinyint(1) default 0;

#Tarek 2012-08-31
alter table module add Module_TransferSorder tinyint(1) default 0;
alter table clients add Client_DeliveryTransfer tinyint(1) default 1; # 1 for delivery  2 for transfer
alter table sorder add Sorder_Status tinyint(1) default 0; # 0 for pending  1 for delivered  2 for transfered


#maroun 01.09.2012
ALTER TABLE `rma` ADD COLUMN `Rma_EngineerName` VARCHAR(100);
ALTER TABLE `rma` ADD COLUMN `QC_Check` TINYINT(1) UNSIGNED default 0;
ALTER TABLE `rma` ADD COLUMN `QC_remark` VARCHAR(300);
ALTER TABLE `rma` ADD COLUMN `Rma_complete` TINYINT(1) UNSIGNED  default 0;
ALTER TABLE `trackinghistory` ADD COLUMN `Remark` VARCHAR(300);
ALTER TABLE `module` ADD COLUMN `Module_QC` TINYINT(1) UNSIGNED DEFAULT 0 ;


#Tarek 2012-09-04
alter table module add Module_PackCostPerc tinyint(1) default 1;


alter table PackDt add PackDt_Promotion tinyint(1) default 0;
alter table PackDt add PackDt_TotalPromotion double;


# Nabil  2012-09-04 rawda library
ALTER TABLE PACKDT ADD BARCODE VARCHAR(20);


# Nabil  2012-09-04 AKROSS
alter table salesjv add salesJV_formalityName varchar(45);
alter table salesjv add salesJV_blnno varchar(45);
alter table salesjv add salesJV_PortOfLoading varchar(45);
alter table salesjv add salesJV_PortOfDischarge varchar(45);
alter table salesjv add salesJV_VesselName varchar(45);
alter table salesjv add salesJV_ContainerNo varchar(45);
alter table salesjv add salesJV_Bulletin varchar(45);
alter table salesjv add salesJV_Commodity varchar(45);
alter table salesjv add salesJV_ShippingLine varchar(45);
alter table salesjv add salesJV_CustomReceipt varchar(45);
alter table salesjv add salesJV_CustomDate varchar(45);
alter table salesjv add salesJV_Freight varchar(45);
alter table salesjv add salesJV_ImportExport varchar(45);
alter table salesjv add salesJV_PakingOfGrossWeight varchar(45);
alter table salesjv add salesJV_ValueOfGoods varchar(45);

# Nabil  2012-09-18 abdel ahad
ALTER TABLE `setup` ADD COLUMN `PrevShowThumbsStatment` TINYINT(1) UNSIGNED DEFAULT 1 ;
ALTER TABLE `setup`  ADD COLUMN `PrevShowThumbsTrialBalance` TINYINT(1) UNSIGNED DEFAULT 1 ;



alter table accesslabelsrocky.login add column FI_SalebelowLandedCostWarning tinyint(1) UNSIGNED DEFAULT 1 ;


#Tarek 2012-09-14
CREATE TABLE `ItemButtons` (
  `ItemButton_Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `ItemButton_Value` VARCHAR(45) NOT NULL,
  `ItemButton_Label` VARCHAR(100) NOT NULL,
  `ItemButton_Order` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`ItemButton_Id`)
)
ENGINE = InnoDB;

alter table module add Module_CashRegisterFastItem tinyint(1) default 0;
alter table module add Module_CashRegisterBase2 tinyint(1) default 1;

# Nabil  2012-09-21 abdel ahad
ALTER TABLE `setup` ADD COLUMN `PrevShowThumbsStatmentofItems` TINYINT(1) UNSIGNED DEFAULT 1 ;
ALTER TABLE `setup`  ADD COLUMN `PrevShowThumbsSalesReport` TINYINT(1) UNSIGNED DEFAULT 1 ;
ALTER TABLE `setup`  ADD COLUMN `PrevShowThumbsInventoryReport` TINYINT(1) UNSIGNED DEFAULT 1 ;


#Tarek 2012-09-20
alter table sorder add Sorder_ConfirmUser varchar(45) default null;
alter table temp_sorder add Sorder_ConfirmUser varchar(45) default null;

# Nabil  2012-09-24 CCT
alter table accesslabelsrocky.login add column FI_MessageCenter tinyint(1)  default 0;



# Nabil  2012-09-28 CCT
alter table rmadt add column rmadt_price2 float default 0;
#Tarek 2012-09-26
CREATE TABLE `PaymentMethods` (
  `Payment_Id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Payment_Account` VARCHAR(10) NOT NULL,
  `Payment_Description` VARCHAR(50) NOT NULL,
  `Payment_Image` BLOB,
  PRIMARY KEY (`Payment_Id`)
);


#Tarek 2012-10-01 - 2012-10-04
alter table items add Item_ModifySellingPrice tinyint(1) default 1;
alter table accesslabelsrocky.login add FC_SearchByCashRegister tinyint(1) default 1;
alter table accesslabelsrocky.login drop column FC_PostingByCashRegister;
alter table module add Module_PostingByCashRegister tinyint(1) default 1;
alter table setup add Setup_TipsMaxAmount double default 0;

#nabil 20112-10-04 solicar production
ALTER TABLE `prodtranschdt` ADD COLUMN `ProdTransChDT_PrvQty` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE `prodtranschdt` ADD COLUMN `ProdTransChDT_NetQty` DOUBLE NOT NULL DEFAULT 0 ;


#Tarek 2012-10-13
alter table accesslabelsrocky.login add RA_AgingOfSupplierInvoices tinyint(1) default 0;

#Tarek 2012-10-16
alter table accesslabelsrocky.login add RA_StatisticsReport tinyint(1) default 0;
alter table accesslabelsrocky.login add RI_InvComparisonReport tinyint(1) default 0;


#nabil 2012-10-16  - cct dash board
#DROP TABLE IF EXISTS `accesslabelsrocky`.`queries`;
CREATE TABLE  `accesslabelsrocky`.`queries` (
  `query_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `query_Application` varchar(45) DEFAULT NULL,
  `query_Description` varchar(45) NOT NULL,
  `query_SQL` longtext,
  PRIMARY KEY (`query_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;


ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_query` BOOLEAN DEFAULT 0 ;
alter table accesslabelsrocky.login add login_queries tinyint(1) default 0;

alter table `accesslabelsrocky`.login add login_queiresEdit tinyint(1) default 0;

#nabil 2012-10-16  - avd financial report
ALTER TABLE `financialtemplate` ADD COLUMN `Financial_PrvBalance` TINYINT(1) UNSIGNED  default 1;
ALTER TABLE `financialtemplate` ADD COLUMN `Financial_NoOfDays` SMALLINT UNSIGNED NOT NULL DEFAULT 0 ;


#Tarek 2012-10-29
alter table clients add Client_Rebate double;
alter table clients add Client_Target double;
alter table accesslabelsrocky.login add RI_TargetRebateReport tinyint(1) default 0;


#Tarek 2012-10-30
alter table module add Module_SendSorderMail tinyint(1) default 0;
alter table setup add Setup_SorderMailMsg varchar(255);


#Tarek 2012-11-01
alter table salessetup add Sale_MinPendingQty double default 0;
alter table salessetup add Sale_MaxExceedQty double default 0;


#Tarek 2012-11-05
alter table accesslabelsrocky.login add RI_SalesOrderReport tinyint(1) default 0;



#Tarek 2012-11-13
alter table module add Module_RestrictCashTypePV  tinyint(1) default 1;
alter table module add Module_RestrictCashTypeRV  tinyint(1) default 1;
alter table module add Module_RestrictCashTypeCV  tinyint(1) default 1;
alter table module add Module_RestrictCashTypeDV  tinyint(1) default 1;
alter table module add Module_RestrictCashTypeCT  tinyint(1) default 1;


#NABIL SOLICAR 2012-11-21
ALTER TABLE `accesslabelsrocky`.`login`
 ADD COLUMN `RI_YEARLYCOMPARATIVEREPORT` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`login`
 ADD COLUMN `RA_YEARLYCOMPARATIVEREPORT` TINYINT(1);

#Tarek 2012-11-26
alter table salessetup add Sale_MarginPer double default 0;


#Tarek 2012-11-27
alter table purchasesjv add PurchaseJV_DiscountPer double default 0;
alter table temp_purchasesjv add PurchaseJV_DiscountPer double default 0;

alter table purchasesjv add PurchaseJV_DiscountAccount varchar(10);
alter table temp_purchasesjv add PurchaseJV_DiscountAccount varchar(10); 

#nabil 2012-12-04 
alter table salesjv add salesjv_Reservation date;
alter table salesjv add salesjv_CheckIn date;
alter table salesjv add salesjv_CheckOut date;
alter table salesjv add salesjv_RoomType varchar(30);

alter table Purchasesjv add Purchasejv_Reservation date;
alter table Purchasesjv add Purchasejv_CheckIn date;
alter table Purchasesjv add Purchasejv_CheckOut date;
alter table Purchasesjv add Purchasejv_RoomType varchar(30);


#Tarek 2012-12-05
alter table accesslabelsrocky.login add FC_DiscountPerLimit double default 0;
alter table project add Project_Picture blob;

#Nabil 2012-12-06
alter table project add project_metier varchar(60);
alter table project add project_technician varchar(60);


#Tarek 2012-12-12
alter table module add Module_InvoiceGridPV  tinyint(1) default 1;
alter table module add Module_InvoiceGridRV  tinyint(1) default 1;
alter table module add Module_InvoiceGridCV  tinyint(1) default 1;
alter table module add Module_InvoiceGridDV  tinyint(1) default 1;
alter table module add Module_InvoiceGridCT  tinyint(1) default 1;

#Nabil  2012-12-8  //Sonit
alter table production Add production_WIDTH double default 0;
alter table production Add production_WIDTHTrim double default 0;
alter table production Add production_WIDTHTrimPer double default 0;
alter table production add production_ActualNetWidth double default 0;
alter table production add production_thick double default 0;


#Tarek added by Fady in Nigeria
alter table items add Item_Volume double default 0;
alter table items add Item_Color varchar(165);
alter table items add Item_Size varchar(75);

#Nabil  2012-12-30  //Sonit
alter table production Add production_ActualNetWeight double default 0;
alter table productiondt Add productiondt_Weight double default 0;
alter table productiondt Add productiondt_width double default 0;

#nabil 2013-01-01 vat new procedure
alter table purchasesetup add VATAccountNonStock varchar(10) ;
#INSERT INTO LEDGER (LEDGER_NUMBER,LEDGER_NAME,LEDGER_GRPDET)  VALUES ('442611','VAT STOCK ITEM',1);
#INSERT INTO LEDGER (LEDGER_NUMBER,LEDGER_NAME,LEDGER_GRPDET)  VALUES ('442661','VAT NON-STOCK ITEM',1);
#UPDATE PURCHASESETUP SET VATAccount='44261',VATAccountNonStock='44266';
#UPDATE PURCHASESETUP SET VATAccountNonStock=vataccount;

alter table salessetup add VATAccountNonStock varchar(10) ;
#INSERT INTO LEDGER (LEDGER_NUMBER,LEDGER_NAME,LEDGER_GRPDET)  VALUES ('442711','VAT STOCK ITEM',1);
#INSERT INTO LEDGER (LEDGER_NUMBER,LEDGER_NAME,LEDGER_GRPDET)  VALUES ('442761','VAT NON-STOCK ITEM',1);
#update salessetup set vataccount='44271',VATAccountNonStock='44276'
#UPDATE salessetup SET VATAccountNonStock=vataccount;



#nabil 2013-01-05 //problem in trasfer of account
ALTER TABLE `ledger` 
MODIFY COLUMN `Ledger_dbbase1` DOUBLE DEFAULT 0,
MODIFY COLUMN `Ledger_dbbase2` DOUBLE DEFAULT 0,
MODIFY COLUMN `Ledger_cdbase1` DOUBLE DEFAULT 0,
MODIFY COLUMN `Ledger_cdbase2` DOUBLE DEFAULT 0;


update ledger set Ledger_dbbase1=0 where  Ledger_dbbase1 is null;
update ledger set Ledger_dbbase2=0 where  Ledger_dbbase2 is null;
update ledger set Ledger_cdbase1=0 where  Ledger_cdbase1 is null;
update ledger set Ledger_cdbase2=0 where  Ledger_cdbase2 is null;


#Tarek 2013-01-15
alter table setup add CashReg_Weight tinyint(1) default 0;
alter table setup add CashReg_StartBarcode integer;
alter table setup add CashReg_EndBarcode integer;
alter table setup add CashReg_StartQty integer;
alter table setup add CashReg_EndQty integer;


#Tarek 2013-01-19
alter table setup modify COMPANY_TELEPHONE varchar(30);

#NABIL SICOM
CREATE TABLE `SalesJVLabels` (
  `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `LABEL1` VARCHAR(45),
  `LABEL2` VARCHAR(45),
  `LABEL3` VARCHAR(45),
  `LABEL4` VARCHAR(45),
  `LABEL5` VARCHAR(45),
  `LABEL6` VARCHAR(45),
  `LABEL7` VARCHAR(45),
  `LABEL8` VARCHAR(45),
  `LABEL9` VARCHAR(45),
  `LABEL10` VARCHAR(45),
  `LABEL11` VARCHAR(45),
  `LABEL12` VARCHAR(45),
  `LABEL13` VARCHAR(45),
  `LABEL14` VARCHAR(45),
  `LABEL15` VARCHAR(45),
  `LABEL16` VARCHAR(45),
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;



#Tarek 2013-01-23
alter table retaildt add SaleDt_ActualPrice double default 0;
alter table temp_retaildt add SaleDt_ActualPrice double default 0;


#NABIL CCT 2013-01-24
ALTER TABLE purchasesserialno ADD COLUMN OrgSerialNo_Used TINYINT(1) DEFAULT 0;

#NABIL CCT 2013-02-04 akross
ALTER TABLE  `SalesJVLabels` ADD COLUMN  `LABEL17` VARCHAR(45);
ALTER TABLE  `SalesJVLabels` ADD COLUMN  `LABEL18` VARCHAR(45);
alter table salesjv add column salesJV_formalitydate VARCHAR(45);
alter table salesjv add column salesJV_formalityvalue VARCHAR(45);
ALTER TABLE `salesjv` MODIFY COLUMN `salesJV_ContainerNo` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `setup` add COLUMN `setup_plu` VARCHAR(150) ;




#Tarek 2013-01-02

CREATE TABLE `DivisionTypes` (
  `DivisionTypes_Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `DivisionTypes_Name` VARCHAR(50) NOT NULL,
  `DivisionTypes_Forms` VARCHAR(100) ,
  PRIMARY KEY (`DivisionTypes_Id`)
)
ENGINE = InnoDB;

CREATE TABLE `DivisionTypesDt` (
  `DivisionTypesDt_Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `DivisionTypes_Id` INTEGER UNSIGNED NOT NULL,
  `DivisionTypesDt_Attribute` VARCHAR(50),
  `DivisionTypesDt_Unit` VARCHAR(30),
  PRIMARY KEY (`DivisionTypesDt_Id`),
  CONSTRAINT `FK_DivisionTypesDt_1` FOREIGN KEY `FK_DivisionTypesDt_1` (`DivisionTypes_Id`)
    REFERENCES `divisiontypes` (`DivisionTypes_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;


CREATE TABLE `Divisions` (
  `Divisions_Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `Divisions_Code` VARCHAR(30),
  `Divisions_Name` VARCHAR(50),
  `DivisionTypes_Id` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`Divisions_Id`),
  CONSTRAINT `FK_Divisions_1` FOREIGN KEY `FK_Divisions_1` (`DivisionTypes_Id`)
    REFERENCES `divisiontypes` (`DivisionTypes_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;


CREATE TABLE `DivisionsDt` (
  `DivisionsDt_Id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `Divisions_Id` INTEGER UNSIGNED NOT NULL,
  `DivisionsDt_Name` VARCHAR(50),
  `DivisionsDt_Value` VARCHAR(50),
  PRIMARY KEY (`DivisionsDt_Id`),
  CONSTRAINT `FK_DivisionsDt_1` FOREIGN KEY `FK_DivisionsDt_1` (`Divisions_Id`)
    REFERENCES `divisions` (`Divisions_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;



CREATE TABLE `ProductionHD` (
  `ProductionHD_Id` DOUBLE NOT NULL,
  `ProductionHD_Reference` DOUBLE,
  `ProductionHD_Date` DATETIME,
  `ProductionHD_Remark` VARCHAR(100),
  `ProductionHD_Type` VARCHAR(5) DEFAULT 'P',
  `ProductionHD_ExpireDate` DATETIME,
  `ProductionHD_BatchNo` VARCHAR(40),
  `Journal_Id` DOUBLE,
  `Currency_Code` VARCHAR(6),
  `ProductionHD_Total` DOUBLE DEFAULT 0,
  `ProductionHD_TotalBase1` DOUBLE DEFAULT 0,
  `ProductionHD_TotalBase2` DOUBLE DEFAULT 0,
  `ProductionHD_IdealTotal` DOUBLE DEFAULT 0,
  `ProductionHD_WasteTotal` DOUBLE DEFAULT 0,
  `ProductionHD_BelongsToGroup` INT(11) UNSIGNED DEFAULT 0,
  `ProductionHD_Posted` TINYINT(1) UNSIGNED DEFAULT 0,
  `ProductionHD_Reversed` TINYINT(1) UNSIGNED DEFAULT 0,
  `User_Account` VARCHAR(30),
  PRIMARY KEY (`ProductionHD_Id`)
)
ENGINE = InnoDB;


CREATE TABLE `ProductionRM` (
  `ProductionRM_Id` DOUBLE NOT NULL,
  `ProductionHD_Id` DOUBLE NOT NULL,
  `ProductionHD_Date` DATETIME,
  `Item_Code` VARCHAR(20),
  `Item_CodePacked` VARCHAR(20),
  `Item_QtyPacked` DOUBLE,
  `Warehouse_Code` VARCHAR(15),
  `ProductionRM_Quantity` DOUBLE,
  `ProductionRM_IdealQty` DOUBLE,
  `Currency_Code` VARCHAR(6),
  `ProductionRM_Cost` DOUBLE DEFAULT 0,
  `ProductionRM_CostBase1` DOUBLE DEFAULT 0,
  `ProductionRM_CostBase2` DOUBLE DEFAULT 0,
  `ProductionRM_ExpireDate` DATETIME,
  `ProductionRM_BatchNo` VARCHAR(40),
  `ProductionRM_ItemAccount` VARCHAR(10),
  `ProductionRM_DirectStkDbt` VARCHAR(10),
  `ProductionRM_DirectStkCrd` VARCHAR(10),
  `ProductionRM_DirectStkCur` VARCHAR(6),
  `ProductionRM_Remark` VARCHAR(150),
  `ProductionRM_Waste` DOUBLE DEFAULT 0,
  `ProductionRM_WasteDebit` VARCHAR(10),
  `ProductionRM_WasteCredit` VARCHAR(10),
  `Item_UnitCoef` DOUBLE DEFAULT 0,
  `Item_Unit2Qty` DOUBLE DEFAULT 0,
  `RelatedDt_Id` DOUBLE ,
  `ProductionRM_CostOption` DOUBLE DEFAULT 1,
  `Color_Code` VARCHAR(10),
  `Size_Measure` VARCHAR(15),
  PRIMARY KEY (`ProductionRM_Id`),
  CONSTRAINT `FK_ProductionRM_1` FOREIGN KEY `FK_ProductionRM_1` (`ProductionHD_Id`)
    REFERENCES `productionhd` (`ProductionHD_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


CREATE TABLE `ProductionFG` (
  `ProductionFG_Id` DOUBLE NOT NULL,
  `ProductionHD_Id` DOUBLE NOT NULL,
  `ProductionHD_Date` DATETIME,
  `Item_Code` VARCHAR(20),
  `Item_CodePacked` VARCHAR(20),
  `Item_QtyPacked` DOUBLE,
  `Warehouse_Code` VARCHAR(15),
  `ProductionFG_Quantity` DOUBLE,
  `ProductionFG_IdealQty` DOUBLE,
  `Currency_Code` VARCHAR(6),
  `ProductionFG_Cost` DOUBLE DEFAULT 0,
  `ProductionFG_CostBase1` DOUBLE DEFAULT 0,
  `ProductionFG_CostBase2` DOUBLE DEFAULT 0,
  `ProductionFG_ExpireDate` DATETIME,
  `ProductionFG_BatchNo` VARCHAR(40),
  `ProductionFG_ItemAccount` VARCHAR(10),
  `ProductionFG_DirectStkDbt` VARCHAR(10),
  `ProductionFG_DirectStkCrd` VARCHAR(10),
  `ProductionFG_DirectStkCur` VARCHAR(6),
  `ProductionFG_Remark` VARCHAR(150),
  `ProductionFG_Waste` DOUBLE DEFAULT 0,
  `ProductionFG_WasteDebit` VARCHAR(10),
  `ProductionFG_WasteCredit` VARCHAR(10),
  `Item_UnitCoef` DOUBLE DEFAULT 0,
  `Item_Unit2Qty` DOUBLE DEFAULT 0,
  `RelatedDt_Id` DOUBLE ,
  `ProductionFG_CostOption` DOUBLE DEFAULT 1,
  `Color_Code` VARCHAR(10),
  `Size_Measure` VARCHAR(15),
  PRIMARY KEY (`ProductionFG_Id`),
  CONSTRAINT `FK_ProductionFG_1` FOREIGN KEY `FK_ProductionFG_1` (`ProductionHD_Id`)
    REFERENCES `productionhd` (`ProductionHD_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


CREATE TABLE `ProductionHDDivisions` (
  `ProductionHDDivisions_Id` DOUBLE NOT NULL,
  `ProductionHD_Id` DOUBLE NOT NULL,
  `Divisions_Id` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`ProductionHDDivisions_Id`),
  CONSTRAINT `FK_ProductionHDDivisions_1` FOREIGN KEY `FK_ProductionHDDivisions_1` (`ProductionHD_Id`)
    REFERENCES `productionhd` (`ProductionHD_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_ProductionHDDivisions_2` FOREIGN KEY `FK_ProductionHDDivisions_2` (`Divisions_Id`)
    REFERENCES `divisions` (`Divisions_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;



CREATE TABLE `ProdRecipe` (
  `ProdRecipe_Id` DOUBLE NOT NULL,
  `ProdRecipe_Reference` DOUBLE,
  `ProdRecipe_Date` DATETIME,
  `ProdRecipe_Remark` VARCHAR(100),
  `ProdRecipe_Active` TINYINT(1) DEFAULT 1,
  `ProdRecipe_BelongsToGroup` INT(11) UNSIGNED DEFAULT 0,
  `User_Account` VARCHAR(30),
  PRIMARY KEY (`ProdRecipe_Id`)
)
ENGINE = InnoDB;


CREATE TABLE `ProdRecipeFG` (
  `ProdRecipeFG_Id` DOUBLE NOT NULL,
  `ProdRecipe_Id` DOUBLE NOT NULL,
  `ProdRecipe_Date` DATETIME,
  `Item_Code` VARCHAR(20),
  `Item_CodePacked` VARCHAR(20),
  `Item_QtyPacked` DOUBLE,
  `Warehouse_Code` VARCHAR(15),
  `ProdRecipeFG_Quantity` DOUBLE,
  `ProdRecipeFG_Remark` VARCHAR(150),
  `Item_UnitCoef` DOUBLE DEFAULT 0,
  `Item_Unit2Qty` DOUBLE DEFAULT 0,
  `ProdRecipeFG_DistOption` DOUBLE DEFAULT 1,
  PRIMARY KEY (`ProdRecipeFG_Id`),
  CONSTRAINT `FK_ProdRecipeFG_1` FOREIGN KEY `FK_ProdRecipeFG_1` (`ProdRecipe_Id`)
    REFERENCES `ProdRecipe` (`ProdRecipe_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;

CREATE TABLE `ProdRecipeRM` (
  `ProdRecipeRM_Id` DOUBLE NOT NULL,
  `ProdRecipe_Id` DOUBLE NOT NULL,
  `ProdRecipe_Date` DATETIME,
  `Item_Code` VARCHAR(20),
  `Item_CodePacked` VARCHAR(20),
  `Item_QtyPacked` DOUBLE,
  `Warehouse_Code` VARCHAR(15),
  `ProdRecipeRM_Quantity` DOUBLE,
  `ProdRecipeRM_Remark` VARCHAR(150),
  `Item_UnitCoef` DOUBLE DEFAULT 0,
  `Item_Unit2Qty` DOUBLE DEFAULT 0,
  `ProdRecipeRM_DistOption` DOUBLE DEFAULT 1,
  PRIMARY KEY (`ProdRecipeRM_Id`),
  CONSTRAINT `FK_ProdRecipeRM_1` FOREIGN KEY `FK_ProdRecipeRM_1` (`ProdRecipe_Id`)
    REFERENCES `ProdRecipe` (`ProdRecipe_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


CREATE TABLE `JournalDtDivisions` (
  `JournalDtDivisions_Id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `JournalDt_Id` DOUBLE NOT NULL,
  `DivisionTypes_Name` VARCHAR(50) NOT NULL,
  `Divisions_Code` VARCHAR(30) NOT NULL,
  `JournalDtDivisions_Amount` DOUBLE DEFAULT 0,
  `JournalDtDivisions_Amount1` DOUBLE DEFAULT 0,
  `JournalDtDivisions_Amount2` DOUBLE DEFAULT 0,
  `JournalDtDivisions_PerCent` DOUBLE DEFAULT 0,
  `JournalDtDivisions_Posted` TINYINT(1) DEFAULT 0,
  `Synchronized` TINYINT(1) DEFAULT 0,
  PRIMARY KEY (`JournalDtDivisions_Id`),
  INDEX `Index_2`(`DivisionTypes_Name`),
  INDEX `Index_3`(`Divisions_Code`),
  CONSTRAINT `FK_journaldtdivisions_1` FOREIGN KEY `FK_journaldtdivisions_1` (`JournalDt_Id`)
    REFERENCES `journaldt` (`Journaldt_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


CREATE TABLE `AdjustmentDivisions` (
  `AdjustmentDivisions_Id` DOUBLE NOT NULL,
  `Adjustment_Id` DOUBLE NOT NULL,
  `Divisions_Id` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`AdjustmentDivisions_Id`),
  CONSTRAINT `FK_AdjustmentDivisions_1` FOREIGN KEY `FK_AdjustmentDivisions_1` (`Adjustment_Id`)
    REFERENCES `Adjustment` (`Adjustment_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_AdjustmentDivisions_2` FOREIGN KEY `FK_AdjustmentDivisions_2` (`Divisions_Id`)
    REFERENCES `divisions` (`Divisions_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;

create table Temp_AdjustmentDivisions like AdjustmentDivisions;




alter table Module add Module_BatchNo Tinyint(1) default 0;

#alter table Adjustment add Adjustment_Production Tinyint(1) default 0;
#alter table Temp_Adjustment add Adjustment_Production Tinyint(1) default 0;

alter table adjustment add Entry_Type varchar(20);
alter table temp_adjustment add Entry_Type varchar(20);

alter table AdjustmentDt add AdjustmentDt_ExpireDate datetime;
alter table AdjustmentDt add AdjustmentDt_BatchNo varchar(40);
alter table Temp_AdjustmentDt add AdjustmentDt_ExpireDate datetime;
alter table Temp_AdjustmentDt add AdjustmentDt_BatchNo varchar(40);

alter table StkTransaction add Item_ExpireDate datetime;
alter table StkTransaction add Item_BatchNo varchar(40);

alter table accesslabelsrocky.loginstk add Machine_Code varchar(15);
alter table accesslabelsrocky.loginstk add Default_Machine tinyint(1) default 0;

alter table sequence add ProdRecipe_Id double;
alter table sequence add ProdRecipe_Reference double;
alter table sequence add ProdRecipeRM_Id double;
alter table sequence add ProdRecipeFG_Id double;

alter table sequence add ProductionHD_Id double;
alter table sequence add ProductionHD_Reference double;
alter table sequence add ProductionHDDivisions_Id double;
alter table sequence add ProductionRM_Id double;
alter table sequence add ProductionFG_Id double;

alter table sequence add AdjustmentDivisions_Id double;


alter table purchasesserialno add ProductionFG_ID double;
alter table temp_purchasesserialno add ProductionFG_ID double;
alter table purchasesserialno add ProductionRM_ID double;
alter table temp_purchasesserialno add ProductionRM_ID double;

alter table purchasesserialno modify Journal_Type varchar(4);
alter table temp_purchasesserialno modify Journal_Type varchar(4);


alter table Module add Module_RestrictMachine tinyint(1) default 1;
alter table StkTransaction add Machine_Code varchar(15);


alter table accesslabelsrocky.login add FI_ProductionTemp tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ProductionTempApp tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ProductionTempDel tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ProductionTempMod tinyint(1) default 0;


#Tarek 2013-02-06
alter table Vendor add Vendor_Commission double default 0;
alter table module add Module_CashRegAutoItemsList tinyint(1) default 0;

#nabil 2013-02-06 desil
alter table setup add column setup_ItemDtGrid double default 0;

#nabil 2013-02-16   //sonit
alter table sordersetup add column sorder_bank1 varchar(100);
alter table sordersetup add column sorder_bank2 varchar(100);
alter table sordersetup add column sorder_bank3 varchar(100);
alter table production add column production_BabyQuantity double default 1;
alter table accesslabelsrocky.login add column RI_INVENTORY2 tinyint(1) default 0;

#NABIIL 2013-02-20
ALTER TABLE `itemjour` DROP FOREIGN KEY `itemjourjournaldt_id`;


#NABIL AS COMPANY 2013-03-04
CREATE TABLE `BRANCHES` (
  `BRANCH_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `BRANCH_CODE` VARCHAR(20) NOT NULL,
  `BRANCH_NAME` VARCHAR(100) NOT NULL,
  PRIMARY KEY (`BRANCH_ID`)
)
ENGINE = InnoDB;

ALTER TABLE `branches` ADD INDEX `Index_BranchCode`(`BRANCH_CODE`);


ALTER TABLE JOURNAL ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE `journal` ADD CONSTRAINT `FK_journal_Branch` FOREIGN KEY `FK_journal_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

ALTER TABLE TRANS ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE TRANS ADD CONSTRAINT `FK_TRANS_Branch` FOREIGN KEY `FK_TRANS_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE SALESJV ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE SALESJV ADD CONSTRAINT `FK_SALESJV_Branch` FOREIGN KEY `FK_SALESJV_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE PURCHASESJV ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE PURCHASESJV ADD CONSTRAINT `FK_PURCHASESJV_Branch` FOREIGN KEY `FK_PURCHASESJV_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;



ALTER TABLE PREQUEST ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE PREQUEST ADD CONSTRAINT `FK_PREQUEST_Branch` FOREIGN KEY `FK_PREQUEST_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;



ALTER TABLE PORDER ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE PORDER ADD CONSTRAINT `FK_PORDER_Branch` FOREIGN KEY `FK_PORDER_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;



ALTER TABLE PURCHASES ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE PURCHASES ADD CONSTRAINT `FK_PURCHASES_Branch` FOREIGN KEY `FK_PURCHASES_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;



ALTER TABLE SORDER ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE SORDER ADD CONSTRAINT `FK_SORDER_Branch` FOREIGN KEY `FK_SORDER_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;



ALTER TABLE DELIVERIES ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE DELIVERIES ADD CONSTRAINT `FK_DELIVERIES_Branch` FOREIGN KEY `FK_DELIVERIES_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE SALES ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE SALES ADD CONSTRAINT `FK_SALES_Branch` FOREIGN KEY `FK_SALES_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;



ALTER TABLE TRANSFER ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE TRANSFER ADD CONSTRAINT `FK_TRANSFER_Branch` FOREIGN KEY `FK_TRANSFER_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE ADJUSTMENT ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE ADJUSTMENT ADD CONSTRAINT `FK_ADJUSTMENT_Branch` FOREIGN KEY `FK_ADJUSTMENT_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


ALTER TABLE RMA ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE RMA ADD CONSTRAINT `FK_RMA_Branch` FOREIGN KEY `FK_RMA_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;
	
ALTER TABLE production ADD COLUMN BRANCH_CODE VARCHAR(20);
ALTER TABLE production ADD CONSTRAINT `FK_production_Branch` FOREIGN KEY `FK_production_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


alter table accesslabelsrocky.users add column BRANCH_CODE VARCHAR(20);
ALTER table module add column module_branch tinyint(1) default 0;


#Tarek 2013-03-04
#Added by Elie

CREATE TABLE  `clientsdetail` (

  `Detail_code` varchar(50) NOT NULL,
  `detail_name` varchar(100) DEFAULT NULL,
  `Ledger_number` varchar(10) DEFAULT NULL,
  `detail_remark` varchar(100) DEFAULT NULL,
  `detail_address` varchar(100) DEFAULT NULL,
  `Detail_ID` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`Detail_code`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 

alter table items add column item_zeroPrice boolean default 0;
alter table sorderdt add column user_account varchar(50);
alter table temp_sorderdt add column user_account varchar(50);
alter table deliverydt add column user_account varchar(50);
alter table temp_deliverydt add column user_account varchar(50);
alter table salesdt add column user_account varchar(50);
alter table temp_salesdt add column user_account varchar(50);
alter table module add column Module_ZeroQuantity boolean ;
alter table items add column item_id double;
alter table warehouse add column warehouse_id double;
alter table transdt add user_account varchar(50);
alter table temp_transdt add user_account varchar(50);
alter table cstjourdt add user_account varchar(50);
alter table temp_cstjourdt add user_account varchar(50);
alter table billjour add user_account varchar(50);
alter table temp_billjour add user_account varchar(50);
alter table chkjour add user_account varchar(50);
alter table temp_chkjour add user_account varchar(50);
alter table chkjourdt add user_account varchar(50);
alter table temp_chkjourdt add user_account varchar(50);
alter table journaldt add user_account varchar(50);
alter table temp_journaldt add user_account varchar(50);
alter table cstjour add user_account varchar(50);
alter table temp_cstjourdt add user_account varchar(50);
alter table acclink add user_account varchar(50);
alter table temp_acclink add user_account varchar(50);




#Tarek 2013-02-15
alter table accesslabelsrocky.login add FI_Charges tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ChargesApp tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ChargesMod tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ChargesDel tinyint(1) default 0;


alter table purchasechargessetup add Distribution_Method int(11) default 1;


CREATE TABLE `ChargesHD` (
  `Charges_Id` DOUBLE NOT NULL,
  `Charges_Reference` DOUBLE,
  `Charges_Date` DATETIME,
  `Charges_Remark` VARCHAR(200),
  `Charges_Posted` TINYINT(1) DEFAULT 0,
  `Charges_BelongsToGroup` INT(1) DEFAULT 0,
  `Journal_Id` DOUBLE,
  `Journal_Type` VARCHAR(2),
  `User_Account` VARCHAR(30),
  PRIMARY KEY (`Charges_Id`)
)
ENGINE = InnoDB;


CREATE TABLE `ChargesDT` (
  `ChargesDt_Id` DOUBLE NOT NULL,
  `Charges_Id` DOUBLE NOT NULL,
  `ChargesDt_DistOption` INT(11) DEFAULT 1,
  `Currency_Code` VARCHAR(6),
  `ChargesDt_Total` DOUBLE DEFAULT 0,
  `ChargesDt_TotalBase1` DOUBLE DEFAULT 0,
  `ChargesDt_TotalBase2` DOUBLE DEFAULT 0,
  `ChargesDt_DebitAccount` VARCHAR(10),
  `ChargesDt_CreditAccount` VARCHAR(10),
  `ChargesDt_GenerateDebit` TINYINT(1) DEFAULT 0,
  `ChargesDt_isVat` TINYINT(1) DEFAULT 0,
  PRIMARY KEY (`ChargesDt_Id`),
  CONSTRAINT `FK_ChargesDt_1` FOREIGN KEY `FK_ChargesDt_1` (`Charges_Id`)
    REFERENCES `chargesHD` (`Charges_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


CREATE TABLE `ChargesPurchases` (
  `ChargesPurchases_Id` DOUBLE NOT NULL,
  `Charges_Id` DOUBLE,
  `Purchase_Id` DOUBLE,
  `ChargesPurchases_Closed` TINYINT(1) default 0,
  PRIMARY KEY (`ChargesPurchases_Id`),
  CONSTRAINT `FK_ChargesPurchases_1` FOREIGN KEY `FK_ChargesPurchases_1` (`Charges_Id`)
    REFERENCES `chargesHD` (`Charges_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_ChargesPurchases_2` FOREIGN KEY `FK_ChargesPurchases_2` (`Purchase_Id`)
    REFERENCES `purchases` (`Purchase_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;


CREATE TABLE `ChargesItems` (
  `ChargesItems_Id` DOUBLE NOT NULL,
  `ChargesPurchases_Id` DOUBLE,
  `Purchase_Id` DOUBLE,
  `PurchaseDt_Id` DOUBLE,
  `ChargesItems_Volume` DOUBLE,
  `Currency_Code` VARCHAR(6),
  `ChargesItems_Amount` DOUBLE DEFAULT 0,
  `ChargesItems_AmountB1` DOUBLE DEFAULT 0,
  `ChargesItems_AmountB2` DOUBLE DEFAULT 0,
  `ChargesItems_Perc` DOUBLE DEFAULT 0,
  `ChargesItems_ItemAccount` VARCHAR(10),
  PRIMARY KEY (`ChargesItems_Id`),
  CONSTRAINT `FK_ChargesItems_1` FOREIGN KEY `FK_ChargesItems_1` (`ChargesPurchases_Id`)
    REFERENCES `chargespurchases` (`ChargesPurchases_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_ChargesItems_2` FOREIGN KEY `FK_ChargesItems_2` (`Purchase_Id`)
    REFERENCES `purchases` (`Purchase_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT,
  CONSTRAINT `FK_ChargesItems_3` FOREIGN KEY `FK_ChargesItems_3` (`PurchaseDt_Id`)
    REFERENCES `purchasesdt` (`PurchaseDt_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;



CREATE TABLE `ChargesItemsDt` (
  `ChargesItemsDt_Id` DOUBLE NOT NULL,
  `ChargesItems_Id` DOUBLE,
  `ChargesItemsDt_DebitAccount` VARCHAR(10),
  `ChargesItemsDt_CreditAccount` VARCHAR(10),
  `Currency_Code` VARCHAR(6),
  `ChargesItemsDt_Amount` DOUBLE DEFAULT 0,
  `ChargesItemsDt_AmountB1` DOUBLE DEFAULT 0,
  `ChargesItemsDt_AmountB2` DOUBLE DEFAULT 0,
  PRIMARY KEY (`ChargesItemsDt_Id`),
  CONSTRAINT `FK_ChargesItemsDt_1` FOREIGN KEY `FK_ChargesItemsDt_1` (`ChargesItems_Id`)
    REFERENCES `chargesitems` (`ChargesItems_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


alter table sequence add Charges_Id double;
alter table sequence add Charges_Reference double;
alter table sequence add ChargesDt_Id double;
alter table sequence add ChargesPurchases_Id double;
alter table sequence add ChargesItems_Id double;
alter table sequence add ChargesItemsDt_Id double;

alter table module add Module_ChargesShowProject tinyint(1) default 1;
alter table module add Module_ChargesShowCostCent tinyint(1) default 1;

#nabil 2013-02-07 as company
CREATE TABLE `DeliveryPay` (
  `DeliveryPay_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Delivery_id` BIGINT UNSIGNED NOT NULL,
  `DeliveryPay_Date` DATE NOT NULL,
  `DeliveryPay_Amount` DOUBLE NOT NULL,
  PRIMARY KEY (`DeliveryPay_id`)
)
ENGINE = InnoDB;

ALTER TABLE `deliverypay` ADD INDEX `Index_DeliveryPayDeliveryId`(`Delivery_id`);
ALTER TABLE `deliverypay` MODIFY COLUMN `Delivery_id` DOUBLE NOT NULL,
 ADD CONSTRAINT `FK_deliverypay_deliveryid` FOREIGN KEY `FK_deliverypay_deliveryid` (`Delivery_id`)
    REFERENCES `deliveries` (`Delivery_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;
alter table DeliveryPay add DeliveryPay_Percentage double not null default 0;

ALTER TABLE ITEMS ADD BRANCH_CODE VARCHAR(20);
ALTER TABLE ITEMS ADD CONSTRAINT `FK_ITEMS_Branch` FOREIGN KEY `FK_ITEMS_Branch` (`BRANCH_CODE`)
    REFERENCES `branches` (`BRANCH_CODE`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


#Tarek 2013-03-11
alter table setup add CashReg_Price tinyint(1) default 0;
alter table setup add CashReg_StartPrice integer;
alter table setup add CashReg_EndPrice integer;


#Tarek 2013-03-11
alter table module add Module_NegativeQtyJV tinyint(1) default 0;

#Tarek 2013-03-15
alter table module add Module_SorderCheckQtyOnPost tinyint(1) default 1;


#Tarek 2013-03-21
alter table cashregister add CashRegister_LedDescLength int(11);


#Tarek 2013-03-30
alter table setup add CashReg_DispLedMsg varchar(20);

#Tarek 2013-03-30
alter table accesslabelsrocky.login add FI_ProductionReq tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ProductionReqApp tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ProductionReqDel tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ProductionReqMod tinyint(1) default 0;



CREATE TABLE `ProductionRequest` (
  `ProductionReq_Id` DOUBLE NOT NULL,
  `ProductionReq_Reference` DOUBLE,
  `ProductionReq_Date` DATETIME,
  `ProductionReq_Remark` VARCHAR(100),
  `ProductionReq_Manager` VARCHAR(100),
  `ProductionReq_Shift` VARCHAR(100),
  `ProductionReq_BelongsToGroup` INT(11) UNSIGNED DEFAULT 0,
  `ProductionReq_Posted` TINYINT(1) UNSIGNED DEFAULT 0,
  `ProductionReq_Confirmed` TINYINT(1) UNSIGNED DEFAULT 0,
  `User_Account` VARCHAR(30),
  PRIMARY KEY (`ProductionReq_Id`)
)
ENGINE = InnoDB;


CREATE TABLE `ProductionReqRM` (
  `ProductionReqRM_Id` DOUBLE NOT NULL,
  `ProductionReq_Id` DOUBLE NOT NULL,
  `ProductionReq_Date` DATETIME,
  `Item_Code` VARCHAR(20),
  `Item_CodePacked` VARCHAR(20),
  `Item_QtyPacked` DOUBLE,
  `Warehouse_Code` VARCHAR(15),
  `ProductionReqRM_Quantity` DOUBLE,
  `Item_CodeFinished` varchar(50), 
  `Item_UnitCoef` DOUBLE DEFAULT 0,
  `Item_Unit2Qty` DOUBLE DEFAULT 0,
  PRIMARY KEY (`ProductionReqRM_Id`),
  CONSTRAINT `FK_ProductionReqRM_1` FOREIGN KEY `FK_ProductionReqRM_1` (`ProductionReq_Id`)
    REFERENCES `productionrequest` (`ProductionReq_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


CREATE TABLE `ProductionReqFG` (
  `ProductionReqFG_Id` DOUBLE NOT NULL,
  `ProductionReq_Id` DOUBLE NOT NULL,
  `ProductionReq_Date` DATETIME,
  `Item_Code` VARCHAR(20),
  `Item_CodePacked` VARCHAR(20),
  `Item_QtyPacked` DOUBLE,
  `Warehouse_Code` VARCHAR(15),
  `ProductionReqFG_Quantity` DOUBLE,
  `Item_UnitCoef` DOUBLE DEFAULT 0,
  `Item_Unit2Qty` DOUBLE DEFAULT 0,
  `ProdRecipe_Id` DOUBLE,
  PRIMARY KEY (`ProductionReqFG_Id`),
  CONSTRAINT `FK_ProductionReqFG_1` FOREIGN KEY `FK_ProductionReqFG_1` (`ProductionReq_Id`)
    REFERENCES `productionrequest` (`ProductionReq_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;



alter table sequence add ProductionReq_Id double;
alter table sequence add ProductionReq_Reference double;
alter table sequence add ProductionReqRM_Id double;
alter table sequence add ProductionReqFG_Id double;


#Tarek 2013-04-05
alter table salessetup add
( BonusAccount varchar(10),
  ExportBonusToJV tinyint(1) default 0
);

alter table deliveries add
(Delivery_TransportTTC      double default 0,
 Delivery_BonusAccount      varchar(10),
 Delivery_BonusAmount       double default 0,
 Delivery_BonusBase1        double default 0,
 Delivery_BonusBase2        double default 0,
 Delivery_BonusTTC          double default 0
);

alter table temp_deliveries add
(Delivery_TransportTTC      double default 0,
 Delivery_BonusAccount      varchar(10),
 Delivery_BonusAmount       double default 0,
 Delivery_BonusBase1        double default 0,
 Delivery_BonusBase2        double default 0,
 Delivery_BonusTTC          double default 0
);


alter table Deliverydt add
(DeliveryDt_BonusAmount       double default 0,
 DeliveryDt_BonusBase1        double default 0,
 DeliveryDt_BonusBase2        double default 0
);

alter table temp_Deliverydt add
(DeliveryDt_BonusAmount       double default 0,
 DeliveryDt_BonusBase1        double default 0,
 DeliveryDt_BonusBase2        double default 0
);



#Nabil 2013-04-01
CREATE TABLE  `accesslabelsrocky`.`companyemails` (
  `CompanyEmail_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `company_name` varchar(45) NOT NULL,
  `CompanyEmail_type` varchar(45) NOT NULL,
  `CompanyEmail_Title` varchar(45) NOT NULL,
  `CompanyEmail_address` varchar(45) NOT NULL,
  PRIMARY KEY (`CompanyEmail_id`)
) ENGINE=InnoDB;

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `employee_id` VARCHAR(12);
alter table accesslabelsrocky.login add column FP_EmployeeRequest tinyint(1) default 0;

#Nabil 2013-04-04
ALTER TABLE `accesslabelsrocky`.`queries` MODIFY COLUMN `query_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT;

CREATE TABLE `accesslabelsrocky`.`queriesdt` (
  `querydt_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `query_id` BIGINT UNSIGNED NOT NULL,
  `user_account` VARCHAR(10) NOT NULL,
  PRIMARY KEY (`querydt_id`)
)
ENGINE = InnoDB;

ALTER TABLE `accesslabelsrocky`.`queriesdt` ADD INDEX `Index_quereyid`(`query_id`),
 ADD INDEX `Index_user`(`user_account`);
ALTER TABLE `accesslabelsrocky`.`queriesdt` ADD CONSTRAINT `FK_queriesdt_queryid` FOREIGN KEY `FK_queriesdt_queryid` (`query_id`)
    REFERENCES `queries` (`query_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;


#Tarek 2013-04-09
alter table module add Module_CashRegItemQtyInCode tinyint(1) default 0;


#Tarek 2013-04-11
alter table accesslabelsrocky.login add FI_AllowEditIfDelivered tinyint(1) default 0;

#nABIL 2013-04-13
UPDATE accesslabelsrocky.reportoptionsAcc_label SET Tab6='Difference of Exchange';


#Tarek 2013-04-15
alter table ProductionFG add ProductionReqFG_Id double;
alter table Temp_ProductionFG add ProductionReqFG_Id double;
alter table ProductionRM add ProductionReqRM_Id double;
alter table Temp_ProductionRM add ProductionReqRM_Id double;



#Tarek 2013-04-18
ALTER TABLE `prepaymentm` 
 ADD COLUMN `PrePaymentM_Id` DOUBLE NOT NULL AFTER `GenerateRef`,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY  USING BTREE(`PrePaymentM_Id`, `Ledger_number`);



ALTER TABLE `prepaymentd` 
 ADD COLUMN `PrePaymentD_Id` DOUBLE NOT NULL AFTER `GenerateRef`,
 ADD COLUMN `PrePaymentM_Id` DOUBLE NOT NULL AFTER `PrePaymentD_Id`,
 ADD CONSTRAINT `FK_prepaymentd_6` FOREIGN KEY `FK_prepaymentd_6` (`PrePaymentM_Id`)
    REFERENCES `prepaymentm` (`PrePaymentM_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;



alter table sequence add PrePaymentM_Id double;
alter table sequence add PrePaymentD_Id double;


#Tarek 2013-04-25
alter table accesslabelsrocky.login add Login_CancelSorder tinyint(1) default 0;



#Tarek 2013-04-26
alter table salessetup add SorderComment varchar(500);
alter table accesslabelsrocky.login add Allow_MinimumPrice tinyint(1) default 1;
alter table items add Item_MinimumPrice double default 0;


#Tarek 2013-04-30
alter table module add Module_RestaurantDelivery tinyint(1) DEFAULT '0';
alter table retail add SaleOrder_Id double;
alter table retail add SaleOrder_Reference double;
alter table temp_retail add SaleOrder_Id double;
alter table temp_retail add SaleOrder_Reference double;




#NABIL 2013-05-07 ABBOUND 
CREATE TABLE `CostcentAttribute` (
  `CostcentAttribute_id` BIGINT NOT NULL AUTO_INCREMENT,
  `Costcent_id` BIGINT NOT NULL,
  `CostcentAttribute_name` VARCHAR(45) NOT NULL,
  `currency_code` VARCHAR(6) NOT NULL,
  `CostcentAttribute_price` DOUBLE NOT NULL DEFAULT 0,
  `CostcentAttribute_Sdate` date NOT NULL,
  `CostcentAttribute_Edate` date ,
  PRIMARY KEY (`CostcentAttribute_id`)
)
ENGINE = InnoDB;

alter table costcent add costcent_id bigint default 0;

ALTER TABLE `costcentattribute` ADD INDEX `Index_CostCentID`(`Costcent_id`);
ALTER TABLE `costcent` ADD INDEX `Index_CostcentID`(`costcent_id`);
ALTER TABLE `costcentattribute` ADD CONSTRAINT `FK_costcentattribute_CostCentID` FOREIGN KEY `FK_costcentattribute_CostCentID` (`costcent_id`)
    REFERENCES `costcent` (`costcent_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

alter table clients add client_id bigint default 0;
ALTER TABLE `clients` ADD INDEX `Index_ClientID`(`client_id`);

CREATE TABLE `ClientCounter` (
  `ClientCounter_id` BIGINT NOT NULL AUTO_INCREMENT,
  `client_id` BIGINT NOT NULL,
  `ClientCounter_code` varchar(20),
  `costcent_code` varchar(20),
  PRIMARY KEY (`ClientCounter_id`)
)
ENGINE = InnoDB;

ALTER TABLE `clientcounter` ADD INDEX `Index_clientcounterID`(`clientcounter_id`);

ALTER TABLE `clientcounter` ADD CONSTRAINT `FK_clientcounter_ClientID` FOREIGN KEY `FK_clientcounter_ClientID` (`client_id`)
    REFERENCES `clients` (`client_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;

	
CREATE TABLE `ClientCounterdt` (
  `ClientCounterdt_id` BIGINT NOT NULL AUTO_INCREMENT,
  `ClientCounter_id` BIGINT NOT NULL,
  `ClientCounterdt_StartDate` date ,
  `ClientCounterdt_EndDate` date ,
	clientcounterdt_OldCounter BIGINT NOT NULL default 0,
	clientcounterdt_NewCounter BIGINT NOT NULL default 0,
  PRIMARY KEY (`ClientCounterdt_id`)
)
ENGINE = InnoDB;


ALTER TABLE `clientcounterdt` ADD CONSTRAINT `FK_clientcounterdt_ClientCounterID` FOREIGN KEY `FK_clientcounterdt_ClientCounterID` (`clientcounter_id`)
    REFERENCES `clientcounter` (`clientcounter_id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT;




START TRANSACTION;
SET @C:=SELECT IFNULL(MAX(CLIENT_ID),0) FROM CLIENTS;
UPDATE CLIENTS SET CLIENT_ID=(@C:=@C+1) WHERE CLIENT_ID =0 OR CLIENT_ID IS NULL;
COMMIT;

START TRANSACTION;
SET @C:=SELECT IFNULL(MAX(COSTCENT_ID),0) FROM COSTCENT;
UPDATE COSTCENT SET COSTCENT_ID=(@C:=@C+1) WHERE COSTCENT_ID =0 OR COSTCENT_ID IS NULL;
COMMIT;


#CLIENTS FORM AND COSTCENTER FORM

alter table clientcounterdt add column clientcounterdt_generated tinyint(1);




#Tarek 2013-05-03
alter table ProductionFG add ProductionFG_InitialQty double default 0;
alter table ProductionFG add ProductionFG_DamageQty double default 0;
alter table ProductionFG add ProductionFG_RemixQty double default 0;
alter table Temp_ProductionFG add ProductionFG_InitialQty double default 0;
alter table Temp_ProductionFG add ProductionFG_DamageQty double default 0;
alter table Temp_ProductionFG add ProductionFG_RemixQty double default 0;


#Tarek 2013-05-08
alter table PurchasesDt add Related_Ref double;
alter table Temp_PurchasesDt add Related_Ref double;

#nabil 2013-05-27  cct: this special field to link company with bmb table bmb_reference_companies
alter table setup add companyseq_id bigint(10);
#update setup set companyseq_id=1; for cct company
#update setup set companyseq_id=2; for cct tpro

alter table purchasesdt add column purchasedt_usedqty float;
alter table deliverydt add column deliverydt_usedqty float;

#maroun 2013-05-31
ALTER TABLE `module` ADD COLUMN `Module_Unit1Method` TINYINT(1) DEFAULT 1;	


#Tarek 2013-06-03
alter table ProdRecipeFG add ProdRecipeFG_QuantityFrom double after Warehouse_Code;
alter table ProdRecipeRM add ProdRecipeRM_QuantityFrom double after Warehouse_Code;

#nabil 2013-06-03 //equip
alter table prepaymentg add column Journal_BelongsToGroup bigint(11);


#Tarek 2013-06-04
alter table deliverydt add DeliveryDt_ClosingQuantity double default 0;
alter table temp_deliverydt add DeliveryDt_ClosingQuantity double default 0;

alter table module add Module_DeliveryClosingQty tinyint(1) default 0;

#Tarek 2013-06-08

alter table paymentrqst add
(PaymentRqst_App tinyint(1)default 0,
 PaymentRqst_Confirmed tinyint(1)default 0,
 Touser_account varchar(50),
 User_Confirmed varchar(50)
);

alter table accesslabelsrocky.login add
(Login_Daily tinyint(1)default 0,
 Login_Weekly tinyint(1)default 0,
 Login_Monthly tinyint(1)default 0,
 Login_Limit double default 0,
 AllowedPaymentDirect tinyint(1) default 0,
 Branch_Manager tinyint(1) default 0
);

alter table module add Module_PaymentLimit tinyint(1) default 0;


alter table trans add Trans_Confirmed tinyint(1) default 0;
alter table trans add Trans_UserConfirmed varchar(45);
alter table temp_trans add Trans_Confirmed tinyint(1) default 0;
alter table temp_trans add Trans_UserConfirmed varchar(45);



#nabil 2013-06-15 sonit  print delivery by warehouse
alter table salessetup add PrintDeliveryByWarehouse tinyint(1) default 0;

#nabil 2013-06-19 tpro rma
ALTER TABLE accesslabelsrocky.configurationemail ADD ReceivermailBCC2 VARCHAR(100);


#Tarek 2013-06-24

CREATE TABLE `ProductionReqDivisions` (
  `ProductionReqDivisions_Id` DOUBLE NOT NULL,
  `ProductionReq_Id` DOUBLE NOT NULL,
  `Divisions_Id` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`ProductionReqDivisions_Id`),
  CONSTRAINT `FK_ProductionReqDivisions_1` FOREIGN KEY `FK_ProductionReqDivisions_1` (`ProductionReq_Id`)
    REFERENCES `productionrequest` (`ProductionReq_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_ProductionReqDivisions_2` FOREIGN KEY `FK_ProductionReqDivisions_2` (`Divisions_Id`)
    REFERENCES `divisions` (`Divisions_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;

alter table sequence add ProductionReqDivisions_Id double;

create table Temp_ProductionReqDivisions like ProductionReqDivisions;

#Tarek 2013-06-27
alter table ProductionReqRM add ProductionReqFG_Id DOUBLE;
alter table Temp_ProductionReqRM add ProductionReqFG_Id DOUBLE;



#Tarek 2013-07-02

CREATE TABLE `ProductionSummaryRM` (
  `ProductionSummaryRM_Id` DOUBLE NOT NULL,
  `ProductionHD_Id` DOUBLE NOT NULL,
  `Item_Code` VARCHAR(20),
  `ProductionSummaryRM_Quantity` DOUBLE,
  `ProductionSummaryRM_IdealQty` DOUBLE,
  `ProductionSummaryRM_Multiplier` DOUBLE DEFAULT 0,
  PRIMARY KEY (`ProductionSummaryRM_Id`),
  CONSTRAINT `FK_ProductionSummaryRM_1` FOREIGN KEY `FK_ProductionSummaryRM_1` (`ProductionHD_Id`)
    REFERENCES `productionhd` (`ProductionHD_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE
)
ENGINE = InnoDB;


alter table sequence add ProductionSummaryRM_Id double;
create table Temp_ProductionSummaryRM like ProductionSummaryRM;


#Tarek 2013-07-03
alter table module add Module_ChangeInvoiceClient tinyint(1) default 0;
alter table module add Module_ChangeInvoiceItems tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ChangeInvoiceClient tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_ChangeInvoiceItems tinyint(1) default 0;

#NABIL 2013-07-04 
alter table accesslabelsrocky.login add FA_TOPVAT TINYINT(1);
alter table MODULE add MODULE_TOPVAT TINYINT(1);


#Tarek 2013-07-10
alter table module add Module_ProjectParent tinyint(1) default 1;
alter table module add Module_CostCenterParent tinyint(1) default 1;

#Tarek 2013-07-12
alter table accesslabelsrocky.login add FI_FrmRestrictWarehouse tinyint(1) default 0;



#Tarek 2013-07-13

CREATE TABLE `AdjustmentDtDivisions` (
  `AdjustmentDtDivisions_Id` DOUBLE NOT NULL,
  `AdjustmentDt_Id` DOUBLE NOT NULL,
  `Divisions_Id` INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY (`AdjustmentDtDivisions_Id`),
  CONSTRAINT `FK_AdjustmentDtDivisions_1` FOREIGN KEY `FK_AdjustmentDtDivisions_1` (`AdjustmentDt_Id`)
    REFERENCES `AdjustmentDt` (`AdjustmentDt_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE,
  CONSTRAINT `FK_AdjustmentDtDivisions_2` FOREIGN KEY `FK_AdjustmentDtDivisions_2` (`Divisions_Id`)
    REFERENCES `divisions` (`Divisions_Id`)
    ON DELETE RESTRICT
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;

alter table sequence add AdjustmentDtDivisions_Id double;

create table Temp_AdjustmentDtDivisions like AdjustmentDtDivisions;


alter table module add Module_Divisions tinyint(1) default 1;
alter table module add Module_DivisionsDt tinyint(1) default 0;

alter table DivisionTypes add DivisionTypes_Master tinyint(1) default 1;


#shukri sicom 2013-07-24
ALTER TABLE `deliveries` ADD COLUMN `delivery_iban` VARCHAR(45) ;
ALTER TABLE `deliveries` ADD COLUMN `delivery_bankdetails` VARCHAR(45) ;

#nabil  2013-08-06  solicar if sorder_produced =1 it will show in production plan and it will not show in pending sorder
#alter table sorder add column sorder_produced tinyint default 0;
#alter table sorder add column sorder_produced INT(11) default 0;
#ALTER TABLE sorder MODIFY COLUMN `sorder_produced` INTEGER DEFAULT 0;
alter table sorder add column sorder_produced INTEGER default 0;

#nabil 2013-08-21  abboud 
alter table ipaddress add  IPAddress_3Phase tinyint(1) default 0;
alter table costcent add CostCent_MonoPhase double default 0;
alter table costcent add CostCent_3Phase double default 0;
alter table costcent add CostCent_NoofHours double default 0;
alter table costcent add CostCent_OfficalPrice double default 0;
alter table costcent add CostCent_3PhasePrice double default 0;

#nabil 2013-09-09  tpro 
ALTER TABLE `rmadt` MODIFY COLUMN `RMADt_Remark` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_informedon` DATE;
ALTER TABLE `rmadt`  ADD COLUMN `rmadt_repliedon` DATE;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_backfromsrvon` DATE;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_physicalDamage` tinyint(1) default 0;
ALTER TABLE `rmadt` ADD COLUMN `rmadt_DOA` tinyint(1) default 0;

ALTER TABLE `rmadt` ADD COLUMN `rmadt_servicecenter` VARCHAR(1000) CHARACTER SET utf8 COLLATE utf8_general_ci;

#nabil 2013-09-18 tpro 
ALTER TABLE RMADT ADD COLUMN RMADT_PROBLEMCATEGORY VARCHAR(100);
CREATE TABLE `PROBLEMCATEGORY` (
  `PROBLEMCATEGORY` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `PROBLEMCATEGORY_NAME` VARCHAR(100) NOT NULL,
  PRIMARY KEY (`PROBLEMCATEGORY`),
  INDEX `Index_PCAT`(`PROBLEMCATEGORY_NAME`)
)
ENGINE = InnoDB;

insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('PCBA');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('LCD SCREEN');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('TOUCH SCREEN');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('BATTERY');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('POWER ADAPTOR');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('USB POWER CABLE');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('SPEAKER');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('WIFI');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('OTHERS');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('INLET');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('SOFTWARE');
insert into PROBLEMCATEGORY (PROBLEMCATEGORY_name) values ('BUTTONS');



#Tarek 2013-09-19
alter table prodreciperm add
(Currency_Code varchar(6),
 ProdRecipeRM_Cost double,
 ProdRecipeRM_CostBase1 double,
 ProdRecipeRM_CostBase2 double,
 ProdRecipeRM_WasteRate double,
 ProdRecipeRM_WastePerBillet double
);

alter table productionrm add
(ProductionRM_WasteRate double,
 ProductionRM_WastePerBillet double
);

alter table temp_productionrm add
(ProductionRM_WasteRate double,
 ProductionRM_WastePerBillet double
);



#Tarek 2013-09-25
alter table module add Module_UniqueManualNo tinyint(1) default 0;

#Tarek 2013-09-26
alter table module add Module_CreditLimitCheckPend tinyint(1) default 0;

#Tarek 2013-09-27
CREATE TABLE `adjustmenttypes` (
  `AdjustmentType_Id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `AdjustmentType_Code` VARCHAR(150) NOT NULL,
  `DebitAccount` VARCHAR(10),
  `CreditAccount` VARCHAR(10),
  `AdjustmentType_Default` TINYINT(1) DEFAULT 0,
  PRIMARY KEY (`AdjustmentType_Id`)
)
ENGINE = InnoDB;


#Tarek 2013-10-09
alter table transdt add TransDt_ManualNo varchar(45);
alter table temp_transdt add TransDt_ManualNo varchar(45);

alter table salesjvdt add SalesJvDt_ManualNo varchar(45);
alter table temp_salesjvdt add SalesJvDt_ManualNo varchar(45);

alter table purchasesjvdt add PurchaseJvDt_ManualNo varchar(45);
alter table temp_purchasesjvdt add PurchaseJvDt_ManualNo varchar(45);

alter table module add Module_PurchasesJvWHT  tinyint(1) default 0;

alter table purchasesjv add
(PurchaseJV_WHTPer double default 0,
 PurchaseJV_WHTAmt double default 0,
 [REDACTED] double default 0,
 [REDACTED] double default 0,
 PurchaseJV_WHTChk tinyint(1) default 0,
 PurchaseJV_WHTAccount varchar(10)
);

alter table temp_purchasesjv add
(PurchaseJV_WHTPer double default 0,
 PurchaseJV_WHTAmt double default 0,
 [REDACTED] double default 0,
 [REDACTED] double default 0,
 PurchaseJV_WHTChk tinyint(1) default 0,
 PurchaseJV_WHTAccount varchar(10)
);



#Gilbert 2013-10-2
alter table setup add column maxperpage double;

alter table CURRENCY add column CURRENCY_ID BIGINT UNSIGNED default 0;
alter table LEDGER add column LEDGER_ID BIGINT  UNSIGNED default 0;

#NABIL 2013-10-08
ALTER TABLE `closingtemplate` ADD COLUMN `TRANSACTION_TYPE` VARCHAR(3) NOT NULL ;
UPDATE closingtEmplate set TRANSACTION_TYPE='CLS' WHERE TRANSACTION_TYPE IS NULL OR TRANSACTION_TYPE='';

#Ralph 2013-10-10
alter table accesslabelsrocky.login add Logistics tinyint(1) default 0;
#Ralph 2013-10-11
alter table accesslabelsrocky.login add FL_Proforma  tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaSetup tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaMod tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaDel tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaApp tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaSetupMod tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaSetupDel tinyint(1) default 0;
alter table accesslabelsrocky.login add FL_ProformaSetupApp tinyint(1) default 0;



#Gilbert 2013-10-17
ALTER TABLE sequence
ADD COLUMN currency_id DOUBLE;

ALTER TABLE sequence
ADD COLUMN warehouse_id DOUBLE;

#Tarek 2013-10-16
alter table ledger add Ledger_WHT tinyint(1) default 0;

alter table salesjv add SalesJv_ManualNo varchar(45);
alter table temp_salesjv add SalesJv_ManualNo varchar(45);

alter table purchasesjv add PurchaseJv_ManualNo varchar(45);
alter table temp_purchasesjv add PurchaseJv_ManualNo varchar(45);

alter table deliveries add Delivery_ManualNo varchar(45);
alter table temp_deliveries add Delivery_ManualNo varchar(45);

alter table sales add Sale_ManualNo varchar(45);
alter table temp_sales add Sale_ManualNo varchar(45);

#Gilbert 2013-10-22
Alter table LedgerGrp add column LedgerGrp_Id bigint(20);
alter table module add column Module_Transportation tinyint(1);



#nabil 2013-10-29
ALTER TABLE `rma` ADD COLUMN `rma_saleid`  BIGINT UNSIGNED NOT NULL DEFAULT 0 ;
ALTER TABLE `rma` ADD COLUMN `rma_sreturnid`  BIGINT UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `rmadt` ADD COLUMN `RMADT_SALEPRICE` FLOAT NOT NULL DEFAULT 0 ;
ALTER TABLE `rmadt` ADD COLUMN `RMADT_SRETURNPRICE` FLOAT NOT NULL DEFAULT 0 ;
ALTER TABLE `rmadt` ADD COLUMN `RMADT_SALEWAREHOUSE` VARCHAR(15) ;
ALTER TABLE `rmadt` ADD COLUMN `RMADT_SRETURNWAREHOUSE` VARCHAR(15) ;
alter table module add module_returnRMATOSales tinyint(1) default 0;
ALTER TABLE `rmadt` ADD COLUMN RMADT_Salevat tinyint(1) default 0;
ALTER TABLE `rmadt` ADD COLUMN RMADT_ReturnSalevat tinyint(1) default 0;


#Ralph 2013-10-31


ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SalesmenCommission` TINYINT(1) DEFAULT 0;

#Gilbert 2013-10-31
ALTER TABLE `ledgergrp` MODIFY COLUMN `LedgerGrp_Id` BIGINT(20) NOT NULL AUTO_INCREMENT,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY (`LedgerGrp_Id`);


#Tarek 2013-10-22
alter table accesslabelsrocky.login add FA_InvoicesAllocation tinyint(1) default 0;



alter table acclink add
(
  Return_Ref  double,
  Return_Type  varchar(2),
  Sale_ReturnAmnt double,
  Sale_ReturnAmntbase1 double,
  Sale_ReturnAmntbase2 double
);


#DROP TABLE IF EXISTS `accesslabelsrocky`.`acclink`;
CREATE TABLE  `accesslabelsrocky`.`acclink`
(
  `ACC_Id` int(11) NOT NULL AUTO_INCREMENT,
  
   `Journal_Id` double DEFAULT NULL,
  
   `Link_Ref` double DEFAULT NULL,
  
   `Link_Type` varchar(2) DEFAULT NULL,
  
   `Journal_Type` varchar(20) DEFAULT NULL,
  
   `Sale_NetTotal` double DEFAULT NULL,
  
   `Sale_PaidAmnt` double DEFAULT NULL,
  
   `Sale_RemainAmnt` double DEFAULT NULL,
  
   `Sale_NetTotalBase1` double DEFAULT NULL,
  
   `Sale_NetTotalBase2` double DEFAULT NULL,
  
   `Sale_PaidAmntbase1` double DEFAULT NULL,
  
   `Sale_PaidAmntbase2` double DEFAULT NULL,
  
   `Sale_RemainAmntBase1` double DEFAULT NULL,
  
   `Sale_RemainAmntBase2` double DEFAULT NULL,
  
   `Synchronized` tinyint(1) DEFAULT '0',
  
   `Sale_NetToPay` double DEFAULT NULL,
  
   `Sale_NetToPayBase1` double DEFAULT NULL,
  
   `Sale_NetToPayBase2` double DEFAULT NULL,
  
   `Trajournal_ID` float DEFAULT NULL,
  
   `PayJournal_ID` double DEFAULT NULL,
  
   `Trans_Ref` double DEFAULT NULL,
  
   `user_account` varchar(50) DEFAULT NULL,
  
   `Return_Ref` double DEFAULT NULL,
  
   `Return_Type` varchar(2) DEFAULT NULL,
  
   `Sale_ReturnAmnt` double DEFAULT NULL,
  
   `Sale_ReturnAmntbase1` double DEFAULT NULL,
  
   `Sale_ReturnAmntbase2` double DEFAULT NULL,
  
   `CompanyName` varchar(25) DEFAULT NULL,
  
   `DirYear` varchar(25) DEFAULT NULL,
  
   `Link_DirYear` varchar(25) DEFAULT NULL,
  
   PRIMARY KEY (`ACC_Id`),
  
   KEY `LinkIndex` (`Link_Ref`,`Link_Type`) USING BTREE,
  
   KEY `JourIndex` (`Journal_Id`,`Journal_Type`),
  
   KEY `ReturnIndex` (`Return_Ref`,`Return_Type`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;


ALTER TABLE `accesslabelsrocky`.`acclink`
 ADD INDEX `CompanyIndex`(`CompanyName`),
 ADD INDEX `YearIndex`(`DirYear`),
 ADD INDEX `LinkYearIndex`(`Link_DirYear`);


alter table `accesslabelsrocky`.temp_acclink add
(
  Return_Ref  double,
  Return_Type  varchar(2),
  Sale_ReturnAmnt double,
  Sale_ReturnAmntbase1 double,
  Sale_ReturnAmntbase2 double
);

alter table `accesslabelsrocky`.acclink add
(
  Return_Ref  double,
  Return_Type  varchar(2),
  Sale_ReturnAmnt double,
  Sale_ReturnAmntbase1 double,
  Sale_ReturnAmntbase2 double
);


#Tarek 2013-10-30
alter table items add Item_Expire tinyint(1) default 0;

alter table purchasesdt add PurchaseDt_BatchNo varchar(40);
alter table temp_purchasesdt add PurchaseDt_BatchNo varchar(40);

alter table grnpurchasesdt add PurchaseDt_BatchNo varchar(40);
alter table temp_grnpurchasesdt add PurchaseDt_BatchNo varchar(40);

alter table StkTransaction add Item_ExpireDate datetime;
alter table StkTransaction add Item_BatchNo varchar(40);

alter table purchasesserialno add Item_ExpireDate datetime;
alter table purchasesserialno add Item_BatchNo varchar(40);
alter table temp_purchasesserialno add Item_ExpireDate datetime;
alter table temp_purchasesserialno add Item_BatchNo varchar(40);

alter table deliverydt add DeliveryDt_BatchNo varchar(40);
alter table temp_deliverydt add DeliveryDt_BatchNo varchar(40);

alter table salesdt add SaleDt_BatchNo varchar(40);
alter table temp_salesdt add SaleDt_BatchNo varchar(40);

alter table production add Production_BatchNo varchar(40);
alter table productiondt add ProductionDt_BatchNo varchar(40);
alter table temp_production add Production_BatchNo varchar(40);
alter table temp_productiondt add ProductionDt_BatchNo varchar(40);


alter table ProductionFG add
( Project_Code  varchar(15),
  CostCenter_Code  varchar(15)
);
alter table Temp_ProductionFG add
( Project_Code  varchar(15),
  CostCenter_Code  varchar(15)
);
alter table ProductionRM add
( Project_Code  varchar(15),
  CostCenter_Code  varchar(15)
);
alter table Temp_ProductionRM add
( Project_Code  varchar(15),
  CostCenter_Code  varchar(15)
);

alter table ProductionHD add
( Project_Code  varchar(15),
  CostCenter_Code  varchar(15)
);
alter table Temp_ProductionHD add
( Project_Code  varchar(15),
  CostCenter_Code  varchar(15)
);



#maroun 06.11.2013
alter table accesslabelsrocky.login add FI_VehcileLoad tinyint(1) default 0;
alter table module add Module_VehicleWeight tinyint(1);

alter table Sorder add Sorder_vehicalno varchar(30);
alter table Sorder add Sorder_drivername varchar(30);
alter table Sorder add Sorder_vehicleweight double;
alter table temp_Sorder add Sorder_vehicalno varchar(30);
alter table temp_Sorder add Sorder_drivername varchar(30);
alter table temp_Sorder add Sorder_vehicleweight double;



alter table deliveries add Delivery_vehicleLoadweight double;
alter table temp_deliveries add Delivery_vehicleLoadweight double;
alter table deliveries add Delivery_vehicleweight double;
alter table temp_deliveries add Delivery_vehicleweight double;

alter table sales add Sale_vehicleLoadweight double;
alter table temp_sales add Sale_vehicleLoadweight double;
alter table sales add Sale_vehicleweight double;
alter table temp_sales add Sale_vehicleweight double;


alter table module add Module_VehicleWeight tinyint(1);
alter table temp_Sorder add Sorder_vehicalno varchar(30);
alter table temp_Sorder add Sorder_drivername varchar(30);
alter table temp_Sorder add Sorder_vehicleweight double;

alter table sales add Sale_vehicleLoadweight double;
alter table temp_sales add Sale_vehicleLoadweight double;
alter table sales add Sale_vehicleweight double;
alter table temp_sales add Sale_vehicleweight double;


#nabil 06-11-2013 CCT
CREATE TABLE `SRorder` (
  `SRorder_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `SRorder_Reference` BIGINT UNSIGNED NOT NULL,
  `SRorder_date` DATETIME NOT NULL,
  `SRorder_Remark` VARCHAR(100) NOT NULL,
  `client_code` VARCHAR(10) NOT NULL,
  `SRorder_Confirmed` BOOLEAN NOT NULL DEFAULT 0,
  `currency_code` VARCHAR(6) NOT NULL,
  `SRorder_ValueDate` DATETIME NOT NULL,
  `SRorder_Taxable` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_TaxableBase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_TaxableBase2` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_noneTaxable` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_noneTaxableBase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_noneTaxableBase2` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_Total` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_TotalBase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_TotalBase2` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_DiscountPer` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_DiscountAmount` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_DiscountAmountBase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_DiscountAmountBase2` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_VAT` tinyint(1) DEFAULT 0,
  `SRorder_VATAmount` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_VATAmountBase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorder_VATAmountBase2` DOUBLE NOT NULL DEFAULT 0,
  PRIMARY KEY (`SRorder_id`)
)
ENGINE = InnoDB;

CREATE TABLE `SRorderDt` (
  `SRorderDt_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `SRorder_id` BIGINT UNSIGNED NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `SRorder_date` DATETIME NOT NULL,
  `SRorderDt_Quantity` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDt_price` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDt_pricebase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDt_Pricebase2` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDT_discountPer` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDt_DiscountAmount` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDT_DiscountAmountBase1` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDT_DiscountAmountBase2` DOUBLE NOT NULL DEFAULT 0,
  `SRorderDt_Remark` VARCHAR(45) NOT NULL,
  `client_code` VARCHAR(10) NOT NULL,
  `currency_code` VARCHAR(6) NOT NULL,
  `Warehouse_Code` VARCHAR(15) NOT NULL,
  `Item_vat` DOUBLE NOT NULL DEFAULT 0,
  
  PRIMARY KEY (`SRorderDt_id`)
)
ENGINE = InnoDB;



ALTER TABLE `srorderdt` ADD CONSTRAINT `FK_srorderID` FOREIGN KEY `FK_srorderID` (`SRorder_id`)
    REFERENCES `srorder` (`SRorder_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
alter table sequence add column SRorder_id double default 0;
alter table sequence add column SRorder_Reference double default 0;


#nabil 08-11-2013 CCT
CREATE TABLE `PRorder` (
  `PRorder_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `PRorder_Reference` BIGINT UNSIGNED NOT NULL,
  `PRorder_date` DATETIME NOT NULL,
  `PRorder_Remark` VARCHAR(100) NOT NULL,
  `Supplier_code` VARCHAR(10) NOT NULL,
  `PRorder_Confirmed` BOOLEAN NOT NULL DEFAULT 0,
  `currency_code` VARCHAR(6) NOT NULL,
  `PRorder_ValueDate` DATETIME NOT NULL,
  `PRorder_Taxable` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_TaxableBase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_TaxableBase2` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_noneTaxable` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_noneTaxableBase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_noneTaxableBase2` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_Total` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_TotalBase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_TotalBase2` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_DiscountPer` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_DiscountAmount` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_DiscountAmountBase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_DiscountAmountBase2` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_VAT` tinyint(1) DEFAULT 0,
  `PRorder_VATAmount` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_VATAmountBase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorder_VATAmountBase2` DOUBLE NOT NULL DEFAULT 0,
  PRIMARY KEY (`PRorder_id`)
)
ENGINE = InnoDB;

CREATE TABLE `PRorderDt` (
  `PRorderDt_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `PRorder_id` BIGINT UNSIGNED NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `PRorder_date` DATETIME NOT NULL,
  `PRorderDt_Quantity` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDt_price` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDt_pricebase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDt_Pricebase2` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDT_discountPer` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDt_DiscountAmount` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDT_DiscountAmountBase1` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDT_DiscountAmountBase2` DOUBLE NOT NULL DEFAULT 0,
  `PRorderDt_Remark` VARCHAR(45) NOT NULL,
  `Supplier_code` VARCHAR(10) NOT NULL,
  `currency_code` VARCHAR(6) NOT NULL,
  `Warehouse_Code` VARCHAR(15) NOT NULL,
  `Item_vat` DOUBLE NOT NULL DEFAULT 0,
  
  PRIMARY KEY (`PRorderDt_id`)
)
ENGINE = InnoDB;



ALTER TABLE `PRorderdt` ADD CONSTRAINT `FK_PRorderID` FOREIGN KEY `FK_PRorderID` (`PRorder_id`)
    REFERENCES `PRorder` (`PRorder_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
alter table sequence add column PRorder_id double default 0;
alter table sequence add column PRorder_Reference double default 0;

alter table accesslabelsrocky.login add column FI_RetrunSaleOrder tinyint(1) default 0;
alter table accesslabelsrocky.login add column FI_ReturnPurchaseOrder tinyint(1)  default 0;

#Gilbert 2013-11-8
alter table accesslabelsrocky.login add CRM tinyint(1) default 0;

#maroun 2013-11-09
Alter table prequest add PRqst_Total double default 0;
Alter table prequest add PRqst_TotalBase1 double default 0;
Alter table prequest add PRqst_TotalBase2 double default 0;
Alter table prequest add PRqst_Type varchar(3);
alter table prequest add Prqst_Confirmed tinyint(1) default 0;
alter table prequest add Prqst_Import tinyint(1) default 0;
alter table prequest add Prqst_VATChckbx tinyint(1) default 0;

alter table module add Module_PRequestConfirm tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_PRequestConfirmed tinyint(1) default 0;



alter table prequestdt add PRqstDt_PriceTTC double default 0;
alter table prequestdt add Item_Tax1 double;
alter table prequestdt add Item_Tax2 double;
alter table prequestdt add Item_Tax3 double;
alter table prequestdt add Item_Tax4 double;
alter table prequestdt add Item_Tax5 double;

create table temp_prequest like prequest;
alter table temp_prequest add logged_code varchar(100);


create table temp_prequestdt like prequestdt;
alter table temp_prequestdt add logged_code varchar(100);
alter table prequest add Expiry_date datetime;
alter table temp_prequest add Expiry_date datetime;
ALTER TABLE `prequestdt` ADD COLUMN `Item_QtyPacked` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE  `prequestdt`ADD COLUMN `Item_CodePacked` VARCHAR(21) ;
ALTER TABLE `temp_prequestdt` ADD COLUMN `Item_QtyPacked` DOUBLE NOT NULL DEFAULT 0 ;
ALTER TABLE  `temp_prequestdt`ADD COLUMN `Item_CodePacked` VARCHAR(21) ;
alter table prequestdt add PRqstDt_PriceTTCBase1 double;
alter table prequestdt add PRqstDt_PriceTTCBase2 double;
alter table temp_prequestdt add PRqstDt_PriceTTCBase1 double;
alter table temp_prequestdt add PRqstDt_PriceTTCBase2 double;
alter table prequestdt add item_description varchar(100);
alter table temp_prequestdt add item_description varchar(100);
alter table accesslabelsrocky.login add FI_PurchaseRequestItems tinyint(1) default 0;
alter table prequestdt add PRqstDt_OQuantity double;
alter table prequestdt add PRqstDt_CQuantity double;
alter table temp_prequestdt add PRqstDt_OQuantity double;
alter table temp_prequestdt add PRqstDt_CQuantity double;
alter table prequestdt add PRqstDt_status varchar(1);
alter table temp_prequestdt add PRqstDt_status varchar(1);




#nabil 2013-11-09
alter table purchasesdt add column  prorderdt_id double;
alter table purchases add column  prorder_id double;
alter table deliverydt add column  srorderdt_id double;
alter table deliveries add column  srorder_id double;

ALTER TABLE PURCHASES ADD COLUMN PURCHASE_LOADHHT TINYINT(1) DEFAULT 0;
ALTER TABLE DELIVERIES ADD COLUMN DELIVERY_LOADHHT TINYINT(1) DEFAULT 0;

#nabil 2013-11-11 to check bug of empty type in trans
CREATE TABLE `logtrans` (
  `logtrans_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `trans_id` double ,
  `trans_type` VARCHAR(45) ,
  `trans_date` DATETIME ,
  `trans_reference` double ,
  `logtrans_date` DATETIME ,
  PRIMARY KEY (`logtrans_id`)
);

#nabil 2013-11-11 cct
CREATE TABLE `PTransfer` (
  `PTransfer_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `PTransfer_Reference` BIGINT UNSIGNED NOT NULL,
  `PTransfer_date` DATETIME NOT NULL,
  `PTransfer_Remark` VARCHAR(100) NOT NULL,
  `WAREHOUSE_codeFrom` VARCHAR(15) NOT NULL,
  `WAREHOUSE_codeTo` VARCHAR(15) NOT NULL,
  `PTransfer_Confirmed` BOOLEAN NOT NULL DEFAULT 0,
  PRIMARY KEY (`PTransfer_id`)
)
ENGINE = InnoDB;

CREATE TABLE `PTransferDt` (
  `PTransferDt_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `PTransfer_id` BIGINT UNSIGNED NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `PTransfer_date` DATETIME NOT NULL,
  `PTransferDt_Quantity` DOUBLE NOT NULL DEFAULT 0,
  `PTransferDt_Remark` VARCHAR(45) NOT NULL,
  `Warehouse_CodeFrom` VARCHAR(15) NOT NULL,
  `Warehouse_CodeTo` VARCHAR(15) NOT NULL,
  PRIMARY KEY (`PTransferDt_id`)
)
ENGINE = InnoDB;
alter table sequence add column PTRANSFER_id double default 0;
alter table sequence add column PTRANSFER_Reference double default 0;
alter table transfer add column PTRANSFER_id double default 0;
alter table transferdt add column PTRANSFERdt_id double default 0;

ALTER TABLE TRANSFER ADD COLUMN Transfer_LOADHHT TINYINT(1) DEFAULT 0;
alter table accesslabelsrocky.login add column FI_PRETransfer tinyint(1) default 0;


#Gilbert 2013-11-14
alter table clientsip add column service_name varchar(60);
#Tarek 2013-11-14
alter table accesslabelsrocky.login add FA_Invoicing tinyint(1) default 0;

#Gilbert 2013-11-25
update setup set maxperpage=20 where maxperpage is null;


#Tarek 2013-11-26
alter table module add Module_ReceiptLoadSorder tinyint(1) default 0;
alter table Sorder add Sorder_Invoiced tinyint(1) default 0;


#maroun 2013-11-29
#DROP TABLE IF EXISTS `transferrequest`;
CREATE TABLE  `transferrequest` (
  `Transferrequest_Id` double NOT NULL,
  `Transferrequest_Reference` double DEFAULT NULL,
  `Transferrequest_Date` datetime DEFAULT NULL,
  `Transferrequest_Remark` varchar(100) DEFAULT NULL,
  `Transferrequest_Posted` tinyint(1) DEFAULT '0',
  `Transferrequest_Edit` tinyint(1) DEFAULT '0',
  `Project_code1` varchar(15) DEFAULT NULL,
  `Project_code2` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `Journal_id` double DEFAULT NULL,
  `TransferRequestDt_ID` double DEFAULT NULL,
  `SendReceive_Reference` double DEFAULT NULL,
  `TransferRequest_BelongsToGroup` int(11) DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Adjustment_id` double DEFAULT NULL,
  `Driver_Name` varchar(100) DEFAULT NULL,
  `Vehicle_No` varchar(100) DEFAULT NULL,
  `f_Date` varchar(45) DEFAULT NULL,
  `Requestedby` varchar(45) DEFAULT NULL,
  `User_account` varchar(30) DEFAULT NULL,
  `Company_Name` varchar(45) DEFAULT NULL,
  `Transferrequest_WarehouseFrom` varchar(15) DEFAULT NULL,
  `Transferrequest_WarehouseTo` varchar(15) DEFAULT NULL,
  `ToCostcenter_Code` varchar(15) DEFAULT NULL,
  `Document_RefNo` varchar(50) DEFAULT NULL,
  `Transferrequest_Type` varchar(2) DEFAULT 'TR',
  `Sorder_reference` double DEFAULT NULL,
  `documentrefno` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`Transferrequest_Id`) USING BTREE,
  KEY `transferproject_code1` (`Project_code1`),
  KEY `transferproject_code2` (`Project_code2`),
  KEY `transfercostcent_code` (`Costcenter_Code`),
  KEY `Reference` (`Transferrequest_Reference`) USING BTREE,
  KEY `Date` (`Transferrequest_Date`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#DROP TABLE IF EXISTS  `transferrequestdt`;
CREATE TABLE   `transferrequestdt` (
  `TransferrequestDt_id` double NOT NULL,
  `Transferrequest_Id` double DEFAULT NULL,
  `Transferrequest_Date` datetime DEFAULT NULL,
  `Item_Barcode` varchar(40) DEFAULT NULL,
  `Item_code` varchar(20) DEFAULT NULL,
  `Size_Measure` varchar(10) DEFAULT NULL,
  `TransferrequestDt_WarehouseFrom` varchar(15) DEFAULT NULL,
  `TransferrequestDt_WarehouseTo` varchar(15) DEFAULT NULL,
  `TransferrequestDt_Quantity` double DEFAULT '1',
  `TransferrequestDt_ExpireDate` datetime DEFAULT NULL,
  `TransferrequestDt_Price` double DEFAULT NULL,
  `TransferrequestDt_PriceBase1` double DEFAULT NULL,
  `TransferrequestDt_PriceBase2` double DEFAULT NULL,
  `Transferrequest_Posted` tinyint(1) DEFAULT '0',
  `Project_Code1` varchar(15) DEFAULT NULL,
  `Project_Code2` varchar(15) DEFAULT NULL,
  `Costcent_Code` varchar(15) DEFAULT NULL,
  `Transferrequestdt_remark` varchar(100) DEFAULT NULL,
  `Color_Code` varchar(15) DEFAULT NULL,
  `Cur_code` varchar(20) DEFAULT 'NGN',
  `Transferrequestdt_posted` tinyint(1) DEFAULT '0',
  `PreProduction_Serial` varchar(20) DEFAULT NULL,
  `Item_CodePacked` varchar(20) DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Item_qtyPacked` double DEFAULT NULL,
  `TransferrequestDt_DirectStkDbt` varchar(10) DEFAULT NULL,
  `TransferrequestDt_DirectStkCrd` varchar(10) DEFAULT NULL,
  `TransferrequestDt_DirectStkCur` varchar(10) DEFAULT NULL,
  `TransferrequestDt_PricePerUnit` double DEFAULT '0',
  `TransferrequestDt_QtyUnit` double DEFAULT '0',
  `Date` varchar(25) DEFAULT NULL,
  `Item_ManufacturedCode` varchar(20) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `relateddt_id` double DEFAULT NULL,
  `ToCostcent_Code` varchar(15) DEFAULT NULL,
  `Item_CodeFinished` varchar(20) DEFAULT NULL,
  `Item_CodeSemiFinished` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`TransferrequestDt_id`) USING BTREE,
  KEY `Itemcode` (`Item_code`),
  KEY `Project1` (`Project_Code1`),
  KEY `Project2` (`Project_Code2`),
  KEY `PreProdSerial` (`PreProduction_Serial`),
  KEY `transferdtcostcent_code` (`Costcent_Code`),
  KEY `relatedid` (`relateddt_id`) USING BTREE,
  KEY `ItemWarehouseFrom` (`Item_code`,`TransferrequestDt_WarehouseFrom`) USING BTREE,
  KEY `ItemWarehouseTo` (`Item_code`,`TransferrequestDt_WarehouseTo`) USING BTREE,
  KEY `itemdate` (`Item_code`,`Transferrequest_Date`) USING BTREE,
  KEY `ItemDateWarehouseFrom` (`Item_code`,`Transferrequest_Date`,`TransferrequestDt_WarehouseFrom`) USING BTREE,
  KEY `IdItemWhTo` (`Transferrequest_Id`,`Item_code`,`TransferrequestDt_WarehouseTo`) USING BTREE,
  KEY `TransferID` (`Transferrequest_Id`) USING BTREE,
  KEY `TransferIDItem` (`Transferrequest_Id`,`Item_code`) USING BTREE,
  KEY `ItemWhToPrepSerial` (`Item_code`,`TransferrequestDt_WarehouseTo`,`PreProduction_Serial`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

alter table accesslabelsrocky.login add FI_TransferRequest tinyint(1) default 0;
create table Temp_TransferRequest like TransferRequest;
create table Temp_TransferRequestDt like TransferRequestDt;
alter table Temp_transferRequest add logged_code varchar(50);
alter table Temp_transferRequestdt add logged_code varchar(50);
alter table sequence add TransferRequest_reference double;
alter table sequence add TransferRequest_id double;
alter table sequence add TransferRequestDt_id double;
alter table transferrequestdt add TransferrequestDt_status varchar(1);
alter table module add Module_PurchaseRequestPrice tinyint(1);
Alter table transfer add Transferrequest_Id bigint;
Alter table transferdt add Transferrequest_Reference double;
Alter table transferdt add Transferrequestdt_Id double;
Alter table temp_transfer add Transferrequest_Id bigint;
Alter table temp_transferdt add Transferrequest_Reference double;
Alter table temp_transferdt add Transferrequestdt_Id double;

Alter table porder add PRqst_id bigint;
Alter table porderdt add PRqst_Reference double;
Alter table porderdt add PRqstdt_id double;
Alter table temp_porder add PRqst_id bigint;
Alter table temp_porderdt add PRqst_Reference double;
Alter table temp_porderdt add PRqstdt_id double;
alter table module add Module_TransferRequestPrice tinyint(1);
alter table accesslabelsrocky.login add FI_AdjustmentRequest tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_OUTREQUEST tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_OutappRequest tinyint(1) default 0;
alter table accesslabelsrocky.login add Login_FastPrintRequest tinyint(1) default 0;

#DROP TABLE IF EXISTS `adjustmentrequest`;
CREATE TABLE  `adjustmentrequest` (
  `Adjustmentrequest_Id` double NOT NULL,
  `Adjustmentrequest_Reference` double DEFAULT NULL,
  `Adjustmentrequest_Date` datetime DEFAULT NULL,
  `Adjustmentrequest_Remak` varchar(100) DEFAULT NULL,
  `Adjustmentrequest_posted` tinyint(1) DEFAULT '0',
  `Currency_Code` varchar(6) DEFAULT NULL,
  `AdjustmentRequest_Amount` double DEFAULT '0',
  `AdjustmentRequest_AmountBase1` double DEFAULT '0',
  `AdjustmentRequest_AmountBase2` double DEFAULT '0',
  `Costcent_Code` varchar(15) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Journal_id` double DEFAULT NULL,
  `Invdebitaccount` varchar(10) DEFAULT NULL,
  `Invcreditaccount` varchar(10) DEFAULT NULL,
  `AdjustmentRequest_isInvoice` tinyint(1) DEFAULT '0',
  `AdjustmentRequest_BelongsToGroup` int(11) DEFAULT NULL,
  `Mach_code` varchar(18) DEFAULT NULL,
  `Item_code` varchar(23) DEFAULT NULL,
  `AdjustmentRequest_hours` double DEFAULT NULL,
  `AdjustmentRequest_Type` varchar(4) DEFAULT NULL,
  `Sendreceive_reference` double DEFAULT NULL,
  `AdjustmentRequest_RateBase1` double DEFAULT '0',
  `AdjustmentRequest_RateBase2` double DEFAULT '0',
  `AdjustmentRequest_Rate` double DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `adjustmentRequest_isinv_dstk` tinyint(1) NOT NULL DEFAULT '0',
  `AdjustmentRequest_EntryType` varchar(1) DEFAULT NULL,
  `Tag_Reference` varchar(15) DEFAULT NULL,
  `AdjustmentRequest_RequestBy` varchar(100) DEFAULT NULL,
  `User_account` varchar(30) DEFAULT NULL,
  `AdjustmentRequest_asset` tinyint(1) DEFAULT '0',
  `adjustmentRequest_TotalQuantity` double DEFAULT NULL,
  `Entry_Type` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`Adjustmentrequest_Id`) USING BTREE,
  KEY `adjustmentproject_code` (`Project_Code`),
  KEY `adjustmentcostcent_code` (`Costcent_Code`),
  KEY `Index_Journalid` (`Journal_id`),
  KEY `Index_Journal` (`Journal_id`),
  KEY `Reference` (`Adjustmentrequest_Reference`) USING BTREE,
  KEY `Date` (`Adjustmentrequest_Date`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


#DROP TABLE IF EXISTS `adjustmentrequestdt`;
CREATE TABLE  `adjustmentrequestdt` (
  `AdjustmentRequestDt_Id` double NOT NULL,
  `AdjustmentRequest_Id` double DEFAULT NULL,
  `AdjustmentRequest_Date` datetime DEFAULT NULL,
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `Item_Code` varchar(20) DEFAULT NULL,
  `AdjustmentRequestDt_Quantity` double DEFAULT '1',
  `AdjustmentRequestDt_Posted` tinyint(1) DEFAULT '0',
  `Color_Code` varchar(10) DEFAULT NULL,
  `Costcent_Code` varchar(15) DEFAULT NULL,
  `Project_code` varchar(15) DEFAULT NULL,
  `Size_measure` varchar(10) DEFAULT NULL,
  `AdjustmentRequestDt_Price` double DEFAULT '0',
  `AdjustmentRequestDt_PriceBase1` double DEFAULT '0',
  `AdjustmentRequestDt_PriceBase2` double DEFAULT '0',
  `AdjustmentRequestDt_ExistingQty` double DEFAULT NULL,
  `AdjustmentRequestDt_PhysicalQty` double DEFAULT '0',
  `Item_Barcode` varchar(40) DEFAULT NULL,
  `Journal_Type` varchar(2) DEFAULT NULL,
  `AdjustmentRequestDt_DirectStkDbt` varchar(10) DEFAULT NULL,
  `AdjustmentRequestDt_DirectStkCrd` varchar(10) DEFAULT NULL,
  `AdjustmentRequestDt_DirectStkCur` varchar(10) DEFAULT NULL,
  `Deliverydt_id` double DEFAULT NULL,
  `Item_codepacked` varchar(20) DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Item_qtyPacked` double DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Tag_Reference` varchar(15) DEFAULT NULL,
  `AdjustmentDt_PricePerUnit` double DEFAULT '0',
  `AdjustmentDt_QtyUnit` double DEFAULT '0',
  `Item_ManufacturedCode` varchar(20) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `AdjustmentRequestdt_AssetPrice` double DEFAULT '0',
  `AdjustmentRequestDt_ExpireDate` datetime DEFAULT NULL,
  `AdjustmentRequestDt_BatchNo` varchar(40) DEFAULT NULL,
  PRIMARY KEY (`AdjustmentRequestDt_Id`) USING BTREE,
  KEY `ItemWarehouseCode` (`Item_Code`,`Warehouse_Code`),
  KEY `ItemCode` (`Item_Code`),
  KEY `adjustmentdtproject_code` (`Project_code`),
  KEY `adjustmentdtcostcent_code` (`Costcent_Code`),
  KEY `adjustmentdtwarehouse_code` (`Warehouse_Code`),
  KEY `ItemDate` (`Item_Code`,`AdjustmentRequest_Date`) USING BTREE,
  KEY `IDItemWarehouseType` (`AdjustmentRequest_Id`,`Item_Code`,`Warehouse_Code`,`Journal_Type`) USING BTREE,
  KEY `IdCodeWareProjCost` (`AdjustmentRequest_Id`,`Item_Code`,`Warehouse_Code`,`Project_code`,`Costcent_Code`) USING BTREE,
  KEY `IdItemWarehouse` (`AdjustmentRequest_Id`,`Item_Code`,`Warehouse_Code`) USING BTREE,
  KEY `adjustmentdtadjustment_id` (`AdjustmentRequest_Id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


Create table Temp_AdjustmentRequest like AdjustmentRequest;
Create table Temp_AdjustmentRequestDt like AdjustmentRequestDt;
alter table sequence add AdjustmentRequest_id double;
alter table sequence add AdjustmentRequestDt_id double;
alter table sequence add OUTRequest_Reference varchar(50);
alter table Temp_adjustmentrequest add logged_code varchar(50);
alter table Temp_adjustmentrequestDT add logged_code varchar(50);
alter table AdjustmentRequestDt add AdjustmentRequestDt_status varchar(3);
alter table temp_AdjustmentRequestDt add AdjustmentRequestDt_status varchar(3);

Alter table adjustmentdt add adjustmentrequest_Reference double;
Alter table adjustmentdt add adjustmentrequestdt_Id double;
Alter table adjustment add adjustmentrequest_Id bigint;
Alter table temp_adjustment add adjustmentrequest_Id bigint;
Alter table temp_adjustmentdt add adjustmentrequest_Reference double;
Alter table temp_adjustmentdt add adjustmentrequestdt_Id double;
Alter table adjustmentdt add adjustmentrequestdt_Id double;



CREATE TABLE `salesmen_budget` (
  `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `salesmen_code` VARCHAR(45),
  `Immediate_payout` DOUBLE,
  `salesmen_mst` DOUBLE,
  `salesmen_startdate` DATE,
  `salesmen_enddate` DATE,
  `monthly_achievmentfrom` DOUBLE,
  `monthly_achievmentto` DOUBLE,
  `salesmen_sip` DOUBLE,
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;

#nabil 2013-12-06
CREATE TABLE `salesmen_budgetdt` (
  `salesmen_budgetdtid` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `salesmen_budgetid` INTEGER UNSIGNED NOT NULL,
  `monthly_achievement` DOUBLE,
  `salesmen_budgetdt_sip` DOUBLE,
  PRIMARY KEY (`salesmen_budgetdtid`),
  CONSTRAINT `FK_salesmen_budgetdt_1` FOREIGN KEY `FK_salesmen_budgetdt_1` (`salesmen_budgetid`)
    REFERENCES `salesmen_budget` (`id`)
    ON DELETE CASCADE
    ON UPDATE RESTRICT
)
ENGINE = InnoDB;



ALTER TABLE `salesmen_budget` ADD COLUMN `Salesmen_cst` DOUBLE AFTER `salesmen_sip`;
ALTER TABLE `salesmen_budgetdt` ADD COLUMN `salesmen_budgetdt_cip` DOUBLE AFTER `salesmen_budgetdt_sip`;

#maroun 2013-12-11
alter table sales add Sale_vehicleRealweight double;
alter table temp_sales add Sale_vehicleRealweight double;
alter table accesslabelsrocky.login add Fi_VehicleWeightChange tinyint(1);

#Tarek 2013-12-16
CREATE TABLE `cashregisterclosing` (
  `CashRegisterClosing_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `CashRegister_Name` VARCHAR(20) NOT NULL,
  `CashRegisterClosing_Date` DATETIME NOT NULL,
  `CashRegisterClosing_AmountB1` DOUBLE DEFAULT 0,
  `CashRegisterClosing_AmountB2` DOUBLE DEFAULT 0,
  PRIMARY KEY (`CashRegisterClosing_Id`)
)
ENGINE = InnoDB;


alter table accesslabelsrocky.login add FC_CashRegisterClosing tinyint(1) default 0;
alter table accesslabelsrocky.login add FC_ShowBtnCancel tinyint(1) default 0;



alter table module add Module_TransferPrice tinyint(1) default 0;

#Gilbert 2013-12-18
CREATE TABLE `toolbar` (
  `toolbar_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `toolbar_type` VARCHAR(15),
  `toolbar_url` VARCHAR(50),
  `toolbar_parent` INTEGER,
  `toolbar_position` varchar(10),
  `toolbar_location` varchar(50),
  PRIMARY KEY (`toolbar_id`)
)
ENGINE = InnoDB;

#Gilbert 2013-12-19
alter table toolbar add toolbar_order integer;
alter table toolbar add column toolbar_word varchar(20);


#Tarek 2014-01-02
alter table module add Module_CashBankRV tinyint(1) default 0;
alter table module add Module_CashBankPV tinyint(1) default 0;
alter table JourTypeButton add JourTypeButton_CashBank int(1) default 0;

#Tarek 2014-01-04
alter table accesslabelsrocky.login add FC_CashRegisterDelItem tinyint(1) default 0;


#maroun 2014-01-04
alter table  accesslabelsrocky.login add column approved_level integer;
alter table  prequestdt 	add column PRqstDt_approvedlevel integer;
alter table  TransferrequestDt add column TransferrequestDt_approvedlevel integer;
alter table  adjustmentrequestdt add column adjustmentrequestdt_approvedlevel integer;

alter table  temp_prequestdt 	add column PRqstDt_approvedlevel integer;
alter table  temp_TransferrequestDt add column TransferrequestDt_approvedlevel integer;
alter table  temp_adjustmentrequestdt add column adjustmentrequestdt_approvedlevel integer;


#maroun 2014-01-11
alter table checkscollected add debit_ledgernumber varchar(30);

#Tarek 2014-01-13
alter table module add Module_CashRegItemSeperate tinyint(1) default 0;

#Tarek 2014-01-14
alter table sales add Sale_PrintReceipt tinyint(1) default 0;
alter table temp_sales add Sale_PrintReceipt tinyint(1) default 0;


#Tarek 2014-01-15
alter table salessetup add PriceDecimalBase int(11);


#Tarek 2014-01-17
alter table setup add Setup_LogoWidth double;
alter table setup add Setup_LogoHeight double;



#Maroun 2014-01-24
alter table accesslabelsrocky.login add fi_pendingpurchaserequest tinyint(1) default 0;
alter table accesslabelsrocky.login add fi_pendingtransferrequest tinyint(1) default 0;
alter table accesslabelsrocky.login add fi_pendingadjustmentrequest tinyint(1) default 0;
alter table prequestdt add approvedby varchar(20);
alter table temp_prequestdt add approvedby varchar(20);
alter table porder add approvedby varchar(50);


#Gilbert 2014-01-28
alter table module add column Module_CashRegisterStandardView int(3);

#Maroun 2014-01-28
alter table transferrequest add prqst_id bigint;
create table temp_purchaseordercharges like temp_purchasecharges;
alter table temp_PurchaseOrdercharges add column logged_code varchar(50);
create table purchaseordercharges like purchasecharges;


#Tarek 2014-01-30
alter table module add Module_ShowInvoiceAging tinyint(1) default 0;

#Tarek 2014-02-03
alter table ProductionRequest add Project_Code varchar(15);
alter table Temp_ProductionRequest add Project_Code varchar(15);

alter table ProductionRequest add CostCenter_Code varchar(15);
alter table Temp_ProductionRequest add CostCenter_Code varchar(15);



#Gilbert 2014-02-04
alter table setup add column show_companylogo tinyint(1);
alter table setup add column show_companyname tinyint(1);
alter table setup add column show_printdatetime tinyint(1);
alter table setup add column show_user tinyint(1);
alter table setup add column show_companymemo tinyint(1);

#maroun 06.02.2014
alter table itemjour add adjustmentdt_id double;

#maroun 2013-10-18
create table temp_assets like assets;
alter table assets add column assets_id bigint;
alter table temp_assets add column assets_id bigint;
alter table sequence add column assets_id double;
alter table assets add User_Account varchar(20);
alter table temp_assets add User_Account varchar(20);
alter table temp_assets add logged_code varchar(20);
alter table assets add Assets_MaturityDate datetime;
alter table temp_assets add Assets_MaturityDate datetime;
alter table assetsdt add User_Account varchar(100);
alter table temp_assetsdt add User_Account varchar(100);
alter table assets add Logged_code varchar(100);
alter table temp_assets add Logged_code varchar(100);


CREATE TABLE   `assetsdt` (
  `assetsdt_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `assets_id` bigint(20) unsigned NOT NULL,
  `ledger_number` varchar(45) DEFAULT NULL,
  `currency_code` varchar(45) DEFAULT NULL,
  `assetsdt_description` varchar(100) DEFAULT NULL,
  `assetsdt_amount` double DEFAULT NULL,
  `assetsdt_amount1` double DEFAULT NULL,
  `assetsdt_amount2` double DEFAULT NULL,
  `assetsdt_valuedate` date DEFAULT NULL,
  `assetsdt_isvat` tinyint(1) unsigned DEFAULT NULL,
  `project_code` varchar(45) DEFAULT NULL,
  `costcenter_code` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`assetsdt_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


create table temp_assetsdt like assetsdt;
alter table temp_assetsdt add logged_code varchar(100);
alter table temp_assetsdt add User_Account varchar(100);
create table temp_itemjour like itemjour;
alter table temp_itemjour add logged_code varchar(100);
alter table temp_itemjour add assetsdt_id bigint;
alter table itemjour add assetsdt_id bigint;

CREATE TABLE `assetjour` (
  `assetjour_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Costcent_code` VARCHAR(15),
  `Project_Code` VARCHAR(15),
  `assetjour_prcnt` DOUBLE,
  `assetjour_amount` DOUBLE,
  `assetjour_amount1` DOUBLE,
  `assetjour_amount2` DOUBLE,
  `Costcent_Precode` VARCHAR(15),
  `assetjour_posted` TINYINT(1) UNSIGNED DEFAULT 0,
  `Synchronized` TINYINT(1) UNSIGNED DEFAULT 0,
  `Journal_JVRef` DOUBLE,
  `Variant_Code` VARCHAR(30),
  `user_account` VARCHAR(50),
  PRIMARY KEY (`assetjour_id`)
)
ENGINE = InnoDB;

alter table assetjour add assetsdt_id bigint;
create table temp_assetjour like assetjour;
alter table temp_assetjour add logged_code varchar(100);
alter table temp_assetjour add assetsdt_id bigint;
create table temp_cstjour like cstjour;
alter table temp_cstjour add logged_code varchar(100);
alter table temp_cstjour add assetsdt_id bigint;
alter table cstjour add assetsdt_id bigint;
alter table temp_cstjour add user_account varchar(100);
alter table cstjour add user_account varchar(100);


#Ralph 07-02-2014

ALTER TABLE `sales` ADD INDEX `sales_reference`(`Sale_Reference`);

#Gilbert 10-02-2014
alter table curdt add column curdt_id bigint(20);
alter table curdt add column currency_id bigint(20);


#Tarek 2014-02-14
alter table sales add Sale_OldData tinyint(1) default 0;
alter table deliveries add Delivery_OldData tinyint(1) default 0;
alter table purchases add Purchase_OldData tinyint(1) default 0;
alter table trans add Trans_OldData tinyint(1) default 0;
alter table journal add Journal_OldData tinyint(1) default 0;
alter table salesjv add SalesJv_OldData tinyint(1) default 0;


#maroun 15.02.2014
create table assetsitemjour like itemjour;
create table assetscstjour like cstjour;
create table temp_assetsitemjour like temp_itemjour;
create table temp_assetscstjour like temp_cstjour;


#Tarek 2014-02-24
CREATE TABLE `cashregisterrounding` (
  `CashRegisterRounding_Id` BIGINT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `CashRegisterRounding_RangeFrom` DOUBLE NOT NULL,
  `CashRegisterRounding_RangeTo` DOUBLE NOT NULL,
  `CashRegisterRounding_Value` DOUBLE NOT NULL,
  PRIMARY KEY (`CashRegisterRounding_Id`)
)
ENGINE = InnoDB;

alter table setup add CashReg_RoundDivisor double;



#Tarek 2014-02-27
alter table purchases add Purchase_TotalAmount double default 0;
alter table temp_purchases add Purchase_TotalAmount double default 0;
alter table module add Module_PurchaseCheckTotal tinyint(1) default 0;

#Tarek 2014-02-28
alter table accesslabelsrocky.login add FA_TransferFunds tinyint(1) default 0;
alter table sequence add TransferFunds_TypeRef double default 0;


#Gilbert 2014-03-04
alter table `accesslabelsrocky`.login add column login_maturitydate tinyint(1);

#Tarek 2014-03-11
alter table transdt modify TransDt_Description varchar(240);
alter table transdt modify TransDt_Description2 varchar(240);
alter table journaldt modify Journaldt_desc varchar(240);
alter table journaldt modify Journaldt_desc1 varchar(240);


#maroun 12.03.2014
alter table accesslabelsrocky.login add fi_pendingpurchaseorder tinyint(1);
alter table porder add user_name varchar(50);
alter table porder add porder_approvedstatus varchar(1);
alter table porder add porder_approvedlevel int(20);
alter table porder add rejectedreason varchar(100);
alter table accesslabelsrocky.login add PorderApproved_Level bigint;
alter table accesslabelsrocky.login add PrequestApproved_Level bigint;
alter table accesslabelsrocky.login add TransferRequestApproved_Level bigint;
alter table accesslabelsrocky.login add AdjustmentRequestApproved_Level bigint;
alter table transfer add Sorder_reference double;
alter table temp_transfer add Sorder_reference double;
alter table prequest add rejectedreason varchar(100);
alter table transferrequest add rejectedreason varchar(100);
alter table adjustmentrequest add rejectedreason varchar(100);


#Tarek 2014-03-13
alter table sorder add
(Sorder_TransportAccount varchar(10)
,Sorder_TransportAmount double default 0
,Sorder_TransportBase1 double default 0
,Sorder_TransportBase2 double default 0
,Sorder_TransportTTC double default 0
);
alter table temp_sorder add
(Sorder_TransportAccount varchar(10)
,Sorder_TransportAmount double default 0
,Sorder_TransportBase1 double default 0
,Sorder_TransportBase2 double default 0
,Sorder_TransportTTC double default 0
);

alter table sorderdt add
(SorderDt_TransportAmount double default 0
,SorderDt_TransportBase1 double default 0
,SorderDt_TransportBase2 double default 0
);
alter table temp_sorderdt add
(SorderDt_TransportAmount double default 0
,SorderDt_TransportBase1 double default 0
,SorderDt_TransportBase2 double default 0
);

#maroun 14.03.2014
alter table  prequestdt add rejectedreason varchar(100);
alter table  porderdt add rejectedreason varchar(100);
alter table  transferrequestdt add rejectedreason varchar(100);
alter table  adjustmentrequestdt add rejectedreason varchar(100);

alter table  prequestdt add user_name varchar(100);
alter table  temp_prequestdt add user_name varchar(100);

#Tarek 2014-03-20
alter table accesslabelsrocky.login add RI_TopClientsSuppliers tinyint(1) default 0;


#nabil 2014-03-20
alter table accesslabelsrocky.login add column fi_transferstockout tinyint(1) default 0;
alter table accesslabelsrocky.login add column fi_purchasestockout tinyint(1) default 0;

#Gilbert 2014-03-26

#DROP TABLE IF EXISTS `notification`;
CREATE TABLE  `notification` (
  `notification_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `notification_type` varchar(45) DEFAULT NULL,
  `notification_action` varchar(45) DEFAULT NULL,
  `notification_description` varchar(45) DEFAULT NULL,
  `notification_reference` varchar(45) DEFAULT NULL,
  `notification_createduser` varchar(45) DEFAULT NULL,
  `notification_level` int(10) unsigned DEFAULT NULL,
  `notification_date` datetime DEFAULT NULL,
  `notification_done` tinyint(1) unsigned DEFAULT NULL,
  `notification_checked` tinyint(1) unsigned DEFAULT NULL,
  `trans_id` bigint(20) unsigned DEFAULT NULL,
  `notification_table` varchar(30) DEFAULT NULL,
  PRIMARY KEY (`notification_id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8;

#DROP TABLE IF EXISTS `indexaction`;
CREATE TABLE  `indexaction` (
  `index_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `index_number` int(10) unsigned NOT NULL,
  `index_formname` varchar(45) NOT NULL,
  `index_action` varchar(45) NOT NULL,
  `index_tablename` varchar(45) NOT NULL,
  PRIMARY KEY (`index_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

#nabil 2014-03-26							
alter table purchasesdt add column PURCHASEDT_ITEMSELLINGPRICE double default 0;
alter table accesslabelsrocky.login add column FI_ItemPricing tinyint(1) default 0;

#gilbert 2014-03-29	
alter table subgroup add column subgroup_picture blob;

#gilbert 2014-03-31	
alter table setup add column cashreg_colortheme varchar(20);

#maroun 2014-03-31
ALTER TABLE `module` ADD COLUMN `Module_Notification` TINYINT DEFAULT 0 ;

#Ralph 2014-04-08
ALTER TABLE `shipments` ADD COLUMN `shipmentrouting_reference` BIGINT ;



#Ralph 2014-04-08
ALTER TABLE `sales` ADD INDEX `sale_posted`(`sale_posted`);




#maroun 2014.04.08
alter table retail add Projectdt_id bigint;
alter table temp_retail add Projectdt_id bigint;
alter table module add Module_CashRegisterTable tinyint(1) default 0;

#Tarek 2014-04-10
alter table cashtype add CostCent_Code varchar(15);

alter table purchasesetup add ShowCostCentLayout tinyint(1) default 0;
alter table salessetup add ShowCostCentLayout tinyint(1) default 0;
alter table sordersetup add ShowCostCentLayout tinyint(1) default 0;
alter table transfersetup add ShowCostCentLayout tinyint(1) default 0;
alter table adjustmentsetup add ShowCostCentLayout tinyint(1) default 0;
alter table productionsetup add ShowCostCentLayout tinyint(1) default 0;

ALTER TABLE `salesdt` ADD INDEX `Index_JourType`(`journal_type`);


alter table  prequestdt add user_name varchar(30);
alter table  temp_prequestdt add user_name varchar(30);

#Tarek 2014-04-11
alter table sequence add curdt_id double default 0;
Drop Trigger if Exists Currency_BI;


#nabil 2014-04-12
alter table project add column project_id bigint default 0;

#Maroun 2014-04-15
alter table accesslabelsrocky.login add Perc_CreditLimit double  default 0;
alter table accesslabelsrocky.login add RA_Statistics tinyint(1) default 0;
alter table accesslabelsrocky.login add RI_Statistics tinyint(1) default 0;
alter table accesslabelsrocky.login add FI_Statistics tinyint(1) default 0;
alter table module add module_newproduction tinyint(1) default 0;

#Tarek 2014-04-22
ALTER TABLE SETUP ADD COLUMN Setup_Branch VARCHAR(20);

alter table clients add Owner_Branch varchar(20);
alter table suppliers add Owner_Branch varchar(20);
alter table salesmen add Owner_Branch varchar(20);
alter table customer add Owner_Branch varchar(20);
alter table project add Owner_Branch varchar(20);
alter table costcent add Owner_Branch varchar(20);
alter table currency add Owner_Branch varchar(20);
alter table warehouse add Owner_Branch varchar(20);
alter table items add Owner_Branch varchar(20);
alter table coupon add Owner_Branch varchar(20);
alter table vendor add Owner_Branch varchar(20);
alter table area add Owner_Branch varchar(20);
alter table category add Owner_Branch varchar(20);
alter table ledgergrp add Owner_Branch varchar(20);
alter table grouping add Owner_Branch varchar(20);
alter table subgroup add Owner_Branch varchar(20);
alter table acctype add Owner_Branch varchar(20);
alter table checks add Owner_Branch varchar(20);
alter table bills add Owner_Branch varchar(20);
alter table banks add Owner_Branch varchar(20);
alter table ledger add Owner_Branch varchar(20);

alter table sorder add
( Owner_Branch varchar(50),
  Destination_Branch varchar(50),
  Sorder_Syn_ID double
);


alter table sorderdt add
( SorderDt_Syn_ID double,
  Sorder_Syn_ID double
);

alter table retail add
( Owner_Branch varchar(50),
  Destination_Branch varchar(50),
  Sale_Syn_ID double
);


alter table retaildt add
( SaleDt_Syn_ID double,
  Sale_Syn_ID double
);

alter table deliveries add
( Owner_Branch varchar(50),
  Destination_Branch varchar(50),
  Delivery_Syn_ID double
);


alter table deliverydt add
( DeliveryDt_Syn_ID double,
  Delivery_Syn_ID double
);

alter table Sales add
( Owner_Branch varchar(50),
  Destination_Branch varchar(50),
  Sale_Syn_ID double
);


alter table Salesdt add
( SaleDt_Syn_ID double,
  Sale_Syn_ID double
);

#######################################
CREATE TABLE `SynchroData` (
  `Synchro_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Synchro_Date` DATETIME NOT NULL,
  `Synchro_State` VARCHAR(1) NOT NULL,
  `Synchro_TableName` VARCHAR(50) NOT NULL,
  `Synchro_TransID` BIGINT UNSIGNED,
  `Synchro_TransCode` VARCHAR(50),
  `Synchro_BranchCode` VARCHAR(20),
  `Synchro_Flag` VARCHAR(1) NOT NULL,
  PRIMARY KEY (`Synchro_ID`),
  INDEX `Index_2`(`Synchro_TableName`),
  INDEX `Index_3`(`Synchro_State`),
  INDEX `Index_4`(`Synchro_Flag`),
  INDEX `Index_5`(`Synchro_TransID`),
  INDEX `Index_6`(`Synchro_TransCode`)
)
ENGINE = InnoDB;

/*
CREATE TABLE `Branches` (
  `Branch_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Branch_Code` VARCHAR(20) NOT NULL,
  `Branch_Name` VARCHAR(100) NOT NULL,
  `Branch_Main` TINYINT(1) DEFAULT 0,
  `Branch_DbServer` VARCHAR(45),
  `Branch_DbName` VARCHAR(45),
  `Branch_DbUser` VARCHAR(45),
  `Branch_DbPass` VARCHAR(45),
  PRIMARY KEY (`Branch_ID`)
)
ENGINE = InnoDB;
*/

ALTER TABLE `Branches` ADD (
  `Branch_Main` TINYINT(1) DEFAULT 0,
  `Branch_DbServer` VARCHAR(45),
  `Branch_DbName` VARCHAR(45),
  `Branch_DbUser` VARCHAR(45),
  `Branch_DbPass` VARCHAR(45)
);

CREATE TABLE `SynchroTables` (
  `SynchroTable_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `SynchroTable_Name` VARCHAR(50) NOT NULL,
  `SynchroTable_Active` TINYINT(1) NOT NULL DEFAULT 1,
  `SynchroTable_Receive` TINYINT(1) NOT NULL DEFAULT 1,
  `SynchroTable_AllBranches` TINYINT(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`SynchroTable_ID`)
)
ENGINE = InnoDB;


CREATE TABLE `SynchroLogs` (
  `SynchroLogs_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `SynchroLogs_Date` DATETIME NOT NULL,
  `SynchroLogs_TableName` VARCHAR(50) NOT NULL,
  `SynchroLogs_Message` BLOB NOT NULL,
  `SynchroLogs_Flag` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`SynchroLogs_ID`)
)
ENGINE = InnoDB;


alter table SynchroTables add SynchroTable_Receive TINYINT(1) NOT NULL DEFAULT 1;

############################################################
############################################################


#NABIL 2014-04-23
ALTER TABLE accesslabelsrocky.LOGIN ADD FA_INTERRESTRATE TINYINT(1) DEFAULT 0;
ALTER TABLE accesslabelsrocky.LOGIN ADD Perc_creditlimit TINYINT(1) DEFAULT 0;




#maroun 2014.04.23
alter table accesslabelsrocky.login add Fi_POS tinyint(1) default 0;



#maroun 2014.04.25
alter table module drop column Module_CashRegisterTable;
alter table module drop column Module_CashregisterStandardview;
alter table module drop column Module_Cashregisterfastitem;
alter table module drop column Module_CashRegAutoItemsList;
alter table module drop column Module_RestaurantDelivery;
alter table cashregister add Module_CashRegisterTable tinyint(1) default 0;
alter table cashregister add Module_CashregisterStandardview tinyint(1)  default 0;
alter table cashregister add Module_Cashregisterfastitem tinyint(1)  default 0;
alter table cashregister add Module_CashRegAutoItemsList tinyint(1)  default 0;
alter table cashregister add Module_RestaurantDelivery tinyint(1)  default 0;

#maroun 12.05.2014
alter table module add Module_ImportExcell tinyint(1) default 0;
alter table module add Module_CancelledQty tinyint(1) default 0;
#NABIL CHEMICO 12.05.2014
ALTER TABLE MODULE ADD COLUMN MODULE_SHOWUNIT TINYINT(1) DEFAULT 0;


#Tarek 2014-05-13
alter table packdt add Group_Code varchar(15);


alter table PRequest add username varchar(50);
alter table Temp_PRequest add username varchar(50);


#Tarek 2014-05-21
alter table ProductionDt add ProductionDt_Checked tinyint(1) default 1;
alter table Temp_ProductionDt add ProductionDt_Checked tinyint(1) default 1;

#nabil 2014-05-27 ash supermarket
ALTER TABLE PURCHASESDT ADD COLUMN PURCHASEDT_PRICINGONCOST TINYINT(1) DEFAULT 0;


#Tarek 2014-06-06
#alter table items drop column Warehouse_Code ;
alter table items add Item_WarehouseCode varchar(15);

#Tarek 2014-06-09
alter table module add Module_LoadSoldItems tinyint(1) default 0;

#Tarek 2014-06-10
alter table sequence add Project_Id double default 0;

create table projectdt (
  ProjectDt_Id  bigint(20) auto_increment primary key,
  ProjectDt_Name varchar(100),
  ProjectDt_NumberofSeats int(11),
  Project_Id bigint(20),
  ProjectDt_Reserved tinyint(1) default 0,
  ProjectDt_Floor varchar(50),
  ProjectDt_View varchar(50),
  ProjectDt_Smoking tinyint(1) default 0
);


alter table projectdt add (
  ProjectDt_Floor varchar(50),
  ProjectDt_View varchar(50),
  ProjectDt_Smoking tinyint(1) default 0
);



#Tarek 2014-06-11
alter table items add Item_RebateBy tinyint(1) default 1;

create table itemsrebate (
  ItemRebate_Id bigint(20) auto_increment primary key,
  Item_Code varchar(20),
  ItemRebate_RangeFrom double,
  ItemRebate_RangeTo double,
  ItemRebate_Per double
);


#Nabil 2014-06-12 //ashrafieh supermarket
alter table suppliers add supplier_targetamount double default 0;


#Tarek 2014-06-19
alter table accesslabelsrocky.login add FI_SorderAllowConfirmCash tinyint(1) default 0;

#Tarek 2014-06-26
ALTER TABLE clients ADD Ledger_NameF VARCHAR(50);  # (arabic)
ALTER TABLE suppliers ADD Ledger_NameF VARCHAR(50); # (Arabic)
ALTER TABLE suppliers ADD Supplier_Address3 VARCHAR(100);         #new field for address
ALTER TABLE salesmen ADD Salesman_WarehouseCode VARCHAR(15);   #new field for warehouse in salesman
ALTER TABLE items add item_descriptionf1 varchar(100); # (arabic)
ALTER TABLE items add item_descriptionf2 varchar(100);    # (french)
alter table items add Item_NetWeight double;



alter table setup add (
 Company_NameF varchar(60),
 Company_MemoF varchar(255),
 Company_Capital varchar(100),
 Company_CapitalF varchar(100)
);

alter table setup add Setup_MultiLangPrint tinyint(1) default 0;


#nabil 2014-06-27 //problem in checks for colloction due to enlarge field Journaldt_desc in journaldt table
alter table ChecksCollected modify Journaldt_desc varchar(240);


ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_Tracking` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_vehicle` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_VehicleCharges` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_Place` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_VehicleMovement` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_Employee` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Fi_vehicleservice` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Fi_vehiclefueltype` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Fi_VehicleMovementReport` TINYINT(1) ;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Fi_vehicletype` TINYINT(1) ;



#NABIL  2014-07-07 NEW VAT PROCESS
ALTER TABLE PURCHASESETUP add (VATAccountRefundable varchar(10));
ALTER TABLE PURCHASESETUP add (DebitAccountVatRefundable varchar(10));

ALTER TABLE  salessetup add (VatAccountRefundable varchar(10));
ALTER TABLE  salessetup add (CreditAccountVATRefundable varchar(10));

alter table items add (Item_unknownStock tinyint(1) unsigned default 0);

#Tarek 2014-07-10
alter table deliverydt add DeliveryDt_ProductionDate datetime;
alter table temp_deliverydt add DeliveryDt_ProductionDate datetime;


#Tarek 2014-07-16
alter table purchases add Purchase_DirectReturn tinyint(1) default 0;
alter table temp_purchases add Purchase_DirectReturn tinyint(1) default 0;


#Tarek 2014-07-21
alter table transactionsetup add Trans_TipsAcc varchar(10);
alter table deliverydt add DeliveryDt_TipsAccount varchar(10);
alter table temp_deliverydt add DeliveryDt_TipsAccount varchar(10);
alter table salesdt add SaleDt_TipsAccount varchar(10);
alter table temp_salesdt add SaleDt_TipsAccount varchar(10);

#nabil 2014-07-21  //suidan
ALTER TABLE clients ADD column client_Longitude double default 0;
ALTER TABLE clients ADD column client_Latitude double default 0;
alter table accesslabelsrocky.users add column user_admin tinyint(1) default 0;

ALTER TABLE suppliers ADD column supplier_Longitude double default 0;
ALTER TABLE suppliers ADD column supplier_Latitude double default 0;



CREATE TABLE `dailyvisits` (
  `DAILYVISIT_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `USER_CODE` VARCHAR(10) NOT NULL,
  `CLIENT_CODE` VARCHAR(10) NOT NULL,
  `DAILYVISIT_LATITUDE` DOUBLE NOT NULL DEFAULT 0,
  `DAILYVISIT_LONGTITUDE` DOUBLE NOT NULL DEFAULT 0,
  `DAILYVISIT_DATE` DATETIME NOT NULL,
  `DAILYVISIT_FOUND` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
  `DAILYVISIT_REMARK` VARCHAR(100),
  PRIMARY KEY (`DAILYVISIT_ID`)
)
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8   
 COLLATE utf8_general_ci;
ALTER TABLE `dailyvisits` ADD INDEX `Index_dclient_Code`(`CLIENT_CODE`);

#nabil tpro 2014-07-24
ALTER TABLE deliverydt ADD INDEX `Index_dlvsroderdt`(`srorderdt_id`);
ALTER TABLE srorder ADD INDEX `Index_sroderclient`(`client_code`);


create table visits (
  visit_id  BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  ledger_number varchar(10),
  ledger_name varchar(100),
  visit_latitude DOUBLE NOT NULL DEFAULT 0,
  visit_logitude DOUBLE NOT NULL DEFAULT 0,

PRIMARY KEY (VISIT_ID) )
ENGINE = InnoDB
DEFAULT CHARACTER SET utf8
 COLLATE utf8_general_ci;
ALTER TABLE `visits` ADD INDEX `Index_vledger_number`(`ledger_number`);


#Ralph 2014-01-08


ALTER TABLE accesslabelsrocky.login ADD COLUMN `Login_Mobile` TINYINT(1) DEFAULT 0;
ALTER TABLE accesslabelsrocky.login ADD COLUMN `FM_Visits` TINYINT(1) UNSIGNED DEFAULT 0;
ALTER TABLE accesslabelsrocky.login ADD COLUMN `RM_DailyVisits` TINYINT(1) DEFAULT 0;



#maroun 01.08.2014
ALTER TABLE accesslabelsrocky.login add FC_CashRegisterSetup TINYINT(1) default 0;


#maroun 05.08.2014
CREATE TABLE  accesslabelsrocky.`printersubgroup` (
  `p_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `p_name` varchar(200) DEFAULT NULL,
  `p_subgroup` varchar(200) DEFAULT NULL,
  `p_cashregister` varchar(200) DEFAULT NULL,
  PRIMARY KEY (`p_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `retaildt` ADD COLUMN `saleDt_ItemStatus` DOUBLE DEFAULT 0;
ALTER TABLE temp_retaildt ADD COLUMN `saleDt_ItemStatus` DOUBLE DEFAULT 0;

#Ralph 2014-05-08
ALTER TABLE accesslabelsrocky.login ADD COLUMN `FM_Mobiles` TINYINT(1) DEFAULT 0 ;
CREATE TABLE  `mobile` (
`MOBILE_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `MOBILE_BUILDNUMBER` varchar(20) NOT NULL,
  `MOBILE_NAME` varchar(45) DEFAULT NULL,
  `MOBILE_ACTIVE` int(11) DEFAULT NULL,

  PRIMARY KEY (`MOBILE_ID`),
  UNIQUE KEY `Index_mbuild` (`MOBILE_BUILDNUMBER`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

#maroun 06.08.2014
alter table temp_prequest add PRqst_Purpose varchar(200);
alter table prequest add PRqst_Purpose varchar(200);
alter table temp_prequest add PRqst_Location varchar(200);
alter table prequest add PRqst_Location varchar(200);
alter table temp_prequest add PRqst_Priority varchar(200);
alter table prequest add PRqst_Priority varchar(200);


#maroun 08.08.2014
alter table porder add porder_paymentcondition varchar(500);
alter table porder add porder_downpayment tinyint(1);
alter table temp_porder add porder_paymentcondition varchar(500);
alter table temp_porder add porder_downpayment tinyint(1);
alter table module add Module_DownPayment tinyint(1) default 0;


ALTER TABLE `accesslabelsrocky`.`mobile` MODIFY COLUMN `MOBILE_NAME` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `accesslabelsrocky`.`mobile` MODIFY COLUMN `MOBILE_BUILDNUMBER` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;


#Tarek 2014-08-11
alter table accesslabelsrocky.login add FU_DataTransfer tinyint(1) default 0;
alter table transfer add IsProcessed tinyint(1) default 0;


#Tarek 2014-08-18
alter table accesslabelsrocky.login add FC_CashRegisterGift tinyint(1) default 0;
alter table accesslabelsrocky.login add FC_CashRegisterVoid tinyint(1) default 0;
alter table accesslabelsrocky.login add FC_CashRegisterWaste tinyint(1) default 0;

ALTER TABLE retaildt ADD COLUMN SaleDt_ItemStatusRemark varchar(200);
ALTER TABLE temp_retaildt ADD COLUMN SaleDt_ItemStatusRemark varchar(200);

CREATE TABLE `cashregister_voidreasons` (
  `Reason_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Reason_Remark` VARCHAR(200) NOT NULL,
  PRIMARY KEY (`Reason_Id`)
)
ENGINE = InnoDB DEFAULT CHARSET=utf8;



#Tarek 2014-08-29
alter table setup add Setup_TransShowLedger tinyint(1) default 0;


#nabil 2014-09-01 //adventist
create table print_barcode (
item_code varchar(20),
ITEM_DESCRIPTION varchar(100),
barcodeindex  double,
ITEM_BARCODE varchar(20),
ITEM_BARCODE2 varchar(20),
ITEM_BARCODE3 varchar(20),
Currency_code varchar(6),
Item_SellingPrice1 double,
Item_SellingPrice1Base1 double,
Item_SellingPrice1Base2 double
);



#Tarek 2014-09-02
alter table cashregister add CashRegister_ShowTaxNonTax tinyint(1) default 0;
alter table module add Module_Weight tinyint(1) default 0;

alter table aging add id int(10);

#Tarek 2014-09-05
alter table accesslabelsrocky.acclink add Link_ID double after Journal_Id;
alter table accesslabelsrocky.temp_acclink add Link_ID double after Journal_Id;
alter table accesslabelsrocky.acclink add Return_ID double after user_account;
alter table accesslabelsrocky.temp_acclink add Return_ID double after user_account;


#Tarek 2014-09-10
CREATE TABLE `cashregistermenu` (
  `Menu_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Menu_Index` VARCHAR(10),
  `Menu_Title` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
  `Menu_Link` VARCHAR(200),
  `Menu_Order` DOUBLE,
  `Menu_Active` TINYINT(1) UNSIGNED DEFAULT 1,
  `Menu_ImageName` VARCHAR(50),
  PRIMARY KEY (`Menu_Id`)
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;


#Tarek 2014-09-12
alter table accesslabelsrocky.login add Login_TipsMaxAmount double;


#Tarek 2014-09-15
alter table subgroup add subgroup_color varchar(50);
alter table ItemButtons add ItemButton_Color varchar(50);
alter table ItemButtons add ItemButton_Picture blob;


#maroun 19.09.2014
alter table porder add porder_downperc double;
alter table porder add porder_downamount double;
alter table temp_porder add porder_downperc double;
alter table temp_porder add porder_downamount double;
alter table prequestdt add prequestdt_availableqty double;
alter table temp_prequestdt add prequestdt_availableqty double;


#Tarek 2014-09-22
alter table setup add report_color1 varchar(45) default '#ABD4F1';
alter table setup add report_color2 varchar(45) default '#EFF1F3';



#maroun 2014-09-25
alter table retail add sale_type varchar(20);
alter table temp_retail add sale_type varchar(20);

#Tarek 2014-09-26
alter table module add Module_PorderAutoApprove tinyint(1) default 0;
alter table module add Module_PrequestAutoApprove tinyint(1) default 0;
alter table module add Module_TrequestAutoApprove tinyint(1) default 0;

#maroun 2014-09-26
alter table temp_retail add driver_Code varchar(50);
alter table retail add driver_Code varchar(50);




#Tarek 2014-09-29
CREATE TABLE `CashAmounts` (
  `Cash_Id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `Currency_Code` VARCHAR(6) NOT NULL,
  `Cash_Value` DOUBLE,
  PRIMARY KEY (`Cash_Id`)
)
ENGINE = InnoDB;

CREATE TABLE `CashRegisterTrans` (
  `ctrans_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `cashregister_name` VARCHAR(45) NOT NULL,
  `ctrans_timein` DATETIME,
  `ctrans_timeout` DATETIME,
  `currency_code` varchar(6),
  `ctrans_additionalcash` DOUBLE DEFAULT 0,
  `ctrans_totalcashstart` DOUBLE DEFAULT 0,
  `ctrans_totalcashclose` DOUBLE DEFAULT 0,
  PRIMARY KEY (`ctrans_id`)
)
ENGINE = InnoDB;

CREATE TABLE `CashRegisterCount` (
  `moneycount_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `ctrans_id` BIGINT(20) NOT NULL,
  `ctrans_type` VARCHAR(5),
  `moneycount_unit` DOUBLE,
  `moneycount_qty` DOUBLE,
  `moneycount_total` DOUBLE,
  PRIMARY KEY (`moneycount_id`)
)
ENGINE = InnoDB;


CREATE TABLE `cashregistertransdt` (
  `ctransdt_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `ctrans_id` BIGINT(20) NOT NULL,
  `ctransdt_date` DATETIME,
  `ctransdt_type` varchar(3),
  `currency_code` VARCHAR(6),
  `ctransdt_amount` DOUBLE DEFAULT 0,
  `[REDACTED]` DOUBLE DEFAULT 0,
  `[REDACTED]` DOUBLE DEFAULT 0,
  `ctransdt_description` VARCHAR(250) CHARACTER SET utf8 COLLATE utf8_general_ci,
  `ctransdt_posted` TINYINT(1) DEFAULT 0,
  PRIMARY KEY (`ctransdt_id`)
)
ENGINE = InnoDB
CHARACTER SET utf8 COLLATE utf8_general_ci;


alter table porder add column Expiry_date datetime;
alter table temp_porder add column Expiry_date datetime;

#Tarek 2014-10-02
alter table accesslabelsrocky.login add Login_PReqApprove tinyint(1) default 0;
alter table accesslabelsrocky.login add Login_PReqReject tinyint(1) default 0;
alter table accesslabelsrocky.login add Login_PReqUndProc tinyint(1) default 0;

alter table accesslabelsrocky.login add Login_POrdApprove tinyint(1) default 0;
alter table accesslabelsrocky.login add Login_POrdReject tinyint(1) default 0;

alter table accesslabelsrocky.login add Login_TReqApprove tinyint(1) default 0;
alter table accesslabelsrocky.login add Login_TReqReject tinyint(1) default 0;

alter table accesslabelsrocky.login add Login_AReqApprove tinyint(1) default 0;
alter table accesslabelsrocky.login add Login_AReqReject tinyint(1) default 0;


CREATE TABLE  `customer_res` (
  `res_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `customer_code` varchar(50) NOT NULL,
  `res_fromdate` datetime DEFAULT NULL,
  `res_todate` datetime DEFAULT NULL,
  `ampm` varchar(45) DEFAULT NULL,
  `projectdt_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`res_id`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8;


#maroun 2014.10.13
alter table clients add client_type varchar(20);

CREATE TABLE  `dispatchdriver` (
  `dispatch_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `dispatch_out` datetime DEFAULT NULL,
  `dispatch_in` datetime DEFAULT NULL,
  `deldriver_id` bigint(20) unsigned DEFAULT NULL,
  `retail_id` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`dispatch_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;



alter table temp_retail add sale_closed tinyint(1) default 0;
alter table retail add sale_closed tinyint(1) default 0;

alter table temp_retail add sale_status varchar(20);
alter table retail add sale_status varchar(20);


#Tarek 2014-10-15
alter table items add column Item_DispOrder double;

#Tarek 2014-10-17
alter table setup add column Setup_GenerateJvNoAmount tinyint(1) default 0;


#Tarek 2014-10-20
alter table paymentrqst add column Porder_Reference double;
alter table temp_paymentrqst add column Porder_Reference double;
alter table paymentsetup add column DefaultCreditAccount varchar(10);

#Tarek 2014-10-23
alter table salesmen add Salesman_CashAccount varchar(10);

#Tarek 2014-10-24
alter table cashregister add CashRegister_SlipKitchen tinyint(1) default 0;

#Tarek 2014-10-27
alter table setup add Setup_SlipFooter varchar(255);

#Tarek 2014-10-28
alter table salesmen add Salesman_InvoiceSequence varchar(20);

CREATE TABLE `SalesmenInvoiceSequence` (
  `Sequence_id` BIGINT(20) NOT NULL AUTO_INCREMENT,
  `Ledger_Number` VARCHAR(10) NOT NULL,
  `Project_Code` varchar(20),
  `CostCenter_Code` VARCHAR(20),
  `Delivery_Reference` VARCHAR(45),
  `Dreturn_Reference` VARCHAR(45),
  PRIMARY KEY (`Sequence_id`)
)
ENGINE = InnoDB;



alter table Adjustment add Adjustment_asset tinyint(1) default 0;
alter table Temp_Adjustment add Adjustment_asset tinyint(1) default 0;
alter table AdjustmentDt add AdjustmentDt_AssetPrice double;
alter table Temp_AdjustmentDt add AdjustmentDt_AssetPrice double;



#Tarek 2014-11-05
alter table transdt add TransDt_OldData tinyint(1) default 0;
alter table journaldt add JournalDt_OldData tinyint(1) default 0;


alter table salessetup add VatAccountPOS varchar(10);


#Tarek 2014-11-06
alter table setup add CashReg_BgColorOffer varchar(20);
alter table setup add CashReg_BgColorQty varchar(20);
alter table setup add CashReg_BgColorOrderQty varchar(20);
alter table setup add CashReg_BgColorZeroPrice varchar(20);
alter table setup add CashReg_BgColorZeroQty varchar(20);
alter table setup add CashReg_BgColorHasDiscount varchar(20);


#Tarek 2014-11-11
alter table clients add Client_Promotion tinyint(1) default 0;
alter table cashregister add CashRegister_SlipCopy double default 1;


#Tarek 2014-11-14
alter table setup add VATSufixLength integer default 0;


#1-deductable 2 collactable 3-not clear
alter table items add item_vattype integer default 1;

alter table purchasesetup add column VatAccount2 varchar(10);
alter table purchasesetup add column VatAccount3 varchar(10);
alter table purchasesetup add column VATAccountNonStock2 varchar(10);
alter table purchasesetup add column VATAccountNonStock3 varchar(10);

alter table salessetup add column VatAccountPOS varchar(10);
alter table salessetup add column VATAccountNonStockPOS varchar(10);

alter table salessetup add column CreditAccountNonStock varchar(10);
alter table salessetup add column CreditAccountVATNonStock varchar(10);
alter table salessetup add column CreditAccountReturn varchar(10);
alter table salessetup add column CreditVATReturn varchar(10);
alter table salessetup add column CreditReturnNonStock varchar(10);
alter table salessetup add column CreditVATReturnNonStock varchar(10);
alter table purchasesetup add column CreditAccountReturn varchar(10);

alter table salesdt add SaleDt_VatAccount varchar(10);
alter table temp_salesdt add SaleDt_VatAccount varchar(10);
alter table deliverydt add DeliveryDt_VatAccount varchar(10);
alter table temp_deliverydt add DeliveryDt_VatAccount varchar(10);

alter table purchasesjv add PurchaseJv_VatPrefix varchar(10);
alter table salesjv add SalesJv_VatPrefix varchar(10);
alter table temp_purchasesjv add PurchaseJv_VatPrefix varchar(10);
alter table temp_salesjv add SalesJv_VatPrefix varchar(10);

#Tarek 2014-11-17
alter table ItemButtons add ItemButton_Type varchar(30) default 'SHORTCUT';

#Tarek 2014-11-18
alter table retaildt add SalesDt_Remark varchar(250);
alter table temp_retaildt add SalesDt_Remark varchar(250);


#Tarek 2014-11-20
alter table module add Module_PrintApprovedRqst tinyint(1) default 0;


alter table accesslabelsrocky.acclink add (
  Trans_Date datetime,
  Trans_ValueDate datetime,
  Trans_Description varchar(250),
  Return_Date datetime,
  Return_ValueDate datetime,
  Return_Description varchar(250)
);

alter table accesslabelsrocky.temp_acclink add (
  Trans_Date datetime,
  Trans_ValueDate datetime,
  Trans_Description varchar(250),
  Return_Date datetime,
  Return_ValueDate datetime,
  Return_Description varchar(250)
);


#Tarek 2014-11-21
alter table purchases add (
  Purchase_VatCharges double default 0,
  Purchase_VatChargesBase1 double default 0,
  Purchase_VatChargesBase2 double default 0
);

alter table temp_purchases add (
  Purchase_VatCharges double default 0,
  Purchase_VatChargesBase1 double default 0,
  Purchase_VatChargesBase2 double default 0
);


#Tarek 2014-11-24
alter table cashregister add CashRegister_DrawerPrinter varchar(100);


#Elie Njeim 2014-11-26
alter table accesslabelsrocky.login add column PR_default varchar(1);
alter table accesslabelsrocky.login add column PO_default varchar(1);
alter table accesslabelsrocky.login add column TR_default varchar(1);
alter table accesslabelsrocky.login add column AD_default varchar(1);

alter table accesslabelsrocky.login add column PR_status1 boolean default 1;
alter table accesslabelsrocky.login add column PR_status2 boolean default 1;
alter table accesslabelsrocky.login add column PR_status3 boolean default 1;
alter table accesslabelsrocky.login add column PR_status4 boolean default 1;
alter table accesslabelsrocky.login add column PR_status5 boolean default 1;
alter table accesslabelsrocky.login add column PR_status6 boolean default 1;
alter table accesslabelsrocky.login add column PR_status7 boolean default 1;
alter table accesslabelsrocky.login add column PR_status8 boolean default 1;
alter table accesslabelsrocky.login add column PR_status9 boolean default 1;
alter table accesslabelsrocky.login add column PR_status10 boolean default 1;
alter table accesslabelsrocky.login add column PR_status11 boolean default 1;


alter table accesslabelsrocky.login add column TR_status1 boolean default 1;
alter table accesslabelsrocky.login add column TR_status2 boolean default 1;
alter table accesslabelsrocky.login add column TR_status3 boolean default 1;

alter table accesslabelsrocky.login add column AD_status1 boolean default 1;
alter table accesslabelsrocky.login add column AD_status2 boolean default 1;
alter table accesslabelsrocky.login add column AD_status3 boolean default 1;

alter table accesslabelsrocky.login add column PO_status1 boolean default 1;
alter table accesslabelsrocky.login add column PO_status2 boolean default 1;
alter table accesslabelsrocky.login add column PO_status3 boolean default 1;
alter table accesslabelsrocky.login add column PO_status4 boolean default 1;
alter table accesslabelsrocky.login add column PO_status5 boolean default 1;



#Tarek 2014-12-01
alter table porder add user_account varchar(50);
alter table temp_porder add user_account varchar(50);


#Tarek 2014-12-10
alter table porderdt add PorderDt_ApprovedStatus varchar(1);
alter table porderdt add PorderDt_ApprovedLevel int(20);
alter table porderdt add PorderDt_GRNRejected tinyint(1);

alter table temp_porderdt add PorderDt_ApprovedStatus varchar(1);
alter table temp_porderdt add PorderDt_ApprovedLevel int(20);
alter table temp_porderdt add PorderDt_GRNRejected tinyint(1);


#Tarek 2014-12-15
alter table setup add CashReg_ApplyColorOffer tinyint(1) default 0;
alter table setup add CashReg_ApplyColorQty tinyint(1) default 0;
alter table setup add CashReg_ApplyColorOrderQty tinyint(1) default 0;
alter table setup add CashReg_ApplyColorZeroPrice tinyint(1) default 0;
alter table setup add CashReg_ApplyColorZeroQty tinyint(1) default 0;
alter table setup add CashReg_ApplyColorHasDiscount tinyint(1) default 0;

alter table cashregistermenu add Menu_WinWidth int(11);
alter table cashregistermenu add Menu_WinHeight int(11);
alter table cashregistermenu add Menu_ShortCutLabel varchar(100);

alter table setup add Setup_LicenseNo varchar(100);
alter table setup add Setup_ClientSerialNo varchar(200);

#Tarek 2014-12-30
alter table temp_retail add Sale_numberofguests varchar(10);
alter table retail add Sale_numberofguests varchar(10);
alter table cashregister add CashRegister_ShowUserTables tinyint(1);

alter table ItemButtons add ItemButton_Level varchar(2);
alter table ItemButtons add ItemButton_RelatedItem varchar(45);

#Tarek 2015-01-05
alter table cashregister add CashRegister_AutoClosePrint tinyint(1) default 0;
alter table accesslabelsrocky.login add FC_ShowAllTables tinyint(1) default 0;



alter table retail add Sale_BelongsToGroup int(11) default 0;
alter table temp_retail add Sale_BelongsToGroup int(11) default 0;


#Tarek 2015-01-08
alter table accesslabelsrocky.printersubgroup add p_category varchar(50) default null;



#Tarek 2015-01-09
alter table accesslabelsrocky.login add column PR_status12 tinyint(1) default 1;
alter table accesslabelsrocky.login add column PO_status6 tinyint(1) default 1;
alter table accesslabelsrocky.login add column PO_status7 tinyint(1) default 1;
alter table accesslabelsrocky.login add FI_PendingPaymentRequest tinyint(1) default 0;
alter table accesslabelsrocky.login add PaymentRqstApproved_Level bigint(11);

alter table accesslabelsrocky.login add column PYR_default varchar(1);

alter table accesslabelsrocky.login add column PYR_status1 tinyint(1) default 1;
alter table accesslabelsrocky.login add column PYR_status2 tinyint(1) default 1;
alter table accesslabelsrocky.login add column PYR_status3 tinyint(1) default 1;
alter table accesslabelsrocky.login add PaymentRqstApproved_Level bigint(11);


alter table paymentrqst add PaymentRqst_ApprovedStatus varchar(1);
alter table paymentrqst add PaymentRqst_ApprovedLevel int(20);
alter table paymentrqst add PaymentRqst_RejectedReason varchar(100);



#Tarek 2015-01-13
alter table accesslabelsrocky.login drop column Login_AllowCostPer;
alter table accesslabelsrocky.login add Login_MinAllowCostPer double default 0;
alter table accesslabelsrocky.login add Login_MaxAllowCostPer double default 0;

#Maroun 2015-01-15
CREATE TABLE  `callerid` (
  `callerid_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `callerid_desc` varchar(45) DEFAULT NULL,
  `callerid_DATE` varchar(45) DEFAULT NULL,
  `callerid_TIME` varchar(45) DEFAULT NULL,
  `callerid_number` varchar(45) DEFAULT NULL,
  `caller_id_status` tinyint(1) unsigned DEFAULT '0',
  PRIMARY KEY (`callerid_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#Maroun 2015-01-15
ALTER TABLE `cashregister`  ADD COLUMN `CashRegister_CallerId` TINYINT(1) UNSIGNED DEFAULT 0 ,
ADD COLUMN `CashRegister_CallerIdCOM` VARCHAR(45) ;
 


#Tarek 2015-01-19
alter table cashregistermenu add Menu_Belongstogrp int(11);

#Tarek 2015-01-23
alter table accesslabelsrocky.login add FC_CashRegisterMenu tinyint(1) default 1;



#Maroun 2015-02-02
alter table retaildt add saledt_printed tinyint(1) default 0;
alter table temp_retaildt add saledt_printed tinyint(1) default 0;
alter table CashRegister add CashRegister_SlipRePrinter tinyint(1) default 0;


ALTER TABLE `customer` MODIFY COLUMN `Customer_Address` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#Maroun 2015-02-11
ALTER TABLE `module` ADD COLUMN `Module_GroupHoldFire` TINYINT(1) DEFAULT 0 ;

#Maroun 2015-02-17
alter table clients add client_showcreditlimit tinyint(1) default 0;
alter table clients add client_showmaturitydate tinyint(1) default 0;
alter table temp_retail add payment_description varchar(50);
alter table retail add payment_description varchar(50);

alter table accesslabelsrocky.login add FC_CashRegisterHold tinyint(1) default 0;
alter table module add Module_HoldPermission tinyint(1) default 0;

alter table purchasesetup add ShowItemSellingPrice tinyint(1) default 0;

#maroun 2015.02.20
alter table accesslabelsrocky.loginstk add ShowReportHeader tinyint(1) default 1;

#maroun 2015.02.24
alter table cashregister add cashregister_logout tinyint(1) default 0;
alter table subgroup add subgroup_order double ;
alter table cashregister add cashregister_retailtype varchar(20);
alter table accesslabelsrocky.login add FC_RetailStatistics tinyint(1) default 1;

#maroun 20150227
alter table prequestdt add prequestdt_unitsalesdesc varchar(20);
alter table temp_prequestdt add prequestdt_unitsalesdesc varchar(20);

alter table module add Module_TransferConfirmation tinyint(1) default 0;
ALTER TABLE accesslabelsrocky.loginstk  ADD COLUMN `TransferWH` VARCHAR(20) ;
alter table transfer add transfer_confirmed tinyint(1) default 0;

#maroun 20150312
CREATE TABLE  `sellingpricehistory` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `username` varchar(45) NOT NULL,
  `item_id` bigint(20) unsigned DEFAULT NULL,
  `fieldname` varchar(200) DEFAULT NULL,
  `value_before` double DEFAULT NULL,
  `value_after` double DEFAULT NULL,
  `datemodified` datetime DEFAULT NULL,
  `currency_code` varchar(45) DEFAULT NULL,
  `groupid` bigint(20) unsigned DEFAULT NULL,
  PRIMARY KEY (`id`)
);


alter table project add PRequest_Reference double default 0;
alter table module add PrequestReferenceByProject tinyint(1) default 0;

alter table porder add Porder_Charges double;
alter table porder add Porder_ChargesBase1 double;
alter table porder add Porder_ChargesBase2 double;
alter table porder add Porder_VatCharges double;
alter table porder add Porder_VatChargesBase1 double;
alter table porder add Porder_VatChargesBase2 double;
alter table porderdt add PorderDt_VatCharge double;
alter table porderdt add PorderDt_VatChargeBase1 double;
alter table porderdt add PorderDt_VatChargeBase2 double;
alter table porderdt add PorderDt_Charges double;
alter table porderdt add PorderDt_ChargesBase1 double;
alter table porderdt add PorderDt_ChargesBase2 double;

alter table temp_porder add Porder_Charges double;
alter table temp_porder add Porder_ChargesBase1 double;
alter table temp_porder add Porder_ChargesBase2 double;
alter table temp_porder add Porder_VatCharges double;
alter table temp_porder add Porder_VatChargesBase1 double;
alter table temp_porder add Porder_VatChargesBase2 double;
alter table temp_porderdt add PorderDt_Charges double;
alter table temp_porderdt add PorderDt_ChargesBase1 double;
alter table temp_porderdt add PorderDt_ChargesBase2 double;
alter table temp_porderdt add PorderDt_VatCharge double;
alter table temp_porderdt add PorderDt_VatChargeBase1 double;
alter table temp_porderdt add PorderDt_VatChargeBase2 double;

alter table porderdt add PorderDt_Volume double;
alter table temp_porderdt add PorderDt_Volume double;
alter table porderdt add PorderDt_ChargePer double;
alter table temp_porderdt add PorderDt_ChargePer double;




#maroun 20.03.2015
ALTER TABLE `sellingpricehistory` ADD COLUMN `groupid` BIGINT ;
alter table accesslabelsrocky.login add FI_ShowPriceHistory tinyint(1) default 0;

#maroun 24.03.2015
alter table accesslabelsrocky.login add FC_SalesAnalysis tinyint(1) default 0;

#maroun 09.04.2015
alter table salesmen add salesmen_deactivatedate datetime;
alter table salesmen add salesmen_deactivate tinyint(1);


#maroun 14.04.2015
alter table temp_purchasecharges add purchasecharges_remark varchar(500);
alter table purchasecharges add purchasecharges_remark varchar(500);


ALTER TABLE module ADD COLUMN `Module_RestrictProjectReport` tinyint(1) default 1;

alter table setup add discount_amount double default 0;

#maroun 29.04.2015
alter table setup add category_order double;
alter table setup add category_length double;
alter table setup add group_order double;
alter table setup add group_length double;
alter table setup add subgroup_order double;
alter table setup add subgroup_length double;
alter table setup add remaining_length double;

alter table module add module_autoitemcode double default 0;

alter table grouping add group_length double default 0;
alter table subgroup add subgroup_length double default 0;
alter table category add category_length double default 0;


alter table module add module_autoledger tinyint(1) default 0;




alter table ledger add ledger_sequence tinyint(1) default 0;
alter table ledger add ledger_length double default 8;


alter table module add Module_Checks tinyint(1) default 1;


alter table module add Module_Heatno tinyint(1) default 0;
CREATE TABLE `HeatNo` (
  `HeatNo_Type` VARCHAR(50) NOT NULL,
  `HeatNo_No` VARCHAR(100) NOT NULL,
  PRIMARY KEY (`HeatNo_Type`, `HeatNo_No`)
)
ENGINE = InnoDB;

alter table Temp_GrnPurchasesDt add PurchaseDt_heatNo varchar(100);
alter table GrnPurchasesDt add PurchaseDt_heatNo varchar(100);

alter table Temp_PORDERDT add PorderDt_heatNo varchar(100);
alter table PORDERDT add PorderDt_heatNo varchar(100);

alter table temp_purchasesdt add purchasedt_heatno varchar(100);
alter table purchasesdt add purchasedt_heatno varchar(100);

alter table temp_transferdt add transferdt_heatno varchar(100);
alter table transferdt add transferdt_heatno  varchar(100);


alter table temp_adjustmentdt add adjustmentdt_heatno varchar(100);
alter table adjustmentdt add adjustmentdt_heatno  varchar(100);


alter table temp_deliverydt add deliverydt_heatno varchar(100);
alter table deliverydt add deliverydt_heatno  varchar(100);



#maroun 16.06.2015
alter table `accesslabelsrocky`.login add column FI_DeliveryStatus tinyint(1) default 0;



CREATE TABLE `deliverystatus_setup` (
  `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;



CREATE TABLE `delivery_deliverystatus` (
  `deliverystatus_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `deliverystatus_date` DATETIME NOT NULL,
  `status_id` DOUBLE NOT NULL,
  `username` VARCHAR(45) NOT NULL,
  `remark` VARCHAR(500),
  `delivery_id` BIGINT UNSIGNED NOT NULL,
  PRIMARY KEY (`deliverystatus_id`)
)
ENGINE = InnoDB;

CREATE TABLE  `delivery_lotnumber` (
  `lotnumber_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `lotnumber_qty` double NOT NULL,
  `lotnumber_number` varchar(500) DEFAULT NULL,
  `deliverydt_id` bigint(20) unsigned NOT NULL,
  PRIMARY KEY (`lotnumber_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

CREATE TABLE `clientfollowup` (
  `clientfollowup_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `clientfollowup_date` DATETIME,
  `clientfollowup_reason` VARCHAR(500),
  `clientfollowup_response` VARCHAR(500),
  `clientfollowup_status` VARCHAR(45),
  `username` VARCHAR(45),
  `client_id` BIGINT UNSIGNED,
  PRIMARY KEY (`clientfollowup_id`)
)
;


ALTER TABLE `delivery_deliverystatus` ADD INDEX `Index_2`(`delivery_id`);


#maroun 13.07.2015
alter table `accesslabelsrocky`.login add column FI_heatNo tinyint(1) default 0;
ALTER TABLE `heatno` ADD COLUMN `heatno_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT AFTER `HeatNo_No`,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY  USING BTREE(`heatno_id`);
 
 ALTER TABLE `heatno` ADD UNIQUE INDEX `Index_2`(`HeatNo_No`, `HeatNo_Type`);
 
 
 
alter table temp_productiondt add productiondt_heatno varchar(100);
alter table productiondt add productiondt_heatno  varchar(100);


alter table Temp_ProductionFG add productionfg_heatno varchar(100);
alter table ProductionFG add productionfg_heatno  varchar(100);


alter table Temp_ProductionRM add productionRM_heatno varchar(100);
alter table ProductionRM add productionRM_heatno  varchar(100);

#maroun 22.07.2015
alter table Temp_ProductionFG add productionfg_bundle varchar(100);
alter table ProductionFG add productionfg_bundle  varchar(100);


alter table Temp_ProductionRM add productionRM_bundle varchar(100);
alter table ProductionRM add productionRM_bundle  varchar(100);

alter table stkTransaction add item_heatno varchar(100);
alter table regreceiptheader add regreceiptheader_reference double;


alter table module add module_Checkzerosales tinyint(1) default 0;

ALTER TABLE `accesslabelsrocky`.`login` Add FI_StockOutRequest tinyint(1) default 0;
alter table adjustmentRequest add prqst_id bigint;



alter table module add module_purchasezero tinyint(1) default 0;

alter table module add module_limit tinyint(1) default 0;

alter table `accesslabelsrocky`.login add Login_porderLimit double;;



CREATE TABLE  `projectlimit` (
  `projectlimit_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `project_code` varchar(10) NOT NULL,
  `user_account` varchar(45) NOT NULL,
  `projectlimit_limit` double NOT NULL,
  PRIMARY KEY (`projectlimit_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


alter table module add module_limitProject tinyint(1) default 0;

alter table module add Module_ShowWarehouseSalesorder tinyint(1) default 1;


alter table costcent add costcent_applyvat tinyint(1) default 1;


alter table temp_retail add discount_user varchar(50);
alter table retail add discount_user varchar(50);


alter table accesslabelsrocky.login add FC_RetailViewer tinyint(1) default 0;


alter table setup add delivery_maxrecords double;


alter table module add module_autodiscount tinyint(1) default 0;

alter table deliverystatus_setup add deliverystatus_level double;
alter table accesslabelsrocky.users add deliverystatus_level double;


alter table accesslabelsrocky.login add RI_Adjustment varchar(100);

alter table items add item_fixedcost double;
ALTER TABLE `items` ADD INDEX `Index_fixed`(`item_fixedcost`);


alter table items add item_codeexport varchar(20);
alter table items add item_descriptionexporten varchar(100);
alter table items add item_descriptionexportar varchar(100);
alter table items add item_descriptionexportfr varchar(100);



alter table clients add client_discountonInvoice double;

alter table module add module_chargespurchase tinyint(1) default 0;


alter table temp_porder add porder_othercharges double;
alter table porder add porder_othercharges double;


alter table purchasesetup add porder_termsconditions varchar(1000);

alter table purchases add purchase_paymentcondition varchar(1000);
alter table temp_purchases add purchase_paymentcondition varchar(1000);


alter table deliverydt add deliverydt_clientdiscount double;
alter table deliverydt add deliverydt_itemdiscount double;

alter table temp_deliverydt add deliverydt_clientdiscount double;
alter table temp_deliverydt add deliverydt_itemdiscount double;


alter table sorderdt add sorderdt_clientdiscount double;
alter table sorderdt add sorderdt_itemdiscount double;

alter table temp_sorderdt add sorderdt_clientdiscount double;
alter table temp_sorderdt add sorderdt_itemdiscount double;




#salma 23.11.2015

CREATE TABLE  `preproduction` (
  `Production_id` double NOT NULL,
  `Production_Reference` double DEFAULT NULL,
  `Production_Date` datetime DEFAULT NULL,
  `Item_Code` varchar(20) DEFAULT NULL,
  `SerialNo_Code` varchar(20) DEFAULT NULL,
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `Production_quantity` double DEFAULT '1',
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `Production_Remark` varchar(100) DEFAULT NULL,
  `Journal_id` double DEFAULT NULL,
  `Production_Total` double DEFAULT NULL,
  `Production_TotalBase1` double DEFAULT NULL,
  `Production_TotalBase2` double DEFAULT NULL,
  `Production_ExpireDate` datetime DEFAULT NULL,
  `ProductionDt_Id` double DEFAULT NULL,
  `Production_edit` tinyint(1) DEFAULT '0',
  `Size_Measure` varchar(15) DEFAULT NULL,
  `Color_code` varchar(15) DEFAULT NULL,
  `Production_MeanOrLastCost` int(11) DEFAULT '0',
  `Production_ItemAccount` varchar(11) DEFAULT NULL,
  `Production_BelongsToGroup` int(11) DEFAULT NULL,
  `PreProduction_id` double DEFAULT NULL,
  `Production_idealqty` double DEFAULT '1',
  `Production_IdealTotal` double DEFAULT NULL,
  `SERIALNO_CODEREF` double DEFAULT NULL,
  `Production_DirectStkDbt` varchar(11) DEFAULT NULL,
  `Production_DirectStkCrd` varchar(11) DEFAULT NULL,
  `Production_DirectStkCur` varchar(7) DEFAULT NULL,
  `Production_posted` tinyint(1) DEFAULT '0',
  `Sendreceive_reference` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Barcode` tinyint(1) DEFAULT '0',
  `Production_waste` double DEFAULT '0',
  `TimeStart` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `TimeStop` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `CounterStart` double DEFAULT NULL,
  `CounterStop` double DEFAULT NULL,
  `Production_WasteDebit` varchar(10) DEFAULT NULL,
  `Production_WasteCredit` varchar(10) DEFAULT NULL,
  `Production_WasteDiff` varchar(10) DEFAULT NULL,
  `Production_Reversed` int(11) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `User_account` varchar(30) DEFAULT NULL,
  `production_type` varchar(10) DEFAULT NULL,
  `subgroup_code` varchar(10) DEFAULT NULL,
  `production_WIDTH` double DEFAULT '0',
  `production_WIDTHTrim` double DEFAULT '0',
  `production_WIDTHTrimPer` double DEFAULT '0',
  `production_ActualNetWidth` double DEFAULT '0',
  `production_thick` double DEFAULT '0',
  `production_ActualNetWeight` double DEFAULT '0',
  `production_BabyQuantity` double DEFAULT '1',
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `Production_BatchNo` varchar(40) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`PreProduction_id`),
  KEY `FK_Preproduction_Branch` (`BRANCH_CODE`),
  KEY `Preproductionproject_code` (`Project_Code`),
  KEY `Preproductionitem_code` (`Item_Code`),
  KEY `Preproductionwarehouse_code` (`Warehouse_Code`),
  KEY `PreReference` (`Production_Reference`),
  KEY `Predate` (`Production_Date`),
  CONSTRAINT `FK_Preproduction_Branch` FOREIGN KEY (`BRANCH_CODE`) REFERENCES `branches` (`BRANCH_CODE`),
  CONSTRAINT `Preproductionitem_code` FOREIGN KEY (`Item_Code`) REFERENCES `items` (`Item_Code`),
  CONSTRAINT `Preproductionproject_code` FOREIGN KEY (`Project_Code`) REFERENCES `project` (`Project_Code`),
  CONSTRAINT `Preproductionwarehouse_code` FOREIGN KEY (`Warehouse_Code`) REFERENCES `warehouse` (`Warehouse_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `preproductiondt` (
  `ProductionDt_id` double NOT NULL,
  `Production_id` double DEFAULT NULL,
  `Production_Date` datetime DEFAULT NULL,
  `Item_Code` varchar(20) DEFAULT NULL,
  `SerialNo_Code` varchar(20) DEFAULT NULL,
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `ProductionDt_Quantity` double DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `ProductionDt_cost` double DEFAULT NULL,
  `ProductionDt_CostBase1` double DEFAULT NULL,
  `ProductionDt_CostBase2` double DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `ProductionDt_ExpireDate` datetime DEFAULT NULL,
  `Size_Measure` varchar(15) DEFAULT NULL,
  `Color_Code` varchar(15) DEFAULT NULL,
  `Item_Barcode` varchar(20) DEFAULT NULL,
  `Productiondt_ItemAccount` varchar(11) DEFAULT NULL,
  `Productiondt_idealqty` double DEFAULT '1',
  `ProductionDt_DirectStkDbt` varchar(11) DEFAULT NULL,
  `ProductionDt_DirectStkCrd` varchar(11) DEFAULT NULL,
  `ProductionDt_DirectStkCur` varchar(7) DEFAULT NULL,
  `Item_CodePacked` varchar(21) DEFAULT NULL,
  `Item_qtyPacked` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Production_DefaultSerial` tinyint(1) DEFAULT '0',
  `Productiondt_Remark` varchar(50) DEFAULT NULL,
  `ProductionDt_Waste` double DEFAULT '0',
  `ProductionDt_WasteDebit` varchar(10) DEFAULT NULL,
  `ProductionDt_WasteCredit` varchar(10) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `Productionmaster_id` double DEFAULT NULL,
  `item_special` tinyint(1) DEFAULT '0',
  `productiondt_Weight` double DEFAULT '0',
  `productiondt_width` double DEFAULT '0',
  `ProductionDt_BatchNo` varchar(40) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  `ProductionDt_Checked` tinyint(1) DEFAULT '1',
  `productiondt_heatno` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`ProductionDt_id`),
  KEY `Preproductiondtproject_code` (`Project_Code`),
  KEY `Preproductiondtitem_code` (`Item_Code`),
  KEY `Preproductiondtwarehouse_code` (`Warehouse_Code`),
  KEY `Preproductiondtproduction_id` (`Production_id`),
  KEY `Idx_LoggedCode` (`Logged_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `temp_preproduction` (
  `Production_id` double NOT NULL,
  `Production_Reference` double DEFAULT NULL,
  `Production_Date` datetime DEFAULT NULL,
  `Item_Code` varchar(20) DEFAULT NULL,
  `SerialNo_Code` varchar(20) DEFAULT NULL,
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `Production_quantity` double DEFAULT '1',
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `Production_Remark` varchar(100) DEFAULT NULL,
  `Journal_id` double DEFAULT NULL,
  `Production_Total` double DEFAULT NULL,
  `Production_TotalBase1` double DEFAULT NULL,
  `Production_TotalBase2` double DEFAULT NULL,
  `Production_ExpireDate` datetime DEFAULT NULL,
  `ProductionDt_Id` double DEFAULT NULL,
  `Production_edit` tinyint(1) DEFAULT '0',
  `Size_Measure` varchar(15) DEFAULT NULL,
  `Color_code` varchar(15) DEFAULT NULL,
  `Production_MeanOrLastCost` int(11) DEFAULT '0',
  `Production_ItemAccount` varchar(11) DEFAULT NULL,
  `Production_BelongsToGroup` int(11) DEFAULT NULL,
  `PreProduction_id` double DEFAULT NULL,
  `Production_idealqty` double DEFAULT '1',
  `Production_IdealTotal` double DEFAULT NULL,
  `SERIALNO_CODEREF` double DEFAULT NULL,
  `Production_DirectStkDbt` varchar(11) DEFAULT NULL,
  `Production_DirectStkCrd` varchar(11) DEFAULT NULL,
  `Production_DirectStkCur` varchar(7) DEFAULT NULL,
  `Production_posted` tinyint(1) DEFAULT '0',
  `Sendreceive_reference` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Barcode` tinyint(1) DEFAULT '0',
  `Production_waste` double DEFAULT '0',
  `TimeStart` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `TimeStop` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `CounterStart` double DEFAULT NULL,
  `CounterStop` double DEFAULT NULL,
  `Production_WasteDebit` varchar(10) DEFAULT NULL,
  `Production_WasteCredit` varchar(10) DEFAULT NULL,
  `Production_WasteDiff` varchar(10) DEFAULT NULL,
  `Production_Reversed` int(11) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `User_account` varchar(30) DEFAULT NULL,
  `production_type` varchar(10) DEFAULT NULL,
  `subgroup_code` varchar(10) DEFAULT NULL,
  `production_WIDTH` double DEFAULT '0',
  `production_WIDTHTrim` double DEFAULT '0',
  `production_WIDTHTrimPer` double DEFAULT '0',
  `production_ActualNetWidth` double DEFAULT '0',
  `production_thick` double DEFAULT '0',
  `production_ActualNetWeight` double DEFAULT '0',
  `production_BabyQuantity` double DEFAULT '1',
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `Production_BatchNo` varchar(40) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`PreProduction_id`),
  KEY `FK_production_Branch` (`BRANCH_CODE`),
  KEY `Preproductionproject_code` (`Project_Code`),
  KEY `Preproductionitem_code` (`Item_Code`),
  KEY `Preproductionwarehouse_code` (`Warehouse_Code`),
  KEY `Idx_LoggedCode` (`Logged_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `temp_preproductiondt` (
  `ProductionDt_id` double NOT NULL,
  `Production_id` double DEFAULT NULL,
  `Production_Date` datetime DEFAULT NULL,
  `Item_Code` varchar(20) DEFAULT NULL,
  `SerialNo_Code` varchar(20) DEFAULT NULL,
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `ProductionDt_Quantity` double DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `ProductionDt_cost` double DEFAULT NULL,
  `ProductionDt_CostBase1` double DEFAULT NULL,
  `ProductionDt_CostBase2` double DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `ProductionDt_ExpireDate` datetime DEFAULT NULL,
  `Size_Measure` varchar(15) DEFAULT NULL,
  `Color_Code` varchar(15) DEFAULT NULL,
  `Item_Barcode` varchar(20) DEFAULT NULL,
  `Productiondt_ItemAccount` varchar(11) DEFAULT NULL,
  `Productiondt_idealqty` double DEFAULT '1',
  `ProductionDt_DirectStkDbt` varchar(11) DEFAULT NULL,
  `ProductionDt_DirectStkCrd` varchar(11) DEFAULT NULL,
  `ProductionDt_DirectStkCur` varchar(7) DEFAULT NULL,
  `Item_CodePacked` varchar(21) DEFAULT NULL,
  `Item_qtyPacked` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Production_DefaultSerial` tinyint(1) DEFAULT '0',
  `Productiondt_Remark` varchar(50) DEFAULT NULL,
  `ProductionDt_Waste` double DEFAULT '0',
  `ProductionDt_WasteDebit` varchar(10) DEFAULT NULL,
  `ProductionDt_WasteCredit` varchar(10) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `Productionmaster_id` double DEFAULT NULL,
  `item_special` tinyint(1) DEFAULT '0',
  `productiondt_Weight` double DEFAULT '0',
  `productiondt_width` double DEFAULT '0',
  `ProductionDt_BatchNo` varchar(40) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  `ProductionDt_Checked` tinyint(1) DEFAULT '1',
  `productiondt_heatno` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`ProductionDt_id`),
  KEY `Preproductiondtproject_code` (`Project_Code`),
  KEY `Preproductiondtitem_code` (`Item_Code`),
  KEY `Preproductiondtwarehouse_code` (`Warehouse_Code`),
  KEY `Preproductiondtproduction_id` (`Production_id`),
  KEY `Idx_LoggedCode` (`Logged_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#salma 1-12-2015
ALTER TABLE `preproduction` MODIFY COLUMN `Production_Delivery_Date` DATETIME;
ALTER TABLE `preproductiondt` ADD COLUMN `Production_Delivery_Date` DATETIME;
ALTER TABLE `temp_preproduction` MODIFY COLUMN `Production_Delivery_Date` DATETIME;
ALTER TABLE `temp_preproductiondt` ADD COLUMN `Production_Delivery_Date` DATETIME;

ALTER TABLE `items` ADD COLUMN `item_location` VARCHAR(30);

#salma 2-12-2015
ALTER TABLE `loginstk` ADD COLUMN `projectDt_table` VARCHAR(45);

#salma 4-12-2015
ALTER TABLE `loginstk` CHANGE COLUMN `projectDt_table` `projectDt_id` BIGINT UNSIGNED;

#nadine 14-12-2015

ALTER TABLE `customer` ADD COLUMN `Customer_special` INTEGER,
 ADD COLUMN `Customer_point` DOUBLE;
 
  CREATE TABLE `retailPoint` (
  `retailpoint _id` INTEGER NOT NULL AUTO_INCREMENT,
  `from_amount` DOUBLE,
  `to_amount` DOUBLE,
  `retail_point` DOUBLE,
  PRIMARY KEY (`retailpoint _id`)
)
ENGINE = InnoDB;

ALTER TABLE `retailpoint` CHANGE COLUMN `from_amount` `amount` DOUBLE DEFAULT NULL,
 DROP COLUMN `to_amount`;

#salma 17-12-2015
CREATE TABLE `sync` (
  `sync_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `sync_date` DATETIME,
  PRIMARY KEY (`sync_id`)
)
ENGINE = InnoDB;

ALTER TABLE `employees` ADD COLUMN `employee_typeid` BIGINT UNSIGNED;

#nadine  23-12-2015

ALTER TABLE accesslabelsrocky.login ADD COLUMN FI_SetDeliveryStatus TINYINT(1) default 0;
ALTER TABLE accesslabelsrocky.login ADD COLUMN FI_DeliveryStatusFrom INTEGER(1) default 2;
ALTER TABLE accesslabelsrocky.login ADD COLUMN FI_DeliveryStatusTo INTEGER(1) default 4;

#nadine 28-12-2015

ALTER TABLE `costcent` ADD COLUMN `costcent_applyvat` TINYINT(1) DEFAULT 1;

#nadine #30-12-2015

ALTER TABLE `module` ADD COLUMN `Module_Purchase_Pending` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Login_Purchase_Pending` TINYINT(1) DEFAULT 0;
ALTER TABLE `module` ADD COLUMN `module_autodiscount` TINYINT(1) DEFAULT 0, ROW_FORMAT = DYNAMIC;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_ModInvStatusDlv` TINYINT(1) DEFAULT 0;

ALTER TABLE `warehouse` ADD COLUMN `warehouse_type` VARCHAR(20),
ADD COLUMN `warehouse_parentId` VARCHAR(15), ENGINE = InnoDB;

ALTER TABLE `warehouse` ADD CONSTRAINT `FK_warehouse_1` FOREIGN KEY `FK_warehouse_1` (`warehouse_parentId`)
    REFERENCES `warehouse` (`Warehouse_code`)
    ON DELETE RESTRICT
    ON UPDATE CASCADE, ROW_FORMAT = DYNAMIC;
	
#nadine #4-1-2016

ALTER TABLE `temp_grnpurchasesdt` ADD COLUMN `Location_code` VARCHAR(15);

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Login_location` TINYINT(1) DEFAULT 0;

ALTER TABLE `module` ADD COLUMN `module_locationGrn` TINYINT(1) DEFAULT 0,
 ADD COLUMN `module_locationPurchases` TINYINT(1) DEFAULT 0,
 ADD COLUMN `module_locationDelivery` TINYINT(1) DEFAULT 0,
 ADD COLUMN `module_locationadjustment` TINYINT(1) DEFAULT 0,
 ADD COLUMN `module_locationTransfer` TINYINT(1) DEFAULT 0,
 ADD COLUMN `module_locationproduction` TINYINT(1) DEFAULT 0, ROW_FORMAT = DYNAMIC;
 
 #nadine #27-1-2016
 ALTER TABLE `transfersetup` ADD COLUMN `warehouse` VARCHAR(15);
 
 #nadine #3-2-2016
 ALTER TABLE `transfersetup` ADD COLUMN `warehouseFG` VARCHAR(15);
 
 ALTER TABLE `Temp_Deliveries` ADD COLUMN `delivery_export` tinyint(1) DEFAULT 0;
 ALTER TABLE `Deliveries` ADD COLUMN `delivery_export` tinyint(1) DEFAULT 0;

 ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_quantitybox` DOUBLE,
 ADD COLUMN `deliverydt_itemunit` DOUBLE,
 ADD COLUMN `deliverydt_itempackage` VARCHAR(100),
  ROW_FORMAT = DYNAMIC;
 
  ALTER TABLE `temp_deliverydt` ADD COLUMN `deliverydt_quantitybox` DOUBLE,
 ADD COLUMN `deliverydt_itemunit` DOUBLE,
 ADD COLUMN `deliverydt_itempackage` VARCHAR(100),
 ROW_FORMAT = DYNAMIC;
 
 #nadine #8-2-2016
ALTER TABLE `prequest` ADD COLUMN `user_confirmed` varchar(10);
ALTER TABLE `temp_purchasesserialno` ADD INDEX `Index_13`(`SerialNo_Code`);
ALTER TABLE `purchasesserialno` ADD INDEX `Index_12`(`SerialNo_Used`);
ALTER TABLE `purchasesserialno` DROP INDEX `Index_12`,
 ADD INDEX `Index_12` USING BTREE(`SerialNo_Code`);
 ALTER TABLE `purchasesserialno` ADD INDEX `Index_13`(`Warehouse_code`);
ALTER TABLE `temp_purchasesserialno` ADD INDEX `Index_14`(`Warehouse_code`);

#nadine #12-2-2016
ALTER TABLE `customer` ADD COLUMN `customer_card` VARCHAR(20);
#nadine #16-2-2016
ALTER TABLE `prequest` ADD COLUMN `Prqst_Cancelled` TINYINT(1) DEFAULT 0;
ALTER TABLE `module` ADD COLUMN `module_PRWarehouse` TINYINT(1) DEFAULT 0;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `PR_status13` TINYINT(1) DEFAULT 1;

#nadine #19-2-2016
ALTER TABLE `delivery_deliverystatus` ADD COLUMN `deliverystatus_last` DOUBLE;

#nadine #22-2-2016
ALTER TABLE `setup` ADD COLUMN `journal_setup` VARCHAR(200);
ALTER TABLE `module` ADD COLUMN `module_groupbyledger` TINYINT(1) DEFAULT 0;

ALTER TABLE `items` ADD COLUMN `item_discountper` DOUBLE;
ALTER TABLE `items` ADD COLUMN `item_descriptionexporten` varchar(100);

#nadine #7-3-2016
ALTER TABLE `grnpurchasesdt` ADD COLUMN `Location_code` VARCHAR(15);

#nadine #8-3-2016
ALTER TABLE `setup` ADD COLUMN `serialNb_quantity_setup` TINYINT(1) DEFAULT 1;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `Retail_Cancel` TINYINT(1) DEFAULT 1;
ALTER TABLE `purchasesdt` ADD COLUMN `Location_code` varchar(15);
ALTER TABLE `temp_purchasesdt` ADD COLUMN `Location_code` varchar(15);

ALTER TABLE `cashregister` ADD COLUMN `cashregister_DPbeforePosting` TINYINT(1) DEFAULT 0;

#nadine #9-3-2016
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_WHTChk` tinyint(1);
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_WHTAccount` varchar(10);
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_WHTPer` DOUBLE;
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_WHTAmt` DOUBLE;
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_WHTAmt1` DOUBLE,
 ADD COLUMN `Purchase_WHTAmt2` DOUBLE;

ALTER TABLE `purchases` ADD COLUMN `Purchase_WHTChk` tinyint(1);
ALTER TABLE `purchases` ADD COLUMN `Purchase_WHTAccount` varchar(10);
ALTER TABLE `purchases` ADD COLUMN `Purchase_WHTPer` DOUBLE;
ALTER TABLE `purchases` ADD COLUMN `Purchase_WHTAmt` DOUBLE;
ALTER TABLE `purchases` ADD COLUMN `Purchase_WHTAmt1` DOUBLE,
 ADD COLUMN `Purchase_WHTAmt2` DOUBLE;
 
 #nadine #15-3-2016
 ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_othercharges` DOUBLE;
 ALTER TABLE `purchases` ADD COLUMN `Purchase_othercharges` DOUBLE;
 
 ALTER TABLE `temp_grnpurchases` ADD COLUMN `grnpurchases_othercharges` DOUBLE;
 ALTER TABLE `grnpurchases` ADD COLUMN `grnpurchases_othercharges` DOUBLE;
 
 ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_otherchargesB1` DOUBLE;
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_otherchargesB2` DOUBLE;
 ALTER TABLE `purchases` ADD COLUMN `Purchase_otherchargesB1` DOUBLE;
 ALTER TABLE `purchases` ADD COLUMN `Purchase_otherchargesB2` DOUBLE;
 
 #nadine #24-3-2016
 ALTER TABLE `setup` ADD COLUMN `keyboardfocus` TINYINT(1) DEFAULT 0;
 
 #nadine #29-3-2016
 ALTER TABLE `module` ADD COLUMN `Module_Sorderproduction` TINYINT(1) DEFAULT 0;
 ALTER TABLE `production` ADD COLUMN `RelatedDt_Id` DOUBLE;
 ALTER TABLE `temp_production` ADD COLUMN `RelatedDt_Id` DOUBLE;
 ALTER TABLE `production` ADD COLUMN `Client_Code` varchar(10);
 ALTER TABLE `temp_production` ADD COLUMN `Client_Code` varchar(10);

 
 #nadine #31-3-2016
 #ALTER TABLE `deliveries` DROP COLUMN `RelatedDtprod_Id`;
 #ALTER TABLE `temp_deliveries` DROP COLUMN `RelatedDtprod_Id`;
 ALTER TABLE `temp_deliverydt` ADD COLUMN `RelatedDtprod_Id` DOUBLE;
 ALTER TABLE `deliverydt` ADD COLUMN `RelatedDtprod_Id` DOUBLE;
 ALTER TABLE `productionsetup` ADD COLUMN `Actual_Zero` TINYINT(1) DEFAULT 0;
 ALTER TABLE `production` ADD COLUMN `Quantity_Ill` DOUBLE;
 ALTER TABLE `temp_production` ADD COLUMN `Quantity_Ill` DOUBLE;
 
 alter table sorder add column sorder_export boolean;
alter table temp_sorder add column sorder_export boolean;

alter table sorderdt add column sorderdt_quantitybox double;
alter table temp_sorderdt add column sorderdt_quantitybox double;

alter table sorderdt add column sorderdt_itemunit double;
alter table temp_sorderdt add column sorderdt_itemunit double;

alter table sorderdt add column sorderdt_itempackage double;
alter table temp_sorderdt add column sorderdt_itempackage double;

 #nadine #1-4-2016
 ALTER TABLE `productionsetup` ADD COLUMN `productionReq_packdt` TINYINT(1) DEFAULT 0;

#nadine #5-4-2016 
 ALTER TABLE `salessetup` ADD COLUMN `packingXNbrOfUnit` TINYINT(1) DEFAULT 0;
ALTER TABLE `deliverydt` ADD COLUMN `deliverydt_packingkg` DOUBLE,
 ADD COLUMN `deliverydt_nbrUnit` DOUBLE;

 ALTER TABLE `temp_deliverydt` ADD COLUMN `deliverydt_packingkg` DOUBLE,
 ADD COLUMN `deliverydt_nbrUnit` DOUBLE;

#nadine #6-4-2016

ALTER TABLE `temp_sorder` ADD COLUMN `Sorder_Total` DOUBLE;
ALTER TABLE `sorder` ADD COLUMN `Sorder_Total` DOUBLE;

ALTER TABLE `productionsetup` ADD COLUMN `Production_extraInfo` TINYINT(1);

 ALTER TABLE `production` ADD COLUMN `production_shadeStrd` VARCHAR(45),
 ADD COLUMN `production_strengthStrd` VARCHAR(45),
 ADD COLUMN `production_shadeAct` VARCHAR(45),
 ADD COLUMN `production_strengthAct` VARCHAR(45),
 ADD COLUMN `production_prevBatchno` VARCHAR(45),
 ADD COLUMN `production_referenceStd` VARCHAR(45),
 ADD COLUMN `production_viscosityDirect` VARCHAR(45),
 ADD COLUMN `production_viscosityReduced` VARCHAR(45),
 ADD COLUMN `packingdt_amountStrd` DOUBLE,
 ADD COLUMN `packingdt_nbrStrd` DOUBLE
 ADD COLUMN `packingdt_amountAct` DOUBLE,
 ADD COLUMN `packingdt_nbrAct` DOUBLE;

 ALTER TABLE `temp_production` ADD COLUMN `production_shadeStrd` VARCHAR(45),
 ADD COLUMN `production_strengthStrd` VARCHAR(45),
 ADD COLUMN `production_shadeAct` VARCHAR(45),
 ADD COLUMN `production_strengthAct` VARCHAR(45),
 ADD COLUMN `production_prevBatchno` VARCHAR(45),
 ADD COLUMN `production_referenceStd` VARCHAR(45),
 ADD COLUMN `production_viscosityDirect` VARCHAR(45),
 ADD COLUMN `production_viscosityReduced` VARCHAR(45),
 ADD COLUMN `packingdt_amountStrd` DOUBLE,
 ADD COLUMN `packingdt_nbrStrd` DOUBLE
 ADD COLUMN `packingdt_amountAct` DOUBLE,
 ADD COLUMN `packingdt_nbrAct` DOUBLE;

 #nadine #8-4-2016
 ALTER TABLE `items` ADD COLUMN `item_type` TINYINT(1);
 ALTER TABLE `jfolio` ADD COLUMN `prod_ref` INTEGER DEFAULT 0;
 
 ALTER TABLE `setup` ADD COLUMN `delivery_maxrecords` double;
 
 #nadine #11-4-2016
 ALTER TABLE `items` DROP COLUMN `item_type`;
ALTER TABLE `items` ADD COLUMN `item_reducer` VARCHAR(100),
 ADD COLUMN `item_retarder` VARCHAR(100);

 ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_itemTransfer` TINYINT(1) DEFAULT 0;

  ALTER TABLE `module` ADD COLUMN `module_CheckItem` TINYINT(1) DEFAULT 0;
   ALTER TABLE `module` ADD COLUMN `module_pendingprocess` TINYINT(1) DEFAULT 0;
 ALTER TABLE `module` ADD COLUMN `PrequestReferenceByProject` TINYINT(1) DEFAULT 0;
 
 #nadine #20-4-2016
 ALTER TABLE `items` ADD COLUMN `item_Shade` VARCHAR(45),
 ADD COLUMN `item_Strength` VARCHAR(45),
 ADD COLUMN `item_Packing` DOUBLE,
 ADD COLUMN `item_ViscosityDirect` VARCHAR(45),
 ADD COLUMN `item_ViscosityReduced` VARCHAR(45);
 
 ALTER TABLE `packdt` ADD COLUMN `item_stage` VARCHAR(50);
 
 ALTER TABLE `productionsetup` ADD COLUMN `ShowStage` TINYINT(1) DEFAULT 0;
ALTER TABLE `productionsetup` ADD COLUMN `ShowAdditions` TINYINT(1) DEFAULT 0;

ALTER TABLE `temp_productiondt` ADD COLUMN `productiondt_initialQty` DOUBLE,
 ADD COLUMN `productiondt_addition` DOUBLE DEFAULT 0;
ALTER TABLE `productiondt` ADD COLUMN `productiondt_initialQty` DOUBLE,
 ADD COLUMN `productiondt_addition` DOUBLE DEFAULT 0;
 #nadine #27-4-2016
 ALTER TABLE `temp_paymentrqst` ADD COLUMN `paymentrqst_cash` TINYINT(1) DEFAULT 0,
 ADD COLUMN `paymentrqst_check` TINYINT(1) DEFAULT 0,
 ADD COLUMN `paymentrqst_costshare` TINYINT(1) DEFAULT 0,
 ADD COLUMN `paymentrqst_guarantee` TINYINT(1) DEFAULT 0;

  ALTER TABLE `paymentrqst` ADD COLUMN `paymentrqst_cash` TINYINT(1) DEFAULT 0,
 ADD COLUMN `paymentrqst_check` TINYINT(1) DEFAULT 0,
 ADD COLUMN `paymentrqst_costshare` TINYINT(1) DEFAULT 0,
 ADD COLUMN `paymentrqst_guarantee` TINYINT(1) DEFAULT 0;
 
 ALTER TABLE `paymentsetup` ADD COLUMN `paymentrqstNoDt` TINYINT(1) DEFAULT 0;
 ALTER TABLE `temp_paymentrqst` ADD COLUMN `user_account` TINYINT(1);
ALTER TABLE `paymentrqst` ADD COLUMN `user_account` TINYINT(1);
ALTER TABLE `paymentrqst` ADD COLUMN `Logged_Code` varchar(10); 

ALTER TABLE `sequence` ADD COLUMN `notification_reference` DOUBLE DEFAULT 0;
ALTER TABLE `notification` ADD COLUMN `notification_field` VARCHAR(30);
ALTER TABLE `notification` MODIFY COLUMN `notification_description` VARCHAR(100) CHARACTER 
SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `salessetup` ADD COLUMN `autoReceiptAccount` VARCHAR(10);
ALTER TABLE `deliveries` ADD COLUMN `trans_id` BIGINT(20);
ALTER TABLE `temp_deliveries` ADD COLUMN `trans_id` BIGINT(20);

#nadine #29-4-2016
ALTER TABLE `module` ADD COLUMN `module_SalesAutoReceipt` TINYINT(1) DEFAULT 0;

#nadine #4-5-2016

ALTER TABLE `project` ADD COLUMN `project_email` VARCHAR(1000);
CREATE TABLE `configurationemail` (
  `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `hostname` VARCHAR(50),
  `mailagent` VARCHAR(45),
  `port` INT(10),
  `username` VARCHAR(45),
  `password` VARCHAR(100),
  `SenderEmail` VARCHAR(100),
  `ReceiverEmail` VARCHAR(100),
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;

#nadine #6-5-2016

alter table temp_production add column production_gloss varchar(50);
alter table temp_production add column production_Adhesion varchar(50);
alter table temp_production add column production_Alkali  varchar(50);
alter table temp_production add column production_scuff varchar(50);

alter table production add column production_gloss varchar(50);
alter table production add column production_Adhesion varchar(50);
alter table production add column production_Alkali  varchar(50);
alter table production add column production_scuff varchar(50);

alter table items add column item_gloss varchar(50);
alter table items add column item_Adhesion varchar(50);
alter table items add column item_Alkali  varchar(50);
alter table items add column item_scuff varchar(50);

#nadine #9-5-2016
ALTER TABLE `module` ADD COLUMN `module_journalRate` TINYINT(1) DEFAULT 0;
ALTER TABLE `journaldt` ADD COLUMN `journaldt_rate` DOUBLE;
ALTER TABLE `temp_journaldt` ADD COLUMN `journaldt_rate` DOUBLE;

#nadine #10-5-2016
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `RI_Procurement` TINYINT(1) DEFAULT 0;
ALTER TABLE `temp_cstjourdt` ADD COLUMN `Logged_Code` VARCHAR(30) AFTER `user_account`;
ALTER TABLE `cstjourdt` ADD COLUMN `Logged_Code` VARCHAR(30) AFTER `user_account`;

#nadine #11-5-2016

CREATE TABLE accesslabelsrocky.`headerlink` (
  `headerlink_id` INTEGER NOT NULL AUTO_INCREMENT,
  `headerlink_date` DATE,
  `year` year(4),
  `id` INTEGER,
  `company` VARCHAR(100),
  `journal_type` VARCHAR(10),
  `form_id` INTEGER,
  `ledger_number` VARCHAR(15),
  `project_code` VARCHAR(45),
  `costcent_code` VARCHAR(45),
  `saleman_number` VARCHAR(45),
  `amount` DOUBLE,
  `amountbase1` DOUBLE,
  `amountbase2` DOUBLE,
  `amount_paid` DOUBLE,
  `amountbase1_paid` DOUBLE,
  `amountbase2_paid` DOUBLE,
  `amount_remaining` DOUBLE,
  `amountbase1_remaining` DOUBLE,
  `amountbase2_remaining` DOUBLE,
  `currency_code` VARCHAR(45),
  `remark` VARCHAR(100),
  PRIMARY KEY (`headerlink_id`)
)
ENGINE = InnoDB;


CREATE TABLE accesslabelsrocky.`Detaillink` (
  `Detaillink_id` INTEGER NOT NULL AUTO_INCREMENT,
  `Detaillink_date` DATE,
  `year` year(4),
  `id` INTEGER,
  `company` VARCHAR(100),
  `journal_type` VARCHAR(10),
  `form_id` int(11),
  `ledger_number` varchar(15),
  `project_code` VARCHAR(45),
  `costcent_code` VARCHAR(45),
  `amount` DOUBLE,
  `amountbase1` DOUBLE,
  `amountbase2` DOUBLE,
  `amount_paid` DOUBLE,
  `amountbase1_paid` DOUBLE,
  `amountbase2_paid` DOUBLE,
  `amount_remaining` DOUBLE,
  `amountbase1_remaining` DOUBLE,
  `amountbase2_remaining` DOUBLE,
  `currency_code` VARCHAR(45),
  `remark` VARCHAR(100),
  PRIMARY KEY (`Detaillink_id`)
)
ENGINE = InnoDB;

ALTER TABLE accesslabelsrocky.`login` ADD COLUMN `warehouse_excluded` VARCHAR(50);

alter table production add column (packingdt_amountAct2 double ,packingdt_nbrAct2 double);
alter table temp_production add column (packingdt_amountAct2 double ,packingdt_nbrAct2 double);

#nadine #13-05-2016
CREATE TABLE `LedgerInvoice` (
  `LedgerInvoice_id` INTEGER NOT NULL AUTO_INCREMENT,
  `Ledger_number` VARCHAR(10),
  PRIMARY KEY (`LedgerInvoice_id`)
)
ENGINE = InnoDB;

alter table production add column (Transfer_id double);
alter table temp_production add column (Transfer_id double);

#nadine #11-5-2016

CREATE TABLE accesslabelsrocky.`temp_headerlink` (
  `headerlink_id` INTEGER NOT NULL,
  `headerlink_date` DATE,
  `year` year(4),
  `id` INTEGER,
  `company` VARCHAR(100),
  `journal_type` VARCHAR(10),
  `form_id` INTEGER,
  `ledger_number` VARCHAR(15),
  `project_code` VARCHAR(45),
  `costcent_code` VARCHAR(45),
  `saleman_number` VARCHAR(45),
  `amount` DOUBLE,
  `amountbase1` DOUBLE,
  `amountbase2` DOUBLE,
  `amount_paid` DOUBLE,
  `amountbase1_paid` DOUBLE,
  `amountbase2_paid` DOUBLE,
  `amount_remaining` DOUBLE,
  `amountbase1_remaining` DOUBLE,
  `amountbase2_remaining` DOUBLE,
  `currency_code` VARCHAR(45),
  `remark` VARCHAR(100),
  PRIMARY KEY (`headerlink_id`)
)
ENGINE = InnoDB;


CREATE TABLE accesslabelsrocky.`temp_detaillink` (
  `Detaillink_id` INTEGER NOT NULL AUTO_INCREMENT,
  `Detaillink_date` DATE,
  `year` year(4),
  `id` INTEGER,
  `company` VARCHAR(100),
  `journal_type` VARCHAR(10),
  `form_id` int(11),
  `ledger_number` varchar(15),
  `project_code` VARCHAR(45),
  `costcent_code` VARCHAR(45),
  `amount` DOUBLE,
  `amountbase1` DOUBLE,
  `amountbase2` DOUBLE,
  `amount_paid` DOUBLE,
  `amountbase1_paid` DOUBLE,
  `amountbase2_paid` DOUBLE,
  `amount_remaining` DOUBLE,
  `amountbase1_remaining` DOUBLE,
  `amountbase2_remaining` DOUBLE,
  `currency_code` VARCHAR(45),
  `remark` VARCHAR(100),
  PRIMARY KEY (`Detaillink_id`)
)
ENGINE = InnoDB;

#nadine #19-5-2016

ALTER TABLE `porder` ADD COLUMN `Confirmed_date` DATETIME;
ALTER TABLE `temp_porder` ADD COLUMN `Confirmed_date` DATETIME;
ALTER TABLE `porderdt` ADD COLUMN `Approval_date` DATETIME;
ALTER TABLE `temp_porderdt` ADD COLUMN `Approval_date` DATETIME;

ALTER TABLE `prequest` ADD COLUMN `Confirm_date` DATETIME;
ALTER TABLE `temp_prequest` ADD COLUMN `Confirm_date` DATETIME;
ALTER TABLE `temp_prequestdt` ADD COLUMN `Approved_date` DATETIME;
ALTER TABLE `prequestdt` ADD COLUMN `Approved_date` DATETIME;

ALTER TABLE `transferrequestdt` ADD COLUMN `Approval_date` DATETIME;
ALTER TABLE `temp_transferrequestdt` ADD COLUMN `Approval_date` DATETIME;

ALTER TABLE `adjustmentrequestdt` ADD COLUMN `Approval_date` DATETIME;
ALTER TABLE `temp_adjustmentrequestdt` ADD COLUMN `Approval_date` DATETIME;

ALTER TABLE `trans` ADD COLUMN `AdvancePayment` TINYINT(1) DEFAULT 0;
ALTER TABLE `temp_trans` ADD COLUMN `AdvancePayment` TINYINT(1) DEFAULT 0;

#nadine #24-5-2016
ALTER TABLE `journaldt` ADD COLUMN `journaldt_rate2` DOUBLE;
ALTER TABLE `temp_journaldt` ADD COLUMN `journaldt_rate2` DOUBLE;





CREATE TABLE  `viewerretail` (
  `viewer_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `viewer_date` datetime NOT NULL,
  `user_account` varchar(45) DEFAULT NULL,
  `cashregister_name` varchar(45) DEFAULT NULL,
  `trans_id` bigint(20) unsigned DEFAULT NULL,
  `trans_reference` varchar(45) DEFAULT NULL,
  `trans_date` datetime DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `user_discount` varchar(45) DEFAULT NULL,
  `trans_account1` varchar(45) DEFAULT NULL,
  `trans_account2` varchar(45) DEFAULT NULL,
  `FormName` varchar(45) DEFAULT NULL,
  `Trans_Type` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`viewer_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1135 DEFAULT CHARSET=utf8;

ALTER TABLE `setup` ADD COLUMN `CashAccount` VARCHAR(10) ;
ALTER TABLE `setup` ADD COLUMN `NbrOfDigitInItem` int(11) ;
ALTER TABLE `setup` ADD COLUMN `id` int(10) ;
ALTER TABLE `purchasesetup` ADD COLUMN `id` int(10) ;
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccount2` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccount3` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountVat2` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountVat3` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountNonStock` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountNonStock2` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountNonStock3` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountVATNonStock` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountVATNonStock2` varchar(10);
ALTER TABLE `purchasesetup` ADD COLUMN `DebitAccountVATNonStock3` varchar(10);
ALTER TABLE `salessetup` ADD COLUMN `Sale_changeClient` tinyint(1);
ALTER TABLE `salessetup` ADD COLUMN `id` int(11);

#nadine #8-6-2016
ALTER TABLE `accesslabelsrocky`.`detaillink` DROP COLUMN `amount_paid`,
 DROP COLUMN `amountbase1_paid`,
 DROP COLUMN `amountbase2_paid`,
 DROP COLUMN `amount_remaining`,
 DROP COLUMN `amountbase1_remaining`,
 DROP COLUMN `amountbase2_remaining`,
 ADD COLUMN `related_journalType` VARCHAR(10);
 
 ALTER TABLE `accesslabelsrocky`.`headerlink` DROP COLUMN `amount_paid`,
 DROP COLUMN `amountbase1_paid`,
 DROP COLUMN `amountbase2_paid`,
 DROP COLUMN `amount_remaining`,
 DROP COLUMN `amountbase1_remaining`,
 DROP COLUMN `amountbase2_remaining`,
 ADD COLUMN `reference` DOUBLE;

 ALTER TABLE `accesslabelsrocky`.`temp_detaillink` DROP COLUMN `amount_paid`,
 DROP COLUMN `amountbase1_paid`,
 DROP COLUMN `amountbase2_paid`,
 DROP COLUMN `amount_remaining`,
 DROP COLUMN `amountbase1_remaining`,
 DROP COLUMN `amountbase2_remaining`,
 ADD COLUMN `related_journalType` VARCHAR(10);
 

 ALTER TABLE `accesslabelsrocky`.`temp_headerlink` DROP COLUMN `amount_paid`,
 DROP COLUMN `amountbase1_paid`,
 DROP COLUMN `amountbase2_paid`,
 DROP COLUMN `amount_remaining`,
 DROP COLUMN `amountbase1_remaining`,
 DROP COLUMN `amountbase2_remaining`,
ADD COLUMN `reference` DOUBLE;

ALTER TABLE `accesslabelsrocky`.`temp_detaillink`
ADD COLUMN `saleman_number` varchar(45);

ALTER TABLE `accesslabelsrocky`.`detaillink`
ADD COLUMN `saleman_number` varchar(45);


ALTER TABLE `accesslabelsrocky`.`temp_detaillink` ADD COLUMN `relation_id` INTEGER;
ALTER TABLE `accesslabelsrocky`.`detaillink` ADD COLUMN `relation_id` INTEGER;
ALTER TABLE `accesslabelsrocky`.`headerlink` MODIFY COLUMN `form_id` VARCHAR(50) DEFAULT NULL;
ALTER TABLE `accesslabelsrocky`.`temp_headerlink` MODIFY COLUMN `form_id` VARCHAR(50) DEFAULT NULL;
ALTER TABLE `accesslabelsrocky`.`detaillink` MODIFY COLUMN `form_id` VARCHAR(50) DEFAULT NULL;
ALTER TABLE `accesslabelsrocky`.`temp_detaillink` MODIFY COLUMN `form_id` VARCHAR(50) DEFAULT NULL;
ALTER TABLE `accesslabelsrocky`.`temp_detaillink` MODIFY COLUMN `Detaillink_id` INT(11) NOT NULL;

#Saeid  #09-06-2016
ALTER TABLE `transactionsetup` ADD COLUMN `trans_export` VARCHAR(10);
ALTER TABLE `salessetup` ADD COLUMN `id` INT(11);

#nadine #11-06-2016

ALTER TABLE `purchasesdt` ADD COLUMN `purchasedt_unitPrince` DOUBLE,
 ADD COLUMN `purchasedt_freight` DOUBLE;
 
 ALTER TABLE `temp_purchasesdt` ADD COLUMN `purchasedt_unitPrince` DOUBLE,
 ADD COLUMN `purchasedt_freight` DOUBLE;
 
 ALTER TABLE `accesslabelsrocky`.`detaillink` ADD COLUMN `reference` DOUBLE;
 ALTER TABLE `accesslabelsrocky`.`temp_detaillink` ADD COLUMN `reference` DOUBLE;
 
 ALTER TABLE `productiondt` ADD COLUMN `productiondt_stage` VARCHAR(10);
 ALTER TABLE `temp_productiondt` ADD COLUMN `productiondt_stage` VARCHAR(10);

 #Saeid  #15-06-2016
 ALTER TABLE `items` ADD COLUMN `item_codeexport` VARCHAR(20) ;
ALTER TABLE `items` ADD COLUMN `item_descriptionexporten` VARCHAR(100) ;
ALTER TABLE `items` ADD COLUMN `item_descriptionexportar` VARCHAR(100) ;
ALTER TABLE `items` ADD COLUMN `item_descriptionexportfr` VARCHAR(100) ;

ALTER TABLE `items` ADD COLUMN `item_location` VARCHAR(30) ;
ALTER TABLE `items` ADD COLUMN `item_reducer` VARCHAR(100) ;
ALTER TABLE `items` ADD COLUMN `item_retarder` VARCHAR(100) ;
ALTER TABLE `items` ADD COLUMN `item_shade` VARCHAR(45) ;
ALTER TABLE `items` ADD COLUMN `item_strength` VARCHAR(100) ;

ALTER TABLE `items` ADD COLUMN `item_packing` double ;
ALTER TABLE `items` ADD COLUMN `item_viscositydirect` VARCHAR(45) ;
ALTER TABLE `items` ADD COLUMN `item_viscosityreduced` VARCHAR(45) ;
ALTER TABLE `items` ADD COLUMN `item_gloss` VARCHAR(50) ;
ALTER TABLE `items` ADD COLUMN `item_adhesion` VARCHAR(50) ;

ALTER TABLE `items` ADD COLUMN `item_alkali` VARCHAR(50) ;
ALTER TABLE `items` ADD COLUMN `item_scuff` VARCHAR(50) ;
 
 
  #nadine #24-06-2016
 ALTER TABLE `setup` ADD COLUMN `doubleunit_returndelivery` tinyint(1) default 0,
 ADD COLUMN `doubleunit_returnpurchase` tinyint(1) default 0;
 
 ALTER TABLE `Temp_Deliveries` ADD COLUMN `totalWeight` DOUBLE;
ALTER TABLE `Deliveries` ADD COLUMN `totalWeight` DOUBLE;
 
#nadine #1-07-2016

ALTER TABLE `sequence` ADD COLUMN `visit_reference` DOUBLE ;
ALTER TABLE `customer` ADD COLUMN `CustProject_Code` VARCHAR(15) ;
ALTER TABLE `customer` MODIFY COLUMN `Customer_Address` VARCHAR(500) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;


CREATE TABLE  `visit` (
  `visit_reference` double NOT NULL,
  `customer_code` varchar(10) DEFAULT NULL,
  `salesmen_code` varchar(10) DEFAULT NULL,
  `visit_date` datetime DEFAULT NULL,
  `visit_starttime` time DEFAULT NULL,
  `visit_endtime` time DEFAULT NULL,
  `visit_note` varchar(500) DEFAULT NULL,
  `visit_request` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`visit_reference`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

 #nadine #7-04-2016
 
 ALTER TABLE `visit`
 ADD COLUMN `Visit_type` VARCHAR(45),
ADD COLUMN `visit_followup` TINYINT(1) DEFAULT 0,
ADD COLUMN `Visit_followupdate` DATETIME;

#nadine #19-07-2016
ALTER TABLE `module`
 ADD COLUMN `module_visit` VARCHAR(45) default 0;

ALTER TABLE `Customer`
 ADD COLUMN `customer_group` VARCHAR(30),
 ADD COLUMN `customer_description` VARCHAR(100);
 
 
 CREATE TABLE `Customer_Offices` (
  `customer_officeId` INTEGER NOT NULL AUTO_INCREMENT,
  `Customer_Code` VARCHAR(10),
  `office_address` VARCHAR(500),
  `office_contact` VARCHAR(100),
  `mainoffice_id` INTEGER,
  PRIMARY KEY (`customer_officeId`)
)
ENGINE = InnoDB;

CREATE TABLE `CustomerContactInfo` (
  `contactinfo_id` INTEGER NOT NULL AUTO_INCREMENT,
  `customeroffice_id` INTEGER,
  `contact_firstname` VARCHAR(50),
  `contact_fathername` VARCHAR(50),
  `contact_lastname` VARCHAR(60),
  `contact_position` VARCHAR(60),
  `contact_phone1` VARCHAR(30),
  `contact_phone2` VARCHAR(30),
  `contact_phone3` VARCHAR(30),
  `contact_email1` VARCHAR(45),
  `contact_email2` VARCHAR(45),
  `contact_website` VARCHAR(45),
  PRIMARY KEY (`contactinfo_id`)
)
ENGINE = InnoDB;

CREATE TABLE `customer_project` (
  `customerproject_id` INTEGER NOT NULL AUTO_INCREMENT,
  `customerproject_desc` VARCHAR(100),
  `customerproject_address` VARCHAR(100),
  `customerproject_phone` VARCHAR(30),
  `customerproject_consultantname` VARCHAR(45),
  `customerproject_consultantdetail` VARCHAR(200),
  `customerproject_situation` TEXT,
  `customerproject_ironname` VARCHAR(50),
  `customerproject_competitorname` VARCHAR(70),
  `customerproject_parent` INTEGER,
  `customer_code` VARCHAR(10),
  `customerproject_contact` VARCHAR(100),
  PRIMARY KEY (`customerproject_id`)
)
ENGINE = InnoDB;

ALTER TABLE `visit` ADD COLUMN `visit_priceoffered` DOUBLE,
 ADD COLUMN `visit_paymentterms` VARCHAR(200),
 ADD COLUMN `visit_creditlimit` DOUBLE,
 ADD COLUMN `visit_gift` VARCHAR(100),
 ADD COLUMN `visit_result` VARCHAR(200),
 ADD COLUMN `visit_commission` VARCHAR(100),
 ADD COLUMN `visit_mainofficeId` INTEGER,
 ADD COLUMN `visit_branchofficeId` INTEGER,
 ADD COLUMN `visit_projectId` INTEGER;
 
 #nadine #25-07-2016
ALTER TABLE `purchasesetup` ADD COLUMN `purchase_doubleunit` TINYINT(1) default 0;
ALTER TABLE `AdjustmentSetup` ADD COLUMN `Adjustment_doubleunit` TINYINT(1) default 0;

#amin #27-07-2016

ALTER TABLE `deliveries` MODIFY COLUMN `Delivery_ShippingWay` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Delivery_ShipName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `deliveries` ADD COLUMN `Delivery_ClientDeliveryDate` DATETIME;
ALTER TABLE `deliveries` ADD COLUMN `Delivery_ClientPhone` VARCHAR(100);

ALTER TABLE `visit` MODIFY COLUMN `visit_priceoffered` VARCHAR(60) DEFAULT NULL;

#amin #29-07-2016

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_expirydate` date;

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_deactivate` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_deactivate_date` date;

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_complex_password` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_expiry` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_first_login` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FU_SalesmenTracking` TINYINT(1);

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SalesmanDailyVisit` TINYINT(1);

#nadine #01-08-2016
ALTER TABLE `customer` MODIFY COLUMN `customer_group` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `visit` ADD COLUMN `visit_followTime` DATETIME;
ALTER TABLE `visit` MODIFY COLUMN `visit_request` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `customer` MODIFY COLUMN `customer_card` CHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#amin #01-08-2016

ALTER TABLE `sorder` ADD COLUMN `Sorder_ClientSorderDate` DATETIME AFTER `sorder_export`,
 ADD COLUMN `Sorder_ClientPhone` VARCHAR(100) AFTER `Sorder_ClientSorderDate`,
 ADD COLUMN `Sorder_ShippingWay` VARCHAR(150) AFTER `Sorder_ClientPhone`,
 ADD COLUMN `Sorder_ShipName` VARCHAR(100) AFTER `Sorder_ShippingWay`;

 
 ALTER TABLE `temp_deliveries` MODIFY COLUMN `Delivery_ShippingWay` VARCHAR(150) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Delivery_ShipName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_deliveries` ADD COLUMN `Delivery_ClientDeliveryDate` DATETIME;
ALTER TABLE `temp_deliveries` ADD COLUMN `Delivery_ClientPhone` VARCHAR(100);

ALTER TABLE `temp_sorder` ADD COLUMN `Sorder_ClientSorderDate` DATETIME,
 ADD COLUMN `Sorder_ClientPhone` VARCHAR(100),
 ADD COLUMN `Sorder_ShippingWay` VARCHAR(150),
 ADD COLUMN `Sorder_ShipName` VARCHAR(100);
 
#amin #02-08-2016

ALTER TABLE `module` ADD COLUMN `Module_DirectStockSales` TINYINT(1);

#amin #04-08-2016 #sika #supplier_information

ALTER TABLE `items` ADD COLUMN `Manufacture_code` VARCHAR(100);

ALTER TABLE `suppliers` ADD COLUMN `Supplier_bank_name` VARCHAR(200);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_account_number` VARCHAR(100);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_iban` VARCHAR(100);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_swift` VARCHAR(100);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_bank_address` VARCHAR(250);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_designation` VARCHAR(100);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_is_iso` TINYINT(1);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_delivery_time` VARCHAR(100);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_port_of_loading` VARCHAR(100);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_incoterm` VARCHAR(50);
ALTER TABLE `suppliers` ADD COLUMN `Supplier_account_name` VARCHAR(50);

#amin #04-08-2016 #tiba #new_rout_form

CREATE TABLE `rout` (
  `rout_id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `Salesman_Code` VARCHAR(10),
  `rout_week` VARCHAR(10),
  `rout_day` VARCHAR(3),
  `client_code` VARCHAR(10),
  PRIMARY KEY (`rout_id`)
)
ENGINE = InnoDB;

ALTER TABLE `rout` ADD COLUMN `rout_day_num` TINYINT(1) UNSIGNED DEFAULT 1;
ALTER TABLE `login` ADD COLUMN `FI_Routing` TINYINT(1) UNSIGNED DEFAULT 0;
ALTER TABLE `login` ADD COLUMN `FI_SalesStatistics` TINYINT(1) UNSIGNED DEFAULT 0;
ALTER TABLE `login` ADD COLUMN `FI_ClientsStatus` TINYINT(1) DEFAULT 0;

#amin #04-08-2016 #tiba #deliveries

ALTER TABLE `deliveries` ADD COLUMN `Delivery_ClientDeliveryDate` DATETIME;
ALTER TABLE `deliveries_temp` ADD COLUMN `Delivery_ClientDeliveryDate` DATETIME;
ALTER TABLE `temp_deliveries` ADD COLUMN `Delivery_ClientDeliveryDate` DATETIME;

#nadine #04-08-2016
ALTER TABLE `temp_Prequest` ADD COLUMN `user_account` varchar(10);
ALTER TABLE `Prequest` ADD COLUMN `user_account` varchar(10);

ALTER TABLE `temp_PrequestDt` ADD COLUMN `user_account` varchar(10);
ALTER TABLE `PrequestDt` ADD COLUMN `user_account` varchar(10);

#nadine #08-08-2016

ALTER TABLE `purchasesetup` ADD COLUMN `auto_paymentrqst` TINYINT(1) DEFAULT 0;
ALTER TABLE `purchases` ADD COLUMN `auto_paymentrqst` TINYINT(1);
ALTER TABLE `temp_purchases` ADD COLUMN `auto_paymentrqst` TINYINT(1);

ALTER TABLE `PaymentRqst` ADD COLUMN `purRelated_id` INTEGER;
ALTER TABLE `temp_PaymentRqst` ADD COLUMN `purRelated_id` INTEGER;

ALTER TABLE `accesslabelsrocky`.`detaillink` ADD COLUMN `trans_reference` DOUBLE;
ALTER TABLE `accesslabelsrocky`.`temp_detaillink` ADD COLUMN `trans_reference` DOUBLE;

alter table CstjourDt add logged_code varchar(100);
#richard #10-08-2016

CREATE TABLE  `clientssellingprice` (
  `clientssellingprice_id` int(11) NOT NULL AUTO_INCREMENT,
  `clientssellingprice_code` varchar(15) DEFAULT NULL,
  `clientssellingprice_default` tinyint(4) DEFAULT NULL,
  `clientssellingprice_percentage` double DEFAULT NULL,
  `clientssellingprice_amount` double DEFAULT NULL,
  `clientssellingprice_currency` varchar(15) DEFAULT NULL,
  PRIMARY KEY (`clientssellingprice_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

#nadine #11-08-2016
ALTER TABLE `module` ADD COLUMN `auto_approve` TINYINT(1);
ALTER TABLE `temp_transferrequestdt` ADD COLUMN `TransferrequestDt_status` varchar(1);
ALTER TABLE `CustomerContactInfo` ADD COLUMN `contact_photo` VARCHAR(50);

#Richard #12-08-2016
ALTER TABLE `customer` ADD COLUMN `customer_website` VARCHAR(100);

#amin #16-08-2016
#For_Reason_Form_Tiba
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FU_Reason` TINYINT(1);

#nadine #18-08-2016

ALTER TABLE `clientssellingprice` 
 ADD COLUMN `clientssellingprice_amountb1` DOUBLE,
 ADD COLUMN `clientssellingprice_amountb2` DOUBLE,
 ADD COLUMN `clientssellingprice_amount2` DOUBLE,
 ADD COLUMN `clientssellingprice_amount2b1` DOUBLE,
 ADD COLUMN `clientssellingprice_amount2b2` DOUBLE,
 ADD COLUMN `clientssellingprice_amount3` DOUBLE,
 ADD COLUMN `clientssellingprice_amount3b1` DOUBLE,
 ADD COLUMN `clientssellingprice_amount3b2` DOUBLE,
 ADD COLUMN `clientssellingprice_amount4` DOUBLE,
 ADD COLUMN `clientssellingprice_amount4b1` DOUBLE,
 ADD COLUMN `clientssellingprice_amount4b2` DOUBLE,
 ADD COLUMN `clientssellingprice_amount5` DOUBLE,
 ADD COLUMN `clientssellingprice_amount5b1` DOUBLE,
 ADD COLUMN `clientssellingprice_amount5b2` DOUBLE,
 ADD COLUMN `clientssellingprice_amount6` DOUBLE,
 ADD COLUMN `clientssellingprice_amount6b1` DOUBLE,
 ADD COLUMN `clientssellingprice_amount6b2` DOUBLE,
 ADD COLUMN `client_code` VARCHAR(15);

 ALTER TABLE `module` ADD COLUMN `module_sellingbyclient` TINYINT(1) DEFAULT 0;
 
 CREATE TABLE `sellingPriceByClient` (
  `sellingprice_id` INTEGER NOT NULL AUTO_INCREMENT,
  `client_code` VARCHAR(15),
  `item_code` VARCHAR(20),
  `sellingprice` DOUBLE,
  `sellingpriceb1` DOUBLE,
  `sellingpriceb2` DOUBLE,
  `currency_code` VARCHAR(20),
  PRIMARY KEY (`sellingprice_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
  
  
  #nadine #22-08-2016
  ALTER TABLE `project` MODIFY COLUMN `Project_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `costcent` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 MODIFY COLUMN `Costcent_name` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 #amin #tiba #data_transfer #23-08-2016
 
 ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FU_DeleteTempReceipt` TINYINT(1);

 #nadine #25-08-2016
 ALTER TABLE `sorderdt` ADD COLUMN `relateddt_id` DOUBLE;
 ALTER TABLE `temp_sorderdt` ADD COLUMN `relateddt_id` DOUBLE;
 
 #Richard #26-08-2016
 ALTER TABLE `login` MODIFY COLUMN `FI_employeeApp` TINYINT(1),
 ADD COLUMN `FI_employeeDel` TINYINT(1),
 ADD COLUMN `FI_employeeMod` TINYINT(1);

 ALTER TABLE `login` ADD COLUMN `FI_VehicleApp` TINYINT(1),
 ADD COLUMN `FI_VehicleDel` TINYINT(1),
 ADD COLUMN `FI_VehicleMod` TINYINT(1);

 ALTER TABLE `login` ADD COLUMN `FI_VehicleServiceApp` TINYINT(1),
 ADD COLUMN `FI_VehicleServiceDel` TINYINT(1),
 ADD COLUMN `FI_VehicleServiceMod` TINYINT(1);
 
 ALTER TABLE `login` ADD COLUMN `FI_vehicleFuelTypeApp` TINYINT(1),
 ADD COLUMN `FI_vehicleFuelTypeDel` TINYINT(1),
 ADD COLUMN `FI_vehicleFuelTypeMod` TINYINT(1);
 
 ALTER TABLE `login` ADD COLUMN `FI_vehicleTypeApp` TINYINT(1),
 ADD COLUMN `FI_vehicleTypeDel` TINYINT(1),
 ADD COLUMN `FI_vehicleTypeMod` TINYINT(1);

 ALTER TABLE `login` ADD COLUMN `FI_vehicleChargesApp` TINYINT(1),
 ADD COLUMN `FI_vehicleChargesDel` TINYINT(1),
 ADD COLUMN `FI_vehicleChargesMod` TINYINT(1);
 
 ALTER TABLE `login` ADD COLUMN `FI_PlaceApp` TINYINT(1),
 ADD COLUMN `FI_PlaceDel` TINYINT(1),
 ADD COLUMN `FI_PlaceMod` TINYINT(1);
 
 #amin #tiba #client #signature #2016-08-26
 ALTER TABLE `tiba_acc2016`.`clients` ADD COLUMN `client_signature` VARCHAR(250);

 #nadine #2016-08-30
 
 ALTER TABLE `porder`  ADD COLUMN `Approval_date` Datetime;
 ALTER TABLE `temp_porder`  ADD COLUMN `Approval_date` Datetime;
 
 
  #Richard #26-08-2016
 CREATE TABLE  `employee` (
  `employee_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `employee_firstname` varchar(45) NOT NULL,
  `employee_lastname` varchar(45) NOT NULL,
  `employee_birthdate` date DEFAULT NULL,
  `employee_licensenumber` varchar(45) DEFAULT NULL,
  `employee_licenseexpirydate` date DEFAULT NULL,
  `employee_note` varchar(500) DEFAULT NULL,
  `employee_country` varchar(45) DEFAULT NULL,
  `employee_city` varchar(45) DEFAULT NULL,
  `employee_address` varchar(100) DEFAULT NULL,
  `employee_telephone1` varchar(45) DEFAULT NULL,
  `employee_telephone2` varchar(45) DEFAULT NULL,
  `employee_picture` blob,
  PRIMARY KEY (`employee_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



CREATE TABLE `employeeaccident` (
  `employeeaccident_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint(20) unsigned NOT NULL,
  `vehicle_id` bigint(20) unsigned NOT NULL,
  `employeeaccident_startdate` date DEFAULT NULL,
  `employeeaccident_reference` varchar(45) DEFAULT NULL,
  `employeeaccident_note` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`employeeaccident_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `employeevehicle` (
  `employeevehicle_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `employee_id` bigint(20) unsigned DEFAULT NULL,
  `vehicle_id` bigint(20) unsigned DEFAULT NULL,
  `employeevehicle_startdate` date DEFAULT NULL,
  `employeevehicle_enddate` date DEFAULT NULL,
  `employeevehicle_note` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`employeevehicle_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `charges` (
  `charges_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `charges_name` varchar(100) DEFAULT NULL,
  `charges_amount` double DEFAULT NULL,
  PRIMARY KEY (`charges_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



CREATE TABLE `fueltype` (
  `fueltype_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `fueltype_description` varchar(100) NOT NULL,
  PRIMARY KEY (`fueltype_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;



CREATE TABLE `place` (
  `place_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `fromplace_name` varchar(100) NOT NULL,
  `toplace_name` varchar(100) DEFAULT NULL,
  `place_millage` int(10) unsigned DEFAULT NULL,
  `place_millagetype` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`place_id`),
  UNIQUE KEY `Index_2` (`fromplace_name`,`toplace_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `service` (
  `service_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `service_description` varchar(100) DEFAULT NULL,
  `service_frequency` int(10) unsigned DEFAULT NULL,
  `service_repeattype` varchar(45) DEFAULT NULL,
  `service_odometer` int(10) unsigned DEFAULT NULL,
  PRIMARY KEY (`service_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `vehicle` (
  `vehicle_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `vehicle_make` varchar(100) DEFAULT NULL,
  `vehicle_model` varchar(100) DEFAULT NULL,
  `vehicle_year` int(10) unsigned DEFAULT NULL,
  `vehicle_color` varchar(45) DEFAULT NULL,
  `vehicletype_id` bigint(20) unsigned DEFAULT NULL,
  `fueltype_id` bigint(20) unsigned DEFAULT NULL,
  `employee_id` bigint(20) unsigned DEFAULT NULL,
  `vehicle_note` varchar(500) DEFAULT NULL,
  `vehicle_active` tinyint(1) unsigned DEFAULT NULL,
  `insurance_reference` varchar(50) DEFAULT NULL,
  `insurance_startdate` date DEFAULT NULL,
  `insurance_enddate` date DEFAULT NULL,
  `vehicle_platenumber` varchar(50) DEFAULT NULL,
  `vehicle_acquisitiondate` date DEFAULT NULL,
  `vehicle_odometertype` varchar(20) DEFAULT NULL,
  `vehicle_odometeracuisition` varchar(45) DEFAULT NULL,
  `vehicle_licensereference` varchar(45) DEFAULT NULL,
  `license_startdate` date DEFAULT NULL,
  `license_enddate` date DEFAULT NULL,
  `road_startdate` date DEFAULT NULL,
  `road_enddate` date DEFAULT NULL,
  `item_picture` blob,
  `permit_startdate` date DEFAULT NULL,
  `permit_enddate` date DEFAULT NULL,
  `roadpermit_startdate` date DEFAULT NULL,
  `roadpermit_enddate` date DEFAULT NULL,
  PRIMARY KEY (`vehicle_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `vehiclemovement` (
  `vehicleMovement_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `vehicleMovement_start` datetime DEFAULT NULL,
  `vehicleMovement_end` datetime DEFAULT NULL,
  `place_id` bigint(20) unsigned DEFAULT NULL,
  `vehicle_id` bigint(20) unsigned DEFAULT NULL,
  `employee_id` bigint(20) unsigned DEFAULT NULL,
  `vehiclemovement_millage` int(10) unsigned DEFAULT NULL,
  `vehiclemovement_millagetype` varchar(45) DEFAULT NULL,
  `vehiclemovement_reference` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`vehicleMovement_id`),
  KEY `FK_vehiclemovement_1` (`vehicle_id`),
  KEY `FK_vehiclemovement_2` (`employee_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `vehiclemovementcharges` (
  `vehiclemovementcharges_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `charges_id` bigint(20) unsigned NOT NULL,
  `vehiclemovement_id` bigint(20) DEFAULT NULL,
  `vehiclemovementcharges_amount` double DEFAULT NULL,
  `vehiclemovementcharges_note` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`vehiclemovementcharges_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `vehiclemovementitems` (
  `vehiclemovementitems_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `vehiclemovement_id` bigint(20) unsigned NOT NULL,
  `item_code` varchar(45) DEFAULT NULL,
  `vehiclemovementitems_quantity` double DEFAULT NULL,
  `vehiclemovementitems_note` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`vehiclemovementitems_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `vehiclepart` (
  `vehiclepart_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `vehiclepart_startdate` datetime DEFAULT NULL,
  `vehiclepart_reference` varchar(45) DEFAULT NULL,
  `vehiclepart_note` varchar(500) DEFAULT NULL,
  `vehicle_id` bigint(20) unsigned DEFAULT NULL,
  `item_code` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`vehiclepart_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `vehicleservice` (
  `vehicleservice_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `vehicleservice_startdate` datetime DEFAULT NULL,
  `vehicleservice_reference` varchar(45) DEFAULT NULL,
  `vehicleservice_note` varchar(500) DEFAULT NULL,
  `vehicle_id` bigint(20) unsigned NOT NULL,
  `service_id` bigint(20) unsigned NOT NULL,
  `service_status` varchar(1) DEFAULT NULL,
  PRIMARY KEY (`vehicleservice_id`),
  KEY `FK_vehicleservice_1` (`service_id`),
  KEY `FK_vehicleservice_2` (`vehicle_id`),
  CONSTRAINT `FK_vehicleservice_1` FOREIGN KEY (`service_id`) REFERENCES `service` (`service_id`),
  CONSTRAINT `FK_vehicleservice_2` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicle` (`vehicle_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE `vehicletype` (
  `vehicletype_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `vehicletype_description` varchar(100) NOT NULL,
  PRIMARY KEY (`vehicletype_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `toolbar` (
  `toolbar_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `toolbar_type` varchar(15) DEFAULT NULL,
  `toolbar_url` varchar(50) DEFAULT NULL,
  `toolbar_parent` int(11) DEFAULT NULL,
  `toolbar_position` varchar(10) DEFAULT NULL,
  `toolbar_location` varchar(50) DEFAULT NULL,
  `toolbar_order` int(11) DEFAULT NULL,
  `toolbar_word` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`toolbar_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


 #nadine #07-09-2016
 ALTER TABLE accesslabelsrocky.`login`  ADD COLUMN `FI_RetailCashOut` TINYINT(1) default 0;
 
 #nadine #10-09-2016
ALTER TABLE `CashRegister` ADD COLUMN `CashRegister_showitemcode` TINYINT(1) default 0,
                          ADD COLUMN `CashRegister_showdiscount` TINYINT(1) default 0;
						  
ALTER TABLE `cashregistertransdt` ADD COLUMN `user_name` varchar(15);				

ALTER TABLE `SubGroup` ADD COLUMN `button_dimwidth` double;
ALTER TABLE `SubGroup` ADD COLUMN `button_dimheight` double;

#nadine #15-09-2016

ALTER TABLE `purchasesserialno` ADD COLUMN `serialno_date` DATETIME;
ALTER TABLE `temp_purchasesserialno` ADD COLUMN `serialno_date` DATETIME;

#amin #16-09-2016

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_Visit` TINYINT(1),
 ADD COLUMN `RI_Visit` TINYINT(1);
 
 #nadine #26-09-2016
 ALTER TABLE `setup` ADD COLUMN `Retaildt_height` DOUBLE;
 ALTER TABLE `setup` ADD COLUMN `shortcutgrid_height` DOUBLE;
ALTER TABLE `setup` ADD COLUMN `subgroupgrid_height` DOUBLE;

ALTER TABLE `setup` ADD COLUMN `shortcutgrid_width` DOUBLE;
ALTER TABLE `setup` ADD COLUMN `subgroupgrid_width` DOUBLE;

#amin #29-09-2016

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_ArchiveReports` TINYINT(1);

#nadine #06-10-2016
#ALTER TABLE `sorder` MODIFY COLUMN `Sorder_remark` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci;
#ALTER TABLE `temp_sorder` MODIFY COLUMN `Sorder_remark` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci;

ALTER TABLE `temp_deliveries` MODIFY COLUMN `Delivery_Remark` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `deliveries` MODIFY COLUMN `Delivery_Remark` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci;

#nadine #07-10-2016
ALTER TABLE `module` ADD COLUMN `sellingprice_basedonCost` TINYINT(1) default 0;

#nadine #19-10-2016
ALTER TABLE `itembuttons` ADD COLUMN `ItemButton_Width` DOUBLE,
 ADD COLUMN `ItemButton_Height` DOUBLE;
 
 #amin #21-10-2016
 
 ALTER TABLE `accesslabelsrocky`.`mainform_label` MODIFY COLUMN `Costcenter` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `Banks` VARCHAR(100),
 ADD COLUMN `FinancialAccounts` VARCHAR(100),
 ADD COLUMN `PaymentRequest` VARCHAR(100),
 ADD COLUMN `ChecksCollection` VARCHAR(100),
 ADD COLUMN `Reconcilation` VARCHAR(100),
 ADD COLUMN `Contra` VARCHAR(20),
 ADD COLUMN `PurchaseJV` VARCHAR(100),
 ADD COLUMN `SalesJV` VARCHAR(100),
 ADD COLUMN `ListOfReports` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`reportoptionsacc_label` ADD COLUMN `GeneralReports` VARCHAR(50),
 ADD COLUMN `ListOfSalesJV` VARCHAR(100),
 ADD COLUMN `ListOfPurchaseJV` VARCHAR(100);

 ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `InvoicesAllocation` VARCHAR(100);
 
 #amin 22-10-2016
 
 ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `StatementOfAccount` VARCHAR(100),
 ADD COLUMN `FinancialReport` VARCHAR(100),
 ADD COLUMN `DailyReport` VARCHAR(100),
 ADD COLUMN `Aging` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`ledger_label` ADD COLUMN `Number/Name` VARCHAR(100),
 ADD COLUMN `Description` VARCHAR(100),
 ADD COLUMN `Co-Number/Name` VARCHAR(100),
 ADD COLUMN `CashTypeCode` VARCHAR(100),
 ADD COLUMN `ProjectCode/Name` VARCHAR(100),
 ADD COLUMN `CostCenterCode/Name` VARCHAR(100),
 ADD COLUMN `Type` VARCHAR(100),
 ADD COLUMN `Nature` VARCHAR(100),
 ADD COLUMN `LedgerinactiveDate` VARCHAR(100),
 ADD COLUMN `Currency` VARCHAR(100),
 ADD COLUMN `Group` VARCHAR(100),
 ADD COLUMN `RequireDetail` VARCHAR(100),
 ADD COLUMN `Sequence` VARCHAR(100),
 ADD COLUMN `Length` VARCHAR(100),
 ADD COLUMN `Other` VARCHAR(100),
 ADD COLUMN `Clients` VARCHAR(100),
 ADD COLUMN `Suppliers` VARCHAR(100),
 ADD COLUMN `Salesmen` VARCHAR(100),
 ADD COLUMN `Student` VARCHAR(100),
 ADD COLUMN `Code` VARCHAR(100),
 ADD COLUMN `Name` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`ledger_label` CHANGE COLUMN `ProjectCode/Name` `ProjectCodeName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `CostCenterCode/Name` `CostCenterCodeName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `Number/Name` `NumberName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `Co-Number/Name` `CoNumberName` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `accesslabelsrocky`.`ledger_label` CHANGE COLUMN `Group` `Groupp` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

 ALTER TABLE `accesslabelsrocky`.`currency_label` ADD COLUMN `CreationDate` VARCHAR(100),
 ADD COLUMN `Currency` VARCHAR(100),
 ADD COLUMN `MultiplierOf` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`currency_label` MODIFY COLUMN `CURFORM_CODE` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

 #amin #24-10-2016
 
ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `StatisticsReports` VARCHAR(100);
 
ALTER TABLE `accesslabelsrocky`.`mainform_label` MODIFY COLUMN `Transaction` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Archive` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `Results/Page` VARCHAR(100);
 
ALTER TABLE `accesslabelsrocky`.`mainform_label` CHANGE COLUMN `Results/Page` `ResultsPage` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
ALTER TABLE `accesslabelsrocky`.`ledger_label` ADD COLUMN `AddLedger` VARCHAR(100);
 
ALTER TABLE `accesslabelsrocky`.`ledger_label` ADD COLUMN `AddCurrency` VARCHAR(100);

ALTER TABLE `accesslabelsrocky`.`ledger_label` DROP COLUMN `AddCurrency`;

ALTER TABLE `accesslabelsrocky`.`currency_label` ADD COLUMN `AddCurrency` VARCHAR(100);

ALTER TABLE `accesslabelsrocky`.`clientform_label` ADD COLUMN `MainPage` VARCHAR(100),
 ADD COLUMN `Contact` VARCHAR(100),
 ADD COLUMN `Company` VARCHAR(100),
 ADD COLUMN `Delivery` VARCHAR(100),
 ADD COLUMN `Others` VARCHAR(100),
 ADD COLUMN `Competitors` VARCHAR(100),
 ADD COLUMN `Activation` VARCHAR(100),
 ADD COLUMN `BusinessSector` VARCHAR(100),
 ADD COLUMN `ClientIP` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`clientform_label` ADD COLUMN `CreationDate` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`clientform_label` ADD COLUMN `Arabic` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`clientform_label` ADD COLUMN `DeativateDate` VARCHAR(100);

 ALTER TABLE `accesslabelsrocky`.`clientform_label` ADD COLUMN `ShowCrLimit` VARCHAR(100),
 ADD COLUMN `ShowMatDate` VARCHAR(100),
 ADD COLUMN `Export` VARCHAR(100),
 ADD COLUMN `Local` VARCHAR(100),
 ADD COLUMN `SentEmail` VARCHAR(100),
 ADD COLUMN `Cash` VARCHAR(100),
 ADD COLUMN `Mode` VARCHAR(100),
 ADD COLUMN `DiscountOnInvoice` VARCHAR(100),
 ADD COLUMN `FinancialNo` VARCHAR(100),
 ADD COLUMN `Project` VARCHAR(100),
 ADD COLUMN `Costcenter` VARCHAR(100),
 ADD COLUMN `ProfitCenter` VARCHAR(100),
 ADD COLUMN `CheckAccount` VARCHAR(100),
 ADD COLUMN `BudgetLimit` VARCHAR(100),
 ADD COLUMN `CheckDueTerm` VARCHAR(100),
 ADD COLUMN `CustomerType` VARCHAR(100),
 ADD COLUMN `Date` VARCHAR(100),
 ADD COLUMN `LocalType` VARCHAR(100),
 ADD COLUMN `PaymentType` VARCHAR(150),
 ADD COLUMN `Type` VARCHAR(100),
 ADD COLUMN `Term` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`project_label` ADD COLUMN `MainPage` VARCHAR(100),
 ADD COLUMN `Detail` VARCHAR(100),
 ADD COLUMN `CreationDate` VARCHAR(100),
 ADD COLUMN `Email` VARCHAR(100),
 ADD COLUMN `Parent` VARCHAR(100),
 ADD COLUMN `People` VARCHAR(100),
 ADD COLUMN `View` VARCHAR(100),
 ADD COLUMN `Floor` VARCHAR(100),
 ADD COLUMN `Smoking` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`project_label` ADD COLUMN `AddProject` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`costcenter_label` ADD COLUMN `CreationDate` VARCHAR(100),
 ADD COLUMN `Parent` VARCHAR(100),
 ADD COLUMN `Deactivate` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`costcenter_label` ADD COLUMN `AddCostCenter` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`journal_label` ADD COLUMN `TypeRef` VARCHAR(100),
 ADD COLUMN `Remark` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`journal_label` ADD COLUMN `LedgerName` VARCHAR(100),
 ADD COLUMN `Desc1` VARCHAR(100);
 
 #amin #31-10-2016
 
 ALTER TABLE `accesslabelsrocky`.`journal_label` ADD COLUMN `NoRecords` VARCHAR(150),
 ADD COLUMN `Perpage` VARCHAR(120);
 
 ALTER TABLE `accesslabelsrocky`.`journal_label` ADD COLUMN `Page` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`receipt_label` ADD COLUMN `Receipt` VARCHAR(100),
 ADD COLUMN `CreditAccount` VARCHAR(120),
 ADD COLUMN `DebitAccount` VARCHAR(120),
 ADD COLUMN `Reference` VARCHAR(100),
 ADD COLUMN `JVRef` VARCHAR(100),
 ADD COLUMN `Date` VARCHAR(100),
 ADD COLUMN `Representative` VARCHAR(100),
 ADD COLUMN `Curr` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100),
 ADD COLUMN `Remark` VARCHAR(100),
 ADD COLUMN `Costcenter` VARCHAR(100),
 ADD COLUMN `LedgerNo` VARCHAR(100),
 ADD COLUMN `LedgerName` VARCHAR(100),
 ADD COLUMN `Desc` VARCHAR(100),
 ADD COLUMN `Amount` VARCHAR(100),
 ADD COLUMN `ValueDate` VARCHAR(100),
 ADD COLUMN `DetailCode` VARCHAR(100),
 ADD COLUMN `Name` VARCHAR(100),
 ADD COLUMN `Per` VARCHAR(100),
 ADD COLUMN `CheckNo` VARCHAR(100),
 ADD COLUMN `Bank` VARCHAR(100),
 ADD COLUMN `Debit` VARCHAR(100),
 ADD COLUMN `Credit` VARCHAR(100),
 ADD COLUMN `Balance` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`receipt_label` MODIFY COLUMN `Language` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 ADD PRIMARY KEY (`Language`);
 
 ALTER TABLE `accesslabelsrocky`.`receipt_label` CHANGE COLUMN `Desc` `Descr` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
  ALTER TABLE `accesslabelsrocky`.`crdnote_label` ADD COLUMN `CreditNote` VARCHAR(100),
 ADD COLUMN `CreditAccount` VARCHAR(120),
 ADD COLUMN `DebitAccount` VARCHAR(120),
 ADD COLUMN `Reference` VARCHAR(100),
 ADD COLUMN `JVRef` VARCHAR(100),
 ADD COLUMN `Date` VARCHAR(100),
 ADD COLUMN `Representative` VARCHAR(100),
 ADD COLUMN `Curr` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100),
 ADD COLUMN `Remark` VARCHAR(100),
 ADD COLUMN `Costcenter` VARCHAR(100),
 ADD COLUMN `LedgerNo` VARCHAR(100),
 ADD COLUMN `LedgerName` VARCHAR(100),
 ADD COLUMN `Descr` VARCHAR(100),
 ADD COLUMN `Amount` VARCHAR(100),
 ADD COLUMN `ValueDate` VARCHAR(100),
 ADD COLUMN `DetailCode` VARCHAR(100),
 ADD COLUMN `Name` VARCHAR(100),
 ADD COLUMN `Per` VARCHAR(100),
 ADD COLUMN `CheckNo` VARCHAR(100),
 ADD COLUMN `Bank` VARCHAR(100),
 ADD COLUMN `Debit` VARCHAR(100),
 ADD COLUMN `Credit` VARCHAR(100),
 ADD COLUMN `Balance` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`dbtnote_label` ADD COLUMN `DebitNote` VARCHAR(100),
 ADD COLUMN `CreditAccount` VARCHAR(120),
 ADD COLUMN `DebitAccount` VARCHAR(120),
 ADD COLUMN `Reference` VARCHAR(100),
 ADD COLUMN `JVRef` VARCHAR(100),
 ADD COLUMN `Date` VARCHAR(100),
 ADD COLUMN `Representative` VARCHAR(100),
 ADD COLUMN `Curr` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100),
 ADD COLUMN `Remark` VARCHAR(100),
 ADD COLUMN `Costcenter` VARCHAR(100),
 ADD COLUMN `LedgerNo` VARCHAR(100),
 ADD COLUMN `LedgerName` VARCHAR(100),
 ADD COLUMN `Descr` VARCHAR(100),
 ADD COLUMN `Amount` VARCHAR(100),
 ADD COLUMN `ValueDate` VARCHAR(100),
 ADD COLUMN `DetailCode` VARCHAR(100),
 ADD COLUMN `Name` VARCHAR(100),
 ADD COLUMN `Per` VARCHAR(100),
 ADD COLUMN `CheckNo` VARCHAR(100),
 ADD COLUMN `Bank` VARCHAR(100),
 ADD COLUMN `Debit` VARCHAR(100),
 ADD COLUMN `Credit` VARCHAR(100),
 ADD COLUMN `Balance` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`dbtnote_label` MODIFY COLUMN `Language` VARCHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 ADD PRIMARY KEY (`Language`);
 
  ALTER TABLE `accesslabelsrocky`.`payment_label` ADD COLUMN `Payment` VARCHAR(100),
 ADD COLUMN `CreditAccount` VARCHAR(120),
 ADD COLUMN `DebitAccount` VARCHAR(120),
 ADD COLUMN `Reference` VARCHAR(100),
 ADD COLUMN `JVRef` VARCHAR(100),
 ADD COLUMN `Date` VARCHAR(100),
 ADD COLUMN `Representative` VARCHAR(100),
 ADD COLUMN `Curr` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100),
 ADD COLUMN `Remark` VARCHAR(100),
 ADD COLUMN `Costcenter` VARCHAR(100),
 ADD COLUMN `LedgerNo` VARCHAR(100),
 ADD COLUMN `LedgerName` VARCHAR(100),
 ADD COLUMN `Descr` VARCHAR(100),
 ADD COLUMN `Amount` VARCHAR(100),
 ADD COLUMN `ValueDate` VARCHAR(100),
 ADD COLUMN `DetailCode` VARCHAR(100),
 ADD COLUMN `Name` VARCHAR(100),
 ADD COLUMN `Per` VARCHAR(100),
 ADD COLUMN `CheckNo` VARCHAR(100),
 ADD COLUMN `Bank` VARCHAR(100),
 ADD COLUMN `Debit` VARCHAR(100),
 ADD COLUMN `Credit` VARCHAR(100),
 ADD COLUMN `Balance` VARCHAR(100);

ALTER TABLE `accesslabelsrocky`.`journal_label` ADD COLUMN `JournalVoucher` VARCHAR(100);

ALTER TABLE `accesslabelsrocky`.`journal_label` ADD COLUMN `PreparedBy` VARCHAR(100),
 ADD COLUMN `ControlledBy` VARCHAR(100),
 ADD COLUMN `ApprovedBy` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`payment_label` ADD COLUMN `PaymentVoucher` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`receipt_label` ADD COLUMN `ReceiptVoucher` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`crdnote_label` ADD COLUMN `CreditNoteVoucher` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`dbtnote_label` ADD COLUMN `DebitNoteVoucher` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`payment_label` ADD COLUMN `TheSumOf` VARCHAR(100),
 ADD COLUMN `PaidTo` VARCHAR(100),
 ADD COLUMN `CheckedBy` VARCHAR(100),
 ADD COLUMN `PaidBy` VARCHAR(100),
 ADD COLUMN `AuthorizedBy` VARCHAR(100);
 
  ALTER TABLE `accesslabelsrocky`.`receipt_label` ADD COLUMN `TheSumOf` VARCHAR(100),
 ADD COLUMN `ReceivedFrom` VARCHAR(100),
 ADD COLUMN `CheckedBy` VARCHAR(100),
 ADD COLUMN `ReceivedBy` VARCHAR(100),
 ADD COLUMN `AuthorizedBy` VARCHAR(100);
 
 #amin #01-11-2016
 
 CREATE TABLE `accesslabelsrocky`.`TransactionJV_labels` (
  `Language` VARCHAR(100) NOT NULL,
  `TransactionJournalVoucher` VARCHAR(150),
  `Date` VARCHAR(100),
  `Reference` VARCHAR(100),
  `Folio` VARCHAR(100),
  `From` VARCHAR(100),
  `To` VARCHAR(100),
  `Options` VARCHAR(100),
  `AllTypes` VARCHAR(100),
  `Exclude` VARCHAR(100),
  `CostcenterProject` VARCHAR(100),
  `CheckBill` VARCHAR(100),
  `PrintManualNo` VARCHAR(100),
  `ForceNewPage` VARCHAR(100),
  `WithMonthlyCalculation` VARCHAR(100),
  `JournalListing` VARCHAR(100),
  `Currency` VARCHAR(100),
  `NGN` VARCHAR(100),
  `USD` VARCHAR(100),
  `Type` VARCHAR(100),
  PRIMARY KEY (`Language`)
)
ENGINE = InnoDB;

#nadine #01-11-2016

ALTER TABLE `purchasesetup` ADD COLUMN `showCIF` TINYINT(1) DEFAULT 0, ADD COLUMN `ShowLC` TINYINT(1) DEFAULT 0,
	ADD COLUMN `showBatch` TINYINT(1) DEFAULT 0;

ALTER TABLE `transfersetup` ADD COLUMN `showBatch` TINYINT(1) DEFAULT 0; 
ALTER TABLE `salessetup` ADD COLUMN `showBatch` TINYINT(1) DEFAULT 0;


ALTER TABLE `porderdt` ADD COLUMN `porderdt_cost` DOUBLE, ADD COLUMN `porderdt_freight` DOUBLE;
ALTER TABLE `temp_porderdt` ADD COLUMN `porderdt_cost` DOUBLE, ADD COLUMN `porderdt_freight` DOUBLE;

ALTER TABLE `purchasesdt` ADD COLUMN `purchasedt_cost` DOUBLE;
ALTER TABLE `temp_purchasesdt` ADD COLUMN `purchasedt_cost` DOUBLE;

ALTER TABLE `grnpurchasesdt` ADD COLUMN `grnpurchasesdt_cost` DOUBLE, ADD COLUMN `grnpurchasesdt_freight` DOUBLE;
ALTER TABLE `temp_grnpurchasesdt` ADD COLUMN `grnpurchasesdt_cost` DOUBLE, ADD COLUMN `grnpurchasesdt_freight` DOUBLE;

CREATE TABLE `Shipping_Methods` (
  `shippingmethod_id` INTEGER NOT NULL AUTO_INCREMENT,
  `shippingmethod_description` VARCHAR(50),
  PRIMARY KEY (`shippingmethod_id`)
)
ENGINE = InnoDB;

ALTER TABLE `porder` ADD COLUMN `shippingmethod_id` INTEGER;
ALTER TABLE `temp_porder` ADD COLUMN `shippingmethod_id` INTEGER;

ALTER TABLE `purchases` ADD COLUMN `Purchase_shippedIn` VARCHAR(45);
ALTER TABLE `temp_purchases` ADD COLUMN `Purchase_shippedIn` VARCHAR(45);

ALTER TABLE `project` ADD COLUMN `FormM_No` VARCHAR(50),
 ADD COLUMN `BA_No` VARCHAR(50), ADD COLUMN `Bank_Name` VARCHAR(50),
 ADD COLUMN `LC_No` VARCHAR(50);

 ALTER TABLE `grnpurchasesdt` ADD COLUMN `grnpurchasesdt_packagingno` DOUBLE, ADD COLUMN `grnpurchasesdt_nbrUnit` DOUBLE;
 ALTER TABLE `temp_grnpurchasesdt` ADD COLUMN `grnpurchasesdt_packagingno` DOUBLE, ADD COLUMN `grnpurchasesdt_nbrUnit` DOUBLE;
 
 ALTER TABLE `transferrequestdt` ADD COLUMN `TransferrequestDt_BatchNo` VARCHAR(50), ADD COLUMN `TransferrequestDt_packagingNo` DOUBLE,
 ADD COLUMN `TransferrequestDt_nbrUnit` DOUBLE;
 ALTER TABLE `temp_transferrequestdt` ADD COLUMN `TransferrequestDt_BatchNo` VARCHAR(50), ADD COLUMN `TransferrequestDt_packagingNo` DOUBLE,
 ADD COLUMN `TransferrequestDt_nbrUnit` DOUBLE;
 
 ALTER TABLE `transferdt` ADD COLUMN `TransferDt_BatchNo` VARCHAR(50), ADD COLUMN `TransferDt_packagingNo` DOUBLE,
 ADD COLUMN `TransferDt_nbrUnit` DOUBLE;
ALTER TABLE `temp_transferdt` ADD COLUMN `TransferDt_BatchNo` VARCHAR(50), ADD COLUMN `TransferDt_packagingNo` DOUBLE,
 ADD COLUMN `TransferDt_nbrUnit` DOUBLE;
 
 alter table temp_cstjour add logged_code varchar(100);
#amin #01-11-2016

ALTER TABLE `accesslabelsrocky`.`transactionjv_labels` CHANGE COLUMN `Date` `Datee` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `From` `Fromm` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `To` `Too` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `Type` `Typee` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 CREATE TABLE `accesslabelsrocky`.`listoftransaction_labels` (
  `Language` VARCHAR(100) NOT NULL,
  `Voucher` VARCHAR(100),
  `Receipts` VARCHAR(100),
  `GroupBy` VARCHAR(100),
  `Date` VARCHAR(100),
  `ValueDate` VARCHAR(100),
  `Reference` VARCHAR(100),
  `None` VARCHAR(50),
  `Salesman` VARCHAR(100),
  `LedgerNo` VARCHAR(100),
  `Payments` VARCHAR(100),
  `Fromm` VARCHAR(100),
  `Too` VARCHAR(100),
  `Journal` VARCHAR(100),
  `DebitNotes` VARCHAR(100),
  `CreditNotes` VARCHAR(100),
  `All` VARCHAR(50),
  `Confirmed` VARCHAR(100),
  `NotConfirmed` VARCHAR(100),
  `LedgerNumberName` VARCHAR(100),
  `SalesmanCodeDescription` VARCHAR(100),
  `CollectionsPerSalesman` VARCHAR(100),
  `Project` VARCHAR(100),
  `Usee` VARCHAR(100),
  `Costcenter` VARCHAR(100),
  `CreditAccounts` VARCHAR(100),
  `DebitAccounts` VARCHAR(100),
  `Both` VARCHAR(100),
  `ShowDescription` VARCHAR(100),
  `ShowProjectCostcenterHeader` VARCHAR(150),
  `ShowProjectCostcenterDetail` VARCHAR(100),
  `ShowChecks` VARCHAR(100),
  `ShowDetailedJV` VARCHAR(120),
  `ShowOtherSide` VARCHAR(120),
  PRIMARY KEY (`Language`)
)
ENGINE = InnoDB;

ALTER TABLE `accesslabelsrocky`.`listoftransaction_labels` CHANGE COLUMN `Date` `Datee` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `None` `Nonee` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `All` `Alll` VARCHAR(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 CHANGE COLUMN `Both` `Bothh` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 #amin #02-11-2016
 
 ALTER TABLE `accesslabelsrocky`.`listoftransaction_labels` ADD COLUMN `ListOfTransaction` VARCHAR(120);
 
 CREATE TABLE `accesslabelsrocky`.`listofledger_label` (
  `Language` VARCHAR(100) NOT NULL,
  `LedgerNumberName` VARCHAR(120),
  `Fromm` VARCHAR(100),
  `Too` VARCHAR(100),
  `Options` VARCHAR(100),
  `OrderBy` VARCHAR(100),
  `NewPageForEachClass` VARCHAR(100),
  `PrintAuxiliariesAccount` VARCHAR(120),
  `LedgerNo` VARCHAR(100),
  `LedgerName` VARCHAR(100),
  PRIMARY KEY (`Language`)
)
ENGINE = InnoDB;

ALTER TABLE `accesslabelsrocky`.`listofledger_label` ADD COLUMN `ListOfGeneralLedger` VARCHAR(150) AFTER `LedgerName`;

ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `ClearPage` VARCHAR(100),
 ADD COLUMN `Save` VARCHAR(100),
 ADD COLUMN `Print` VARCHAR(100),
 ADD COLUMN `Add` VARCHAR(100),
 ADD COLUMN `Search` VARCHAR(100),
 ADD COLUMN `Pending` VARCHAR(100),
 ADD COLUMN `CopyJV` VARCHAR(100),
 ADD COLUMN `PaymentRequests` VARCHAR(120),
 ADD COLUMN `ExportExcel` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`mainform_label` CHANGE COLUMN `Add` `Addd` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `Preview` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`transactionjv_labels` ADD COLUMN `Amount` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100),
 ADD COLUMN `LedgerNameDescription` VARCHAR(100),
 ADD COLUMN `LedgerNo` VARCHAR(100),
 ADD COLUMN `Credit` VARCHAR(100),
 ADD COLUMN `Debit` VARCHAR(100),
 ADD COLUMN `PreparedBy` VARCHAR(100),
 ADD COLUMN `ControlledBy` VARCHAR(100),
 ADD COLUMN `ApprovedBy` VARCHAR(100);
 
 ALTER TABLE `accesslabelsrocky`.`listoftransaction_labels` ADD COLUMN `ListOfReceipts` VARCHAR(100),
 ADD COLUMN `ManualNo` VARCHAR(100),
 ADD COLUMN `LedgerNameDescription` VARCHAR(120),
 ADD COLUMN `Amount` VARCHAR(100),
 ADD COLUMN `JVRef` VARCHAR(100),
 ADD COLUMN `TotalCurrencies` VARCHAR(100),
 ADD COLUMN `Currency` VARCHAR(100),
 ADD COLUMN `SumOfAmount` VARCHAR(100);

#amin #03-11-2016

ALTER TABLE `accesslabelsrocky`.`mainform_label` ADD COLUMN `ListOfTransaction` VARCHAR(100);

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_ReportsOptions` TINYINT(1) AFTER `FI_ArchiveReports`;

#nadine #07-11-2016

ALTER TABLE  `purchasesdt` CHANGE COLUMN `purchasedt_unitPrince` `purchasedt_unitPrice` DOUBLE DEFAULT NULL;
ALTER TABLE  `temp_purchasesdt` CHANGE COLUMN `purchasedt_unitPrince` `purchasedt_unitPrice` DOUBLE DEFAULT NULL;

#amin #09-11-2016

ALTER TABLE `clients` DROP FOREIGN KEY `clientsclientgrp_code`;

#nabil 2016-10-11
alter table accesslabelsrocky.directories add StartReportDate datetime;
alter table accesslabelsrocky.directories add EndReportDate datetime;
update accesslabelsrocky.directories set StartReportDate=StartFinancialDate where StartReportDate is null;
update accesslabelsrocky.directories set EndReportDate=EndFinancialDate where EndReportDate is null;

#nadine #10-11-2016
ALTER TABLE `transdt` ADD COLUMN `transdtRate` DOUBLE;
ALTER TABLE `temp_transdt` ADD COLUMN `transdtRate` DOUBLE;

#amin #11-11-2016
alter table temp_porder add approvedby varchar(50);

#nadine #18-11-2016
ALTER TABLE `temp_transdt` ADD COLUMN `transdt_rate` DOUBLE;
ALTER TABLE `transdt` ADD COLUMN `transdt_rate` DOUBLE;



#nabil 2016-11-21 tpro target sales
CREATE TABLE  `targetbygoup` (
  `targetbygoup_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `targetbygoup_year` int(10) unsigned DEFAULT NULL,
  `targetbygoup_sysdate` datetime NOT NULL,
  `group_code` varchar(15) NOT NULL,
  `JAN` double NOT NULL DEFAULT '0',
  `FEB` double NOT NULL DEFAULT '0',
  `MAR` double NOT NULL DEFAULT '0',
  `Q1` double NOT NULL DEFAULT '0',
  `APR` double NOT NULL DEFAULT '0',
  `MAY` double NOT NULL DEFAULT '0',
  `JUN` double NOT NULL DEFAULT '0',
  `Q2` double NOT NULL DEFAULT '0',
  `JUL` double NOT NULL DEFAULT '0',
  `AUG` double NOT NULL DEFAULT '0',
  `SEP` double NOT NULL DEFAULT '0',
  `Q3` double NOT NULL DEFAULT '0',
  `OCT` double unsigned NOT NULL DEFAULT '0',
  `NOV` double NOT NULL DEFAULT '0',
  `DEC1` double NOT NULL DEFAULT '0',
  `Q4` double NOT NULL DEFAULT '0',
  `currency_code` varchar(6) NOT NULL,
  PRIMARY KEY (`targetbygoup_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;


CREATE TABLE  `targetcomission` (
  `targetcomission_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `targetcomission_from` double NOT NULL DEFAULT '0',
  `targetcomission_to` double NOT NULL DEFAULT '0',
  `targetcomission_percentage` double NOT NULL DEFAULT '0',
  `targetcomission_year` int(10) unsigned NOT NULL,
  PRIMARY KEY (`targetcomission_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

#amin #28-11-2016

ALTER TABLE `salesdt` ADD COLUMN `SaleDt_Reason` VARCHAR(150);
ALTER TABLE `temp_salesdt` ADD COLUMN `SaleDt_Reason` VARCHAR(150);

#amin #29-11-2016

ALTER TABLE `deliverydt` ADD COLUMN `DeliveryDt_REason` VARCHAR(150);
ALTER TABLE `temp_deliverydt` ADD COLUMN `DeliveryDt_REason` VARCHAR(150);

#nadine #30-11-2016
ALTER TABLE `transsetup` ADD COLUMN `Hide_ValueDate` TINYINT(0),ADD COLUMN `Hide_Base2` TINYINT(0);
ALTER TABLE `module` ADD COLUMN `module_ledgerrestrictcur` TINYINT(0);

#nadine #05-12-2016
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FC_SalesStatistic` TINYINT(1) DEFAULT 0;

#nadine #13-12-2016
alter TABLE `setup` add column `RestrictZeroPrice` TINYINT(1) default 0;

#amin #23-12-2016 #for_tiba

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RoutingList` TINYINT(1) DEFAULT 0;

#nadine #29-12-2016

alter table `module` add `Module_PurchaseOrderJV` TINYINT(1) DEFAULT 0;
alter table `accesslabelsrocky`.`login` add `FA_PurchaseOrderJV` TINYINT(1) DEFAULT 0;


CREATE TABLE  `porderjv` (
  `PorderJV_Id` double NOT NULL,
  `PorderJV_Reference` double DEFAULT NULL,
  `PorderJV_Date` datetime DEFAULT NULL,
  `Supplier_Code` varchar(10) DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `Journal_Id` double DEFAULT NULL,
  `JournalDt_ValueDate` datetime DEFAULT NULL,
  `journal_type` varchar(2),
  `PorderJV_edit` tinyint(1) DEFAULT '0',
  `PorderJV_posted` tinyint(1) DEFAULT '0',
  `PorderJV_Total` double DEFAULT NULL,
  `PorderJV_TotalBase1` double DEFAULT NULL,
  `PorderJV_TotalBase2` double DEFAULT NULL,
  `PorderJV_discamount` double DEFAULT '0',
  `PorderJV_DiscAmount1` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `Purchase_Remark` varchar(100) DEFAULT NULL,
  `purchase_mode` double DEFAULT '0',
  `User_Account` varchar(10) DEFAULT NULL,
  `PorderJV_VAT` double DEFAULT NULL,
  `PorderJV_VatBase1` double DEFAULT NULL,
  `PorderJV_VatBase2` double DEFAULT NULL,
  `PorderJV_percharge` double DEFAULT '0',
  `PorderJV_chargeamount` double DEFAULT '0',
  `PorderJV_ChargeAmount1` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `PorderJV_ChargeDebit` varchar(10) DEFAULT NULL,
  `PorderJV_ChargeCredit` varchar(10) DEFAULT NULL,
  `PorderJV_CreditAccount` varchar(10) DEFAULT NULL,
  `PorderJV_CheckAccount` varchar(10) DEFAULT NULL,
  `PorderJV_CashAccount` varchar(10) DEFAULT NULL,
  `PorderJV_Amount` double DEFAULT NULL,
  `PorderJV_AmountBase1` double DEFAULT NULL,
  `PorderJV_AmountBase2` double DEFAULT NULL,
  `PorderJV_CheckNo` varchar(40) DEFAULT NULL,
  `PorderJV_CheckDate` datetime DEFAULT NULL,
  `PorderJV_Bank` varchar(50) DEFAULT NULL,
  `PorderJV_BankBranch` varchar(20) DEFAULT NULL,
  `PorderJV_CreditCur` varchar(6) DEFAULT NULL,
  `PorderJV_CashCur` varchar(6) DEFAULT NULL,
  `PorderJV_CheckCur` varchar(6) DEFAULT NULL,
  `PorderJV_RetentionPer` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `PorderJV_RetentionAmt` double DEFAULT NULL,
  `PorderJV_VatAccount` varchar(10) DEFAULT NULL,
  `PorderJV_BelongsToGroup` int(11) DEFAULT NULL,
  `SendReceive_Reference` double DEFAULT NULL,
  `Generatedinvoice_Ref` double DEFAULT NULL,
  `PorderJV_InvoiceNo` varchar(25) DEFAULT NULL,
  `PorderJV_taxable` double DEFAULT '0',
  `PorderJV_nonetaxable` double DEFAULT '0',
  `PorderJV_NoneTaxableBase1` double DEFAULT NULL,
  `PorderJV_NoneTaxableBase2` double DEFAULT NULL,
  `PorderJV_TaxableBase1` double DEFAULT NULL,
  `PorderJV_TaxableBase2` double DEFAULT NULL,
  `PorderJV_vatcheck` tinyint(1) DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `PorderJV_type` varchar(20) DEFAULT NULL,
  `PorderJV_OriginType` varchar(20) DEFAULT NULL,
  `LPO_Number` varchar(20) DEFAULT NULL,
  `PorderJV_manualVat` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `PorderJV_VATPER` float NOT NULL DEFAULT '0',
  `PorderJV_DiscountPer` double DEFAULT '0',
  `PorderJV_DiscountAccount` varchar(10) DEFAULT NULL,
  `PorderJV_Reservation` date DEFAULT NULL,
  `PorderJV_CheckIn` date DEFAULT NULL,
  `PorderJV_CheckOut` date DEFAULT NULL,
  `PorderJV_RoomType` varchar(30) DEFAULT NULL,
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `PorderJV_WHTPer` double DEFAULT '0',
  `PorderJV_WHTAmt` double DEFAULT '0',
  `PorderJV_WHTAmt1` double DEFAULT '0',
  `PorderJV_WHTAmt2` double DEFAULT '0',
  `PorderJV_WHTChk` tinyint(1) DEFAULT '0',
  `PorderJV_WHTAccount` varchar(10) DEFAULT NULL,
  `PorderJV_ManualNo` varchar(45) DEFAULT NULL,
  `PorderJV_VatPrefix` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`PorderJV_Id`),
  KEY `Reference` (`PorderJV_Reference`),
  KEY `ProjectDate` (`Project_Code`,`PorderJV_Date`),
  KEY `Project` (`Project_Code`),
  KEY `InvoiceNo` (`PorderJV_InvoiceNo`),
  KEY `Date` (`PorderJV_Date`),
  KEY `purchasesjvarea_code` (`PorderJV_BankBranch`),
  KEY `FK_PORDERJV_Branch` (`BRANCH_CODE`),
  CONSTRAINT `FK_PORDERJV_Branch` FOREIGN KEY (`BRANCH_CODE`) REFERENCES `branches` (`BRANCH_CODE`),
  CONSTRAINT `PorderJVarea_code` FOREIGN KEY (`PorderJV_BankBranch`) REFERENCES `area` (`Area_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `porderjvdt` (
  `PorderJVDt_Id` double NOT NULL,
  `PorderJV_Id` double DEFAULT NULL,
  `PorderJV_Date` datetime DEFAULT NULL,
  `Supplier_Code` varchar(10) DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Ledger_Number` varchar(10) DEFAULT NULL,
  `PorderJVDt_Description` varchar(100) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `PorderJVdt_quantity` double DEFAULT '0',
  `PorderJVdt_price` double DEFAULT '0',
  `PorderJVDt_PriceBase1` double DEFAULT NULL,
  `PorderJVDt_PriceBase2` double DEFAULT NULL,
  `PorderJVdt_discper` double DEFAULT '0',
  `PorderJVDt_DiscAmount` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `Journal_Id` double DEFAULT NULL,
  `Warehouse_Code` varchar(20) DEFAULT NULL,
  `PorderJVDt_ExpireDate` datetime DEFAULT NULL,
  `PorderJVdt_posted` tinyint(1) DEFAULT '0',
  `Journal_Type` varchar(2) DEFAULT NULL,
  `PorderJVdt_discount` double DEFAULT '0',
  `PorderJVdt_discount1` double DEFAULT '0',
  `PorderJVdt_discount2` double DEFAULT '0',
  `PorderJVdt_charge` double DEFAULT '0',
  `PorderJVdt_charge1` double DEFAULT '0',
  `PorderJVdt_charge2` double DEFAULT '0',
  `PrefixJV_ID` double DEFAULT NULL,
  `PorderJVDt_VAT` tinyint(1) DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `PorderJVDt_Description2` varchar(100) DEFAULT NULL,
  `PorderJVDTCalcTotal` double DEFAULT '0',
  `PorderJVdt_tax` float DEFAULT '0',
  `PorderJVdt_taxbase1` float DEFAULT '0',
  `PorderJVdt_taxbase2` float DEFAULT '0',
  `PorderJVdt_description3` varchar(100) DEFAULT NULL,
  `PorderJVdt_date` date DEFAULT NULL,
  `PorderJVDt_ManualNo` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`PorderJVDt_Id`),
  KEY `PorderJVID` (`PorderJV_Id`),
  KEY `IdPrjCst` (`PorderJV_Id`,`Project_Code`,`Costcenter_Code`),
  KEY `PorderJVdtPorderJV_Id` (`PorderJV_Id`),
  KEY `porderjvdtproject_code` (`Project_Code`),
  CONSTRAINT `porderjvdtpurchasesjv_id` FOREIGN KEY (`PorderJV_Id`) REFERENCES `porderjv` (`PorderJV_Id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
	

CREATE TABLE  `temp_porderjv` (
  `PorderJV_Id` double NOT NULL,
  `PorderJV_Reference` double DEFAULT NULL,
  `PorderJV_Date` datetime DEFAULT NULL,
  `Supplier_Code` varchar(10) DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `Journal_Id` double DEFAULT NULL,
  `JournalDt_ValueDate` datetime DEFAULT NULL,
  `journal_type` varchar(2) DEFAULT 'JP',
  `PorderJV_edit` tinyint(1) DEFAULT '0',
  `PorderJV_posted` tinyint(1) DEFAULT '0',
  `PorderJV_Total` double DEFAULT NULL,
  `PorderJV_TotalBase1` double DEFAULT NULL,
  `PorderJV_TotalBase2` double DEFAULT NULL,
  `PorderJV_discamount` double DEFAULT '0',
  `PorderJV_DiscAmount1` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `Purchase_Remark` varchar(100) DEFAULT NULL,
  `purchase_mode` double DEFAULT '0',
  `User_Account` varchar(10) DEFAULT NULL,
  `PorderJV_VAT` double DEFAULT NULL,
  `PorderJV_VatBase1` double DEFAULT NULL,
  `PorderJV_VatBase2` double DEFAULT NULL,
  `PorderJV_percharge` double DEFAULT '0',
  `PorderJV_chargeamount` double DEFAULT '0',
  `PorderJV_ChargeAmount1` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `PorderJV_ChargeDebit` varchar(10) DEFAULT NULL,
  `PorderJV_ChargeCredit` varchar(10) DEFAULT NULL,
  `PorderJV_CreditAccount` varchar(10) DEFAULT NULL,
  `PorderJV_CheckAccount` varchar(10) DEFAULT NULL,
  `PorderJV_CashAccount` varchar(10) DEFAULT NULL,
  `PorderJV_Amount` double DEFAULT NULL,
  `PorderJV_AmountBase1` double DEFAULT NULL,
  `PorderJV_AmountBase2` double DEFAULT NULL,
  `PorderJV_CheckNo` varchar(40) DEFAULT NULL,
  `PorderJV_CheckDate` datetime DEFAULT NULL,
  `PorderJV_Bank` varchar(50) DEFAULT NULL,
  `PorderJV_BankBranch` varchar(20) DEFAULT NULL,
  `PorderJV_CreditCur` varchar(6) DEFAULT NULL,
  `PorderJV_CashCur` varchar(6) DEFAULT NULL,
  `PorderJV_CheckCur` varchar(6) DEFAULT NULL,
  `PorderJV_RetentionPer` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `PorderJV_RetentionAmt` double DEFAULT NULL,
  `PorderJV_VatAccount` varchar(10) DEFAULT NULL,
  `PorderJV_BelongsToGroup` int(11) DEFAULT NULL,
  `SendReceive_Reference` double DEFAULT NULL,
  `Generatedinvoice_Ref` double DEFAULT NULL,
  `PorderJV_InvoiceNo` varchar(25) DEFAULT NULL,
  `PorderJV_taxable` double DEFAULT '0',
  `PorderJV_nonetaxable` double DEFAULT '0',
  `PorderJV_NoneTaxableBase1` double DEFAULT NULL,
  `PorderJV_NoneTaxableBase2` double DEFAULT NULL,
  `PorderJV_TaxableBase1` double DEFAULT NULL,
  `PorderJV_TaxableBase2` double DEFAULT NULL,
  `PorderJV_vatcheck` tinyint(1) DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `PorderJV_type` varchar(20) DEFAULT NULL,
  `PorderJV_OriginType` varchar(20) DEFAULT NULL,
  `LPO_Number` varchar(20) DEFAULT NULL,
  `PorderJV_manualVat` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `PorderJV_VATPER` float NOT NULL DEFAULT '0',
  `PorderJV_DiscountPer` double DEFAULT '0',
  `PorderJV_DiscountAccount` varchar(10) DEFAULT NULL,
  `PorderJV_Reservation` date DEFAULT NULL,
  `PorderJV_CheckIn` date DEFAULT NULL,
  `PorderJV_CheckOut` date DEFAULT NULL,
  `PorderJV_RoomType` varchar(30) DEFAULT NULL,
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `PorderJV_WHTPer` double DEFAULT '0',
  `PorderJV_WHTAmt` double DEFAULT '0',
  `PorderJV_WHTAmt1` double DEFAULT '0',
  `PorderJV_WHTAmt2` double DEFAULT '0',
  `PorderJV_WHTChk` tinyint(1) DEFAULT '0',
  `PorderJV_WHTAccount` varchar(10) DEFAULT NULL,
  `PorderJV_ManualNo` varchar(45) DEFAULT NULL,
  `PorderJV_VatPrefix` varchar(10) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`PorderJV_Id`),
  KEY `Reference` (`PorderJV_Reference`),
  KEY `ProjectDate` (`Project_Code`,`PorderJV_Date`),
  KEY `Project` (`Project_Code`),
  KEY `InvoiceNo` (`PorderJV_InvoiceNo`),
  KEY `Date` (`PorderJV_Date`),
  KEY `purchasesjvarea_code` (`PorderJV_BankBranch`),
  KEY `FK_PORDERJV_Branch` (`BRANCH_CODE`),
  KEY `Idx_LoggedCode` (`Logged_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `temp_porderjvdt` (
  `PorderJVDt_Id` double NOT NULL,
  `PorderJV_Id` double DEFAULT NULL,
  `PorderJV_Date` datetime DEFAULT NULL,
  `Supplier_Code` varchar(10) DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Ledger_Number` varchar(10) DEFAULT NULL,
  `PorderJVDt_Description` varchar(100) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcenter_Code` varchar(15) DEFAULT NULL,
  `PorderJVdt_quantity` double DEFAULT '0',
  `PorderJVdt_price` double DEFAULT '0',
  `PorderJVDt_PriceBase1` double DEFAULT NULL,
  `PorderJVDt_PriceBase2` double DEFAULT NULL,
  `PorderJVdt_discper` double DEFAULT '0',
  `PorderJVDt_DiscAmount` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `Journal_Id` double DEFAULT NULL,
  `Warehouse_Code` varchar(20) DEFAULT NULL,
  `PorderJVDt_ExpireDate` datetime DEFAULT NULL,
  `PorderJVdt_posted` tinyint(1) DEFAULT '0',
  `Journal_Type` varchar(2) DEFAULT NULL,
  `PorderJVdt_discount` double DEFAULT '0',
  `PorderJVdt_discount1` double DEFAULT '0',
  `PorderJVdt_discount2` double DEFAULT '0',
  `PorderJVdt_charge` double DEFAULT '0',
  `PorderJVdt_charge1` double DEFAULT '0',
  `PorderJVdt_charge2` double DEFAULT '0',
  `PrefixJV_ID` double DEFAULT NULL,
  `PorderJVDt_VAT` tinyint(1) DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `PorderJVDt_Description2` varchar(100) DEFAULT NULL,
  `PorderJVDTCalcTotal` double DEFAULT '0',
  `PorderJVdt_tax` float DEFAULT '0',
  `PorderJVdt_taxbase1` float DEFAULT '0',
  `PorderJVdt_taxbase2` float DEFAULT '0',
  `PorderJVdt_description3` varchar(100) DEFAULT NULL,
  `PorderJVdt_date` date DEFAULT NULL,
  `PorderJVDt_ManualNo` varchar(45) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`PorderJVDt_Id`),
  KEY `PorderJVID` (`PorderJV_Id`),
  KEY `IdPrjCst` (`PorderJV_Id`,`Project_Code`,`Costcenter_Code`),
  KEY `PorderJVdtPorderJV_Id` (`PorderJV_Id`),
  KEY `porderjvdtproject_code` (`Project_Code`),
  KEY `Idx_LoggedCode` (`Logged_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;	

alter table `sequence` add `PorderJV_Id` double, add `PorderJVDt_Id` double,  add `PorderJV_Reference` double;
alter table `temp_purchasesjvdt` add `RelatedDt_Id` double;
alter table `purchasesjvdt` add `RelatedDt_Id` double;

#amin #29-12-2016 #tiba

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_NotRoutingList` TINYINT(1) default 0;

#nadine #09-01-2017
Alter Table `accesslabelsrocky`.`Login` Add Column `FI_PorderJVConfirmed` TINYINT(1) DEFAULT 0;
Alter Table `porderjv` Add Column `PorderJV_confirmed` TINYINT(1) DEFAULT 0;
Alter Table `temp_porderjv` Add Column `PorderJV_confirmed` TINYINT(1) DEFAULT 0;

#nadine #19-01-2017 
#project/costcenter code size

ALTER TABLE `trans` MODIFY COLUMN `COSTCENT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `PROJECT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_trans` MODIFY COLUMN `COSTCENT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `PROJECT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `cstjourdt` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_cstjourdt` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `journal` MODIFY COLUMN `Costcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_journal` MODIFY COLUMN `Costcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `paymentrqst` MODIFY COLUMN `PROJECT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `COSTCENT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_paymentrqst` MODIFY COLUMN `PROJECT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `COSTCENT_CODE` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `prequest` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_prequest` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `prequestdt` MODIFY COLUMN `CostCent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_prequestdt` MODIFY COLUMN `CostCent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `transferrequest` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `temp_transferrequest` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `transferrequestdt` MODIFY COLUMN `Costcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `temp_transferrequestdt` MODIFY COLUMN `Costcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `transfer` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `temp_transfer` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `transferdt` MODIFY COLUMN `Costcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `temp_transferdt` MODIFY COLUMN `Costcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
MODIFY COLUMN `ToCostcent_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code1` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code2` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `prequest` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_prequest` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `prequestdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_prequestdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
	
ALTER TABLE `porder` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_porder` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `porderdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_porderdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `purchases` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_purchases` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `purchasesdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_purchasesdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `sorder` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_sorder` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `sorderdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_sorderdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `sales` MODIFY COLUMN `Costcenter_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_sales` MODIFY COLUMN `Costcenter_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `salesdt` MODIFY COLUMN `Costcenter_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_salesdt` MODIFY COLUMN `Costcenter_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `deliveries` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_deliveries` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `deliverydt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_deliverydt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `production` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_production` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `productiondt` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_productiondt` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `productionfg` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_productionfg` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `productionhd` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_productionhd` MODIFY COLUMN `Costcenter_Code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `adjustment` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_adjustment` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `adjustmentdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_adjustmentdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `grnpurchases` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_grnpurchases` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `grnpurchasesdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_grnpurchasesdt` MODIFY COLUMN `Costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL; 
 
 alter Table `setup` add column `company_email` varchar(50);
 
#amin #31-01-2017

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `RI_PricingList` TINYINT(1) DEFAULT 0;

#amin #02-02-2017

CREATE TABLE `clientaddresses` (
  `clientaddresses_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `client_code` VARCHAR(10),
  `clientsaddresses_address` VARCHAR(250),
  PRIMARY KEY (`clientaddresses_id`),
  CONSTRAINT `FK_clientaddresses_1` FOREIGN KEY `FK_clientaddresses_1` (`client_code`)
    REFERENCES `clients` (`Ledger_number`)
    ON DELETE SET NULL
    ON UPDATE SET NULL
)
ENGINE = InnoDB;
 
 #nadine #02-02-2017
ALTER TABLE `purchasesetup` ADD COLUMN `ShowInvoiceDate` TINYINT(1) DEFAULT 0;
 
ALTER TABLE `purchases` ADD COLUMN `InvoiceDate` DATETIME, ADD COLUMN `Logged_Code` varchar(10);
ALTER TABLE `temp_purchases` ADD COLUMN `InvoiceDate` DATETIME;
ALTER TABLE `temp_transferdt` MODIFY COLUMN `Transferdt_remark` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `transferdt` MODIFY COLUMN `Transferdt_remark` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
#amin #02-02-2017

ALTER TABLE `deliveries` ADD COLUMN `clientaddresses_id` BIGINT(20);

ALTER TABLE `temp_deliveries` ADD COLUMN `clientaddresses_id` BIGINT(20);

#nadine #03-02-2017
ALTER TABLE `module` ADD COLUMN `module_saleswht` TINYINT(1) DEFAULT 0;
ALTER TABLE `salessetup` ADD COLUMN `WHT_account` VARCHAR(10);

ALTER TABLE `clients` ADD COLUMN `WHTchecked` TINYINT(1),
ADD COLUMN `WHTPercentage` DOUBLE;

ALTER TABLE `temp_sales` ADD COLUMN `Sale_WHTchecked` TINYINT(1),
ADD COLUMN `Sale_WHTAmount` DOUBLE, ADD COLUMN `Sale_WHTAmountBase1` DOUBLE,
ADD COLUMN `Sale_WHTAmountBase2` DOUBLE;
ALTER TABLE `sales` ADD COLUMN `Sale_WHTchecked` TINYINT(1),
ADD COLUMN `Sale_WHTAmount` DOUBLE, ADD COLUMN `Sale_WHTAmountBase1` DOUBLE,
ADD COLUMN `Sale_WHTAmountBase2` DOUBLE;

#nadine #06-02-2017
ALTER TABLE `temp_purchasesjv` ADD COLUMN `InvoiceDate` DATETIME;
ALTER TABLE `purchasesjv` ADD COLUMN `InvoiceDate` DATETIME;

#amin #06-02-2017

ALTER TABLE `grouping` ADD COLUMN `grouping_pricelist` TINYINT(1) DEFAULT 0;

#amin #07-02-2017

ALTER TABLE `items` ADD COLUMN `item_pricelist` TINYINT(1) DEFAULT 0;

#amin #08-02-2017

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FA_SellingPrice` TINYINT(1),
 ADD COLUMN `RI_ReportOptions` TINYINT(1);
 
 #nadine #16-02-2017
 ALTER TABLE `adjustmentsetup` ADD COLUMN `ShowSellingPrice` TINYINT(1) DEFAULT 0;
 
 CREATE TABLE `LedgerFilter` (
  `filter_id` INTEGER NOT NULL AUTO_INCREMENT,
  `filter_type` VARCHAR(3),
  `filter_CrDb` VARCHAR(1),
  `fromledgercode` VARCHAR(20),
  `toledgercode` VARCHAR(20),
  PRIMARY KEY (`filter_id`)
)
ENGINE = InnoDB;

#amin 21-02-2017

CREATE TABLE `temp_statementofaccount` (
  `statementofaccount_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `ledger_number` VARCHAR(250),
  `ledger_name` VARCHAR(500),
  PRIMARY KEY (`statementofaccount_id`)
)
ENGINE = InnoDB;

#nadine #24-02-2017
ALTER TABLE `stktransaction` MODIFY COLUMN `Warehouse_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `project_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `costcent_code` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

ALTER TABLE `paymentrqst` MODIFY COLUMN `user_account` VARCHAR(20) DEFAULT NULL;
ALTER TABLE `temp_paymentrqst` MODIFY COLUMN `user_account` VARCHAR(20) DEFAULT NULL;

ALTER TABLE accesslabelsrocky.headerlink ADD COLUMN `description` varchar(256),
ADD COLUMN `value_date` DATETIME;
ALTER TABLE accesslabelsrocky.detaillink ADD COLUMN `description` varchar(256),
ADD COLUMN `value_date` DATETIME;

#nadine #13-03-2017
ALTER TABLE `Temp_Deliveries` ADD COLUMN `related_schemaname` VARCHAR(45);
ALTER TABLE `Deliveries` ADD COLUMN `related_schemaname` VARCHAR(45);

ALTER TABLE `Temp_Purchases` ADD COLUMN `related_schemaname` VARCHAR(45);
ALTER TABLE `Purchases` ADD COLUMN `related_schemaname` VARCHAR(45);

#nadine #16-03-2017
ALTER TABLE `module` ADD COLUMN `Module_Archive` TINYINT(1) DEFAULT 0;
ALTER TABLE `archiving` ADD COLUMN `documentnumber` INTEGER;
ALTER TABLE `product` MODIFY COLUMN `name` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;

#nadine #21-03-2017
CREATE TABLE `measurementsetup` (
  `Measurement_id` INTEGER UNSIGNED NOT NULL,
  `Measurement_Type` VARCHAR(45),
  `Measurement_number` VARCHAR(45),
  PRIMARY KEY (`Measurement_Type`, `Measurement_number`)
)
ENGINE = InnoDB;

ALTER TABLE `module` ADD COLUMN `module_transactionweight` TINYINT(1);
ALTER TABLE `project` ADD COLUMN `thickness_id` INTEGER, ADD COLUMN `width_id` INTEGER;
ALTER TABLE `project` ADD COLUMN `gross_weight` DOUBLE, ADD COLUMN `net_weight` DOUBLE;

#nadine #28-03-2017
ALTER TABLE `setup` ADD COLUMN `encodingmode` VARCHAR(50);
ALTER TABLE `setup` ADD COLUMN `archive_path` VARCHAR(50);
ALTER TABLE `archiving` ADD INDEX `Index_2`(`companyname`),
 ADD INDEX `Index_3`(`documentnumber`),
 ADD INDEX `Index_4`(`shipper`);
ALTER TABLE `archivingdt` ADD INDEX `Index_2`(`documentnumber`);
ALTER TABLE `shipping` ADD INDEX `Index_2`(`documentnumber`);

ALTER TABLE `accesslabelsrocky`.`detaillink` MODIFY COLUMN `relation_id` DOUBLE DEFAULT NULL;

#amin #05-04-2017 #tiba

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_DeleteMobileSorders` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_DeleteMobileInvoices` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_DeleteMobileReturnInvoices` TINYINT(1) DEFAULT 0;
 
 #nadine #06-04-2017
 ALTER TABLE `accesslabelsrocky`.`Login` ADD COLUMN `is_superUser` TINYINT(1) DEFAULT 0;
 ALTER TABLE `PURCHASESETUP` ADD COLUMN `CreditCurReturnDefault` TINYINT(1) DEFAULT 0;
 ALTER TABLE `sorder` ADD COLUMN `Sorder_confirmed2` TINYINT(1) DEFAULT 0;
 ALTER TABLE `temp_sorder` ADD COLUMN `Sorder_confirmed2` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_SalesOrderConfirm2` TINYINT(1) DEFAULT 0;

 CREATE TABLE `Constraint_Type` (
  `type_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `constraint_code` VARCHAR(60) NOT NULL,
  `constraint_desc` VARCHAR(100),
  PRIMARY KEY (`type_id`)
)
ENGINE = InnoDB;

CREATE TABLE `Form_Constraint` (
  `Form_ConstraintId` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `constraint_typeId` INTEGER UNSIGNED NOT NULL,
  `form_type` VARCHAR(3) NOT NULL,
  `constraint_active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
  PRIMARY KEY (`Form_ConstraintId`)
)
ENGINE = InnoDB;

#nadine #10-04-2017
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_CalculateRMReport` TINYINT(1) DEFAULT 0;

CREATE TABLE `RM_Calculation` (
  `Calculation_id` INTEGER UNSIGNED NOT NULL,
  `item_codefg` VARCHAR(20) NOT NULL,
  `qty` DOUBLE NOT NULL,
  `user_code` VARCHAR(45) NOT NULL,
  PRIMARY KEY (`Calculation_id`)
)
ENGINE = InnoDB;

CREATE TABLE `RM_Calculationdt` (
  `Calculationdt_id` INTEGER UNSIGNED NOT NULL,
  `Calculation_id` INTEGER UNSIGNED NOT NULL,
  `item_coderm` VARCHAR(20) NOT NULL,
  `qty` DOUBLE NOT NULL,
  PRIMARY KEY (`Calculationdt_id`)
)
ENGINE = InnoDB;



#fatima #10-04-2017
ALTER TABLE `SalesSetup` ADD COLUMN showGRNNo TINYINT(1) DEFAULT 0;
ALTER TABLE `deliveries` ADD COLUMN GRNNO VARCHAR(45);
ALTER TABLE `temp_deliveries` ADD COLUMN GRNNO VARCHAR(45);

#nadine #12-04-2017
CREATE TABLE  `notification_type` (
  `Notification_Name` varchar(30) NOT NULL,
  `Notification_Description` varchar(150) DEFAULT NULL,
  PRIMARY KEY (`Notification_Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE  `accesslabelsrocky`.`notification_access` (
  `NotifyAccess_Id` int(11) NOT NULL AUTO_INCREMENT,
  `user_code` varchar(20) DEFAULT NULL,
  `Notification_Name` varchar(30) DEFAULT NULL,
  `View_Access` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`NotifyAccess_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `accesslabelsrocky`.`Notification_Access` ADD COLUMN nbrOfDays DOUBLE;

ALTER TABLE `notification` MODIFY COLUMN `notification_description` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE notification_type ADD COLUMN menubased TINYINT(1);
ALTER TABLE Notification ADD COLUMN expiredate DATETIME;

ALTER TABLE `setup` ADD COLUMN `project_no` DOUBLE,ADD COLUMN `costcent_no` DOUBLE;

CREATE TABLE  `mailogs` (
  `mailog_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `ticket_id` bigint(20) DEFAULT NULL,
  `ticket_date` datetime DEFAULT NULL,
  `errormsg` varchar(1000) DEFAULT NULL,
  `sender` varchar(200) DEFAULT NULL,
  `recipient` varchar(1000) DEFAULT NULL,
  `mailbody` varchar(1000) NOT NULL,
  PRIMARY KEY (`mailog_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#nadine #18-04-2017
ALTER TABLE `module` ADD COLUMN `module_allowexpiry` TINYINT(1) DEFAULT 0;


#nadine #19-04-2017
ALTER TABLE `stktransaction` ADD COLUMN  `qt_productionrqst` DOUBLE;
#nadine #02-05-2017
ALTER TABLE `accesslabelsrocky`.`LOGIN` ADD COLUMN `ShowBankInfo` TINYINT(1) DEFAULT 0,
ADD COLUMN `ShowInsuranceInfo` TINYINT(1) DEFAULT 0;


 #fatima #27-4-2017
 ALTER TABLE `archivingoffer` CHANGE COLUMN `Offer code` `Offer_code` VARCHAR(45) CHARACTER 
 SET utf8 COLLATE utf8_general_ci NOT NULL;
 
 
 #fatima #4-5-2017
 
 alter table `archivingoffer`
add column filename varchar(45) default null;

#fatima #5-5-2017
alter table setup add column offer_path varchar(50) default null;


#fatima 05-08-2017
alter table archivingoffer MODIFY filename varchar(100) default null;

#nadine #08-05-2017
ALTER TABLE `module` ADD COLUMN `Module_ConfirmDR` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_ReturnDeliveryConfirm` TINYINT(1) DEFAULT 0;
ALTER TABLE `deliverydt` ADD COLUMN `confirmDR` tinyint(1) DEFAULT 0;
#amin #09-05-2017

ALTER TABLE `rma` ADD COLUMN `RMA_No` VARCHAR(50),
 ADD COLUMN `RMA_PromissDate` DATETIME,
 ADD COLUMN `RMA_ClientTelephone` VARCHAR(50),
 ADD COLUMN `RMA_ClientMobile` VARCHAR(50);
 
 ALTER TABLE `rmadt` ADD COLUMN `RMADt_Charge` VARCHAR(50),
 ADD COLUMN `RMADt_Charge2` VARCHAR(50),
 ADD COLUMN `RMADt_PickedUpBy` VARCHAR(100);
 
 CREATE TABLE temp_rma like rma;
 CREATE TABLE temp_rmadt like rmadt;
 
  ALTER TABLE `temp_rmadt` ADD COLUMN `RMADt_Charge` VARCHAR(50),
 ADD COLUMN `RMADt_Charge2` VARCHAR(50),
 ADD COLUMN `RMADt_PickedUpBy` VARCHAR(100);
 
 ALTER TABLE `rma` ADD COLUMN `RMA_email` VARCHAR(100),
 ADD COLUMN `RMA_subject` VARCHAR(100);
 
  ALTER TABLE `temp_rma` ADD COLUMN `RMA_email` VARCHAR(100),
 ADD COLUMN `RMA_subject` VARCHAR(100);
 
 #nadine #11-05-2017
 ALTER TABLE `items` ADD COLUMN `Item_SubSequence` VARCHAR(20);
 
 #nadine #12-05-2017
 CREATE TABLE  `periods` (
  `period_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `period_description` varchar(150) CHARACTER SET utf8 DEFAULT NULL,
  `period_default` tinyint(1) DEFAULT NULL,
  `period_StartDate` date DEFAULT NULL,
  `period_EndDate` date DEFAULT NULL,
  `period_sequence` varchar(10) DEFAULT NULL,
  `period_nextperiod` tinyint(1) DEFAULT '0',
  `feesheader_reference` bigint(20) DEFAULT NULL,
  `next_period` tinyint(1) DEFAULT NULL,
  `prev_periodid` bigint(20) DEFAULT NULL,
  PRIMARY KEY (`period_id`),
  KEY `period_default` (`period_default`),
  KEY `Index_3` (`period_description`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 ALTER TABLE `archiving` ADD COLUMN `period_id` INTEGER;
 
 ALTER TABLE `setup` ADD COLUMN `Project_FromItems` TINYINT(1) DEFAULT 0;
 
 ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_MultiplePosting` TINYINT(1) DEFAULT 0;
 ALTER TABLE `module` ADD COLUMN `Module_CheckNegativeQtyBeforePosting` TINYINT(1) DEFAULT 0;
 
 #fatima 12-5-2017
 
alter table setup add column company_address varchar(255);
alter table setup add column company_phone2 varchar(30),
add column company_phone3 varchar(30);
alter table setup add column company_address2 varchar(255);
alter table setup add column company_city2 varchar(60);
alter table setup add column company_city_arabic varchar(60),
add column company_address_arabic varchar(255),
add column company_city2_arabic varchar(60),
add column company_address2_arabic varchar(255);
alter table setup add column company_country_arabic varchar(60);



alter table setup add column company_phone4 varchar(30);
alter table setup add column company_city3 varchar(30),
 add column company_city4 varchar(30);

alter table setup
add column company_telephone_city3 varchar(30),
add column company_phone1_city3 varchar(30),
add column company_phone2_city3 varchar(30);

alter table setup add column company_telephone_city4 varchar(30),
add column company_phone1_city4 varchar(30),
add column company_phone2_city4 varchar(30)
;
alter table setup add column website varchar(75);
alter table setup add column company_name_arabic varchar(45);

alter table setup add column company_memo_arabic varchar(45);






#nadine #15-05-2017
ALTER TABLE `module` ADD COLUMN `Module_CashRegisterAutoDisc` TINYINT(1) DEFAULT 0;

#amin #15-05-2017

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_DeliveryStatusItems` TINYINT(1);

#nadine #16-05-2017
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_FactoryProduction` TINYINT(1) DEFAULT 0;
CREATE TABLE `productionFactory` (
  `productionFactory_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `productionFactory_reference` DOUBLE,
  `productionFactory_date` DATETIME,
  `Currency_Code` VARCHAR(3),
  `productionFactory_remark` VARCHAR(256),
  `productionFactory_BelongsToGroup` INTEGER,
  `User_Account` VARCHAR(10),
  `Logged_User` VARCHAR(10),
  PRIMARY KEY (`productionFactory_id`)
)
ENGINE = InnoDB;

CREATE TABLE `temp_productionFactory` (
  `productionFactory_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `productionFactory_reference` DOUBLE,
  `productionFactory_date` DATETIME,
  `Currency_Code` VARCHAR(3),
  `productionFactory_remark` VARCHAR(256),
  `productionFactory_BelongsToGroup` INTEGER,
  `User_Account` VARCHAR(10),
  `Logged_User` VARCHAR(10),
  PRIMARY KEY (`productionFactory_id`)
)
ENGINE = InnoDB;

CREATE TABLE `productionFactoryFG` (
  `productionFactoryfg_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `productionFactory_id` INTEGER,
  `item_code` VARCHAR(20) NOT NULL,
  `item_created` DOUBLE,
  `warehouse_code` VARCHAR(20),
  `productionFactoryfg_qty` DOUBLE NOT NULL,
  `productionFactoryfg_price` DOUBLE NOT NULL,
  `productionFactoryfg_price1` DOUBLE NOT NULL,
  `productionFactoryfg_price2` DOUBLE NOT NULL,
  `productionFactoryfg_net` DOUBLE NOT NULL,
  `productionFactoryfg_net1` DOUBLE NOT NULL,
  `productionFactoryfg_net2` DOUBLE NOT NULL,
  PRIMARY KEY (`productionFactoryfg_id`)
)
ENGINE = InnoDB;

CREATE TABLE `temp_productionFactoryFG` (
  `productionFactoryfg_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `productionFactory_id` INTEGER,
  `item_code` VARCHAR(20) NOT NULL,
  `item_created` DOUBLE,
  `warehouse_code` VARCHAR(20),
  `productionFactoryfg_qty` DOUBLE NOT NULL,
  `productionFactoryfg_price` DOUBLE NOT NULL,
  `productionFactoryfg_price1` DOUBLE NOT NULL,
  `productionFactoryfg_price2` DOUBLE NOT NULL,
  `productionFactoryfg_net` DOUBLE NOT NULL,
  `productionFactoryfg_net1` DOUBLE NOT NULL,
  `productionFactoryfg_net2` DOUBLE NOT NULL,
  PRIMARY KEY (`productionFactoryfg_id`)
)
ENGINE = InnoDB;



CREATE TABLE `productionFactorySF` (
  `productionFactorysf_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `productionFactoryfg_id` INTEGER,
  `productionFactory_id` INTEGER UNSIGNED NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `productionFactorysf_weight` DOUBLE,
  `warehouse_code` VARCHAR(20),
  `productionFactorysf_qty` DOUBLE NOT NULL,
  `productionFactorysf_price` DOUBLE NOT NULL,
  `productionFactorysf_price1` DOUBLE NOT NULL,
  `productionFactorysf_price2` DOUBLE NOT NULL,
  PRIMARY KEY (`productionFactorysf_id`)
)
ENGINE = InnoDB;

CREATE TABLE `temp_productionFactorySF` (
  `productionFactorysf_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `productionFactoryfg_id` INTEGER,
  `productionFactory_id` INTEGER UNSIGNED NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `productionFactorysf_weight` DOUBLE,
  `warehouse_code` VARCHAR(20),
  `productionFactorysf_qty` DOUBLE NOT NULL,
  `productionFactorysf_price` DOUBLE NOT NULL,
  `productionFactorysf_price1` DOUBLE NOT NULL,
  `productionFactorysf_price2` DOUBLE NOT NULL,
  PRIMARY KEY (`productionFactorysf_id`)
)
ENGINE = InnoDB;

ALTER TABLE `sequence` ADD COLUMN `productionFactory_id` DOUBLE, ADD COLUMN `productionFactoryfg_id` DOUBLE, ADD COLUMN `productionFactorysf_id` DOUBLE;
ALTER TABLE `sequence` ADD COLUMN `productionFactory_reference` DOUBLE;
#amin #18-05-2017

ALTER TABLE `rma` ADD COLUMN `User_Code` VARCHAR(100);
ALTER TABLE `temp_rma` ADD COLUMN `User_Code` VARCHAR(100);

#nadine #22-05-2017 
ALTER TABLE `module` ADD COLUMN `module_outconfirm` TINYINT(1) DEFAULT 0;
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `login_outconfirm` TINYINT(1) DEFAULT 0;
ALTER TABLE `adjustment` ADD COLUMN `Adjustment_confirm` TINYINT(1) DEFAULT 0,ADD COLUMN `Confirmed_user` VARCHAR(20);
ALTER TABLE `temp_adjustment` ADD COLUMN `Adjustment_confirm` TINYINT(1) DEFAULT 0,ADD COLUMN `Confirmed_user` VARCHAR(20);

ALTER TABLE `adjustmentdt` ADD COLUMN `InvDEBITaccount` VARCHAR(20);
ALTER TABLE `temp_adjustmentdt` ADD COLUMN `InvDEBITaccount` VARCHAR(20);


ALTER TABLE `temp_productionFactory` ADD COLUMN `totnetweightrm` DOUBLE,ADD COLUMN `totnetweightsf` DOUBLE,ADD COLUMN `totwaste` DOUBLE;
ALTER TABLE `productionFactory` ADD COLUMN `totnetweightrm` DOUBLE,ADD COLUMN `totnetweightsf` DOUBLE,ADD COLUMN `totwaste` DOUBLE;

ALTER TABLE `temp_productionFactory` ADD COLUMN `related_id` INTEGER;
ALTER TABLE `productionFactory` ADD COLUMN `related_id` INTEGER;

#fatima #14-05-2017 
alter table archivingoffer add column confirmed tinyint(1);

#nadine #24-05-2017
ALTER TABLE `temp_productionFactory` ADD COLUMN `productionfactory_manualno` VARCHAR(45),ADD COLUMN `project_code` VARCHAR(20),
ADD COLUMN `costcent_code` VARCHAR(20);
ALTER TABLE `productionFactory` ADD COLUMN `productionfactory_manualno` VARCHAR(45),ADD COLUMN `project_code` VARCHAR(20),
ADD COLUMN `costcent_code` VARCHAR(20);

ALTER TABLE `temp_productionFactoryFG` ADD COLUMN `project_codedt` VARCHAR(20),ADD COLUMN `costcent_codedt` VARCHAR(20);
ALTER TABLE `productionFactoryFG` ADD COLUMN `project_codedt` VARCHAR(20),ADD COLUMN `costcent_codedt` VARCHAR(20);

ALTER TABLE `temp_productionFactorySF` ADD COLUMN `project_codedt` VARCHAR(20),ADD COLUMN `costcent_codedt` VARCHAR(20);
ALTER TABLE `productionFactorySF` ADD COLUMN `project_codedt` VARCHAR(20),ADD COLUMN `costcent_codedt` VARCHAR(20);

#fatima #25-05-2017
alter table setup add column company_address varchar(255);
alter table setup add column company_phone2 varchar(30),
add column company_phone3 varchar(30);
alter table setup add column company_address2 varchar(255);
alter table setup add column company_city2 varchar(60);
alter table setup add column company_city_arabic varchar(60),
add column company_address_arabic varchar(255),
add column company_city2_arabic varchar(60),
add column company_address2_arabic varchar(255);
alter table setup add column company_country_arabic varchar(60);
alter table setup add column company_phone4 varchar(30);
alter table setup add column company_city3 varchar(30),
add column company_city4 varchar(30);
alter table setup
add column company_telephone_city3 varchar(30),
add column company_phone1_city3 varchar(30),
add column company_phone2_city3 varchar(30);
alter table setup add column company_telephone_city4 varchar(30),
add column company_phone1_city4 varchar(30),
add column company_phone2_city4 varchar(30);
alter table setup add column website varchar(75);

#amin #26-05-2017

CREATE TABLE  `rmadtrpc` (
  `rmadtrpc_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `rmadt_id` bigint(20) unsigned NOT NULL,
  `item_code` varchar(20) NOT NULL,
  `rmadtrpc_quantity` double NOT NULL DEFAULT '0',
  `rmadtrpc_price` double NOT NULL DEFAULT '0',
  `rmadtrpc_pricebase1` double NOT NULL DEFAULT '0',
  `rmadtrpc_pricebase2` double NOT NULL DEFAULT '0',
  `warehouse_code` varchar(15) NOT NULL,
  `serial_number` varchar(40) DEFAULT NULL,
  `rma_id` bigint(20) NOT NULL,
  PRIMARY KEY (`rmadtrpc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#nadine #26-05-2017
alter table `temp_productionFactory` add column `wasteItem_Code` varchar(20);
alter table `productionFactory` add column `wasteItem_Code` varchar(20);

#amin #29-05-2017

create table temp_rmadtrpc like rmadtrpc;

#nadine #29-05-2017
ALTER TABLE `items` ADD COLUMN `last_SubItemSeq` VARCHAR(20);
ALTER TABLE `SorderSetup` ADD COLUMN `SubItem_Production` TINYINT(1) DEFAULT 0;
ALTER TABLE `sorderdt` ADD COLUMN `sorderdt_desc1` text;
ALTER TABLE `temp_sorderdt` ADD COLUMN `sorderdt_desc1` text;

#nadine #05-06-2017
CREATE TABLE  `temp_itemsdt` (
  `ItemDt_ID` int(11) NOT NULL AUTO_INCREMENT,
  `Item_Code` varchar(25) DEFAULT NULL,
  `ItemParam_Code` varchar(10) DEFAULT NULL,
  `itemdt_value` varchar(50) DEFAULT NULL,
  `itemdt_sign` varchar(1) DEFAULT NULL,
  `itemdt_value2` double DEFAULT NULL,
  `transid` double DEFAULT NULL,
  PRIMARY KEY (`ItemDt_ID`),
  KEY `itemsdtitem_code` (`Item_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE `temp_items` (
  `item_code` VARCHAR(20) NOT NULL,
  `item_picture` BLOB,
  `trans_id` INTEGER,
  PRIMARY KEY (`item_code`)
)
ENGINE = InnoDB;
ALTER TABLE `temp_items` ADD COLUMN `temp_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT AFTER `trans_id`,
 DROP PRIMARY KEY,
 ADD PRIMARY KEY (`temp_id`);

 alter table `sordersetup` add column default_sorderType varchar(2),add column allow_duplicateItem tinyint(1) default 0;
 
 #nadine #07-06-2017
 alter table notification_type add column multiple_ids tinyint(1) default 0;
 
#fatima #08-06-2017
CREATE TABLE  `package` (
  `package_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `package_code` varchar(45) NOT NULL,
  `package_description` varchar(200) NOT NULL,
  PRIMARY KEY (`package_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

ALTER TABLE `car_fuel` ADD COLUMN `fueltype_id` BIGINT(20) UNSIGNED NOT NULL;
ALTER TABLE `car_fuel` CHANGE COLUMN `fueltype_id` `vehicle_id` BIGINT(20);

 #fatima #09-06-2017
 ALTER TABLE `suppliers` ADD COLUMN `supplier_nature` VARCHAR(50) AFTER `Supplier_account_name`,
 ADD COLUMN `supplier_type` VARCHAR(50) AFTER `supplier_nature`;

 #nadine #12-06-2017
 CREATE TABLE `item_supplier` (
  `itemSupplier_id` INTEGER NOT NULL AUTO_INCREMENT,
  `item_code` VARCHAR(20) NOT NULL,
  `supplier_code` VARCHAR(20) NOT NULL,
  PRIMARY KEY (`itemSupplier_id`)
)
ENGINE = InnoDB;

CREATE TABLE `item_auction` (
  `auction_id` INTEGER NOT NULL AUTO_INCREMENT,
  `auction_reference` DOUBLE,
  `auction_startDate` DATETIME,
  `auction_endDate` DATETIME,
  `item_code` VARCHAR(20) NOT NULL,
  `auction_qty` DOUBLE NOT NULL,
  `auction_remark` VARCHAR(256) ,
  PRIMARY KEY (`auction_id`)
)
ENGINE = InnoDB;


CREATE TABLE `temp_item_auction` (
  `auction_id` INTEGER NOT NULL AUTO_INCREMENT,
  `auction_reference` DOUBLE,
  `auction_startDate` DATETIME,
  `auction_endDate` DATETIME,
  `item_code` VARCHAR(20) NOT NULL,
  `auction_qty` DOUBLE NOT NULL,
  `auction_remark` VARCHAR(256) ,
  PRIMARY KEY (`auction_id`)
)
ENGINE = InnoDB;

CREATE TABLE `item_auctiondt` (
  `auctiondt_id` INTEGER NOT NULL AUTO_INCREMENT,
  `auction_id` INTEGER NOT NULL,
  `supplier_code` VARCHAR(20) NOT NULL,
  `auction_checked` TINYINT(1),
  PRIMARY KEY (`auctiondt_id`)
)
ENGINE = InnoDB;

CREATE TABLE `temp_item_auctiondt` (
  `auctiondt_id` INTEGER NOT NULL AUTO_INCREMENT,
  `auction_id` INTEGER NOT NULL,
  `supplier_code` VARCHAR(20) NOT NULL,
  `auction_checked` TINYINT(1),
  PRIMARY KEY (`auctiondt_id`)
)
ENGINE = InnoDB;

alter table `sequence` add column `auction_reference` double,add column `auction_id` double,add column `auctiondt_id` double;
alter table `accesslabelsrocky`.`login` add column `FI_ItemAuction` tinyint(1) default 0;

#fatima #12-06-2017
CREATE TABLE `container` (
  `Cntr_size` varchar(15) NOT NULL,
  `Cntr_designation` varchar(50) NOT NULL,
  `Cntr_seel` tinyint(1) unsigned DEFAULT NULL,
  `Cntr_barcode` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`Cntr_size`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


#nadine #14-06-2017
alter table `accesslabelsrocky`.`login` add column `FI_SupplierItemAuction` tinyint(1) default 0;
CREATE TABLE `supplierBid` (
  `bid_id` INTEGER NOT NULL AUTO_INCREMENT,
  `auction_id` INTEGER NOT NULL,
  `supplier_code` VARCHAR(20) NOT NULL,
  `alias_name` VARCHAR(50),
  `bid_price` DOUBLE NOT NULL,
  PRIMARY KEY (`bid_id`)
)
ENGINE = InnoDB;
#nadine #15-06-2017
alter table `accesslabelsrocky`.`login` add column `FI_ItemAuctionHall` tinyint(1) default 0;


#amin #20-06-2017

ALTER TABLE `grouping` ADD COLUMN `grouping_optionledger` TINYINT(1),
 ADD COLUMN `grouping_groupcode2` VARCHAR(150),
 ADD COLUMN `grouping_ledgernumber2` VARCHAR(150);
 
 #nadine #22-06-2017
alter table `sorderdt` add column `Sorderdt_DirectWasteDbt` varchar(10),add column `Sorderdt_DirectWasteCrd` varchar(10),
add column `Sorderdt_exportAccount` varchar(10);

alter table `temp_sorderdt` add column `Sorderdt_DirectWasteDbt` varchar(10),add column `Sorderdt_DirectWasteCrd` varchar(10),
add column `Sorderdt_exportAccount` varchar(10);


ALTER TABLE `temp_purchasesserialno` ADD INDEX `Index_15`(`RelatedSerial_Id`),
 ADD INDEX `Index_16`(`TransferDt_ID`),
 ADD INDEX `Index_17`(`AdjustmentDt_ID`);
 
 ALTER TABLE `SorderSetup` ADD COLUMN `show_discountAmount` TINYINT(1) DEFAULT 0;
ALTER TABLE `SalesSetup` ADD COLUMN `show_discountAmount` TINYINT(1) DEFAULT 0;


#fatima #30-06-2017
alter table `area` add column `area_country` tinyint(1) DEFAULT NULL;

#nadine #30-06-2017
alter table `sordersetup` add column `autoloadProduction` tinyint(1) default 0;


ALTER TABLE `sorder` ADD INDEX `Index_16`(`Sorder_confirmed2`, `Sorder_Total`, `Sorder_ShipName`, `Sorder_ShippingWay`, `Sorder_ClientPhone`, `Sorder_ClientSorderDate`, `sorder_export`),
 ADD INDEX `Index_17`(`Sorder_TransportTTC`, `Sorder_TransportBase2`, `Sorder_TransportBase1`, `Sorder_TransportAmount`, `Sorder_TransportAccount`),
 ADD INDEX `Index_18`(`Sorder_Invoiced`, `Sorder_vehicleweight`, `Sorder_drivername`, `Sorder_vehicalno`, `sorder_produced`),
 ADD INDEX `Index_19`(`Sorder_ConfirmUser`, `Sorder_Status`, `Detail_Code`, `sorder_deliverytype`, `Sorder_disapproved`, `Sorder_Hide`, `Salesman_Code`, `sorder_transportAmnt2`, `sorder_transportAmnt1`, `sorder_transportAmnt`),
 ADD INDEX `Index_20`(`Sorder_ArtWorkAmnt2`, `Sorder_ArtWorkAmnt1`, `Sorder_ArtWorkAmnt`, `Sorder_ClichetAmnt2`, `Sorder_ClichetAmnt1`, `Sorder_ClichetAmnt`, `Sorder_DieCutAmnt2`, `Sorder_DieCutAmnt1`, `Sorder_DieCutAmnt`),
 ADD INDEX `Index_21`(`Sorder_ratebase2`, `Sorder_ratebase1`, `Sorder_rate`);

#nadine #12-07-2017
alter table `transsetup` add column `InvoiceOnSorder` tinyint(1) default 0;

#amin #12-07-2017

ALTER TABLE `salessetup` ADD COLUMN `Warehouse_Return` VARCHAR(20);

#amin #20-07-2017

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RMALocations` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_RMAPendingItems` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_ReturnRMAPendingItems` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_ReturnRMALocations` TINYINT(1) DEFAULT 0,
 ADD COLUMN `FI_ReturnRMAReception` TINYINT(1) DEFAULT 0;
 
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_informedby` VARCHAR(150);
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_informedby` VARCHAR(150);

 #nadine #21-07-2017
alter table `transactionsetup` add column `chk_GeneralAccount` tinyint(1) default 0;

#amin #21-07-2017

ALTER TABLE `problemcategory` ADD COLUMN `PROBLEMCATEGORY_TYPE` VARCHAR(1) DEFAULT 'C';

#fatima #26-07-2017
ALTER TABLE `setup` ADD COLUMN `manifest_path` VARCHAR(45) ;
ALTER TABLE `manifest` MODIFY COLUMN `voyage_BOLnumber` VARCHAR(3) NOT NULL;
ALTER TABLE `manifest` MODIFY COLUMN `BOL_pagenumber` VARCHAR(10) DEFAULT NULL;
ALTER TABLE `manifest` MODIFY COLUMN `vessel_id` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `manifest` MODIFY COLUMN `Agent_Id` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `manifest` MODIFY COLUMN `Agent1_id` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `manifest` MODIFY COLUMN `tax1_amount` VARCHAR(12) DEFAULT NULL,
 MODIFY COLUMN `tax2_amount` VARCHAR(12) DEFAULT NULL,
 MODIFY COLUMN `tax3_amount` VARCHAR(12) DEFAULT NULL,
 MODIFY COLUMN `tax4_amount` VARCHAR(12) DEFAULT NULL,
 MODIFY COLUMN `tax5_amount` VARCHAR(12) DEFAULT NULL,
 MODIFY COLUMN `tax6_amount` VARCHAR(12) DEFAULT NULL;

#nadine #28-07-2017
alter table `setup` add column `AlphaNumeral_CurrFirst` tinyint(1) default 0;

#amin #31-07-2017

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_engineer` TINYINT(1);

#nadine #01-08-2017
CREATE TABLE `accesslabelsrocky`.`System_Language` (
  `Lang_Code` VARCHAR(20) NOT NULL,
  `Lang_description` VARCHAR(45),
  `Lang_Default` TINYINT(1) NOT NULL DEFAULT 0,
  PRIMARY KEY (`Lang_Code`)
)
ENGINE = InnoDB;

#amin #01-08-2017

ALTER TABLE `problemcategory` ADD COLUMN `user_code` VARCHAR(100);

#nadine #03-08-2017
alter TABLE `module` add column `Module_RewardPointPer` TINYINT(1) default 0;
alter table `retailpoint` add column `toAmount` double, add column `retail_pointPer` double;

#fatima 07-08-2017
ALTER TABLE `manifestdt` MODIFY COLUMN `voyage_BOLnumber` VARCHAR(45) NOT NULL;
ALTER TABLE `port` ADD COLUMN `port_carrier` VARCHAR(45) AFTER `ShortCode`;

#nadine #08-08-2017
alter table `items` add column `item_createdBy` varchar(25);
alter table accesslabelsrocky.`headerlink` add column `manual_no` varchar(45);
alter table accesslabelsrocky.`detaillink` add column `manual_no` varchar(45);
alter table `deliveries` add column `delivery_cashType` varchar(10) ;
alter table `temp_deliveries` add column `delivery_cashType` varchar(10) ;

#amin #08-08-2017

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FI_RMAReport` TINYINT(1) DEFAULT 0;

#fatima #11-08-2017
ALTER TABLE `manifestdesc` MODIFY COLUMN `voyage_BOLnumber` VARCHAR(45) NOT NULL;

#nadine #17-08-2017
alter table `supplierBid` add column `qty_supplied` double not null;
alter table `supplierBid` add column `bid_dateTime` datetime not null;
alter table `transsetup` add column `show_prqstRef` tinyint(1) default 0;
ALTER TABLE `temp_trans` MODIFY COLUMN `Trans_Representative` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `trans` MODIFY COLUMN `Trans_Representative` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
alter table `notification` add column `createdby_user` varchar(20);

#fatima #18-08-2017
ALTER TABLE `manifest` ADD COLUMN `received_date` DATETIME AFTER `manifest_id`,
 ADD COLUMN `confirmed_user` VARCHAR(45) AFTER `received_date`,
 ADD COLUMN `manifest_confirm` TINYINT(1) UNSIGNED AFTER `confirmed_user`;
 
#amin #18-08-2017

ALTER TABLE `porder` ADD COLUMN `porder_confirmedby` VARCHAR(100);

#amin #22-08-2017

ALTER TABLE `items` ADD COLUMN `item_investper` DOUBLE; #item #interest
ALTER TABLE `production` ADD COLUMN `Production_investper` DOUBLE; #item #interest
ALTER TABLE `temp_production` ADD COLUMN `Production_investper` DOUBLE; #item #interest

#fatima #22-08-2017
ALTER TABLE `containerdt` ADD COLUMN `received_date` DATETIME AFTER `container_seal1`,
 ADD COLUMN `departure_date` DATETIME AFTER `received_date`,
 ADD COLUMN `Shipper` VARCHAR(45) AFTER `departure_date`,
 ADD COLUMN `consigne` VARCHAR(45) AFTER `Shipper`,
 ADD COLUMN `vessel_name` VARCHAR(45) AFTER `consigne`;
 
 ALTER TABLE `containerdt` ADD COLUMN `container_code` VARCHAR(45) AFTER `vessel_name`;

#fatima #23-08-2017
CREATE TABLE  `manifestdtl` (
  `tax_description` varchar(45) DEFAULT NULL,
  `item_name` varchar(45) DEFAULT NULL,
  `tax_amount` double DEFAULT NULL,
  `quantity` int(10) unsigned DEFAULT NULL,
  `manifestdtl_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `discount` double DEFAULT NULL,
  `DESCRIPTION` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`manifestdtl_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8;

#amin #24-08-2017

ALTER TABLE `grouping` ADD COLUMN `Group_Export` TINYINT(1);


#nadine #24-08-2017
alter table `setup` add column `item_sequence` varchar(10);
alter table `accesslabelsrocky`.`login` add column `FI_PreReceipt` tinyint(1) default 0;
alter table `transsetup` add column `show_prqstRef` tinyint(1) default 0;
ALTER TABLE `temp_trans` MODIFY COLUMN `Trans_Representative` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `trans` MODIFY COLUMN `Trans_Representative` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
alter table `notification` add column `createdby_user` varchar(20);

#fatima #24-08-2017
ALTER TABLE `manifestdtl` ADD COLUMN `vessel_name` VARCHAR(45) AFTER `DESCRIPTION`,
 ADD COLUMN `Voyage_year` VARCHAR(2) AFTER `vessel_name`,
 ADD COLUMN `voyage_number` DECIMAL(3,0) AFTER `Voyage_year`,
 ADD COLUMN `BOL_identification` VARCHAR(16) AFTER `voyage_number`;
 
 CREATE TABLE `default_charges` (
  `charges_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `item_code` VARCHAR(45),
  `subgroup` VARCHAR(45),
  `sellingprice` DOUBLE,
  `quantity` INTEGER UNSIGNED,
  `active` TINYINT(1) UNSIGNED,
  PRIMARY KEY (`charges_id`)
)
ENGINE = InnoDB;

#fatima #25-08-2017
ALTER TABLE `containerdt` ADD COLUMN `remark` VARCHAR(45) AFTER `container_code`,
 ADD COLUMN `Voyage_year` VARCHAR(2) AFTER `remark`,
 ADD COLUMN `voyage_number` DECIMAL(3,0) AFTER `Voyage_year`,
 ADD COLUMN `BOL_identification` VARCHAR(16) AFTER `vessel_name`;
 
 ALTER TABLE `containertrace` MODIFY COLUMN `vessel_id` INT(10) UNSIGNED,
 ADD COLUMN `Voyage_year` varchar(2) AFTER `vessel_id`,
 ADD COLUMN `voyage_number` decimal(3,0) AFTER `Voyage_year`,
 ADD COLUMN `BOL_identification` VARCHAR(45) AFTER `voyage_number`,
 ADD COLUMN `vessel_name` VARCHAR(45) AFTER `BOL_identification`;
 
 
 ALTER TABLE `containerdt` ADD COLUMN `manifestdt_auto` INTEGER UNSIGNED AFTER `voyage_number`;


ALTER TABLE `manifestdesc` MODIFY COLUMN `voyage_BOLnumber` VARCHAR(45) NOT NULL;
ALTER TABLE `manifestdesc` MODIFY COLUMN `BOL_pagenumber` VARCHAR(45) DEFAULT NULL;
ALTER TABLE `containerdt` MODIFY COLUMN `remark` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `containertrace` CHANGE COLUMN `Manifest_id` `Manifest_auto` INT(10) UNSIGNED NOT NULL;

ALTER TABLE `containertrace` ADD COLUMN `manifestdt_auto` INTEGER UNSIGNED AFTER `vessel_name`;


#nadine #29-08-2017
alter table `temp_transferrequestdt` add column `transferrequestdt_heatno` varchar(100);
alter table `transferrequestdt` add column `transferrequestdt_heatno` varchar(100);
alter table `TransferSetup` add column `HeatNo_Required` tinyint(1) default 0;

alter table `Temp_PRequestDt` add column `PRequestDt_heatno` varchar(100);
alter table `PRequestDt` add column `PRequestDt_heatno` varchar(100);

alter table `PurchaseSetup` add column `HeatNo_Required` tinyint(1) default 0;
alter table `ProductionSetup` add column `HeatNo_Required` tinyint(1) default 0;

alter table `Temp_AdjustmentRequestDt` add column `AdjustmentRequestDt_heatno` varchar(100);
alter table `AdjustmentRequestDt` add column `AdjustmentRequestDt_heatno` varchar(100);
alter table `AdjustmentSetup` add column `HeatNo_Required` tinyint(1) default 0;

alter table `Temp_PRequestDt` add column `PRequestDt_RequiredDate` Datetime;
alter table `PRequestDt` add column `PRequestDt_RequiredDate` Datetime;

alter table `temp_sorderdt` add column `sorderdt_heatno` varchar(100);
alter table `sorderdt` add column `sorderdt_heatno` varchar(100);

#nadine #06-09-2017
Alter Table `accesslabelsrocky`.`login` Add Column `FI_MaterialRequisition` Tinyint(1) default 0;

CREATE TABLE  `temp_materialreq` (
  `MReq_id` int(11) NOT NULL,
  `MReq_reference` double DEFAULT NULL,
  `MReq_date` datetime DEFAULT NULL,
  `MReq_RequestDate` datetime DEFAULT NULL,
  `MReq_RequestBy` varchar(50) DEFAULT NULL,
  `MReq_remark` varchar(100) DEFAULT NULL,
  `Supplier_code` varchar(10) DEFAULT NULL,
  `MReq_SupplierContract` varchar(50) DEFAULT NULL,
  `Currency_code` varchar(6) DEFAULT NULL,
  `Costcent_code` varchar(20) DEFAULT NULL,
  `MReq_warranty` varchar(150) DEFAULT NULL,
  `MReq_document` varchar(150) DEFAULT NULL,
  `MReq_DeliveryDate` datetime DEFAULT NULL,
  `MReq_DeliveryPlace` varchar(50) DEFAULT NULL,
  `MReq_DeliveryContact` varchar(50) DEFAULT NULL,
  `MReq_DeliveryTelephone` varchar(15) DEFAULT NULL,
  `MReq_DeliveryFax` varchar(15) DEFAULT NULL,
  `MReq_PaymentTerm` varchar(150) DEFAULT NULL,
  `MReq_PorderDepartment` varchar(40) DEFAULT NULL,
  `MReq_InspectionPlace` varchar(50) DEFAULT NULL,
  `MReq_InspectionDate` datetime DEFAULT NULL,
  `MReq_Inspectionby` varchar(50) DEFAULT NULL,
  `Project_code` varchar(20) DEFAULT NULL,
  `MReq_TotalQuantity` double DEFAULT '0',
  `MReq_TotalQuantityUsed` double DEFAULT '0',
  `MReq_QuantityEqual` tinyint(1) DEFAULT '0',
  `MReq_Posted` tinyint(1) DEFAULT '0',
  `CostCenter_code` varchar(15) DEFAULT NULL,
  `User_Name` varchar(30) DEFAULT NULL,
  `MReq_BelongsToGroup` int(11) DEFAULT NULL,
  `MReq_BelongsToGrp` int(11) DEFAULT NULL,
  `MReq_CarNo` varchar(31) DEFAULT NULL,
  `MReq_ReducedQuantity` double DEFAULT '0',
  `MReq_Quantity` double DEFAULT '0',
  `SendReceive_Reference` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `MReq_Price` double DEFAULT '0',
  `MReq_PriceBase1` double DEFAULT '0',
  `MReq_PriceBase2` double DEFAULT '0',
  `MReq_Application` varchar(150) DEFAULT NULL,
  `MReq_Approved` tinyint(1) DEFAULT '0',
  `MReq_ApprovedBy` varchar(10) DEFAULT NULL,
  `MReq_Status` varchar(1) DEFAULT NULL,
  `Status_Remark` varchar(100) DEFAULT NULL,
  `MReq_VatChkBox` tinyint(1) DEFAULT '0',
  `MReq_Print` tinyint(1) DEFAULT '0',
  `MReq_Tax1` double DEFAULT NULL,
  `MReq_Tax2` double DEFAULT NULL,
  `MReq_Tax3` double DEFAULT NULL,
  `MReq_Tax4` double DEFAULT NULL,
  `MReq_Tax5` double DEFAULT NULL,
  `MReq_Tax1Base1` double DEFAULT NULL,
  `MReq_Tax2Base1` double DEFAULT NULL,
  `MReq_Tax3Base1` double DEFAULT NULL,
  `MReq_Tax4Base1` double DEFAULT NULL,
  `MReq_Tax5Base1` double DEFAULT NULL,
  `MReq_Tax1Base2` double DEFAULT NULL,
  `MReq_Tax2Base2` double DEFAULT NULL,
  `MReq_Tax3Base2` double DEFAULT NULL,
  `MReq_Tax4Base2` double DEFAULT NULL,
  `MReq_Tax5Base2` double DEFAULT NULL,
  `MReq_lstordsupp` varchar(45) DEFAULT NULL,
  `MReq_lstordpayterm` varchar(45) DEFAULT NULL,
  `MReq_lstorddeliveryterms` varchar(45) DEFAULT NULL,
  `MReq_otherSupplier` varchar(45) DEFAULT NULL,
  `MReq_Taxable` double DEFAULT '0',
  `MReq_TaxableBase1` double DEFAULT '0',
  `MReq_TaxableBase2` double DEFAULT '0',
  `MReq_NoneTaxable` double DEFAULT '0',
  `MReq_NoneTaxableBase1` double DEFAULT '0',
  `MReq_NoneTaxableBase2` double DEFAULT '0',
  `MReq_DiscountAmount` double DEFAULT '0',
  `MReq_DiscountBase1` double DEFAULT '0',
  `MReq_DiscountBase2` double DEFAULT '0',
  `MReq_Vat` double DEFAULT '0',
  `MReq_VatBase1` double DEFAULT '0',
  `MReq_VatBase2` double DEFAULT '0',
  `MReq_DiscountPer` double DEFAULT '0',
  `MReq_monthlyconsumption` double DEFAULT NULL,
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `MReq_Total` double DEFAULT '0',
  `MReq_TotalBase1` double DEFAULT '0',
  `MReq_TotalBase2` double DEFAULT '0',
  `MReq_Type` varchar(3) DEFAULT NULL,
  `MReq_Confirmed` tinyint(1) DEFAULT '0',
  `MReq_Import` tinyint(1) DEFAULT '0',
  `MReq_VATChckbx` tinyint(1) DEFAULT '0',
  `Expiry_date` datetime DEFAULT NULL,
  `username` varchar(20) DEFAULT NULL,
  `user_account` varchar(20) DEFAULT NULL,
  `rejectedreason` varchar(100) DEFAULT NULL,
  `MReq_Purpose` varchar(200) DEFAULT NULL,
  `MReq_Location` varchar(200) DEFAULT NULL,
  `MReq_Priority` varchar(200) DEFAULT NULL,
  `user_confirmed` varchar(100) DEFAULT NULL,
  `MReq_Cancelled` tinyint(1) DEFAULT '0',
  `Confirm_date` datetime DEFAULT NULL,
  PRIMARY KEY (`MReq_id`),
  KEY `Costcenter` (`Costcent_code`),
  KEY `Date` (`MReq_date`),
  KEY `DateRef` (`MReq_reference`,`MReq_date`),
  KEY `PrjCst` (`Costcent_code`,`Project_code`),
  KEY `Reference` (`MReq_reference`),
  KEY `supplier` (`Supplier_code`),
  KEY `SupplierDate` (`MReq_date`,`Supplier_code`),
  KEY `SupplierDateRef` (`MReq_reference`,`MReq_date`,`Supplier_code`),
  KEY `FK_materialreq_Branch` (`BRANCH_CODE`),
  CONSTRAINT `FK_materialreq_Branch` FOREIGN KEY (`BRANCH_CODE`) REFERENCES `branches` (`BRANCH_CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE  `temp_materialreqdt` (
  `MReqDt_id` int(11) NOT NULL,
  `MReq_id` double DEFAULT NULL,
  `MReq_Date` datetime DEFAULT NULL,
  `Item_code` varchar(20) DEFAULT NULL,
  `MReqDt_Quantity` double DEFAULT NULL,
  `MReqDt_QuantityUsed` double DEFAULT NULL,
  `MReqDt_QuantityEqual` tinyint(1) DEFAULT '0',
  `MReqDt_Remark` varchar(100) DEFAULT NULL,
  `Project_code` varchar(20) DEFAULT NULL,
  `Costcent_code` varchar(20) DEFAULT NULL,
  `Item_Barcode` varchar(40) DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Supplier_code` varchar(10) DEFAULT NULL,
  `MReqDt_PrintRemark` tinyint(1) DEFAULT '0',
  `MReqDt_PrintRow` tinyint(1) DEFAULT '0',
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `Porder_References` varchar(50) DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `MReqDt_Price` double DEFAULT NULL,
  `MReqDt_PriceBase1` double DEFAULT NULL,
  `MReqDt_PriceBase2` double DEFAULT NULL,
  `Item_ManufacturedCode` varchar(20) DEFAULT NULL,
  `item_vat` double DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `MReqDt_QuantityExist` double DEFAULT NULL,
  `MReqDt_LastPrice` double DEFAULT NULL,
  `MReqDt_LastCurrency_code` varchar(6) DEFAULT NULL,
  `MReqDt_LastSupplier_code` varchar(10) DEFAULT NULL,
  `MReqDt_Discount` double DEFAULT '0',
  `MReqDt_DiscountAmount` double DEFAULT '0',
  `MReqDt_DiscountBase1` double DEFAULT '0',
  `MReqDt_DiscountBase2` double DEFAULT '0',
  `MReqDt_PriceTTC` double DEFAULT '0',
  `Item_Tax1` double DEFAULT NULL,
  `Item_Tax2` double DEFAULT NULL,
  `Item_Tax3` double DEFAULT NULL,
  `Item_Tax4` double DEFAULT NULL,
  `Item_Tax5` double DEFAULT NULL,
  `Item_QtyPacked` double DEFAULT '0',
  `Item_CodePacked` varchar(21) DEFAULT NULL,
  `MReqDt_PriceTTCBase1` double DEFAULT NULL,
  `MReqDt_PriceTTCBase2` double DEFAULT NULL,
  `item_description` varchar(200) DEFAULT NULL,
  `MReqDt_OQuantity` double DEFAULT NULL,
  `MReqDt_CQuantity` double DEFAULT NULL,
  `MReqDt_status` varchar(1) DEFAULT NULL,
  `MReqDt_approvedlevel` int(11) DEFAULT NULL,
  `approvedby` varchar(20) DEFAULT NULL,
  `rejectedreason` varchar(100) DEFAULT NULL,
  `user_name` varchar(200) DEFAULT NULL,
  `user_account` varchar(50) DEFAULT NULL,
  `Logged_Code` varchar(10) DEFAULT NULL,
  `MReqDt_availableqty` double DEFAULT NULL,
  `MReqDt_unitsalesdesc` varchar(20) DEFAULT NULL,
  `Approved_date` datetime DEFAULT NULL,
  `MReqDt_heatno` varchar(100) DEFAULT NULL,
  `MReqDt_RequiredDate` datetime DEFAULT NULL,
  PRIMARY KEY (`MReqDt_id`),
  KEY `id` (`MReq_id`),
  KEY `IdItemWhCst` (`MReq_id`,`Item_code`,`Costcent_code`,`Warehouse_Code`),
  KEY `Item` (`Item_code`),
  KEY `Idx_LoggedCode` (`Logged_Code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE  `materialreq` (
  `MReq_id` int(11) NOT NULL,
  `MReq_reference` double DEFAULT NULL,
  `MReq_date` datetime DEFAULT NULL,
  `MReq_RequestDate` datetime DEFAULT NULL,
  `MReq_RequestBy` varchar(50) DEFAULT NULL,
  `MReq_remark` varchar(100) DEFAULT NULL,
  `Supplier_code` varchar(10) DEFAULT NULL,
  `MReq_SupplierContract` varchar(50) DEFAULT NULL,
  `Currency_code` varchar(6) DEFAULT NULL,
  `Costcent_code` varchar(20) DEFAULT NULL,
  `MReq_warranty` varchar(150) DEFAULT NULL,
  `MReq_document` varchar(150) DEFAULT NULL,
  `MReq_DeliveryDate` datetime DEFAULT NULL,
  `MReq_DeliveryPlace` varchar(50) DEFAULT NULL,
  `MReq_DeliveryContact` varchar(50) DEFAULT NULL,
  `MReq_DeliveryTelephone` varchar(15) DEFAULT NULL,
  `MReq_DeliveryFax` varchar(15) DEFAULT NULL,
  `MReq_PaymentTerm` varchar(150) DEFAULT NULL,
  `MReq_PorderDepartment` varchar(40) DEFAULT NULL,
  `MReq_InspectionPlace` varchar(50) DEFAULT NULL,
  `MReq_InspectionDate` datetime DEFAULT NULL,
  `MReq_Inspectionby` varchar(50) DEFAULT NULL,
  `Project_code` varchar(20) DEFAULT NULL,
  `MReq_TotalQuantity` double DEFAULT '0',
  `MReq_TotalQuantityUsed` double DEFAULT '0',
  `MReq_QuantityEqual` tinyint(1) DEFAULT '0',
  `MReq_Posted` tinyint(1) DEFAULT '0',
  `CostCenter_code` varchar(15) DEFAULT NULL,
  `User_Name` varchar(30) DEFAULT NULL,
  `MReq_BelongsToGroup` int(11) DEFAULT NULL,
  `MReq_BelongsToGrp` int(11) DEFAULT NULL,
  `MReq_CarNo` varchar(31) DEFAULT NULL,
  `MReq_ReducedQuantity` double DEFAULT '0',
  `MReq_Quantity` double DEFAULT '0',
  `SendReceive_Reference` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `MReq_Price` double DEFAULT '0',
  `MReq_PriceBase1` double DEFAULT '0',
  `MReq_PriceBase2` double DEFAULT '0',
  `MReq_Application` varchar(150) DEFAULT NULL,
  `MReq_Approved` tinyint(1) DEFAULT '0',
  `MReq_ApprovedBy` varchar(10) DEFAULT NULL,
  `MReq_Status` varchar(1) DEFAULT NULL,
  `Status_Remark` varchar(100) DEFAULT NULL,
  `MReq_VatChkBox` tinyint(1) DEFAULT '0',
  `MReq_Print` tinyint(1) DEFAULT '0',
  `MReq_Tax1` double DEFAULT NULL,
  `MReq_Tax2` double DEFAULT NULL,
  `MReq_Tax3` double DEFAULT NULL,
  `MReq_Tax4` double DEFAULT NULL,
  `MReq_Tax5` double DEFAULT NULL,
  `MReq_Tax1Base1` double DEFAULT NULL,
  `MReq_Tax2Base1` double DEFAULT NULL,
  `MReq_Tax3Base1` double DEFAULT NULL,
  `MReq_Tax4Base1` double DEFAULT NULL,
  `MReq_Tax5Base1` double DEFAULT NULL,
  `MReq_Tax1Base2` double DEFAULT NULL,
  `MReq_Tax2Base2` double DEFAULT NULL,
  `MReq_Tax3Base2` double DEFAULT NULL,
  `MReq_Tax4Base2` double DEFAULT NULL,
  `MReq_Tax5Base2` double DEFAULT NULL,
  `MReq_lstordsupp` varchar(45) DEFAULT NULL,
  `MReq_lstordpayterm` varchar(45) DEFAULT NULL,
  `MReq_lstorddeliveryterms` varchar(45) DEFAULT NULL,
  `MReq_otherSupplier` varchar(45) DEFAULT NULL,
  `MReq_Taxable` double DEFAULT '0',
  `MReq_TaxableBase1` double DEFAULT '0',
  `MReq_TaxableBase2` double DEFAULT '0',
  `MReq_NoneTaxable` double DEFAULT '0',
  `MReq_NoneTaxableBase1` double DEFAULT '0',
  `MReq_NoneTaxableBase2` double DEFAULT '0',
  `MReq_DiscountAmount` double DEFAULT '0',
  `MReq_DiscountBase1` double DEFAULT '0',
  `MReq_DiscountBase2` double DEFAULT '0',
  `MReq_Vat` double DEFAULT '0',
  `MReq_VatBase1` double DEFAULT '0',
  `MReq_VatBase2` double DEFAULT '0',
  `MReq_DiscountPer` double DEFAULT '0',
  `MReq_monthlyconsumption` double DEFAULT NULL,
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `MReq_Total` double DEFAULT '0',
  `MReq_TotalBase1` double DEFAULT '0',
  `MReq_TotalBase2` double DEFAULT '0',
  `MReq_Type` varchar(3) DEFAULT NULL,
  `MReq_Confirmed` tinyint(1) DEFAULT '0',
  `MReq_Import` tinyint(1) DEFAULT '0',
  `MReq_VATChckbx` tinyint(1) DEFAULT '0',
  `Expiry_date` datetime DEFAULT NULL,
  `username` varchar(20) DEFAULT NULL,
  `user_account` varchar(20) DEFAULT NULL,
  `rejectedreason` varchar(100) DEFAULT NULL,
  `MReq_Purpose` varchar(200) DEFAULT NULL,
  `MReq_Location` varchar(200) DEFAULT NULL,
  `MReq_Priority` varchar(200) DEFAULT NULL,
  `user_confirmed` varchar(100) DEFAULT NULL,
  `MReq_Cancelled` tinyint(1) DEFAULT '0',
  `Confirm_date` datetime DEFAULT NULL,
  PRIMARY KEY (`MReq_id`),
  KEY `Costcenter` (`Costcent_code`),
  KEY `Date` (`MReq_date`),
  KEY `DateRef` (`MReq_reference`,`MReq_date`),
  KEY `PrjCst` (`Costcent_code`,`Project_code`),
  KEY `Reference` (`MReq_reference`),
  KEY `supplier` (`Supplier_code`),
  KEY `SupplierDate` (`MReq_date`,`Supplier_code`),
  KEY `SupplierDateRef` (`MReq_reference`,`MReq_date`,`Supplier_code`),
  CONSTRAINT `FK_materialreq1_Branch` FOREIGN KEY (`BRANCH_CODE`) REFERENCES `branches` (`BRANCH_CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE  `materialreqdt` (
  `MReqDt_id` int(11) NOT NULL,
  `MReq_id` double DEFAULT NULL,
  `MReq_Date` datetime DEFAULT NULL,
  `Item_code` varchar(20) DEFAULT NULL,
  `MReqDt_Quantity` double DEFAULT NULL,
  `MReqDt_QuantityUsed` double DEFAULT NULL,
  `MReqDt_QuantityEqual` tinyint(1) DEFAULT '0',
  `MReqDt_Remark` varchar(100) DEFAULT NULL,
  `Project_code` varchar(20) DEFAULT NULL,
  `Costcent_code` varchar(20) DEFAULT NULL,
  `Item_Barcode` varchar(40) DEFAULT NULL,
  `Currency_Code` varchar(6) DEFAULT NULL,
  `Supplier_code` varchar(10) DEFAULT NULL,
  `MReqDt_PrintRemark` tinyint(1) DEFAULT '0',
  `MReqDt_PrintRow` tinyint(1) DEFAULT '0',
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `Porder_References` varchar(50) DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `MReqDt_Price` double DEFAULT NULL,
  `MReqDt_PriceBase1` double DEFAULT NULL,
  `MReqDt_PriceBase2` double DEFAULT NULL,
  `Item_ManufacturedCode` varchar(20) DEFAULT NULL,
  `item_vat` double DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `MReqDt_QuantityExist` double DEFAULT NULL,
  `MReqDt_LastPrice` double DEFAULT NULL,
  `MReqDt_LastCurrency_code` varchar(6) DEFAULT NULL,
  `MReqDt_LastSupplier_code` varchar(10) DEFAULT NULL,
  `MReqDt_Discount` double DEFAULT '0',
  `MReqDt_DiscountAmount` double DEFAULT '0',
  `MReqDt_DiscountBase1` double DEFAULT '0',
  `MReqDt_DiscountBase2` double DEFAULT '0',
  `MReqDt_PriceTTC` double DEFAULT '0',
  `Item_Tax1` double DEFAULT NULL,
  `Item_Tax2` double DEFAULT NULL,
  `Item_Tax3` double DEFAULT NULL,
  `Item_Tax4` double DEFAULT NULL,
  `Item_Tax5` double DEFAULT NULL,
  `Item_QtyPacked` double DEFAULT '0',
  `Item_CodePacked` varchar(21) DEFAULT NULL,
  `MReqDt_PriceTTCBase1` double DEFAULT NULL,
  `MReqDt_PriceTTCBase2` double DEFAULT NULL,
  `item_description` varchar(200) DEFAULT NULL,
  `MReqDt_OQuantity` double DEFAULT NULL,
  `MReqDt_CQuantity` double DEFAULT NULL,
  `MReqDt_status` varchar(1) DEFAULT NULL,
  `MReqDt_approvedlevel` int(11) DEFAULT NULL,
  `approvedby` varchar(20) DEFAULT NULL,
  `rejectedreason` varchar(100) DEFAULT NULL,
  `user_name` varchar(200) DEFAULT NULL,
  `user_account` varchar(50) DEFAULT NULL,
  `MReqDt_availableqty` double DEFAULT NULL,
  `MReqDt_unitsalesdesc` varchar(20) DEFAULT NULL,
  `Approved_date` datetime DEFAULT NULL,
  `MReqDt_heatno` varchar(100) DEFAULT NULL,
  `MReqDt_RequiredDate` datetime DEFAULT NULL,
  PRIMARY KEY (`MReqDt_id`),
  KEY `id` (`MReq_id`),
  KEY `IdItemWhCst` (`MReq_id`,`Item_code`,`Costcent_code`,`Warehouse_Code`),
  KEY `Item` (`Item_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Alter Table `sequence` Add Column `MaterialReq_id` Double, Add Column `MaterialReqdt_id` Double;
alter table `temp_materialreq` add column `Logged_Code` varchar(20);
alter table `sequence` add column `MaterialReq_Reference` double;

#fatima #06-09-2017

ALTER TABLE `manifest` MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `manifestdt` MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `manifestdesc` MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
ALTER TABLE `manifestdesc` MODIFY COLUMN `voyage_descripiton` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL,
 MODIFY COLUMN `descriptiongood` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;
 
 #fatima #07-09-2017
ALTER TABLE `manifest` ADD COLUMN `delivery_id` DOUBLE AFTER `manifest_confirm`;

#nadine #07-09-2017
alter table `adjustmentsetup` add column `Adjustment_loadCharging` tinyint(1) default 0;

alter table `temp_PrepaymentD` add column `client_code` varchar(10), add column `item_code` varchar(20), add column `serial_no` varchar(20),
add column `warehouse_code` varchar(20);
alter table `PrepaymentD` add column `client_code` varchar(10), add column `item_code` varchar(20), add column `serial_no` varchar(20),
add column `warehouse_code` varchar(20);

Alter Table `adjustment` add column `client_code` varchar(10), add column adj_division double, add column `chk_loadToChanging` tinyint(1) default 0, add column `PrePM_id` integer;
Alter Table `temp_adjustment` add column `client_code` varchar(10), add column adj_division double, add column `chk_loadToChanging` tinyint(1) default 0, add column `PrePM_id` integer;

#fatima #11-09-2017
alter table manifestdt add column manifest_manifestauto Integer;
alter table manifestdesc add column manifest_manifestauto Integer;
alter table manifestdtl add column manifest_manifestauto Integer;

#nadine #11-09-2017
Alter Table `accesslabelsrocky`.`Login` Add Column `FI_MaterialReqDel` Tinyint(1) default 0,	Add Column `FI_MaterialReqMod` Tinyint(1) default 0,
								Add Column `FI_MaterialReqToPurchaseReq` Tinyint(1) default 0;

Alter Table `temp_materialreq` add column `MReq_TransToPrqst` tinyint(1) default 0, add column `TransferToPRqst_date` Datetime, add column `TransferToPRqst_user` varchar(20);
Alter Table `materialreq` add column `MReq_TransToPrqst` tinyint(1) default 0, add column `TransferToPRqst_date` Datetime, add column `TransferToPRqst_user` varchar(20);

Alter Table `prequestdt` Add Column `related_MReqdtid` integer;
Alter Table `temp_prequestdt` Add Column `related_MReqdtid` integer;

#nadine #12-09-2017
Alter Table `accesslabelsrocky`.`login` Add Column `MR_default` Tinyint(1) default 0, Add Column `MR_status1` Tinyint(1) default 1,
Add Column `MR_status2` Tinyint(1) default 1, Add Column `MR_status3` Tinyint(1) default 1, Add Column `MR_status4` Tinyint(1) default 1;

Alter Table `accesslabelsrocky`.`login` Add Column `FI_PostPurchase` Tinyint(1) default 0;

alter table `purchasesetup` add column `Restricted_Posting` tinyint(1);

#nadine #14-09-2017

CREATE TABLE `accesslabelsrocky`.`users_emails` (
  `email_id` INTEGER NOT NULL AUTO_INCREMENT,
  `user_account` VARCHAR(10) NOT NULL,
  `email_address` VARCHAR(256) NOT NULL,
  PRIMARY KEY (`email_id`)
)
ENGINE = InnoDB;

ALTER TABLE `materialreq` DROP COLUMN `MReq_TransToPrqst`,
 DROP COLUMN `TransferToPRqst_date`,
 DROP COLUMN `TransferToPRqst_user`;

ALTER TABLE `temp_materialreq` DROP COLUMN `MReq_TransToPrqst`,
 DROP COLUMN `TransferToPRqst_date`,
 DROP COLUMN `TransferToPRqst_user`;
 
 #nadine #18-09-2017
 alter table `setup` add column `default_itemSubSequence` varchar(20);
 alter table `cashtype` add column `ledgernumber` varchar(10);
 
 #amin #23-10-2017
 
CREATE TABLE  `deliveries_temp` (
  `Delivery_id` double NOT NULL,
  `Delivery_Reference` double DEFAULT NULL,
  `Delivery_Date` datetime DEFAULT NULL,
  `Delivery_Remark` varchar(100) DEFAULT NULL,
  `Client_code` varchar(10) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Costcent_code` varchar(15) DEFAULT NULL,
  `Journal_Type` varchar(2) DEFAULT 'DI',
  `Delivery_QuantityEqual` tinyint(1) DEFAULT '0',
  `Delivery_TotalQuantity` double DEFAULT '0',
  `Delivery_TotalQuantityRet` double DEFAULT '0',
  `Delivery_QuantityEqualSld` tinyint(1) DEFAULT '0',
  `Delivery_TotalQuantitySld` double DEFAULT '0',
  `Delivery_TotalNoOfItem` double DEFAULT '0',
  `DeliveryDt_Id` double DEFAULT NULL,
  `Sale_id` double DEFAULT NULL,
  `Delivery_posted` tinyint(1) DEFAULT '0',
  `Transfer_Id` double DEFAULT NULL,
  `Delivery_Edit` tinyint(1) DEFAULT '0',
  `Journal_Id` double DEFAULT NULL,
  `Delivery_Marks` varchar(30) DEFAULT NULL,
  `Delivery_ShippedVia` varchar(30) DEFAULT NULL,
  `Delivery_ShippedTo` blob,
  `Delivery_NoCarton` double DEFAULT NULL,
  `Delivery_CartonSize` varchar(15) DEFAULT NULL,
  `Delivery_CartonUnit` varchar(10) DEFAULT NULL,
  `Delivery_CartonGrossWt` double DEFAULT '0',
  `Delivery_CartonNetWeight` double DEFAULT '0',
  `SALESMAN_cODE` varchar(10) DEFAULT NULL,
  `Delivery_VAT` double DEFAULT '0',
  `Delivery_VATBase1` double DEFAULT '0',
  `Delivery_VATBase2` double DEFAULT '0',
  `Delivery_Taxable` double DEFAULT '0',
  `Delivery_TaxableBase1` double DEFAULT '0',
  `Delivery_TaxableBase2` double DEFAULT '0',
  `Delivery_NoneTaxable` double DEFAULT '0',
  `Delivery_NoneTaxableBase1` double DEFAULT '0',
  `Delivery_NoneTaxableBase2` double DEFAULT '0',
  `Delivery_Total` double DEFAULT '0',
  `Delivery_TotalBase1` double DEFAULT '0',
  `Delivery_TotalBase2` double DEFAULT '0',
  `Delivery_DiscountAmount` double DEFAULT '0',
  `Delivery_DiscountBase1` double DEFAULT '0',
  `Delivery_DiscountBase2` double DEFAULT '0',
  `Currency_code` varchar(6) DEFAULT NULL,
  `Delivery_Cash` double DEFAULT '0',
  `Delivery_CashBase1` double DEFAULT '0',
  `Delivery_CashBase2` double DEFAULT '0',
  `Delivery_CashInBase1` double DEFAULT '0',
  `Delivery_CashInBase2` double DEFAULT '0',
  `Delivery_CashOutBase1` double DEFAULT '0',
  `Delivery_CashOutBase2` double DEFAULT '0',
  `Delivery_TipsBase1` double DEFAULT '0',
  `DELIVERY_CASHACCOUNT` varchar(10) DEFAULT NULL,
  `DELIVERY_CASHCUR` varchar(6) DEFAULT NULL,
  `DELIVERY_CHECKNO` varchar(20) DEFAULT NULL,
  `DELIVERY_CHECKDATE` datetime DEFAULT NULL,
  `DELIVERY_bANK` varchar(30) DEFAULT NULL,
  `DELIVERY_bANKBRANCH` varchar(20) DEFAULT NULL,
  `DELIVERY_TIPSACCOUNT` varchar(10) DEFAULT NULL,
  `Delivery_Mode` double DEFAULT '0',
  `DELIVERY_CREDITACCOUNT` varchar(10) DEFAULT NULL,
  `DELIVERY_CREDITACCOUNTVAT` varchar(10) DEFAULT NULL,
  `DELIVERY_VATACCOUNT` varchar(10) DEFAULT NULL,
  `DELIVERY_CREDITCUR` varchar(6) DEFAULT NULL,
  `JOURNALDT_VALUEDATE` datetime DEFAULT NULL,
  `USER_Account` varchar(10) DEFAULT NULL,
  `Delivery_assemblyno` varchar(15) DEFAULT NULL,
  `Delivery_Printed` int(11) DEFAULT '0',
  `Journalsec_id` double DEFAULT NULL,
  `Delivery_TaxableTTC` double DEFAULT '0',
  `Delivery_DiscountTTC` double DEFAULT '0',
  `Dlv_CreditCurInCashReg` varchar(7) DEFAULT NULL,
  `Delivery_CouponAmt` double DEFAULT '0',
  `Delivery_CouponAmt1` double DEFAULT '0',
  `Delivery_CouponAmt2` double DEFAULT '0',
  `Delivery_RMAcc` varchar(11) DEFAULT NULL,
  `Delivery_RMVatAcc` varchar(11) DEFAULT NULL,
  `SendReceive_Reference` double DEFAULT NULL,
  `Delivery_Rate` double DEFAULT '0',
  `Delivery_RateBase1` double DEFAULT '0',
  `Delivery_RateBase2` double DEFAULT '0',
  `Delivery_creditamount` double DEFAULT '0',
  `Delivery_creditamount1` double DEFAULT '0',
  `Delivery_creditamount2` double DEFAULT '0',
  `Delivery_CREDITACC` varchar(11) DEFAULT NULL,
  `Delivery_CREDITACCcur` varchar(7) DEFAULT NULL,
  `Delivery_BelongsToGroup` int(11) DEFAULT '0',
  `Purchase_id` double DEFAULT NULL,
  `Delivery_DiscountPer` double DEFAULT '0',
  `Delivery_CltNationality` varchar(31) DEFAULT NULL,
  `Delivery_CltPassportNo` varchar(31) DEFAULT NULL,
  `Delivery_ShippingWay` varchar(21) DEFAULT NULL,
  `Delivery_ShipName` varchar(61) DEFAULT NULL,
  `Delivery_FlightNo` varchar(21) DEFAULT NULL,
  `Delivery_ShipArrivalDate` datetime DEFAULT NULL,
  `Delivery_ShipDepartDate` datetime DEFAULT NULL,
  `Delivery_ShipDepartTime` datetime DEFAULT NULL,
  `Delivery_TotalTax` double DEFAULT '0',
  `Delivery_TotalTaxBase1` double DEFAULT '0',
  `Delivery_TotalTaxBase2` double DEFAULT '0',
  `Delivery_NonRMTTCIncAcc` varchar(13) DEFAULT NULL,
  `Delivery_NonRMAcc` varchar(13) DEFAULT NULL,
  `Delivery_RMTTCIncAcc` varchar(13) DEFAULT NULL,
  `Delivery_NonRMVatAcc` varchar(13) DEFAULT NULL,
  `Item_qtypacked` double DEFAULT '0',
  `Delivery_Tax1` double DEFAULT '0',
  `Delivery_Tax2` double DEFAULT '0',
  `Delivery_Tax3` double DEFAULT '0',
  `Delivery_Tax4` double DEFAULT '0',
  `Delivery_Tax5` double DEFAULT '0',
  `Delivery_Tax1Base1` double DEFAULT '0',
  `Delivery_Tax2Base1` double DEFAULT '0',
  `Delivery_Tax3Base1` double DEFAULT '0',
  `Delivery_Tax4Base1` double DEFAULT '0',
  `Delivery_Tax5Base1` double DEFAULT '0',
  `Delivery_Tax1Base2` double DEFAULT '0',
  `Delivery_Tax2Base2` double DEFAULT '0',
  `Delivery_Tax3Base2` double DEFAULT '0',
  `Delivery_Tax4Base2` double DEFAULT '0',
  `Delivery_Tax5Base2` double DEFAULT '0',
  `Delivery_Acctax1` varchar(11) DEFAULT NULL,
  `[REDACTED]` varchar(11) DEFAULT NULL,
  `[REDACTED]` varchar(11) DEFAULT NULL,
  `[REDACTED]` varchar(11) DEFAULT NULL,
  `[REDACTED]` varchar(11) DEFAULT NULL,
  `Delivery_Promotion` tinyint(1) DEFAULT '0',
  `Delivery_PromotionAcc` varchar(11) DEFAULT NULL,
  `Adjustment_Id` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Delivery_returnRef` double DEFAULT '0',
  `Delivery_Confirmed` tinyint(1) DEFAULT '0',
  `Delivery_FtsiSRF` double DEFAULT '0',
  `Delivery_FtsiPaletts` double DEFAULT '0',
  `Delivery_FTSISRFDVL` char(1) DEFAULT NULL,
  `delivery_commissionper` double DEFAULT '0',
  `DreturnIsDirect` tinyint(1) DEFAULT '0',
  `Delivery_TransportAccount` varchar(10) DEFAULT NULL,
  `Delivery_transportAmount` double DEFAULT '0',
  `Delivery_TransportAmountBase1` double DEFAULT '0',
  `Delivery_TransportAmountBase2` double DEFAULT '0',
  `Sorder_Reference` double DEFAULT '0',
  `delivery_activevat` tinyint(1) unsigned DEFAULT '0',
  `Detail_Code` varchar(50) DEFAULT NULL,
  `Delivery_SorderReferences` varchar(200) DEFAULT NULL,
  `Delivery_VatChkbx` tinyint(1) DEFAULT '1',
  `CashRegister_Name` varchar(20) DEFAULT NULL,
  `Delivery_DirectReturn` tinyint(1) DEFAULT '0',
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `Delivery_TransportTTC` double DEFAULT NULL,
  `Delivery_BonusAccount` varchar(10) DEFAULT NULL,
  `Delivery_BonusAmount` double DEFAULT NULL,
  `Delivery_BonusBase1` double DEFAULT NULL,
  `Delivery_BonusBase2` double DEFAULT NULL,
  `Delivery_BonusTTC` double DEFAULT NULL,
  `delivery_iban` varchar(45) DEFAULT NULL,
  `delivery_bankdetails` varchar(45) DEFAULT NULL,
  `Delivery_ManualNo` varchar(45) DEFAULT NULL,
  `Delivery_vehicleLoadweight` double DEFAULT NULL,
  `Delivery_vehicleweight` double DEFAULT NULL,
  `srorder_id` double DEFAULT NULL,
  `DELIVERY_LOADHHT` tinyint(1) DEFAULT '0',
  `Logged_code` varchar(10) DEFAULT NULL,
  `Delivery_OldData` tinyint(1) DEFAULT '0',
  `delivery_export` tinyint(1) DEFAULT NULL,
  `Delivery_ClientDeliveryDate` datetime DEFAULT NULL,
  PRIMARY KEY (`Delivery_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


CREATE TABLE  `deliverydt_temp` (
  `DeliveryDt_id` double NOT NULL,
  `Delivery_id` double DEFAULT '0',
  `Client_Code` varchar(10) DEFAULT NULL,
  `Delivery_Date` datetime DEFAULT NULL,
  `Journal_Type` varchar(2) DEFAULT 'DI',
  `Project_Code` varchar(15) DEFAULT NULL,
  `CostCent_Code` varchar(15) DEFAULT NULL,
  `Warehouse_Code` varchar(15) DEFAULT NULL,
  `Item_code` varchar(20) DEFAULT NULL,
  `DeliveryDt_Quantity` double DEFAULT '0',
  `DeliveryDt_QuantityReturn` double DEFAULT '0',
  `DeliveryDt_QuantitySld` double DEFAULT '0',
  `DeliveryDt_ExpireDate` datetime DEFAULT NULL,
  `RelatedDt_Id` double DEFAULT '0',
  `DeliveryDt_QuantityEqual` tinyint(1) DEFAULT '0',
  `DeliveryDt_QtyEqualSld` tinyint(1) DEFAULT '0',
  `Sale_id` double DEFAULT '0',
  `Currency_code` varchar(6) DEFAULT NULL,
  `SaleDt_Price` double DEFAULT '0',
  `SaleDt_PriceBase1` double DEFAULT '0',
  `SaleDt_PriceBase2` double DEFAULT '0',
  `Transferdt_id` double DEFAULT '0',
  `Related_id` double DEFAULT '0',
  `Deliverydt_remark` varchar(100) DEFAULT NULL,
  `Deliverydt_cost` double DEFAULT '0',
  `Deliverydt_costbase1` double DEFAULT '0',
  `Deliverydt_costbase2` double DEFAULT '0',
  `Item_CodePacked` varchar(20) DEFAULT NULL,
  `Color_Code` varchar(15) DEFAULT NULL,
  `Item_Vat` double DEFAULT '0',
  `Item_Barcode` varchar(20) DEFAULT NULL,
  `DeliveryDt_Price` double DEFAULT '0',
  `DeliveryDt_PriceBase1` double DEFAULT '0',
  `DeliveryDt_PriceBase2` double DEFAULT '0',
  `DeliveryDt_DiscountAmount` double DEFAULT '0',
  `DeliveryDt_DiscountBase1` double DEFAULT '0',
  `DeliveryDt_DiscountBase2` double DEFAULT '0',
  `DeliveryDt_DiscountPer` double DEFAULT '0',
  `SIZE_Measure` varchar(20) DEFAULT NULL,
  `SorderDt_CurrencyCode` varchar(7) DEFAULT NULL,
  `SorderDt_Price` double DEFAULT '0',
  `SorderDt_PriceBase1` double DEFAULT '0',
  `SorderDt_PriceBase2` double DEFAULT '0',
  `DeliveryDt_PriceTTC` double DEFAULT '0',
  `DeliveryDt_DeliveriedQty` double DEFAULT '0',
  `Item_QtyPacked` double DEFAULT '0',
  `Deliverydt_posted` tinyint(1) DEFAULT '0',
  `Deliverydt_DirectStkDbt` varchar(11) DEFAULT NULL,
  `Deliverydt_DirectStkCrd` varchar(11) DEFAULT NULL,
  `Deliverydt_DirectStkCur` varchar(11) DEFAULT NULL,
  `Deliverydt_ItemAccount` varchar(11) DEFAULT NULL,
  `Deliverydt_BelongsToGroup` int(11) DEFAULT '0',
  `Purchase_InvoiceNo` varchar(26) DEFAULT NULL,
  `Item_tax` double DEFAULT '0',
  `Journalsec_id` double DEFAULT '0',
  `Delivery_discountTTC` double DEFAULT '0',
  `Delivery_taxableTTC` double DEFAULT '0',
  `DeliveryDt_DelQtyEqual` tinyint(1) DEFAULT '0',
  `Item_Tax1` double DEFAULT '0',
  `Item_Tax2` double DEFAULT '0',
  `Item_Tax3` double DEFAULT '0',
  `Item_Tax4` double DEFAULT '0',
  `Item_Tax5` double DEFAULT '0',
  `DeliveryDt_QuantityFiscal` double DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  `DeliveryDt_PricePerUnit` double DEFAULT '0',
  `DeliveryDt_QtyUnit` double DEFAULT '0',
  `DeliveryDt_Promotion` tinyint(1) DEFAULT '0',
  `DeliveryDt_FtsiItemRef` varchar(14) DEFAULT NULL,
  `DeliveryDt_FtsiItmDes` varchar(60) DEFAULT NULL,
  `DeliveryDt_FtsiExtint` varchar(1) DEFAULT NULL,
  `DeliveryDt_FtsiLGH` double DEFAULT '0',
  `DeliveryDt_FtsiWDH` double DEFAULT '0',
  `DeliveryDt_FtsiHGT` double DEFAULT '0',
  `DeliveryDt_FtsiBND` double DEFAULT '0',
  `DeliveryDt_FtsiOF` double DEFAULT '0',
  `DeliveryDt_FtsiPCE` double DEFAULT '0',
  `DeliveryDt_FtsiFREE` varchar(1) DEFAULT NULL,
  `DeliveryDt_FtsiCLH` varchar(1) DEFAULT NULL,
  `DeliveryDt_FtsiDCT` varchar(1) DEFAULT NULL,
  `DeliveryDt_FtsiAW` varchar(1) DEFAULT NULL,
  `DeliveryDt_FtsiTRP` varchar(1) DEFAULT NULL,
  `DeliveryDt_FtsiCLAAMT` double DEFAULT '0',
  `DeliveryDt_FtsiDCTAMT` double DEFAULT '0',
  `DeliveryDt_FtsiAWAMT` double DEFAULT '0',
  `DeliveryDt_FtsiTRPAMT` double DEFAULT '0',
  `DeliveryDt_FTsiSOF` double DEFAULT '0',
  `DeliveryDt_OldData` tinyint(1) DEFAULT '0',
  `deliverydt_discountacc` varchar(10) DEFAULT NULL,
  `DeliveryDt_TransportAmount` double DEFAULT '0',
  `DeliveryDt_TransportAmountBase1` double DEFAULT '0',
  `DeliveryDt_TransportAmountBase2` double DEFAULT '0',
  `DeliveryDt_PromoAcc` varchar(10) DEFAULT NULL,
  `Item_ManufacturedCode` varchar(20) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `deliverydt_pqty` double DEFAULT NULL,
  `deliverydt_LastSellingPrice` double DEFAULT NULL,
  `deliverydt_lastsellingdiscount` double DEFAULT NULL,
  `deliverydt_lastsellingdate` datetime DEFAULT NULL,
  `deliverydt_priceTTCBase1` double DEFAULT '0',
  `deliverydt_priceTTCBase2` double DEFAULT '0',
  `Deliverydt_QtySorder` double DEFAULT '0',
  `Related_Ref` double DEFAULT NULL,
  `deliverydt_offer` tinyint(1) unsigned DEFAULT '0',
  `user_account` varchar(50) DEFAULT NULL,
  `DeliveryDt_BonusAmount` double DEFAULT NULL,
  `DeliveryDt_BonusBase1` double DEFAULT NULL,
  `DeliveryDt_BonusBase2` double DEFAULT NULL,
  `deliverydt_usedqty` float DEFAULT NULL,
  `DeliveryDt_ClosingQuantity` double DEFAULT '0',
  `DeliveryDt_BatchNo` varchar(40) DEFAULT NULL,
  `srorderdt_id` double DEFAULT NULL,
  `Logged_code` varchar(10) DEFAULT NULL,
  `DeliveryDt_ProductionDate` datetime DEFAULT NULL,
  `DeliveryDt_TipsAccount` varchar(10) DEFAULT NULL,
  `DeliveryDt_VatAccount` varchar(10) DEFAULT NULL,
  `deliverydt_clientdiscount` double DEFAULT NULL,
  `deliverydt_itemdiscount` double DEFAULT NULL,
  `deliverydt_heatno` varchar(100) DEFAULT NULL,
  `deliverydt_quantitybox` double DEFAULT NULL,
  `deliverydt_itemunit` double DEFAULT NULL,
  `deliverydt_itempackage` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`DeliveryDt_id`),
  KEY `deliverydtdelivery_id` (`Delivery_id`),
  KEY `FK_deliverydt_temp_1` (`Delivery_id`),
  CONSTRAINT `FK_deliverydt_temp_1` FOREIGN KEY (`Delivery_id`) REFERENCES `deliveries_temp` (`Delivery_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `sorder_temp`;
CREATE TABLE  `sorder_temp` (
  `Sorder_id` double NOT NULL,
  `Sorder_reference` double DEFAULT NULL,
  `Sorder_date` datetime DEFAULT NULL,
  `Sorder_RequestDate` datetime DEFAULT NULL,
  `Sorder_RequestBy` varchar(50) DEFAULT NULL,
  `Sorder_remark` varchar(100) DEFAULT NULL,
  `Client_code` varchar(10) DEFAULT NULL,
  `Sorder_ClientContact` varchar(100) DEFAULT NULL,
  `Currency_code` varchar(6) DEFAULT NULL,
  `Costcent_code` varchar(15) DEFAULT NULL,
  `Sorder_warranty` varchar(150) DEFAULT NULL,
  `Sorder_document` varchar(150) DEFAULT NULL,
  `Sorder_DeliveryDate` datetime DEFAULT NULL,
  `Sorder_DeliveryPlace` varchar(100) DEFAULT NULL,
  `Sorder_DeliveryContact` varchar(50) DEFAULT NULL,
  `Sorder_DeliveryTelephone` varchar(15) DEFAULT NULL,
  `Sorder_DeliveryFax` varchar(15) DEFAULT NULL,
  `Sorder_PaymentTerm` varchar(150) DEFAULT NULL,
  `Sorder_SalesDepartment` varchar(40) DEFAULT NULL,
  `Sorder_InspectionPlace` varchar(50) DEFAULT NULL,
  `Sorder_InspectionDate` datetime DEFAULT NULL,
  `Sorder_Inspectionby` varchar(50) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Sorder_TotalQuantity` double DEFAULT '0',
  `Sorder_TotalQuantityUsed` double DEFAULT '0',
  `Sorder_quantityequal` tinyint(1) DEFAULT '0',
  `Sorder_Total` double DEFAULT NULL,
  `sorder_paymentmode` double DEFAULT '0',
  `Sorder_MaturityDate` datetime DEFAULT NULL,
  `Sorder_taxable` double DEFAULT '0',
  `Sorder_nonetaxable` double DEFAULT '0',
  `Sorder_vat` double DEFAULT '0',
  `Sorder_discountamount` double DEFAULT '0',
  `Sorder_type` varchar(2) DEFAULT 'SO',
  `Sorder_posted` tinyint(1) DEFAULT '0',
  `Sorder_projectCode` varchar(16) DEFAULT NULL,
  `Sorder_costcenter` varchar(16) DEFAULT NULL,
  `SendReceive_Reference` double DEFAULT NULL,
  `Sorder_BelongsToGrp` int(11) DEFAULT NULL,
  `Sorder_discountper` double DEFAULT '0',
  `Sorder_DiscountBase1` double DEFAULT NULL,
  `Sorder_DiscountBase2` double DEFAULT NULL,
  `Sorder_TaxableBase1` double DEFAULT NULL,
  `Sorder_TaxableBase2` double DEFAULT NULL,
  `Sorder_NoneTaxableBase1` double DEFAULT NULL,
  `Sorder_NoneTaxableBase2` double DEFAULT NULL,
  `Sorder_VatBase1` double DEFAULT NULL,
  `Sorder_VatBase2` double DEFAULT NULL,
  `sorder_Tax1` double DEFAULT '0',
  `sorder_Tax2` double DEFAULT '0',
  `sorder_Tax3` double DEFAULT '0',
  `sorder_Tax4` double DEFAULT '0',
  `sorder_Tax5` double DEFAULT '0',
  `sorder_Tax1Base1` double DEFAULT '0',
  `sorder_Tax2Base1` double DEFAULT '0',
  `sorder_Tax3Base1` double DEFAULT '0',
  `sorder_Tax4Base1` double DEFAULT '0',
  `sorder_Tax5Base1` double DEFAULT '0',
  `sorder_Tax1Base2` double DEFAULT '0',
  `sorder_Tax2Base2` double DEFAULT '0',
  `sorder_Tax3Base2` double DEFAULT '0',
  `sorder_Tax4Base2` double DEFAULT '0',
  `sorder_Tax5Base2` double DEFAULT '0',
  `Sorder_VATChckbx` tinyint(1) DEFAULT '1',
  `Synchronized` tinyint(1) DEFAULT '0',
  `Transfer_ID` double DEFAULT NULL,
  `Sorder_confirmed` tinyint(1) DEFAULT '0',
  `journal_type` varchar(2) DEFAULT 'SO',
  `JOURNAL_ID` double DEFAULT NULL,
  `sorder_CreditCur` varchar(6) DEFAULT NULL,
  `sorder_CreditAccount` varchar(10) DEFAULT NULL,
  `sorder_CreditAccountVat` varchar(10) DEFAULT NULL,
  `Sorder_rate` double DEFAULT '0',
  `Sorder_ratebase1` double DEFAULT '0',
  `Sorder_ratebase2` double DEFAULT '0',
  `Sorder_Title` varchar(25) DEFAULT NULL,
  `SorderFlag` varchar(1) DEFAULT NULL,
  `Adjustment_ID` double DEFAULT NULL,
  `Sorder_Package` varchar(1) DEFAULT NULL,
  `Sorder_SysDate` datetime DEFAULT NULL,
  `Sorder_SysTime` datetime DEFAULT NULL,
  `User_Account` varchar(10) DEFAULT NULL,
  `Sorder_Repetitive` varchar(1) DEFAULT NULL,
  `Sorder_DieCutAmnt` double DEFAULT '0',
  `Sorder_DieCutAmnt1` double DEFAULT '0',
  `Sorder_DieCutAmnt2` double DEFAULT '0',
  `Sorder_ClichetAmnt` double DEFAULT '0',
  `Sorder_ClichetAmnt1` double DEFAULT '0',
  `Sorder_ClichetAmnt2` double DEFAULT '0',
  `Sorder_ArtWorkAmnt` double DEFAULT '0',
  `Sorder_ArtWorkAmnt1` double DEFAULT '0',
  `Sorder_ArtWorkAmnt2` double DEFAULT '0',
  `Sorder_Problematic` varchar(10) DEFAULT NULL,
  `Sorder_TransportAmnt` double DEFAULT '0',
  `Sorder_TransportAmnt1` double DEFAULT '0',
  `Sorder_TransportAmnt2` double DEFAULT '0',
  `Salesman_Code` varchar(10) DEFAULT NULL,
  `Sorder_Hide` tinyint(1) DEFAULT '0',
  `Sorder_disapproved` tinyint(1) DEFAULT '0',
  `sorder_deliverytype` varchar(60) DEFAULT NULL,
  `Detail_Code` varchar(50) DEFAULT NULL,
  `Sorder_Status` tinyint(1) DEFAULT '0',
  `Sorder_ConfirmUser` varchar(45) DEFAULT NULL,
  `BRANCH_CODE` varchar(20) DEFAULT NULL,
  `sorder_produced` int(11) DEFAULT '0',
  `Sorder_vehicalno` varchar(30) DEFAULT NULL,
  `Sorder_drivername` varchar(30) DEFAULT NULL,
  `Sorder_vehicleweight` double DEFAULT NULL,
  `Sorder_Invoiced` tinyint(1) DEFAULT '0',
  `Owner_Branch` varchar(50) DEFAULT NULL,
  `Destination_Branch` varchar(50) DEFAULT NULL,
  `Sorder_Syn_ID` double DEFAULT NULL,
  `Sorder_TransportAccount` varchar(10) DEFAULT NULL,
  `Sorder_TransportAmount` double DEFAULT '0',
  `Sorder_TransportBase1` double DEFAULT '0',
  `Sorder_TransportBase2` double DEFAULT '0',
  `Sorder_TransportTTC` double DEFAULT '0',
  PRIMARY KEY (`Sorder_id`),
  KEY `FK_SORDER_Branch` (`BRANCH_CODE`),
  KEY `SorderSalesman_Code` (`Salesman_Code`),
  KEY `sorderproject_code` (`Project_Code`),
  KEY `sordercostcent_code` (`Costcent_code`),
  KEY `sorderclient_code` (`Client_code`),
  KEY `sordertransfer_id` (`Transfer_ID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE  `sorderdt_temp` (
  `SorderDt_id` double NOT NULL,
  `Sorder_id` double DEFAULT NULL,
  `Sorder_Date` datetime DEFAULT NULL,
  `CLIENT_CODE` varchar(10) DEFAULT NULL,
  `Item_code` varchar(20) DEFAULT NULL,
  `CostCent_Code` varchar(15) DEFAULT NULL,
  `SorderDt_Quantity` double DEFAULT '0',
  `SorderDt_QuantityUsed` double DEFAULT '0',
  `Sorderdt_quantityequal` tinyint(1) DEFAULT '0',
  `Sorderdt_price` double DEFAULT '0',
  `SorderDt_PriceBase1` double DEFAULT NULL,
  `SroderDt_PriceBase2` double DEFAULT NULL,
  `Sorderdt_discount` double DEFAULT '0',
  `SorderDt_Remark` varchar(50) DEFAULT NULL,
  `Warehouse_code` varchar(15) DEFAULT NULL,
  `Project_Code` varchar(15) DEFAULT NULL,
  `Item_CodePacked` varchar(20) DEFAULT NULL,
  `Item_vat` double DEFAULT NULL,
  `CURRENCY_cODE` varchar(6) DEFAULT NULL,
  `ITEM_BARCODE` varchar(25) DEFAULT NULL,
  `SorderDt_PriceTTC` double DEFAULT NULL,
  `Item_QtyPacked` double DEFAULT NULL,
  `Sorderdt_posted` tinyint(1) DEFAULT '0',
  `SorderDt_DiscountAmount` double DEFAULT '0',
  `SorderDt_DiscountBase1` double DEFAULT '0',
  `SorderDt_DiscountBase2` double DEFAULT '0',
  `Item_Tax1` double DEFAULT NULL,
  `Item_Tax2` double DEFAULT NULL,
  `Item_Tax3` double DEFAULT NULL,
  `Item_Tax4` double DEFAULT NULL,
  `Item_Tax5` double DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `SorderDt_ItemAccount` varchar(13) DEFAULT NULL,
  `sorderdt_approximate` varchar(1) DEFAULT NULL,
  `sorderdt_deliveryDate` datetime DEFAULT NULL,
  `SorderDt_CorrQuantity` int(11) DEFAULT NULL,
  `SorderDt_ConvQuantity` int(11) DEFAULT NULL,
  `SorderDt_Grammage` double DEFAULT NULL,
  `Sorderdt_specification` varchar(1) DEFAULT NULL,
  `SorderDt_Base` double DEFAULT NULL,
  `SorderDt_EffectiveBase` double DEFAULT NULL,
  `SorderDt_UCostbase` double DEFAULT NULL,
  `Sorderdt_Flag` varchar(1) DEFAULT NULL,
  `Sorderdt_insQty` int(11) DEFAULT NULL,
  `SorderDt_itemQty` int(11) DEFAULT NULL,
  `SorderDt_itemSeq` int(11) DEFAULT NULL,
  `ProdQuality_Code` varchar(7) DEFAULT NULL,
  `ProdQuality_Description` varchar(20) DEFAULT NULL,
  `[REDACTED]` varchar(100) DEFAULT NULL,
  `SorderDt_ApproximateQty` double DEFAULT NULL,
  `SorderDt_DeliveryWay` varchar(1) DEFAULT NULL,
  `SorderDt_DeliveryLocation` varchar(100) DEFAULT NULL,
  `SorderDt_Document` double DEFAULT NULL,
  `Sorderdt_OldData` tinyint(1) DEFAULT '0',
  `Sorderdt_DirectStkDbt` varchar(10) DEFAULT NULL,
  `Sorderdt_DirectStkCrd` varchar(10) DEFAULT NULL,
  `Sorderdt_DirectStkCur` varchar(10) DEFAULT NULL,
  `sorderdt_GrossModel` varchar(4) DEFAULT NULL,
  `sorderdt_GrossBLen` double DEFAULT '0',
  `sorderdt_GrossBWid` double DEFAULT '0',
  `sorderdt_Outs` double DEFAULT '0',
  `sorderdt_Pces` double DEFAULT '0',
  `sorderdt_SOITSAI` varchar(1) DEFAULT NULL,
  `sorderdt_Unit` varchar(1) DEFAULT NULL,
  `sorderdt_PcesPerItem` int(11) DEFAULT '0',
  `sorderdt_ManType` varchar(1) DEFAULT NULL,
  `sorderdt_PcsModel` varchar(4) DEFAULT NULL,
  `sorderdt_NumOfColor` int(11) DEFAULT '0',
  `sorderdt_Colors` varchar(3) DEFAULT NULL,
  `sorderdt_coverLayer` varchar(1) DEFAULT NULL,
  `sorderdt_SpecialInsQty` varchar(1) DEFAULT NULL,
  `sorderdt_CorrugatorQty` int(11) DEFAULT '0',
  `sorderdt_Fluting` varchar(3) DEFAULT NULL,
  `sorderdt_Length` double DEFAULT '0',
  `sorderdt_Width` double DEFAULT '0',
  `sorderdt_height` double DEFAULT '0',
  `sorderdt_Bonding` varchar(1) DEFAULT NULL,
  `sorderdt_packagePrice` double DEFAULT '0',
  `sorderdt_SalvagePrice` double DEFAULT '0',
  `sorderdt_ExtraPrice` double DEFAULT '0',
  `sorderdt_UCostPrice` double DEFAULT '0',
  `SorderDt_Promotion` tinyint(1) DEFAULT '0',
  `Item_ManufacturedCode` varchar(20) DEFAULT NULL,
  `Item_UnitCoef` double DEFAULT '0',
  `Item_Unit2Qty` double DEFAULT '0',
  `sorderdt_oqty` double NOT NULL DEFAULT '0',
  `sorderdt_cqty` double NOT NULL DEFAULT '0',
  `sorderdt_cqtydate` datetime DEFAULT NULL,
  `sorderdt_cqtyuser` varchar(30) DEFAULT NULL,
  `sorderdt_quantitydelivered` double DEFAULT '0',
  `sorderDt_QtyUnit` double DEFAULT '0',
  `deliveryrelease` tinyint(3) unsigned DEFAULT '0',
  `sorderdt_meancost` double DEFAULT '0',
  `user_account` varchar(50) DEFAULT NULL,
  `SorderDt_Syn_ID` double DEFAULT NULL,
  `Sorder_Syn_ID` double DEFAULT NULL,
  `SorderDt_TransportAmount` double DEFAULT '0',
  `SorderDt_TransportBase1` double DEFAULT '0',
  `SorderDt_TransportBase2` double DEFAULT '0',
  `sorderdt_clientdiscount` double DEFAULT NULL,
  `sorderdt_itemdiscount` double DEFAULT NULL,
  PRIMARY KEY (`SorderDt_id`),
  KEY `sorderdtproject_code` (`Project_Code`),
  KEY `sorderdtcostcent_code` (`CostCent_Code`),
  KEY `sorderdtitem_code` (`Item_code`),
  KEY `sorderdtwarehouse_code` (`Warehouse_code`),
  KEY `sorderdtsorder_id` (`Sorder_id`),
  CONSTRAINT `FK_sorderdt_temp_1` FOREIGN KEY (`Sorder_id`) REFERENCES `sorder_temp` (`Sorder_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


#nadine #23-10-2017
alter table `setup` add column `costcentminimum` tinyint(1) default 0;
alter table `setup` add column `alwaysClearPage` tinyint(1) default 0;

#nadine #24-10-2017
alter table `setup` add column `reconcilation_AmountChecked` tinyint(1) default 0;

CREATE TABLE `default_vessel` (
  `auto_vessel` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `default_value` TINYINT NOT NULL DEFAULT 0,
  `Voyage_year` VARCHAR(2),
  `voyage_number` VARCHAR(45),
  `line_operator` VARCHAR(45),
  `voyage_BOLnumber` VARCHAR(3),
  `voyage_destination` VARCHAR(45),
  `vessel_id` VARCHAR(45),
  `Portofloading` VARCHAR(20),
  `Freight_type` VARCHAR(2),
  `issued` VARCHAR(20),
  `issued_date` DATETIME,
  `Manifest_date` DATETIME,
  `received_date` DATETIME,
  `currency` VARCHAR(6),
  `Agent1_id` VARCHAR(45),
  `Negotiable_BOL` VARCHAR(20),
  `term_of_carriage` VARCHAR(10),
  `linear_meters` DOUBLE DEFAULT 0,
  PRIMARY KEY (`auto_vessel`)
)
ENGINE = InnoDB;


ALTER TABLE `manifest` MODIFY COLUMN `Voyage_year` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_number` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_BOLnumber` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_descripiton` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_type` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_identification` VARCHAR(16) CHARACTER SET utf8 COLLATE utf8_general_ci;

 ALTER TABLE `manifestdt` MODIFY COLUMN `Voyage_year` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_number` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_BOLnumber` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_descripiton` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_type` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_identification` VARCHAR(16) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `detailsequence` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `CTRFlag` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `Container` VARCHAR(11) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `Marks` VARCHAR(12) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `Packages` VARCHAR(12) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `Container_Weight` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `CubeMeters` DECIMAL(7,2),
 MODIFY COLUMN `Agent1` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `year` DECIMAL(4,0),
 MODIFY COLUMN `month` DECIMAL(2,0),
 MODIFY COLUMN `day` DECIMAL(2,0),
 MODIFY COLUMN `hour` DECIMAL(2,0),
 MODIFY COLUMN `minutes` DECIMAL(2,0),
 MODIFY COLUMN `seconds` DECIMAL(2,0);

 
 ALTER TABLE `manifestdesc` MODIFY COLUMN `Voyage_year` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_number` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_BOLnumber` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_descripiton` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_type` VARCHAR(1) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_identification` VARCHAR(16) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `detailsequence` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `descriptiongood` VARCHAR(300) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `Agent1` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `year` DECIMAL(4,0),
 MODIFY COLUMN `month` DECIMAL(2,0),
 MODIFY COLUMN `day` DECIMAL(2,0),
 MODIFY COLUMN `hour` DECIMAL(2,0),
 MODIFY COLUMN `minutes` DECIMAL(2,0),
 MODIFY COLUMN `seconds` DECIMAL(2,0);

 
 ALTER TABLE `containerdt` MODIFY COLUMN `container_BOL` VARCHAR(25) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `Client_code` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci;
 
 ALTER TABLE `containertrace` MODIFY COLUMN `container_no` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci;

 
 ALTER TABLE `manifeststamp` MODIFY COLUMN `Voyage_year` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_number` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_destination` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_type` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `voyage_BOLnumber` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `BOL_pagenumber` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc1` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc2` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc3` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc4` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc5` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc6` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc7` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc8` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc9` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc10` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc11` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc12` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc13` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc14` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc15` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc16` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc17` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc18` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc19` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc20` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc21` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampdesc22` VARCHAR(64) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampcode1` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampcode2` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampcode3` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampcode4` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampcode5` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `stampcode6` VARCHAR(3) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `source_agentcode` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `year` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `month` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `day` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `hour` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `minutes` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci,
 MODIFY COLUMN `seconds` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci;

 
 ALTER TABLE `manifest` MODIFY COLUMN `Offernumber` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 ALTER TABLE `manifest` MODIFY COLUMN `tax1_desc` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `tax2_desc` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `tax3_desc` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `tax4_desc` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `tax5_desc` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `tax6_desc` VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 alter table `accesslabelsrocky`.`login` add column `archiving` tinyint(1) default 0;
 #amin #25-10-2017
 
 CREATE TABLE  `accesslabelsrocky`.`mobile` (
  `MOBILE_BUILDNUMBER` varchar(40) NOT NULL,
  `MOBILE_NAME` varchar(45) DEFAULT NULL,
  `MOBILE_ACTIVE` int(11) DEFAULT NULL,
  `MOBILE_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`MOBILE_ID`),
  UNIQUE KEY `Index_mbuild` (`MOBILE_BUILDNUMBER`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=130 DEFAULT CHARSET=utf8;


CREATE TABLE  `receipt_temp` (
  `Receipt_ID` int(11) NOT NULL DEFAULT '0',
  `receipt_date` date DEFAULT NULL,
  `Ledger_number` varchar(10) DEFAULT NULL,
  `CostCent_CODE` varchar(15) DEFAULT NULL,
  `User_ID` varchar(10) DEFAULT NULL,
  `Receipt_CashBase1` double DEFAULT '0',
  `Receipt_CashBase2` double DEFAULT '0',
  `Receipt_NUMBER` varchar(20) DEFAULT NULL,
  `Receipt_BANK` varchar(30) DEFAULT NULL,
  `Receipt_BRANCH` varchar(30) DEFAULT NULL,
  `Receipt_VALUE_DATE` varchar(15) DEFAULT NULL,
  `Receipt_MANUAL_NUMBER` varchar(30) DEFAULT NULL,
  `Receipt_CURRENCY` varchar(5) DEFAULT NULL,
  `Receipt_CHECK_VALUE_Base1` double DEFAULT '0',
  `Receipt_CHECK_VALUE_Base2` double DEFAULT '0',
  `Synchronized` tinyint(1) DEFAULT '0',
  PRIMARY KEY (`Receipt_ID`),
  KEY `Index_2` (`Ledger_number`),
  KEY `Index_3` (`CostCent_CODE`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


#nadine #26-10-2017

CREATE TABLE `CRFT_Header` (
  `crft_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `cr_type` VARCHAR(3) NOT NULL,
  `reference` DOUBLE NOT NULL,
  `BL_number` VARCHAR(16) NOT NULL,
  `voy_number` VARCHAR(45) NOT NULL,
  `voy_year` varchar(2) NOT NULL,
  `extra_info` TEXT,
  PRIMARY KEY (`auto`)
)
ENGINE = InnoDB;

alter table `CRFT_Header` add column `manifest_auto` integer not null;
alter table `CRFT_Header` add column `crft_date` datetime;
alter table `CRFT_Header` add column `delivery_id` integer;
alter table `sequence` add column `crf_reference` double,  add column `crt_reference` double;

CREATE TABLE `demarage_values` (
  `dem_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `dem_value` DOUBLE NOT NULL,
  PRIMARY KEY (`dem_id`)
)
ENGINE = InnoDB;

alter table `containertrace` add column `crf_date` datetime, add column `crt_date` datetime;

alter table `deliverydt` add column `deliverydt_netweight` double;
alter table `temp_deliverydt` add column `deliverydt_netweight` double;

alter table `accesslabelsrocky`.`login` add column `manifest` tinyint(1) default 0;
alter table `accesslabelsrocky`.`login` add column `archiving` tinyint(1) default 0;

#nadine #30-10-2017

alter table `FinancialTemplate` add column `project_code` varchar(20), add column `costcent_code` varchar(20);
alter table `suppliers` add column `paymentcondition` text;

#nadine #01-11-2017
alter table `FinancialTemplate` add column `dbcd` varchar(1);

CREATE TABLE `bidhistory` (
  `bidhistory_id` INTEGER NOT NULL AUTO_INCREMENT,
  `auction_id` INTEGER NOT NULL,
  `supplier_code` VARCHAR(10) NOT NULL,
  `systemdate` DATETIME NOT NULL,
  `bid_price` DOUBLE,
  `bid_rank` INTEGER,
  `bid_qty` DOUBLE,
  PRIMARY KEY (`bidhistory_id`)
)
ENGINE = InnoDB;

#nadine #06-11-2017
alter table `productionFactory` add column `item_group` varchar(15);
alter table `temp_productionFactory` add column `item_group` varchar(15);

alter table `productionFactory` add column `item_subgroup` varchar(15);
alter table `temp_productionFactory` add column `item_subgroup` varchar(15);

alter table `productionFactory` add column `item_category` varchar(15);
alter table `temp_productionFactory` add column `item_category` varchar(15);

#nadine #09-11-2017
alter table `agent` add column `chk_local` tinyint(1) default 0;
alter table `manifest` add column `localagent_code` varchar(3);
alter table `manifest` add column `declaredbyforwarder` tinyint(1) default 0;
alter table `manifestdt` add column `bctc_remark` varchar(100);
alter table `manifestdtl` add column `currencycode` varchar(6);

#nabil aoun 2017-11-13
alter table category modify Category_name varchar(30);
alter table category add Category_namearabic varchar(30);
ALTER TABLE accesslabelsrocky.loginstk ADD CATEGORY_CODE VARCHAR(15);

#amin #2017-11-13

ALTER TABLE `cashtype` ADD COLUMN `bank_id` BIGINT(20),
 ADD COLUMN `currency_code` VARCHAR(50);
 
 ALTER TABLE `banks` ADD COLUMN `Currency` tinyint(1) DEFAULT NULL,
 ADD COLUMN `CurrencyX` varchar(25) DEFAULT NULL,
 ADD COLUMN `AmountX` varchar(25) DEFAULT NULL,
ADD COLUMN  `AmountY` varchar(25) DEFAULT NULL,
 ADD COLUMN `OrderOfX` varchar(25) DEFAULT NULL,
 ADD COLUMN `OrderOfY` varchar(25) DEFAULT NULL,
ADD COLUMN  `SumOfX` varchar(25) DEFAULT NULL,
ADD COLUMN  `SumOfY` varchar(25) DEFAULT NULL,
ADD COLUMN  `DateX` varchar(25) DEFAULT NULL,
ADD COLUMN  `DateY` varchar(25) DEFAULT NULL,
ADD COLUMN  `PlaceX` varchar(25) DEFAULT NULL,
ADD COLUMN  `PlaceY` varchar(25) DEFAULT NULL,
ADD COLUMN  `DivWidth` varchar(25) DEFAULT NULL,
ADD COLUMN  `DivHeight` varchar(25) DEFAULT NULL,
ADD COLUMN  `Place` varchar(25) DEFAULT NULL,
ADD COLUMN  `CurrencyY` varchar(25) DEFAULT NULL;

ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FA_PrePayment` TINYINT(1);

#nadine #20-11-2017
alter table `sequence` add column `CloseVAT_TypeRef` integer;
alter table `sorder` add column `assignto_user` varchar(45);
alter table `temp_sorder` add column `assignto_user` varchar(45);
alter table `accesslabelsrocky`.`login` add column `SO_AssignUsers` TINYINT(1) DEFAULT 0;


alter table `deliveries` add column `delivery_HScode` varchar(50);
alter table `temp_deliveries` add column `delivery_HScode` varchar(50);

#amin #23-11-2017
ALTER TABLE `accesslabelsrocky`.`login` ADD COLUMN `FA_JournalPrintingAsk` TINYINT(1) DEFAULT 1;

#nadine #28-11-2017
alter table `project` add column `project_blocked` TINYINT(1) default 0;

#nadine #05-12-2017
alter table `vehicle` add column `project_code` varchar(20);
alter table `vehicle` add column `ledger_number` varchar(20);
alter table `vehicle` add column `asset_id` integer;
alter table `accesslabelsrocky`.`login` add column `ShowBankInfo` tinyint(1) default 0;
alter table `accesslabelsrocky`.`login` add column `ShowInsuranceInfo` tinyint(1) default 0;
alter table `accesslabelsrocky`.`login` add column `ShowSalaryInfo` tinyint(1) default 0;

ALTER TABLE `staff_salary` MODIFY COLUMN `EmployeeID` VARCHAR(15) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
 MODIFY COLUMN `Description` VARCHAR(256) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
 
 #amin #05-12-2017
 
 ALTER TABLE `rmadt` ADD INDEX `datereceived`(`rmadt_DateReceived`),
 ADD INDEX `datedelivered`(`rmadt_DateDelivered`);

 ALTER TABLE `rma` ADD INDEX `rmatype`(`rma_type`),
 ADD INDEX `engineername`(`Rma_EngineerName`);
 
 ALTER TABLE `problemcategory` ADD INDEX `usercode`(`user_code`);
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_receivedby` VARCHAR(50);
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_receivedby` VARCHAR(50);
 
#nadine #08-12-2017

CREATE TABLE  `userrequest` (
  `iduserrequest` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_account` varchar(100) DEFAULT NULL,
  `user_related` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`iduserrequest`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

#amin #08-12-2017

ALTER TABLE `rmadt` ADD COLUMN `rmadt_techcheckupdate` TINYINT(1) DEFAULT 0,
 ADD COLUMN `rmadt_techcheckupdatedate` DATETIME,
 ADD COLUMN `rmadt_techquotation` VARCHAR(250),
 ADD COLUMN `ramdt_techquotationdate` DATETIME,
 ADD COLUMN `rmadt_approved` TINYINT(1);
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_techcheckupdate` TINYINT(1) DEFAULT 0,
 ADD COLUMN `rmadt_techcheckupdatedate` DATETIME,
 ADD COLUMN `rmadt_techquotation` VARCHAR(250),
 ADD COLUMN `ramdt_techquotationdate` DATETIME,
 ADD COLUMN `rmadt_approved` TINYINT(1);
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_approveddate` DATETIME;
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_repStartDateTime` DATETIME,
 ADD COLUMN `rmadt_repEndDateTime` DATETIME;
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_operatorSpareParts` VARCHAR(200);
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_techcheckupdate` TINYINT(1) DEFAULT 0,
 ADD COLUMN `rmadt_techcheckupdatedate` DATETIME,
 ADD COLUMN `rmadt_techquotation` VARCHAR(250),
 ADD COLUMN `ramdt_techquotationdate` DATETIME,
 ADD COLUMN `rmadt_approved` TINYINT(1);
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_approveddate` DATETIME;
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_repStartDateTime` DATETIME,
 ADD COLUMN `rmadt_repEndDateTime` DATETIME;
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_operatorSpareParts` VARCHAR(200);

 #amin #12-12-2017
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_qcremark` VARCHAR(200),
 ADD COLUMN `rmadt_qcduration` VARCHAR(50);
 
  ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_qcremark` VARCHAR(200),
 ADD COLUMN `rmadt_qcduration` VARCHAR(50);
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_qcapproved` TINYINT(1),
 ADD COLUMN `rmadt_qcapproveddate` DATETIME;
 
  ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_qcapproved` TINYINT(1),
 ADD COLUMN `rmadt_qcapproveddate` DATETIME;
 
 ALTER TABLE `problemcategory` ADD COLUMN `user_email` VARCHAR(100);
 
 #nadine #13-12-2017
 alter table `cashregister` add column `cashregister_service` tinyint(1) default 0, add column `cashregister_servicePercentage` double, add column `service_account` varchar(20);
 alter table `retail` add column `sale_service` double, add column `sale_serviceB1` double, add column `sale_serviceB2` double;
 alter table `temp_retail` add column `sale_service` double, add column `sale_serviceB1` double, add column `sale_serviceB2` double;

 
 #amin #13-12-2017
 
 CREATE TABLE `invoicing` (
  `Invoicing_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Invoicing_Reference` BIGINT(20),
  `Invoicing_Date` DATETIME,
  `Client_Code` VARCHAR(10),
  `Currency_Code` VARCHAR(6),
  `Invoicing_Amount` DOUBLE,
  `Invoicing_AmountBase1` DOUBLE,
  `Invoicing_AmountBase2` DOUBLE,
  `User_Code` VARCHAR(50),
  PRIMARY KEY (`Invoicing_Id`)
)
ENGINE = InnoDB;

 CREATE TABLE `temp_invoicing` (
  `Invoicing_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Invoicing_Reference` BIGINT(20),
  `Invoicing_Date` DATETIME,
  `Client_Code` VARCHAR(10),
  `Currency_Code` VARCHAR(6),
  `Invoicing_Amount` DOUBLE,
  `Invoicing_AmountBase1` DOUBLE,
  `Invoicing_AmountBase2` DOUBLE,
  `User_Code` VARCHAR(50),
  PRIMARY KEY (`Invoicing_Id`)
)
ENGINE = InnoDB;

CREATE TABLE `invoicingdt` (
  `InvoicingDt_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Invoicing_Id` BIGINT(20) UNSIGNED NOT NULL,
  `InvoicingDt_DueDate` DATETIME,
  `InvoicingDt_Amount` DOUBLE,
  `InvoicingDt_AmountBase1` DOUBLE,
  `InvoicingDt_AmountBase2` DOUBLE,
  PRIMARY KEY (`InvoicingDt_Id`)
)
ENGINE = InnoDB;

CREATE TABLE `temp_invoicingdt` (
  `InvoicingDt_Id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `Invoicing_Id` BIGINT(20) UNSIGNED NOT NULL,
  `InvoicingDt_DueDate` DATETIME,
  `InvoicingDt_Amount` DOUBLE,
  `InvoicingDt_AmountBase1` DOUBLE,
  `InvoicingDt_AmountBase2` DOUBLE,
  PRIMARY KEY (`InvoicingDt_Id`)
)
ENGINE = InnoDB;

CREATE TABLE `headerinvoicing` (
  `headerinvoicing_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `headerinvoicing_date` DATETIME,
  PRIMARY KEY (`headerinvoicing_id`)
)
ENGINE = InnoDB;

CREATE TABLE `temp_headerinvoicing` (
  `headerinvoicing_id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
  `headerinvoicing_date` DATETIME,
  PRIMARY KEY (`headerinvoicing_id`)
)
ENGINE = InnoDB;

ALTER TABLE `invoicing` ADD COLUMN `headerinvoicing_id` BIGINT(20) UNSIGNED;

ALTER TABLE `temp_invoicing` ADD COLUMN `headerinvoicing_id` BIGINT(20) UNSIGNED;

ALTER TABLE `invoicing` ADD COLUMN `Invoicing_ValueDate` DATETIME;

ALTER TABLE `temp_invoicing` ADD COLUMN `Invoicing_ValueDate` DATETIME;

ALTER TABLE `clients` ADD COLUMN `Client_EndofMonthPay` TINYINT(1);

ALTER TABLE `clients` MODIFY COLUMN `Client_EndofMonthPay` TINYINT(1) DEFAULT 0;


#nadine #18-12-2017
CREATE TABLE `archivingofferdt` (
  `offerdt_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `offer_id` INTEGER NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `description` VARCHAR(256),
  `amount` DOUBLE,
  `qty` DOUBLE,
  `discount` DOUBLE,
  `currency_code` VARCHAR(3),
  PRIMARY KEY (`offerdt_id`)
)
ENGINE = InnoDB;

alter table `archivingoffer` add column `client_code` varchar(20);
alter table `Vessel` add column `vessel_flag` varchar(30);

#amin #18-12-2017

ALTER TABLE `invoicingdt` ADD CONSTRAINT `FK_invoicingdt_1` FOREIGN KEY `FK_invoicingdt_1` (`Invoicing_Id`)
    REFERENCES `invoicing` (`Invoicing_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
	
ALTER TABLE `temp_invoicingdt` ADD CONSTRAINT `FK_tempinvoicingdt_1` FOREIGN KEY `FK_invoicingdt_1` (`Invoicing_Id`)
    REFERENCES `temp_invoicing` (`Invoicing_Id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
	
ALTER TABLE `invoicing` ADD COLUMN `Journal_Id` BIGINT(20);

ALTER TABLE `temp_invoicing` ADD COLUMN `Journal_Id` BIGINT(20);

ALTER TABLE `invoicing` ADD CONSTRAINT `FK_invoicing_1` FOREIGN KEY `FK_invoicing_1` (`headerinvoicing_id`)
    REFERENCES `headerinvoicing` (`headerinvoicing_id`)
    ON DELETE CASCADE
    ON UPDATE CASCADE;
	

#nadine #26-12-2017

alter table `accesslabelsrocky`.`login` add column `FI_QtyBudget` tinyint(1) default 0;
alter table `transsetup` add column `showJournalRate` tinyint(1) default 0;

CREATE TABLE `qty_budget` (
  `budget_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `sdate` DATETIME NOT NULL,
  `edate` DATETIME NOT NULL,
  `item_code` VARCHAR(20) NOT NULL,
  `budget_desc` VARCHAR(256),
  `project_code` VARCHAR(20),
  `costcent_code` VARCHAR(20),
  `qty_month1` DOUBLE,
  `qty_month2` DOUBLE,
  `qty_month3` DOUBLE,
  `qty_month4` DOUBLE,
  `qty_month5` DOUBLE,
  `qty_month6` DOUBLE,
  `qty_month7` DOUBLE,
  `qty_month8` DOUBLE,
  `qty_month9` DOUBLE,
  `qty_month10` DOUBLE,
  `qty_month11` DOUBLE,
  `qty_month12` DOUBLE,
  PRIMARY KEY (`budget_id`)
) 
ENGINE = InnoDB;

#amin #27-12-2017

ALTER TABLE `rmadt` ADD COLUMN `rmadt_operatoraditionalcomments` VARCHAR(250);

ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_operatoraditionalcomments` VARCHAR(250);

ALTER TABLE `rmadt` ADD COLUMN `rmadt_qcStartDateTime` DATETIME,
 ADD COLUMN `rmadt_qcEndDateTime` DATETIME;
 
ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_qcStartDateTime` DATETIME,
 ADD COLUMN `rmadt_qcEndDateTime` DATETIME;
 
#amin #28-12-2017

ALTER TABLE `rmadt` ADD COLUMN `rmadt_repStartDateTime2` DATETIME,
 ADD COLUMN `rmadt_repEndDateTime2` DATETIME;
 
ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_repStartDateTime2` DATETIME,
 ADD COLUMN `rmadt_repEndDateTime2` DATETIME;
 
ALTER TABLE `rmadt` ADD COLUMN `rmadt_qcStartDateTime2` DATETIME;

ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_qcStartDateTime2` DATETIME;

ALTER TABLE `rmadt` ADD COLUMN `rmadt_qcEndDateTime2` DATETIME;

ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_qcEndDateTime2` DATETIME;

ALTER TABLE `rmadt` ADD COLUMN `rmadt_qcduration2` VARCHAR(50);

ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_qcduration2` VARCHAR(50);

#amin #02-01-2018

ALTER TABLE `rmadt` ADD COLUMN `rmadt_techquotation2` VARCHAR(250);

ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_techquotation2` VARCHAR(250);

#nadine #03-01-2018
alter table `CashRegister` add column `cashregister_TaxConsumption` tinyint(1) default 0, add column `cashregister_TaxConsumptionpPer` double,
add column `TaxConsumption_Account` varchar(20);

alter table `retail` add column `sale_TaxConsumption` double, add column `sale_TaxConsumptionB1` double,
add column `sale_TaxConsumptionB2` double;

alter table `temp_retail` add column `sale_TaxConsumption` double, add column `sale_TaxConsumptionB1` double,
add column `sale_TaxConsumptionB2` double;

ALTER TABLE `budget` MODIFY COLUMN `Budget_ID` INT(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `budget` DROP INDEX `FK_budget_Status`,
 DROP FOREIGN KEY `FK_budget_Status`;
 
 #amin #04-01-2018
 
 ALTER TABLE `rmadt` ADD COLUMN `rmadt_techquotationdate2` DATETIME;
 
 ALTER TABLE `temp_rmadt` ADD COLUMN `rmadt_techquotationdate2` DATETIME;
 
 #nadine #04-01-2018
 alter table `accesslabelsrocky`.`login` add column `RI_Transfer` tinyint(1) default 0;
 
 #nadine #10-01-2018
 CREATE TABLE `Manifest_FeetAmount` (
  `feetAmount_id` INTEGER NOT NULL AUTO_INCREMENT,
  `location` VARCHAR(50),
  `bl_type` VARCHAR(2),
  `container_type` VARCHAR(4),
  `op_line` VARCHAR(50),
  `amount` DOUBLE,
  `currency_code` VARCHAR(5),
  `commission` DOUBLE,
  `bl_freight` VARCHAR(45),
  `fees1` DOUBLE,
  `fees2` DOUBLE,
  `fees3` DOUBLE,
  PRIMARY KEY (`feetAmount_id`)
)
ENGINE = InnoDB;

CREATE TABLE `Manifest_Deposit` (
  `deposit_id` INTEGER NOT NULL AUTO_INCREMENT,
  `voy_year` VARCHAR(2) NOT NULL,
  `client_code` VARCHAR(20) NOT NULL,
  `dep_amount` DOUBLE,
  `currency_code` VARCHAR(4),
  `dep_type` VARCHAR(1),
  `cntr_type` VARCHAR(20),
  PRIMARY KEY (`deposit_id`)
)
ENGINE = InnoDB;

#nadine #17-01-2018
alter table `productionhd` add column `productionhd_confirm` tinyint(1) default 0;
alter table `temp_productionhd` add column `productionhd_confirm` tinyint(1) default 0;
alter table `productionhd` add column `confirm_user` varchar(20);
alter table `temp_productionhd` add column `confirm_user` varchar(20);

alter table `item_auction` add column `timeExtended` tinyint(1) default 0;
alter table `temp_item_auction` add column `timeExtended` tinyint(1) default 0;

#nadine #23-01-2018
alter table `retail` add column `guest_name` varchar(150);
alter table `temp_retail` add column `guest_name` varchar(150);
alter table `temp_porder` add column `Manual_No` Varchar(50);
alter table `porder` add column `Manual_No` Varchar(50);
alter table `temp_purchases` add column `Manual_No` Varchar(50);
alter table `purchases` add column `Manual_No` Varchar(50);

alter table `porder` add column `date_received` datetime;
alter table `temp_porder` add column `date_received` datetime;
alter table `grnpurchases` add column `date_received` datetime;
alter table `temp_grnpurchases` add column `date_received` datetime;
alter table `module` add column `Module_GRNwithPorder` tinyint(1) default 0;

#amin #24-01-2018

ALTER TABLE `sequence` ADD COLUMN `Invoicing_Id` BIGINT(20),
 ADD COLUMN `HeaderInvoicing_Id` BIGINT(20);
 
 ALTER TABLE `sequence` ADD COLUMN `InvoicingDt_Id` BIGINT(20) DEFAULT 0;
 
 ALTER TABLE `invoicing` MODIFY COLUMN `Invoicing_Id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 315;
 ALTER TABLE `temp_invoicing` MODIFY COLUMN `Invoicing_Id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 315;
 
 ALTER TABLE `invoicingdt` MODIFY COLUMN `InvoicingDt_Id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 563;
  ALTER TABLE `temp_invoicingdt` MODIFY COLUMN `InvoicingDt_Id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 563;
  
  ALTER TABLE `headerinvoicing` MODIFY COLUMN `headerinvoicing_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 55;
  ALTER TABLE `temp_headerinvoicing` MODIFY COLUMN `headerinvoicing_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 55;
  
 #nadine #25-01-2018
alter table `archivingoffer` add column `freetimedetention` decimal(3,0); 
alter table `manifestdt` add column `detailtype` integer, add column `container_type` varchar(20);
alter table `deliveries` add column `manifest_auto` integer;
alter table `temp_deliveries` add column `manifest_auto` integer;
alter table `accesslabelsrocky`.`login` add column `login_upload` tinyint(1) default 0;
#nadine #30-01-2018

CREATE TABLE `warehouseProject` (
  `wp_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `project_code` VARCHAR(30) NOT NULL,
  `warehouse_code` VARCHAR(30) NOT NULL,
  PRIMARY KEY (`wp_id`)
)
ENGINE = InnoDB;

#nadine #02-02-2018
alter table `vehicle` add column `engineNbr` varchar(30), add column `chassisNbr` varchar(30);
ALTER TABLE `deliveries` MODIFY COLUMN `Delivery_Marks` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_deliveries` MODIFY COLUMN `Delivery_Marks` VARCHAR(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `deliveries` MODIFY COLUMN `Delivery_ShippedVia` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
ALTER TABLE `temp_deliveries` MODIFY COLUMN `Delivery_ShippedVia` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL;
alter table `manifest` add column `manifest_emptyContainer` tinyint(1) default 0;

#nadine #12-02-2018
ALTER TABLE `budget` ADD COLUMN `currency` varchar(15);
ALTER TABLE `budget` ADD COLUMN `amount` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `base1` DOUBLE;
ALTER TABLE `budget` ADD COLUMN `base2` DOUBLE;

#nadine #15-02-2018
CREATE TABLE `temp_reconcile` (
  `reconcile_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `fromdate` DATETIME NOT NULL,
  `todate` DATETIME NOT NULL,
  `ledger_number` VARCHAR(10),
  `ledger_number2` varchar(10),
  `amountToCheck` DOUBLE,
  `currencycode` VARCHAR(5) NOT NULL,
  PRIMARY KEY (`reconcile_id`)
)
ENGINE = InnoDB;

CREATE TABLE  `temp_reconciledt` (
  `reconciledt_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `reconcile_id` int(10) unsigned NOT NULL,
  `Ledger_number` varchar(10) DEFAULT NULL,
  `Journaldt_desc` varchar(240) DEFAULT NULL,
  `Journaldt_desc1` varchar(240) DEFAULT NULL,
  `Currency_code` varchar(6) DEFAULT NULL,
  `Journaldt_dbcd` varchar(1) DEFAULT NULL,
  `Journaldt_dbcdAra` varchar(1) DEFAULT NULL,
  `Journaldt_amount` double DEFAULT '0',
  `Journaldt_amount1` double DEFAULT NULL,
  `[REDACTED]` double DEFAULT NULL,
  `Journaldt_ccenter` tinyint(1) DEFAULT '0',
  `Journal_date` datetime DEFAULT NULL,
  `Journaldt_ValueDate` datetime DEFAULT NULL,
  `Document` varchar(30) DEFAULT NULL,
  `BankTrans_Serial` varchar(20) DEFAULT NULL,
  `Journaldt_posted` tinyint(1) DEFAULT '0',
  `Journaldt_reconciled` tinyint(1) DEFAULT '0',
  `Journaldt_reconciledref` varchar(20) DEFAULT NULL,
  `Journal_BelongsToGroup` int(11) DEFAULT NULL,
  `Synchronized` tinyint(1) DEFAULT '0',
  `Journaldt_JVMode` varchar(20) DEFAULT NULL,
  `Journal_JVRef` double DEFAULT '0',
  `Reconciliation_date` datetime DEFAULT NULL,
  `JournalDt_IsVat` tinyint(1) DEFAULT '0',
  `Reconciliation_Sysdate` datetime DEFAULT NULL,
  `Manual_no` varchar(45) DEFAULT NULL,
  `Detail_Code` varchar(50) DEFAULT NULL,
  `user_account` varchar(50) DEFAULT NULL,
  `JournalDt_OldData` tinyint(1) DEFAULT '0',
  `journaldt_rate2` double DEFAULT NULL,
  `journaldt_rate` double DEFAULT NULL,
  `journaldt_id` double not null,
  PRIMARY KEY (`reconciledt_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

#amin #15-02-2018

ALTER TABLE `setup` ADD COLUMN `setup_invoiceremarks` VARCHAR(200);
 
#nadine #23-02-2018
CREATE TABLE `accesslabelsrocky`.`HOD_Users` (
  `hod_id` INTEGER NOT NULL AUTO_INCREMENT,
  `hod_code` VARCHAR(10) NOT NULL,
  `user_code` VARCHAR(10) NOT NULL,
  PRIMARY KEY (`hod_id`)
)
ENGINE = InnoDB;

#nadine #26-02-2018
CREATE TABLE `Payment_Mode` (
  `paymentmode_code` CHAR(20) NOT NULL,
  `paymentmode_desc` VARCHAR(120) NOT NULL,
  PRIMARY KEY (`paymentmode_code`)
)
ENGINE = InnoDB;

CREATE TABLE `Source_Funds` (
  `sourceFund_Code` VARCHAR(20) NOT NULL,
  `sourceFund_desc` VARCHAR(120),
  PRIMARY KEY (`sourceFund_Code`)
)
ENGINE = InnoDB;

alter table `accesslabelsrocky`.`login` add column `FA_SourceFunds` tinyint(1) default 0;

CREATE TABLE `Source_Fundsdt` (
  `funddt_id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  `sourceFund_Code` VARCHAR(20) NOT NULL,
  `user_code` VARCHAR(10) NOT NULL,
  PRIMARY KEY (`funddt_id`)
)
ENGINE = InnoDB;

alter table `paymentsetup` add column `toBeApprovedByHOD` tinyint(1) default 0;

alter table `PaymentRqst` add column `sourceFund_Code` varchar(20), add column `paymentmode_code` varchar(20);
alter table `temp_PaymentRqst` add column `sourceFund_Code` varchar(20), add column `paymentmode_code` varchar(20);

#amin #26-02-2018

ALTER TABLE `accesslabelsrocky`.`users` ADD COLUMN `user_engineerqc` TINYINT(1);

#nadine #02-03-2018
alter table `module` add column `module_chargesInTransfer` tinyint default 0;

alter table `transfer` add column `amountBase1` double, add column `amountBase2` double,
add column curencycode varchar(6), add column `chargesAccountDb` varchar(10), add column `chargesAccountCd` varchar(10);
alter table `temp_transfer` add column `amountBase1` double, add column `amountBase2` double,
add column curencycode varchar(6), add column `chargesAccountDb` varchar(10), add column `chargesAccountCd` varchar(10);


alter table `accesslabelsrocky`.login add column Trans_ModAfterPost  boolean default 0;
ALTER TABLE `accesslabelsrocky`.`login`  Add Column `FI_ItemsLocation` BOOLEAN default 0;
alter table `accesslabelsrocky`.`ListUserDir` add column `FI_ProductDescription` tinyint(1) default 0;
alter table `accesslabelsrocky`.`listUserDir` add column `RI_YearlyPurchases` tinyint(1) default 0;
alter table `accesslabelsrocky`.`listUserDir` add column `RI_YearlyPurchasesOrder` tinyint(1) default 0;
alter table `accesslabelsrocky`.`listUserDir` add column `FI_itemBOQ` tinyint(1) default 0;
alter table module add Module_Checks tinyint(1) default 1;
select * from journal order by journal_date;