CREATE DATABASE  IF NOT EXISTS `ygopticals` /*!40100 DEFAULT CHARACTER SET latin1 */;
USE `ygopticals`;
--
-- Host: localhost    Database: ygopticals
-- ------------------------------------------------------


--
-- Table structure for table `tbl_barcode_details`
--

CREATE TABLE `tbl_barcode_details` (
  `a_brcd_id` int(11) NOT NULL AUTO_INCREMENT,
  `Category_Id` int(11) DEFAULT NULL,
  `itemId` int(11) DEFAULT NULL,
  `depoId` int(11) DEFAULT NULL,
  `depoGRNId` int(11) DEFAULT NULL,
  `issuedToBranch` tinyint(4) DEFAULT NULL,
  `branchId` int(11) DEFAULT NULL,
  `branchGRNId` int(11) DEFAULT NULL,
  `barcodeVal` varchar(45) DEFAULT NULL,
  `itemSold` int(11) DEFAULT NULL,
  `isAcceptedByBranch` tinyint(4) DEFAULT '0',
  `isRemovedByStockCorrection` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`a_brcd_id`),
  KEY `idx_pk_barcode_1` (`barcodeVal`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_barcode_details`
--


--
-- Table structure for table `tbl_branchtransfer_details`
--

CREATE TABLE `tbl_branchtransfer_details` (
  `abrnchtanid` int(11) NOT NULL AUTO_INCREMENT,
  `po_raised_id` int(11) DEFAULT NULL,
  `reqRaisedDate` date DEFAULT NULL,
  `totalQty` int(11) DEFAULT NULL,
  `totalItems` int(11) DEFAULT NULL,
  `fromBranchId` int(11) DEFAULT '0',
  `fromBranchName` varchar(250) DEFAULT NULL,
  `toBranchId` int(11) DEFAULT '0',
  `toBranchName` varchar(250) DEFAULT NULL,
  `reqRaisedUserId` int(11) DEFAULT NULL,
  `reqRaisedUserName` varchar(150) DEFAULT NULL,
  `fromBranchComment` text,
  `expctDeliveryDate` date DEFAULT NULL,
  `toBranchComment` text,
  `actualDeliveryDate` date DEFAULT NULL,
  `depoComment` text,
  `brnchTrans_statu_id` tinyint(4) DEFAULT '0',
  `brnchTrans_statu_text` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`abrnchtanid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_branchtransfer_details`
--


--
-- Table structure for table `tbl_company_depot_details`
--

CREATE TABLE `tbl_company_depot_details` (
  `adepotId` int(11) NOT NULL AUTO_INCREMENT,
  `depotName` varchar(1000) DEFAULT NULL,
  `depotOwnerName` varchar(250) DEFAULT NULL,
  `depotAddress` varchar(1000) DEFAULT NULL,
  `depotCity` varchar(100) DEFAULT NULL,
  `depotState` varchar(100) DEFAULT NULL,
  `depotCountry` varchar(100) DEFAULT NULL,
  `dPincode` varchar(50) DEFAULT NULL,
  `depotPhNo` varchar(250) DEFAULT NULL,
  `depotEmergencyNo` varchar(250) DEFAULT NULL,
  `depotActive` int(11) DEFAULT NULL,
  `nComId` int(11) DEFAULT NULL,
  `dEmailId` varchar(250) DEFAULT NULL,
  `depotcode` varchar(250) DEFAULT NULL,
  `regNo` varchar(45) DEFAULT NULL,
  `PANNo` varchar(45) DEFAULT NULL,
  `distCode` varchar(45) DEFAULT NULL,
  `depotDistrict` varchar(50) DEFAULT NULL,
  `dGSTINno` varchar(45) DEFAULT NULL,
  `st_number` varchar(50) DEFAULT NULL,
  `cin_number` varchar(50) DEFAULT NULL,
  `rohini_id` varchar(50) DEFAULT NULL,
  `depot_DeliveryAddress` text,
  `depot_BillingAddress` text,
  `depot_LocationId` int(11) DEFAULT NULL,
  `po_raise_format` varchar(45) DEFAULT NULL,
  `grnShortCode` varchar(10) DEFAULT NULL,
  `faxNumber` varchar(45) DEFAULT NULL,
  `contact_Num` varchar(15) DEFAULT NULL,
  `contact_Person` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`adepotId`),
  KEY `depot_LocationId_idx` (`depot_LocationId`),
  KEY `nComId_idx` (`nComId`),
  CONSTRAINT `depot_LocationId` FOREIGN KEY (`depot_LocationId`) REFERENCES `tbl_mst_locations` (`aLocationId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_company_depot_details_1` FOREIGN KEY (`nComId`) REFERENCES `tbl_company_details` (`aComId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_company_depot_details`
--

INSERT INTO `tbl_company_depot_details` VALUES (1,'YaraGo Depo','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','400057','022-2615005','9731420162',1,1,'yarago@gmail.com','1000','U74999MH2017PTC300119','AAEXI6389M','1','1','27AAECI6389M1ZT','1','1','1','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1000','1000',NULL,NULL,NULL),(2,'YaraGo','YaraGo Software','Yarago Software Pvt Ltd','1','1','1','560037','123456','1234567890',1,1,'yaragos.com','2000','123','PAN123','2','1','GSTIN12345','1','1','1','Yarago software pvt ltd oxford house bangalore','Yarago software pvt ltd oxford house bangalore',1,'2000','2000',NULL,NULL,NULL);

--
-- Table structure for table `tbl_company_details`
--

CREATE TABLE `tbl_company_details` (
  `aComId` int(11) NOT NULL AUTO_INCREMENT,
  `CompanyName` varchar(500) DEFAULT NULL,
  `CompanyOwnerName` varchar(250) DEFAULT NULL,
  `CompanyAddress` varchar(1000) DEFAULT NULL,
  `CompanyCity` varchar(100) DEFAULT NULL,
  `CompanyState` varchar(100) DEFAULT NULL,
  `CompanyCountry` varchar(100) DEFAULT NULL,
  `Pincode` varchar(50) DEFAULT NULL,
  `CompanyPhNo` varchar(250) DEFAULT NULL,
  `CompanyEmergencyNo` varchar(250) DEFAULT NULL,
  `active` int(11) DEFAULT NULL,
  `CompanyEmail` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`aComId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_company_details`
--

INSERT INTO `tbl_company_details` VALUES (1,'Main Depo','1','1','1','1','1','1','1','1',1,'1');

--
-- Table structure for table `tbl_courier_dctnumber`
--

CREATE TABLE `tbl_courier_dctnumber` (
  `dctnumber_id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(45) DEFAULT NULL,
  `address` varchar(45) DEFAULT NULL,
  `phone_number` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`dctnumber_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_courier_dctnumber`
--

INSERT INTO `tbl_courier_dctnumber` VALUES (1,'dct1','banglore','111','2019-02-13 15:55:35','2019-02-13 15:55:35',1,0),(2,'dct2','baglkot','222','2019-02-13 15:56:19','2019-02-13 15:56:19',1,0);

--
-- Table structure for table `tbl_customer_branch_details`
--

CREATE TABLE `tbl_customer_branch_details` (
  `abranchId` int(11) NOT NULL AUTO_INCREMENT,
  `branchName` varchar(1000) DEFAULT NULL,
  `branchOwnerName` varchar(250) DEFAULT NULL,
  `branchAddress` varchar(1000) DEFAULT NULL,
  `branchCity` varchar(100) DEFAULT NULL,
  `branchState` varchar(100) DEFAULT NULL,
  `branchCountry` varchar(100) DEFAULT NULL,
  `bPincode` varchar(50) DEFAULT NULL,
  `branchPhNo` varchar(250) DEFAULT NULL,
  `branchEmergencyNo` varchar(250) DEFAULT NULL,
  `branchActive` int(11) DEFAULT NULL,
  `ncustomerId` int(11) DEFAULT NULL,
  `bEmailId` varchar(250) DEFAULT NULL,
  `ccMail` text,
  `bccMail` text,
  `branchcode` varchar(250) DEFAULT NULL,
  `regNo` varchar(45) DEFAULT NULL,
  `PANNo` varchar(45) DEFAULT NULL,
  `distCode` varchar(45) DEFAULT NULL,
  `branchDistrict` varchar(50) DEFAULT NULL,
  `bGSTINno` varchar(45) DEFAULT NULL,
  `st_number` varchar(50) DEFAULT NULL,
  `cin_number` varchar(50) DEFAULT NULL,
  `rohini_id` varchar(50) DEFAULT NULL,
  `branch_DeliveryAddress` text,
  `branch_BillingAddress` text,
  `branch_LocationId` int(11) DEFAULT NULL,
  `po_raise_format` varchar(45) DEFAULT NULL,
  `grnShortCode` varchar(10) DEFAULT NULL,
  `po_mail_password` varchar(500) DEFAULT NULL,
  `faxNumber` varchar(45) DEFAULT NULL,
  `contact_Num` varchar(15) DEFAULT NULL,
  `contact_Person` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`abranchId`),
  KEY `fk_tbl_customer_branch_details_1_idx` (`branch_LocationId`),
  KEY `fk_tbl_customer_branch_details_2_idx` (`ncustomerId`),
  CONSTRAINT `fk_tbl_customer_branch_details_1` FOREIGN KEY (`branch_LocationId`) REFERENCES `tbl_mst_locations` (`aLocationId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_customer_branch_details_2` FOREIGN KEY (`ncustomerId`) REFERENCES `tbl_customer_details` (`acustomerId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_customer_branch_details`
--

INSERT INTO `tbl_customer_branch_details` VALUES (-5,'Sanity','Sanity','YaraGo Software Pvt Ltd','1','1','1','560017',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1000','1','876567576','560017','1','9898098909',NULL,'9090908089','9090909090','YaraGo Software Pvt Ltd','YaraGo Software Pvt Ltd',1,'1000','1000',NULL,NULL,'9999999999','YaraGo'),(1,'YG Branch 1','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','401303',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1002','1','AAEXI6389M','401303','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119','8900080409538','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1002','1002',NULL,NULL,'8976682087','YaraGo'),(2,'YG Branch 2','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','401404',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1001','1','AAEXI6389M','401404','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119','8900080414150','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1001','1001',NULL,NULL,'8976682087','YaraGo'),(3,'YG Branch 3','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','400016',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1004','1','AAEXI6389M','400016','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119',NULL,'YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1003','1003',NULL,NULL,'8976682087','YaraGo'),(4,'YG Branch 4','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','401101',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1003','1','AAEXI6389M','401101','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119',NULL,'YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1004','1004',NULL,NULL,'8976682087','YaraGo'),(5,'YG Branch 5','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','401103',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1005','1','AAEXI6389M','401103','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119',NULL,'YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1005','1005',NULL,NULL,'8976682087','YaraGo'),(6,'YG Branch 6','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','401506',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1006','1','AAEXI6389M','401506','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119',NULL,'YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1006','1006',NULL,NULL,'8976682087','YaraGo'),(7,'YG Branch 7','YaraGo','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','1','1','1','416415',NULL,NULL,1,1,'batch13@yaragos.com','batch13@yaragos.com',NULL,'1007','1','AAEXI6389M','416415','1','27AAECI6389M1ZT',NULL,'U74999MH2017PTC300119',NULL,'YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ','YaraGo Software Pvt Ltd,#304 2nd floor Oxford House,Rustam Bagh Main Road,Bangalore,560017 ',1,'1007','1007',NULL,NULL,'8976682087','YaraGo');

--
-- Table structure for table `tbl_customer_details`
--

CREATE TABLE `tbl_customer_details` (
  `acustomerId` int(11) NOT NULL AUTO_INCREMENT,
  `customerName` varchar(500) DEFAULT NULL,
  `nComId` int(11) DEFAULT NULL,
  `customerOwnerName` varchar(250) DEFAULT NULL,
  `customerAddress` varchar(1000) DEFAULT NULL,
  `customerCity` varchar(100) DEFAULT NULL,
  `customerState` varchar(100) DEFAULT NULL,
  `customerCountry` varchar(100) DEFAULT NULL,
  `Pincode` varchar(50) DEFAULT NULL,
  `customerPhNo` varchar(250) DEFAULT NULL,
  `customerEmergencyNo` varchar(250) DEFAULT NULL,
  `active` int(11) DEFAULT NULL,
  `customerEmail` varchar(500) DEFAULT NULL,
  PRIMARY KEY (`acustomerId`),
  KEY `nComId_idx` (`nComId`),
  CONSTRAINT `nComId` FOREIGN KEY (`nComId`) REFERENCES `tbl_company_details` (`aComId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_customer_details`
--

INSERT INTO `tbl_customer_details` VALUES (1,'test',1,'1','1','1','1','1','1','1','1',1,'1');

--
-- Table structure for table `tbl_frametype_discount_branchmap`
--

CREATE TABLE `tbl_frametype_discount_branchmap` (
  `aId` int(11) NOT NULL AUTO_INCREMENT,
  `nframeTypeId` int(11) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `discountPercentage` float DEFAULT NULL,
  `isActive` int(11) DEFAULT '1',
  `isDeleted` int(11) DEFAULT '0',
  `insertedDateTime` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDateTime` datetime DEFAULT CURRENT_TIMESTAMP,
  `nUserId` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`aId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_frametype_discount_branchmap`
--

INSERT INTO `tbl_frametype_discount_branchmap` VALUES (1,1,1,20,1,0,'2020-06-17 16:25:30','2020-06-17 16:25:30','1');

--
-- Table structure for table `tbl_goods_return_each_item_details`
--

CREATE TABLE `tbl_goods_return_each_item_details` (
  `aItemRetId` int(11) NOT NULL AUTO_INCREMENT,
  `mainReturnId` varchar(45) DEFAULT NULL,
  `categoryId` int(11) DEFAULT NULL,
  `is_customer_or_cunsumer_retn_by` int(11) DEFAULT NULL,
  `customer_or_cunsumer_id_retn_by` int(11) DEFAULT NULL,
  `is_customer_or_supplier_retn_to` int(11) DEFAULT NULL,
  `customer_or_supplier_id_retn_to` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `grnID` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `batchNo` varchar(150) DEFAULT NULL,
  `expiryDate` datetime DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `returnedItems` int(11) DEFAULT NULL,
  `returnedQty` int(11) DEFAULT NULL,
  `isApproved` int(11) DEFAULT '0',
  `approvedBy` int(11) DEFAULT NULL,
  `isDepoAccepted` int(11) DEFAULT '0',
  `depoAcceptedBy` int(11) DEFAULT NULL,
  `retReasonId` int(11) DEFAULT NULL,
  `retReason` text,
  `scannedBarcodeNo` text,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `returntype` int(11) DEFAULT '0',
  `returnActive` int(11) DEFAULT '0',
  PRIMARY KEY (`aItemRetId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_goods_return_each_item_details`
--


--
-- Table structure for table `tbl_goods_return_main_details`
--

CREATE TABLE `tbl_goods_return_main_details` (
  `aRetID` int(11) NOT NULL AUTO_INCREMENT,
  `categoryId` int(11) DEFAULT NULL,
  `is_customer_or_cunsumer_retn_by` int(11) DEFAULT NULL,
  `customer_or_cunsumer_id_retn_by` int(11) DEFAULT NULL,
  `is_customer_or_supplier_retn_to` int(11) DEFAULT NULL,
  `customer_or_supplier_id_retn_to` int(11) DEFAULT NULL,
  `returnedItems_total` int(11) DEFAULT NULL,
  `returnedQty_total` int(11) DEFAULT NULL,
  `generatedUUID_PerTran` varchar(500) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `returntype` int(11) DEFAULT '0',
  `returnActive` int(11) DEFAULT '0',
  PRIMARY KEY (`aRetID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_goods_return_main_details`
--


--
-- Table structure for table `tbl_grn_for_po_each_item_orders`
--

CREATE TABLE `tbl_grn_for_po_each_item_orders` (
  `aGrnId_each_pk` int(11) NOT NULL AUTO_INCREMENT,
  `nGrnId_fk` int(11) DEFAULT NULL,
  `categoryid` int(11) DEFAULT NULL,
  `nPoIdCentral_fk` int(11) DEFAULT NULL,
  `nPoEachId` int(11) DEFAULT NULL,
  `nPoEachIdBranch_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_Central_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_Centra_Each_fk` int(11) DEFAULT NULL,
  `sendToBranch` int(11) DEFAULT NULL,
  `nGrnIdCentral_fk` int(11) DEFAULT NULL,
  `nPoType_fk` int(11) DEFAULT NULL,
  `nSupplierId_fk` int(11) DEFAULT NULL,
  `nGrnDepo_fk` int(11) DEFAULT NULL,
  `nGrnUserId_fk` int(11) DEFAULT NULL,
  `nItemId_fk` int(11) DEFAULT NULL,
  `grnItemStatusId` int(11) DEFAULT NULL,
  `grnItemStatusText` text,
  `balanceQty` int(11) DEFAULT NULL,
  `receivedQty` int(11) DEFAULT NULL,
  `freeQtys` int(11) DEFAULT '0',
  `issuedqty_fromdepo` int(11) DEFAULT NULL,
  `batchNo` varchar(150) DEFAULT NULL,
  `expiryDate` datetime DEFAULT NULL,
  `serialNumber` varchar(100) DEFAULT NULL,
  `itemAmount` float DEFAULT NULL,
  `gstType` int(11) DEFAULT NULL,
  `cgstPercent` float DEFAULT NULL,
  `sgstPercent` float DEFAULT NULL,
  `igstPercent` float DEFAULT NULL,
  `gstPercent` float DEFAULT NULL,
  `cgstAmount` float DEFAULT NULL,
  `sgstAmount` float DEFAULT NULL,
  `igstAmount` float DEFAULT NULL,
  `gstAmount` float DEFAULT NULL,
  `grossAmount` float DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `ngrnBranchId_fk` int(11) DEFAULT NULL,
  `size` varchar(25) DEFAULT NULL,
  `diapter` varchar(25) DEFAULT NULL,
  `strength` varchar(25) DEFAULT NULL,
  `volume` varchar(25) DEFAULT NULL,
  `issuedToBranch` int(11) DEFAULT '0',
  `nSupplierItemMapid` int(11) DEFAULT NULL,
  `nGrnTypeId` int(11) DEFAULT '1',
  `nEachTransferId` int(11) DEFAULT NULL,
  `nMainTransferId` int(11) DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `po_from_depo_fk` int(11) DEFAULT NULL,
  `n_poid_from_branch_fk` int(11) DEFAULT '0',
  `grn_from_depo_fk` int(11) DEFAULT NULL,
  `grn_from_branch_fk` int(11) DEFAULT '0',
  `disPercentage` float DEFAULT '0',
  `disAmt` float DEFAULT '0',
  `itemTotalAmt` float DEFAULT '0',
  `taxableAmount` float DEFAULT '0',
  `taxForTaxableAmount` float DEFAULT '0',
  `cgstForTaxbleAmt` float DEFAULT '0',
  `sgstForTaxableAmt` float DEFAULT '0',
  `taxableAmtForOneQty` float DEFAULT '0',
  `taxForOneQty` float DEFAULT '0',
  PRIMARY KEY (`aGrnId_each_pk`),
  UNIQUE KEY `nEachTransferId_UNIQUE` (`nEachTransferId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_grn_for_po_each_item_orders`
--


--
-- Table structure for table `tbl_grn_for_po_each_item_orders_temp_mq`
--

CREATE TABLE `tbl_grn_for_po_each_item_orders_temp_mq` (
  `aGrnId_each_pk` int(11) NOT NULL AUTO_INCREMENT,
  `nGrnId_fk` int(11) DEFAULT NULL,
  `categoryid` int(11) DEFAULT NULL,
  `nPoIdCentral_fk` int(11) DEFAULT NULL,
  `nPoEachId` int(11) DEFAULT NULL,
  `nPoEachIdBranch_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_Central_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_Centra_Each_fk` int(11) DEFAULT NULL,
  `sendToBranch` int(11) DEFAULT NULL,
  `nGrnIdCentral_fk` int(11) DEFAULT NULL,
  `nPoType_fk` int(11) DEFAULT NULL,
  `nSupplierId_fk` int(11) DEFAULT NULL,
  `nGrnDepo_fk` int(11) DEFAULT NULL,
  `nGrnUserId_fk` int(11) DEFAULT NULL,
  `nItemId_fk` int(11) DEFAULT NULL,
  `grnItemStatusId` int(11) DEFAULT NULL,
  `grnItemStatusText` text,
  `balanceQty` int(11) DEFAULT NULL,
  `receivedQty` int(11) DEFAULT NULL,
  `issuedqty_fromdepo` int(11) DEFAULT NULL,
  `batchNo` varchar(10) DEFAULT NULL,
  `expiryDate` datetime DEFAULT NULL,
  `serialNumber` varchar(100) DEFAULT NULL,
  `itemAmount` float DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `ngrnBranchId_fk` int(11) DEFAULT NULL,
  `size` varchar(25) DEFAULT NULL,
  `diapter` varchar(25) DEFAULT NULL,
  `strength` varchar(25) DEFAULT NULL,
  `volume` varchar(25) DEFAULT NULL,
  `issuedToBranch` int(11) DEFAULT '0',
  `nSupplierItemMapid` int(11) DEFAULT NULL,
  `nGrnTypeId` int(11) DEFAULT '1',
  `nEachTransferId` int(11) DEFAULT NULL,
  `nMainTransferId` int(11) DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `po_from_depo_fk` int(11) DEFAULT NULL,
  `n_poid_from_branch_fk` int(11) DEFAULT '0',
  `grn_from_depo_fk` int(11) DEFAULT NULL,
  `grn_from_branch_fk` int(11) DEFAULT '0',
  PRIMARY KEY (`aGrnId_each_pk`),
  UNIQUE KEY `nEachTransferId_UNIQUE` (`nEachTransferId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_grn_for_po_each_item_orders_temp_mq`
--


--
-- Table structure for table `tbl_grn_for_po_orders`
--

CREATE TABLE `tbl_grn_for_po_orders` (
  `aGrnId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `grnNumber` varchar(50) DEFAULT NULL,
  `categoryid` int(11) DEFAULT NULL,
  `nPoIdCentral_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_Central_fk` int(11) DEFAULT NULL,
  `nGrnIdCentral_fk` int(11) DEFAULT NULL,
  `sendToBranch` int(11) DEFAULT '0',
  `nPoType_fk` int(11) DEFAULT NULL,
  `nSupplierId_fk` int(11) DEFAULT NULL,
  `nGrnDepo_fk` int(11) DEFAULT NULL,
  `nGrnUserId_fk` int(11) DEFAULT NULL,
  `grnDate` datetime DEFAULT NULL,
  `dcNumber` varchar(25) DEFAULT NULL,
  `dcDate` datetime DEFAULT NULL,
  `invoiceNumber` varchar(50) DEFAULT NULL,
  `invoiceAmount` float DEFAULT NULL,
  `invoiceTaxAmt` float DEFAULT '0',
  `frightCharges` float DEFAULT NULL,
  `invoicePhotoUploadName` varchar(25) DEFAULT NULL,
  `grnRemarks` text,
  `grnTotalItems` int(11) DEFAULT NULL,
  `grnTotalItemsQty` int(11) DEFAULT NULL,
  `issuedqty_fromdepo` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `ngrnBranchId_fk` int(11) DEFAULT NULL,
  `issuedToBranch` int(11) DEFAULT '0',
  `centralGRNNum` varchar(25) DEFAULT NULL,
  `centralGrnId` int(11) DEFAULT '0',
  `invoiceDate` datetime DEFAULT NULL,
  `nCommertialStatus` int(11) DEFAULT '0',
  `commercialStatusUpdatedDate` datetime DEFAULT NULL,
  `commercialStatusUpdatedBy` int(11) DEFAULT NULL,
  `statusRemarks` text,
  `centralMainTransferId` int(11) DEFAULT NULL,
  `centralMainGrnId` int(11) DEFAULT '0',
  `accountsStatusId` int(11) DEFAULT NULL,
  `accountsRemarks` text,
  `accountsUserId` int(11) DEFAULT NULL,
  `accountsDate` datetime DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `po_from_depo_fk` int(11) DEFAULT NULL,
  `n_poid_from_branch_fk` int(11) DEFAULT '0',
  `grn_from_depo_fk` int(11) DEFAULT NULL,
  `grn_from_branch_fk` int(11) DEFAULT '0',
  `sgst` float DEFAULT '0',
  `cgst` float DEFAULT '0',
  `igst` float DEFAULT '0',
  `dctnumer_id_fk` int(11) DEFAULT NULL,
  `dct_name` varchar(45) DEFAULT NULL,
  `courier_dct_number` varchar(45) DEFAULT NULL,
  `courier_phone` varchar(45) DEFAULT NULL,
  `isDepoOrBranchGeneratingInvoice` int(11) DEFAULT NULL,
  `invoiceGenerateDepoOrBranchId` int(11) DEFAULT NULL,
  `grnFrightCharges` float DEFAULT '0',
  `grnAmtWithFright` float DEFAULT '0',
  `grnDisTotAmt` float DEFAULT '0',
  `isPaidToSupplier` int(11) DEFAULT '0',
  PRIMARY KEY (`aGrnId_pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_grn_for_po_orders`
--


--
-- Table structure for table `tbl_grn_for_po_orders_temp_mq`
--

CREATE TABLE `tbl_grn_for_po_orders_temp_mq` (
  `aGrnId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `grnNumber` varchar(50) DEFAULT NULL,
  `categoryid` int(11) DEFAULT NULL,
  `nPoIdCentral_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_fk` int(11) DEFAULT NULL,
  `nPoIdBranch_Central_fk` int(11) DEFAULT NULL,
  `nGrnIdCentral_fk` int(11) DEFAULT NULL,
  `sendToBranch` int(11) DEFAULT '0',
  `nPoType_fk` int(11) DEFAULT NULL,
  `nSupplierId_fk` int(11) DEFAULT NULL,
  `nGrnDepo_fk` int(11) DEFAULT NULL,
  `nGrnUserId_fk` int(11) DEFAULT NULL,
  `grnDate` datetime DEFAULT NULL,
  `dcNumber` varchar(25) DEFAULT NULL,
  `dcDate` datetime DEFAULT NULL,
  `invoiceNumber` varchar(50) DEFAULT NULL,
  `invoiceAmount` float DEFAULT NULL,
  `invoiceTaxAmt` float DEFAULT '0',
  `frightCharges` float DEFAULT NULL,
  `invoicePhotoUploadName` varchar(25) DEFAULT NULL,
  `grnRemarks` text,
  `grnTotalItems` int(11) DEFAULT NULL,
  `grnTotalItemsQty` int(11) DEFAULT NULL,
  `issuedqty_fromdepo` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `ngrnBranchId_fk` int(11) DEFAULT NULL,
  `issuedToBranch` int(11) DEFAULT '0',
  `centralGRNNum` varchar(25) DEFAULT NULL,
  `centralGrnId` int(11) DEFAULT '0',
  `invoiceDate` datetime DEFAULT NULL,
  `nCommertialStatus` int(11) DEFAULT '0',
  `commercialStatusUpdatedDate` datetime DEFAULT NULL,
  `commercialStatusUpdatedBy` int(11) DEFAULT NULL,
  `statusRemarks` text,
  `centralMainTransferId` int(11) DEFAULT NULL,
  `centralMainGrnId` int(11) DEFAULT '0',
  `accountsStatusId` int(11) DEFAULT NULL,
  `accountsRemarks` text,
  `accountsUserId` int(11) DEFAULT NULL,
  `accountsDate` datetime DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `po_from_depo_fk` int(11) DEFAULT NULL,
  `n_poid_from_branch_fk` int(11) DEFAULT '0',
  `grn_from_depo_fk` int(11) DEFAULT NULL,
  `grn_from_branch_fk` int(11) DEFAULT '0',
  PRIMARY KEY (`aGrnId_pk`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_grn_for_po_orders_temp_mq`
--


--
-- Table structure for table `tbl_item_availability`
--

CREATE TABLE `tbl_item_availability` (
  `itemAvailId` int(11) NOT NULL AUTO_INCREMENT,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `available_qty` int(11) DEFAULT NULL,
  `previous_avail_qty` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`itemAvailId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_availability`
--


--
-- Table structure for table `tbl_item_availability_stock_corrn_history`
--

CREATE TABLE `tbl_item_availability_stock_corrn_history` (
  `itemAvailId_st_crn` int(11) NOT NULL AUTO_INCREMENT,
  `nitemAvailId` int(11) NOT NULL,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `available_qty` int(11) DEFAULT NULL,
  `previous_avail_qty` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`itemAvailId_st_crn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_availability_stock_corrn_history`
--


--
-- Table structure for table `tbl_item_grn_availability`
--

CREATE TABLE `tbl_item_grn_availability` (
  `itemAvailId` int(11) NOT NULL AUTO_INCREMENT,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `grnID` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `available_qty` int(11) DEFAULT NULL,
  `previous_avail_qty` int(11) DEFAULT NULL,
  `discountPercentIfRemainUnsold` float DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`itemAvailId`),
  KEY `fr_key_1_idx` (`itemID`),
  CONSTRAINT `fr_key_1` FOREIGN KEY (`itemID`) REFERENCES `tbl_mst_items_details` (`aItemId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_grn_availability`
--


--
-- Table structure for table `tbl_item_grn_availability_stock_corrn_history`
--

CREATE TABLE `tbl_item_grn_availability_stock_corrn_history` (
  `itemAvailId_st_crn` int(11) NOT NULL AUTO_INCREMENT,
  `nitemAvailId` int(11) NOT NULL,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `grnID` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `available_qty` int(11) DEFAULT NULL,
  `previous_avail_qty` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`itemAvailId_st_crn`),
  KEY `fr_key_1_idx` (`itemID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_grn_availability_stock_corrn_history`
--


--
-- Table structure for table `tbl_item_grn_module_expire_availability`
--

CREATE TABLE `tbl_item_grn_module_expire_availability` (
  `itemAvail_expire_Id` int(11) NOT NULL AUTO_INCREMENT,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `grnID` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `batchNo` varchar(45) DEFAULT NULL,
  `expiryDate` datetime DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `available_qty` int(11) DEFAULT NULL,
  `previous_avail_qty` int(11) DEFAULT NULL,
  `discountPercentIfRemainUnsold` float DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`itemAvail_expire_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_grn_module_expire_availability`
--


--
-- Table structure for table `tbl_item_grn_module_expire_availability_stock_corrn_history`
--

CREATE TABLE `tbl_item_grn_module_expire_availability_stock_corrn_history` (
  `itemAvail_expire_Id_st_crn` int(11) NOT NULL AUTO_INCREMENT,
  `nitemAvail_expire_Id` int(11) NOT NULL,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `grnID` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `batchNo` varchar(45) DEFAULT NULL,
  `expiryDate` datetime DEFAULT NULL,
  `itemratemasterID` int(11) DEFAULT NULL,
  `available_qty` int(11) DEFAULT NULL,
  `previous_avail_qty` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`itemAvail_expire_Id_st_crn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_grn_module_expire_availability_stock_corrn_history`
--


--
-- Table structure for table `tbl_item_rate_master`
--

CREATE TABLE `tbl_item_rate_master` (
  `aitemrateId` int(11) NOT NULL AUTO_INCREMENT,
  `nSupplierId_fk` int(11) NOT NULL,
  `nItemId_fk` int(11) NOT NULL,
  `iscustomerorconsumer` int(11) NOT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `ndepotId` int(11) DEFAULT NULL,
  `iscompanyorsupplier` int(11) DEFAULT '0',
  `companyassupplierId` int(11) DEFAULT '0',
  `branchassupplierId` int(11) DEFAULT '0',
  `purchasePrice` float DEFAULT NULL,
  `nhsnId_fk` int(11) DEFAULT NULL,
  `sellingPrice` float DEFAULT NULL,
  `MRP` float DEFAULT NULL,
  `freeQty` float DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aitemrateId`),
  KEY `fk_tbl_item_rate_master_1_idx` (`nSupplierId_fk`),
  KEY `fk_tbl_item_rate_master_2_idx` (`nItemId_fk`),
  KEY `fk_tbl_item_rate_master_3_idx` (`ndepotId`),
  KEY `fk_tbl_item_rate_master_4_idx` (`nBranchId`),
  KEY `fk_tbl_item_rate_master_5_idx` (`nUserId_fk`),
  KEY `fk_tbl_item_rate_master_6_idx` (`nhsnId_fk`),
  CONSTRAINT `fk_tbl_item_rate_master_2` FOREIGN KEY (`nItemId_fk`) REFERENCES `tbl_mst_items_details` (`aItemId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_item_rate_master_5` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_item_rate_master_6` FOREIGN KEY (`nhsnId_fk`) REFERENCES `tbl_mst_hsn_codes` (`aHsnId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_item_rate_master`
--


--
-- Table structure for table `tbl_modules`
--

CREATE TABLE `tbl_modules` (
  `aModuleId` int(11) NOT NULL AUTO_INCREMENT,
  `priority` float NOT NULL,
  `moduleName` varchar(100) DEFAULT NULL,
  `moduleNameForMobile` varchar(100) DEFAULT NULL,
  `isHavingSubModule` int(11) DEFAULT NULL,
  `isMobileOrWeb` int(11) DEFAULT NULL,
  `moduleId` int(11) DEFAULT NULL COMMENT 'Module Id refers to aModuleId of same table',
  `fnOnClick` varchar(250) NOT NULL COMMENT 'This is the function name that will be triggered (in js) on click of a link in jsp',
  `moduleIcon` varchar(45) DEFAULT NULL,
  `fnOnClickForMobile` varchar(250) DEFAULT NULL,
  `moduleIconForMobile` varchar(100) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedDate` datetime DEFAULT NULL,
  `isActive` int(11) DEFAULT NULL,
  `isDeleted` int(11) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  `iscompanyorcustomerUser` int(11) DEFAULT NULL,
  PRIMARY KEY (`aModuleId`),
  UNIQUE KEY `moduleName_UNIQUE` (`moduleName`),
  KEY `fk_tblModules_1_idx` (`nUserId`),
  CONSTRAINT `fk_tblModules_1` FOREIGN KEY (`nUserId`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=36 DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tbl_modules`
--

INSERT INTO `tbl_modules` VALUES (25,1,'Masters',NULL,1,1,1,'dsf','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(26,2,'Lists',NULL,1,1,1,'dsf','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(27,3,'Lists2',NULL,0,1,1,'dsadf','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(28,2,'Purchase Order',NULL,1,1,1,' ','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(29,3,'Indent',NULL,1,1,1,'','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(30,4,'Sales',NULL,1,1,1,'fa fa-tasks','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(31,5,'Reports',NULL,1,1,1,'dsadf','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(32,6,'Inventory',NULL,1,1,1,'fa fa-tasks','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(33,7,'Goods Return',NULL,1,1,1,'fa fa-tasks','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(34,8,'Audit',NULL,1,1,1,'fa fa-tasks','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,0),(35,9,'Supplier Payment',NULL,1,1,1,'fa fa-tasks','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,0);

--
-- Table structure for table `tbl_mst_bank`
--

CREATE TABLE `tbl_mst_bank` (
  `aBankId_pk` int(11) NOT NULL,
  `name` varchar(50) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aBankId_pk`),
  KEY `fk_tbl_mst_bank_1_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_bank_1` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_bank`
--

INSERT INTO `tbl_mst_bank` VALUES (0,'Kotak Mahindra Bank',NULL,'2019-08-22 11:51:19','2019-08-22 11:51:19',1,0,133),(1,'Development credit bank(dcb bank)','BankDesc','2018-10-30 19:38:00','2018-10-30 19:38:00',1,0,133),(2,'CITI BANK',NULL,'2019-03-23 13:01:26','2019-03-23 13:01:26',1,0,133),(3,'YES BANK',NULL,'2019-03-23 13:01:26','2019-03-23 13:01:26',1,0,133),(4,'Abhyudaya Co Op Bank, ',NULL,'2019-03-23 13:01:26','2019-03-23 13:01:26',1,0,133),(5,'Bank of India,',NULL,'2019-03-23 13:01:26','2019-03-23 13:01:26',1,0,133),(6,'Punjab national bank',NULL,'2019-03-23 15:56:07','2019-03-23 15:56:07',1,0,133),(7,'HDFC',NULL,'2019-04-18 15:02:15','2019-04-18 15:02:15',1,0,133),(8,'SVC CORPORATIVE',NULL,'2019-04-25 14:57:27','2019-04-25 14:57:27',1,0,133),(9,'COSMOS BANK',NULL,'2019-05-15 18:01:40','2019-05-15 18:01:40',1,0,133),(10,'CENTRAL BANK OF INDIA',NULL,'2019-09-28 15:24:43','2019-09-28 15:24:43',1,0,133),(11,'IDBI Bank',NULL,'2019-10-01 11:39:09','2019-10-01 11:39:09',1,0,133),(12,'Bank of Maharashtra',NULL,'2019-10-01 11:39:09','2019-10-01 11:39:09',1,0,133);

--
-- Table structure for table `tbl_mst_barcode_config_details`
--

CREATE TABLE `tbl_mst_barcode_config_details` (
  `aBarCodeId` int(11) NOT NULL AUTO_INCREMENT,
  `depoId` int(11) DEFAULT NULL,
  `isconsumerorcustomer` int(11) DEFAULT NULL,
  `consumerorcustomerid` int(11) DEFAULT NULL,
  `nCategoryIdFk` int(11) DEFAULT NULL,
  `categoryIdShortCode` varchar(45) DEFAULT NULL,
  `barcodeCurrentValue` varchar(45) DEFAULT NULL,
  `barcodePreviseValue` varchar(45) DEFAULT NULL,
  `barcodeLength` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`aBarCodeId`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_barcode_config_details`
--

INSERT INTO `tbl_mst_barcode_config_details` VALUES (1,1,1,1,1,'FR','7255','7245','9','2019-01-23 16:32:44','2020-05-06 13:42:05',1,0),(2,1,1,1,4,'SG','211','211','9','2019-01-23 16:32:44','2020-05-06 13:42:05',1,0),(3,1,1,1,6,'RG','90','90','9','2019-01-23 16:32:44','2020-05-06 13:42:05',1,0);

--
-- Table structure for table `tbl_mst_brands`
--

CREATE TABLE `tbl_mst_brands` (
  `aBrandTypeId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `brandName` varchar(100) DEFAULT NULL,
  `nCategoryId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aBrandTypeId_pk`),
  KEY `fk_tbl_mst_brands_1_idx` (`nCategoryId_fk`),
  CONSTRAINT `fk_tbl_mst_brands_1` FOREIGN KEY (`nCategoryId_fk`) REFERENCES `tbl_mst_category` (`aCategoryId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_brands`
--


--
-- Table structure for table `tbl_mst_business_type`
--

CREATE TABLE `tbl_mst_business_type` (
  `aBusinessId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(1) DEFAULT '1',
  `isDeleted` tinyint(1) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aBusinessId_pk`),
  KEY `fk_tbl_mst_business_type_1_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_business_type_1` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_business_type`
--

INSERT INTO `tbl_mst_business_type` VALUES (1,'Business Name','Business Desc','2018-10-30 19:41:20','2018-10-30 19:41:20',1,0,70);

--
-- Table structure for table `tbl_mst_categories`
--

CREATE TABLE `tbl_mst_categories` (
  `aPharmaCatId` int(11) NOT NULL AUTO_INCREMENT,
  `categoryName` varchar(100) DEFAULT NULL,
  `categoryTypeId` tinyint(4) DEFAULT '2',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aPharmaCatId`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_categories`
--

INSERT INTO `tbl_mst_categories` VALUES (7,'Tablet',2,'2018-12-22 14:47:50','2018-12-22 14:47:50',1,0,1),(8,'Eye Drop',2,'2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,1),(9,'Ointment',2,'2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,1),(10,'Injection',2,'2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,1),(11,'All',2,'2019-03-07 13:41:44','2019-03-07 13:41:44',1,0,1);

--
-- Table structure for table `tbl_mst_category`
--

CREATE TABLE `tbl_mst_category` (
  `aCategoryId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `CategoryCode` varchar(100) DEFAULT NULL,
  `CategoryName` varchar(100) DEFAULT NULL,
  `isBatchNum_Expiey_Category` tinyint(4) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aCategoryId_pk`),
  KEY `fk_tbl_mst_category_1_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_category_1` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_category`
--

INSERT INTO `tbl_mst_category` VALUES (1,'F001','Frames',0,'2018-10-25 16:07:59','2018-10-25 16:07:59',1,0,75),(2,'L002','Lens',0,'2018-10-25 16:07:59','2018-10-25 16:07:59',1,0,75),(3,'CL003','Contact Lens',1,'2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,75),(4,'S004','Sunglasses',0,'2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,75),(5,'Oth-006','Others',0,'2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,75),(6,'RG','Reading Glasses',0,'2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,75),(7,'SS','Surgery Glasses',0,'2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,75),(8,'CBnS','CaseBox and Selvet',1,'2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,75),(9,'Acc007','Accessories',0,'2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,75),(11,'TAB','Tablet',1,'2018-12-22 14:47:50','2018-12-22 14:47:50',0,0,75),(12,'ED','Eye Drop',1,'2018-12-26 11:39:28','2018-12-26 11:39:28',0,0,75),(13,'OINT','Ointment',1,'2018-12-26 11:39:28','2018-12-26 11:39:28',0,0,75),(14,'INJ','Injection',1,'2018-12-26 11:39:28','2018-12-26 11:39:28',0,0,75);

--
-- Table structure for table `tbl_mst_category_item_fields`
--

CREATE TABLE `tbl_mst_category_item_fields` (
  `aCatItemId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `nCategoryId_fk` int(11) NOT NULL,
  `Fieldname` varchar(100) NOT NULL,
  `Fielddescription` varchar(255) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(1) DEFAULT '1',
  `isDeleted` tinyint(1) DEFAULT '0',
  `isDefaultSourceForNaming` int(11) DEFAULT '1',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aCatItemId_pk`),
  KEY `fk_tbl_mst_category_item_fields_1_idx` (`nCategoryId_fk`),
  KEY `fk_tbl_mst_category_item_fields_2_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_category_item_fields_1` FOREIGN KEY (`nCategoryId_fk`) REFERENCES `tbl_mst_category` (`aCategoryId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_category_item_fields_2` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=73 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_category_item_fields`
--

INSERT INTO `tbl_mst_category_item_fields` VALUES (1,1,'Model_Name','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(2,1,'Color','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(4,1,'Size','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(5,1,'field5','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(6,2,'Model_Name','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(7,2,'Color',NULL,'2018-10-26 14:03:55','2018-10-26 14:03:55',1,0,1,133),(10,4,'Model_Name','desc','2018-10-26 14:03:55','2018-10-26 14:03:55',1,0,1,133),(11,4,'Color','desc','2018-10-26 14:03:55','2018-10-26 14:03:55',1,0,1,133),(12,5,'Model_Name','desc','2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,1,133),(13,5,'Color','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(14,3,'Model_Name','desc','2018-11-06 14:44:16','2018-11-06 14:44:16',1,0,1,133),(15,3,'Color','desc','2018-11-06 14:44:16','2018-11-06 14:44:16',1,0,1,133),(16,3,'Size','desc','2018-11-06 14:44:16','2018-11-06 14:44:16',1,0,1,133),(17,6,'Model_Name','desc','2018-11-06 14:45:28','2018-11-06 14:45:28',1,0,1,133),(18,6,'Color','desc','2018-11-06 14:45:28','2018-11-06 14:45:28',1,0,1,133),(19,6,'Material','desc','2018-11-06 14:45:28','2018-11-06 14:45:28',1,0,1,133),(20,6,'Model_No','desc','2018-11-06 14:45:28','2018-11-06 14:45:28',0,0,1,133),(21,1,'Material','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',0,0,1,133),(22,1,'Model_No','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',0,0,1,133),(23,1,'Type','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',0,0,1,133),(24,1,'Shape','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',0,0,1,133),(25,11,'Shape','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(26,12,'Shape','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(27,13,'Shape','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(28,14,'Shape','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(29,7,'Model_Name','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(30,8,'Model_Name','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(31,9,'Field7','desc','2018-12-26 11:39:28','2018-12-26 11:39:28',1,0,1,133),(32,4,'Size',NULL,'2019-03-26 20:35:29','2019-03-26 20:35:29',1,0,1,133),(33,4,'Material',NULL,'2019-03-26 20:35:29','2019-03-26 20:35:29',1,0,1,133),(34,4,'Type',NULL,'2019-03-26 20:35:29','2019-03-26 20:35:29',1,0,1,133),(35,4,'Shape',NULL,'2019-03-26 20:35:29','2019-03-26 20:35:29',1,0,1,133),(36,4,'Model_No',NULL,'2019-03-26 20:36:06','2019-03-26 20:36:06',1,0,1,133),(37,2,'Size','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(38,2,'Material',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(39,2,'Model_No',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(40,2,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(41,2,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(42,3,'Material',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(43,3,'Model_No',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(44,3,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(45,3,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(46,5,'Size','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(47,5,'Material',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(48,5,'Model_No',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(49,5,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(50,5,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(51,6,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(52,6,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(53,7,'Color','desc','2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,1,133),(54,7,'Size','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(55,7,'Material',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(56,7,'Model_No',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(57,7,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(58,7,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(59,8,'Color','desc','2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,1,133),(60,8,'Size','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(61,8,'Material',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(62,8,'Model_No',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(63,8,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(64,8,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(65,6,'Size','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(66,9,'Model_Name','desc','2018-10-25 16:30:26','2018-10-25 16:30:26',1,0,1,133),(67,9,'Color','desc','2018-10-26 20:32:14','2018-10-26 20:32:14',1,0,1,133),(68,9,'Size','desc','2018-10-26 20:32:15','2018-10-26 20:32:15',1,0,1,133),(69,9,'Material',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(70,9,'Model_No',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(71,9,'Type',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133),(72,9,'Shape',NULL,'2019-03-26 20:31:12','2019-03-26 20:31:12',1,0,1,133);

--
-- Table structure for table `tbl_mst_countries`
--

CREATE TABLE `tbl_mst_countries` (
  `aCountryId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `countryCode` varchar(10) DEFAULT NULL,
  `countryShortCode` varchar(10) DEFAULT NULL,
  `countryName` varchar(100) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aCountryId_pk`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_countries`
--

INSERT INTO `tbl_mst_countries` VALUES (1,'1','A1','India','2018-10-30 16:17:03','2018-10-30 16:17:03',1,0,1),(2,'CCode','CSCode','CName','2018-10-30 19:52:16','2018-10-30 19:52:16',1,0,70);

--
-- Table structure for table `tbl_mst_creditcompanies`
--

CREATE TABLE `tbl_mst_creditcompanies` (
  `aCompanyId` int(11) NOT NULL AUTO_INCREMENT,
  `companyName` text,
  `companyAddress` varchar(1000) DEFAULT NULL,
  `companyPhNo` varchar(45) DEFAULT NULL,
  `companyTINNo` varchar(250) DEFAULT NULL,
  `companyRegistrationNo` varchar(250) DEFAULT NULL,
  `companyEstDate` datetime DEFAULT NULL,
  `InsertedDate` datetime DEFAULT NULL,
  `LastModifiedDate` datetime DEFAULT NULL,
  `isActive` tinyint(1) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aCompanyId`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_mst_creditcompanies`
--

INSERT INTO `tbl_mst_creditcompanies` VALUES (1,'CGHS',NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL),(2,'EGSH',NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL),(3,'AirIndia',NULL,NULL,NULL,NULL,NULL,NULL,NULL,1,NULL);

--
-- Table structure for table `tbl_mst_global_configurations`
--

CREATE TABLE `tbl_mst_global_configurations` (
  `aConfig_fk` int(11) NOT NULL AUTO_INCREMENT,
  `configKey` varchar(250) DEFAULT NULL,
  `configValue` varchar(1000) CHARACTER SET utf8 DEFAULT NULL,
  `configDescription` varchar(250) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedDate` datetime DEFAULT NULL,
  `isActive` int(11) DEFAULT NULL,
  `isDeleted` int(11) DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `branchId` int(11) DEFAULT NULL,
  `userId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aConfig_fk`)
) ENGINE=InnoDB AUTO_INCREMENT=59 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_global_configurations`
--

INSERT INTO `tbl_mst_global_configurations` VALUES (1,'mst_permisable_level_config','1','1 => Percentage, 2 => Qty, 3 => Amount Value',NULL,NULL,1,NULL,NULL,1,NULL),(2,'mst_permisable_level','20','configuration value',NULL,NULL,1,NULL,NULL,1,NULL),(3,'audit_without_approval_show_for_reconcile','1','1 => show audit in reconsile without approval 0 => dont show',NULL,NULL,1,NULL,NULL,1,NULL),(4,'mst_permisable_level_config','1','1 => Percentage, 2 => Qty, 3 => Amount Value',NULL,NULL,1,NULL,NULL,2,NULL),(5,'mst_permisable_level','20','configuration value',NULL,NULL,1,NULL,NULL,2,NULL),(6,'audit_without_approval_show_for_reconcile','1','1 => show audit in reconsile without approval 0 => dont show',NULL,NULL,1,NULL,NULL,2,NULL),(7,'mst_permisable_level_config','1','1 => Percentage, 2 => Qty, 3 => Amount Value',NULL,NULL,1,NULL,NULL,3,NULL),(8,'mst_permisable_level','20','configuration value',NULL,NULL,1,NULL,NULL,3,NULL),(9,'audit_without_approval_show_for_reconcile','1','1 => show audit in reconsile without approval 0 => dont show',NULL,NULL,1,NULL,NULL,3,NULL),(10,'mst_permisable_level_config','1','1 => Percentage, 2 => Qty, 3 => Amount Value',NULL,NULL,1,NULL,NULL,4,NULL),(11,'mst_permisable_level','20','configuration value',NULL,NULL,1,NULL,NULL,4,NULL),(12,'audit_without_approval_show_for_reconcile','1','1 => show audit in reconsile without approval 0 => dont show',NULL,NULL,1,NULL,NULL,4,NULL),(13,'mst_permisable_level_config','1','1 => Percentage, 2 => Qty, 3 => Amount Value',NULL,NULL,1,NULL,NULL,5,NULL),(14,'mst_permisable_level','20','configuration value',NULL,NULL,1,NULL,NULL,5,NULL),(15,'audit_without_approval_show_for_reconcile','1','1 => show audit in reconsile without approval 0 => dont show',NULL,NULL,1,NULL,NULL,5,NULL),(16,'mst_permisable_level_config','1','1 => Percentage, 2 => Qty, 3 => Amount Value',NULL,NULL,1,NULL,NULL,6,NULL),(17,'mst_permisable_level','20','configuration value',NULL,NULL,1,NULL,NULL,6,NULL),(18,'audit_without_approval_show_for_reconcile','1','1 => show audit in reconsile without approval 0 => dont show',NULL,NULL,1,NULL,NULL,6,NULL),(19,'OPT_Refraction_Print_Terms&Condition','This is computer generated, so signature is not required.','Terms & Condition OPT Prescription',NULL,NULL,1,0,NULL,1,NULL),(20,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,1,NULL),(21,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,1,NULL),(22,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,1,NULL),(23,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,1,NULL),(24,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,2,NULL),(25,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,3,NULL),(26,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,4,NULL),(27,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,5,NULL),(28,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,6,NULL),(29,'OPT_Sale_Terms&Condition','<br>1.This Bill / Order  cannot be cancelled or modified. Amount will not be refund under any circumstances</br>\n  <br>2.Every order requires the payment of at least 50% as advanced of total order value.</br>\n  <br>3.Order not collected by customer within 90 days from the order date will be cancelled and advance amount will be forfeited</br>\n  <br>4.Customers own frames and lenses given to the store for adjustments can only be handled at customer risk.</br>\n  <br>5.All disputes are subject to   jurisdiction Only.</br>','Terms & Condition','0000-00-00 00:00:00',NULL,1,0,1,7,NULL),(30,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,2,NULL),(31,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,2,NULL),(32,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,2,NULL),(33,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,3,NULL),(34,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,3,NULL),(35,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,3,NULL),(36,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,4,NULL),(37,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,4,NULL),(38,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,4,NULL),(39,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,5,NULL),(40,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,5,NULL),(41,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,5,NULL),(42,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,6,NULL),(43,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,6,NULL),(44,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,6,NULL),(45,'isBarcodeMandatory_ForAll_Functions','1','1 => Barcode is mandatpry for sale, issue and return functionalities, 0 => Not mandatory',NULL,NULL,0,0,NULL,7,NULL),(46,'BarcodeMandatory_Categories','Frames, Sunglasses','Comma seperated value of barcode mandatory categories',NULL,NULL,0,0,NULL,7,NULL),(47,'Maximum_Fitting_Charge','500','Maximum fitting charge allowed',NULL,NULL,1,0,2,7,NULL),(48,'showCostPriceInOpticalPendingOrderReport','1','1 => show cost price , 0 = > dont show',NULL,NULL,1,0,2,1,NULL),(49,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,1,NULL),(50,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,2,NULL),(51,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,3,NULL),(52,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,4,NULL),(53,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,5,NULL),(54,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,6,NULL),(55,'categoriesWhichPatientCategoryDiscountApplied','1,2,3,4','Comma seperated values of categories for optical sale each item discount',NULL,NULL,1,0,2,7,NULL),(56,'followUp_Visit_Dates_in_English','<b>Note:</b>Please do visit us on date SIXMONTHSDATE and  ONEYEARDATE for reaching  your vision & glass prescription','text should be in english language,SIXMONTHSDATE,ONEYEARDATE',NULL,NULL,1,0,2,1,NULL),(57,'followUp_Visit_Dates_in_Local','<b>Note:</b>कृपया आपला चस्मा व दृष्टी तपासून घेण्यासाठी दि. SIXMONTHSDATE व  दि. ONEYEARDATE या दिवशी हॉस्पिटलमध्ये पुर्नतपासणीसाठी यावे.','text should be in local language,SIXMONTHSDATE,ONEYEARDATE',NULL,NULL,1,0,2,1,NULL),(58,'FollowUp_Note_Language_Display','','if is active 1 and config value 1  to show 0 means not to show ',NULL,NULL,1,0,2,1,NULL);

--
-- Table structure for table `tbl_mst_goods_purchase_return_reasons_details`
--

CREATE TABLE `tbl_mst_goods_purchase_return_reasons_details` (
  `areasonId` int(11) NOT NULL AUTO_INCREMENT,
  `reason` text,
  `isCustomerOrConsumer` int(11) DEFAULT NULL,
  `customerOrConsumerId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`areasonId`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_goods_purchase_return_reasons_details`
--

INSERT INTO `tbl_mst_goods_purchase_return_reasons_details` VALUES (1,'Damaged',NULL,NULL,'2019-02-28 11:29:15','2019-02-28 11:29:15',1,0,70),(2,'For Other Branch Transfer',NULL,NULL,'2019-02-28 11:29:15','2019-02-28 11:29:15',1,0,70),(3,'Unsold Product',NULL,NULL,'2019-02-28 11:29:15','2019-02-28 11:29:15',1,0,70);

--
-- Table structure for table `tbl_mst_hsn_codes`
--

CREATE TABLE `tbl_mst_hsn_codes` (
  `aHsnId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `hsnCode` varchar(15) DEFAULT NULL,
  `gstPercentage` double DEFAULT NULL,
  `sgstPercentage` double DEFAULT NULL,
  `cgstPercentage` double DEFAULT NULL,
  `igstPercentage` double DEFAULT NULL,
  `nCountryId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDeleted` int(11) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aHsnId_pk`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_hsn_codes`
--

INSERT INTO `tbl_mst_hsn_codes` VALUES (1,'90015000',12,6,6,12,1,'2019-03-20 10:45:35','2019-03-20 10:45:35',1,0,NULL),(2,'9001',12,6,6,12,1,'2019-03-20 10:45:35','2019-03-20 10:45:35',1,0,NULL),(3,'9003',12,6,6,12,1,'2019-03-20 10:45:35','2019-03-20 10:45:35',1,0,NULL),(4,'9005',18,9,9,18,1,'2019-03-25 08:51:50','2019-03-25 08:51:50',1,0,NULL),(5,'900002',0,0,0,0,1,'2019-03-25 08:51:50','2019-03-25 08:51:50',1,0,NULL),(6,'90013000',12,6,6,12,1,'2019-06-28 15:00:57','2019-06-28 15:00:57',1,0,NULL),(7,'33079020',12,6,6,12,1,'2019-06-28 15:01:12','2019-06-28 15:01:12',0,0,NULL),(8,'33079020',18,9,9,18,1,'2020-01-25 17:46:04','2020-01-25 17:46:04',1,0,NULL),(9,'900015000',12,6,6,12,1,'2019-03-20 10:45:35','2019-03-20 10:45:35',1,0,NULL),(10,'90041000',18,9,9,NULL,1,'2020-03-04 15:48:29','2020-03-04 15:48:29',1,0,NULL),(11,'333',10,10,10,10,1,'2020-05-06 13:09:29','2020-05-06 13:09:29',1,0,NULL),(12,'4001',15,12.5,12.5,12.5,1,'2020-06-24 19:26:32','2020-06-24 19:26:32',1,0,NULL),(13,'4005',18,6.87,6.98,7.82,1,'2020-06-24 19:26:54','2020-06-24 19:26:54',1,0,NULL),(14,'4009',25,12.5,12.5,12.5,1,'2020-06-24 19:27:11','2020-06-24 19:27:11',1,0,NULL);

--
-- Table structure for table `tbl_mst_items_details`
--

CREATE TABLE `tbl_mst_items_details` (
  `aItemId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `nCategoryId_fk` int(11) DEFAULT NULL,
  `itemCode` varchar(45) DEFAULT NULL,
  `itemShortCode` varchar(30) DEFAULT NULL,
  `itemName` varchar(250) DEFAULT NULL,
  `customer_desc` varchar(150) DEFAULT NULL,
  `nBrandTypeId_fk` int(11) DEFAULT NULL,
  `itemDescription` varchar(500) DEFAULT NULL,
  `nItemManufacturerId_fk` int(11) DEFAULT NULL,
  `taxability` int(11) DEFAULT NULL,
  `genericName` text,
  `nHsnCodeId_fk` int(11) DEFAULT NULL,
  `ROL` int(11) DEFAULT '0',
  `ROQ` int(11) DEFAULT NULL,
  `UNIT` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `isSingleOrMultiUser_Product` int(11) DEFAULT '0',
  `max_times_multiproduct_to_use` int(11) DEFAULT '0',
  `freeQtyAvail` int(11) DEFAULT NULL,
  `remarks` tinytext,
  `nTypeId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aItemId_pk`),
  KEY `fk_tbl_mst_items_details_1_idx` (`nCategoryId_fk`),
  KEY `fk_tbl_mst_items_details_2_idx` (`nItemManufacturerId_fk`),
  KEY `fk_tbl_mst_items_details_3_idx` (`nUserId_fk`),
  KEY `fk_tbl_mst_items_details_4_idx` (`nHsnCodeId_fk`),
  CONSTRAINT `fk_tbl_mst_items_details_1` FOREIGN KEY (`nCategoryId_fk`) REFERENCES `tbl_mst_category` (`aCategoryId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_items_details_2` FOREIGN KEY (`nItemManufacturerId_fk`) REFERENCES `tbl_mst_manufacturers` (`aManufacturerId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_items_details_3` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_items_details_4` FOREIGN KEY (`nHsnCodeId_fk`) REFERENCES `tbl_mst_hsn_codes` (`aHsnId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_items_details`
--


--
-- Table structure for table `tbl_mst_items_details_fields`
--

CREATE TABLE `tbl_mst_items_details_fields` (
  `aItemfieldId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `nItemId_fk` int(11) DEFAULT NULL,
  `nCatItemId_fk` int(11) DEFAULT NULL,
  `CatFieldName` varchar(250) DEFAULT NULL,
  `CatFieldValue` varchar(500) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `isSingleOrMultiUser_Product` int(11) DEFAULT '0',
  `max_times_multiproduct_to_use` int(11) DEFAULT '0',
  PRIMARY KEY (`aItemfieldId_pk`),
  KEY `fk_tbl_mst_items_details_fields_1_idx` (`nItemId_fk`),
  KEY `fk_tbl_mst_items_details_fields_2_idx` (`nCatItemId_fk`),
  KEY `fk_tbl_mst_items_details_fields_3_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_items_details_fields_1` FOREIGN KEY (`nItemId_fk`) REFERENCES `tbl_mst_items_details` (`aItemId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_items_details_fields_2` FOREIGN KEY (`nCatItemId_fk`) REFERENCES `tbl_mst_category_item_fields` (`aCatItemId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_items_details_fields_3` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_items_details_fields`
--


--
-- Table structure for table `tbl_mst_lens_fitters_details`
--

CREATE TABLE `tbl_mst_lens_fitters_details` (
  `aid` int(11) NOT NULL AUTO_INCREMENT,
  `fitter_name` varchar(500) DEFAULT NULL,
  `isCustomerOrConsumer` int(11) DEFAULT NULL,
  `customerOrConsumerId` int(11) DEFAULT NULL,
  `isDefault_Fitter_ForBranch` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aid`)
) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_lens_fitters_details`
--

INSERT INTO `tbl_mst_lens_fitters_details` VALUES (1,'Essilor India Pvt. Ltd ',2,1,1,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(2,'Essilor India Pvt. Ltd ',2,2,1,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(3,'Essilor India Pvt. Ltd ',2,3,1,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(4,'Essilor India Pvt. Ltd ',2,4,1,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(5,'Essilor India Pvt. Ltd ',2,5,1,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(6,'Essilor India Pvt. Ltd ',2,6,1,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(7,'Essilor India Pvt. Ltd ',2,7,1,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(8,'Spectacular Retails Ventures',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(9,'Spectacular Retails Ventures',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(10,'Spectacular Retails Ventures',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(11,'Spectacular Retails Ventures',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(12,'Spectacular Retails Ventures',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(13,'Spectacular Retails Ventures',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(14,'Spectacular Retails Ventures',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(15,'Ramani Optical',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(16,'Ramani Optical',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(17,'Ramani Optical',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(18,'Ramani Optical',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(19,'Ramani Optical',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(20,'Ramani Optical',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(21,'Ramani Optical',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(22,'Delta Lenses Pvt Ltd ',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(23,'Delta Lenses Pvt Ltd ',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(24,'Delta Lenses Pvt Ltd ',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(25,'Delta Lenses Pvt Ltd ',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(26,'Delta Lenses Pvt Ltd ',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(27,'Delta Lenses Pvt Ltd ',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(28,'Delta Lenses Pvt Ltd ',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(29,'Prime Lenses Pvt Ltd',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(30,'Prime Lenses Pvt Ltd',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(31,'Prime Lenses Pvt Ltd',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(32,'Prime Lenses Pvt Ltd',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(33,'Prime Lenses Pvt Ltd',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(34,'Prime Lenses Pvt Ltd',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(35,'Prime Lenses Pvt Ltd',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(36,'VIPUL WADHEL',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(37,'VIPUL WADHEL',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(38,'VIPUL WADHEL',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(39,'VIPUL WADHEL',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(40,'VIPUL WADHEL',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(41,'VIPUL WADHEL',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(42,'VIPUL WADHEL',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(43,'Yash Optics And Lens Pvt Ltd ',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(44,'Yash Optics And Lens Pvt Ltd ',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(45,'Yash Optics And Lens Pvt Ltd ',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(46,'Yash Optics And Lens Pvt Ltd ',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(47,'Yash Optics And Lens Pvt Ltd ',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(48,'Yash Optics And Lens Pvt Ltd ',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(49,'Yash Optics And Lens Pvt Ltd ',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(50,'Vaishnavi Optical',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(51,'Vaishnavi Optical',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(52,'Vaishnavi Optical',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(53,'Vaishnavi Optical',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(54,'Vaishnavi Optical',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(55,'Vaishnavi Optical',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(56,'Vaishnavi Optical',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(57,'SIDDHI OPTICAL',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(58,'SIDDHI OPTICAL',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(59,'SIDDHI OPTICAL',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(60,'SIDDHI OPTICAL',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(61,'SIDDHI OPTICAL',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(62,'SIDDHI OPTICAL',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(63,'SIDDHI OPTICAL',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(64,'United Sales Agency',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(65,'United Sales Agency',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(66,'United Sales Agency',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(67,'United Sales Agency',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(68,'United Sales Agency',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(69,'United Sales Agency',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(70,'United Sales Agency',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(71,'NAYAN SUKH OPTICIAN',2,1,0,'2019-11-30 11:23:29','2019-11-30 11:23:29',1,0,1),(72,'NAYAN SUKH OPTICIAN',2,2,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(73,'NAYAN SUKH OPTICIAN',2,3,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(74,'NAYAN SUKH OPTICIAN',2,4,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(75,'NAYAN SUKH OPTICIAN',2,5,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(76,'NAYAN SUKH OPTICIAN',2,6,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(77,'NAYAN SUKH OPTICIAN',2,7,0,'2019-12-10 21:47:42','2019-12-10 21:47:42',1,0,1),(78,'Demo',2,-5,1,'2020-04-15 16:35:16','2020-04-15 16:35:16',1,0,1);

--
-- Table structure for table `tbl_mst_lestypes`
--

CREATE TABLE `tbl_mst_lestypes` (
  `aLensType_id` int(11) NOT NULL AUTO_INCREMENT,
  `lensTypeName` varchar(250) DEFAULT NULL,
  `lensTypeCode` varchar(250) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aLensType_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_lestypes`
--

INSERT INTO `tbl_mst_lestypes` VALUES (1,'Glass','Gls','2019-05-16 11:00:59','2019-05-16 11:00:59',1,0,133),(2,'Single Vision','SV','2019-05-16 11:00:59','2019-05-16 11:00:59',1,0,133),(3,'Bifocal','Bi','2019-05-16 12:26:07','2019-05-16 12:26:07',1,0,133),(4,'Progressive','Pgr','2019-05-16 12:26:07','2019-05-16 12:26:07',1,0,133),(5,'Others','oth','2019-05-16 12:26:07','2019-05-16 12:26:07',1,0,133);

--
-- Table structure for table `tbl_mst_locations`
--

CREATE TABLE `tbl_mst_locations` (
  `aLocationId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `locnCode` varchar(10) DEFAULT NULL,
  `locnShortCode` varchar(10) DEFAULT NULL,
  `locnName` varchar(100) DEFAULT NULL,
  `nCountryId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aLocationId_pk`),
  KEY `fk_tbl_mst_locations_1_idx` (`nCountryId_fk`),
  CONSTRAINT `fk_tbl_mst_locations_1` FOREIGN KEY (`nCountryId_fk`) REFERENCES `tbl_mst_countries` (`aCountryId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_locations`
--

INSERT INTO `tbl_mst_locations` VALUES (1,'1002','MH','Maharashtra',1,'2018-10-30 19:52:38','2018-10-30 19:52:38',1,0,70),(2,'1001','PLG','Kolkata',1,'2018-10-30 19:52:38','2018-10-30 19:52:38',1,0,70),(3,'1003','MM','Karnataka',1,'2018-10-30 19:52:38','2018-10-30 19:52:38',1,0,70),(4,'1004','BHY','BHAYNDAR',1,'2018-10-30 19:52:38','2018-10-30 19:52:38',1,0,70);

--
-- Table structure for table `tbl_mst_manufacturers`
--

CREATE TABLE `tbl_mst_manufacturers` (
  `aManufacturerId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `manufacturerCode` varchar(10) DEFAULT NULL,
  `manufacturerShortCode` varchar(10) DEFAULT NULL,
  `manufacturerName` varchar(250) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aManufacturerId_pk`),
  KEY `fk_tbl_mst_manufacturers_1_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_manufacturers_1` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_manufacturers`
--


--
-- Table structure for table `tbl_mst_module_features`
--

CREATE TABLE `tbl_mst_module_features` (
  `aMstModFeatureId` int(11) NOT NULL AUTO_INCREMENT,
  `nModuleId` int(11) DEFAULT NULL,
  `nSubModuleId` int(11) DEFAULT NULL,
  `featureName` varchar(100) DEFAULT NULL,
  `isDeleted` tinyint(4) DEFAULT '0',
  `isActive` tinyint(4) DEFAULT '1',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aMstModFeatureId`),
  UNIQUE KEY `featureName` (`featureName`),
  KEY `fk_tbl_mst_module_features_1_idx` (`nModuleId`),
  KEY `fk_tbl_mst_module_features_2_idx` (`nSubModuleId`),
  CONSTRAINT `fk_tbl_mst_module_features_1` FOREIGN KEY (`nModuleId`) REFERENCES `tbl_modules` (`aModuleId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_module_features_2` FOREIGN KEY (`nSubModuleId`) REFERENCES `tbl_sub_modules` (`aSubModuleId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_mst_module_features`
--


--
-- Table structure for table `tbl_mst_opticalsale_main_status`
--

CREATE TABLE `tbl_mst_opticalsale_main_status` (
  `aStatusId` int(11) NOT NULL AUTO_INCREMENT,
  `Status_Name` varchar(250) DEFAULT NULL,
  `InsertedDate` datetime DEFAULT NULL,
  `LastModifiedDate` datetime DEFAULT NULL,
  `isActive` tinyint(1) DEFAULT NULL,
  `isDelete` tinyint(1) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aStatusId`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_opticalsale_main_status`
--

INSERT INTO `tbl_mst_opticalsale_main_status` VALUES (1,'Inprogress','2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(2,'Ready for Delivery','2018-12-17 10:51:12','2018-12-17 10:51:12',1,0,1),(3,'Delivered','2018-12-17 10:51:12','2018-12-17 10:51:12',1,0,1),(4,'Canceled','2018-12-17 10:51:12','2018-12-17 10:51:12',1,0,1);

--
-- Table structure for table `tbl_mst_opticalsale_payment_mode`
--

CREATE TABLE `tbl_mst_opticalsale_payment_mode` (
  `aPaymentId` int(11) NOT NULL AUTO_INCREMENT,
  `PaymentModeName` varchar(250) DEFAULT NULL,
  `isDefault` tinyint(1) DEFAULT NULL,
  `InsertedDate` datetime DEFAULT NULL,
  `LastModifiedDate` datetime DEFAULT NULL,
  `isActive` tinyint(1) DEFAULT NULL,
  `isDelete` tinyint(1) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aPaymentId`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_opticalsale_payment_mode`
--

INSERT INTO `tbl_mst_opticalsale_payment_mode` VALUES (1,'Cash',1,'2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(2,'Card',1,'2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(3,'Cheque',0,'2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(4,'NEFT',0,NULL,NULL,1,0,1),(5,'PayTm',0,NULL,NULL,1,0,1);

--
-- Table structure for table `tbl_mst_opticalsale_payment_type`
--

CREATE TABLE `tbl_mst_opticalsale_payment_type` (
  `aPaymentTypeId` int(11) NOT NULL AUTO_INCREMENT,
  `PaymentTypeName` varchar(250) DEFAULT NULL,
  `isDefault` tinyint(1) DEFAULT NULL,
  `InsertedDate` datetime DEFAULT NULL,
  `LastModifiedDate` datetime DEFAULT NULL,
  `isActive` tinyint(1) DEFAULT NULL,
  `isDelete` tinyint(1) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aPaymentTypeId`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_opticalsale_payment_type`
--

INSERT INTO `tbl_mst_opticalsale_payment_type` VALUES (1,'Advance',0,'2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(2,'Second Advance',0,'2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(3,'Amt On Delivery',0,'2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(4,'Cancelled',0,'2018-11-29 13:05:52','2018-11-29 13:05:52',0,0,1);

--
-- Table structure for table `tbl_mst_opticalsale_sub_status`
--

CREATE TABLE `tbl_mst_opticalsale_sub_status` (
  `aSubStatusId` int(11) NOT NULL AUTO_INCREMENT,
  `nStatusId` int(10) DEFAULT NULL,
  `SubStatus_Name` varchar(250) DEFAULT NULL,
  `InsertedDate` datetime DEFAULT NULL,
  `LastModifiedDate` datetime DEFAULT NULL,
  `isActive` tinyint(1) DEFAULT NULL,
  `isDelete` tinyint(1) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aSubStatusId`),
  KEY `nStatusId` (`nStatusId`),
  CONSTRAINT `tbl_mst_opticalsale_sub_status_ibfk_1` FOREIGN KEY (`nStatusId`) REFERENCES `tbl_mst_opticalsale_main_status` (`aStatusId`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_opticalsale_sub_status`
--

INSERT INTO `tbl_mst_opticalsale_sub_status` VALUES (1,1,'Open','2018-11-29 13:05:52','2018-11-29 13:05:52',1,0,1),(2,1,'Send to Supplier','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1),(3,1,'Received from Supplier','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1),(4,1,'Fitting','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1),(5,1,'Quality Check','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1),(6,1,'Rejected','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1),(7,2,'Open','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1),(8,3,'Open','2018-12-17 10:52:31','2018-12-17 10:52:31',1,0,1);

--
-- Table structure for table `tbl_mst_paymodes`
--

CREATE TABLE `tbl_mst_paymodes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `payModeName` varchar(250) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_paymodes`
--

INSERT INTO `tbl_mst_paymodes` VALUES (1,'CASH','2019-12-11 11:30:17','2019-12-11 11:30:17',1,0),(2,'NEFT','2019-12-11 11:30:17','2019-12-11 11:30:17',1,0),(3,'IMPS','2019-12-11 11:30:17','2019-12-11 11:30:17',1,0),(4,'REFT','2019-12-11 16:48:22','2019-12-11 16:48:22',1,0),(5,'PhonePy','2019-12-11 18:09:26','2019-12-11 18:09:26',1,0);

--
-- Table structure for table `tbl_mst_registration_type`
--

CREATE TABLE `tbl_mst_registration_type` (
  `aRegTypeId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `regTypeShortCode` varchar(10) DEFAULT NULL,
  `regTypeName` varchar(100) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aRegTypeId_pk`),
  KEY `fk_tbl_mst_registration_type_1_idx` (`nUserId_fk`),
  CONSTRAINT `fk_tbl_mst_registration_type_1` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_registration_type`
--

INSERT INTO `tbl_mst_registration_type` VALUES (1,'RegCode','RegName','2018-10-30 19:59:46','2018-10-30 19:59:46',1,0,70);

--
-- Table structure for table `tbl_mst_supplier`
--

CREATE TABLE `tbl_mst_supplier` (
  `aSupplierId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `nToDepoId` int(11) DEFAULT NULL,
  `nToBranchId` varchar(150) DEFAULT NULL,
  `code` varchar(20) NOT NULL,
  `Supplier_name` varchar(100) NOT NULL,
  `supplyLeadTime` int(11) DEFAULT '0',
  `nBusiness_typeId_fk` int(11) DEFAULT NULL,
  `registration_type` int(11) DEFAULT NULL,
  `GSTIN` varchar(200) DEFAULT NULL,
  `IGSTN` varchar(200) DEFAULT NULL,
  `emailId` varchar(255) NOT NULL,
  `po_emailId` varchar(255) NOT NULL,
  `pan_no` varchar(30) NOT NULL,
  `drugl_no` varchar(200) NOT NULL,
  `nLocationId_fk` int(11) DEFAULT NULL,
  `credit_period` int(11) DEFAULT NULL,
  `com_address` varchar(255) DEFAULT NULL,
  `po_address` varchar(255) DEFAULT NULL,
  `contact_person` varchar(50) NOT NULL,
  `designation` varchar(50) DEFAULT NULL,
  `mobile_no` varchar(10) DEFAULT NULL,
  `phone_no` varchar(15) DEFAULT NULL,
  `alternative_no` varchar(15) DEFAULT NULL,
  `nBankId_fk` int(11) DEFAULT NULL,
  `beneficiary_name` varchar(50) DEFAULT NULL,
  `ac_no` varchar(20) DEFAULT NULL,
  `ifsc` varchar(20) DEFAULT NULL,
  `chequeFavourName` varchar(100) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(1) DEFAULT '1',
  `isDeleted` tinyint(1) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `cin_Numbera` varchar(45) DEFAULT NULL,
  `fax_Numbera` varchar(45) DEFAULT NULL,
  `cin_Number` varchar(45) DEFAULT NULL,
  `fax_Number` varchar(45) DEFAULT NULL,
  `agreementExpiryDate` datetime DEFAULT NULL,
  `gstnRegistered` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`aSupplierId_pk`),
  KEY `fk_tbl_mst_supplier_1_idx` (`nBusiness_typeId_fk`),
  KEY `fk_tbl_mst_supplier_2_idx` (`registration_type`),
  KEY `fk_tbl_mst_supplier_3_idx` (`nLocationId_fk`),
  KEY `fk_tbl_mst_supplier_5_idx` (`nUserId_fk`),
  KEY `fk_tbl_mst_supplier_4` (`nBankId_fk`),
  CONSTRAINT `fk_tbl_mst_supplier_1` FOREIGN KEY (`nBusiness_typeId_fk`) REFERENCES `tbl_mst_business_type` (`aBusinessId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_supplier_2` FOREIGN KEY (`registration_type`) REFERENCES `tbl_mst_registration_type` (`aRegTypeId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_supplier_3` FOREIGN KEY (`nLocationId_fk`) REFERENCES `tbl_mst_locations` (`aLocationId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_supplier_4` FOREIGN KEY (`nBankId_fk`) REFERENCES `tbl_mst_bank` (`aBankId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_mst_supplier_5` FOREIGN KEY (`nUserId_fk`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_supplier`
--


--
-- Table structure for table `tbl_mst_supplier_frametypewise_rol`
--

CREATE TABLE `tbl_mst_supplier_frametypewise_rol` (
  `aid` int(11) NOT NULL AUTO_INCREMENT,
  `nBranchId` int(11) DEFAULT NULL,
  `nSupplierId` int(11) DEFAULT NULL,
  `nFrameTypeId` int(11) DEFAULT NULL,
  `rol_qty` int(11) DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_supplier_frametypewise_rol`
--


--
-- Table structure for table `tbl_mst_taxablility`
--

CREATE TABLE `tbl_mst_taxablility` (
  `ataxableId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `description` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDeleted` int(11) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`ataxableId_pk`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_taxablility`
--

INSERT INTO `tbl_mst_taxablility` VALUES (1,'Taxable','2018-10-30 16:03:18','2018-10-30 16:03:18',1,0,1),(2,'Nil Rated','2018-10-30 16:03:18','2018-10-30 16:03:18',1,0,1),(3,'Exempt','2018-10-30 16:03:18','2018-10-30 16:03:18',1,0,1),(4,'Non GST','2018-10-30 16:03:18','2018-10-30 16:03:18',1,0,1);

--
-- Table structure for table `tbl_mst_types`
--

CREATE TABLE `tbl_mst_types` (
  `aTypeId_pk` int(11) NOT NULL AUTO_INCREMENT,
  `typeName` varchar(100) DEFAULT NULL,
  `nCategoryId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `discount_percentage` float DEFAULT '0',
  PRIMARY KEY (`aTypeId_pk`),
  KEY `fk_tbl_mst_types_1_idx` (`nCategoryId_fk`),
  CONSTRAINT `fk_tbl_mst_types_1` FOREIGN KEY (`nCategoryId_fk`) REFERENCES `tbl_mst_category` (`aCategoryId_pk`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_types`
--

INSERT INTO `tbl_mst_types` VALUES (1,'FULL',1,'2019-08-07 15:53:51','2019-08-07 15:53:51',1,0,NULL,0),(2,'HALF',1,'2019-08-07 15:53:51','2019-08-07 15:53:51',1,0,NULL,0),(3,'RIMLESS',1,'2019-08-07 15:53:51','2019-08-07 15:53:51',1,0,NULL,0),(4,'HALF FRAME',1,'2019-08-07 15:53:51','2019-08-07 15:53:51',0,1,NULL,0),(5,'SUPRA',1,'2019-08-21 13:17:47','2019-08-21 13:17:47',1,0,NULL,0),(6,'HIGH',8,'2019-12-23 12:28:47','2019-12-23 12:28:47',1,0,NULL,0),(7,'MEDIUM',8,'2019-12-23 12:28:47','2019-12-23 12:28:47',1,0,NULL,0),(8,'LOW',8,'2019-12-23 12:28:47','2019-12-23 12:28:47',1,0,NULL,0);

--
-- Table structure for table `tbl_mst_visioninst`
--

CREATE TABLE `tbl_mst_visioninst` (
  `aRow_ID` int(11) NOT NULL AUTO_INCREMENT,
  `tInst_Name` varchar(500) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedTime` datetime DEFAULT NULL,
  `is_active` int(11) DEFAULT NULL,
  PRIMARY KEY (`aRow_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_mst_visioninst`
--

INSERT INTO `tbl_mst_visioninst` VALUES (1,'Distance only ','2017-01-10 16:27:52','2017-01-10 16:27:52',1),(2,'NV only','2017-01-10 16:27:57','2017-01-10 16:27:57',1),(3,'Constant wear','2017-01-10 16:28:14','2017-01-10 16:28:14',1),(4,'Vocation Use','2017-01-10 16:28:46','2017-01-10 16:28:46',1);

--
-- Table structure for table `tbl_mst_visionmaterial`
--

CREATE TABLE `tbl_mst_visionmaterial` (
  `aRow_ID` int(11) NOT NULL AUTO_INCREMENT,
  `tMaterial_Name` varchar(500) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedTime` datetime DEFAULT NULL,
  `is_active` int(11) DEFAULT NULL,
  PRIMARY KEY (`aRow_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_mst_visionmaterial`
--

INSERT INTO `tbl_mst_visionmaterial` VALUES (1,'White','2017-01-06 18:51:47','2017-01-06 18:51:47',1),(2,'Tint','2017-01-06 18:52:04','2017-01-06 18:52:04',1),(3,'Photochromic','2017-01-06 18:52:11','2017-01-06 18:52:11',1),(4,'AR Coat','2017-03-24 19:21:47','2017-03-24 19:21:47',1);

--
-- Table structure for table `tbl_mst_visiontype`
--

CREATE TABLE `tbl_mst_visiontype` (
  `aRow_ID` int(11) NOT NULL AUTO_INCREMENT,
  `tType_Name` varchar(500) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedTime` datetime DEFAULT NULL,
  `is_active` int(11) DEFAULT NULL,
  PRIMARY KEY (`aRow_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_mst_visiontype`
--

INSERT INTO `tbl_mst_visiontype` VALUES (1,'SV','2016-04-07 11:40:28','2016-04-07 11:40:28',0),(2,'CR','2016-04-07 11:40:42','2016-04-07 11:40:42',0),(3,'Kyrptok','2016-04-07 11:41:02','2016-04-07 11:41:02',1),(4,'ARC','2016-04-07 11:41:15','2016-04-07 11:41:15',0),(5,'Executive','2016-04-07 11:41:23','2016-04-07 11:41:23',1),(6,'Photo Chromic','2016-04-07 11:41:38','2016-04-07 11:41:38',0),(7,'D-Type','2017-01-06 18:54:21','2017-01-06 18:54:21',1),(8,'Progressive','2017-01-06 18:54:52','2017-01-06 18:54:52',1),(9,'Monofocal','2017-01-06 18:55:14','2017-01-06 18:55:14',1);

--
-- Table structure for table `tbl_mst_waivers_category`
--

CREATE TABLE `tbl_mst_waivers_category` (
  `a_waivers_category_id` int(11) NOT NULL AUTO_INCREMENT,
  `categorycol_name` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`a_waivers_category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_waivers_category`
--

INSERT INTO `tbl_mst_waivers_category` VALUES (1,'Regular'),(2,'Camp Patient'),(3,'Marketing Activity'),(4,'Others');

--
-- Table structure for table `tbl_mst_waivers_sub_category`
--

CREATE TABLE `tbl_mst_waivers_sub_category` (
  `a_sub_category_id` int(11) NOT NULL AUTO_INCREMENT,
  `sub_category_name` varchar(45) DEFAULT NULL,
  `category_id` int(11) DEFAULT NULL,
  `opti_waiver_percentage` float DEFAULT NULL,
  `is_active` tinyint(4) DEFAULT '1',
  PRIMARY KEY (`a_sub_category_id`)
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_mst_waivers_sub_category`
--

INSERT INTO `tbl_mst_waivers_sub_category` VALUES (1,'Regular',1,50,1),(2,'Free Followup',1,0,1),(3,'Camp Patient',2,0,1),(4,'15 Test Campaign',2,0,1),(5,'Festival Campaign',2,0,1),(6,'DR Activity',3,0,1),(7,'Dus Ka Dum Campaign',3,0,1),(8,'Independence Day Campaign',3,0,1),(9,'Vendor',3,0,1),(10,'TPA',3,0,1),(11,'Employee',3,0,1),(12,'Aunt/Uncle/Cousin',3,0,1),(13,'Government Officials',3,0,1);

--
-- Table structure for table `tbl_optical_sale_each_returns`
--

CREATE TABLE `tbl_optical_sale_each_returns` (
  `aOpticalSaleEachReturnId` int(11) NOT NULL AUTO_INCREMENT,
  `nOpticalSaleMainReturnId` int(11) DEFAULT NULL,
  `nOrderId` int(11) DEFAULT NULL,
  `nOrderDetailsId` int(11) DEFAULT NULL,
  `nGrnId` int(11) DEFAULT '0',
  `nCategoryId` int(11) DEFAULT '0',
  `nBranchId` int(11) DEFAULT '0',
  `nItemId` int(11) DEFAULT NULL,
  `itemName` text,
  `batchNo` varchar(150) DEFAULT NULL,
  `returnQty` int(11) DEFAULT NULL,
  `inStockQty` int(11) DEFAULT NULL,
  `isToIntock` tinyint(4) DEFAULT NULL,
  `returnDate` datetime DEFAULT NULL,
  `returnAmount` float DEFAULT NULL,
  `scannedBarcodeId` int(11) DEFAULT NULL,
  `scannedBarcodeNo` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aOpticalSaleEachReturnId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_optical_sale_each_returns`
--


--
-- Table structure for table `tbl_optical_sale_main_returns`
--

CREATE TABLE `tbl_optical_sale_main_returns` (
  `aOpticalSaleReturnId` int(11) NOT NULL AUTO_INCREMENT,
  `returnNumber` varchar(100) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `nOrderId` int(11) DEFAULT NULL,
  `nPayMainId` int(11) DEFAULT '0',
  `returnDate` datetime DEFAULT NULL,
  `returnAmount` float DEFAULT NULL,
  `returnMode` tinyint(4) DEFAULT NULL,
  `patientDetails` text,
  `saleOrderNumber` varchar(100) DEFAULT NULL,
  `billNumber` varchar(100) DEFAULT NULL,
  `returnRemarks` text,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  `nPatient_Id` int(11) DEFAULT NULL,
  PRIMARY KEY (`aOpticalSaleReturnId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_optical_sale_main_returns`
--


--
-- Table structure for table `tbl_opticalsale_main_payment`
--

CREATE TABLE `tbl_opticalsale_main_payment` (
  `PayId` int(11) NOT NULL AUTO_INCREMENT,
  `OrderId` int(11) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `nPatient_Id` int(11) DEFAULT NULL,
  `TotalQty` int(45) DEFAULT '0',
  `Dis_Perc` int(45) DEFAULT '0',
  `Dis_Amount` float DEFAULT '0',
  `mustPayAdvance_Amount` float DEFAULT '0',
  `asOfPaidAmt` float DEFAULT '0',
  `returnedAmt` float DEFAULT '0',
  `billNumber` varchar(100) DEFAULT NULL,
  `PaymentTypeId` int(11) DEFAULT NULL,
  `PaymentTypeName` varchar(150) DEFAULT NULL,
  `TotalAmt` float DEFAULT '0',
  `grandTotal` float DEFAULT '0',
  `balanceAmt` float DEFAULT '0',
  `is_Credit_Company_Transction` int(10) DEFAULT NULL,
  `Credit_Company_Id` int(10) DEFAULT NULL,
  `Credit_Company_Amt` float DEFAULT NULL,
  `Credit_Company_Status` int(45) DEFAULT NULL,
  `billerId` int(11) DEFAULT '0',
  `Roundoff_Value` varchar(10) DEFAULT '0',
  `Fitting_Charge` float DEFAULT NULL,
  `Cust_GSTIN` varchar(45) DEFAULT NULL,
  `Fitting_by` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDelete` tinyint(1) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`PayId`),
  KEY `OrderId` (`OrderId`,`PaymentTypeId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_opticalsale_main_payment`
--


--
-- Table structure for table `tbl_opticalsale_order_payment_transcation`
--

CREATE TABLE `tbl_opticalsale_order_payment_transcation` (
  `aOrderPaymentTransId` int(11) NOT NULL AUTO_INCREMENT,
  `OrderId` int(10) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `OrderPaymentId` int(10) DEFAULT NULL,
  `OrderPaymentId_EachTran` int(11) DEFAULT NULL,
  `PaymentModeId` int(10) DEFAULT NULL,
  `PaymentModeName` varchar(150) DEFAULT NULL,
  `PaymentTypeId` int(10) DEFAULT NULL,
  `PaymentDate` date DEFAULT NULL,
  `PaymentRemarks` text,
  `PaymentAmount` float DEFAULT NULL,
  `RoundOff` varchar(10) DEFAULT NULL,
  `PaymentCollectedBy` int(11) DEFAULT NULL,
  `CardNumber` varchar(100) DEFAULT NULL,
  `chequeNumber` varchar(100) DEFAULT NULL,
  `checkdate` varchar(100) DEFAULT NULL,
  `ChequeBankName` varchar(100) DEFAULT NULL,
  `ApprovalCode` varchar(100) DEFAULT NULL,
  `BatchNumber` varchar(100) DEFAULT NULL,
  `InsertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `LastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(1) DEFAULT '1',
  `isDelete` tinyint(1) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  `referenceNumb` text,
  PRIMARY KEY (`aOrderPaymentTransId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_opticalsale_order_payment_transcation`
--


--
-- Table structure for table `tbl_opticalsale_order_status_transcation`
--

CREATE TABLE `tbl_opticalsale_order_status_transcation` (
  `aOrderTransId` int(11) NOT NULL AUTO_INCREMENT,
  `OrderId` int(10) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `nPatientId` int(10) DEFAULT NULL,
  `MainStatusId` int(10) DEFAULT NULL,
  `SubStatusId` int(10) DEFAULT NULL,
  `MainStatusName` varchar(150) DEFAULT NULL,
  `SubStatusName` varchar(150) DEFAULT NULL,
  `Remarks` text,
  `isCurrentActive` int(10) DEFAULT NULL,
  `Status_Date` date DEFAULT NULL,
  `InsertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `LastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(1) DEFAULT '1',
  `isDelete` tinyint(1) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aOrderTransId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_opticalsale_order_status_transcation`
--


--
-- Table structure for table `tbl_opticalsale_orderdetails`
--

CREATE TABLE `tbl_opticalsale_orderdetails` (
  `ODId` int(11) NOT NULL AUTO_INCREMENT,
  `nOrderId` int(11) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `OrderCode` varchar(100) DEFAULT NULL,
  `nCategoryId` int(11) DEFAULT NULL,
  `lensTypeId` int(11) DEFAULT NULL,
  `lensTypeName` varchar(250) DEFAULT NULL,
  `ItemCode` varchar(45) DEFAULT NULL,
  `ItemName` varchar(500) DEFAULT NULL,
  `ItemId` int(11) DEFAULT NULL,
  `saleType_GRN_Or_Open` int(11) DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `grn_id` int(11) DEFAULT NULL,
  `expiryDate` varchar(100) DEFAULT NULL,
  `batchNo` varchar(250) DEFAULT NULL,
  `expDateDBForm` datetime DEFAULT NULL,
  `is_Company_Or_Supplier` int(10) DEFAULT NULL,
  `company_As_Supplier_Id` int(10) DEFAULT NULL,
  `nSuppId` int(11) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `nQty` int(11) DEFAULT NULL,
  `returnedQty` int(11) DEFAULT '0',
  `non_in_stock_issuing_qty` int(11) DEFAULT '0',
  `unitSellingPrice` float DEFAULT NULL,
  `cancelledQty` int(11) DEFAULT '0',
  `discountPercent` float DEFAULT NULL,
  `discountAmount` float DEFAULT NULL,
  `item_gst_percent` float DEFAULT NULL,
  `item_gst_rs` float DEFAULT NULL,
  `item_sgst_percent` float DEFAULT NULL,
  `item_sgst_rs` float DEFAULT NULL,
  `item_cgst_percent` float DEFAULT NULL,
  `item_cgst_rs` float DEFAULT NULL,
  `item_igst_percent` float DEFAULT NULL,
  `item_igst_rs` float DEFAULT NULL,
  `item_total_amt_without_gst` float DEFAULT NULL,
  `item_total_amt_with_gst` float DEFAULT NULL,
  `totAmount` float DEFAULT NULL,
  `hsnCode` varchar(250) DEFAULT NULL,
  `isPoRaised` int(11) DEFAULT NULL,
  `poMainId` int(11) DEFAULT NULL,
  `poNumber` varchar(150) DEFAULT NULL,
  `poMailSent_ToSupplier` int(11) DEFAULT NULL,
  `numOfTimesMailSent` int(11) DEFAULT NULL,
  `scannedBarcodeId` int(11) DEFAULT NULL,
  `scannedBarcodeNo` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `nUserId` int(11) DEFAULT NULL,
  `isActive` int(11) DEFAULT '1',
  `isDelete` tinyint(1) DEFAULT '0',
  `customerItemDecName` varchar(45) DEFAULT NULL,
  `purchasePrice` float DEFAULT '0',
  `contractExpiryReturnQty` int(11) DEFAULT '0',
  `contractExpiryStockInQty` int(11) DEFAULT '0',
  PRIMARY KEY (`ODId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_opticalsale_orderdetails`
--


--
-- Table structure for table `tbl_opticalsale_orders`
--

CREATE TABLE `tbl_opticalsale_orders` (
  `OrderId` int(11) NOT NULL AUTO_INCREMENT,
  `nBranchId` int(11) DEFAULT NULL,
  `nOrderAutoId` varchar(150) DEFAULT NULL,
  `returnIds` varchar(150) DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `is_Depo_Id` int(11) DEFAULT NULL,
  `is_Branch_Id` int(11) DEFAULT NULL,
  `saleType_GRN_Or_Open` int(11) DEFAULT NULL,
  `PatientType_EMR_Or_NEMR` int(11) DEFAULT NULL,
  `nPatient_Id` int(10) DEFAULT NULL,
  `nAppoint_Id` int(11) DEFAULT NULL,
  `orderDate` datetime DEFAULT NULL,
  `actDeliveredDate` datetime DEFAULT NULL,
  `expDeliveryDate` datetime DEFAULT NULL,
  `iS_Credit_Company_Transction` int(10) DEFAULT NULL,
  `Credit_Company_Id` int(10) DEFAULT NULL,
  `medicineRxType` int(11) DEFAULT NULL,
  `Current_Main_Status_Id` int(10) DEFAULT NULL,
  `Current_Sub_Statusa_Id` int(10) DEFAULT NULL,
  `isPatientFrame` int(11) DEFAULT NULL,
  `billerId` int(11) DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDelete` tinyint(1) DEFAULT '0',
  `userId` int(11) DEFAULT NULL,
  `returnQtyStatus` int(11) DEFAULT '0',
  `marketingByUser` varchar(100) DEFAULT NULL,
  `verifiedByUser` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`OrderId`),
  KEY `patApptId` (`nPatient_Id`,`nAppoint_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_opticalsale_orders`
--


--
-- Table structure for table `tbl_opticalsale_payment_each_tran`
--

CREATE TABLE `tbl_opticalsale_payment_each_tran` (
  `PayId_each_tran` int(11) NOT NULL AUTO_INCREMENT,
  `bill_num` varchar(150) DEFAULT NULL,
  `OrderId` int(11) DEFAULT NULL,
  `OrderPaymentId` int(11) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `nPatient_Id` int(11) DEFAULT NULL,
  `PaymentDate` date DEFAULT NULL,
  `PaymentTypeId` int(11) DEFAULT NULL,
  `PaymentTypeName` varchar(150) DEFAULT NULL,
  `TotalAmt_paid` float DEFAULT NULL,
  `billerId` int(11) DEFAULT '0',
  `Roundoff_Value` varchar(10) DEFAULT '0',
  `Fitting_Charge` float DEFAULT NULL,
  `Cust_GSTIN` varchar(45) DEFAULT NULL,
  `Fitting_by` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDelete` tinyint(1) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`PayId_each_tran`),
  KEY `PaymentIntex` (`nPatient_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_opticalsale_payment_each_tran`
--


--
-- Table structure for table `tbl_pharma_patients_each_sales`
--

CREATE TABLE `tbl_pharma_patients_each_sales` (
  `aSalesEachId` int(11) NOT NULL AUTO_INCREMENT,
  `nMainSalesId` int(11) DEFAULT NULL,
  `discountAmount` float DEFAULT NULL,
  `nItemExpiryAvailId` int(11) DEFAULT NULL,
  `nItemId` int(11) DEFAULT NULL,
  `nItemRateMstId` int(11) DEFAULT NULL,
  `soldQty` int(11) DEFAULT NULL,
  `waiverAmt` float DEFAULT NULL,
  `taxAmount` float DEFAULT NULL,
  `amtWithoutTax` float DEFAULT NULL,
  `amtWithTax` float DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aSalesEachId`),
  KEY `nItemExpiryAvailId` (`nItemExpiryAvailId`),
  KEY `nItemId` (`nItemId`),
  KEY `nItemRateMstId` (`nItemRateMstId`),
  KEY `nMainSalesId` (`nMainSalesId`),
  KEY `nBranchId` (`nBranchId`),
  CONSTRAINT `tbl_pharma_patients_each_sales_ibfk_1` FOREIGN KEY (`nItemExpiryAvailId`) REFERENCES `tbl_item_grn_module_expire_availability` (`itemAvail_expire_Id`),
  CONSTRAINT `tbl_pharma_patients_each_sales_ibfk_2` FOREIGN KEY (`nItemId`) REFERENCES `tbl_mst_items_details` (`aItemId_pk`),
  CONSTRAINT `tbl_pharma_patients_each_sales_ibfk_3` FOREIGN KEY (`nItemRateMstId`) REFERENCES `tbl_item_rate_master` (`aitemrateId`),
  CONSTRAINT `tbl_pharma_patients_each_sales_ibfk_4` FOREIGN KEY (`nMainSalesId`) REFERENCES `tbl_pharma_patients_main_sales` (`aSalesId`),
  CONSTRAINT `tbl_pharma_patients_each_sales_ibfk_5` FOREIGN KEY (`nBranchId`) REFERENCES `tbl_customer_branch_details` (`abranchId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_pharma_patients_each_sales`
--


--
-- Table structure for table `tbl_pharma_patients_main_sales`
--

CREATE TABLE `tbl_pharma_patients_main_sales` (
  `aSalesId` int(11) NOT NULL AUTO_INCREMENT,
  `saleOrderNumber` varchar(100) DEFAULT NULL,
  `nPatientTypeId` int(11) DEFAULT '1',
  `nPharmaPatientId` int(11) DEFAULT NULL,
  `nPatientId` int(11) DEFAULT NULL,
  `nAppointId` int(11) DEFAULT '0',
  `totalDiscountAmount` float DEFAULT NULL,
  `totalWaiverAmt` float DEFAULT NULL,
  `totalTaxAmount` float DEFAULT NULL,
  `totalAmtWithoutTax` float DEFAULT NULL,
  `totalAmtWithTax` float DEFAULT NULL,
  `totalcashAmt` float DEFAULT '0',
  `totalcardAmt` float DEFAULT '0',
  `otherPayType` int(11) DEFAULT '0',
  `otherPayAmt` float DEFAULT '0',
  `totalroundOff` float DEFAULT '0',
  `totalPaidAmt` float DEFAULT '0',
  `otherPayAmtRefNumber` varchar(100) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aSalesId`),
  KEY `nBranchId` (`nBranchId`),
  CONSTRAINT `tbl_pharma_patients_main_sales_ibfk_1` FOREIGN KEY (`nBranchId`) REFERENCES `tbl_customer_branch_details` (`abranchId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_pharma_patients_main_sales`
--


--
-- Table structure for table `tbl_pharma_patientsregistration`
--

CREATE TABLE `tbl_pharma_patientsregistration` (
  `aPatientPharmaId` int(11) NOT NULL AUTO_INCREMENT,
  `patienttype` int(11) DEFAULT '1',
  `nEmrPatientId` int(11) DEFAULT '0',
  `nEmrApptId` int(11) DEFAULT NULL,
  `emrPatientCode` varchar(100) DEFAULT NULL,
  `patientName` varchar(100) DEFAULT NULL,
  `patientCode` varchar(100) DEFAULT NULL,
  `patientAge` tinyint(4) DEFAULT NULL,
  `gender` varchar(10) DEFAULT NULL,
  `phoneNumber` varchar(10) DEFAULT NULL,
  `email` varchar(50) DEFAULT NULL,
  `address` text,
  `nConsultantId` int(11) DEFAULT NULL,
  `consultantName` varchar(100) DEFAULT NULL,
  `nCategoryId` int(11) DEFAULT NULL,
  `nSubCategoryId` int(11) DEFAULT NULL,
  `nSourceId` int(11) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `isSold` tinyint(4) DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`aPatientPharmaId`),
  KEY `nBranchId` (`nBranchId`),
  CONSTRAINT `tbl_pharma_patientsregistration_ibfk_1` FOREIGN KEY (`nBranchId`) REFERENCES `tbl_customer_branch_details` (`abranchId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_pharma_patientsregistration`
--


--
-- Table structure for table `tbl_pharma_sales_each_returns`
--

CREATE TABLE `tbl_pharma_sales_each_returns` (
  `aSaleEachReturnId` int(11) NOT NULL AUTO_INCREMENT,
  `nMainReturnId` int(11) DEFAULT NULL,
  `nItemId` int(11) DEFAULT NULL,
  `nItemExpireAvailId` int(11) DEFAULT NULL,
  `returnedQty` int(11) DEFAULT NULL,
  `returnedAmt` double DEFAULT NULL,
  `inStock` tinyint(4) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aSaleEachReturnId`),
  KEY `nMainReturnId` (`nMainReturnId`),
  KEY `nUserId` (`nUserId`),
  CONSTRAINT `tbl_pharma_sales_each_returns_ibfk_1` FOREIGN KEY (`nMainReturnId`) REFERENCES `tbl_pharma_sales_main_returns` (`aSaleReturnId`),
  CONSTRAINT `tbl_pharma_sales_each_returns_ibfk_2` FOREIGN KEY (`nUserId`) REFERENCES `tbl_user` (`auserId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_pharma_sales_each_returns`
--


--
-- Table structure for table `tbl_pharma_sales_main_returns`
--

CREATE TABLE `tbl_pharma_sales_main_returns` (
  `aSaleReturnId` int(11) NOT NULL AUTO_INCREMENT,
  `saleReturnNumber` varchar(50) DEFAULT NULL,
  `nMainSaleId` int(11) DEFAULT NULL,
  `mainSaleNumber` varchar(50) DEFAULT NULL,
  `nReturnReasonId` int(11) DEFAULT '0',
  `returnReasonsText` text,
  `saleDate` datetime DEFAULT NULL,
  `returnDate` datetime DEFAULT NULL,
  `returnAmount` double DEFAULT NULL,
  `nReturnedToPatientId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aSaleReturnId`),
  KEY `nMainSaleId` (`nMainSaleId`),
  KEY `nReturnedToPatientId` (`nReturnedToPatientId`),
  KEY `nUserId` (`nUserId`),
  CONSTRAINT `tbl_pharma_sales_main_returns_ibfk_1` FOREIGN KEY (`nMainSaleId`) REFERENCES `tbl_pharma_patients_main_sales` (`aSalesId`),
  CONSTRAINT `tbl_pharma_sales_main_returns_ibfk_2` FOREIGN KEY (`nReturnedToPatientId`) REFERENCES `tbl_pharma_patientsregistration` (`aPatientPharmaId`),
  CONSTRAINT `tbl_pharma_sales_main_returns_ibfk_3` FOREIGN KEY (`nUserId`) REFERENCES `tbl_user` (`auserId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_pharma_sales_main_returns`
--


--
-- Table structure for table `tbl_po_each_item_details`
--

CREATE TABLE `tbl_po_each_item_details` (
  `apoeachid` int(11) NOT NULL AUTO_INCREMENT,
  `npoid_fk` int(11) DEFAULT NULL,
  `typeOfRequest` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `po_from_depo_fk` int(11) DEFAULT NULL,
  `n_poeachid_from_branch_fk` int(11) DEFAULT NULL,
  `is_company_or_supplier` int(11) DEFAULT NULL,
  `po_to_company_or_supplier_id_fk` int(11) DEFAULT NULL,
  `po_to_supplier_id_fk` int(11) DEFAULT NULL,
  `item_id_fk` int(11) DEFAULT NULL,
  `item_code` varchar(50) DEFAULT NULL,
  `item_name` tinytext,
  `categoryid_fk` int(11) DEFAULT NULL,
  `item_hsn_code` varchar(45) DEFAULT NULL,
  `item_free_qty` int(11) DEFAULT NULL,
  `item_order_qty` int(11) DEFAULT NULL,
  `item_unit_price` float DEFAULT NULL,
  `item_discount_percent` float DEFAULT NULL,
  `item_discount_rs` float DEFAULT NULL,
  `item_gst_percent` float DEFAULT NULL,
  `item_gst_rs` float DEFAULT NULL,
  `item_sgst_percent` float DEFAULT NULL,
  `item_sgst_rs` float DEFAULT NULL,
  `item_cgst_percent` float DEFAULT NULL,
  `item_cgst_rs` float DEFAULT NULL,
  `item_igst_percent` float DEFAULT NULL,
  `item_igst_rs` float DEFAULT NULL,
  `item_total_amt_without_gst` float DEFAULT NULL,
  `item_total_amt_with_gst` float DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `poItemStatusId` tinyint(4) DEFAULT NULL,
  `nSupplierItemMapid` int(11) DEFAULT NULL,
  `poItemStatusText` text,
  `po_auth_reason` text,
  `po_authorized_by_fk` int(11) DEFAULT NULL,
  `po_authorized_date` datetime DEFAULT NULL,
  `po_rejected_reason` text,
  `po_rejected_by_fk` int(11) DEFAULT NULL,
  `po_rejected_date` datetime DEFAULT NULL,
  `po_forceclose_reason` text,
  `po_forceclose_by_fk` int(11) DEFAULT NULL,
  `po_forceclose_date` datetime DEFAULT NULL,
  `po_item_brchtrans_status_id` tinyint(4) DEFAULT '0',
  `po_item_brchtrans_status_text` varchar(45) DEFAULT NULL,
  `po_item_brchtrans_reqqty` int(11) DEFAULT NULL,
  `po_item_brchtrans_req_depo_auth_qty` int(11) DEFAULT NULL,
  PRIMARY KEY (`apoeachid`),
  KEY `fk_tbl_ygo_po_each_item_details_1_idx` (`npoid_fk`),
  KEY `fk_tbl_ygo_po_each_item_details_2_idx` (`isconsumer_or_iscustomer`),
  KEY `fk_tbl_ygo_po_each_item_details_3_idx` (`po_from_depo_fk`),
  KEY `fk_tbl_ygo_po_each_item_details_4_idx` (`is_company_or_supplier`),
  KEY `fk_tbl_ygo_po_each_item_details_5_idx` (`po_to_company_or_supplier_id_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_po_each_item_details`
--


--
-- Table structure for table `tbl_po_main_details`
--

CREATE TABLE `tbl_po_main_details` (
  `apoid` int(11) NOT NULL AUTO_INCREMENT,
  `typeOfRequest` int(11) DEFAULT '1',
  `po_number` varchar(30) DEFAULT NULL,
  `categoryid_fk` int(11) DEFAULT NULL,
  `po_type_fk` int(11) DEFAULT NULL,
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `po_from_depo_fk` int(11) DEFAULT NULL,
  `n_poid_from_branch_fk` int(11) DEFAULT '0',
  `po_date` datetime DEFAULT NULL,
  `po_raisedby_fk` int(11) DEFAULT NULL,
  `po_billingaddress` text,
  `po_deliveryaddress` text,
  `po_del_addr_iscustomerorconsumer` int(11) DEFAULT NULL,
  `po_del_addr_customerorconsumerid` int(11) DEFAULT NULL,
  `is_company_or_supplier` int(11) DEFAULT NULL,
  `po_to_company_or_supplier_id_fk` int(11) DEFAULT NULL,
  `po_to_supplier_id_fk` int(11) DEFAULT NULL,
  `gstType` int(11) DEFAULT '0',
  `po_expexted_delivery_date` datetime DEFAULT NULL,
  `po_total_items` int(11) DEFAULT NULL,
  `po_total_items_qty` int(11) DEFAULT NULL,
  `po_total_amount` float DEFAULT NULL,
  `po_total_tax_amount` float DEFAULT NULL,
  `po_total_po_aoumt_withtax` float DEFAULT '0',
  `po_status` int(11) DEFAULT NULL,
  `po_status_text` varchar(45) DEFAULT NULL,
  `reasonForAuthOrRej` text,
  `po_authorized_by_fk` int(11) DEFAULT NULL,
  `po_authorized_date` datetime DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  `poRemarkss` text,
  `po_auth_reason` text,
  `po_rejected_reason` text,
  `po_rejected_by_fk` int(11) DEFAULT NULL,
  `po_rejected_date` datetime DEFAULT NULL,
  `po_forceclose_reason` text,
  `po_forceclose_by_fk` int(11) DEFAULT NULL,
  `po_forceclose_date` datetime DEFAULT NULL,
  `payment_type_id` int(11) DEFAULT NULL COMMENT '										nu		nu',
  `payment_type_name` varchar(45) DEFAULT NULL,
  `payment_days` int(11) DEFAULT NULL,
  PRIMARY KEY (`apoid`),
  KEY `fk_tbl_ygo_po_main-details_1_idx` (`categoryid_fk`),
  KEY `fk_tbl_ygo_po_main-details_2_idx` (`isconsumer_or_iscustomer`),
  KEY `fk_tbl_ygo_po_main-details_3_idx` (`po_from_depo_fk`),
  KEY `fk_tbl_ygo_po_main-details_4_idx` (`is_company_or_supplier`),
  KEY `fk_tbl_ygo_po_main-details_5_idx` (`po_to_company_or_supplier_id_fk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_po_main_details`
--


--
-- Table structure for table `tbl_stock_audit_creation_details`
--

CREATE TABLE `tbl_stock_audit_creation_details` (
  `audit_id` int(11) NOT NULL AUTO_INCREMENT,
  `branch_id` int(11) DEFAULT NULL,
  `branch_name` varchar(250) DEFAULT NULL,
  `audit_name` varchar(250) DEFAULT NULL,
  `start_date` date DEFAULT NULL,
  `end_date` date DEFAULT NULL,
  `start_time` time DEFAULT NULL,
  `end_time` time DEFAULT NULL,
  `audity_id` int(11) DEFAULT NULL,
  `audity_name` varchar(250) DEFAULT NULL,
  `auditor_id` int(11) DEFAULT NULL,
  `auditor_name` varchar(250) DEFAULT NULL,
  `category_Id` int(11) DEFAULT NULL,
  `remarks` text,
  `audit_status_id` int(11) DEFAULT NULL,
  `audit_status_text` varchar(100) DEFAULT NULL,
  `audit_stock_corr_appr_status_id` int(11) DEFAULT NULL,
  `audit_stock_corr_appr_status_text` varchar(100) DEFAULT NULL,
  `audit_stock_corr_appoved_by_id` int(11) DEFAULT NULL,
  `audit_stock_corr_appoved_by_name` varchar(250) DEFAULT NULL,
  `is_within_permisable_level` float(100,0) DEFAULT NULL,
  `mst_permisable_level_config` int(11) DEFAULT NULL,
  `mst_permisable_level_percentage` float(100,0) DEFAULT NULL,
  `mst_permisable_level_qty` int(11) DEFAULT NULL,
  `mst_permisable_level_amount` float(100,0) DEFAULT NULL,
  `deviation_qty` int(11) DEFAULT NULL,
  `deviation_value` float(100,0) DEFAULT NULL,
  `deviation_percentage` float(100,0) DEFAULT NULL,
  `deviation_qty_more_than_inventory` int(11) DEFAULT NULL,
  `deviation_value_more_than_inventory` float DEFAULT NULL,
  `audit_stock_total_qty` int(11) DEFAULT NULL,
  `audit_stock_total_value` float(100,0) DEFAULT NULL,
  `audit_stock_inventory_total_qty` int(11) DEFAULT NULL,
  `audit_stock_inventory_total_value` float(100,0) DEFAULT NULL,
  `audit_inventory_corrn_status_id` int(11) DEFAULT NULL,
  `audit_inventory_corrn_status_text` varchar(100) DEFAULT NULL,
  `remarks_complete` text,
  `nUserId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`audit_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_audit_creation_details`
--


--
-- Table structure for table `tbl_stock_audit_inventory_corrn_creation_details`
--

CREATE TABLE `tbl_stock_audit_inventory_corrn_creation_details` (
  `audit_id_st_corrn` int(11) NOT NULL AUTO_INCREMENT,
  `naudit_id` int(11) DEFAULT NULL,
  `branch_id` int(11) DEFAULT NULL,
  `branch_name` varchar(250) DEFAULT NULL,
  `category_Id` int(11) DEFAULT NULL,
  `remarks` text,
  `deviation_qty` int(11) DEFAULT NULL,
  `deviation_value` float(100,0) DEFAULT NULL,
  `deviation_percentage` float(100,0) DEFAULT NULL,
  `deviation_qty_more_than_inventory` int(11) DEFAULT NULL,
  `deviation_value_more_than_inventory` float DEFAULT NULL,
  `audit_stock_total_qty` int(11) DEFAULT NULL,
  `audit_stock_total_value` float(100,0) DEFAULT NULL,
  `audit_stock_inventory_total_qty` int(11) DEFAULT NULL,
  `audit_stock_inventory_total_value` float(100,0) DEFAULT NULL,
  `nUserId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`audit_id_st_corrn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_audit_inventory_corrn_creation_details`
--


--
-- Table structure for table `tbl_stock_audit_inventory_corrn_item_barcode_details`
--

CREATE TABLE `tbl_stock_audit_inventory_corrn_item_barcode_details` (
  `a_stk_aud_barcode_id_st_corrn` int(11) NOT NULL AUTO_INCREMENT,
  `n_audit_id` int(11) DEFAULT NULL,
  `n_stock_corrn_id` int(11) DEFAULT NULL,
  `isconsumerorcustomer` int(11) DEFAULT NULL,
  `consumerorcustomerid` int(11) DEFAULT NULL,
  `n_barcode_det_id` int(11) DEFAULT NULL,
  `item_id` int(11) DEFAULT NULL,
  `grn_id` int(11) DEFAULT NULL,
  `barcode_number` varchar(150) DEFAULT NULL,
  `nUserId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  PRIMARY KEY (`a_stk_aud_barcode_id_st_corrn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_audit_inventory_corrn_item_barcode_details`
--


--
-- Table structure for table `tbl_stock_audit_inventory_corrn_item_grn_and_expiry_all_details`
--

CREATE TABLE `tbl_stock_audit_inventory_corrn_item_grn_and_expiry_all_details` (
  `a_stk_aud_item_id_st_corrn` int(11) NOT NULL AUTO_INCREMENT,
  `n_audit_id` int(11) DEFAULT NULL,
  `n_stock_corrn_id` int(11) DEFAULT NULL,
  `isconsumerorcustomer` int(11) DEFAULT NULL,
  `consumerorcustomerid` int(11) DEFAULT NULL,
  `item_id` int(11) DEFAULT NULL,
  `item_name` varchar(500) DEFAULT NULL,
  `item_code` varchar(500) DEFAULT NULL,
  `grn_id` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `category_Id` int(11) DEFAULT NULL,
  `is_Batch_Num_Exp_Category` tinyint(4) DEFAULT NULL,
  `item_avail_or_avail_batch_exp_id` int(11) DEFAULT NULL,
  `item_inventory_avail_qty` int(11) DEFAULT NULL,
  `item_inventory_audit_actual_qty` int(11) DEFAULT NULL,
  `item_qty_difference` int(11) DEFAULT NULL,
  `nUserId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`a_stk_aud_item_id_st_corrn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_audit_inventory_corrn_item_grn_and_expiry_all_details`
--


--
-- Table structure for table `tbl_stock_audit_item_barcode_details`
--

CREATE TABLE `tbl_stock_audit_item_barcode_details` (
  `a_stk_aud_barcode_id` int(11) NOT NULL AUTO_INCREMENT,
  `n_audit_id` int(11) DEFAULT NULL,
  `isconsumerorcustomer` int(11) DEFAULT NULL,
  `consumerorcustomerid` int(11) DEFAULT NULL,
  `is_barcode_audit_done` int(11) DEFAULT NULL,
  `n_barcode_det_id` int(11) DEFAULT NULL,
  `item_id` int(11) DEFAULT NULL,
  `grn_id` int(11) DEFAULT NULL,
  `is_barcode_audit_valid` int(11) DEFAULT NULL,
  `barcode_number` varchar(150) DEFAULT NULL,
  `nUserId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  PRIMARY KEY (`a_stk_aud_barcode_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_audit_item_barcode_details`
--


--
-- Table structure for table `tbl_stock_audit_item_grn_and_expiry_all_details`
--

CREATE TABLE `tbl_stock_audit_item_grn_and_expiry_all_details` (
  `a_stk_aud_item_id` int(11) NOT NULL AUTO_INCREMENT,
  `n_audit_id` int(11) DEFAULT NULL,
  `isconsumerorcustomer` int(11) DEFAULT NULL,
  `consumerorcustomerid` int(11) DEFAULT NULL,
  `is_item_audit_done` int(11) DEFAULT NULL,
  `item_id` int(11) DEFAULT NULL,
  `item_name` varchar(500) DEFAULT NULL,
  `item_code` varchar(500) DEFAULT NULL,
  `grn_id` int(11) DEFAULT NULL,
  `grn_number` varchar(150) DEFAULT NULL,
  `category_Id` int(11) DEFAULT NULL,
  `is_Batch_Num_Exp_Category` tinyint(4) DEFAULT NULL,
  `item_avail_or_avail_batch_exp_id` int(11) DEFAULT NULL,
  `item_inventory_avail_qty` int(11) DEFAULT NULL,
  `item_inventory_audit_actual_qty` int(11) DEFAULT NULL,
  `item_qty_difference` int(11) DEFAULT NULL,
  `is_item_audit_valid` int(11) DEFAULT NULL,
  `nUserId_fk` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`a_stk_aud_item_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_audit_item_grn_and_expiry_all_details`
--


--
-- Table structure for table `tbl_stock_details_daily`
--

CREATE TABLE `tbl_stock_details_daily` (
  `adly_stk_id` int(11) NOT NULL AUTO_INCREMENT,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `depo_Id` int(11) DEFAULT NULL,
  `branch_Id` int(11) DEFAULT NULL,
  `stock_date` date DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `itemName` text,
  `itemCode` varchar(500) DEFAULT NULL,
  `isCompanyOrSupplier` int(11) DEFAULT NULL,
  `vendor_Id` int(11) DEFAULT NULL,
  `vendorName` text,
  `batchNumber` varchar(250) DEFAULT NULL,
  `openingStock` int(11) DEFAULT '0',
  `closingStock` int(11) DEFAULT '0',
  `soldStock` int(11) DEFAULT '0',
  `purchaseStock` int(11) DEFAULT '0',
  `purchaseReturnStock` int(11) DEFAULT '0',
  `salesReturnStock` int(11) DEFAULT '0',
  `purchaseReturnAcceptStock` int(11) DEFAULT '0',
  `saleReturnAcceptStock` int(11) DEFAULT '0',
  `inventory_Corrn_Stock` int(11) DEFAULT '0',
  `openingStock_amt` float DEFAULT '0',
  `closingStock_amt` float DEFAULT '0',
  `soldStock_amt` float DEFAULT '0',
  `purchaseStock_amt` float DEFAULT '0',
  `purchaseReturnStock_amt` float DEFAULT '0',
  `salesReturnStock_amt` float DEFAULT '0',
  `purchaseReturnAcceptStock_amt` float DEFAULT '0',
  `saleReturnAcceptStock_ant` float DEFAULT '0',
  `inventory_Corrn_Stock_amt` float DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT '0',
  PRIMARY KEY (`adly_stk_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_details_daily`
--


--
-- Table structure for table `tbl_stock_details_daily_stock_corrn_history`
--

CREATE TABLE `tbl_stock_details_daily_stock_corrn_history` (
  `adly_stk_id_st_corrn` int(11) NOT NULL AUTO_INCREMENT,
  `nadly_stk_id` int(11) NOT NULL,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `depo_Id` int(11) DEFAULT NULL,
  `branch_Id` int(11) DEFAULT NULL,
  `stock_date` date DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `itemName` text,
  `itemCode` varchar(500) DEFAULT NULL,
  `isCompanyOrSupplier` int(11) DEFAULT NULL,
  `vendor_Id` int(11) DEFAULT NULL,
  `vendorName` text,
  `batchNumber` varchar(250) DEFAULT NULL,
  `openingStock` int(11) DEFAULT '0',
  `closingStock` int(11) DEFAULT '0',
  `soldStock` int(11) DEFAULT '0',
  `purchaseStock` int(11) DEFAULT '0',
  `purchaseReturnStock` int(11) DEFAULT '0',
  `salesReturnStock` int(11) DEFAULT '0',
  `purchaseReturnAcceptStock` int(11) DEFAULT '0',
  `saleReturnAcceptStock` int(11) DEFAULT '0',
  `openingStock_amt` float DEFAULT '0',
  `closingStock_amt` float DEFAULT '0',
  `soldStock_amt` float DEFAULT '0',
  `purchaseStock_amt` float DEFAULT '0',
  `purchaseReturnStock_amt` float DEFAULT '0',
  `salesReturnStock_amt` float DEFAULT '0',
  `purchaseReturnAcceptStock_amt` float DEFAULT '0',
  `saleReturnAcceptStock_ant` float DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`adly_stk_id_st_corrn`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_details_daily_stock_corrn_history`
--


--
-- Table structure for table `tbl_stock_details_monthly`
--

CREATE TABLE `tbl_stock_details_monthly` (
  `amo_stk_id` int(11) NOT NULL AUTO_INCREMENT,
  `Category_Id` int(11) DEFAULT '1',
  `isconsumer_or_iscustomer` int(11) DEFAULT NULL,
  `depo_Id` int(11) DEFAULT NULL,
  `branch_Id` int(11) DEFAULT NULL,
  `year` int(11) DEFAULT NULL,
  `month` int(11) DEFAULT NULL,
  `itemID` int(11) DEFAULT NULL,
  `openingStock` int(11) DEFAULT '0',
  `closingStock` int(11) DEFAULT '0',
  `soldStock` int(11) DEFAULT '0',
  `purchaseStock` int(11) DEFAULT '0',
  `purchaseReturnStock` int(11) DEFAULT '0',
  `salesReturnStock` int(11) DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`amo_stk_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_details_monthly`
--


--
-- Table structure for table `tbl_stock_issue_or_inv_gen_tempsave_details`
--

CREATE TABLE `tbl_stock_issue_or_inv_gen_tempsave_details` (
  `a_si_tempid_pk` int(11) NOT NULL AUTO_INCREMENT,
  `depoId` int(11) DEFAULT NULL,
  `temp_save_date` datetime DEFAULT NULL,
  `branches` varchar(150) DEFAULT NULL,
  `tempData` longtext,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`a_si_tempid_pk`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_stock_issue_or_inv_gen_tempsave_details`
--


--
-- Table structure for table `tbl_sub_module_pemissions`
--

CREATE TABLE `tbl_sub_module_pemissions` (
  `aPermissionId` int(11) NOT NULL AUTO_INCREMENT,
  `permissionName` varchar(500) DEFAULT NULL,
  `displayName` varchar(500) DEFAULT NULL,
  `discription` text,
  `displayOrder` int(11) DEFAULT NULL,
  `nMainModuleId` int(11) DEFAULT NULL,
  `nSubModuleId` int(11) DEFAULT NULL,
  `isActive` int(11) DEFAULT '1',
  `isDeleted` int(11) DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModified` datetime DEFAULT CURRENT_TIMESTAMP,
  `nUserId` int(11) DEFAULT NULL,
  PRIMARY KEY (`aPermissionId`)
) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_sub_module_pemissions`
--

INSERT INTO `tbl_sub_module_pemissions` VALUES (1,'Authorize','Authorize',NULL,NULL,28,31,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(2,'Reject','Reject',NULL,NULL,28,31,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(3,'ForceClose','Force Close',NULL,NULL,28,31,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(4,'otherBranch_DepoStock','OtherBranch DepoStock',NULL,NULL,32,41,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(5,'BranchDashBoard','Branch Dash Board',NULL,NULL,31,39,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(6,'BranchCombinedReport','Branch Combined Report',NULL,NULL,31,40,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(7,'Authorize','Authorize',NULL,NULL,29,35,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(8,'Reject','Reject',NULL,NULL,29,35,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(9,'ForceClose','Force Close',NULL,NULL,29,35,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(10,'UpdatePOMRP','Update PP',NULL,NULL,28,31,1,0,'2019-01-21 13:55:29','2019-01-21 13:55:29',NULL),(11,'allowedToSeeAmountDetails','allowedToSeeAmountDetails',NULL,NULL,30,38,1,0,'2019-08-01 11:23:40','2019-08-01 11:23:40',NULL),(12,'New','New',NULL,NULL,30,38,1,0,'2019-08-01 11:39:14','2019-08-01 11:39:14',NULL),(13,'In Progress & Other','In Progress & Other',NULL,NULL,30,38,1,0,'2019-08-01 11:39:14','2019-08-01 11:39:14',NULL),(14,'Bill Print','Bill Print',NULL,NULL,30,38,1,0,'2019-08-01 11:39:14','2019-08-01 11:39:14',NULL),(15,'Inprogress','Inprogress',NULL,NULL,30,38,1,0,'2019-08-01 11:41:17','2019-08-01 11:41:17',NULL),(16,'Ready for Delivery','Ready for Delivery',NULL,NULL,30,38,1,0,'2019-08-01 11:41:17','2019-08-01 11:41:17',NULL),(17,'Delivered','Delivered',NULL,NULL,30,38,1,0,'2019-08-01 11:41:17','2019-08-01 11:41:17',NULL),(18,'Canceled','Canceled',NULL,NULL,30,38,1,0,'2019-08-01 11:41:17','2019-08-01 11:41:17',NULL),(19,'Open','Open',NULL,NULL,30,38,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(20,'Send to Supplier','Send to Supplier',NULL,NULL,30,38,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(21,'Received from Supplier','Received from Supplier',NULL,NULL,30,38,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(22,'Fitting','Fitting',NULL,NULL,30,38,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(23,'Quality Check','Quality Check',NULL,NULL,30,38,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(24,'Rejected','Rejected',NULL,NULL,30,38,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(25,'isCompletedApprovalPermit','isCompletedApprovalPermit',NULL,NULL,34,71,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(26,'Edit_Payment_Mode','Edit Payment Mode',NULL,NULL,30,38,1,0,'2019-08-01 11:39:14','2019-08-01 11:39:14',NULL),(27,'branchWiseOutStand','Branch Wise OutStand',NULL,NULL,35,77,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(28,'vendorPayment','Supplier Payment',NULL,NULL,35,77,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(29,'SupplierWiseOutStand','Supplier Wise OutStand',NULL,NULL,35,77,1,0,'2019-08-01 11:45:53','2019-08-01 11:45:53',NULL),(30,'Discount Edit','Discount Edit',NULL,NULL,30,38,1,0,'2022-01-29 15:55:28','2022-01-29 15:55:28',NULL),(33,'deliveryTotalAmountPay','ZeroBalanceAmtforDelivery',NULL,NULL,30,38,1,0,'2022-03-26 11:45:58','2022-03-26 11:45:58',NULL),(35,'Purchase GST Percentage Report','Purchase GST Percentage Report',NULL,NULL,31,80,1,0,'2023-06-06 11:38:53','2023-06-06 11:38:53',NULL),(36,'Cancel Contract Expiry Order','Cancel Contract Expiry Order',NULL,NULL,33,46,1,0,'2023-08-18 13:36:57','2023-08-18 13:36:57',NULL);

--
-- Table structure for table `tbl_sub_modules`
--

CREATE TABLE `tbl_sub_modules` (
  `aSubModuleId` int(11) NOT NULL AUTO_INCREMENT,
  `nModuleId` int(11) DEFAULT NULL,
  `priority` float NOT NULL,
  `submoduleName` varchar(100) DEFAULT NULL,
  `submoduleNameForMobile` varchar(100) DEFAULT NULL,
  `isMobileOrWeb` int(11) DEFAULT NULL,
  `fnOnClick` varchar(250) NOT NULL COMMENT 'This is the function name that will be triggered (in js) on click of a link in jsp',
  `submoduleIcon` varchar(45) DEFAULT NULL,
  `fnOnClickForMobile` varchar(250) DEFAULT NULL,
  `submoduleIconForMobile` varchar(100) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedDate` datetime DEFAULT NULL,
  `isActive` int(11) DEFAULT NULL,
  `isDeleted` int(11) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  `iscompanyorcustomerUser` int(11) DEFAULT NULL,
  PRIMARY KEY (`aSubModuleId`),
  UNIQUE KEY `moduleName_UNIQUE` (`submoduleName`),
  KEY `fk_tblModules_1_idx` (`nUserId`),
  KEY `fk_tblModules_2` (`nModuleId`),
  CONSTRAINT `fk_tblsubModules_1` FOREIGN KEY (`nUserId`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tblsubModules_2` FOREIGN KEY (`nModuleId`) REFERENCES `tbl_modules` (`aModuleId`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tbl_sub_modules`
--

INSERT INTO `tbl_sub_modules` VALUES (25,25,1.1,'UserCreation','UserCreation',1,'users','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(26,25,1.2,'Category Field Master','Category Field Master',1,'category_field_master','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,0),(28,26,1.2,'UserLists','UserList',NULL,'users','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(29,25,1.3,'Item Registration','Item Registration',1,'itemregistration','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(30,25,1.4,'Item Rate Master','Item Rate Master',1,'itemratemaster','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(31,28,2.1,'Raise PO','Raise PO',1,'raisepurchaseorder','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(32,28,2.2,'GRN','GRN',1,'po_grn','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(33,28,2.3,'Stock Issue','Stock Issue',1,'po_generate_invoice','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(34,28,2.4,'GRN / Accept Invoice','GRN / Accept Invoice',1,'po_grn_accept_invoice','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(35,29,3.1,'Raise Indent','Raise Indent',NULL,'raise_indent','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(37,29,3.2,'Stock Accept','Stock Accept',NULL,'indent_grn_accept_invoice','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(38,30,4.1,'Patient Sale','Patient Sale',NULL,'optical_sale','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(39,31,5.1,'Dashboard','Dashboard',NULL,'report_dashboard','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(40,31,5.2,'Optical Sale Report','Optical Sale Report',NULL,'report_combinedreport','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(41,32,6.1,'Items In Stock','Items In Stock',NULL,'invenorty_itemstock','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(44,33,7.1,'Return Items','Return Items',1,'return_items','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(45,33,7.2,'Accept Return Items','Accept Return Items',1,'accept_return_items','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(46,33,7.3,'Sales Return','Sales Return',1,'salesReturns','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(47,30,4.2,'Pharmacy Sale','Pharmacy Sale',NULL,'pharmacysales','fa fa-tasks',NULL,NULL,NULL,NULL,0,0,31,1),(48,31,5,'Sales Summery Reports','Sales Reports',NULL,'salesreport','fa fa-tasks',NULL,NULL,NULL,NULL,0,0,31,1),(49,33,7,'Pharma Sales Returns','Pharma Sales Returns',NULL,'salesreturns','fa fa-tasks',NULL,NULL,NULL,NULL,0,0,31,1),(50,31,5.3,'Consumption Report','Consumption Report',NULL,'consumption_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,31,1),(51,31,5.4,'Optical Conversion report','Optical Conversion report',NULL,'optical_conversion_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,133,1),(52,31,5.5,'Pharmacy Conversion report','Pharmacy Conversion report',NULL,'pharmacy_conversion_report','fa fa-tasks',NULL,NULL,NULL,NULL,0,0,133,1),(53,31,5.5,'GRN Report','GRN Report',NULL,'grn_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(54,31,5.6,'Sale Report','Pharma Item Sale Report',NULL,'pharmacyitemwisesale_report','fa fa-tasks',NULL,NULL,NULL,NULL,0,0,NULL,1),(55,31,5.7,'Drug  Report','Pharma Drug Details Report',NULL,'pharma_drug_details_report','fa fa-tasks',NULL,NULL,NULL,NULL,0,0,NULL,1),(56,31,5.8,'Optical Credit Billing','Optical Credit Billing',NULL,'optical_credit_billing','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(57,31,5.8,'Lens Order Report','Lense Not In Stock Report',NULL,'lens_not_in_stock_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(58,31,5.9,'Item Return Report','Item Return Report',NULL,'item_return_report','fa fa-tasks',NULL,NULL,'2019-05-07 21:18:48','2019-05-07 21:18:48',1,0,NULL,1),(59,31,6,'Branch Return Report','Item Return Report',NULL,'branch_return_report','fa fa-tasks',NULL,NULL,'2019-05-07 21:18:48','2019-05-07 21:18:48',1,0,NULL,1),(60,31,6.1,'Stock Issue Report','Stock Issue Report',NULL,'stock_issue_report','fa fa-tasks',NULL,NULL,'2019-05-07 21:18:48','2019-05-07 21:18:48',1,0,NULL,1),(61,25,1.5,'PO Masters','PO Masters',NULL,'po_masters','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(62,31,5.1,'Barcode Inventory Report','Barcode Inventory Report',1,'barcode_inventory_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(63,31,5.12,'Optical Pending Order Report','Optical Pending Order Report',1,'optical_pending_order_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(64,31,5.13,'Product Profit Margin Report','Product Profit Margin Report',1,'product_profit_margin_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(65,31,5.14,'Salesman Productivity Report','Salesman Productivity Report',1,'salesman_productivity_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(66,31,5.15,'Optical Flash Dashboard','Optical Flash Dashboard',NULL,'optical_flash_dashboard','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(67,31,5.16,'Optical Sale GST Report','Optical Sale GST Report',1,'optical_sale_gst_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(68,28,2.5,'Branch Transfers','Branch Transfers',1,'branch_transfer_depo','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(69,31,5.17,'Fast Moving Frames','Fast Moving Frames',1,'fast_moving_frames','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(70,34,1,'Create Audit','Create Audit',NULL,'create_audit','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(71,34,2,'Stock Entry','Stock Entry',NULL,'stock_entry','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(72,34,3,'Stock Reconcile','Stock Reconcile',NULL,'stock_reconcile','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(73,31,5.17,'Audit Report','Audit Report',NULL,'audit_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(74,31,5.18,'Fitters Order Report','Fitters Order Report',NULL,'fitters_order_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(75,31,5.19,'Optical Gross Margin Report','Optical Gross Margin Report',NULL,'optical_gross_margin_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(76,31,5.1,'Barcode Age Report','Barcode Age Report',NULL,'barcode_age_report','	fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(77,35,5.2,'Supplier Payment','Vendor Payment',NULL,'vendor_payment','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(78,31,5.2,'Supplier Payment Report','Vendor Payment Report',NULL,'vendor_Payment_Report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(79,31,5.9,'GP Tracker','GP Tracker',NULL,'quality_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(80,31,5.21,'Optical GST Reports','Optical GST Reports',NULL,'opticals_sale_gstr1_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,NULL),(81,31,5.22,'Contract Expired Report','Contract Expired Report',NULL,'contract_expired_report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,NULL),(82,31,5.19,'Optical Collection Dashboard','Optical Collection Dashboard',NULL,'optical_collection_dashboard','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(83,28,2.3,'Credit Note','Credit Note',NULL,'credit_Note','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,1),(84,31,5.23,'Credit Note Report','Credit Note Report',NULL,'credit_Note_Report','fa fa-tasks',NULL,NULL,NULL,NULL,1,0,NULL,NULL);

--
-- Table structure for table `tbl_temp`
--

CREATE TABLE `tbl_temp` (
  `Slno` int(11) NOT NULL AUTO_INCREMENT,
  `itemCode` varchar(100) DEFAULT NULL,
  `ItemName` varchar(100) DEFAULT NULL,
  `PurchasePrice` varchar(100) DEFAULT NULL,
  `MRPPrice` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`Slno`)
) ENGINE=InnoDB AUTO_INCREMENT=331 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_temp`
--

INSERT INTO `tbl_temp` VALUES (1,'FR1147','Nuvo/N 9509/Accetate/Full Rim','360','1355'),(2,'FR1148','Nuvo/ N 9532/Accetate/Full Rim','360','1355'),(3,'FR1149','Nuvo/N 9533/Accetate/Full Rim','360','1355'),(4,'FR1150','Nuvo/ N 9536/Accetate/Full Rim','360','1355'),(5,'FR1151','Nuvo/ N 9537/Accetate/Full Rim','360','1355'),(6,'FR1152','Nuvo/ N 9539/Accetate/Full Rim','360','1355'),(7,'FR1027','Ace-X/AX 2913/Tr-90/Full Rim','234','881'),(8,'FR1028','Ace-X/ AX 2915/Tr-90/Full Rim','234','881'),(9,'FR1029','Ace-X/2917/Tr-90/Full Rim','234','881'),(10,'FR1030','Ace-X/2612/Tr-90/Full Rim','234','881'),(11,'FR1031','Ace-X/2618/Tr-90/Full Rim','234','881'),(12,'FR1032','Ace-X/2613/Tr-90/Full Rim','234','881'),(13,'FR1033','Ace-X/2616/Tr-90/Full Rim','234','881'),(14,'FR1143','Nick /Dora/2327/Baby Accetate/Full Rim','396','1490'),(15,'FR1144','Nick /Dora/2328/Baby Accetate/Full Rim','396','1490'),(16,'FR1145','Dora/DR-2432/Baby Accetate/Full Rim','396','1490'),(17,'FR1146','Nick /NK-2648/Baby Accetate/Full Rim','396','1490'),(18,'FR1250','Symphony/S-9701/Metal/HALF RIM','450','1693'),(19,'FR1251','Symphony/S-9702/Metal/HALF RIM','450','1693'),(20,'FR1252','Symphony/S-9703/Metal/Full Rim','450','1693'),(21,'FR1253','Symphony/S-9707/Metal/HALF RIM','450','1693'),(22,'FR1254','Symphony/S-9708/Metal/Full Rim','450','1693'),(23,'FR1255','Symphony/S-9709/Metal/HALF RIM','450','1693'),(24,'FR1256','Symphony/S-9705/Metal/HALF RIM','450','1693'),(25,'FR1257','Symphony/S-11197/Metal/Full Rim','450','1693'),(26,'FR1258','Symphony/S-11195/Metal/Full Rim','450','1693'),(27,'FR1259','Symphony/S-11196/Metal/Full Rim','450','1693'),(28,'FR1260','Symphony/S-11206/Metal/RIMLESS','450','1693'),(29,'FR1261','Symphony/S-11209/Metal/RIMLESS','450','1693'),(30,'FR1262','Symphony/S-11207/Metal/RIMLESS','450','1693'),(31,'FR1263','Symphony/S-11208/Metal/RIMLESS','450','1693'),(32,'FR1264','Symphony/S-11210/Metal/RIMLESS','450','1693'),(33,'FR1265','Symphony/S-11211/Metal/RIMLESS','450','1693'),(34,'FR1266','Symphony/S-11213/Metal/RIMLESS','450','1693'),(35,'FR1267','Symphony/S-11214/Metal/RIMLESS','450','1693'),(36,'FR1268','Symphony/S-11215/Metal/RIMLESS','450','1693'),(37,'FR1269','Symphony/S-11216/Metal/RIMLESS','450','1693'),(38,'FR1270','Symphony/S-11221/Metal/RIMLESS','450','1693'),(39,'FR1034','Ace-X/AX-2678/Metal/HALF RIM','225','847'),(40,'FR1035','Ace-X/AX-2679/Metal/HALF RIM','225','847'),(41,'FR1036','Ace-X/AX-2680/Metal/Full Rim','225','847'),(42,'FR1037','Ace-X/AX-2687/Metal/HALF RIM','225','847'),(43,'FR1038','Ace-X/AX-2683/Metal/','225','847'),(44,'FR1039','Ace-X/AX-2684/Metal/','225','847'),(45,'FR1040','Ace-X/AX-2685/Metal/','225','847'),(46,'FR1042','Ace-X/AX-2688/Metal/HALF RIM','225','847'),(47,'FR1043','Ace-X/AX-2689/Metal/HALF RIM','225','847'),(48,'FR1044','Ace-X/AX-2690/Metal/HALF RIM','225','847'),(49,'FR1045','Ace-X/AX-2691/Metal/HALF RIM','225','847'),(50,'FR1046','Ace-X/AX-2693/Metal/HALF RIM','225','847'),(51,'FR1047','Ace-X/AX-2665/Metal/HALF RIM','225','847'),(52,'FR1048','Ace-X/AX-2666/Metal/HALF RIM','225','847'),(53,'FR1049','Ace-X/AX-2668/Metal/HALF RIM','225','847'),(54,'FR1050','Ace-X/AX-2671/Metal/HALF RIM','225','847'),(55,'FR1051','Ace-X/AX-2672/Metal/HALF RIM','225','847'),(56,'FR1052','Ace-X/AX-2673/Metal/HALF RIM','225','847'),(57,'FR1053','Ace-X/AX-2674/Metal/HALF RIM','225','847'),(58,'FR1054','Ace-X/AX-2675/Metal/HALF RIM','225','847'),(59,'FR1055','Ace-X/AX-2677/Metal/HALF RIM','225','847'),(60,'FR1056','Ace-X/AX-2696/Metal/HALF RIM','225','847'),(61,'FR1057','Ace-X/AX-2697/Metal/HALF RIM','225','847'),(62,'FR1058','Ace-X/AX-2699/Metal/HALF RIM','225','847'),(63,'FR1059','Ace-X/AX-2700/Metal/HALF RIM','225','847'),(64,'FR1060','Ace-X/AX-2701/Metal/HALF RIM','225','847'),(65,'FR1061','Ace-X/AX-2702/Metal/HALF RIM','225','847'),(66,'FR1062','Ace-X/AX-2703/Metal/HALF RIM','225','847'),(67,'FR1063','Ace-X/AX-2705/Metal/HALF RIM','225','847'),(68,'FR1064','Ace-X/AX-2661/Metal/HALF RIM','225','847'),(69,'FR1065','Ace-X/AX 2664/Metal/HALF RIM','225','847'),(70,'FR1136','Modela/MD 1355/Accetate/Full Rim','252','948'),(71,'FR1137','Modela/MD 1404/Accetate/Full Rim','252','948'),(72,'FR1138','Modela/MD 1358/Accetate/Full Rim','252','948'),(73,'FR1139','Modela/ MD 1364/Accetate/Full Rim','252','948'),(74,'FR1140','Modela/ MD 1405/Accetate/Full Rim','252','948'),(75,'FR1141','Modela/ MD 1369/Accetate/Full Rim','252','948'),(76,'FR1142','Modela/ MD 1401/Accetate/Full Rim','252','948'),(77,'FR1235','Sillotti/SL-8174/Accetate/Full Rim','338','1270'),(78,'FR1236','Sillotti/7050/Accetate/Full Rim','338','1270'),(79,'FR1237','Sillotti/7051/Accetate/Full Rim','338','1270'),(80,'FR1238','Sillotti/7060/Accetate/Full Rim','338','1270'),(81,'FR1239','Sillotti/8701/Accetate/Full Rim','338','1270'),(82,'FR1240','Sillotti/8703/Accetate/Full Rim','338','1270'),(83,'FR1241','Sillotti/9134/Accetate/Full Rim','338','1270'),(84,'FR1242','Sillotti/A 8424/Accetate/Full Rim','338','1270'),(85,'FR1243','Sillotti/A8434/Accetate/Full Rim','338','1270'),(86,'FR1244','Sillotti/A8220/Accetate/Full Rim','338','1270'),(87,'FR1245','Sillotti/A8241/Accetate/Full Rim','338','1270'),(88,'FR1246','Sillotti/A8140/Accetate/Full Rim','338','1270'),(89,'FR1247','Sillotti/9135/Accetate/Full Rim','338','1270'),(90,'FR1248','Sillotti/9138/Accetate/Full Rim','338','1270'),(91,'FR1249','Sillotti/8742/Accetate/Full Rim','338','1270'),(92,'FR1078','FCB/7021/Tr-90/Full Rim','360','1355'),(93,'FR1079','FCB/7014/Tr-90/Full Rim','360','1355'),(94,'FR1080','FCB/7015/Tr-90/Full Rim','360','1355'),(95,'FR1082','FCB/2323/Tr-90/Full Rim','360','1355'),(96,'FR1083','FCB/2325/Tr-90/Full Rim','360','1355'),(97,'FR1153','O2 Art/O2-189/Accetate/Full Rim','360','1355'),(98,'FR1154','O2 Art/O2-1919/Accetate/Full Rim','360','1355'),(99,'FR1155','O2 Art/O2-2002/Accetate/Full Rim','360','1355'),(100,'FR1156','O2 Art/O2-2004/Accetate/Full Rim','360','1355'),(101,'FR1157','O2 Art/O2-2005/Accetate/Full Rim','360','1355'),(102,'FR1158','O2 Art/O2-2177/Accetate/Full Rim','360','1355'),(103,'FR1160','O2 Art/O2-2111/Accetate/Full Rim','360','1355'),(104,'FR1161','O2 Art/O2-2110/Accetate/Full Rim','360','1355'),(105,'FR1162','O2 Art/O2-2115/Accetate/Full Rim','360','1355'),(106,'FR1163','O2 Art/O2-2116/Accetate/Full Rim','360','1355'),(107,'FR1164','O2 Art/O2-2118/Accetate/Full Rim','360','1355'),(108,'FR1165','O2 Art/O2-2119/Accetate/Full Rim','360','1355'),(109,'FR1166','O2 Art/O2-2120/Accetate/Full Rim','360','1355'),(110,'FR1167','O2 Art/O2-1953/Accetate/Full Rim','360','1355'),(111,'FR1168','O2 Art/O2-1907/Accetate/Full Rim','360','1355'),(112,'FR1169','O2 Art/O2-2151/Accetate/Full Rim','360','1355'),(113,'FR1170','Ole/HT 55027/Accetate/Full Rim','340','1279'),(114,'FR1171','Ole/HT22109/Accetate/Full Rim','340','1279'),(115,'FR1172','Ole/MS8317/Accetate/Full Rim','340','1279'),(116,'FR1173','Ole/MG1513/Metal/HALF RIM','255','960'),(117,'FR1174','Ole/HT101012/Metal/Full Rim','255','960'),(118,'FR1175','Ole/8804/Accetate/Full Rim','149','560'),(119,'FR1176','Ole/OO4/Metal/HALF RIM','149','560'),(120,'FR1177','Ole/OO5/Metal/HALF RIM','149','560'),(121,'FR1178','Ole/OO2/Metal/HALF RIM','149','560'),(122,'FR1179','Ole/6001/Metal/Full Rim','149','560'),(123,'FR1180','Ole/6002/Metal/Full Rim','149','560'),(124,'FR1181','Ole/DG1115/Metal/HALF RIM','323','1216'),(125,'FR1182','Ole/DG1113/Metal/HALF RIM','323','1216'),(126,'FR1183','Ole/DG1123/Metal/HALF RIM','323','1216'),(127,'FR1184','Ole/SU12029/Metal/Full Rim','404','1519'),(128,'FR1185','Ole/SU12022/Metal/Full Rim','404','1519'),(129,'FR1186','Ole/XH278/Accetate/Full Rim','204','768'),(130,'FR1187','Ole/XHC275/Accetate/Full Rim','204','768'),(131,'FR1188','Ole/HY837/Accetate/Full Rim','468','1759'),(132,'FR1189','Ole/XHC30/Metal/HALF RIM','468','1759'),(133,'FR1190','Ole/XHC25/Accetate/Full Rim','468','1759'),(134,'FR1191','Ole/HY752/Accetate/Full Rim','468','1759'),(135,'FR1192','Ole/HY1712/Tr-90/Full Rim','468','1759'),(136,'FR1193','Ole/SS7019/Accetate/Full Rim','468','1759'),(137,'FR1194','Ole/17017/Metal/Full Rim','468','1759'),(138,'FR1195','Ole/SS7011/Accetate/Full Rim','468','1759'),(139,'FR1196','Ole/HY575F/Accetate/Full Rim','468','1759'),(140,'FR1084','FCB/K7104/Tr-90/RIMLESS','128','480'),(141,'FR1066','Club Finess/CF014/Metal/Full Rim','255','960'),(142,'FR1197','Ole/16004/Tr-90/Full Rim','128','480'),(143,'FR1198','Ole/TR9289/Tr-90/Full Rim','162','608'),(144,'FR1199','Ole/TR9288/Tr-90/Full Rim','162','608'),(145,'FR1200','Ole/YL6017/Tr-90/Full Rim','140','528'),(146,'FR1201','Ole/MA1102/Tr-90/Full Rim','140','528'),(147,'FR1202','Ole/6017/Tr-90/Full Rim','319','1200'),(148,'FR1203','Ole/16142/Tr-90/Full Rim','213','800'),(149,'FR1205','Ole/CR1278/Metal/Full Rim','489','1839'),(150,'FR1206','Ole/CR1279/Metal/HALF RIM','489','1839'),(151,'FR1207','Ole/CR1273/Metal/Full Rim','489','1839'),(152,'FR1208','Ole/IN7119/Metal/HALF RIM','489','1839'),(153,'FR1209','Ole/MO20/Metal/Full Rim','489','1839'),(154,'FR1210','Ole/MS10096/Metal/HALF RIM','489','1839'),(155,'FR1211','Ole/MS10021/Metal/Full Rim','489','1839'),(156,'FR1212','Ole/MS10103/Metal/HALF RIM','489','1839'),(157,'FR1213','Ole/HD17023/Metal/HALF RIM','489','1839'),(158,'FR1214','Ole/DG1126/Metal/HALF RIM','489','1839'),(159,'FR1215','Ole/MO18/Metal/Full Rim','489','1839'),(160,'FR1216','Ole/MO22/Metal/Full Rim','489','1839'),(161,'FR1217','Ole/SS7044/Accetate/Full Rim','489','1839'),(162,'FR1230','Ole/88160/Accetate/Full Rim','489','1839'),(163,'FR1231','Ole/HY1705/Accetate/Full Rim','489','1839'),(164,'FR1232','Ole/MS8304/Accetate/Full Rim','489','1839'),(165,'FR1233','Ole/SS7026/Accetate/Full Rim','489','1839'),(166,'FR1234','Ole/MS8334/Accetate/Full Rim','489','1839'),(167,'FR1271','Ole/SS5101/Accetate/Full Rim','489','1839'),(168,'FR1272','Ole/5128/Accetate/Full Rim','489','1839'),(169,'FR1274','Ole/SS5100/Accetate/Full Rim','489','1839'),(170,'FR1275','Ole/HY 754/Accetate/Full Rim','489','1839'),(171,'FR1276','Ole/SS7038/Accetate/Full Rim','489','1839'),(172,'FR1277','Ole/7025/Accetate/Full Rim','489','1839'),(173,'FR1278','Ole/MS8314/Accetate/Full Rim','489','1839'),(174,'FR1279','Ole/HT 17027/Metal/Full Rim','489','1839'),(175,'FR1280','Ole/3108/Metal/Full Rim','489','1839'),(176,'FR1281','Ole/7012/Metal/HALF RIM','489','1839'),(177,'FR1282','Ole/HD7909/Metal/Full Rim','489','1839'),(178,'FR1283','Ole/7238/Metal/Full Rim','489','1839'),(179,'FR1284','Ole/DC5028/Metal/Full Rim','489','1839'),(180,'FR1067','Club Finess/CF009/Metal/Full Rim','489','1839'),(181,'FR1068','Club Finess/CF013/Metal/HALF RIM','489','1839'),(182,'FR1069','Club Finess/CF015/Metal/HALF RIM','489','1839'),(183,'FR1285','Ole/1045/TITANIUM/RIMLESS','1386','5216'),(184,'FR1286','Ole/1043/TITANIUM/HALF RIM','1386','5216'),(185,'FR1287','Ole/1042/TITANIUM/Full Rim','1386','5216'),(186,'FR1288','Ole/1046/TITANIUM/RIMLESS','1386','5216'),(187,'FR1289','Ole/1030/TITANIUM/RIMLESS','1386','5216'),(188,'FR1290','Ole/1022/TITANIUM/RIMLESS','1386','5216'),(189,'FR1291','Ole/1039/TITANIUM/RIMLESS','1386','5216'),(190,'FR1292','Ole/1027/TITANIUM/RIMLESS','1386','5216'),(191,'FR1293','Ole/1017/TITANIUM/RIMLESS','1386','5216'),(192,'FR1294','Ole/1038/TITANIUM/HALF RIM','1386','5216'),(193,'FR1072','Ole/1008/TITANIUM/HALF RIM','1386','5216'),(194,'FR1296','Ole/1033/TITANIUM/HALF RIM','1386','5216'),(195,'FR1218','Ole/1044/TITANIUM/HALF RIM','1386','5216'),(196,'FR1219','Ole/1036/TITANIUM/RIMLESS','1386','5216'),(197,'FR1220','Ole/1013/TITANIUM/RIMLESS','1386','5216'),(198,'FR1221','Ole/1023/TITANIUM/RIMLESS','1386','5216'),(199,'FR1222','Ole/1025/TITANIUM/RIMLESS','1386','5216'),(200,'FR1223','Ole/1021/TITANIUM/RIMLESS','1386','5216'),(201,'FR1224','Ole/1034/TITANIUM/RIMLESS','1386','5216'),(202,'FR1225','Ole/1028/TITANIUM/RIMLESS','1386','5216'),(203,'FR1226','Ole/1024/TITANIUM/RIMLESS','1386','5216'),(204,'FR1227','Ole/1041/TITANIUM/RIMLESS','1386','5216'),(205,'FR1228','Ole/1035/TITANIUM/RIMLESS','1386','5216'),(206,'FR1229','Ole/1037/TITANIUM/RIMLESS','1386','5216'),(207,'FR1297','SMB/2707/Tr 90/Full Rim','94','352'),(208,'FR1299','SMB/2706/Tr 90/Full Rim','94','352'),(209,'FR1300','Sea Boy/5403/Tr 90/Full Rim','85','320'),(210,'FR1301','Sea Boy/5402/Tr 90/Full Rim','85','320'),(211,'FR1302','Sea Boy/5401/Tr 90/Full Rim','85','320'),(212,'FR1303','Sea Boy/5408/Tr 90/Full Rim','85','320'),(213,'FR1304','Sea Boy/5404/Tr 90/Full Rim','85','320'),(214,'FR1305','Sea Boy/5413/Tr 90/Full Rim','85','320'),(215,'FR1306','Cores/AR 02/Tr 90/Full Rim','81','304'),(216,'FR1307','Cores/Ar 07/Tr 90/Full Rim','81','304'),(217,'FR1308','Cores/AR 01/Tr 90/Full Rim','81','304'),(218,'FR1309','Casino/930/Tr 90/Full Rim','60','224'),(219,'FR1310','Casino/912/Tr 90/Full Rim','60','224'),(220,'FR1311','SMB/1824/Metal/Full Rim','88','329'),(221,'FR1312','SMB/1821/Metal/Full Rim','88','329'),(222,'FR1313','SMB/1841/Metal/Full Rim','88','329'),(223,'FR1314','SMB/1850/Metal/Full Rim','88','329'),(224,'FR1315','SMB/1852/Metal/Full Rim','88','329'),(225,'FR1316','SMB/18007/Tr 90/Full Rim','88','329'),(226,'FR1317','SMB/18027/Tr 90/Full Rim','88','329'),(227,'FR1318','SMB/18056/Tr 90/Full Rim','88','329'),(228,'FR1319','SMB/18028/Tr 90/Full Rim','88','329'),(229,'FR1320','SMB/18004/Tr 90/Full Rim','88','329'),(230,'FR1321','SMB/18016/Tr 90/Full Rim','88','329'),(231,'FR1322','SMB/18011/Tr 90/Full Rim','88','329'),(232,'FR1323','SMB/18003/Tr 90/Full Rim','88','329'),(233,'FR1324','SMB/18057/Tr 90/Full Rim','88','329'),(234,'FR1325','SMB/18026/Tr 90/Full Rim','88','329'),(235,'FR1326','SMB/18001/Tr 90/Full Rim','88','329'),(236,'FR1327','SMB/18038/Tr 90/Full Rim','88','329'),(237,'FR1328','SMB/18024/Tr 90/Full Rim','88','329'),(238,'FR1329','SMB/18022/Tr 90/Full Rim','88','329'),(239,'FR1330','SMB/18002/Tr 90/Full Rim','88','329'),(240,'FR1331','SMB/1822/Metal/Full Rim','94','352'),(241,'FR1332','SMB/1823/Metal/Full Rim','94','352'),(242,'FR1335','SMB/1837/Metal/Full Rim','94','352'),(243,'FR1336','SMB/1845/Metal/Full Rim','94','352'),(244,'FR1337','SMB/1843/Metal/Full Rim','94','352'),(245,'FR1338','SMB/1838/Metal/Full Rim','94','352'),(246,'FR1339','SMB/1842/Metal/Full Rim','94','352'),(247,'FR1340','SMB/1819/Metal/Full Rim','94','352'),(248,'FR1341','SMB/1840/Metal/Full Rim','94','352'),(249,'SG1','Kosch/Sunglass/1001/Full Rim','1422','5940'),(250,'FR1076','Kosch/Sunglass/1002/Full Rim','1062','4436'),(251,'FR1077','Kosch/Sunglass/1003/Full Rim','1242','5188'),(252,'SG28','Kosch/Sunglass/1006/Full Rim','882','3684'),(253,'FR1071','Kosch/Sunglass/1007/Full Rim','882','3684'),(254,'FR1073','Kosch/Sunglass/1009/Full Rim','972','4060'),(255,'FR1070','Kosch/Sunglass/1010/Full Rim','1062','4436'),(256,'SG33','Kosch/Sunglass/1012/Full Rim','1422','5940'),(257,'SG32','Kosch/Sunglass/1014/Full Rim','1422','5940'),(258,'SG38','Kosch/Sunglass/1015/Full Rim','702','2932'),(259,'SG19','Kosch/Sunglass/1018/Full Rim','972','4060'),(260,'SG27','Kosch/Sunglass/2003/Full Rim','972','4060'),(261,'SG25','Kosch/Sunglass/2007/Full Rim','1152','4812'),(262,'SG30','Kosch/Sunglass/2008/Full Rim','882','3684'),(263,'SG29','Kosch/Sunglass/2009/Full Rim','882','3684'),(264,'SG24','Kosch/Sunglass/2010/Full Rim','1152','4812'),(265,'SG34','Kosch/Sunglass/2011/Full Rim','972','4060'),(266,'SG35','Kosch/Sunglass/2012/Full Rim','972','4060'),(267,'SG21','Kosch/Sunglass/2013/Rimless','1152','4812'),(268,'FR1121','Kosch/Frames/3001/Full Rim','972','2222'),(269,'FR1130','Kosch/Frames/3002/Full Rim','1062','2222'),(270,'FR1134','Kosch/Frames/3004/Half Rim','1152','4098'),(271,'FR1117','Kosch/Frames/3005/Full Rim','1152','4850'),(272,'FR1122','Kosch/Frames/3006/Full Rim','1152','4850'),(273,'FR1123','Kosch/Frames/3007/Full Rim','1152','4850'),(274,'FR1125','Kosch/Frames/3009/Full Rim','1152','4098'),(275,'FR1129','Kosch/Frames/3010/Full Rim','882','4850'),(276,'FR1128','Kosch/Frames/3011/Full Rim','882','4850'),(277,'FR1120','Kosch/Frames/4001/Half Rim','882','2970'),(278,'FR1119','Kosch/Frames/4005/Full Rim','792','4098'),(279,'FR1131','Kosch/Frames/4011/Full Rim','972','4850'),(280,'FR1132','Kosch/Frames/4012/Full Rim','882','3534'),(281,'FR1133','Kosch/Frames/4013/Full Rim','882','2970'),(282,'FR1124','Kosch/Frames/4015/Full Rim','792','2970'),(283,'FR1126','Kosch/Frames/4016/Full Rim','972','4850'),(284,'FR1118','Kosch/Frames/4018/Full Rim','882','3692'),(285,'FR1088','Femina Flaunt/Frames/4802/Full Rim','621','4098'),(286,'FR1091','Femina Flaunt/Frames/4851/Full Rim','531','4850'),(287,'FR1097','Femina Flaunt/Frames/4852/Full Rim','531','4850'),(288,'FR1092','Femina Flaunt/Frames/4854/Full Rim','531','4850'),(289,'FR1107','Femina Flaunt/Frames/5801/Full Rim','711','4850'),(290,'FR1087','Femina Flaunt/Frames/5802/Full Rim','711','2970'),(291,'FR1085','Femina Flaunt/Frames/5804/Full Rim','711','4098'),(292,'FR1086','Femina Flaunt/Frames/5806/Full Rim','711','4098'),(293,'FR1104','Femina Flaunt/Frames/5808/Full Rim','711','3534'),(294,'FR1102','Femina Flaunt/Frames/5810/Full Rim','711','2970'),(295,'FR1103','Femina Flaunt/Frames/5812/Full Rim','711','2970'),(296,'FR1105','Femina Flaunt/Frames/6801/Full Rim','711','4850'),(297,'FR1106','Femina Flaunt/Frames/6802/Full Rim','711','2676'),(298,'FR1093','Femina Flaunt/Frames/6006/Full Rim','1071','4030'),(299,'FR1095','Femina Flaunt/Frames/6007/Full Rim','981','3692'),(300,'FR1112','Femina Flaunt/Frames/6008/Full Rim','801','3014'),(301,'FR1099','Femina Flaunt/Frames/6009/Full Rim','1071','4030'),(302,'FR1096','Femina Flaunt/Frames/6010/Full Rim','981','3692'),(303,'FR1113','Femina Flaunt/Frames/6013/Full Rim','981','3692'),(304,'FR1089','Femina Flaunt/Frames/6804/Full Rim','1071','4030'),(305,'FR1110','Femina Flaunt/Frames/7001/Full Rim','981','3692'),(306,'FR1115','Femina Flaunt/Frames/7002/Full Rim','1161','4369'),(307,'FR1090','Femina Flaunt/Frames/7003/Full Rim','1161','4369'),(308,'FR1098','Femina Flaunt/Frames/7006/Full Rim','1161','4369'),(309,'FR1108','Femina Flaunt/Frames/7007/Full Rim','981','3692'),(310,'FR1094','Femina Flaunt/Frames/7009/Full Rim','1071','4030'),(311,'FR1116','Femina Flaunt/Frames/7010/Full Rim','981','3692'),(312,'SG7','Femina Flaunt/Sunglass/8011/Full Rim','1161','4850'),(313,'SG9','Femina Flaunt/Sunglass/8014/Full Rim','1161','4850'),(314,'SG10','Femina Flaunt/Sunglass/8015/Full Rim','1161','4850'),(315,'SG16','Femina Flaunt/Sunglass/9001/Full Rim','981','4098'),(316,'SG4','Femina Flaunt/Sunglass/9002/Full Rim','1161','4850'),(317,'SG14','Femina Flaunt/Sunglass/9003/Full Rim','1161','4850'),(318,'SG6','Femina Flaunt/Sunglass/9004/Full Rim','711','2970'),(319,'SG13','Femina Flaunt/Sunglass/9008/Full Rim','981','4098'),(320,'SG3','Femina Flaunt/Sunglass/9013/Full Rim','981','4098'),(321,'SG5','Femina Flaunt/Sunglass/9014/Full Rim','1161','4850'),(322,'SG8','Femina Flaunt/Sunglass/9019/Full Rim','846','3534'),(323,'SG11','Femina Flaunt/Sunglass/9020/Full Rim','711','2970'),(324,'SG12','Femina Flaunt/Sunglass/9022/Full Rim','711','2970'),(325,'SG15','Femina Flaunt/Sunglass/9024/Full Rim','1161','4850'),(326,'FR1074','Albert Einstein/Frames/1004/Full Rim','621','2337'),(327,'FR1075','Albert Einstein/Frames/1005/Full Rim','711','2676'),(328,'FR1342','PEN READING H','215','809'),(329,'FR1343','PEN READING H','215','809'),(330,'FR1344','PEN READING N','68','256');

--
-- Table structure for table `tbl_temp1`
--

CREATE TABLE `tbl_temp1` (
  `Slno` int(11) NOT NULL AUTO_INCREMENT,
  `itemCode` varchar(100) DEFAULT NULL,
  `ItemName` varchar(100) DEFAULT NULL,
  `PurchasePrice` varchar(100) DEFAULT NULL,
  `MRPPrice` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`Slno`)
) ENGINE=InnoDB AUTO_INCREMENT=106 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_temp1`
--

INSERT INTO `tbl_temp1` VALUES (1,'FR1499','MC AVI-004 GOLD BROWN  METAL SUPRA','330','1241.86'),(2,'FR1500','MC AVI-002 METAL SUPRA BROWN GOLD','330','1241.86'),(3,'FR1501','MC TR-98001FULL FRAME ASSORTED','340','1279.49'),(4,'FR1502','MC TR-88808 ULL FRAME BLACK WHITE','280','1053.7'),(5,'FR1503','MC TR-8689 TR FULL FRAME ASSORTED','240','903.17'),(6,'FR1504','MC TR-005 TR FULL FRAME ASSORTED','330','1241.86'),(7,'FR1505','MC TR-003TR FULL FRAME ASSORTED','330','1241.86'),(8,'FR1506','MC 8180-C TR FULL FRAME ASSORTED','190','715.01'),(9,'FR1507','MC 8175-C TR FULL FRAME ASSORTED','290','1091.33'),(10,'FR1508','MC 8683 TR FULL FRAME ASSORTED','240','903.17'),(11,'FR1509','MC 8173TR FULL FRAME ASSORTED','190','715.01'),(12,'FR1510','MC 8171 FULL FRAME ASSORTED','190','715.01'),(13,'FR1511','MC 8178 FULL FRAME ASSORTED','190','715.01'),(14,'FR1512','MC 8176 FULL FRAME ASSORTED','190','715.01'),(15,'FR1513','MC 6206 FULL FRAME ASSORTED','340','1279.49'),(16,'FR1514','MC TR-98003 TR FULL FRAME ASSORTED','340','1279.49'),(17,'FR1515','MC 8692 FULL FRAME ASSORTED','240','903.17'),(18,'FR1516','MC EP-01 FULL FRAME ASSORTED','340','1279.49'),(19,'FR1517','MC TR-001 TR FULL FRAME ASSORTED','330','1241.86'),(20,'FR1518','MC L-012 TR FULL FRAME ASSORTED','390','1467.65'),(21,'FR1519','MC 6205 TR FULL FRAME ASSORTED','340','1279.49'),(22,'FR1520','MC Q-007 TR FULL FRAME ASSORTED','390','1467.65'),(23,'FR1521','MC 8177 TR FULL FRAME ASSORTED','190','715.01'),(24,'FR1522','MC 8172 TR FULL FRAME ASSORTED','190','715.01'),(25,'FR1523','MC M-2021 SHEET FULL FRAME ASSORTED','290','1091.33'),(26,'FR1524','MC 3121 METAL SUPRA ASSORTED','390','1467.65'),(27,'FR1525','MC 3124 METAL SUPERA ASSORTED','390','1467.65'),(28,'FR1526','MC 3103 METAL FULL FRAME','390','1467.65'),(29,'FR1527','MC 3108 METAL RIMLESS','580','2182.66'),(30,'FR1528','MC 3106 METAL RIMLESS','580','2182.66'),(31,'FR1529','MC 3110 METAL RIMLESS','580','2182.66'),(32,'FR1530','MC 3112 MEATL SUPRA','390','1467.65'),(33,'FR1531','MC 3118 MEATL SUPRA','330','1241.86'),(34,'FR1532','MC 3136 METAL SUPRA','340','1279.49'),(35,'FR1533','MC L-013 TR FULL FRAME','340','1279.49'),(36,'FR1534','MC TR-004 TR FULL FRAME','330','1241.86'),(37,'FR1535','MC EP-006 TR FULL FRAME','340','1279.49'),(38,'FR1536','MC Q-002 TR FULL FRAME','390','1467.65'),(39,'FR1537','MC 957002 METAL SUPRA','390','1467.65'),(40,'FR1538','MC 93306TR FULL FRAME','390','1467.65'),(41,'FR1539','MC 3133 METAL SUPRA','390','1467.65'),(42,'FR1540','MC 5004 METAL FULL FRAME','390','1467.65'),(43,'FR1541','5MC 002 METAL FULL FRAME','390','1467.65'),(44,'FR1542','MC 5001 METAL SUPRA','390','1467.65'),(45,'FR1543','MC 5003 METAL SUPRA','390','1467.65'),(46,'FR1544','MC 5005 METAL SUPRA','390','1467.65'),(47,'FR1545','MC 3125 METAL SUPRA','340','1279.49'),(48,'FR1546','MC 3131 METAL SUPRA','390','1467.65'),(49,'FR1547','MP 4109 SHEET FULL FRAME','690','2596.61'),(50,'FR1548','MP 4107 SHEET FULL FRAME','690','2596.61'),(51,'FR1549','MP 4108 SHEET FULL FRAME','690','2596.61'),(52,'FR1550','MP 4104 SHEET FULL FRAME','590','2220.29'),(53,'FR1551','MP 6002 METAL SUPRA','590','2220.29'),(54,'FR1552','MP 6001 METAL SUPRA','590','2220.29'),(55,'FR1553','MP 6003 METAL SUPRA','590','2220.29'),(56,'FR1554','MP 4106 METAL FULL FRAME','580','2182.66'),(57,'FR1555','MP 4101 METAL SUPRA','690','2596.61'),(58,'FR1556','MP 4105 SHEET FULL FRAME','590','2220.29'),(59,'FR1557','MP 4102 SHEET FULL FRAME','690','2596.61'),(60,'FR1558','M-1028 SHEET FULL FRAME','290','1091.33'),(61,'FR1559',' SC SL1-2501(SIZE-48) METAL SUPRA','240','903.17'),(62,'FR1560','SC SL1-2004(SIZE-48) METAL SUPRA','240','903.17'),(63,'FR1561','SC SL1-2004(SIZE-50) METAL SUPRA','240','903.17'),(64,'FR1562','SC SL1-1502 (SIZE-46)METAL FULL FRAME','190','715.01'),(65,'FR1563','SC SL1-1503 (SIZE-46) METAL FULL FRAME','190','715.01'),(66,'FR1564','SC SL1-1503(SIZE-48) METAL FULL FRAME','190','715.01'),(67,'FR1565','SC SL1-1001(SIZE-50 MEATL FULL FRAME','190','715.01'),(68,'FR1566','SC SL1-1001(SIZE-52)METAL FULL FRAME','190','715.01'),(69,'FR1567','SC SL1-1002 (SIZE-48) METAL FULL FRAME','190','715.01'),(70,'FR1568','SC SL1-1003 (SIZE-52) METAL FULL FRAME','190','715.01'),(71,'FR1569','SC SL1-1003 (SIZE-50) METAL FULL FRAME','190','715.01'),(72,'FR1570','SC SL1-2003 (SIZE-50) METAL SUPRA','240','903.17'),(73,'FR1571','SC SL1-2003 (SIZE-52)METAL SUPRA','240','903.17'),(74,'FR1572','SC SL2-2502 (SIZE-48) METAL SUPRA','240','903.17'),(75,'FR1573','SC SL2-2502 (SIZE-50) METAL SUPRA','240','903.17'),(76,'FR1574','SC SL2-2503 (SIZE-46) METAL SUPRA','240','903.17'),(77,'FR1575','SC SL2-2503(SIZE-48) METAL SUPRA','240','903.17'),(78,'FR1576','SC SL2-2002 (SIZE-50) METAL SUPRA','240','903.17'),(79,'FR1577','SC SL2-2001 (SIZE-52) METAL SUPRA','240','903.17'),(80,'FR1578','SC MOD-1113 SHEET FULL FRAME','390','1467.65'),(81,'FR1579','SC M-106 SHEET FULL FRAME','290','1091.33'),(82,'FR1580','SC 2319 SHEET FULL FRAME','390','1467.65'),(83,'FR1581','SC M-1028 SHEET FULL FRAME','290','1091.33'),(84,'FR1582','SC M-102 SHEET FULL FRAME','290','1091.33'),(85,'FR1583','SC M-7002 SHEET FULL FRAME','290','1091.33'),(86,'FR1584','SC M-116 SHEET FULL FRAME','290','1091.33'),(87,'FR1585','SC M-115 SHEET FULL FRAME','290','1091.33'),(88,'FR1586','SC 1501(SIZE-48) SHEET FULL FRAME','220','827.9'),(89,'FR1587','SC SL2-3012 SHEET FULL FRAME','450','1693.44'),(90,'FR1588','SP SL2-3009 (SIZE-51) SHEET FULL FRAME','450','1693.44'),(91,'FR1589','SP SL2-3009 (SIZE-53) SHEET FULL FRAME','450','1693.44'),(92,'FR1590','SP SL2-3009 (SIZE-51) SHEET FULL FRAME','390','1467.65'),(93,'FR1591','SP SL2-3009 (SIZE-53) SHEET FULL FRAME','390','1467.65'),(94,'FR1592','SP MOD-3005(SIZE-50) SHEET FULL FRAME','390','1467.65'),(95,'FR1593','SP MOD-3004 SHEET FULL FRAME','450','1693.44'),(96,'FR1594','SP MOD-1132 SHEET FULL FRAME','390','1467.65'),(97,'FR1595','SP MOD-3003 SHEET FULL FRAME','390','1467.65'),(98,'FR1596','SP MOD-1122 SHEET FULL FRAME','390','1467.65'),(99,'FR1597','SP MOD-3002 SHEET FULL FRAME','430','1618.18'),(100,'FR1598','SP SL2-3011 SHEET FULL FRAME','450','1693.44'),(101,'FR1599','SP -3008 SHEET FULL FRAME','390','1467.65'),(102,'FR1600','SP SL2-3007(SIZE-50) SHEET FULL FRAME','450','1693.44'),(103,'FR1601','SP SL2-3007(SIZE-52) SHEET FULL FRAME','450','1693.44'),(104,'FR1602','JP M-1033 SHEET FULL FRAME','290','1091.33'),(105,'FR1603','JP JP1-001 SHEET FULL FRAME','280','1053.7');

--
-- Table structure for table `tbl_trans_log`
--

CREATE TABLE `tbl_trans_log` (
  `atransId` int(11) NOT NULL AUTO_INCREMENT,
  `iscompanyorcustomer` int(11) DEFAULT NULL,
  `iscompanyorsupplier` int(11) DEFAULT NULL,
  `ndepotId` int(11) DEFAULT NULL,
  `ncusBranchId` int(11) DEFAULT NULL,
  `nsupplierId` int(11) DEFAULT NULL,
  `transModule` varchar(45) DEFAULT NULL,
  `transItems` text,
  `logMsg` text,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `nUserId_fk` int(11) DEFAULT NULL,
  PRIMARY KEY (`atransId`),
  UNIQUE KEY `atransId_UNIQUE` (`atransId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_trans_log`
--


--
-- Table structure for table `tbl_user`
--

CREATE TABLE `tbl_user` (
  `auserId` int(11) NOT NULL AUTO_INCREMENT,
  `userName` varchar(100) NOT NULL,
  `firstName` varchar(100) DEFAULT NULL,
  `password` varchar(250) NOT NULL,
  `imageName` varchar(500) DEFAULT NULL,
  `role` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDeleted` int(11) DEFAULT '0',
  `isloggedin` int(11) DEFAULT NULL,
  `ndepotId` int(11) DEFAULT NULL,
  `ncusBranchId` int(11) DEFAULT NULL,
  `iscompanyorcustomerUser` int(11) DEFAULT NULL,
  `sessionid` tinytext,
  `authkey` tinytext,
  PRIMARY KEY (`auserId`)
) ENGINE=InnoDB AUTO_INCREMENT=135 DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tbl_user`
--

INSERT INTO `tbl_user` VALUES (133,'depoadmin','depoadmin','$2a$10$QGAb.Epz002OqBrCnsYM3ul260dFy0oQ9u7iSJK.S949XP61OF/wO',NULL,'USER','2019-03-16 16:06:49','2019-03-16 16:06:49',1,0,NULL,NULL,NULL,1,NULL,NULL),(134,'branchadmin','branchadmin','$2a$10$QGAb.Epz002OqBrCnsYM3ul260dFy0oQ9u7iSJK.S949XP61OF/wO',NULL,'USER','2019-03-16 16:08:18','2019-03-16 16:08:18',1,0,NULL,NULL,NULL,2,NULL,NULL);

--
-- Table structure for table `tbl_user_branches_map`
--

CREATE TABLE `tbl_user_branches_map` (
  `aUserBrachesId` int(11) NOT NULL AUTO_INCREMENT,
  `nUserId` int(11) DEFAULT NULL,
  `iscompanyorcustomerUser` int(11) DEFAULT NULL,
  `nBranchId` int(11) DEFAULT NULL,
  `nDepotId` int(11) DEFAULT NULL,
  `nUserRoleId` varchar(45) DEFAULT NULL,
  `isDeleted` tinyint(4) DEFAULT '0',
  `isActive` tinyint(4) DEFAULT '1',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `nPermission` text,
  `nfeaturepermission` text,
  PRIMARY KEY (`aUserBrachesId`),
  KEY `fk_tbl_user_branches_map_1_idx` (`nUserId`),
  KEY `fk_tbl_user_branches_map_2_idx` (`nBranchId`),
  KEY `fk_tbl_user_branches_map_2_idx1` (`nDepotId`),
  CONSTRAINT `fk_tbl_user_branches_map_1` FOREIGN KEY (`nUserId`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

--
-- Dumping data for table `tbl_user_branches_map`
--

INSERT INTO `tbl_user_branches_map` VALUES (1,133,1,0,1,NULL,0,1,'2019-03-16 16:06:49','2019-03-16 16:06:49','{\"permissions\":[{\"label\":\"MAIN NAVIGATION\",\"separator\": \"true\"},{\"label\":\"Masters\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserCreation\", \"route\": \"users\"},{\"label\": \"Category Field Master\", \"route\": \"category_field_master\"},{\"label\": \"Item Registration\", \"route\": \"itemregistration\"},{\"label\": \"Item Rate Master\", \"route\": \"itemratemaster\"},{\"label\": \"PO Masters\", \"route\": \"po_masters\"}]},{\"label\":\"Lists\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserLists\", \"route\": \"users\"}]},{\"label\":\"Lists2\",\"route\":\"dsadf\",\"iconClasses\":\"fa fa-tasks\"},{\"label\":\"Purchase Order\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise PO\", \"route\": \"raisepurchaseorder\"},{\"label\": \"GRN\", \"route\": \"po_grn\"},{\"label\": \"Stock Issue\", \"route\": \"po_generate_invoice\"},{\"label\": \"Branch Transfers\", \"route\": \"branch_transfer_depo\"}]},{\"label\":\"Reports\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Dashboard\", \"route\": \"report_dashboard\"},{\"label\": \"Optical Sale Report\", \"route\": \"report_combinedreport\"},{\"label\": \"Consumption Report\", \"route\": \"consumption_report\"},{\"label\": \"Optical Conversion report\", \"route\": \"optical_conversion_report\"},{\"label\": \"GRN Report\", \"route\": \"grn_report\"},{\"label\": \"Optical Credit Billing\", \"route\": \"optical_credit_billing\"},{\"label\": \"Lens Order Report\", \"route\": \"lens_not_in_stock_report\"},{\"label\": \"Item Return Report\", \"route\": \"item_return_report\"},{\"label\": \"Branch Return Report\", \"route\": \"branch_return_report\"},{\"label\": \"Stock Issue Report\", \"route\": \"stock_issue_report\"},{\"label\": \"Barcode Inventory Report\", \"route\": \"barcode_inventory_report\"},{\"label\": \"Optical Pending Order Report\", \"route\": \"optical_pending_order_report\"},{\"label\": \"Product Profit Margin Report\", \"route\": \"product_profit_margin_report\"},{\"label\": \"Salesman Productivity Report\", \"route\": \"salesman_productivity_report\"},{\"label\": \"Optical Flash Dashboard\", \"route\": \"optical_flash_dashboard\"},{\"label\": \"Optical Sale GST Report\", \"route\": \"optical_sale_gst_report\"},{\"label\": \"Fast Moving Frames\", \"route\": \"fast_moving_frames\"},{\"label\": \"Audit Report\", \"route\": \"audit_report\"},{\"label\": \"Fitters Order Report\", \"route\": \"fitters_order_report\"},{\"label\": \"Optical Gross Margin Report\", \"route\": \"optical_gross_margin_report\"},{\"label\": \"Barcode Age Report\", \"route\": \"barcode_age_report\"}]},{\"label\":\"Inventory\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Items In Stock\", \"route\": \"invenorty_itemstock\"}]},{\"label\":\"Goods Return\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Return Items\", \"route\": \"return_items\"},{\"label\": \"Accept Return Items\", \"route\": \"accept_return_items\"}]}]}','{\"permissionsArr\":[{\"subModuleName\":\"Raise PO\",\"permission\":[{\"pemissionName\":\"UpdatePOMRP\"},{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"},{\"pemissionName\":\"Reject\"}]},{\"subModuleName\":\"Dashboard\",\"permission\":[{\"pemissionName\":\"BranchDashBoard\"}]},{\"subModuleName\":\"Optical Sale Report\",\"permission\":[{\"pemissionName\":\"BranchCombinedReport\"}]},{\"subModuleName\":\"Items In Stock\",\"permission\":[{\"pemissionName\":\"otherBranch_DepoStock\"}]}]}'),(2,134,2,4,0,NULL,0,1,'2019-03-16 16:08:18','2019-03-16 16:08:18','{\"permissions\":[{\"label\":\"MAIN NAVIGATION\",\"separator\": \"true\"},{\"label\":\"Masters\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserCreation\", \"route\": \"users\"},{\"label\": \"Category Field Master\", \"route\": \"category_field_master\"},{\"label\": \"Item Registration\", \"route\": \"itemregistration\"},{\"label\": \"Item Rate Master\", \"route\": \"itemratemaster\"},{\"label\": \"PO Masters\", \"route\": \"po_masters\"}]},{\"label\":\"Lists\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserLists\", \"route\": \"users\"}]},{\"label\":\"Purchase Order\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise PO\", \"route\": \"raisepurchaseorder\"},{\"label\": \"GRN\", \"route\": \"po_grn\"},{\"label\": \"Stock Issue\", \"route\": \"po_generate_invoice\"}]},{\"label\":\"Indent\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise Indent\", \"route\": \"raise_indent\"},{\"label\": \"Stock Accept\", \"route\": \"indent_grn_accept_invoice\"}]},{\"label\":\"Sales\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Patient Sale\", \"route\": \"optical_sale\"}]},{\"label\":\"Reports\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Dashboard\", \"route\": \"report_dashboard\"},{\"label\": \"Optical Sale Report\", \"route\": \"report_combinedreport\"},{\"label\": \"Consumption Report\", \"route\": \"consumption_report\"},{\"label\": \"Optical Conversion report\", \"route\": \"optical_conversion_report\"},{\"label\": \"GRN Report\", \"route\": \"grn_report\"},{\"label\": \"Optical Credit Billing\", \"route\": \"optical_credit_billing\"},{\"label\": \"Lens Order Report\", \"route\": \"lens_not_in_stock_report\"},{\"label\": \"Item Return Report\", \"route\": \"item_return_report\"},{\"label\": \"Branch Return Report\", \"route\": \"branch_return_report\"},{\"label\": \"Stock Issue Report\", \"route\": \"stock_issue_report\"},{\"label\": \"Barcode Inventory Report\", \"route\": \"barcode_inventory_report\"},{\"label\": \"Optical Pending Order Report\", \"route\": \"optical_pending_order_report\"},{\"label\": \"Product Profit Margin Report\", \"route\": \"product_profit_margin_report\"},{\"label\": \"Salesman Productivity Report\", \"route\": \"salesman_productivity_report\"},{\"label\": \"Optical Flash Dashboard\", \"route\": \"optical_flash_dashboard\"},{\"label\": \"Optical Sale GST Report\", \"route\": \"optical_sale_gst_report\"},{\"label\": \"Fast Moving Frames\", \"route\": \"fast_moving_frames\"},{\"label\": \"Audit Report\", \"route\": \"audit_report\"},{\"label\": \"Fitters Order Report\", \"route\": \"fitters_order_report\"},{\"label\": \"Optical Gross Margin Report\", \"route\": \"optical_gross_margin_report\"},{\"label\": \"Barcode Age Report\", \"route\": \"barcode_age_report\"}]},{\"label\":\"Inventory\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Items In Stock\", \"route\": \"invenorty_itemstock\"}]},{\"label\":\"Goods Return\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Return Items\", \"route\": \"return_items\"},{\"label\": \"Sales Return\", \"route\": \"salesReturns\"}]},{\"label\":\"Audit\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Create Audit\", \"route\": \"create_audit\"},{\"label\": \"Stock Entry\", \"route\": \"stock_entry\"},{\"label\": \"Stock Reconcile\", \"route\": \"stock_reconcile\"}]}]}','{\"permissionsArr\":[{\"subModuleName\":\"Raise PO\",\"permission\":[{\"pemissionName\":\"Reject\"},{\"pemissionName\":\"UpdatePOMRP\"},{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"}]},{\"subModuleName\":\"Raise Indent\",\"permission\":[{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"},{\"pemissionName\":\"Reject\"}]},{\"subModuleName\":\"Patient Sale\",\"permission\":[{\"pemissionName\":\"Bill Print\"},{\"pemissionName\":\"Open\"},{\"pemissionName\":\"Rejected\"},{\"pemissionName\":\"New\"},{\"pemissionName\":\"Delivered\"},{\"pemissionName\":\"Fitting\"},{\"pemissionName\":\"Inprogress\"},{\"pemissionName\":\"Send to Supplier\"},{\"pemissionName\":\"In Progress & Other\"},{\"pemissionName\":\"Canceled\"},{\"pemissionName\":\"Quality Check\"},{\"pemissionName\":\"allowedToSeeAmountDetails\"},{\"pemissionName\":\"Ready for Delivery\"},{\"pemissionName\":\"Received from Supplier\"},{\"pemissionName\":\"Edit_Payment_Mode\"}]},{\"subModuleName\":\"Dashboard\",\"permission\":[{\"pemissionName\":\"BranchDashBoard\"}]},{\"subModuleName\":\"Optical Sale Report\",\"permission\":[{\"pemissionName\":\"BranchCombinedReport\"}]},{\"subModuleName\":\"Items In Stock\",\"permission\":[{\"pemissionName\":\"otherBranch_DepoStock\"}]},{\"subModuleName\":\"Stock Entry\",\"permission\":[{\"pemissionName\":\"isCompletedApprovalPermit\"}]}]}'),(3,134,2,1,0,NULL,0,1,'2019-03-16 16:08:18','2019-03-16 16:08:18','{\"permissions\":[{\"label\":\"MAIN NAVIGATION\",\"separator\": \"true\"},{\"label\":\"Masters\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserCreation\", \"route\": \"users\"},{\"label\": \"Category Field Master\", \"route\": \"category_field_master\"},{\"label\": \"Item Registration\", \"route\": \"itemregistration\"},{\"label\": \"Item Rate Master\", \"route\": \"itemratemaster\"},{\"label\": \"PO Masters\", \"route\": \"po_masters\"}]},{\"label\":\"Lists\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserLists\", \"route\": \"users\"}]},{\"label\":\"Purchase Order\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise PO\", \"route\": \"raisepurchaseorder\"},{\"label\": \"GRN\", \"route\": \"po_grn\"},{\"label\": \"Stock Issue\", \"route\": \"po_generate_invoice\"}]},{\"label\":\"Indent\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise Indent\", \"route\": \"raise_indent\"},{\"label\": \"Stock Accept\", \"route\": \"indent_grn_accept_invoice\"}]},{\"label\":\"Sales\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Patient Sale\", \"route\": \"optical_sale\"}]},{\"label\":\"Reports\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Dashboard\", \"route\": \"report_dashboard\"},{\"label\": \"Optical Sale Report\", \"route\": \"report_combinedreport\"},{\"label\": \"Consumption Report\", \"route\": \"consumption_report\"},{\"label\": \"Optical Conversion report\", \"route\": \"optical_conversion_report\"},{\"label\": \"GRN Report\", \"route\": \"grn_report\"},{\"label\": \"Optical Credit Billing\", \"route\": \"optical_credit_billing\"},{\"label\": \"Lens Order Report\", \"route\": \"lens_not_in_stock_report\"},{\"label\": \"Item Return Report\", \"route\": \"item_return_report\"},{\"label\": \"Branch Return Report\", \"route\": \"branch_return_report\"},{\"label\": \"Stock Issue Report\", \"route\": \"stock_issue_report\"},{\"label\": \"Barcode Inventory Report\", \"route\": \"barcode_inventory_report\"},{\"label\": \"Optical Pending Order Report\", \"route\": \"optical_pending_order_report\"},{\"label\": \"Product Profit Margin Report\", \"route\": \"product_profit_margin_report\"},{\"label\": \"Salesman Productivity Report\", \"route\": \"salesman_productivity_report\"},{\"label\": \"Optical Flash Dashboard\", \"route\": \"optical_flash_dashboard\"},{\"label\": \"Optical Sale GST Report\", \"route\": \"optical_sale_gst_report\"},{\"label\": \"Fast Moving Frames\", \"route\": \"fast_moving_frames\"},{\"label\": \"Audit Report\", \"route\": \"audit_report\"},{\"label\": \"Fitters Order Report\", \"route\": \"fitters_order_report\"},{\"label\": \"Optical Gross Margin Report\", \"route\": \"optical_gross_margin_report\"},{\"label\": \"Barcode Age Report\", \"route\": \"barcode_age_report\"}]},{\"label\":\"Inventory\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Items In Stock\", \"route\": \"invenorty_itemstock\"}]},{\"label\":\"Goods Return\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Return Items\", \"route\": \"return_items\"},{\"label\": \"Sales Return\", \"route\": \"salesReturns\"}]},{\"label\":\"Audit\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Create Audit\", \"route\": \"create_audit\"},{\"label\": \"Stock Entry\", \"route\": \"stock_entry\"},{\"label\": \"Stock Reconcile\", \"route\": \"stock_reconcile\"}]}]}','{\"permissionsArr\":[{\"subModuleName\":\"Raise PO\",\"permission\":[{\"pemissionName\":\"Reject\"},{\"pemissionName\":\"UpdatePOMRP\"},{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"}]},{\"subModuleName\":\"Raise Indent\",\"permission\":[{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"},{\"pemissionName\":\"Reject\"}]},{\"subModuleName\":\"Patient Sale\",\"permission\":[{\"pemissionName\":\"Bill Print\"},{\"pemissionName\":\"Open\"},{\"pemissionName\":\"Rejected\"},{\"pemissionName\":\"New\"},{\"pemissionName\":\"Delivered\"},{\"pemissionName\":\"Fitting\"},{\"pemissionName\":\"Inprogress\"},{\"pemissionName\":\"Send to Supplier\"},{\"pemissionName\":\"In Progress & Other\"},{\"pemissionName\":\"Canceled\"},{\"pemissionName\":\"Quality Check\"},{\"pemissionName\":\"allowedToSeeAmountDetails\"},{\"pemissionName\":\"Ready for Delivery\"},{\"pemissionName\":\"Received from Supplier\"},{\"pemissionName\":\"Edit_Payment_Mode\"}]},{\"subModuleName\":\"Dashboard\",\"permission\":[{\"pemissionName\":\"BranchDashBoard\"}]},{\"subModuleName\":\"Optical Sale Report\",\"permission\":[{\"pemissionName\":\"BranchCombinedReport\"}]},{\"subModuleName\":\"Items In Stock\",\"permission\":[{\"pemissionName\":\"otherBranch_DepoStock\"}]},{\"subModuleName\":\"Stock Entry\",\"permission\":[{\"pemissionName\":\"isCompletedApprovalPermit\"}]}]}'),(4,134,2,3,0,NULL,0,1,'2019-03-16 16:08:18','2019-03-16 16:08:18','{\"permissions\":[{\"label\":\"MAIN NAVIGATION\",\"separator\": \"true\"},{\"label\":\"Masters\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserCreation\", \"route\": \"users\"},{\"label\": \"Category Field Master\", \"route\": \"category_field_master\"},{\"label\": \"Item Registration\", \"route\": \"itemregistration\"},{\"label\": \"Item Rate Master\", \"route\": \"itemratemaster\"},{\"label\": \"PO Masters\", \"route\": \"po_masters\"}]},{\"label\":\"Lists\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserLists\", \"route\": \"users\"}]},{\"label\":\"Purchase Order\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise PO\", \"route\": \"raisepurchaseorder\"},{\"label\": \"GRN\", \"route\": \"po_grn\"},{\"label\": \"Stock Issue\", \"route\": \"po_generate_invoice\"}]},{\"label\":\"Indent\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise Indent\", \"route\": \"raise_indent\"},{\"label\": \"Stock Accept\", \"route\": \"indent_grn_accept_invoice\"}]},{\"label\":\"Sales\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Patient Sale\", \"route\": \"optical_sale\"}]},{\"label\":\"Reports\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Dashboard\", \"route\": \"report_dashboard\"},{\"label\": \"Optical Sale Report\", \"route\": \"report_combinedreport\"},{\"label\": \"Consumption Report\", \"route\": \"consumption_report\"},{\"label\": \"Optical Conversion report\", \"route\": \"optical_conversion_report\"},{\"label\": \"GRN Report\", \"route\": \"grn_report\"},{\"label\": \"Optical Credit Billing\", \"route\": \"optical_credit_billing\"},{\"label\": \"Lens Order Report\", \"route\": \"lens_not_in_stock_report\"},{\"label\": \"Item Return Report\", \"route\": \"item_return_report\"},{\"label\": \"Branch Return Report\", \"route\": \"branch_return_report\"},{\"label\": \"Stock Issue Report\", \"route\": \"stock_issue_report\"},{\"label\": \"Barcode Inventory Report\", \"route\": \"barcode_inventory_report\"},{\"label\": \"Optical Pending Order Report\", \"route\": \"optical_pending_order_report\"},{\"label\": \"Product Profit Margin Report\", \"route\": \"product_profit_margin_report\"},{\"label\": \"Salesman Productivity Report\", \"route\": \"salesman_productivity_report\"},{\"label\": \"Optical Flash Dashboard\", \"route\": \"optical_flash_dashboard\"},{\"label\": \"Optical Sale GST Report\", \"route\": \"optical_sale_gst_report\"},{\"label\": \"Fast Moving Frames\", \"route\": \"fast_moving_frames\"},{\"label\": \"Audit Report\", \"route\": \"audit_report\"},{\"label\": \"Fitters Order Report\", \"route\": \"fitters_order_report\"},{\"label\": \"Optical Gross Margin Report\", \"route\": \"optical_gross_margin_report\"},{\"label\": \"Barcode Age Report\", \"route\": \"barcode_age_report\"}]},{\"label\":\"Inventory\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Items In Stock\", \"route\": \"invenorty_itemstock\"}]},{\"label\":\"Goods Return\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Return Items\", \"route\": \"return_items\"},{\"label\": \"Sales Return\", \"route\": \"salesReturns\"}]},{\"label\":\"Audit\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Create Audit\", \"route\": \"create_audit\"},{\"label\": \"Stock Entry\", \"route\": \"stock_entry\"},{\"label\": \"Stock Reconcile\", \"route\": \"stock_reconcile\"}]}]}','{\"permissionsArr\":[{\"subModuleName\":\"Raise PO\",\"permission\":[{\"pemissionName\":\"Reject\"},{\"pemissionName\":\"UpdatePOMRP\"},{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"}]},{\"subModuleName\":\"Raise Indent\",\"permission\":[{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"},{\"pemissionName\":\"Reject\"}]},{\"subModuleName\":\"Patient Sale\",\"permission\":[{\"pemissionName\":\"Bill Print\"},{\"pemissionName\":\"Open\"},{\"pemissionName\":\"Rejected\"},{\"pemissionName\":\"New\"},{\"pemissionName\":\"Delivered\"},{\"pemissionName\":\"Fitting\"},{\"pemissionName\":\"Inprogress\"},{\"pemissionName\":\"Send to Supplier\"},{\"pemissionName\":\"In Progress & Other\"},{\"pemissionName\":\"Canceled\"},{\"pemissionName\":\"Quality Check\"},{\"pemissionName\":\"allowedToSeeAmountDetails\"},{\"pemissionName\":\"Ready for Delivery\"},{\"pemissionName\":\"Received from Supplier\"},{\"pemissionName\":\"Edit_Payment_Mode\"}]},{\"subModuleName\":\"Dashboard\",\"permission\":[{\"pemissionName\":\"BranchDashBoard\"}]},{\"subModuleName\":\"Optical Sale Report\",\"permission\":[{\"pemissionName\":\"BranchCombinedReport\"}]},{\"subModuleName\":\"Items In Stock\",\"permission\":[{\"pemissionName\":\"otherBranch_DepoStock\"}]},{\"subModuleName\":\"Stock Entry\",\"permission\":[{\"pemissionName\":\"isCompletedApprovalPermit\"}]}]}'),(5,134,2,2,0,NULL,0,1,'2019-03-16 16:08:18','2019-03-16 16:08:18','{\"permissions\":[{\"label\":\"MAIN NAVIGATION\",\"separator\": \"true\"},{\"label\":\"Masters\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserCreation\", \"route\": \"users\"},{\"label\": \"Category Field Master\", \"route\": \"category_field_master\"},{\"label\": \"Item Registration\", \"route\": \"itemregistration\"},{\"label\": \"Item Rate Master\", \"route\": \"itemratemaster\"},{\"label\": \"PO Masters\", \"route\": \"po_masters\"}]},{\"label\":\"Lists\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"UserLists\", \"route\": \"users\"}]},{\"label\":\"Purchase Order\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise PO\", \"route\": \"raisepurchaseorder\"},{\"label\": \"GRN\", \"route\": \"po_grn\"},{\"label\": \"Stock Issue\", \"route\": \"po_generate_invoice\"}]},{\"label\":\"Indent\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Raise Indent\", \"route\": \"raise_indent\"},{\"label\": \"Stock Accept\", \"route\": \"indent_grn_accept_invoice\"}]},{\"label\":\"Sales\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Patient Sale\", \"route\": \"optical_sale\"}]},{\"label\":\"Reports\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Dashboard\", \"route\": \"report_dashboard\"},{\"label\": \"Optical Sale Report\", \"route\": \"report_combinedreport\"},{\"label\": \"Consumption Report\", \"route\": \"consumption_report\"},{\"label\": \"Optical Conversion report\", \"route\": \"optical_conversion_report\"},{\"label\": \"GRN Report\", \"route\": \"grn_report\"},{\"label\": \"Optical Credit Billing\", \"route\": \"optical_credit_billing\"},{\"label\": \"Lens Order Report\", \"route\": \"lens_not_in_stock_report\"},{\"label\": \"Item Return Report\", \"route\": \"item_return_report\"},{\"label\": \"Branch Return Report\", \"route\": \"branch_return_report\"},{\"label\": \"Stock Issue Report\", \"route\": \"stock_issue_report\"},{\"label\": \"Barcode Inventory Report\", \"route\": \"barcode_inventory_report\"},{\"label\": \"Optical Pending Order Report\", \"route\": \"optical_pending_order_report\"},{\"label\": \"Product Profit Margin Report\", \"route\": \"product_profit_margin_report\"},{\"label\": \"Salesman Productivity Report\", \"route\": \"salesman_productivity_report\"},{\"label\": \"Optical Flash Dashboard\", \"route\": \"optical_flash_dashboard\"},{\"label\": \"Optical Sale GST Report\", \"route\": \"optical_sale_gst_report\"},{\"label\": \"Fast Moving Frames\", \"route\": \"fast_moving_frames\"},{\"label\": \"Audit Report\", \"route\": \"audit_report\"},{\"label\": \"Fitters Order Report\", \"route\": \"fitters_order_report\"},{\"label\": \"Optical Gross Margin Report\", \"route\": \"optical_gross_margin_report\"},{\"label\": \"Barcode Age Report\", \"route\": \"barcode_age_report\"}]},{\"label\":\"Inventory\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Items In Stock\", \"route\": \"invenorty_itemstock\"}]},{\"label\":\"Goods Return\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Return Items\", \"route\": \"return_items\"},{\"label\": \"Sales Return\", \"route\": \"salesReturns\"}]},{\"label\":\"Audit\",\"iconClasses\":\"fa fa-tasks\",\"children\":[{\"label\": \"Create Audit\", \"route\": \"create_audit\"},{\"label\": \"Stock Entry\", \"route\": \"stock_entry\"},{\"label\": \"Stock Reconcile\", \"route\": \"stock_reconcile\"}]}]}','{\"permissionsArr\":[{\"subModuleName\":\"Raise PO\",\"permission\":[{\"pemissionName\":\"Reject\"},{\"pemissionName\":\"UpdatePOMRP\"},{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"}]},{\"subModuleName\":\"Raise Indent\",\"permission\":[{\"pemissionName\":\"ForceClose\"},{\"pemissionName\":\"Authorize\"},{\"pemissionName\":\"Reject\"}]},{\"subModuleName\":\"Patient Sale\",\"permission\":[{\"pemissionName\":\"Bill Print\"},{\"pemissionName\":\"Open\"},{\"pemissionName\":\"Rejected\"},{\"pemissionName\":\"New\"},{\"pemissionName\":\"Delivered\"},{\"pemissionName\":\"Fitting\"},{\"pemissionName\":\"Inprogress\"},{\"pemissionName\":\"Send to Supplier\"},{\"pemissionName\":\"In Progress & Other\"},{\"pemissionName\":\"Canceled\"},{\"pemissionName\":\"Quality Check\"},{\"pemissionName\":\"allowedToSeeAmountDetails\"},{\"pemissionName\":\"Ready for Delivery\"},{\"pemissionName\":\"Received from Supplier\"},{\"pemissionName\":\"Edit_Payment_Mode\"}]},{\"subModuleName\":\"Dashboard\",\"permission\":[{\"pemissionName\":\"BranchDashBoard\"}]},{\"subModuleName\":\"Optical Sale Report\",\"permission\":[{\"pemissionName\":\"BranchCombinedReport\"}]},{\"subModuleName\":\"Items In Stock\",\"permission\":[{\"pemissionName\":\"otherBranch_DepoStock\"}]},{\"subModuleName\":\"Stock Entry\",\"permission\":[{\"pemissionName\":\"isCompletedApprovalPermit\"}]}]}');

--
-- Table structure for table `tbl_user_module_map`
--

CREATE TABLE `tbl_user_module_map` (
  `aModuleMapId` int(11) NOT NULL AUTO_INCREMENT,
  `nUserId` int(11) DEFAULT NULL,
  `nModuleId` int(11) DEFAULT NULL,
  `iscompanyorcustomerUser` int(11) DEFAULT NULL,
  `ndepotId` varchar(45) DEFAULT NULL,
  `nBranchId` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedDate` datetime DEFAULT NULL,
  `isActive` int(11) DEFAULT NULL,
  `isDeleted` int(11) DEFAULT NULL,
  `nLoggedInUserId` int(11) DEFAULT NULL,
  `nPermission` text,
  `nfeaturepermission` text,
  PRIMARY KEY (`aModuleMapId`),
  KEY `fk_tbl_user_module_map_1_idx` (`nModuleId`),
  KEY `fk_tbl_user_module_map_2_idx` (`nUserId`),
  CONSTRAINT `fk_tbl_user_module_map_1` FOREIGN KEY (`nModuleId`) REFERENCES `tbl_modules` (`aModuleId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_tbl_user_module_map_2` FOREIGN KEY (`nUserId`) REFERENCES `tbl_user` (`auserId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Dumping data for table `tbl_user_module_map`
--


--
-- Table structure for table `tbl_vender_outstand_payment_each_transaction`
--

CREATE TABLE `tbl_vender_outstand_payment_each_transaction` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mainTrancId` int(11) DEFAULT '0',
  `vendorId` int(11) DEFAULT '0',
  `branchId` int(11) DEFAULT '0',
  `depoId` int(11) DEFAULT '0',
  `isCustOrConsum` int(11) DEFAULT '0',
  `paidAmount` float DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `userId` int(11) DEFAULT NULL,
  `outStandAmount` float DEFAULT '0',
  `paymentDate` date DEFAULT NULL,
  `paymentModeId` int(11) DEFAULT NULL,
  `paymentRemarks` varchar(250) DEFAULT NULL,
  `isCreditOrDebit` int(11) DEFAULT '0',
  `debitTransactionMainTableId` int(11) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_vender_outstand_payment_each_transaction`
--

INSERT INTO `tbl_vender_outstand_payment_each_transaction` VALUES (1,1,1,0,1,1,100000,'2020-06-17 20:47:58','2020-06-17 20:47:58',1,0,160,461914,'2020-06-17',1,'',1,0),(2,1,1,0,1,1,100000,'2020-06-17 20:57:04','2020-06-17 20:57:04',1,0,160,461914,'2020-06-17',1,NULL,2,1);

--
-- Table structure for table `tbl_vender_outstand_payment_main_transaction`
--

CREATE TABLE `tbl_vender_outstand_payment_main_transaction` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `vendorId` int(11) DEFAULT '0',
  `branchId` int(11) DEFAULT '0',
  `depoId` int(11) DEFAULT '0',
  `isCustOrConsum` int(11) DEFAULT '0',
  `totalCreditAmount` float DEFAULT '0',
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_vender_outstand_payment_main_transaction`
--

INSERT INTO `tbl_vender_outstand_payment_main_transaction` VALUES (1,1,0,1,1,0,'2020-06-17 20:47:58','2020-06-17 20:47:58',1,0);

--
-- Table structure for table `tbl_vendor_payment_each_details`
--

CREATE TABLE `tbl_vendor_payment_each_details` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `mainTransId` int(11) DEFAULT NULL,
  `grnId` int(11) DEFAULT NULL,
  `invoiceNo` varchar(250) DEFAULT NULL,
  `invoiceDate` date DEFAULT NULL,
  `invoiceAmount` varchar(45) DEFAULT NULL,
  `venderId` varchar(45) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `branchId` int(11) DEFAULT NULL,
  `depoId` int(11) DEFAULT '0',
  `isCustOrConsum` int(11) DEFAULT '0',
  `userId` int(11) DEFAULT NULL,
  `grnNumber` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_vendor_payment_each_details`
--

INSERT INTO `tbl_vendor_payment_each_details` VALUES (1,1,39,'06082019 PL','2019-08-06','26521.6','1','2020-06-17 20:57:04','2020-06-17 20:57:04',1,0,0,1,1,160,'1000/GRN/08062019/39'),(2,1,41,'06082019 VR10','2019-08-06','75273.0','1','2020-06-17 20:57:04','2020-06-17 20:57:04',1,0,0,1,1,160,'1000/GRN/08062019/41'),(3,1,43,'06082019 VIR 2','2019-08-06','11928.0','1','2020-06-17 20:57:04','2020-06-17 20:57:04',1,0,0,1,1,160,'1000/GRN/08062019/43'),(4,2,1,'1','2019-03-31','184654.0','1','2020-06-17 20:58:26','2020-06-17 20:58:26',1,0,0,1,1,160,'1000/GRN/03312019/1');

--
-- Table structure for table `tbl_vendor_payment_main_details`
--

CREATE TABLE `tbl_vendor_payment_main_details` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `venderId` int(11) DEFAULT '0',
  `totalInvoiceCount` int(11) DEFAULT '0',
  `crediPeriodInvCount` int(11) DEFAULT '0',
  `totalInvAmt` float DEFAULT '0',
  `crediPeriodInvAmt` float DEFAULT '0',
  `paidAmount` float DEFAULT '0',
  `creditAmount` float DEFAULT '0',
  `paymentDate` date DEFAULT NULL,
  `paymentMode` varchar(250) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `branchId` int(11) DEFAULT NULL,
  `depoId` int(11) DEFAULT '0',
  `isCustOrConsum` int(11) DEFAULT '0',
  `userId` int(11) DEFAULT NULL,
  `remarks` varchar(250) DEFAULT NULL,
  `payModeId` int(11) DEFAULT '0',
  `advanceAmtConsumed` float DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tbl_vendor_payment_main_details`
--

INSERT INTO `tbl_vendor_payment_main_details` VALUES (1,1,5,0,461914,113723,13723,0,'2020-06-17','CASH','2020-06-17 20:57:04','2020-06-17 20:57:04',1,0,0,1,1,160,NULL,1,100000),(2,1,2,0,348191,0,184654,0,'2020-06-17','PhonePy','2020-06-17 20:58:26','2020-06-17 20:58:26',1,0,0,1,1,160,NULL,5,0);

--
-- Table structure for table `tblcreditnotedetails`
--

CREATE TABLE `tblcreditnotedetails` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `supplierID` int(11) DEFAULT NULL,
  `creditNoteNumber` varchar(250) DEFAULT NULL,
  `creditNoteDate` date DEFAULT NULL,
  `remarks` varchar(250) DEFAULT NULL,
  `creditNoteAmount` float DEFAULT NULL,
  `creditNoteTaxAmount` float DEFAULT NULL,
  `creditTotalValue` float DEFAULT NULL,
  `userId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `isConsumerOrIsCustomer` int(11) DEFAULT NULL,
  `customerOrConsumerId` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblcreditnotedetails`
--


--
-- Table structure for table `tblcreditnoteitemdetails`
--

CREATE TABLE `tblcreditnoteitemdetails` (
  `Id` int(11) NOT NULL AUTO_INCREMENT,
  `mainCreditId` int(11) DEFAULT NULL,
  `hsnId` int(11) DEFAULT NULL,
  `itemId` int(11) DEFAULT NULL,
  `batchNo` varchar(250) DEFAULT NULL,
  `expDate` date DEFAULT NULL,
  `returnedQty` int(11) DEFAULT NULL,
  `purchasePrice` float DEFAULT NULL,
  `discount` float DEFAULT NULL,
  `gstAmount` float DEFAULT NULL,
  `taxableAmount` float DEFAULT NULL,
  `creditQty` int(11) DEFAULT NULL,
  `totalValue` float DEFAULT NULL,
  `userId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` tinyint(4) DEFAULT '1',
  `isDeleted` tinyint(4) DEFAULT '0',
  `itemRateMasterId` int(11) DEFAULT NULL,
  `mainReturnId` int(11) DEFAULT NULL,
  `eachReturnId` int(11) DEFAULT NULL,
  `supplierId` int(11) DEFAULT NULL,
  `categoryId` int(11) DEFAULT NULL,
  `isConsumerOrIsCustomer` int(11) DEFAULT NULL,
  `customerOrConsumerId` int(11) DEFAULT NULL,
  PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblcreditnoteitemdetails`
--


--
-- Table structure for table `tblhospotalwiseconfigurations`
--

CREATE TABLE `tblhospotalwiseconfigurations` (
  `aConfig_fk` int(11) NOT NULL AUTO_INCREMENT,
  `configKey` varchar(250) DEFAULT NULL,
  `configValue` varchar(1000) CHARACTER SET utf8 DEFAULT NULL,
  `configDescription` varchar(250) DEFAULT NULL,
  `insertedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `lastModifiedDate` datetime DEFAULT CURRENT_TIMESTAMP,
  `isActive` int(11) DEFAULT '1',
  `isDeleted` int(11) DEFAULT '0',
  PRIMARY KEY (`aConfig_fk`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblhospotalwiseconfigurations`
--

INSERT INTO `tblhospotalwiseconfigurations` VALUES (3,'defaultBillHeaderCheck_Opticals','1','if is active 1 and config value 1  to show 0 means not to show ','2022-08-22 10:02:39','2022-08-22 10:02:39',1,0),(4,'defaultBillHeaderCheck_Pharmacy','1','if is active 1 and config value 1  to show 0 means not to show ','2022-08-22 10:02:39','2022-08-22 10:02:39',1,0),(5,'footerReq','1','if is active 1 and config value 1  to show 0 means not to show ','2022-08-22 10:02:39','2022-08-22 10:02:39',1,0),(6,'gstColumsDisplay','1','if is active 1 and config value 1  to show 0 means not to show ','2022-08-22 10:02:40','2022-08-22 10:02:40',1,0),(7,'PlacepfsupplyinGSTReport','MUMBAI','if is active 1 and config value 1  to show 0 means not to show ','2023-06-06 11:38:53','2023-06-06 11:38:53',1,0),(8,'ZeroBalanceAmtforDelivery','1','if is active 1 and config value 1  to show 0 means not to show ','2023-06-09 17:00:44','2023-06-09 17:00:44',1,0),(9,'PDIPDIsMandatory','1','if is active 1 and config value 1  to  mandatory  0 means not to not mandatory ','2023-06-09 17:00:44','2023-06-09 17:00:44',1,0),(10,'ToDisplayADDinRefraction','1','if is active 1 and config value 1  to  Show 0 means not to show','2023-06-09 17:00:44','2023-06-09 17:00:44',1,0),(11,'IsGRNMandaotoryForNotinStockSales','1','1 to mandatory and 0 to not mandatory ','2023-06-09 17:00:44','2023-06-09 17:00:44',1,0),(12,'Purchase GST Percentage Report','1','if is active 1 and config value 1  to show 0 means not to show ','2023-06-20 10:45:02','2023-06-20 10:45:02',0,0),(13,'DaystodisableSalesReturn','90','config value should be days ','2023-08-18 13:36:56','2023-08-18 13:36:56',1,0),(14,'ExpectedDeliveryDateindays','3','if 1 to display 0 not to not display','2023-08-18 13:36:56','2023-08-18 13:36:56',1,0),(15,'DisplayExpectedDeliveryDate','1','if 1 is to dsplay expected delivery Date 0 to not display','2023-08-18 13:36:57','2023-08-18 13:36:57',1,0),(16,'EligibleDaysforContractExpiry','90','config value should be days ','2023-08-18 13:36:57','2023-08-18 13:36:57',1,0),(17,'DisplayConsultantSpectacleAdvice','1','if 1 to display 0 not to not display','2023-08-18 13:36:57','2023-08-18 13:36:57',0,0),(18,'ViewItemPriceInInventory','1','if 1 to display 0 not to not display','2023-08-18 13:36:57','2023-08-18 13:36:57',0,9),(19,'IsGRNInvoicenumberunique','1','if 0 to no check 1 to check invoice unique','2023-09-06 18:45:56','2023-09-06 18:45:56',1,0),(20,'DisplayPreviousRxInSale','1','if 1 to display 0 not to not display','2023-12-12 18:03:59','2023-12-12 18:03:59',0,0),(21,'DisplayDaignosisinprint','1','if 1 to display 0 not to not display','2023-12-12 18:04:00','2023-12-12 18:04:00',0,0),(22,'BrandORVendorDescriptioninBarcode','0','if 0 to display brand and 1 to display vendor discrption','2024-05-15 16:46:11','2024-05-15 16:46:11',1,0),(23,'IsMarkingbymandatory','0','1 to make madataory marking text field and 0 to not mandatory','2024-05-30 16:51:44','2024-05-30 16:51:44',0,0),(24,'IsVerifiedbymandatory','0','1 to make madataory marking text field and 0 to not mandatory','2024-05-30 16:51:44','2024-05-30 16:51:44',0,0);

--
-- Table structure for table `tblopticalpatientrefractiondetails`
--

CREATE TABLE `tblopticalpatientrefractiondetails` (
  `aOpt_ID` int(11) NOT NULL AUTO_INCREMENT,
  `nPat_Id` int(11) DEFAULT NULL,
  `nAppoint_Id` int(11) DEFAULT NULL,
  `nbranchId` int(11) DEFAULT NULL,
  `opticalStatus` int(11) DEFAULT NULL,
  `Patient_Type` int(11) DEFAULT NULL,
  `nConsultantId` int(11) DEFAULT NULL,
  `nOpticianId` int(11) DEFAULT NULL,
  `nsph_R_Id` varchar(250) DEFAULT NULL,
  `nsph_L_Id` varchar(250) DEFAULT NULL,
  `ncyl_R_Id` varchar(250) DEFAULT NULL,
  `ncyl_L_Id` varchar(250) DEFAULT NULL,
  `naxis_R_Id` varchar(250) DEFAULT NULL,
  `naxis_L_Id` varchar(250) DEFAULT NULL,
  `nadd_R_Id` varchar(250) DEFAULT NULL,
  `nadd_L_Id` varchar(250) DEFAULT NULL,
  `nNVA_R_Id` varchar(250) DEFAULT NULL,
  `nNVA_L_Id` varchar(250) DEFAULT NULL,
  `nDVA_R_Id` varchar(250) DEFAULT NULL,
  `nDVA_L_Id` varchar(250) DEFAULT NULL,
  `nsph_B_Id` varchar(250) DEFAULT NULL,
  `ncyl_B_Id` varchar(250) DEFAULT NULL,
  `naxis_B_Id` varchar(250) DEFAULT NULL,
  `nadd_B_Id` varchar(250) DEFAULT NULL,
  `nNVA_B_Id` varchar(250) DEFAULT NULL,
  `nDVA_B_Id` varchar(250) DEFAULT NULL,
  `openComments` varchar(250) DEFAULT NULL,
  `inprogressComments` varchar(250) DEFAULT NULL,
  `closedComments` varchar(250) DEFAULT NULL,
  `cancelledComments` varchar(250) DEFAULT NULL,
  `deliveredComments` varchar(250) DEFAULT NULL,
  `lensType` varchar(500) DEFAULT NULL,
  `lensMaterial` varchar(45) DEFAULT NULL,
  `lensInst` varchar(45) DEFAULT NULL,
  `lensIPD` varchar(45) DEFAULT NULL,
  `consultantComments` varchar(250) DEFAULT NULL,
  `nVADV_R_Id` varchar(250) DEFAULT NULL,
  `nVANV_R_Id` varchar(250) DEFAULT NULL,
  `nVADV_L_Id` varchar(250) DEFAULT NULL,
  `nVANV_L_Id` varchar(250) DEFAULT NULL,
  `addsubstitute_R` varchar(250) DEFAULT NULL,
  `addsubstitute_L` varchar(250) DEFAULT NULL,
  `lensPD` varchar(100) DEFAULT NULL,
  `lensPDLE` varchar(100) DEFAULT NULL,
  `conLens_sph_R` varchar(100) DEFAULT NULL,
  `conLens_sph_L` varchar(100) DEFAULT NULL,
  `conLens_cyl_R` varchar(100) DEFAULT NULL,
  `conLens_cyl_L` varchar(100) DEFAULT NULL,
  `conLens_axis_R` varchar(100) DEFAULT NULL,
  `conLens_axis_L` varchar(100) DEFAULT NULL,
  `conLens_dva_R` varchar(100) DEFAULT NULL,
  `conLens_dva_L` varchar(100) DEFAULT NULL,
  `conLens_basecurve_R` varchar(100) DEFAULT NULL,
  `conLens_basecurve_L` varchar(100) DEFAULT NULL,
  `conLens_diameter_R` varchar(100) DEFAULT NULL,
  `conLens_diameter_L` varchar(100) DEFAULT NULL,
  `conLens_type` varchar(100) DEFAULT NULL,
  `conLens_company` varchar(100) DEFAULT NULL,
  `conLens_usage1` varchar(100) DEFAULT NULL,
  `conLens_usage2` varchar(100) DEFAULT NULL,
  `conLens_txtcomment` mediumtext,
  `consultantName` varchar(250) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  `insertedDate` datetime DEFAULT NULL,
  `lastModifiedDate` datetime DEFAULT NULL,
  `Category` int(11) DEFAULT NULL,
  `SubCategory` int(11) DEFAULT NULL,
  `Referred_ById` int(11) DEFAULT NULL,
  `Referred_By` varchar(100) DEFAULT NULL,
  `SourceId` int(11) DEFAULT NULL,
  `SourceName` varchar(200) DEFAULT NULL,
  `opticalStatusText` varchar(100) DEFAULT NULL,
  `discount_percentage` float DEFAULT NULL,
  `category_name` varchar(100) DEFAULT NULL,
  `sub_category_name` varchar(100) DEFAULT NULL,
  `constultant_RegNo` varchar(100) DEFAULT NULL,
  `consultantAdvice` text,
  `currentNsph_R_Id` varchar(250) DEFAULT NULL,
  `currentNsph_L_Id` varchar(250) DEFAULT NULL,
  `currentNcyl_R_Id` varchar(250) DEFAULT NULL,
  `currentNcyl_L_Id` varchar(250) DEFAULT NULL,
  `currentNaxis_R_Id` varchar(250) DEFAULT NULL,
  `currentNaxis_L_Id` varchar(250) DEFAULT NULL,
  `currentNadd_R_Id` varchar(250) DEFAULT NULL,
  `currentNadd_L_Id` varchar(250) DEFAULT NULL,
  `currentNVA_R_Id` varchar(250) DEFAULT NULL,
  `currentNVA_L_Id` varchar(250) DEFAULT NULL,
  `currentNDVA_R_Id` varchar(250) DEFAULT NULL,
  `currentNDVA_L_Id` varchar(250) DEFAULT NULL,
  `currentNVADV_R_Id` varchar(250) DEFAULT NULL,
  `currentNVANV_R_Id` varchar(250) DEFAULT NULL,
  `currentNVADV_L_Id` varchar(250) DEFAULT NULL,
  `currentNVANV_L_Id` varchar(250) DEFAULT NULL,
  `currentLensType` varchar(500) DEFAULT NULL,
  `currentRemarks` varchar(500) DEFAULT NULL,
  `currentLensInst` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`aOpt_ID`),
  KEY `PatientIdIndex` (`nPat_Id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblopticalpatientrefractiondetails`
--


--
-- Table structure for table `tblopticalsalepatientregistration`
--

CREATE TABLE `tblopticalsalepatientregistration` (
  `aPatientId` int(11) NOT NULL AUTO_INCREMENT,
  `nbranchId` int(11) DEFAULT NULL,
  `PatientName` varchar(250) DEFAULT NULL,
  `PateintGender` varchar(150) DEFAULT NULL,
  `PatientAge` int(11) DEFAULT '0',
  `emrPatientMRDNum` varchar(150) DEFAULT NULL,
  `Patient_Type` int(11) DEFAULT NULL,
  `tDOB` date DEFAULT NULL,
  `MobileNumber` varchar(45) DEFAULT NULL,
  `Address` text,
  `Category` int(11) DEFAULT NULL,
  `SubCategory` int(11) DEFAULT NULL,
  `Referred_By` varchar(45) DEFAULT NULL,
  `Constultant_Name` varchar(45) DEFAULT NULL,
  `Source` varchar(45) DEFAULT NULL,
  `opticalStatusId` int(11) DEFAULT NULL,
  `opticalStatusText` varchar(45) DEFAULT NULL,
  `LastModifiedDate` datetime DEFAULT NULL,
  `InsertedDate` datetime DEFAULT NULL,
  `isActive` tinyint(1) DEFAULT NULL,
  `isDelete` tinyint(1) DEFAULT NULL,
  `nUserId` int(11) DEFAULT NULL,
  `discount_percentage` float DEFAULT NULL,
  `category_name` varchar(45) DEFAULT NULL,
  `sub_category_name` varchar(45) DEFAULT NULL,
  `patEmailId` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`aPatientId`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `tblopticalsalepatientregistration`
--


--
-- Dumping events for database 'ygopticals'
--

--
-- Dumping routines for database 'ygopticals'
--
/*!50003 DROP PROCEDURE IF EXISTS `ABC` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `ABC`()
BEGIN
      DECLARE count INT ;
      declare itemID int;
       SET SQL_SAFE_UPDATES = 0;
      set count =1; 
     while count<=(select count(*) from tbl_TEMP) do
      -- SET SQL_SAFE_UPDATES = 0;
     update tbl_mst_items_details 
	set itemName = (select ItemName from tbl_TEMP where Slno= count)
	where itemCode = (select itemCode from tbl_TEMP where Slno= count);
    
    update tbl_mst_items_details 
	set customer_desc = (select ItemName from tbl_TEMP where Slno= count)
	where itemCode = (select itemCode from tbl_TEMP where Slno= count);

set itemID = (select aItemId_pk from tbl_mst_items_details where itemCode = (select itemCode from tbl_TEMP where Slno= count));

select ItemName , PurchasePrice, MRPPrice into @Itn , @pp, @mrp from tbl_TEMP where  Slno = count; 


update tbl_item_rate_master
set purchasePrice = @pp, sellingPrice = @mrp, MRP = @mrp
where ndepotId = 1  and nItemId_fk = itemID;

     update tbl_po_each_item_details 
	set item_name = (select ItemName from tbl_TEMP where Slno= count)
	where item_code = (select itemCode from tbl_TEMP where Slno= count);
     
         SET count=count+1;
          
        end while; 
        SET SQL_SAFE_UPDATES = 1;
        END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `Bhayndar_Update` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `Bhayndar_Update`()
BEGIN
      DECLARE count INT ;
      declare itemID int;
       SET SQL_SAFE_UPDATES = 0;
      set count =1; 
     while count<=(select count(*) from tbl_TEMP) do
        -- SET SQL_SAFE_UPDATES = 0;
    /* update tbl_mst_items_details 
	set itemName = (select ItemName from tbl_TEMP where Slno = count)
	 where itemCode = (select itemCode from tbl_TEMP where Slno= count); */
    
   /* update tbl_mst_items_details 
	set customer_desc = (select ItemName from tbl_TEMP where Slno= count)
	where itemCode = (select itemCode from tbl_TEMP where Slno= count); */

set itemID = (select aItemId_pk from tbl_mst_items_details where itemCode = (select itemCode from tbl_temp1 where Slno= count));

select ItemName , PurchasePrice, MRPPrice into @Itn , @pp, @mrp from tbl_TEMP1 where  Slno = count; 


update tbl_item_rate_master
set purchasePrice = @pp, sellingPrice = @mrp, MRP = @mrp 
where ndepotId = 1  and nItemId_fk = itemID;

     /*update tbl_po_each_item_details 
	set item_name = (select ItemName from tbl_TEMP where Slno= count)
	where item_code = (select itemCode from tbl_TEMP where Slno= count);*/
     
         SET count=count+1;
        end while; 
		SET SQL_SAFE_UPDATES = 1;
        END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_combined_payment_report_main` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_combined_payment_report_main`(
in fromDate varchar(50),
in toDate varchar(50),
in branchIds tinytext 
)
BEGIN
declare rtnStatus int;
set rtnStatus = 4;
select * from (
(
SELECT 
        DATE(t1.PaymentDate) PaymentDate,
            t1.PaymentTypeId,
            IFNULL(t1.PaymentTypeName, '') PaymentTypeName,
            SUM(IFNULL(t1.TotalAmt_paid, 0)) TotalAmt_paid
    FROM
        tbl_opticalsale_payment_each_tran t1 
    WHERE
        DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)
            AND FIND_IN_SET(nBranchId, branchIds)
    GROUP BY DATE(t1.PaymentDate) , t1.PaymentTypeId
    ORDER BY DATE(t1.PaymentDate) DESC , t1.PaymentTypeId ASC
    )
    UNION  
   (
    SELECT 
        DATE(t1.returnDate) AS returnDate,
           rtnStatus AS PaymentTypeId,
            'Item Returned / Cancel' AS PaymentTypeName,
            SUM(IFNULL(t1.returnAmount, 0)) TotalAmt_paid
    FROM
        tbl_optical_sale_main_returns t1
    WHERE
        DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)
            AND FIND_IN_SET(nBranchId, branchIds)
    GROUP BY DATE(t1.returnDate)
    ORDER BY DATE(t1.returnDate) DESC
    )) t11 order by PaymentDate asc,PaymentTypeId asc;
  


END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_combined_payment_report_sub` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_combined_payment_report_sub`(
in fromDate varchar(50),
in toDate varchar(50),
in branchIds tinytext
)
BEGIN
DECLARE payModeId_ int;
DECLARE payModeTypeId_ int; 
DECLARE balanceAmt_ float; 

set payModeId_ = 1;
set payModeTypeId_ = 4;  
set balanceAmt_ = 0.0;
select * from (
(
SELECT 
    -- ifnull(t1.OrderPaymentId_EachTran, 0) OrderPaymentId_EachTran,
    ifnull(t2.PayId_each_tran, 0) OrderPaymentId_EachTran,
    ifnull(t2.bill_num, '') bill_num,
    ifnull(t3.emrPatientMRDNum,'') AS emrPatientMRDNum,
    ifnull(t3.PatientName,'') AS PatientName,
    ifnull(t1.PaymentModeId, 1) PaymentModeId,
    ifnull(t1.PaymentModeName, '') PaymentModeName,
    t2.PaymentTypeId,
    t2.PaymentTypeName,
    ifnull(t2.TotalAmt_paid, 0) TotalAmt_paid,
    ifnull(t1.PaymentAmount, 0) PaymentAmount,
    t4.nOrderAutoId,
    t4.orderDate,
    ifnull(t3.Constultant_Name, '') Constultant_Name,
    t6.firstName as salesman,
    t5.grandTotal as totalOrderValue,
    t4.actDeliveredDate as saleDate,
    ifnull(t5.balanceAmt,0) AS balanceAmt,
    t2.PaymentDate as PaymentDate,
    t7.Status_Name,
    t4.OrderId ,
     ifnull(t4.marketingByUser,'') as marketingByUser,
      ifnull(t4.verifiedByUser,'') as verifiedByUser
FROM
    (SELECT  
        *
    FROM
        tbl_opticalsale_order_payment_transcation
    WHERE
        DATE(PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)  and find_in_set(nBranchId, branchIds)) t1
        RIGHT JOIN
    (SELECT 
        *
    FROM
        tbl_opticalsale_payment_each_tran
    WHERE
        DATE(PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)  and find_in_set(nBranchId, branchIds)) t2 ON t2.PayId_each_tran = t1.OrderPaymentId_EachTran
        JOIN
    tblopticalsalepatientregistration t3 ON t3.aPatientId = t2.nPatient_Id
		JOIN
	tbl_opticalsale_orders t4 on t4.OrderId = t2.OrderId
		JOIN
	tbl_opticalsale_main_payment t5 on t5.OrderId = t4.OrderId
		JOIN
	tbl_user t6 on t6.auserId = t4.billerId
		JOIN
	tbl_mst_opticalsale_main_status t7 on t7.aStatusId = t4.Current_Main_Status_Id
ORDER BY t2.PaymentTypeId asc, t1.OrderPaymentId_EachTran DESC
)
UNION all
(
SELECT 
    t1.aOpticalSaleReturnId AS OrderPaymentId_EachTran,
    ifnull(t1.returnNumber, '') bill_num,
   ifnull(t3.emrPatientMRDNum,'') AS emrPatientMRDNum,
    ifnull(t3.PatientName,'') AS PatientName,
    payModeId_ AS PaymentModeId,
    'Cash' AS PaymentModeName,
    payModeTypeId_ AS PaymentTypeId,
    'Item Return / Cancel' AS PaymentTypeName, 
    ifnull((t1.returnAmount), 0.0) TotalAmt_paid,
    t1.returnAmount AS PaymentAmount,
    ifnull(t1.saleOrderNumber, '') AS nOrderAutoId,
    t1.returnDate AS orderDate,
    ifnull(t3.Constultant_Name, '') Constultant_Name,
    t6.firstName as salesman,
    t1.returnAmount as totalOrderValue,
    t4.orderDate as saleDate,
    balanceAmt_ AS balanceAmt,
    t4.orderDate as PaymentDate,
	'',
    -1,
     ifnull(t4.marketingByUser,'') as marketingByUser,
      ifnull(t4.verifiedByUser,'') as verifiedByUser
FROM
    (SELECT 
        * 
    FROM
        tbl_optical_sale_main_returns
    WHERE
        DATE(returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)  and find_in_set(nBranchId, branchIds)) t1 
      /*  JOIN
    (SELECT 
        *
    FROM
        tbl_optical_sale_each_returns
    WHERE
        DATE(returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)  and find_in_set(nBranchId, branchIds)) t2 ON t2.nOpticalSaleMainReturnId = t1.aOpticalSaleReturnId */
    --    JOIN tbl_opticalsale_payment_each_tran TBLE ON t1.nOrderId = TBLE.OrderId
        LEFT JOIN
    tblopticalsalepatientregistration t3 ON t3.aPatientId = t1.nPatient_Id
		JOIN
	tbl_opticalsale_orders t4 on t4.OrderId = t1.nOrderId
		JOIN
	tbl_optical_sale_main_returns t5 on t5.nOrderId = t4.OrderId
		JOIN
	tbl_user t6 on t6.auserId = t5.nUserId 
ORDER BY  t1.aOpticalSaleReturnId DESC  /*returnAmount*/
)) t1  
order by PaymentTypeId asc, payModeId_ asc, OrderPaymentId_EachTran asc;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_opticals_eachduration_catagorywise_amt` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_opticals_eachduration_catagorywise_amt`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
SELECT 
   ROUND(SUM(IFNULL(unitSellingPrice * nQty, 0)), 2) AS actualInvoice,
    ROUND(SUM(IFNULL(unitSellingPrice * nQty, 0) - IFNULL(discountAmount, 0)),
            2) AS effectiveInvoice,
    ROUND(SUM(IFNULL(discountAmount, 0)), 2) AS discountAmount,
    t3.aCategoryId_pk,
    t3.CategoryName
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND t2.Current_Main_Status_Id = 3
        AND if(branchId <> '-1',t2.nBranchId = branchId,true)
        AND DATE(t2.actDeliveredDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        RIGHT JOIN
    tbl_mst_category t3 ON t3.aCategoryId_pk = t1.nCategoryId
WHERE
    t3.aCategoryId_pk < 9
GROUP BY t3.aCategoryId_pk;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_EMR_Optical_AmountCollectionontheDayForDashboard` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_EMR_Optical_AmountCollectionontheDayForDashboard`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN

declare advAmt float;
declare retAmt float; 
declare discountAmt float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare otherAmt float;

set advAmt = (SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set retAmt = (SELECT 
    SUM(returnAmount) returnAmount
FROM
    tbl_optical_sale_main_returns
WHERE
    DATE(returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND if(branchId <> '-1', nBranchId IN (branchId), 1=1));
        
set discountAmt = (SELECT 
    SUM(IFNULL(t1.discountAmount, 0)) AS discountAmt
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cashAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cardAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set chequeAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set otherAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        

SELECT 
    IFNULL(advAmt, 0) advAmt,
    IFNULL(retAmt, 0) retAmt,
    IFNULL(discountAmt, 0) discountAmt,
    IFNULL(cashAmt, 0) cashAmt,
    IFNULL(cardAmt, 0) cardAmt,
    IFNULL(chequeAmt, 0) chequeAmt,
    IFNULL(otherAmt, 0) otherAmt;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_cgst_collected_details` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_emr_optical_cgst_collected_details`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
SELECT 
    ROUND(SUM(IFNULL(unitSellingPrice * nQty, 0) - IFNULL(discountAmount, 0)),
            2) AS effectiveInvoice,
    item_cgst_percent
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND t2.Current_Main_Status_Id = 3
        AND t2.nBranchId = branchId
        AND DATE(t2.actDeliveredDate) BETWEEN DATE(fromDate) AND DATE(toDate)
GROUP BY item_cgst_percent;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_consultant_contibutionreport` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_optical_consultant_contibutionreport`(
in fromDate text,
in toDate text,
in branchId text,
in consltId text
)
BEGIN
declare prescibedCount int;
declare convertedCount int;
declare revenue float;

SELECT 
    count(*) into prescibedCount
FROM
    tblopticalpatientrefractiondetails t1
WHERE
    t1.Patient_Type = 1
        AND DATE(t1.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND if(branchId <> '-1', find_in_set(t1.nbranchId, branchId), 1=1)
        AND if(consltId <> '-1', find_in_set(t1.nConsultantId, consltId), 1=1);
        
SELECT 
    count(*) into convertedCount
FROM
    tblopticalpatientrefractiondetails t1
    JOIN tbl_opticalsale_orders t2 on t2.nAppoint_Id = t1.nAppoint_Id
WHERE
    t1.Patient_Type = 1
    AND t2.Current_Main_Status_Id = 3
        AND DATE(t1.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND if(branchId <> '-1', find_in_set(t1.nbranchId, branchId), 1=1)
        AND if(consltId <> '-1', find_in_set(t1.nConsultantId, consltId), 1=1);
        
SELECT 
    sum(t3.TotalAmt_paid) into revenue
FROM
    tblopticalpatientrefractiondetails t1
    JOIN tbl_opticalsale_orders t2 on t2.nAppoint_Id = t1.nAppoint_Id
    JOIN tbl_opticalsale_payment_each_tran t3 on t3.OrderId = t2.OrderId
WHERE
    t1.Patient_Type = 1
    AND t2.Current_Main_Status_Id = 3
        AND DATE(t1.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND if(branchId <> '-1', find_in_set(t1.nbranchId, branchId), 1=1)
        AND if(consltId <> '-1', find_in_set(t1.nConsultantId, consltId), 1=1);
        
select ifnull(prescibedCount,0) AS prescibedCount, ifnull(convertedCount,0) AS convertedCount, ifnull(revenue,0) AS revenue;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_eachduration_amt` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_optical_eachduration_amt`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
  
declare advAmt float;
declare retAmt float; 
declare discountAmt float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare otherAmt float;
declare cashAmt_WO_Adv float;
declare cardAmt_WO_Adv float;
declare chequeAmt_WO_Adv float;
declare otherAmt_WO_Adv float;
declare cashAmt_Adv float;
declare cardAmt_Adv float;
declare chequeAmt_Adv float;
declare otherAmt_Adv float;
declare totalAountPaid float;

declare advColle float;
declare advAdju float;

declare creditAmt float;

set advAmt = (SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4 
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set retAmt = (SELECT 
    SUM(returnAmount) returnAmount
FROM
    tbl_optical_sale_main_returns
WHERE
    DATE(returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND if(branchId <> '-1', nBranchId IN (branchId), 1=1));
        
set discountAmt = (SELECT 
    SUM(IFNULL(t1.discountAmount, 0)) AS discountAmt
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cashAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
    --     AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cardAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt 
FROM 
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
       -- AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set chequeAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
  --      AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set otherAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
  --      AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        


set cashAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cardAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set chequeAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set otherAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
        
set cashAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cardAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt 
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set chequeAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));


set otherAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

  
SET totalAountPaid = (
SELECT 
    SUM(t1.TotalAmt_paid) TotalAmt_paid
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        -- AND t1.nBranchId IN (branchId);
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
SET group_concat_max_len := 1000000;
        
set advColle = (SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt
FROM
    (SELECT * FROM tbl_opticalsale_payment_each_tran
WHERE find_in_set(PayId_each_tran,
(SELECT 
    GROUP_CONCAT(eachIDPay)
FROM
    (SELECT 
        GROUP_CONCAT(DISTINCT PayId_each_tran) AS eachIDPay
    FROM
        tbl_opticalsale_payment_each_tran
	WHERE DATE(PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)
    GROUP BY OrderId , PaymentDate
    HAVING GROUP_CONCAT(DISTINCT PaymentTypeId) NOT LIKE '%3%') t1))) t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
set advAdju = (SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt
FROM
    (SELECT 
    t111.*
FROM
    tbl_opticalsale_payment_each_tran t111
        JOIN
    (SELECT * FROM tbl_opticalsale_payment_each_tran
WHERE find_in_set(PayId_each_tran,
(SELECT 
    GROUP_CONCAT(eachIDPay)
FROM
    (SELECT 
        GROUP_CONCAT(DISTINCT PayId_each_tran) AS eachIDPay
    FROM
        tbl_opticalsale_payment_each_tran
	WHERE DATE(PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)
    GROUP BY OrderId , PaymentDate
    HAVING GROUP_CONCAT(DISTINCT PaymentTypeId) LIKE '3') t1))) t222 ON t222.OrderId = t111.OrderId
        AND t111.PaymentTypeId IN (1 , 2)) t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        -- AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
set creditAmt = (SELECT 
    SUM(t1.Credit_Company_Amt) Credit_Company_Amt
FROM 
    tbl_opticalsale_main_payment t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND t1.iS_Credit_Company_Transction = 1
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
SELECT 
    ROUND(IFNULL(totalAountPaid, 0),2) TotalAmt_paid,
    ROUND(IFNULL(advAmt, 0),2) advAmt,
    ROUND(IFNULL(retAmt, 0),2) retAmt,
    ROUND(IFNULL(discountAmt, 0),2) discountAmt,
    ROUND((IFNULL(cashAmt, 0)),2) cashAmt,
    ROUND(IFNULL(cardAmt, 0),2) cardAmt,
    ROUND(IFNULL(chequeAmt, 0),2) chequeAmt,
    ROUND(IFNULL(otherAmt, 0),2) otherAmt,
    ROUND(IFNULL(advColle, 0),2) advColle,
    ROUND(IFNULL(cashAmt_WO_Adv, 0),2) cashAmt_WO_Adv,
    ROUND(IFNULL(cardAmt_WO_Adv, 0),2) cardAmt_WO_Adv,
    ROUND(IFNULL(chequeAmt_WO_Adv, 0),2) chequeAmt_WO_Adv,
    ROUND(IFNULL(otherAmt_WO_Adv, 0),2) otherAmt_WO_Adv,
    ROUND(IFNULL(cashAmt_Adv, 0),2) cashAmt_Adv,
    ROUND(IFNULL(cardAmt_Adv, 0),2) cardAmt_Adv,
    ROUND(IFNULL(chequeAmt_Adv, 0),2) chequeAmt_Adv,
    ROUND(IFNULL(otherAmt_Adv, 0),2) otherAmt_Adv,
    ROUND(IFNULL(advAdju, 0),2) advAdju,
    ROUND(IFNULL(creditAmt, 0),2) creditAmt; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_eachduration_amt_3_0` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_optical_eachduration_amt_3_0`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
  
declare advAmt float;
declare retAmt float; 
declare discountAmt float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare otherAmt float;
declare cashAmt_WO_Adv float;
declare cardAmt_WO_Adv float;
declare chequeAmt_WO_Adv float;
declare otherAmt_WO_Adv float;
declare cashAmt_Adv float;
declare cardAmt_Adv float;
declare chequeAmt_Adv float;
declare otherAmt_Adv float;
declare totalAountPaid float;

declare advColle float;
declare advAdju float;

declare creditAmt float;

set advAmt = (SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set retAmt = (SELECT 
    SUM(returnAmount) returnAmount
FROM
    tbl_optical_sale_main_returns
WHERE
    DATE(returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND if(branchId <> '-1', nBranchId IN (branchId), 1=1));
        
set discountAmt = (SELECT 
    SUM(IFNULL(t1.discountAmount, 0)) AS discountAmt
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
SET group_concat_max_len := 1000000;
        
-- set advColle = (
SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt, group_concat(OrderPaymentId) into @advColle_, @orderPaymentsIds_
FROM
    (SELECT * FROM tbl_opticalsale_payment_each_tran
WHERE find_in_set(PayId_each_tran,
(SELECT 
    GROUP_CONCAT(eachIDPay)
FROM
    (SELECT 
        GROUP_CONCAT(DISTINCT PayId_each_tran) AS eachIDPay
    FROM
        tbl_opticalsale_payment_each_tran
	WHERE DATE(PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)
    GROUP BY OrderId , PaymentDate
    HAVING GROUP_CONCAT(DISTINCT PaymentTypeId) NOT LIKE '%3%') t1))) t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        -- );
        
set advColle = @advColle_;
        
set advAdju = (SELECT 
    SUM(t1.TotalAmt_paid) advanceAmt
FROM
    (SELECT 
    t111.*
FROM
    tbl_opticalsale_payment_each_tran t111
        JOIN
    (SELECT * FROM tbl_opticalsale_payment_each_tran
WHERE find_in_set(PayId_each_tran,
(SELECT 
    GROUP_CONCAT(eachIDPay)
FROM
    (SELECT 
        GROUP_CONCAT(DISTINCT PayId_each_tran) AS eachIDPay
    FROM
        tbl_opticalsale_payment_each_tran
	WHERE DATE(PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)
    GROUP BY OrderId , PaymentDate
    HAVING GROUP_CONCAT(DISTINCT PaymentTypeId) LIKE '3') t1))) t222 ON t222.OrderId = t111.OrderId
        AND t111.PaymentTypeId IN (1 , 2)) t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        -- AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
set creditAmt = (SELECT 
    SUM(t1.Credit_Company_Amt) Credit_Company_Amt
FROM
    tbl_opticalsale_main_payment t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND t1.iS_Credit_Company_Transction = 1
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cashAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
 
set cardAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set chequeAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set otherAmt = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        


set cashAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set cardAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set chequeAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));

set otherAmt_WO_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND t1.PaymentTypeId not in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
        
set cashAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
		WHERE FIND_IN_SET(t1.OrderPaymentId , @orderPaymentsIds_)
        and t1.PaymentModeId = 1);
        /*JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4 -- in (1,2) -- != 4
        AND t1.PaymentModeId = 1
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1))*/

set cardAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
    WHERE FIND_IN_SET(t1.OrderPaymentId , @orderPaymentsIds_)
        and t1.PaymentModeId = 2);
        /*JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id  != 4-- in (1,2) -- != 4
        AND t1.PaymentModeId = 2
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));*/

set chequeAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
    WHERE FIND_IN_SET(t1.OrderPaymentId , @orderPaymentsIds_)
        and t1.PaymentModeId = 3);
        /*JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id  != 4 -- in (1,2) -- != 4
        AND t1.PaymentModeId = 3
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));*/


set otherAmt_Adv = (SELECT 
    SUM(t1.PaymentAmount) cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
    WHERE FIND_IN_SET(t1.OrderPaymentId , @orderPaymentsIds_)
        and  t1.PaymentModeId not in (1,2,3));
        /*JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id  != 4 -- in (1,2) -- != 4
        AND t1.PaymentModeId not in (1,2,3)
        AND t1.PaymentTypeId in (1,2)
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));*/

  
SET totalAountPaid = (
SELECT 
    SUM(t1.TotalAmt_paid) TotalAmt_paid
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        -- AND t1.nBranchId IN (branchId);
        AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1));
        
SELECT 
-- @orderPaymentsIds,
    IFNULL(totalAountPaid, 0) TotalAmt_paid,
    IFNULL(advAmt, 0) advAmt,
    IFNULL(retAmt, 0) retAmt,
    IFNULL(discountAmt, 0) discountAmt,
    IFNULL(cashAmt, 0) cashAmt,
    IFNULL(cardAmt, 0) cardAmt,
    IFNULL(chequeAmt, 0) chequeAmt,
    IFNULL(otherAmt, 0) otherAmt,
    IFNULL(advColle, 0) advColle,
    -- IFNULL(cashAmt_WO_Adv, 0) cashAmt_WO_Adv,
    -- IFNULL(cardAmt_WO_Adv, 0) cardAmt_WO_Adv,
    -- IFNULL(chequeAmt_WO_Adv, 0) chequeAmt_WO_Adv,
    -- IFNULL(otherAmt_WO_Adv, 0) otherAmt_WO_Adv,
    IFNULL(cashAmt_Adv, 0) cashAmt_Adv,
    IFNULL(cardAmt_Adv, 0) cardAmt_Adv,
    IFNULL(chequeAmt_Adv, 0) chequeAmt_Adv,
    IFNULL(otherAmt_Adv, 0) otherAmt_Adv,
    IFNULL(advAdju, 0) advAdju,
    IFNULL(creditAmt, 0) creditAmt;  

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_mst_gst_details` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_optical_mst_gst_details`()
BEGIN
declare sgstPercentages varchar(200);
declare cgstPercentages varchar(200); 

set sgstPercentages = (select group_concat(distinct sgstPercentage) sgstPercentage from tbl_mst_hsn_codes);
set cgstPercentages = (select group_concat(distinct cgstPercentage) cgstPercentage from tbl_mst_hsn_codes);

select sgstPercentages, cgstPercentages;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_sgst_collected_details` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_emr_optical_sgst_collected_details`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
SELECT 
    ROUND(SUM(IFNULL(unitSellingPrice * nQty, 0) - IFNULL(discountAmount, 0)),
            2) AS effectiveInvoice,
    item_sgst_percent
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND t2.Current_Main_Status_Id = 3
        AND t2.nBranchId = branchId
        AND DATE(t2.actDeliveredDate) BETWEEN DATE(fromDate) AND DATE(toDate)
GROUP BY item_sgst_percent;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_optical_source_wise_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_optical_source_wise_report`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN 
SELECT 
    sum(t1.TotalAmt_paid) totalAmount,
    t3.Source
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId 
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id = 3
		JOIN
	tblopticalsalepatientregistration t3 on t3.aPatientId = t1.nPatient_Id -- AND t3.Patient_Type = 1 if want bari EMR then remove this comment
		AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1)
	GROUP BY t3.Source;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_EMR_Pharma_AmountCollectionontheDayForDashboard` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_EMR_Pharma_AmountCollectionontheDayForDashboard`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN

declare advAmt float;
declare retAmt float;
declare discountAmt float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare otherAmt float;

SELECT 
    SUM(totalDiscountAmount),
    SUM(totalcashAmt),
    SUM(totalcardAmt),
    SUM(otherPayAmt)
    
    INTO 
    discountAmt,
    cashAmt,
    cardAmt,
    otherAmt
FROM
    tbl_pharma_patients_main_sales
WHERE
    DATE(insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        -- AND nBranchId IN ('1,2,3');
		AND if(branchId <> '-1', nBranchId IN (branchId), 1=1);

SELECT 
    SUM(returnAmount) into retAmt
FROM
    tbl_pharma_sales_main_returns t1
        JOIN
    tbl_pharma_patients_main_sales t2 ON t2.aSalesId = t1.nMainSaleId
        AND (DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        -- AND t2.nBranchId IN ('1,2,3');
        AND if(branchId <> '-1', t2.nBranchId IN (branchId), 1=1);

SELECT 
    0 advAmt,
    IFNULL(retAmt, 0) retAmt,
    IFNULL(discountAmt, 0) discountAmt,
    IFNULL(cashAmt, 0) cashAmt,
    IFNULL(cardAmt, 0) cardAmt,
    0 chequeAmt,
    IFNULL(otherAmt, 0) otherAmt;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_pharma_consultant_contibutionreport` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_pharma_consultant_contibutionreport`(
in fromDate text,
in toDate text,
in branchId text,
in consltId text
)
BEGIN
declare prescibedCount int;
declare convertedCount int;
declare revenue float;

SELECT 
    count(*) into prescibedCount
FROM
    tbl_pharma_patientsregistration t1
WHERE
    t1.patienttype IN (2 , 3)
        AND DATE(t1.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND IF(branchId <> '-1', FIND_IN_SET(t1.nBranchId, branchId), 1 = 1)
        AND IF(consltId <> '-1', FIND_IN_SET(t1.nConsultantId, consltId), 1 = 1);
        
SELECT 
    count(*) into convertedCount
FROM
    tbl_pharma_patientsregistration t1
WHERE
    t1.patienttype IN (2 , 3)
		AND t1.isSold = 1
        AND DATE(t1.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND IF(branchId <> '-1', FIND_IN_SET(t1.nBranchId, branchId), 1 = 1)
        AND IF(consltId <> '-1', FIND_IN_SET(t1.nConsultantId, consltId), 1 = 1);
        
SELECT 
    sum(t2.totalPaidAmt) into revenue
FROM
    tbl_pharma_patientsregistration t1
    JOIN tbl_pharma_patients_main_sales t2 on t2.nPharmaPatientId = t1.aPatientPharmaId
WHERE
    t1.patienttype IN (2 , 3)
		AND t1.isSold = 1
        AND DATE(t1.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND IF(branchId <> '-1', FIND_IN_SET(t1.nBranchId, branchId), 1 = 1)
        AND IF(consltId <> '-1', FIND_IN_SET(t1.nConsultantId, consltId), 1 = 1);
        
select prescibedCount, convertedCount, revenue;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_emr_pharma_eachduration_amt` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_emr_pharma_eachduration_amt`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN

declare paidAmt float;
/*declare retAmt float; */


declare advAmt float;
declare retAmt float;
declare discountAmt float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare otherAmt float;

SELECT 
    SUM(totalDiscountAmount),
    SUM(totalcashAmt),
    SUM(totalcardAmt),
    SUM(otherPayAmt)
INTO discountAmt , cashAmt , cardAmt , otherAmt FROM
    tbl_pharma_patients_main_sales
WHERE
    DATE(insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND IF(branchId <> '-1',
        nBranchId IN (branchId),
        1 = 1);

SELECT 
    SUM(returnAmount)
INTO retAmt FROM
    tbl_pharma_sales_main_returns t1
        JOIN
    tbl_pharma_patients_main_sales t2 ON t2.aSalesId = t1.nMainSaleId
        AND (DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND IF(branchId <> '-1',
        t2.nBranchId IN (branchId),
        1 = 1);

    
set paidAmt = (SELECT 
    SUM(totalPaidAmt) paidAmt
FROM
    tbl_pharma_patients_main_sales
WHERE
    DATE(insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        -- AND nBranchId IN (branchId));
        AND if(branchId <> '-1', nBranchId IN (branchId), 1=1));

/* set retAmt = (SELECT 
    SUM(returnAmount) retAmt
FROM
    tbl_pharma_sales_main_returns t1
        JOIN
    tbl_pharma_patients_main_sales t2 ON t2.aSalesId = t1.nMainSaleId
        AND (DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        -- AND t2.nBranchId IN (branchId));
        AND if(branchId <> '-1', t2.nBranchId IN (branchId), 1=1)); */
        
SELECT 
    IFNULL(paidAmt, 0) - IFNULL(retAmt, 0) AS TotalAmt_paid,
    0 advAmt,
    IFNULL(retAmt, 0) retAmt,
    IFNULL(discountAmt, 0) discountAmt,
    IFNULL(cashAmt, 0) cashAmt,
    IFNULL(cardAmt, 0) cardAmt,
    0 chequeAmt,
    IFNULL(otherAmt, 0) otherAmt;

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_getOpticalGpCollectionsToEMR` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_getOpticalGpCollectionsToEMR`(
in fromDate text,
in branchId text
)
BEGIN
declare orderedGpOrders int;
declare gpWithoutOrders int;
declare noOfGps int;
declare noOfGpsOrders int;
declare gspOrderAmount float;
declare gpsOrderAmountCollection float;
declare gpsOrderReturnAmount float;
declare gpsOrderCollection float;



declare mtdorderedGpOrders int;
declare mtdgpWithoutOrders int;
declare mtdnoOfGps int;
declare mtdnoOfGpsOrders int;
declare mtdgspOrderAmount float;
declare mtdgpsOrderAmountCollection float;
declare mtdgpsOrderReturnAmount float;
declare mtdgpsOrderCollection float;
declare currentMomthFirstDate date;




declare lmtdnoOfGps int;
declare lmtdnoOfGpsOrders int;
declare lmtdgspOrderAmount float;
declare lmtdgpsOrderAmountCollection float;
declare lmtdgpsOrderReturnAmount float;
declare lmtdgpsOrderCollection float;
declare previousMonCurrentDate date;
declare previousMonFirstDate date;



  
  SELECT 
    COUNT(*)
INTO orderedGpOrders  FROM  

(
select count(*) from 
    tblopticalpatientrefractiondetails T1
        JOIN
    tbl_opticalsale_orders T2 ON (T2.nPatient_Id = T1.nPat_Id
        AND T2.nAppoint_Id = T1.nAppoint_Id)
WHERE
    (DATE(T2.orderDate) BETWEEN DATE(fromDate) AND DATE(fromDate))
        AND T1.Patient_Type = 1
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1) group by T2.nPatient_Id ,
            T2.nAppoint_Id  ) as T3;
            
            
            
SELECT  
    COUNT(*)
INTO gpWithoutOrders FROM
    tblopticalpatientrefractiondetails T2
WHERE
    DATE(T2.insertedDate) BETWEEN DATE(fromDate) AND DATE(fromDate)
        AND T2.patient_Type = 1
        AND IF(branchId <> '-1',
        FIND_IN_SET(T2.nbranchId, branchId),
        1 = 1)
        AND T2.opticalStatus = 1;
         
        
set noOfGps = gpWithoutOrders + orderedGpOrders ;

        

SELECT 
    COUNT(*)
INTO noOfGpsOrders FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(fromDate) and 
       Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(is_Branch_Id, branchId),
        1 = 1) ;
        
        
        
        SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO gspOrderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(fromDate))
       and t2.Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
        
        
     
             SELECT 
    SUM(IFNULL(t1.returnAmount, 0)) into gpsOrderReturnAmount
FROM
    tbl_optical_sale_main_returns t1
WHERE 
    DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(fromDate)
       AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1) ; 
        
        
        SELECT 
    SUM(t1.TotalAmt_paid)
INTO gpsOrderAmountCollection FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(fromDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId  IN (1,2,3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
          set gpsOrderCollection = ifnull(gpsOrderAmountCollection,0) -  ifnull(gpsOrderReturnAmount,0);


  
  -- LMTD

set previousMonFirstDate = (select last_day((SUBDATE(fromDate, INTERVAL 1 month)) - interval 1 month) + interval 1 day) ;

set previousMonCurrentDate = (SELECT date(SUBDATE(fromDate, INTERVAL 1 month))) ;


SELECT 
    COUNT(*)
INTO lmtdnoOfGps FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
WHERE
    T2.opticalStatus IN (1 , 2)
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        

SELECT 
    COUNT(*)
INTO lmtdnoOfGpsOrders FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate) and 
       Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(is_Branch_Id, branchId),
        1 = 1) ;
        
        
        
        SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO lmtdgspOrderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate))
       and t2.Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
        
        
     
             SELECT 
    SUM(IFNULL(t1.returnAmount, 0)) into lmtdgpsOrderReturnAmount
FROM
    tbl_optical_sale_main_returns t1
WHERE 
    DATE(t1.returnDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate)
       AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1) ; 
        
        
        SELECT 
    SUM(t1.TotalAmt_paid)
INTO lmtdgpsOrderAmountCollection FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId  IN (1,2,3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
          set lmtdgpsOrderCollection = ifnull(lmtdgpsOrderAmountCollection,0) -  ifnull(lmtdgpsOrderReturnAmount,0);

-- MTD


set currentMomthFirstDate = (select last_day(date(fromDate) - interval 1 month) + interval 1 day ) ;


  
  
  SELECT 
    COUNT(*)
INTO mtdorderedGpOrders  FROM  

(
select count(*) from 
    tblopticalpatientrefractiondetails T1
        JOIN
    tbl_opticalsale_orders T2 ON (T2.nPatient_Id = T1.nPat_Id
        AND T2.nAppoint_Id = T1.nAppoint_Id)
WHERE
    (DATE(T2.orderDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate))
        AND T1.Patient_Type = 1
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1) group by T2.nPatient_Id ,
            T2.nAppoint_Id  ) as T3;
            
            
  
        
SELECT 
    COUNT(*)
INTO mtdgpWithoutOrders FROM
    tblopticalpatientrefractiondetails T2
WHERE
    DATE(T2.insertedDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate)
        AND T2.patient_Type = 1
        AND IF(branchId <> '-1',
        FIND_IN_SET(T2.nbranchId, branchId),
        1 = 1)
        AND T2.opticalStatus = 1;
         
        
set mtdnoOfGps = mtdgpWithoutOrders + mtdorderedGpOrders ;

        
        

SELECT 
    COUNT(*)
INTO mtdnoOfGpsOrders FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate) and 
       Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(is_Branch_Id, branchId),
        1 = 1) ;
        
        
        
        SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO mtdgspOrderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate))
       and t2.Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
        
        
     
             SELECT 
    SUM(IFNULL(t1.returnAmount, 0)) into mtdgpsOrderReturnAmount
FROM
    tbl_optical_sale_main_returns t1
WHERE 
    DATE(t1.returnDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate)
       AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1) ; 
        
         
        SELECT 
    SUM(t1.TotalAmt_paid)
INTO mtdgpsOrderAmountCollection FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId  IN (1,2,3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
          set mtdgpsOrderCollection = ifnull(mtdgpsOrderAmountCollection,0) -  ifnull(mtdgpsOrderReturnAmount,0);


/*

SELECT 
    COUNT(*)
INTO noOfGps FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
WHERE
    T2.opticalStatus IN (1 , 2)
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(fromDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        

SELECT 
    COUNT(*)
INTO noOfGpsOrders FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
WHERE
 --    T2.opticalStatus = 2
         DATE(T1.lastModifiedDate) BETWEEN DATE(fromDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
SELECT 
    SUM(IFNULL(T4.item_total_amt_without_gst, 0))
INTO gspOrderAmount FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
        JOIN
    tbl_opticalsale_orderdetails T4 ON T4.nOrderId = T3.OrderId
WHERE
  --  T2.opticalStatus = 2
         DATE(T1.lastModifiedDate) BETWEEN DATE(fromDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
        
        
SELECT 
    SUM(t5.TotalAmt_paid)
INTO gpsOrderAmountCollection FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
        JOIN
    tbl_opticalsale_payment_each_tran t5 ON t5.OrderId = T3.OrderId
WHERE
    (DATE(t5.PaymentDate) BETWEEN DATE(fromDate) AND DATE(fromDate))
        AND t5.PaymentTypeId IN (1 , 2, 3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t5.nBranchId, branchId),
        1 = 1);
        
        
        
        
SELECT 
    SUM(IFNULL(T3.returnAmount, 0))
INTO gpsOrderReturnAmount FROM
    tblopticalpatientrefractiondetails T1
        JOIN
    tbl_opticalsale_orders T2 ON T2.nPatient_Id = T1.nPat_Id
        AND T2.nAppoint_Id = T1.nAppoint_Id
        JOIN
    tbl_optical_sale_main_returns T3 ON T2.OrderId = T3.nOrderId
WHERE
    DATE(T3.returnDate) BETWEEN DATE(fromDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T3.nBranchId, branchId),
        1 = 1); 
     
  set gpsOrderCollection = ifnull(gpsOrderAmountCollection,0) -  ifnull(gpsOrderReturnAmount,0);
  
  
  
  -- LMTD

set previousMonFirstDate = (select last_day((SUBDATE(fromDate, INTERVAL 1 month)) - interval 1 month) + interval 1 day) ;

set previousMonCurrentDate = (SELECT date(SUBDATE(fromDate, INTERVAL 1 month))) ;

  
  
  
SELECT 
    COUNT(*)
INTO lmtdnoOfGps FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
WHERE
    T2.opticalStatus IN (1 , 2)
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        


SELECT 
    COUNT(*)
INTO lmtdnoOfGpsOrders FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
WHERE
    T2.opticalStatus = 2
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
SELECT 
    SUM(IFNULL(T4.item_total_amt_without_gst, 0))
INTO lmtdgspOrderAmount FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
        JOIN
    tbl_opticalsale_orderdetails T4 ON T4.nOrderId = T3.OrderId
WHERE
    T2.opticalStatus = 2
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
        
        
SELECT 
    SUM(t5.TotalAmt_paid)
INTO lmtdgpsOrderAmountCollection FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
        JOIN
    tbl_opticalsale_payment_each_tran t5 ON t5.OrderId = T3.OrderId
WHERE
    (DATE(t5.PaymentDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate))
        AND t5.PaymentTypeId IN (1 , 2, 3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t5.nBranchId, branchId),
        1 = 1);
        
        
        
        
SELECT 
    SUM(IFNULL(T3.returnAmount, 0))
INTO lmtdgpsOrderReturnAmount FROM
    tblopticalpatientrefractiondetails T1
        JOIN
    tbl_opticalsale_orders T2 ON T2.nPatient_Id = T1.nPat_Id
        AND T2.nAppoint_Id = T1.nAppoint_Id
        JOIN
    tbl_optical_sale_main_returns T3 ON T2.OrderId = T3.nOrderId
WHERE  
    DATE(T3.returnDate) BETWEEN DATE(previousMonFirstDate) AND DATE(previousMonCurrentDate)
        AND IF(branchId <> '-1', 
        FIND_IN_SET(T3.nBranchId, branchId),
        1 = 1);  
     
  set lmtdgpsOrderCollection = ifnull(lmtdgpsOrderAmountCollection,0) -  ifnull(lmtdgpsOrderReturnAmount,0);
  
    -- MTD

set currentMomthFirstDate = (select last_day(date(fromDate) - interval 1 month) + interval 1 day ) ;


  
  
SELECT 
    COUNT(*)
INTO mtdnoOfGps FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
WHERE
    T2.opticalStatus IN (1 , 2)
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        


SELECT 
    COUNT(*)
INTO mtdnoOfGpsOrders FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
WHERE
    T2.opticalStatus = 2
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
SELECT 
    SUM(IFNULL(T4.item_total_amt_without_gst, 0))
INTO mtdgspOrderAmount FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
        JOIN
    tbl_opticalsale_orderdetails T4 ON T4.nOrderId = T3.OrderId
WHERE
    T2.opticalStatus = 2
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
        
        
SELECT 
    SUM(t5.TotalAmt_paid)
INTO mtdgpsOrderAmountCollection FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
        JOIN
    tbl_opticalsale_payment_each_tran t5 ON t5.OrderId = T3.OrderId
WHERE
    (DATE(t5.PaymentDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate))
        AND t5.PaymentTypeId IN (1 , 2, 3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t5.nBranchId, branchId),
        1 = 1);
        
        
        
        
SELECT 
    SUM(IFNULL(T3.returnAmount, 0))
INTO mtdgpsOrderReturnAmount FROM
    tblopticalpatientrefractiondetails T1
        JOIN
    tbl_opticalsale_orders T2 ON T2.nPatient_Id = T1.nPat_Id
        AND T2.nAppoint_Id = T1.nAppoint_Id
        JOIN
    tbl_optical_sale_main_returns T3 ON T2.OrderId = T3.nOrderId
WHERE
    DATE(T3.returnDate) BETWEEN DATE(currentMomthFirstDate) AND DATE(fromDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T3.nBranchId, branchId),
        1 = 1); 
     
  set mtdgpsOrderCollection = ifnull(mtdgpsOrderAmountCollection,0) -  ifnull(mtdgpsOrderReturnAmount,0);
  
  
  */
SELECT 
    noOfGps,
    noOfGpsOrders,
    gspOrderAmount,
    gpsOrderAmountCollection,
    gpsOrderReturnAmount,
    gpsOrderCollection,
    mtdnoOfGps,
    mtdnoOfGpsOrders,
    mtdgspOrderAmount,
    mtdgpsOrderAmountCollection,
    mtdgpsOrderReturnAmount,
    mtdgpsOrderCollection,
    lmtdnoOfGps,
    lmtdnoOfGpsOrders,
    lmtdgspOrderAmount,
    lmtdgpsOrderAmountCollection,
    lmtdgpsOrderReturnAmount,
    lmtdgpsOrderCollection;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_get_main_data_order_dashboard` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_get_main_data_order_dashboard`(
in fromDate varchar(25),
in todate varchar(25),
in in_branchIds tinytext
)
BEGIN
SELECT 
    COUNT(DISTINCT t1.OrderId) AS orderCount,
    t1.OrderId,
    t1.Current_Main_Status_Id,
    t1.Current_Sub_Statusa_Id,
    t2.Status_Name,
    t3.SubStatus_Name
FROM
    (SELECT 
        *
    FROM
        tbl_opticalsale_orders
    WHERE
        DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(todate) and if(in_branchIds <> '-1', find_in_set(is_Branch_Id, in_branchIds), 1=1)) t1
        JOIN
    tbl_mst_opticalsale_main_status t2 ON t1.Current_Main_Status_Id = t2.aStatusId
        JOIN
    tbl_mst_opticalsale_sub_status t3 ON IF(t1.Current_Main_Status_Id = 1,
        t1.Current_Sub_Statusa_Id = t3.aSubStatusId,
        1 = 1)
GROUP BY t1.Current_Main_Status_Id , IF(t1.Current_Main_Status_Id = 1,
    t1.Current_Sub_Statusa_Id,
    '')
ORDER BY t1.Current_Main_Status_Id , t1.Current_Sub_Statusa_Id;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_Get_NotIn_Stock_ItemDetails` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_Get_NotIn_Stock_ItemDetails`(
in in_isCompanyOrSupplier int,
in in_companySupplierId int,
in in_isCustomerOrConsumer int,
in in_customerOrConsumerId int,
in in_searchText varchar(250)
)
BEGIN
select * FROM (
select
            itemratema0_.aitemrateId as itemRateId,
            itemdetail1_.aItemId_pk as itemId,
            itemdetail1_.itemCode as itemCode,
            itemdetail1_.itemName as itemName,
            hsncode2_.hsnCode as hsnCode,
            itemratema0_.purchasePrice as purchasePrice,
            itemratema0_.sellingPrice as sellingPrice,
            hsncode2_.gstPercentage as gstPercentage,
            hsncode2_.sgstPercentage as sgstPercentage,
            hsncode2_.cgstPercentage as cgstPercentage,
            itemdetail1_.nCategoryId_fk as categoryId,
            itemratema0_.MRP as mrp,
            hsncode2_.igstPercentage as igstPercentage ,
            itemratema0_.nSupplierId_fk AS supplierId,
            itemratema0_.iscustomerorconsumer AS isCustomerOrConsumer,
            itemratema0_.nBranchId AS branchId,
            itemratema0_.ndepotId AS depotId
        from 
            tbl_item_rate_master itemratema0_ 
        inner join
            tbl_mst_items_details itemdetail1_ 
                on itemratema0_.nItemId_fk=itemdetail1_.aItemId_pk 
        inner join
            tbl_mst_hsn_codes hsncode2_ 
                on itemratema0_.nhsnId_fk=hsncode2_.aHsnId_pk 
        where
            itemratema0_.isActive=1 
            and itemratema0_.iscompanyorsupplier=in_isCompanyOrSupplier 
         
            and itemratema0_.companyassupplierId=case itemratema0_.iscompanyorsupplier 
                when 1 then in_companySupplierId 
                else '<>-1' 
            end 
            and itemratema0_.nSupplierId_fk=case itemratema0_.iscompanyorsupplier 
                when 3 then in_companySupplierId 
                else '<>-1' 
            end 
         /*   and itemratema0_.ndepotId=case itemratema0_.iscustomerorconsumer 
                when 1 then in_customerOrConsumerId 
                else '<>-1' 
            end 
            and itemratema0_.nBranchId=case itemratema0_.iscustomerorconsumer 
                when 2 then in_customerOrConsumerId 
                else '<>-1' 
            end    and itemratema0_.iscustomerorconsumer=in_isCustomerOrConsumer   */
            and (
                itemdetail1_.itemName like CONCAT(in_searchText, '%') 
            )  
        order by
            itemratema0_.aitemrateId desc ) AS TBLNID  group by  TBLNID.supplierId,TBLNID.itemId; -- ,TBLNID.isCustomerOrConsumer,TBLNID.branchId,TBLNID.depotId 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_get_po_items_from_branch_inv_gen_from_depo` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_get_po_items_from_branch_inv_gen_from_depo`(
in branchPoId int,
in isExpiryBatchItem boolean,
in depoId int
)
BEGIN

declare itemBatchCats varchar(150);
declare isPoORBrchTran int;
declare val int;
-- set val = 0;
set itemBatchCats = (select group_concat(aCategoryId_pk) from tbl_mst_category where isBatchNum_Expiey_Category = 1);
-- select itemBatchCats;

set isPoORBrchTran = (select typeOfRequest from tbl_po_main_details where apoid = branchPoId);

SELECT 
    t1.apoeachid,
    t1.npoid_fk,
    t1.item_id_fk,
    t1.item_code,
    t1.item_name,
    t1.item_order_qty,
    t2.nPoEachId,
    IFNULL(t2.receivedQty, 0) receivedQty,  
    CASE 
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     IFNULL(t3.available_qty, 0)
    else 
     IFNULL(t4.available_qty, 0)
    end as available_qty,
    -- IFNULL(t3.available_qty, 0) available_qty,
    CASE 
    -- when isExpiryBatchItem is false
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     IFNULL(t3.itemID, 0)
    else 
     IFNULL(t4.itemID, 0)
    end as itemID,
    -- t3.itemID,
    CASE 
    -- when isExpiryBatchItem is false
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     IFNULL(t3.grnID, 0)
    else 
     IFNULL(t4.grnID, 0)
    end as grnID,
    -- t3.grnID,
    CASE 
    -- when isExpiryBatchItem is false
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     IFNULL(t3.grn_number, '')
    else 
     IFNULL(t4.grn_number, '')
    end as grn_number,
    -- t3.grn_number,
    CASE 
    -- when isExpiryBatchItem is false
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     IFNULL(t3.itemAvailId, 0) 
    else 
     IFNULL(t4.itemAvail_expire_Id, 0)
    end as itemAvailId,
    -- t3.itemAvailId
    CASE 
    -- when isExpiryBatchItem is false
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     ''
    else 
     IFNULL(t4.batchNo, '')
    end as batchNo,
    CASE 
    -- when isExpiryBatchItem is false
    -- when INSTR(itemBatchCats, t3.Category_Id) < 0
    when SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null
    then 
     date('1900-01-01')
    else 
     IFNULL(date(t4.expiryDate), date('1900-01-01'))
    end as expiryDate,
    t1.nSupplierItemMapid,
    t1.categoryid_fk,
    CAST(CONV(ifnull(t1.po_item_brchtrans_status_id, 0), 16, 19) AS UNSIGNED INTEGER) as  po_item_brchtrans_status_id 
FROM
    tbl_po_each_item_details t1  
        LEFT JOIN
    (SELECT 
        nPoEachIdBranch_fk nPoEachId, SUM(ifnull(issuedqty_fromdepo,0)) receivedQty
    FROM
        tbl_grn_for_po_each_item_orders
    WHERE
        nPoIdBranch_fk = branchPoId
    GROUP BY nPoEachIdBranch_fk) t2 ON t1.apoeachid = t2.nPoEachId
        LEFT JOIN
    (SELECT 
        itemAvailId, itemID, grnID, grn_number, available_qty, Category_Id
    FROM
        tbl_item_grn_availability
    WHERE
        if(isPoORBrchTran!=4, is_Depo_Id = depoId, is_Branch_Id=depoId) and available_qty > 0) t3 on t3.itemID = t1.item_id_fk
		LEFT JOIN
    (SELECT 
        itemAvail_expire_Id, itemID, grnID, grn_number, available_qty, batchNo, expiryDate, Category_Id
    FROM
        tbl_item_grn_module_expire_availability
    WHERE
        if(isPoORBrchTran!=4, is_Depo_Id = depoId, is_Branch_Id=depoId) and available_qty > 0) t4 on t4.itemID = t1.item_id_fk
WHERE
t1.npoid_fk = branchPoId and t1.poItemStatusId in (2,4,7) and 
if(SUBSTRING_INDEX(SUBSTRING_INDEX(itemBatchCats, ',', t3.Category_Id), ',', -1) is not null,
    IFNULL(t3.available_qty, 0) > 0, 
     IFNULL(t4.available_qty, 0) > 0)
     and t1.po_item_brchtrans_status_id < 2
    order by t1.item_id_fk
    ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_get_sub_data_order_dashboard` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_get_sub_data_order_dashboard`(
in fromDate varchar(25),
in todate varchar(25),
in in_branchIds tinytext,
in mainStat int,
in subStat int
)
BEGIN
SELECT 
    COUNT(DISTINCT t1.OrderId) AS orderCount,
    t1.OrderId,
    t1.Current_Main_Status_Id,
    t1.Current_Sub_Statusa_Id,
    date(t1.orderDate) as orderDate
FROM
        (SELECT 
        *
    FROM
        tbl_opticalsale_orders
    WHERE
        DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(todate) and if(in_branchIds <> '-1', find_in_set(is_Branch_Id, in_branchIds), 1=1)
        and 
        IF(mainStat = 1, (Current_Main_Status_Id = mainStat and Current_Sub_Statusa_Id = subStat), Current_Main_Status_Id = mainStat)) t1
        
GROUP BY date(t1.orderDate);
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_collection_dashboard_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_optical_collection_dashboard_report`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
declare todaysOrders int;
declare orderAmount float;
declare advAmt float;
declare settlementCount int;
declare settlementAmt float;
declare settleOrderAmount float;
declare returnAmount float;
declare returnOrders int;

SELECT 
    COUNT(*)
INTO todaysOrders FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(toDate) and 
       Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(is_Branch_Id, branchId),
        1 = 1);
        
SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO orderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
       and t2.Current_Main_Status_Id NOT IN (3,4,5)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
		
SELECT 
    SUM(t1.TotalAmt_paid)
INTO advAmt FROM
    tbl_opticalsale_payment_each_tran t1 
    
        where (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
      --  AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId IN (1 ,2)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
     
       
SELECT 
    COUNT(*)
INTO settlementCount FROM
    tbl_opticalsale_orders
WHERE
    DATE(lastModifiedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
           and Current_Main_Status_Id  IN (3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(is_Branch_Id, branchId),
        1 = 1);
        
        
        SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO settleOrderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.lastModifiedDate) BETWEEN DATE(fromDate) AND DATE(toDate))
       and t2.Current_Main_Status_Id  IN (3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1); 
          
SELECT 
    SUM(t1.TotalAmt_paid)
INTO settlementAmt FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId  IN (3)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
             SELECT 
    SUM(IFNULL(t1.returnAmount, 0)) into returnAmount
FROM
    tbl_optical_sale_main_returns t1
WHERE 
    DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)
       AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1) ; 
        
        SELECT 
   COUNT(*)
INTO returnOrders
FROM 
    tbl_optical_sale_main_returns t1
WHERE 
    DATE(t1.returnDate) BETWEEN DATE(fromDate) AND DATE(toDate)
       AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1) ; 
SELECT todaysOrders,orderAmount ,settlementCount,advAmt,settlementAmt,settleOrderAmount,returnAmount,returnOrders;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_contacLense_collection_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_optical_contacLense_collection_report`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN

declare todaysOrders INT;
declare orderAmount float;
declare advAmt float;
declare settlementAmt float; 

SELECT 
    COUNT(*)
INTO todaysOrders FROM
    tbl_opticalsale_orderdetails TBLOED
        JOIN 
    tbl_opticalsale_orders TBLOD ON TBLOD.OrderId = TBLOED.nOrderId
WHERE
    DATE(TBLOD.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND Current_Main_Status_Id != 4
        AND nCategoryId = 3
        AND IF(branchId <> '-1', 
        FIND_IN_SET(TBLOD.is_Branch_Id, branchId),
        1 = 1)
-- GROUP BY TBLOED.nOrderId
;


SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO orderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND nCategoryId = 3
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
		
        
SELECT 
    SUM(t1.TotalAmt_paid)
INTO advAmt FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        JOIN
    tbl_opticalsale_orderdetails t3 ON t2.OrderId = t3.nOrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t3.nCategoryId = 3
        AND t1.PaymentTypeId IN (1 , 2)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
        
SELECT 
    SUM(t1.TotalAmt_paid)
INTO settlementAmt FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        JOIN
    tbl_opticalsale_orderdetails t3 ON t2.OrderId = t3.nOrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t3.nCategoryId = 3
        AND t1.PaymentTypeId NOT IN (1 , 2)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
     
SELECT todaysOrders, orderAmount, advAmt, settlementAmt;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_flash_dashboard_daily_coll_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_optical_flash_dashboard_daily_coll_report`(
in currDateFrom text,
in currDateTo text,
in financialYearFrom text,
in financialYearTo text,
in branchId text
)
BEGIN

declare newOrderCount int;
declare deliveredCount int;
declare advAmt float;
declare settlementAmt float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare creditAmt float;
declare netRevenue_FinancialYear float;

SELECT 
    COUNT(*) into newOrderCount
FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo)
        AND Current_Main_Status_Id != 4
        -- AND is_Branch_Id IN (1 , 2, 3);
        -- AND if(branchId <> '-1', is_Branch_Id IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(is_Branch_Id, branchId), 1=1);
        
SELECT 
    COUNT(*) into deliveredCount
FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo)
        AND Current_Main_Status_Id = 3
        -- AND is_Branch_Id IN (1 , 2, 3);
        -- AND if(branchId <> '-1', is_Branch_Id IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(is_Branch_Id, branchId), 1=1);

SELECT 
    SUM(t1.TotalAmt_paid) INTO advAmt
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.TotalAmt_paid) INTO settlementAmt
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentTypeId not in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into cardAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into chequeAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into creditAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(currDateFrom) AND DATE(currDateTo))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId > 3
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1); 
        
SELECT 
    SUM(t1.TotalAmt_paid) INTO netRevenue_FinancialYear
FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(financialYearFrom) AND DATE(financialYearTo))
        AND t2.Current_Main_Status_Id = 3
        -- AND t1.PaymentTypeId not in (1,2)
        -- AND t1.nBranchId IN (1 , 2, 3));
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    newOrderCount,
    deliveredCount,
    advAmt,
    settlementAmt,
    cashAmt,
    cardAmt,
    chequeAmt,
    creditAmt,
    netRevenue_FinancialYear;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_flash_dashboard_month_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_optical_flash_dashboard_month_report`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN

declare orders int;
declare orderAmount float;
declare cgstAmount float;
declare sgstAmount float;
declare openOrders int;
declare openOrdersAmount float;
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare creditAmt float;

SELECT 
    COUNT(*) into orders 
FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND Current_Main_Status_Id != 4
        -- AND is_Branch_Id IN (1 , 2, 3);
        -- AND if(branchId <> '-1', is_Branch_Id IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(is_Branch_Id, branchId), 1=1);
        
        
SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0)),
    SUM((IFNULL(t1.item_cgst_percent, 0) * IFNULL(t1.unitSellingPrice, 0)) / (100 + IFNULL(t1.item_gst_percent, 0))),
    SUM((IFNULL(t1.item_sgst_percent, 0) * IFNULL(t1.unitSellingPrice, 0)) / (100 + IFNULL(t1.item_gst_percent, 0)))
    into orderAmount, cgstAmount, sgstAmount
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
		
        
SELECT 
    COUNT(*) into openOrders
FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND Current_Main_Status_Id NOT IN (3 , 4)
        -- AND is_Branch_Id IN (1 , 2, 3);
        -- AND if(branchId <> '-1', is_Branch_Id IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(is_Branch_Id, branchId), 1=1);
        
        
SELECT 
    SUM(IFNULL(t1.unitSellingPrice, 0)) into openOrdersAmount
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id NOT IN (3,4)
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
                
SELECT 
    SUM(t1.PaymentAmount) into cardAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
                
SELECT 
    SUM(t1.PaymentAmount) into chequeAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into creditAmt
FROM
    tbl_opticalsale_order_payment_transcation t1 
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId > 3
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT orders, orderAmount, openOrders, cgstAmount, sgstAmount, openOrdersAmount, cashAmt, cardAmt, chequeAmt, creditAmt; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_flash_dashboard_pending_order_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_optical_flash_dashboard_pending_order_report`(
in fromDate_past text,
in toDate_past text,
in branchId text)
BEGIN

declare pendingOrderCount int;
declare pendingOrderValue float;
declare pendingOrderCount_notMin int;
declare pendingOrderValue_notMin float;
declare pendingOrderCount_collectedMin int;
declare pendingOrderValue_collectedMin float;

SELECT 
    COUNT(*) into pendingOrderCount
FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(toDate_past) AND DATE(fromDate_past)
        AND Current_Main_Status_Id in(1,2)
        AND if(branchId <> '-1', find_in_set(is_Branch_Id, branchId), 1=1);
        
SELECT 
    SUM(t1.asOfPaidAmt) into pendingOrderValue
FROM
    tbl_opticalsale_main_payment t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(toDate_past) AND DATE(fromDate_past))
        AND t2.Current_Main_Status_Id IN (1, 2)
        AND IF(branchId <> '-1', FIND_IN_SET(t1.nBranchId, branchId), 1 = 1);
        
SELECT 
    COUNT(t1.asOfPaidAmt) , SUM(IFNULL(t1.asOfPaidAmt, 0)) 
    INTO pendingOrderCount_collectedMin, pendingOrderValue_collectedMin
FROM
    tbl_opticalsale_main_payment t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(toDate_past) AND DATE(fromDate_past))
        AND t2.Current_Main_Status_Id IN (1, 2)
        AND IFNULL(t1.asOfPaidAmt, 0) >= IFNULL(t1.mustPayAdvance_Amount, 0)
        AND IF(branchId <> '-1', FIND_IN_SET(t1.nBranchId, branchId), 1 = 1);
        
SELECT 
    COUNT(t1.asOfPaidAmt) , SUM(IFNULL(t1.asOfPaidAmt, 0)) 
    INTO pendingOrderCount_notMin, pendingOrderValue_notMin
FROM
    tbl_opticalsale_main_payment t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(toDate_past) AND DATE(fromDate_past))
        AND t2.Current_Main_Status_Id IN (1, 2)
        AND IFNULL(t1.asOfPaidAmt, 0) < IFNULL(t1.mustPayAdvance_Amount, 0)
        AND IF(branchId <> '-1', FIND_IN_SET(t1.nBranchId, branchId), 1 = 1);

SELECT 
    pendingOrderCount,
    pendingOrderValue,
    pendingOrderCount_collectedMin,
    IFNULL(pendingOrderValue_collectedMin, 0) pendingOrderValue_collectedMin,
    pendingOrderCount_notMin,
    IFNULL(pendingOrderValue_notMin, 0) pendingOrderValue_notMin;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_gpOrders_collection_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_optical_gpOrders_collection_report`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
declare todaysOrders int;
declare gpOrders int;
declare orderedGpOrders int;
declare gpWithoutOrders int;

SELECT 
    COUNT(*)
INTO todaysOrders FROM
    tblopticalsalepatientregistration T1
        JOIN
    tblopticalpatientrefractiondetails T2 ON T2.nPat_Id = T1.aPatientId
        JOIN
    tbl_opticalsale_orders T3 ON T3.nPatient_Id = T2.nPat_Id
        AND T3.nAppoint_Id = T2.nAppoint_Id
WHERE
    T2.opticalStatus = 2
        AND DATE(T1.lastModifiedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1);
        
        
        
        
SELECT 
    COUNT(*)
INTO orderedGpOrders  FROM  

(
select count(*) from 
    tblopticalpatientrefractiondetails T1
        JOIN
    tbl_opticalsale_orders T2 ON (T2.nPatient_Id = T1.nPat_Id
        AND T2.nAppoint_Id = T1.nAppoint_Id)
WHERE
    (DATE(T2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND T1.Patient_Type = 1
        AND IF(branchId <> '-1',
        FIND_IN_SET(T1.nbranchId, branchId),
        1 = 1) group by T2.nPatient_Id ,
            T2.nAppoint_Id  ) as T3;
        
        
SELECT 
    COUNT(*)
INTO gpWithoutOrders FROM
    tblopticalpatientrefractiondetails T2
WHERE
    DATE(T2.insertedDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND T2.patient_Type = 1
        AND IF(branchId <> '-1',
        FIND_IN_SET(T2.nbranchId, branchId),
        1 = 1)
        AND T2.opticalStatus = 1;
         
        
set gpOrders = gpWithoutOrders + orderedGpOrders ;
        
        
        
	SELECT todaysOrders, gpOrders;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_lensOrders_collection_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_optical_lensOrders_collection_report`(
in fromDate text,
in toDate text,
in branchId text,
in in_lensType int
)
BEGIN

declare todaysOrders int;
declare orderAmount float;
declare advAmt float;

SELECT 
    COUNT(*) 
INTO todaysOrders FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate)) AND DATE(toDate) and (t1.nQty - t1.returnedQty) > 0 
        AND t2.Current_Main_Status_Id != 4
        AND t1.lensTypeId = in_lensType
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1)
;
        
        
        
SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0))
INTO orderAmount FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate)) and (t1.nQty - t1.returnedQty) > 0 
        AND t2.Current_Main_Status_Id != 4
        AND t1.lensTypeId = in_lensType
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
        
SELECT 
    SUM(t1.TotalAmt_paid)
INTO advAmt FROM
    tbl_opticalsale_payment_each_tran t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        JOIN
    tbl_opticalsale_orderdetails t3 ON t2.OrderId = t3.nOrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate)) and (t3.nQty - t3.returnedQty) > 0 
        AND t2.Current_Main_Status_Id != 4
        AND t3.lensTypeId = in_lensType
        AND t1.PaymentTypeId IN (1 , 2)
        AND IF(branchId <> '-1',
        FIND_IN_SET(t1.nBranchId, branchId),
        1 = 1);
        
        
        
SELECT todaysOrders, orderAmount, advAmt;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_pendingOrders_collection_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_optical_pendingOrders_collection_report`(
in fromDate text,
in toDate text,
in branchId text)
BEGIN
declare todaysOrders int;
declare orderAmount float;

SELECT 
    COUNT(*) into todaysOrders
FROM
    tbl_opticalsale_orders
WHERE
    DATE(orderDate) BETWEEN DATE(fromDate) AND DATE(toDate)
        AND Current_Main_Status_Id NOT IN (3 , 4,5)
        -- AND is_Branch_Id IN (1 , 2, 3);
        -- AND if(branchId <> '-1', is_Branch_Id IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(is_Branch_Id, branchId), 1=1);
        
        
SELECT 
    SUM(IFNULL(t1.item_total_amt_without_gst, 0)) into orderAmount 
FROM
    tbl_opticalsale_orderdetails t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.nOrderId
        AND (DATE(t2.orderDate) BETWEEN DATE(fromDate) AND DATE(toDate))
        AND t2.Current_Main_Status_Id NOT IN (3,4,5)
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
        
        
        select todaysOrders ,orderAmount ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_optical_today_collection_report` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_optical_today_collection_report`(
in fromDate text,
in toDate text,
in branchId text
)
BEGIN
declare cashAmt float;
declare cardAmt float;
declare chequeAmt float;
declare creditAmt float;

     
SELECT 
    SUM(t1.PaymentAmount) into cashAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
      --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 1
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
                
SELECT 
    SUM(t1.PaymentAmount) into cardAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
      --  AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 2
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
                
SELECT 
    SUM(t1.PaymentAmount) into chequeAmt
FROM
    tbl_opticalsale_order_payment_transcation t1
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
     --   AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId = 3
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT 
    SUM(t1.PaymentAmount) into creditAmt
FROM
    tbl_opticalsale_order_payment_transcation t1 
        JOIN
    tbl_opticalsale_orders t2 ON t2.OrderId = t1.OrderId
        AND (DATE(t1.PaymentDate) BETWEEN DATE(fromDate) AND DATE(toDate))
    --    AND t2.Current_Main_Status_Id != 4
        AND t1.PaymentModeId > 3
        -- AND if(branchId <> '-1', t1.nBranchId IN (branchId), 1=1);
        AND if(branchId <> '-1', find_in_set(t1.nBranchId, branchId), 1=1);
        
SELECT  cashAmt, cardAmt, chequeAmt, creditAmt; 

END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_POs_For_GRN` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `sproc_POs_For_GRN`(
in isConsumerOrCustomer int,
in customerOrConsumerId int,
in ponum varchar(250)
)
BEGIN
SELECT 
t1.apoeachid,
t1.npoid_fk,
t1.nSupplierItemMapid,
tu.userName,
t2.categoryid_fk,
    ifnull(t3.receivedQty, 0) receivedQuantity, 
    t1.apoeachid as poEachId,
    t1.item_id_fk itemIdFk,
    date(t2.po_date) poDate,
    case t1.is_company_or_supplier
		when 3 
        then ifnull(t5.Supplier_name,'')
        else 
        ifnull(t4.depotName,'')
	end as supplierName,
    -- t6.CategoryName categoryName, 
    '' categoryName,
    '' as serialNumber,
    t1.item_code as itemCode,
    t1.item_name as itemName,
    t1.item_order_qty as itemOrderQuantity,
    ifnull(t1.item_free_qty,0) as itemFreeQuantity,
    ifnull(t3.grnItemStatusText, 'NA') as grnItemStatusText,
    '' batchNo,
    date(now()) expiryDate,
    (ifnull(t1.item_free_qty, 0) + ifnull(t1.item_order_qty,0)) - ifnull(t3.receivedQty, 0) AS balanceQty,
    ifnull(t4.receivedQty, 0) receivedQuantity_temp,
    ifnull(t4.batchNo, '') batchNo_temp,
    date(ifnull(t4.expiryDate, now())) expiryDate_temp,
    ifnull(t4.serialNumber, '') serialNumber_temp,
    case ifnull(t4.receivedQty, 0)
		when 0
        then 0
        else 
			1
	end as itemTemp_GRN_Done,
    t2.po_total_items as po_total_items,
    t2.po_total_items_qty as po_total_items_qty,
    t2.po_total_po_aoumt_withtax as po_total_po_aoumt_withtax,
	t1.item_total_amt_with_gst,
	ifnull(TIRM.purchasePrice,0) as purchasePrice, 
	ifnull(TIRM.sellingPrice,0) as sellingPrice,
    ifnull(TIRM.nSupplierId_fk,0) as supplierId,
    -- ifnull(TMHC.gstPercentage,0) as gstPercentage,
    ifnull(t1.item_gst_percent,0)+ 0E0 as gstPercentage,
    ifnull(t2.gstType,0) as gstType,
    t1.categoryid_fk as each_categoryid_fk,
    ifnull(t2.payment_days,0) as payment_days
FROM
    tbl_po_each_item_details t1
	join tbl_po_main_details t2 on t2.po_number = ponum and t1.npoid_fk = t2.apoid  
		and if(isConsumerOrCustomer = 1, t2.po_from_depo_fk = customerOrConsumerId, t2.n_poid_from_branch_fk = customerOrConsumerId) and t1.poItemStatusId in (2,4,7)
   join tbl_user tu on tu.auserId = t2.nUserId_fk
    JOIN tbl_item_rate_master TIRM ON TIRM.aitemrateId = t1.nSupplierItemMapid
	JOIN tbl_mst_hsn_codes TMHC ON TMHC.aHsnId_pk = TIRM.nhsnId_fk
   left join
    (SELECT 
        SUM(TGFPEIO.receivedQty) AS receivedQty, TGFPEIO.nPoEachId, TGFPEIO.nItemId_fk, TGFPEIO.grnItemStatusText
    FROM
        tbl_grn_for_po_each_item_orders TGFPEIO
    WHERE
        if(isConsumerOrCustomer = 1, 
			nPoIdCentral_fk = (select apoid from tbl_po_main_details where po_number = ponum),  
            nPoIdBranch_fk = (select apoid from tbl_po_main_details where po_number = ponum)
		)
    GROUP BY nPoEachId , nItemId_fk) t3 ON t1.apoeachid = t3.nPoEachId
        AND t1.item_id_fk = t3.nItemId_fk
	
	left join
    (SELECT 
        SUM(receivedQty) AS receivedQty, nPoEachId, nItemId_fk, grnItemStatusText, batchNo, expiryDate, serialNumber
    FROM
        tbl_grn_for_po_each_item_orders_temp_mq
    WHERE
        if(isConsumerOrCustomer = 1, 
			nPoIdCentral_fk = (select apoid from tbl_po_main_details where po_number = ponum),  
            nPoIdBranch_fk = (select apoid from tbl_po_main_details where po_number = ponum)
		)
    GROUP BY nPoEachId , nItemId_fk) t4 ON t1.apoeachid = t4.nPoEachId
        AND t1.item_id_fk = t4.nItemId_fk
	left join
		tbl_company_depot_details t4 on t4.adepotId = t1.po_to_company_or_supplier_id_fk
    left join 
		tbl_mst_supplier t5 on t5.aSupplierId_pk = t1.po_to_supplier_id_fk
	-- join tbl_mst_category t6 on t6.aCategoryId_pk = t2.categoryid_fk
    ; 
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `sproc_updatePatientDetailsFromEMR` */;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `sproc_updatePatientDetailsFromEMR`(
in in_patientID varchar(20),
in in_patientName varchar(250),
in in_patientAge int,
in in_phoneNo varchar(20),
in in_address text,
in in_gender varchar(20)

)
BEGIN

declare updateResults int;
set updateResults = 0;
if exists(select * from tblopticalsalepatientregistration where emrPatientMRDNum = in_patientID)
then

update tblopticalsalepatientregistration
set 
PatientName = in_patientName,
PatientAge = in_patientAge,
PateintGender = in_gender,
MobileNumber = in_phoneNo,
Address = in_address

where emrPatientMRDNum = in_patientID  and  aPatientId <> 0; 

set updateResults = 1;

end if; 

select updateResults ;
END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `test_byname_gentest` */;
DELIMITER ;;
CREATE DEFINER=`root`@`%` PROCEDURE `test_byname_gentest`(
in isConsumerOrCustomer int,
in customerOrConsumerId int,
in ponum varchar(250)
)
BEGIN
SELECT 
t1.apoeachid,
t1.npoid_fk,
t1.nSupplierItemMapid,
tu.userName,
t2.categoryid_fk,
    ifnull(t3.receivedQty, 0) receivedQuantity,
    t1.apoeachid as poEachId,
    t1.item_id_fk itemIdFk,
    date(t2.po_date) poDate,
    case t1.is_company_or_supplier
		when 3 
        then ifnull(t5.Supplier_name,'')
        else 
        ifnull(t4.depotName,'')
	end as supplierName,
    t6.CategoryName categoryName, 
    '' as serialNumber,
    t1.item_code as itemCode,
    t1.item_name as itemName,
    t1.item_order_qty as itemOrderQuantity,
    ifnull(t3.grnItemStatusText, 'NA') as grnItemStatusText,
    '' batchNo,
    date(now()) expiryDate,
    t1.item_order_qty - ifnull(t3.receivedQty, 0) AS balanceQty,
    ifnull(t4.receivedQty, 0) receivedQuantity_temp,
    ifnull(t4.batchNo, '') batchNo_temp,
    date(ifnull(t4.expiryDate, now())) expiryDate_temp,
    ifnull(t4.serialNumber, '') serialNumber_temp,
    case ifnull(t4.receivedQty, 0)
		when 0
        then 0
        else 
			1
	end as itemTemp_GRN_Done
FROM
    tbl_po_each_item_details t1
	join tbl_po_main_details t2 on t2.po_number = ponum and t1.npoid_fk = t2.apoid  
		and if(isConsumerOrCustomer = 1, t2.po_from_depo_fk = customerOrConsumerId, t2.n_poid_from_branch_fk = customerOrConsumerId) and t1.poItemStatusId in (2,4,7)
   join tbl_user tu on tu.auserId = t2.nUserId_fk
   left join
    (SELECT 
        SUM(receivedQty) AS receivedQty, nPoEachId, nItemId_fk, grnItemStatusText
    FROM
        tbl_grn_for_po_each_item_orders
    WHERE
        if(isConsumerOrCustomer = 1, 
			nPoIdCentral_fk = (select apoid from tbl_po_main_details where po_number = ponum),  
            nPoIdBranch_fk = (select apoid from tbl_po_main_details where po_number = ponum)
		)
    GROUP BY nPoEachId , nItemId_fk) t3 ON t1.apoeachid = t3.nPoEachId
        AND t1.item_id_fk = t3.nItemId_fk
	left join
    (SELECT 
        SUM(receivedQty) AS receivedQty, nPoEachId, nItemId_fk, grnItemStatusText, batchNo, expiryDate, serialNumber
    FROM
        tbl_grn_for_po_each_item_orders_temp_mq
    WHERE
        if(isConsumerOrCustomer = 1, 
			nPoIdCentral_fk = (select apoid from tbl_po_main_details where po_number = ponum),  
            nPoIdBranch_fk = (select apoid from tbl_po_main_details where po_number = ponum)
		)
    GROUP BY nPoEachId , nItemId_fk) t4 ON t1.apoeachid = t4.nPoEachId
        AND t1.item_id_fk = t4.nItemId_fk
	left join
		tbl_company_depot_details t4 on t4.adepotId = t1.po_to_company_or_supplier_id_fk
    left join 
		tbl_mst_supplier t5 on t5.aSupplierId_pk = t1.po_to_supplier_id_fk
	join tbl_mst_category t6 on t6.aCategoryId_pk = t2.categoryid_fk; 
END ;;
DELIMITER ;


