<?php
if(isset($_POST['proceed']))
{
  $db=mysqli_connect("localhost","root","@#khadi$");
  $sql1="create DATABASE khadidb";
  mysqli_query($db,$sql1)or die(mysqli_error($db));
  $db1=mysqli_select_db("khadidb") or die(mysqli_error($db));

  $brcode = $_REQUEST['brcode'];
  $brname = $_REQUEST['brname'];
  $brgrp  = $_REQUEST['brgrp'];

  $sql[2]="create table khadidb.acgroups (
  gname char(200) NOT NULL DEFAULT '-',
  nature char(100) DEFAULT '-',
  level int(2) DEFAULT '100',
  type char(5) DEFAULT NULL,
  headgroup char(200) DEFAULT '',
  ghlevel int(11) DEFAULT '100',
  code char(10) DEFAULT '-',
  rnd char(5) DEFAULT 'No',
  id int(10) UNSIGNED NOT NULL DEFAULT '0'
)";

    $sql[3]="INSERT INTO khadidb.acgroups (gname, nature, level, type, headgroup, ghlevel, code, rnd, id) VALUES
  ('Depreciation', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'Dep559', 'No', 1),
  ('Salary & Allowences', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'Sal510', 'No', 2),
  ('Discount Allowed', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'Dis449', 'No', 3),
  ('Land & Building', 'Assets', 1, 'udf', 'FIXED ASSET', 100, 'Lan367', 'No', 4),
  ('Indirect Exp.', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'Ind611', 'No', 5),
  ('Purch. Returns', 'Income', 100, 'udf', 'PURCHASE RETURNS', 100, 'Pur974', 'No', 6),
  ('Opening Stock', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Ope525', 'No', 7),
  ('Purchases 12.5', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Pur789', 'No', 8),
  ('Indirect Inc.', 'Income', 100, 'udf', 'INDIRECT INCOME', 100, 'Ind627', 'No', 9),
  ('Sundry Debtors', 'Assets', 3, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Sun037', 'No', 10),
  ('Capital Account', 'Liabilities', 100, 'udf', 'SHARE CAPITAL', 100, 'Cap829', 'No', 11),
  ('Fixed Deposits', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Fix116', 'No', 12),
  ('Deposits', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Dep241', 'No', 13),
  ('-', 'Expenses', 100, NULL, 'SALES RETURNS', 1101, '-', 'No', 14),
  ('-', 'Income', 100, NULL, 'PURCHASE RETURNS', 1001, '-', 'No', 15),
  ('Bank O/d', 'Liabilities', 2, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'Ban522', 'No', 16),
  ('Plant and Machinery', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'Pla900', 'No', 17),
  ('Printing & Stationery', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'Pri466', 'No', 18),
  ('Sundry Creditors', 'Liabilities', 1, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'Sun224', 'No', 19),
  ('Furniture', 'Assets', 1, 'udf', 'FIXED ASSET', 100, 'Fur176', 'No', 20),
  ('Bank Accounts', 'Assets', 2, 'pdf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Ban165', 'No', 21),
  ('-', 'Liabilities', 100, NULL, 'P&L', 55, '-', 'No', 22),
  ('Provisions', 'Liabilities', 100, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'Pro775', 'No', 23),
  ('-', 'Assets', 100, NULL, 'CURRENT ASSETS,LOANS AND ADVANCES', 3, '-', 'No', 24),
  ('-', 'Assets', 100, NULL, 'FIXED ASSET', 1, '-', 'No', 25),
  ('-', 'Assets', 100, NULL, 'INVESTMENT', 2, '-', 'No', 26),
  ('-', 'Assets', 100, NULL, 'MISCELLANEOUS EXPENDITURE', 4, '-', 'No', 27),
  ('-', 'Expenses', 100, NULL, 'DIRECT EXPENSE', 1001, '-', 'No', 28),
  ('-', 'Expenses', 100, NULL, 'INDIRECT EXPENSE', 1002, '-', 'No', 29),
  ('-', 'Expenses', 100, NULL, 'PURCHASE', 1000, '-', 'No', 30),
  ('-', 'Income', 100, NULL, 'DIRECT INCOME', 1101, '-', 'No', 31),
  ('-', 'Income', 100, NULL, 'INDIRECT INCOME', 1102, '-', 'No', 32),
  ('-', 'Income', 100, NULL, 'SALES', 1100, '-', 'No', 33),
  ('-', 'Liabilities', 100, NULL, 'CONTIGENT LIABILITIES & NOTES', 56, '-', 'No', 34),
  ('-', 'Liabilities', 100, NULL, 'CURRENT LIABILITIES & PROVISIONS', 54, '-', 'No', 35),
  ('-', 'Liabilities', 100, NULL, 'RESERVES AND SURPLUS', 51, '-', 'No', 36),
  ('-', 'Liabilities', 100, NULL, 'SECURED LOAN', 52, '-', 'No', 37),
  ('-', 'Liabilities', 100, NULL, 'SHARE CAPITAL', 50, '-', 'No', 38),
  ('-', 'Liabilities', 100, NULL, 'UNSECURED LOAN', 53, '-', 'No', 39),
  ('Tools and Equipments', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'Too242', 'No', 40),
  ('Cash in hand', 'Assets', 1, 'pdf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Cas914', 'Yes', 41),
  ('Direct Inc.', 'Income', 100, 'udf', 'DIRECT INCOME', 100, 'Dir423', 'No', 42),
  ('Output Tax', 'Liabilities', 100, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'Out697', 'No', 43),
  ('Input Tax', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Inp746', 'No', 44),
  ('Sales 12.5', 'Income', 100, 'udf', 'SALES', 100, 'Sal446', 'No', 45),
  ('Sales Return', 'Expenses', 100, 'udf', 'SALES RETURNS', 100, 'Sal064', 'No', 46),
  ('Purchases Unreg.', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Pur935', 'No', 47),
  ('Stock Transfer In', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Sto598', 'No', 48),
  ('Stock Transfer Out', 'Income', 100, 'udf', 'SALES', 100, 'Sto670', 'No', 49),
  ('Branches', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Bra826', 'No', 50),
  ('LOANS', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'LOA472', 'No', 51),
  ('ADVANCES', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'ADV500', 'No', 52),
  ('AMOUNT RECEIVABLE', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'AMO544', 'No', 53),
  ('Amount Payable', 'Liabilities', 100, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'Amo838', 'No', 54),
  ('MOTOR VEHICLE', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'MOT324', 'No', 55),
  ('COMPUTER', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'COM729', 'No', 56),
  ('LAND', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'LAN931', 'No', 57),
  ('BUILDING', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'BUI943', 'No', 58),
  ('FIXED ASSETS', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'FIX111', 'No', 59),
  ('Electrical Fittings', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'Ele705', 'No', 60),
  ('CST Purchase', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'CST395', 'No', 61),
  ('INTER BRANCHES', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'INT856', 'No', 62),
  ('Direct Expenses', 'Expenses', 100, 'udf', 'DIRECT EXPENSE', 100, 'Dir116', 'No', 63),
  ('DUTIES & TAXES', 'Liabilities', 100, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'DUT775', 'No', 64),
  ('STAFF ADVANCES', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'STA117', 'No', 65),
  ('Travelling Expenses', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'Tra162', 'No', 66),
  ('Current Liabilities', 'Liabilities', 100, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'Cur858', 'No', 67),
  ('Current Assets', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'Cur016', 'No', 68),
  ('RENT OFFICE', 'Expenses', 100, 'udf', 'INDIRECT EXPENSE', 100, 'REN330', 'No', 69),
  ('Purchase CST', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Pur712', 'No', 70),
  ('Service Charge', 'Income', 100, 'udf', 'INDIRECT INCOME', 100, 'Ser385', 'No', 71),
  ('CST SALE', 'Income', 100, 'udf', 'SALES', 100, 'CST532', 'No', 72),
  ('FINANCIERS', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'FIN684', 'No', 73),
  ('PROFIT AND LOSS ACCOUNT', 'Liabilities', 100, 'udf', 'RESERVES AND SURPLUS', 100, 'PRO611', 'No', 74),
  ('PURCHASE 4', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'PUR011', 'No', 75),
  ('Spare Purchase', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Spa962', 'No', 76),
  ('Purchase Machine', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Pur991', 'No', 77),
  ('Purchase Spare Parts', 'Expenses', 100, 'udf', 'PURCHASE', 100, 'Pur005', 'No', 78),
  ('Sales -Spare Parts', 'Income', 100, 'udf', 'SALES', 100, 'Sal353', 'No', 79),
  ('Sales -Labour', 'Income', 100, 'udf', 'SALES', 100, 'Sal369', 'No', 80),
  ('GOODS IN TRANSIT', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'GOO023', 'No', 81),
  ('RENT DEPOSITS', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'REN856', 'No', 82),
  ('OTHER DEPOSITS', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'OTH377', 'No', 83),
  ('OTHER ADVANCES', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'OTH795', 'No', 84),
  ('LOOSE TOOLS', 'Assets', 100, 'udf', 'FIXED ASSET', 100, 'LOO885', 'No', 85),
  ('SALARY ADVANCE', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'SAL198', 'No', 86),
  ('INVESTMENTS', 'Assets', 100, 'udf', 'INVESTMENT', 100, 'INV786', 'No', 87),
  ('VAT COLLECTED AND PAID', 'Liabilities', 100, 'udf', 'CURRENT LIABILITIES & PROVISIONS', 100, 'VAT514', 'No', 88),
  ('ADVANCE TAX AND TDS', 'Assets', 100, 'udf', 'CURRENT ASSETS,LOANS AND ADVANCES', 100, 'ADV520', 'No', 89),
  ('abcd', 'Income', 100, 'udf', 'INDIRECT INCOME', 100, 'abc089', 'No', 90)";
    $sql[4]="create table khadidb.acperiod (acfrom date DEFAULT NULL,acto date DEFAULT NULL,
    id int(10) UNSIGNED NOT NULL DEFAULT '0') ENGINE=InnoDB DEFAULT CHARSET=latin1";
    $sql[5]="INSERT INTO khadidb.acperiod (acfrom, acto, id) VALUES('2015-04-01', '2016-03-31', 1)";
    $sql[6]="create table khadidb.adjstock (entrydate date NOT NULL ,brcode varchar(20) NOT NULL DEFAULT '',
  refno int(12) UNSIGNED NOT NULL DEFAULT '0',partcode varchar(100) DEFAULT NULL,partname varchar(200) DEFAULT NULL,
  rate double(14,2) DEFAULT NULL,qty double(14,2) DEFAULT '0.00',outqty double(14,2) DEFAULT '0.00',gtot double(14,2) DEFAULT NULL,
  note varchar(250) DEFAULT NULL,user varchar(25) DEFAULT NULL,id int(10) UNSIGNED NOT NULL DEFAULT '0',
  dataexchdt date DEFAULT NULL,gname varchar(50) DEFAULT NULL)";
    $sql[7]="create table khadidb.bankmaster (brcode varchar(20) DEFAULT NULL,id int(11) NOT NULL DEFAULT '0',bankname varchar(200) DEFAULT NULL)";
    $sql[8]="create table khadidb.bnkpay (date date DEFAULT NULL,bpno int(12) DEFAULT NULL,type char(2) DEFAULT NULL,
  partic char(200) DEFAULT NULL,dramt double(18,3) DEFAULT NULL,cramt double(18,3) DEFAULT NULL,narr char(250) DEFAULT NULL,
  brcode char(20) DEFAULT NULL,j_type char(20) DEFAULT NULL,against char(100) DEFAULT '-',no char(200) DEFAULT '-',brec_date date DEFAULT NULL,id int(10) UNSIGNED NOT NULL DEFAULT '0',dataexchdt date DEFAULT NULL)";
    $sql[9]="create table khadidb.bnkrec (date date DEFAULT NULL,brno int(12) DEFAULT NULL,type char(2) DEFAULT NULL,
  partic char(200) DEFAULT NULL,dramt double(18,3) DEFAULT NULL,cramt double(18,3) DEFAULT NULL,narr char(250) DEFAULT NULL,
  brcode char(20) DEFAULT NULL,j_type char(20) DEFAULT NULL,against char(100) DEFAULT '-',no char(200) DEFAULT '-',
  brec_date date DEFAULT NULL,id int(10) UNSIGNED NOT NULL DEFAULT '0',dataexchdt date DEFAULT NULL)";
    $sql[10]="create table khadidb.branch (brcode varchar(20) NOT NULL DEFAULT '',brname varchar(200) DEFAULT NULL,
  brman varchar(100) DEFAULT NULL,braddr varchar(250) DEFAULT NULL,brcity varchar(200) DEFAULT NULL,brphone varchar(100) DEFAULT NULL,
  brpass varchar(100) DEFAULT NULL,brtype varchar(50) DEFAULT NULL,tin varchar(200) DEFAULT NULL,cstno varchar(200) DEFAULT NULL,
  brstate varchar(100) DEFAULT NULL,pupass2 varchar(20) DEFAULT NULL,sapass2 varchar(20) DEFAULT NULL,jopass2 varchar(20) DEFAULT NULL,
  acpass2 varchar(20) DEFAULT NULL,otpass2 varchar(20) DEFAULT NULL,id int(11) NOT NULL DEFAULT '0',brgroup varchar(50) DEFAULT NULL,
  inv_prefix varchar(4) DEFAULT NULL,active varchar(1) DEFAULT NULL,login_date date DEFAULT NULL)";
    $sql[11]="INSERT INTO khadidb.branch (brcode, brname, brman, braddr, brcity, brphone, brpass, brtype, tin, cstno, brstate, pupass2, sapass2, jopass2, acpass2, otpass2, id, brgroup, inv_prefix, active, login_date) VALUES
('SHA058', 'KERALA KHADI', 'KERALA KHADI', NULL, NULL, NULL, NULL, 'HO', NULL, NULL, 'Kerala', '0', '0', '0', 'del', '0', 1, NULL, 'CS', 'N', '2015-04-04'),
('PAY002', 'KGS Office Building, Kannur', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 384, 'PAY', '', 'N', '2015-03-27'),
('PKD005', 'KS Thrithala', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 61, 'PKD', '', 'N', NULL),
('$brcode', '$brname', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 21, '$brgrp', '', 'Y', '2016-3-31'),
('MLP001', 'Malappuram Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 362, 'MLP', '', 'N', NULL),
('MLP002', 'KGS Municipal Bus stand', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 363, 'MLP', '', 'N', NULL),
('MLP003', 'KS Sankaramangalam', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 364, 'MLP', '', 'N', NULL),
('MLP004', 'KS Areekode', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 365, 'MLP', '', 'N', NULL),
('MLP005', 'KS Thanoor', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 366, 'MLP', '', 'N', NULL),
('MLP006', 'KS Edavannappara', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 367, 'MLP', '', 'N', NULL),
('CLT001', 'Kozhikode Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 368, 'CLT', '', 'N', '2015-03-17'),
('CLT002', 'KGS Cherootty Road', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 369, 'CLT', '', 'N', '2015-03-26'),
('CLT003', 'KGS Stadium Complex', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 370, 'CLT', '', 'N', NULL),
('CLT004', 'KGS Balussery', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 371, 'CLT', '', 'N', '2015-03-09'),
('CLT005', 'KGS Vadakara', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 372, 'CLT', '', 'N', NULL),
('CLT006', 'KGS Meppayoor', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 373, 'CLT', '', 'N', '2015-03-11'),
('CLT007', 'KGS Ramanattukara', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 374, 'CLT', '', 'N', NULL),
('CLT008', 'KGS Payyoli', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 375, 'CLT', '', 'N', NULL),
('CLT009', 'KGS Kakkoor', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 376, 'CLT', '', 'N', NULL),
('CLT010', 'KGS Koyilandi', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 377, 'CLT', '', 'N', NULL),
('CLT011', 'KS Ulliyeri', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 378, 'CLT', '', 'N', NULL),
('CLT012', 'KS Orkkattery', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 379, 'CLT', '', 'N', NULL),
('CLT013', 'KS Perambra', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 380, 'CLT', '', 'N', NULL),
('WYN001', 'Wayanad Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 381, 'WYN', '', 'N', NULL),
('WYN002', 'KGS  Kalpetta', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 382, 'WYN', '', 'N', '2015-03-12'),
('PKD002', 'KGS Town Bus stand', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 358, 'PKD', '', 'N', NULL),
('PKD003', 'KGS Office Complex', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 359, 'PKD', '', 'N', NULL),
('PKD004', 'KGS Kongad', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 360, 'PKD', '', 'N', NULL),
('TCR003', 'KS Pavaratty', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 356, 'TCR', '', 'N', NULL),
('PKD001', 'Project Godown Palakkad', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 357, 'PKD', '', 'N', NULL),
('KHA001', 'Ernakulam Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 347, 'ERN', '', 'N', '2015-03-22'),
('ERN001', 'Project Godown Ernakulam', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 348, 'ERN', '', 'N', '2015-03-23'),
('ERN002', 'KGS North Paravoor', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 349, 'ERN', '', 'N', '2015-03-23'),
('ERN003', 'KS Moovattupuzha', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 350, 'ERN', '', 'N', NULL),
('ERN004', 'KS Mulamthuruthi', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 351, 'ERN', '', 'N', NULL),
('ERN005', 'KS Payipra', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 352, 'ERN', '', 'N', NULL),
('TCR001', 'Project Godown Trissur', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 353, 'TCR', '', 'N', NULL),
('TCR001', 'KGS Palace Road', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 354, 'TCR', '', 'N', NULL),
('TCR002', 'KGS Vadakkumnadan Shopping Complex', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 355, 'TCR', '', 'N', NULL),
('KTM004', 'KGS Changanassery', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 340, 'KTM', '', 'N', NULL),
('KTM005', 'KGS Ettumanoor', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 341, 'KTM', '', 'N', NULL),
('KTM006', 'KGS Vaikom', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 342, 'KTM', '', 'N', NULL),
('IDK001', 'Idukki Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 343, 'IDK', '', 'N', NULL),
('IDK002', 'KGS Matha Shopping Complex', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 344, 'IDK', '', 'N', NULL),
('IDK003', 'KGS Poomangalam Building', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 345, 'IDK', '', 'N', NULL),
('ALP006', 'KS Venmany', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 336, 'ALP', '', 'N', NULL),
('KTM001', 'Project Godown Kottayam ', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 337, 'KTM', '', 'N', NULL),
('KTM002', 'KGS CSI Complex', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 338, 'KTM', '', 'N', NULL),
('ALP003', 'KS Harippad', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 333, 'ALP', '', 'N', '2015-03-04'),
('ALP004', 'KS Kayamkulam', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 334, 'ALP', '', 'N', NULL),
('PAY003', 'KGS Office Building, Payyannur', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 385, 'PAY', '', 'N', '2015-03-27'),
('PAY001', 'Payyannur Khadi Center', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 383, 'PAY', '', 'N', NULL),
('IDK004', 'KGS Kattappana', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 346, 'IDK', '', 'N', NULL),
('KTM003', 'KGS Temple Road', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 339, 'KTM', '', 'N', NULL),
('ALP005', 'KS Charummood', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 335, 'ALP', '', 'N', NULL),
('ALP002', 'KGS Collectorate Road', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 332, 'ALP', '', 'N', '2015-03-26'),
('ALP001', 'Alappuzha Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 331, 'ALP', '', 'N', '2015-04-04'),
('PTH004', 'KGS Adoor', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 329, 'PTH', '', 'N', '2015-03-28'),
('PTH003', 'KGS Jim Palace', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 328, 'PTH', '', 'N', NULL),
('PTH002', 'KGS Office Building', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 327, 'PTH', '', 'N', NULL),
('PTH001', 'Pathanamthitta Central Godown', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 326, 'PTH', '', 'N', '2015-03-11'),
('KLM004', 'KGS Mobile Sale Van', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 324, 'KLM', '', 'N', NULL),
('KLM001', 'Projcet Godown Kollam', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 321, 'KLM', '', 'N', NULL),
('TVM009', 'KS Attingal', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 320, 'TVM', '', 'N', NULL),
('TVM007', 'KGS Attingal', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 318, 'TVM', '', 'N', NULL),
('TVM006', 'KGS Balaramapuram', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 317, 'TVM', '', 'N', NULL),
('TVM005', 'KGS, Sreekaryam', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 316, 'TVM', '', 'N', NULL),
('TVM004', 'KGS, Kedaram', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 315, 'TVM', '', 'N', NULL),
('KER520', 'KERALA KHADI & V.I. BOARD', 'SECRETARY', 'VANCHIYUR', 'TRIVANDRUM', '0471-2471696', '', 'HO', '', '', 'Kerala', '0', '0', '0', 'del', '0', 386, NULL, NULL, 'N', NULL),
('TVM002', 'KGS, Attukal Shopping Complex', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 313, 'TVM', '', 'N', NULL),
('TVM001', 'Project Godown Thiruvananthapuram ', NULL, NULL, NULL, NULL, NULL, 'HO', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 312, 'TVM', '', 'N', NULL),
('PTH005', 'KGS Ranni', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 330, 'PTH', '', 'N', NULL),
('KLM005', 'KGS, Kottarakkara', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 325, 'KLM', '', 'N', NULL),
('KLM003', 'KGS, Karunagappally', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 323, 'KLM', '', 'N', NULL),
('KLM002', 'KGS Karbala Junction', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 322, 'KLM', '', 'N', NULL),
('TVM008', 'KGS Mobile Van', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 319, 'TVM', '', 'N', NULL),
('TVM003', 'KGS Office Building', NULL, NULL, NULL, NULL, NULL, 'BR', NULL, NULL, NULL, NULL, NULL, NULL, 'del', NULL, 314, 'TVM', '', 'N', NULL)";

    $sql[12]="create table khadidb.breco (jvno int(14) UNSIGNED NOT NULL DEFAULT '0',bdate date DEFAULT NULL,recdate date DEFAULT NULL,user varchar(50) DEFAULT '-',brcode varchar(20) NOT NULL DEFAULT '-',bank varchar(200) NOT NULL DEFAULT '-',id int(10) UNSIGNED NOT NULL DEFAULT '0')";
    $sql[13]="create table khadidb.brtransferin (invno varchar(11) DEFAULT NULL,invdate date DEFAULT NULL,customer varchar(100) DEFAULT NULL,cusid varchar(50) DEFAULT NULL,item varchar(100) DEFAULT NULL,item_code varchar(100) DEFAULT NULL,unit int(11) DEFAULT NULL,qty double(11,2) DEFAULT NULL,unitprice double(11,2) DEFAULT NULL,itmvl double(11,2) DEFAULT NULL,total double(11,2) DEFAULT NULL,flag varchar(20) DEFAULT NULL,salesman varchar(100) DEFAULT NULL,id int(11) NOT NULL DEFAULT '0',brcode varchar(50) DEFAULT NULL,pmode varchar(50) DEFAULT NULL,mba double(10,2) DEFAULT NULL,comision double(10,2) DEFAULT NULL,jvno int(11) DEFAULT '0',
  discount double(10,2) DEFAULT NULL,tax double(10,2) DEFAULT NULL,taxamt double(10,2) DEFAULT NULL,itemtyp varchar(20) DEFAULT NULL,
  mrgin double(10,2) DEFAULT NULL,pfchrgs double(10,2) DEFAULT NULL,othr_chrgs double(10,2) DEFAULT NULL,received varchar(10) DEFAULT NULL,receiv_date date DEFAULT NULL,tobrcode varchar(20) DEFAULT NULL,dataexchdt date DEFAULT NULL,gname varchar(50) DEFAULT NULL,
  refno varchar(20) NOT NULL,refdt date NOT NULL)";
    $sql[14]="create table khadidb.brtransferout (invno varchar(11) DEFAULT NULL,invdate date DEFAULT NULL,customer varchar(100) DEFAULT NULL,cusid varchar(50) DEFAULT NULL,item varchar(100) DEFAULT NULL,item_code varchar(100) DEFAULT NULL,unit int(11) DEFAULT NULL,qty double(11,2) DEFAULT NULL,unitprice double(11,2) DEFAULT NULL,itmvl double(11,2) DEFAULT NULL,total double(11,2) DEFAULT NULL,flag varchar(20) DEFAULT NULL,salesman varchar(100) DEFAULT NULL,id int(11) NOT NULL DEFAULT '0',brcode varchar(50) DEFAULT NULL,pmode varchar(50) DEFAULT NULL,mba double(10,2) DEFAULT NULL,comision double(10,2) DEFAULT NULL,jvno int(11) DEFAULT '0',
  discount double(10,2) DEFAULT NULL,tax double(10,2) DEFAULT NULL,taxamt double(10,2) DEFAULT NULL,itemtyp varchar(20) DEFAULT NULL,
  mrgin double(10,2) DEFAULT NULL,pfchrgs double(10,2) DEFAULT NULL,othr_chrgs double(10,2) DEFAULT NULL,received varchar(10) DEFAULT NULL,receiv_date date DEFAULT NULL,tobrcode varchar(20) DEFAULT NULL,tr_no varchar(20) DEFAULT NULL,dataexchdt date DEFAULT NULL,
  gname varchar(50) DEFAULT NULL,refno varchar(20) NOT NULL,refdt date NOT NULL)";
    $sql[15]="create table khadidb.bruser (brcode varchar(50) DEFAULT NULL,username varchar(100) NOT NULL DEFAULT '-',level int(10) DEFAULT NULL,utype varchar(100) DEFAULT NULL,dept varchar(100) DEFAULT NULL,desig varchar(100) DEFAULT NULL,
  addr varchar(250) DEFAULT NULL,ph varchar(100) DEFAULT NULL,pswd varchar(100) DEFAULT NULL,sno int(10) NOT NULL DEFAULT '0',
  active char(1) DEFAULT NULL,passdate date DEFAULT NULL,id int(11) NOT NULL DEFAULT '0')";
    $sql[16]="INSERT INTO khadidb.bruser (brcode, username, level, utype, dept, desig, addr, ph, pswd, sno, active, passdate, id) VALUES
('$brcode', 'khadi', 5, 'Normal User', NULL, NULL, NULL, NULL, 'khadi', 0, 'Y', '2018-03-31', 6)";
    $sql[17]="create table khadidb.chequecollection (date date DEFAULT NULL,partic char(200) DEFAULT NULL,brcode char(20) DEFAULT NULL,id int(10) UNSIGNED NOT NULL DEFAULT '0',bnknm varchar(200) DEFAULT NULL,chqno int(11) DEFAULT NULL,bnkact varchar(50) DEFAULT NULL,chqamt double(10,2) DEFAULT NULL)";
    $sql[18]="create table khadidb.company_master (id int(11) UNSIGNED NOT NULL DEFAULT '0',brcode varchar(100) DEFAULT NULL,
  comp_name varchar(150) DEFAULT NULL,brname varchar(100) DEFAULT NULL,pbno varchar(50) DEFAULT NULL,city varchar(100) DEFAULT NULL,
  country varchar(100) DEFAULT NULL,tel bigint(15) DEFAULT NULL,fax bigint(15) DEFAULT NULL,mob bigint(15) DEFAULT NULL,
  email1 varchar(100) DEFAULT NULL,email2 varchar(100) DEFAULT NULL,web varchar(150) DEFAULT NULL,fin_code varchar(50) DEFAULT NULL)";
    $sql[19]="create table khadidb.configmaster (code int(12) NOT NULL DEFAULT '0',model varchar(100) DEFAULT NULL,
  config varchar(250) DEFAULT NULL,id int(10) UNSIGNED NOT NULL DEFAULT '0')";
    $sql[20]="create table khadidb.corp_master (code varchar(20) NOT NULL DEFAULT '',corpname varchar(200) DEFAULT NULL,
  addr1 varchar(200) DEFAULT NULL,addr2 varchar(200) DEFAULT NULL,city varchar(200) DEFAULT NULL,dist varchar(200) DEFAULT NULL,
  stat varchar(200) DEFAULT NULL,pin varchar(50) DEFAULT NULL,phone1 varchar(200) DEFAULT NULL,phone2 varchar(200) DEFAULT NULL,
  tin varchar(100) DEFAULT NULL,cst varchar(100) DEFAULT NULL,email varchar(200) DEFAULT NULL,web varchar(200) DEFAULT NULL,
  branch varchar(10) NOT NULL DEFAULT '',id int(10) UNSIGNED NOT NULL DEFAULT '0')";
    $sql[21]="create table khadidb.cshpay (date date DEFAULT NULL,cpno int(12) DEFAULT NULL,type char(2) DEFAULT NULL,
  partic char(200) DEFAULT NULL,dramt double(18,3) DEFAULT NULL,cramt double(18,3) DEFAULT NULL,narr char(250) DEFAULT NULL,
  brcode char(20) DEFAULT NULL,j_type char(20) DEFAULT NULL,against char(100) DEFAULT '-',no char(200) DEFAULT '-',
  id int(10) UNSIGNED NOT NULL DEFAULT '0',dataexchdt date DEFAULT NULL)";
    $sql[22]="create table khadidb.cshrec (date date DEFAULT NULL,crno int(12) DEFAULT NULL,type char(2) DEFAULT NULL,
  partic char(200) DEFAULT NULL,dramt double(18,3) DEFAULT NULL,cramt double(18,3) DEFAULT NULL,narr char(250) DEFAULT NULL,
  brcode char(20) DEFAULT NULL,j_type char(20) DEFAULT NULL,against char(100) DEFAULT '-',no char(200) DEFAULT '-',
  id int(10) UNSIGNED NOT NULL DEFAULT '0',dataexchdt date DEFAULT NULL)";
    $sql[23]="create table khadidb.customer (
  brcode varchar(30) DEFAULT NULL,
  code varchar(30) NOT NULL DEFAULT '-',
  crdate date DEFAULT NULL,
  cname varchar(200) DEFAULT NULL,
  corp varchar(200) DEFAULT NULL,
  acname varchar(200) NOT NULL DEFAULT '-',
  addr1 varchar(250) DEFAULT NULL,
  dist1 varchar(100) DEFAULT NULL,
  state1 varchar(100) DEFAULT NULL,
  pin1 varchar(10) DEFAULT NULL,
  phone1 varchar(100) DEFAULT NULL,
  addr2 varchar(250) DEFAULT NULL,
  addr3 varchar(100) DEFAULT NULL,
  state2 varchar(100) DEFAULT NULL,
  pin2 varchar(100) DEFAULT NULL,
  phone2 varchar(100) DEFAULT NULL,
  mob varchar(100) DEFAULT NULL,
  relation varchar(100) DEFAULT NULL,
  father varchar(100) DEFAULT NULL,
  dob date DEFAULT NULL,
  email varchar(100) DEFAULT NULL,
  web varchar(100) DEFAULT NULL,
  tin varchar(100) DEFAULT NULL,
  cst varchar(100) DEFAULT NULL,
  kgst varchar(100) DEFAULT NULL,
  cramt double(14,2) DEFAULT '0.00',
  crdays double(14,2) DEFAULT '0.00',
  id int(10) UNSIGNED NOT NULL DEFAULT '0'
)";
    $sql[24]="create table khadidb.dbnote (
  date date DEFAULT NULL,
  dbno int(12) DEFAULT NULL,
  type char(2) DEFAULT NULL,
  partic char(200) DEFAULT NULL,
  dramt double(18,2) DEFAULT NULL,
  cramt double(18,2) DEFAULT NULL,
  narr char(250) DEFAULT NULL,
  brcode char(20) DEFAULT NULL,
  j_type char(20) DEFAULT NULL,
  against char(100) DEFAULT '-',
  no char(200) DEFAULT '-',
  dbto varchar(200) DEFAULT '-'
)";

    $sql[25]="create table khadidb.desigmast (
  brcode char(20) DEFAULT NULL,
  divname char(200) DEFAULT NULL,
  code int(11) NOT NULL DEFAULT '0'
)";
    $sql[26]="create table khadidb.down_payment (
  id int(11) NOT NULL DEFAULT '0',
  jcno int(11) DEFAULT NULL,
  regno varchar(100) DEFAULT NULL,
  customer varchar(200) DEFAULT NULL,
  amt double(14,3) DEFAULT NULL,
  date date DEFAULT NULL,
  jvno int(11) DEFAULT NULL,
  trno int(11) DEFAULT NULL,
  brcode varchar(20) DEFAULT NULL,
  typ varchar(20) DEFAULT NULL,
  remark text
)";
    $sql[27]="create table khadidb.empmaster (
  empcode varchar(25) NOT NULL DEFAULT '-',
  brcode varchar(25) DEFAULT NULL,
  divi varchar(250) DEFAULT NULL,
  empname varchar(200) DEFAULT NULL,
  sex varchar(10) DEFAULT NULL,
  dob date DEFAULT NULL,
  fname varchar(200) DEFAULT NULL,
  peraddr varchar(250) DEFAULT NULL,
  praddr varchar(250) DEFAULT NULL,
  design varchar(200) DEFAULT NULL,
  doj date DEFAULT NULL,
  probdate date DEFAULT NULL,
  doconf date DEFAULT NULL,
  doret date DEFAULT NULL,
  esi varchar(200) DEFAULT NULL,
  pf varchar(200) DEFAULT NULL,
  bgrp varchar(100) DEFAULT NULL,
  drvno1 varchar(100) DEFAULT NULL,
  drvdate1 varchar(100) DEFAULT NULL,
  drvtype1 varchar(100) DEFAULT NULL,
  drvno2 varchar(100) DEFAULT NULL,
  drvdate2 varchar(100) DEFAULT NULL,
  drvtype2 varchar(100) DEFAULT NULL,
  drvno3 varchar(100) DEFAULT NULL,
  drvdate3 varchar(100) DEFAULT NULL,
  drvtype3 varchar(100) DEFAULT NULL,
  insurname1 varchar(200) DEFAULT NULL,
  insurdate1 varchar(100) DEFAULT NULL,
  insurtype1 varchar(100) DEFAULT NULL,
  insurname2 varchar(100) DEFAULT NULL,
  insurdate2 varchar(100) DEFAULT NULL,
  insurtype2 varchar(100) DEFAULT NULL,
  insurname3 varchar(100) DEFAULT NULL,
  insurdate3 varchar(100) DEFAULT NULL,
  insurtype3 varchar(100) DEFAULT NULL,
  insurname4 varchar(100) DEFAULT NULL,
  insurdate4 varchar(100) DEFAULT NULL,
  insurtype4 varchar(100) DEFAULT NULL,
  quali1 varchar(200) DEFAULT NULL,
  course1 varchar(200) DEFAULT NULL,
  sub1 varchar(200) DEFAULT NULL,
  mark1 varchar(200) DEFAULT NULL,
  quali2 varchar(200) DEFAULT NULL,
  course2 varchar(200) DEFAULT NULL,
  sub2 varchar(200) DEFAULT NULL,
  mark2 varchar(200) DEFAULT NULL,
  quali3 varchar(200) DEFAULT NULL,
  course3 varchar(200) DEFAULT NULL,
  sub3 varchar(200) DEFAULT NULL,
  mark3 varchar(200) DEFAULT NULL,
  quali4 varchar(200) DEFAULT NULL,
  course4 varchar(200) DEFAULT NULL,
  sub4 varchar(200) DEFAULT NULL,
  mark4 varchar(200) DEFAULT NULL,
  mstatus varchar(100) DEFAULT NULL,
  domarg date DEFAULT NULL,
  nom int(10) DEFAULT NULL,
  nof int(10) DEFAULT NULL,
  resph varchar(100) DEFAULT NULL,
  mob varchar(100) DEFAULT NULL,
  email varchar(100) DEFAULT NULL,
  br varchar(100) DEFAULT NULL,
  remark blob,
  dept varchar(20) DEFAULT NULL,
  empid varchar(100) NOT NULL DEFAULT '-',
  dobactual date DEFAULT NULL,
  icename1 varchar(100) DEFAULT NULL,
  icerel1 varchar(100) DEFAULT NULL,
  iceaddr1 varchar(100) DEFAULT NULL,
  icephone1 varchar(100) DEFAULT NULL,
  icemob1 varchar(100) DEFAULT NULL,
  icename2 varchar(100) DEFAULT NULL,
  icerel2 varchar(100) DEFAULT NULL,
  iceaddr2 varchar(100) DEFAULT NULL,
  icephone2 varchar(100) DEFAULT NULL,
  icemob2 varchar(100) DEFAULT NULL,
  pan varchar(100) DEFAULT NULL,
  term_date date DEFAULT NULL,
  emp_status varchar(100) DEFAULT NULL,
  lop char(1) DEFAULT 'y',
  apinpay char(1) DEFAULT 'Y',
  trainee varchar(12) DEFAULT 'No',
  ptax char(3) DEFAULT 'No',
  grp varchar(100) DEFAULT '-',
  oallow varchar(251) DEFAULT '-',
  emtype varchar(20) DEFAULT NULL,
  incmonth int(11) DEFAULT '0',
  wifename text,
  dobw date DEFAULT NULL,
  dobc1 date DEFAULT NULL,
  dobc2 date DEFAULT NULL,
  dobc3 date DEFAULT NULL,
  c1name text,
  c2name text,
  c3name text,
  bnkac varchar(50) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0'
)";
    $sql[28]="create table khadidb.groupmaster (
  code varchar(100) DEFAULT NULL,
  gname varchar(200) DEFAULT NULL,
  grp_tax float(5,2) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0',
  grp_comsion float(5,2) DEFAULT NULL,
  stat_rbt float(5,2) DEFAULT NULL,
  grp_kvic float(5,2) DEFAULT NULL,
  reduct float(5,2) DEFAULT NULL,
  grp_kvicspl float(5,2) DEFAULT NULL,
  tax_aply varchar(10) DEFAULT NULL,
  rebt_aply varchar(10) DEFAULT NULL,
  kvic_aply varchar(10) DEFAULT NULL,
  redct_aply varchar(10) DEFAULT NULL,
  kvspl_aply varchar(10) DEFAULT NULL,
  brcode varchar(20) DEFAULT NULL
)";
    $sql[29]="INSERT INTO khadidb.groupmaster (code, gname, grp_tax, id, grp_comsion, stat_rbt, grp_kvic, reduct, grp_kvicspl, tax_aply, rebt_aply, kvic_aply, redct_aply, kvspl_aply, brcode) VALUES
('COT04141', 'COTTON', 0.00, 25, 0.00, 10.00, 10.00, 0.00, 0.00, '', '1', '1', '', '', ''),
('SPU10343', 'SPUNSILK', 0.00, 26, 0.00, 0.00, 10.00, 0.00, 0.00, '', '', '1', '', '', ''),
('REE13212', 'REELED SILK', 0.00, 27, 0.00, 0.00, 10.00, 0.00, 0.00, '', '', '1', '', '', ''),
('WOO14929', 'WOOLEN', 0.00, 28, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', ''),
('POL16040', 'POLYSTER', 0.00, 29, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', ''),
('0%-19919', '0% TAXABLE VIP', 0.00, 30, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', ''),
('1%-22242', '1% TAXABLE VIP', 1.00, 31, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', ''),
('5%-24000', '5% TAXABLE VIP', 5.00, 32, 0.00, 0.00, 0.00, 0.00, 0.00, '1', '', '', '', '', ''),
('14.25818', '14.5% TAXABLE VIP', 14.50, 33, 0.00, 0.00, 0.00, 0.00, 0.00, '1', '', '', '', '', ''),
('SPA28141', 'SPARE PARTS', 0.00, 34, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', ''),
('OTH29252', 'OTHERS', 0.00, 35, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', ''),
('YAR95959', 'YARN', 0.00, 36, 0.00, 0.00, 0.00, 0.00, 0.00, '', '', '', '', '', '')";
    $sql[30]="create table khadidb.itempurchase (
  invno varchar(11) DEFAULT NULL,
  invdate date DEFAULT NULL,
  customer varchar(100) DEFAULT NULL,
  cusid varchar(50) DEFAULT NULL,
  item varchar(100) DEFAULT NULL,
  item_code varchar(100) DEFAULT NULL,
  unit int(11) DEFAULT NULL,
  qty double(11,2) DEFAULT NULL,
  unitprice double(11,2) DEFAULT NULL,
  itmvl double(11,2) DEFAULT NULL,
  total double(11,2) DEFAULT NULL,
  flag varchar(20) DEFAULT NULL,
  puroption varchar(100) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0',
  brcode varchar(50) DEFAULT NULL,
  pmode varchar(50) DEFAULT NULL,
  mba double(10,2) DEFAULT NULL,
  comision double(10,2) DEFAULT NULL,
  jvno int(11) DEFAULT '0',
  discount double(10,2) DEFAULT NULL,
  tax double(10,2) DEFAULT NULL,
  taxamt double(10,2) DEFAULT NULL,
  itemtyp varchar(20) DEFAULT NULL,
  mrgin double(10,2) DEFAULT NULL,
  pfchrgs double(10,2) DEFAULT NULL,
  othr_chrgs double(10,2) DEFAULT NULL,
  supinvno varchar(20) DEFAULT NULL,
  supinvdt date DEFAULT NULL,
  gname varchar(40) DEFAULT NULL,
  dataexchdt date DEFAULT NULL
)";
    $sql[31]="create table khadidb.journal2 (
  date date DEFAULT NULL,
  jvno int(12) DEFAULT NULL,
  type char(2) DEFAULT NULL,
  partic varchar(200) DEFAULT NULL,
  dramt double(18,2) DEFAULT NULL,
  cramt double(18,2) DEFAULT NULL,
  narr varchar(250) DEFAULT NULL,
  brcode varchar(20) DEFAULT NULL,
  j_type varchar(20) DEFAULT NULL,
  against varchar(100) DEFAULT '-',
  no varchar(200) DEFAULT '-',
  tr_no int(11) DEFAULT '0',
  dataexchdt date DEFAULT NULL
)";
    $sql[32]="create table khadidb.khadistaff (
  brcode varchar(30) DEFAULT NULL,
  code varchar(30) NOT NULL DEFAULT '-',
  crdate date DEFAULT NULL,
  cname varchar(200) DEFAULT NULL,
  corp varchar(200) DEFAULT NULL,
  acname varchar(200) NOT NULL DEFAULT '-',
  addr1 varchar(250) DEFAULT NULL,
  dist1 varchar(100) DEFAULT NULL,
  state1 varchar(100) DEFAULT NULL,
  pin1 varchar(10) DEFAULT NULL,
  phone1 varchar(100) DEFAULT NULL,
  addr2 varchar(250) DEFAULT NULL,
  addr3 varchar(100) DEFAULT NULL,
  slsyn varchar(100) DEFAULT NULL,
  pin2 varchar(100) DEFAULT NULL,
  phone2 varchar(100) DEFAULT NULL,
  mob varchar(100) DEFAULT NULL,
  relation varchar(100) DEFAULT NULL,
  father varchar(100) DEFAULT NULL,
  dob date DEFAULT NULL,
  email varchar(100) DEFAULT NULL,
  web varchar(100) DEFAULT NULL,
  tin varchar(100) DEFAULT NULL,
  cst varchar(100) DEFAULT NULL,
  kgst varchar(100) DEFAULT NULL,
  cramt double(14,2) DEFAULT '0.00',
  crdays double(14,2) DEFAULT '0.00',
  id int(10) UNSIGNED NOT NULL DEFAULT '0'
)";
    $sql[33]="create table khadidb.ledger (
  led varchar(200) NOT NULL DEFAULT '',
  grp varchar(250) DEFAULT NULL,
  op double(18,2) DEFAULT NULL,
  drcr char(3) DEFAULT NULL,
  code varchar(10) NOT NULL DEFAULT '-',
  brcode varchar(20) DEFAULT NULL,
  dataexchdt date DEFAULT NULL
)";
    $sql[34]="create table khadidb.log (
  brcode char(20) DEFAULT NULL,
  user char(20) DEFAULT NULL,
  ip char(100) DEFAULT NULL,
  date datetime DEFAULT NULL,
  action char(250) DEFAULT NULL
)";
    $sql[35]="create table khadidb.partmaster (
  partcode varchar(100) NOT NULL DEFAULT '',
  partname varchar(100) DEFAULT NULL,
  gname varchar(100) DEFAULT NULL,
  subgroup varchar(100) DEFAULT NULL,
  activevl varchar(10) DEFAULT NULL,
  unit varchar(100) DEFAULT NULL,
  tax_rate double(11,2) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0',
  rbtbl varchar(10) DEFAULT NULL,
  rbtvl double(10,2) DEFAULT NULL,
  reduction double(10,2) DEFAULT NULL,
  dataexchdt date DEFAULT NULL
)";
    $sql[36]="create table khadidb.`payment_mode` (
  `code` varchar(50) NOT NULL,
  `mode` varchar(50) DEFAULT NULL,
  `date` date DEFAULT NULL,
  `brcode` varchar(50) DEFAULT NULL,
  `status` varchar(50) DEFAULT NULL)";
    $sql[37]="INSERT INTO khadidb.payment_mode (code, mode, date, brcode, status) VALUES
('CAS112154', 'CASH', '2013-10-31', 'Wor170', 'yes'),
('CRE112203', 'CREDIT', '2013-10-31', 'SHA058', 'yes'),
('CHE115718', 'CHEQUE', '2013-11-02', 'Wor170', 'no')";
    $sql[38]="create table khadidb.prcsunit (
  unitname varchar(500) NOT NULL,
  brcode varchar(20) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0',
  addrs varchar(500) DEFAULT NULL,
  phno varchar(20) DEFAULT NULL,
  bnknm varchar(200) DEFAULT NULL,
  bnkbrnch varchar(200) DEFAULT NULL,
  bnkacntno varchar(200) DEFAULT NULL,
  bnkifsc varchar(20) DEFAULT NULL,
  pinno varchar(10) DEFAULT NULL
)";
    $sql[39]="create table khadidb.prod_invoice (
  invno varchar(11) DEFAULT NULL,
  invdate date DEFAULT NULL,
  customer varchar(100) DEFAULT NULL,
  vehno varchar(50) DEFAULT NULL,
  item varchar(100) DEFAULT NULL,
  item_code varchar(100) DEFAULT NULL,
  unit int(11) DEFAULT NULL,
  qty double(11,2) DEFAULT NULL,
  unitprice double(11,2) DEFAULT NULL,
  itmvl double(11,2) DEFAULT NULL,
  total double(11,2) DEFAULT NULL,
  nettot double(11,2) DEFAULT NULL,
  flag varchar(20) DEFAULT NULL,
  salesman varchar(100) DEFAULT NULL,
  descr text,
  id int(11) NOT NULL DEFAULT '0',
  group1 varchar(100) DEFAULT NULL,
  brcode varchar(50) DEFAULT NULL,
  pmode varchar(50) DEFAULT NULL,
  redct double(10,2) DEFAULT NULL,
  mba double(10,2) DEFAULT NULL,
  strbtnml double(10,2) DEFAULT NULL,
  jvno int(11) DEFAULT '0',
  strbtspl double(10,2) DEFAULT NULL,
  befrtx double(10,2) DEFAULT NULL,
  tax double(10,2) DEFAULT NULL,
  taxamt double(10,2) DEFAULT NULL,
  itemtyp varchar(20) DEFAULT NULL,
  staffdisc double(10,2) DEFAULT '0.00',
  biltpe varchar(10) DEFAULT NULL,
  gname varchar(100) DEFAULT NULL,
  dataexchdt date DEFAULT NULL
)";

    $sql[40]="create table khadidb.qtytransf (
  itemcode varchar(100) DEFAULT NULL,
  nor_qty double(10,2) DEFAULT NULL,
  dam_qty double(10,2) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0',
  shpsoil_qty double(10,2) DEFAULT NULL,
  cuppic_qty double(10,2) DEFAULT NULL,
  brcode varchar(20) DEFAULT NULL,
  dataexchdt date DEFAULT NULL
)";
    $sql[41]="create table khadidb.`stockverification` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `itemcode` varchar(100) DEFAULT NULL,
  `itemname` varchar(100) DEFAULT NULL,
  `sellprice` double(10,2) DEFAULT NULL,
  `ledqty` double(10,2) DEFAULT NULL,
  `curstk` double(10,2) DEFAULT NULL,
  `brcode` varchar(50) DEFAULT NULL,
  `gname` varchar(100) DEFAULT NULL,
  `item_subgrp` varchar(100) DEFAULT NULL,
  `stock_short` double(10,2) DEFAULT NULL,
  `stock_excess` double(10,2) DEFAULT NULL,
  `stockverifydt` date DEFAULT NULL,
  `ref_no` varchar(20) DEFAULT NULL,
  `remrks` text NOT NULL,
  PRIMARY KEY (`id`)
)";
    $sql[42]="create table khadidb.spareprmast (
  partcode varchar(100) NOT NULL DEFAULT '',
  effectfrom date DEFAULT NULL,
  effectto date DEFAULT NULL,
  ndpcost double(14,2) DEFAULT NULL,
  lstprice double(14,2) DEFAULT NULL,
  mrp double(14,2) DEFAULT NULL,
  discount double(14,2) DEFAULT NULL,
  brcode varchar(100) DEFAULT NULL,
  price2 double(14,2) DEFAULT NULL,
  id int(11) NOT NULL DEFAULT '0',
  dataexchdt date DEFAULT NULL
)";
    $sql[43]="create table khadidb.sparestock (
  id int(11) NOT NULL DEFAULT '0',
  itemcode varchar(100) DEFAULT NULL,
  itemname varchar(100) DEFAULT NULL,
  location varchar(100) DEFAULT NULL,
  buyprice double(10,2) DEFAULT NULL,
  sellprice double(10,2) DEFAULT NULL,
  opstk double(10,2) DEFAULT NULL,
  curstk double(10,2) DEFAULT NULL,
  brcode varchar(50) DEFAULT NULL,
  opstk_dam double(10,2) DEFAULT NULL,
  opstk_soil double(10,2) DEFAULT NULL,
  opstk_cut double(10,2) DEFAULT NULL,
  curstk_dam double(10,2) DEFAULT NULL,
  curstk_soil double(10,2) DEFAULT NULL,
  curstk_cut double(10,2) DEFAULT NULL,
  item_grp varchar(100) DEFAULT NULL,
  item_subgrp varchar(100) DEFAULT NULL,
  item_unit varchar(20) DEFAULT NULL,
  item_active varchar(20) DEFAULT NULL,
  item_rebt varchar(20) DEFAULT NULL,
  item_val int(11) DEFAULT NULL,
  local_code varchar(100) DEFAULT NULL,
  curstk_nor double(10,2) DEFAULT NULL,
  dataexchdt date DEFAULT NULL
)";
    $sql[44]="create table khadidb.sparetmpdw (
  partcode varchar(200) DEFAULT NULL,
  partname varchar(200) DEFAULT NULL,
  op_inqty double(10,2) DEFAULT '0.00',
  op_outqty double(10,2) DEFAULT '0.00',
  stkadj_in double(10,2) DEFAULT '0.00',
  stkadj_out double(12,2) DEFAULT '0.00',
  purch_in double(12,2) DEFAULT '0.00',
  salertn_in double(12,2) DEFAULT '0.00',
  trans_in double(12,2) DEFAULT '0.00',
  trans_out double(12,2) DEFAULT '0.00',
  sale_out double(12,2) DEFAULT '0.00',
  purchrtn_out double(12,2) DEFAULT '0.00'
)";
    $sql[45]="create table khadidb.stockdeedit (
  partcode varchar(200) DEFAULT NULL,
  partname varchar(200) DEFAULT NULL,
  op double(10,2) DEFAULT '0.00',
  purch double(10,2) DEFAULT '0.00',
  serv double(10,2) DEFAULT '0.00',
  sale double(10,2) DEFAULT '0.00',
  transin double(10,2) DEFAULT '0.00',
  transout double(10,2) DEFAULT '0.00',
  sal_ret double(10,2) DEFAULT '0.00',
  pur_ret double(10,2) DEFAULT '0.00',
  war_sal double(10,2) DEFAULT '0.00',
  war_sal_ret double(10,2) DEFAULT '0.00',
  adj_in double(10,2) DEFAULT '0.00',
  adj_out double(10,2) DEFAULT '0.00',
  opin double(10,2) DEFAULT '0.00',
  opout double(10,2) DEFAULT '0.00',
  brcode varchar(20) DEFAULT NULL,
  grp varchar(100) DEFAULT NULL,
  state varchar(50) DEFAULT NULL
)";
    $sql[46]="create table khadidb.stockdetails (
  partcode varchar(200) DEFAULT NULL,
  partname varchar(200) DEFAULT NULL,
  op double(10,2) DEFAULT '0.00',
  purch double(10,2) DEFAULT '0.00',
  serv double(10,2) DEFAULT '0.00',
  sale double(10,2) DEFAULT '0.00',
  transin double(10,2) DEFAULT '0.00',
  transout double(10,2) DEFAULT '0.00',
  sal_ret double(10,2) DEFAULT '0.00',
  pur_ret double(10,2) DEFAULT '0.00',
  war_sal double(10,2) DEFAULT '0.00',
  war_sal_ret double(10,2) DEFAULT '0.00',
  adj_in double(10,2) DEFAULT '0.00',
  adj_out double(10,2) DEFAULT '0.00',
  opin double(10,2) DEFAULT '0.00',
  opout double(10,2) DEFAULT '0.00',
  brcode varchar(20) DEFAULT NULL,
  grp varchar(100) DEFAULT NULL,
  state varchar(50) DEFAULT NULL
)";
    $sql[47]="create table khadidb.stockledger (dat date DEFAULT NULL,partic varchar(250) DEFAULT NULL,inv double(12,2) DEFAULT '0.00',outv double(12,2) DEFAULT '0.00',brcode varchar(25) DEFAULT NULL,led varchar(240) DEFAULT NULL,rate double(10,2) DEFAULT NULL)";
  $sql[50]="create table khadidb.stockverification (id int(11) NOT NULL AUTO_INCREMENT,itemcode varchar(100) DEFAULT NULL,
  itemname varchar(100) DEFAULT NULL,sellprice double(10,2) DEFAULT NULL,ledqty double(10,2) DEFAULT NULL,curstk double(10,2) DEFAULT NULL,brcode varchar(50) DEFAULT NULL,gname varchar(100) DEFAULT NULL,item_subgrp varchar(100) DEFAULT NULL,stock_short double(10,2) DEFAULT NULL,stock_excess double(10,2) DEFAULT NULL,stockverifydt date DEFAULT NULL,ref_no varchar(20) DEFAULT NULL,remrks text NOT NULL,PRIMARY KEY (id))";
  $sql[48]="create table khadidb.subgroupmaster (code varchar(100) DEFAULT NULL,gname varchar(200) DEFAULT NULL,subname varchar(200) DEFAULT NULL, tax float(5,2) DEFAULT NULL,id int(11) NOT NULL AUTO_INCREMENT,PRIMARY KEY (id))";
  $sql[49]="INSERT INTO khadidb.subgroupmaster (code, gname, subname, tax, id) VALUES
('DOT90525', 'COTTON', 'DOTHIES', NULL, 46),
('BED91434', 'COTTON', 'BEDSHEETS', NULL, 47),
('REA92242', 'COTTON', 'READYMADES', NULL, 48),
('CAR93050', 'COTTON', 'CARPETS', NULL, 49),
('SAR93858', 'COTTON', 'SAREES', NULL, 50),
('TOW94707', 'COTTON', 'TOWELS', NULL, 51),
('CHU96929', 'COTTON', 'CHURIDAR SET', NULL, 52),
('BED97939', 'COTTON', 'BED AND PILLOW COVERS', NULL, 53),
('BED99050', 'COTTON', 'BEDS AND PILLOWS', NULL, 54),
('SHI99959', 'COTTON', 'SHIRTINGS', NULL, 55),
('FLA00707', 'COTTON', 'FLAGS', NULL, 56),
('OTH01414', 'COTTON', 'OTHERS', NULL, 57),
('SAR06404', 'SPUNSILK', 'SAREES', NULL, 58),
('SHA07818', 'SPUNSILK', 'SHAWLS', NULL, 59),
('SHI08828', 'SPUNSILK', 'SHIRTINGS', NULL, 60),
('DOT09636', 'SPUNSILK', 'DOTHIES', NULL, 61),
('REA14323', 'SPUNSILK', 'READYMADES', NULL, 62),
('CHU34343', 'SPUNSILK', 'CHURIDAR SET', NULL, 63),
('OTH35353', 'SPUNSILK', 'OTHERS', NULL, 64),
('SAR38323', 'REELED SILK', 'SAREES', NULL, 65),
('SHA39838', 'REELED SILK', 'SHAWLS', NULL, 66),
('SHI40848', 'REELED SILK', 'SHIRTINGS', NULL, 67),
('DOT41858', 'REELED SILK', 'DOTHIES', NULL, 68),
('REA42505', 'REELED SILK', 'READYMADES', NULL, 69),
('CHU43313', 'REELED SILK', 'CHURIDAR SET', NULL, 70),
('OTH44121', 'REELED SILK', 'OTHERS', NULL, 71),
('SHA46040', 'WOOLEN', 'SHAWLS', NULL, 72),
('BLA46949', 'WOOLEN', 'BLANKETS', NULL, 73),
('SWE47656', 'WOOLEN', 'SWEATERS', NULL, 74),
('COA48202', 'WOOLEN', 'COATS', NULL, 75),
('OTH49010', 'WOOLEN', 'OTHERS', NULL, 76),
('SHI50929', 'POLYSTER', 'SHIRTINGS', NULL, 77),
('DOT51737', 'POLYSTER', 'DOTHIES', NULL, 78),
('REA52444', 'POLYSTER', 'READYMADES', NULL, 79),
('OTH53959', 'POLYSTER', 'OTHERS', NULL, 80),
('FOO57232', '0% TAXABLE VIP', 'FOOD ITEMS', NULL, 81),
('OTH58444', '0% TAXABLE VIP', 'OTHERS', NULL, 82),
('PEA64242', '1% TAXABLE VIP', 'PEARLS', NULL, 83),
('FOO64949', '1% TAXABLE VIP', 'FOOD ITEMS', NULL, 84),
('OTH66101', '1% TAXABLE VIP', 'OTHERS', NULL, 85),
('HAN69737', '5% TAXABLE VIP', 'HANDICRAFTS', NULL, 86),
('AYU75737', '5% TAXABLE VIP', 'AYURVEDIC PRODUCTS', NULL, 87),
('FOO76646', '5% TAXABLE VIP', 'FOOD ITEMS', NULL, 88),
('SPI77454', '5% TAXABLE VIP', 'SPICES', NULL, 89),
('STA78202', '5% TAXABLE VIP', 'STARCH', NULL, 90),
('DET82949', '5% TAXABLE VIP', 'DETERGENTS AND CHEMICALS', NULL, 91),
('OTH84909', '5% TAXABLE VIP', 'OTHERS', NULL, 92),
('PER87636', '14.5% TAXABLE VIP', 'PERFUMES', NULL, 93),
('ELE88545', '14.5% TAXABLE VIP', 'ELECTRICAL GOODS', NULL, 94),
('TOL89656', '14.5% TAXABLE VIP', 'TOLET SOAPS', NULL, 95),
('LEA90505', '14.5% TAXABLE VIP', 'LEATHER GOODS', NULL, 96),
('OTH91212', '14.5% TAXABLE VIP', 'OTHERS', NULL, 97),
('COT98525', 'YARN', 'COTTON YARN', NULL, 98),
('POL99535', 'YARN', 'POLYSTER YARN', NULL, 99),
('SIL00343', 'YARN', 'SILK YARN', NULL, 100),
('OTH00949', 'YARN', 'OTHERS', NULL, 101),
('SPI03717', 'SPARE PARTS', 'SPINNING SPARE PARTS', NULL, 102),
('WEA04626', 'SPARE PARTS', 'WEAVING SPARE PARTS', NULL, 103),
('OTH05434', 'SPARE PARTS', 'OTHERS', NULL, 104),
('OTH06848', 'OTHERS', 'OTHERS', NULL, 105)";
  $sql[50]="create table khadidb.sup_master (
  code varchar(20) NOT NULL DEFAULT '',
  supname varchar(200) DEFAULT NULL,
  addr1 varchar(200) DEFAULT NULL,
  addr2 varchar(200) DEFAULT NULL,
  city varchar(200) DEFAULT NULL,
  dist varchar(200) DEFAULT NULL,
  stat varchar(200) DEFAULT NULL,
  pin varchar(50) DEFAULT NULL,
  phone1 varchar(200) DEFAULT NULL,
  phone2 varchar(200) DEFAULT NULL,
  tin varchar(100) DEFAULT NULL,
  cst varchar(100) DEFAULT NULL,
  email varchar(200) DEFAULT NULL,
  web varchar(200) DEFAULT NULL,
  branch varchar(10) NOT NULL DEFAULT '-',
  suptype varchar(100) DEFAULT '-',
  id int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (id)
)";
  $sql[51]="create table khadidb.taxmaster (
  taxcod varchar(20) NOT NULL,
  brcode varchar(20) DEFAULT NULL,
  taxrate double(10,2) DEFAULT NULL,
  id int(11) NOT NULL AUTO_INCREMENT,
  taxdescr text,
  taxtpe varchar(10) DEFAULT NULL,
  PRIMARY KEY (id)
)";
  $sql[52]="INSERT INTO khadidb.taxmaster (taxcod, brcode, taxrate, id, taxdescr, taxtpe) VALUES
('2', '', 14.50, 6, 'VAT@14.5%', NULL),
('3', '', 1.00, 7, 'VAT@1%', NULL),
('4', '', 0.00, 8, 'NIL VAT', NULL),
('5', '', 5.00, 9, 'VAT@5%', 'VAT')";
  $sql[53]="create table khadidb.unit (
  agrp varchar(50) NOT NULL DEFAULT '-',
  brcode varchar(20) DEFAULT NULL,
  conv double(10,2) DEFAULT NULL
)";
$sql[54]="INSERT INTO khadidb.unit (agrp, brcode, conv) VALUES
('NO', 'Wor170', 1.00),
('LTR', 'Wor170', 1.00),
('NOS', 'RAY196', 1.00),
('MTS', 'SHA058', 1.00),
('KG', 'ALP001', 1.00)";

$sql[55]="CREATE TABLE `deliverychallanin` (
  `invno` varchar(11) DEFAULT NULL,
  `invdate` date DEFAULT NULL,
  `customer` varchar(100) DEFAULT NULL,
  `vehno` varchar(50) DEFAULT NULL,
  `item` varchar(100) DEFAULT NULL,
  `item_code` varchar(100) DEFAULT NULL,
  `unit` int(11) DEFAULT NULL,
  `qty` double(11,2) DEFAULT NULL,
  `unitprice` double(11,2) DEFAULT NULL,
  `itmvl` double(11,2) DEFAULT NULL,
  `total` double(11,2) DEFAULT NULL,
  `nettot` double(11,2) DEFAULT NULL,
  `flag` varchar(20) DEFAULT NULL,
  `mat_used` varchar(100) DEFAULT NULL,
  `desc` text,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group1` varchar(100) DEFAULT NULL,
  `brcode` varchar(50) DEFAULT NULL,
  `pmode` varchar(50) DEFAULT NULL,
  `redct` double(10,2) DEFAULT NULL,
  `mba` double(10,2) DEFAULT NULL,
  `strbtnml` double(10,2) DEFAULT NULL,
  `jvno` int(11) DEFAULT '0',
  `strbtspl` double(10,2) DEFAULT NULL,
  `befrtx` double(10,2) DEFAULT NULL,
  `tax` double(10,2) DEFAULT NULL,
  `taxamt` double(10,2) DEFAULT NULL,
  `itemtyp` varchar(20) DEFAULT NULL,
  `staffdisc` double(10,2) DEFAULT '0.00',
  `biltpe` varchar(10) DEFAULT NULL,
  `dataexchdt` date DEFAULT NULL,
  PRIMARY KEY (`id`)
)";

$sql[56]="CREATE TABLE `deliverychallanout` (
  `invno` varchar(11) DEFAULT NULL,
  `invdate` date DEFAULT NULL,
  `customer` varchar(100) DEFAULT NULL,
  `vehno` varchar(50) DEFAULT NULL,
  `item` varchar(100) DEFAULT NULL,
  `item_code` varchar(100) DEFAULT NULL,
  `unit` int(11) DEFAULT NULL,
  `qty` double(11,2) DEFAULT NULL,
  `unitprice` double(11,2) DEFAULT NULL,
  `itmvl` double(11,2) DEFAULT NULL,
  `total` double(11,2) DEFAULT NULL,
  `nettot` double(11,2) DEFAULT NULL,
  `flag` varchar(20) DEFAULT NULL,
  `salesman` varchar(100) DEFAULT NULL,
  `desc` text,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group1` varchar(100) DEFAULT NULL,
  `brcode` varchar(50) DEFAULT NULL,
  `pmode` varchar(50) DEFAULT NULL,
  `redct` double(10,2) DEFAULT NULL,
  `mba` double(10,2) DEFAULT NULL,
  `strbtnml` double(10,2) DEFAULT NULL,
  `jvno` int(11) DEFAULT '0',
  `strbtspl` double(10,2) DEFAULT NULL,
  `befrtx` double(10,2) DEFAULT NULL,
  `tax` double(10,2) DEFAULT NULL,
  `taxamt` double(10,2) DEFAULT NULL,
  `itemtyp` varchar(20) DEFAULT NULL,
  `staffdisc` double(10,2) DEFAULT '0.00',
  `biltpe` varchar(10) DEFAULT NULL,
  `dataexchdt` date DEFAULT NULL,
  PRIMARY KEY (`id`)
)";
$sql[57]="CREATE TABLE `prodinvoicewholesale` (
  `invno` varchar(11) DEFAULT NULL,
  `invdate` date DEFAULT NULL,
  `customer` varchar(100) DEFAULT NULL,
  `cusid` varchar(50) DEFAULT NULL,
  `item` varchar(100) DEFAULT NULL,
  `item_code` varchar(100) DEFAULT NULL,
  `unit` int(11) DEFAULT NULL,
  `qty` double(11,2) DEFAULT NULL,
  `unitprice` double(11,2) DEFAULT NULL,
  `itmvl` double(11,2) DEFAULT NULL,
  `total` double(11,2) DEFAULT NULL,
  `flag` varchar(20) DEFAULT NULL,
  `salesman` varchar(100) DEFAULT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brcode` varchar(50) DEFAULT NULL,
  `pmode` varchar(50) DEFAULT NULL,
  `mba` double(10,2) DEFAULT NULL,
  `comision` double(10,2) DEFAULT NULL,
  `jvno` int(11) DEFAULT '0',
  `discount` double(10,2) DEFAULT NULL,
  `tax` double(10,2) DEFAULT NULL,
  `taxamt` double(10,2) DEFAULT NULL,
  `itemtyp` varchar(20) DEFAULT NULL,
  `mrgin` double(10,2) DEFAULT NULL,
  `pfchrgs` double(10,2) DEFAULT NULL,
  `othr_chrgs` double(10,2) DEFAULT NULL,
  `dataexchdt` date DEFAULT NULL,
  `gname` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
)";

$sql[58]="CREATE TABLE `purchretn` (
  `invno` varchar(11) DEFAULT NULL,
  `invdate` date DEFAULT NULL,
  `customer` varchar(100) DEFAULT NULL,
  `cusid` varchar(50) DEFAULT NULL,
  `item` varchar(100) DEFAULT NULL,
  `item_code` varchar(100) DEFAULT NULL,
  `unit` int(11) DEFAULT NULL,
  `qty` double(11,2) DEFAULT NULL,
  `unitprice` double(11,2) DEFAULT NULL,
  `itmvl` double(11,2) DEFAULT NULL,
  `total` double(11,2) DEFAULT NULL,
  `flag` varchar(20) DEFAULT NULL,
  `puroption` varchar(100) DEFAULT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brcode` varchar(50) DEFAULT NULL,
  `pmode` varchar(50) DEFAULT NULL,
  `mba` double(10,2) DEFAULT NULL,
  `comision` double(10,2) DEFAULT NULL,
  `jvno` int(11) DEFAULT '0',
  `discount` double(10,2) DEFAULT NULL,
  `tax` double(10,2) DEFAULT NULL,
  `taxamt` double(10,2) DEFAULT NULL,
  `itemtyp` varchar(20) DEFAULT NULL,
  `mrgin` double(10,2) DEFAULT NULL,
  `pfchrgs` double(10,2) DEFAULT NULL,
  `othr_chrgs` double(10,2) DEFAULT NULL,
  `supinvno` varchar(20) DEFAULT NULL,
  `supinvdt` date DEFAULT NULL,
  `gname` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ";

$sql[59]="CREATE TABLE `salesretn` (
  `invno` varchar(11) DEFAULT NULL,
  `invdate` date DEFAULT NULL,
  `customer` varchar(100) DEFAULT NULL,
  `vehno` varchar(50) DEFAULT NULL,
  `item` varchar(100) DEFAULT NULL,
  `item_code` varchar(100) DEFAULT NULL,
  `unit` int(11) DEFAULT NULL,
  `qty` double(11,2) DEFAULT NULL,
  `unitprice` double(11,2) DEFAULT NULL,
  `itmvl` double(11,2) DEFAULT NULL,
  `total` double(11,2) DEFAULT NULL,
  `nettot` double(11,2) DEFAULT NULL,
  `flag` varchar(20) DEFAULT NULL,
  `salesman` varchar(100) DEFAULT NULL,
  `desc` text,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `group1` varchar(100) DEFAULT NULL,
  `brcode` varchar(50) DEFAULT NULL,
  `pmode` varchar(50) DEFAULT NULL,
  `redct` double(10,2) DEFAULT NULL,
  `mba` double(10,2) DEFAULT NULL,
  `strbtnml` double(10,2) DEFAULT NULL,
  `jvno` int(11) DEFAULT '0',
  `strbtspl` double(10,2) DEFAULT NULL,
  `befrtx` double(10,2) DEFAULT NULL,
  `tax` double(10,2) DEFAULT NULL,
  `taxamt` double(10,2) DEFAULT NULL,
  `itemtyp` varchar(20) DEFAULT NULL,
  `staffdisc` double(10,2) DEFAULT '0.00',
  `biltpe` varchar(10) DEFAULT NULL,
  `rtnqty` double(10,2) DEFAULT NULL,
  `slinvno` varchar(20) DEFAULT NULL,
  `slsinvdt` date DEFAULT NULL,
  `dataexchdt` date DEFAULT NULL,
  `gname` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
)";

$sql[60]="CREATE TABLE `salesrtnwhole` (
  `invno` varchar(11) DEFAULT NULL,
  `invdate` date DEFAULT NULL,
  `customer` varchar(100) DEFAULT NULL,
  `cusid` varchar(50) DEFAULT NULL,
  `item` varchar(100) DEFAULT NULL,
  `item_code` varchar(100) DEFAULT NULL,
  `unit` int(11) DEFAULT NULL,
  `qty` double(11,2) DEFAULT NULL,
  `unitprice` double(11,2) DEFAULT NULL,
  `itmvl` double(11,2) DEFAULT NULL,
  `total` double(11,2) DEFAULT NULL,
  `flag` varchar(20) DEFAULT NULL,
  `salesman` varchar(100) DEFAULT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `brcode` varchar(50) DEFAULT NULL,
  `pmode` varchar(50) DEFAULT NULL,
  `mba` double(10,2) DEFAULT NULL,
  `comision` double(10,2) DEFAULT NULL,
  `jvno` int(11) DEFAULT '0',
  `discount` double(10,2) DEFAULT NULL,
  `tax` double(10,2) DEFAULT NULL,
  `taxamt` double(10,2) DEFAULT NULL,
  `itemtyp` varchar(20) DEFAULT NULL,
  `mrgin` double(10,2) DEFAULT NULL,
  `pfchrgs` double(10,2) DEFAULT NULL,
  `othr_chrgs` double(10,2) DEFAULT NULL,
  `dataexchdt` date DEFAULT NULL,
  `gname` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
)";

    for ($i = 2; $i <= 60; $i++)
    {
      mysqli_query($db,$sql[$i])or die(mysqli_error($db));
      print $i.".....Successful....!!!<br>";
    }
    echo "Installation Completed ........... Database Created Successfully!";
}
else
{
?>
<html>
<body>
<form method='post'>
<table align='center' style="padding-top: 100px;">
<tr><td>Enter Branch Code (SIX Letters Eg:TVM007):</td><td><input type="text" id = "brcode" name = "brcode"></td>
<tr><td>Enter Branch Name :</td><td><input type="text" id = "brname" name = "brname"></td>
<tr><td>Enter Group Code (First 3 letters of branch code Eg:TVM):</td><td><input type="text" id = "brgrp" name = "brgrp"></td>
<td></td><td><input type='submit' value='>>>Proceed' name='proceed'></td>
</tr>
</table>
</form>
</body>
</html>
<?}?>