/** Function to populate the default required data during installation  
     */
    function create_tables()
    {
        global $app_strings;
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (3,'Home',0,1,'Home',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (7,'Leads',0,4,'Leads',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (6,'Accounts',0,5,'Accounts',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (4,'Contacts',0,6,'Contacts',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (2,'Potentials',0,7,'Potentials',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (8,'Documents',0,9,'Documents',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (9,'Calendar',0,3,'Calendar',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (10,'Emails',0,10,'Emails',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (13,'HelpDesk',0,11,'HelpDesk',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (14,'Products',0,8,'Products',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (1,'Dashboard',0,12,'Dashboards',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (15,'Faq',0,14,'Faq',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (16,'Events',2,13,'Events',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (18,'Vendors',0,15,'Vendors',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (19,'PriceBooks',0,16,'PriceBooks',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (20,'Quotes',0,17,'Quotes',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (22,'SalesOrder',0,19,'SalesOrder',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (23,'Invoice',0,20,'Invoice',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (24,'Rss',0,21,'Rss',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (25,'Reports',0,22,'Reports',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (26,'Campaigns',0,23,'Campaigns',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (27,'Portal',0,24,'Portal',0,1,0)");
        // JFV - disable webmails
        //		$this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (28,'Webmails',0,25,'Webmails',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (28,'Webmails',1,25,'Webmails',0,1,1)");
        // JFV END
        $this->db->query("insert into vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) values (29,'Users',0,26,'Users',0,1,0)");
        // Populate the vtiger_blocks vtiger_table
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_DESCRIPTION_INFORMATION',5,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0,1,0)");
        $fileblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $fileblockid . ",8,'LBL_FILE_INFORMATION',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'LBL_TASK_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',4,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_COMMENTS',6,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0,1,0)");
        //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',2,1,0,0,0,0,1,0)");
        //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'',3,1,0,0,0,0,1,0)");
        $vendorbasicinfo = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendorbasicinfo . ",18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $vendoraddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendoraddressblock . ",18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $vendordescriptionblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendordescriptionblock . ",18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $pricebookbasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pricebookbasicblock . ",19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $pricebookdescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pricebookdescription . ",19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)");
        $quotesbasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotesbasicblock . ",20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $quotesaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotesaddressblock . ",20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $quotetermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotetermsblock . ",20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $quotedescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotedescription . ",20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $pobasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pobasicblock . ",21,'LBL_PO_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $poaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $poaddressblock . ",21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $potermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $potermsblock . ",21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $podescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $podescription . ",21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $sobasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sobasicblock . ",22,'LBL_SO_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",22,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $soaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $soaddressblock . ",22,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",22,'LBL_RELATED_PRODUCTS',5,0,0,0,0,0,1,0)");
        $sotermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sotermsblock . ",22,'LBL_TERMS_INFORMATION',6,0,0,0,0,0,1,0)");
        $sodescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sodescription . ",22,'LBL_DESCRIPTION_INFORMATION',7,0,0,0,0,0,1,0)");
        $invoicebasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicebasicblock . ",23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $invoiceaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoiceaddressblock . ",23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $invoicetermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicetermsblock . ",23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $invoicedescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicedescription . ",23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $imageblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $imageblockid . ",4,'LBL_IMAGE_INFORMATION',6,0,0,0,0,0,1,0)");
        $campaignbasicblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaignbasicblockid . ",26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0,1,0)");
        $campaigncustomblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaigncustomblock . ",26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $campaignexpectedandactualsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaignexpectedandactualsblock . ",26,'LBL_EXPECTATIONS_AND_ACTUALS',3,0,0,0,0,0,1,0)");
        $userloginandroleblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $userloginandroleblockid . ",29,'LBL_USERLOGIN_ROLE',1,0,0,0,0,0,1,0)");
        $usercurrencyinfoblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $usercurrencyinfoblock . ",29,'LBL_CURRENCY_CONFIGURATION',2,0,0,0,0,0,1,0)");
        $usermoreinfoblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $usermoreinfoblock . ",29,'LBL_MORE_INFORMATION',3,0,0,0,0,0,1,0)");
        $useraddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $useraddressblock . ",29,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        //Added an extra block for new UI Settings in Campaigns module
        $campaidndescriptionblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaidndescriptionblock . ",26,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $userblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $userblockid . ",29,'LBL_USER_IMAGE_INFORMATION',4,0,0,0,0,0,1,0)");
        //Added a New Block User Image Info in Users Module
        $useradvanceblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $useradvanceblock . ",29,'LBL_USER_ADV_OPTIONS',5,0,0,0,0,0,1,0)");
        //Added a New Block User Image Info in Users Module
        //Added block 'File Information' to Documents module
        $desc_blockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $desc_blockid . ",8,'LBL_DESCRIPTION',2,0,0,0,0,0,1,0)");
        //Added block for storing the Recurring Inovice Informaiton in SalesOrder
        $sorecurringinvoiceblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sorecurringinvoiceblock . ",22,'Recurring Invoice Information',2,0,0,0,0,0,1,0)");
        //Added to support custom fields for Calendar
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)");
        //Account Details -- START
        //Block9
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'accountname','vtiger_account',1,'2','accountname','Account Name',1,0,'',100,1,9,1,'V~M',0,1,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'account_no','vtiger_account',1,'4','account_no','Account No',1,0,'',100,2,9,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_account',1,'11','phone','Phone',1,2,'',100,4,9,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_account',1,'17','website','Website',1,2,'',100,3,9,1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_account',1,'1','fax','Fax',1,2,'',100,6,9,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'tickersymbol','vtiger_account',1,'1','tickersymbol','Ticker Symbol',1,2,'',100,5,9,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'otherphone','vtiger_account',1,'11','otherphone','Other Phone',1,2,'',100,8,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'parentid','vtiger_account',1,'51','account_id','Member Of',1,2,'',100,7,9,1,'I~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'email1','vtiger_account',1,'13','email1','Email',1,2,'',100,10,9,1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'employees','vtiger_account',1,'7','employees','Employees',1,2,'',100,9,9,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'email2','vtiger_account',1,'13','email2','Other Email',1,2,'',100,11,9,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ownership','vtiger_account',1,'1','ownership','Ownership',1,2,'',100,12,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'rating','vtiger_account',1,'15','rating','Rating',1,2,'',100,14,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'industry','vtiger_account',1,'15','industry','industry',1,2,'',100,13,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'siccode','vtiger_account',1,'1','siccode','SIC Code',1,2,'',100,16,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'account_type','vtiger_account',1,'15','accounttype','Type',1,2,'',100,15,9,1,'V~O',1,null,'ADV',1)");
        // JFV - extend number range, chg type from Integer to Decimal
        //		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'annualrevenue','vtiger_account',1,'71','annual_revenue','Annual Revenue',1,2,'',100,18,9,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'annualrevenue','vtiger_account',1,'71','annual_revenue','Annual Revenue',1,2,'',100,18,9,1,'N~O',1,null,'ADV',1)");
        // JFV END
        //Added vtiger_field emailoptout for vtiger_accounts -- after 4.2 patch2
        // JFV - default "Email Opt Out" to true, account not receive mail
        //		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'emailoptout','vtiger_account',1,'56','emailoptout','Email Opt Out',1,2,'',100,17,9,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'emailoptout','vtiger_account',1,'56','emailoptout','Email Opt Out',1,2,'1',100,17,9,1,'C~O',1,null,'ADV',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'notify_owner','vtiger_account',1,56,'notify_owner','Notify Owner',1,2,'',10,20,9,1,'C~O',1,NULL,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,19,9,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,22,9,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,21,9,2,'T~O',3,null,'BAS',0)");
        //Block 11
        // JFV - change address display order
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_accountbillads',1,'21','bill_street','Billing Address',1,2,'',100,1,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_accountbillads',1,'21','bill_street','Billing Address',1,2,'',100,9,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_accountshipads',1,'21','ship_street','Shipping Address',1,2,'',100,2,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_accountshipads',1,'21','ship_street','Shipping Address',1,2,'',100,10,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_accountbillads',1,'1','bill_city','Billing City',1,2,'',100,5,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_accountbillads',1,'1','bill_city','Billing City',1,2,'',100,7,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_accountshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_accountshipads',1,'1','ship_city','Shipping City',1,2,'',100,8,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_accountbillads',1,'1','bill_state','Billing State',1,2,'',100,7,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_accountbillads',1,'1','bill_state','Billing State',1,2,'',100,5,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_accountshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_accountshipads',1,'1','ship_state','Shipping State',1,2,'',100,6,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_accountbillads',1,'1','bill_code','Billing Code',1,2,'',100,9,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_accountbillads',1,'1','bill_code','Billing Code',1,2,'',100,3,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_accountshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_accountshipads',1,'1','ship_code','Shipping Code',1,2,'',100,4,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_accountbillads',1,'1','bill_country','Billing Country',1,2,'',100,11,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_accountbillads',1,'1','bill_country','Billing Country',1,2,'',100,1,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_accountshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_accountshipads',1,'1','ship_country','Shipping Country',1,2,'',100,2,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_accountbillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_accountbillads',1,'1','bill_pobox','Billing Po Box',1,2,'',10011,11,1,'V~O',1,null,'BAS',1)");
        // 		$this->db->query("insert into vtiger_field values (6,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_accountshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_accountshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,12,11,1,'V~O',1,null,'BAS',1)");
        // JFV END
        //Block12
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,12,1,'V~O',1,null,'BAS',1)");
        //Account Details -- END
        //Lead Details --- START
        //Block13 -- Start
        // JFV - not display saluation (Mr Ms etc)
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'salutation','vtiger_leaddetails',1,'55','salutationtype','Salutation',1,0,'',100,1,13,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'salutation','vtiger_leaddetails',1,'55','salutationtype','Salutation',1,1,'',100,1,13,3,'V~O',1,null,'BAS',1)");
        // JFV END
        // JFV - change firstname and lastname order to japan/china way
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'firstname','vtiger_leaddetails',1,'55','firstname','First Name',1,0,'',100,2,13,1,'V~O',2,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'firstname','vtiger_leaddetails',1,'55','firstname','First Name',1,0,'',100,4,13,1,'V~O',2,1,'BAS',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lead_no','vtiger_leaddetails',1,'4','lead_no','Lead No',1,0,'',100,3,13,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_leadaddress',1,'11','phone','Phone',1,2,'',100,5,13,1,'V~O',2,4,'BAS',1)");
        // JFV - change firstname and lastname order to japan/china way
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'lastname','vtiger_leaddetails',1,'255','lastname','Last Name',1,0,'',100,4,13,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lastname','vtiger_leaddetails',1,'255','lastname','Last Name',1,0,'',100,2,13,1,'V~M',0,2,'BAS',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'mobile','vtiger_leadaddress',1,'1','mobile','Mobile',1,2,'',100,7,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'company','vtiger_leaddetails',1,'2','company','Company',1,2,'',100,6,13,1,'V~M',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_leadaddress',1,'1','fax','Fax',1,2,'',100,9,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'designation','vtiger_leaddetails',1,'1','designation','Designation',1,2,'',100,8,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_leaddetails',1,'13','email','Email',1,2,'',100,11,13,1,'E~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_leaddetails',1,'15','leadsource','Lead Source',1,2,'',100,10,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_leadsubdetails',1,'17','website','Website',1,2,'',100,13,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'industry','vtiger_leaddetails',1,'15','industry','Industry',1,2,'',100,12,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'leadstatus','vtiger_leaddetails',1,'15','leadstatus','Lead Status',1,2,'',100,15,13,1,'V~O',1,null,'BAS',1)");
        // JFV - extend number range, chg type from Integer to Decimal
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'annualrevenue','vtiger_leaddetails',1,'71','annualrevenue','Annual Revenue',1,2,'',100,14,13,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'annualrevenue','vtiger_leaddetails',1,'71','annualrevenue','Annual Revenue',1,2,'',100,14,13,1,'N~O',1,null,'ADV',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'rating','vtiger_leaddetails',1,'15','rating','Rating',1,2,'',100,17,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'noofemployees','vtiger_leaddetails',1,'1','noofemployees','No Of Employees',1,2,'',100,16,13,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,19,13,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'secondaryemail','vtiger_leaddetails',1,'13','secondaryemail','Secondary Email',1,2,'',100,18,13,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,21,13,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,20,13,2,'T~O',3,null,'BAS',0)");
        //Block13 -- End
        //Block15 -- Start
        // JFV - change address display order
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'lane','vtiger_leadaddress',1,'21','lane','Street',1,2,'',100,1,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lane','vtiger_leadaddress',1,'21','lane','Street',1,2,'',100,4,15,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'code','vtiger_leadaddress',1,'1','code','Postal Code',1,2,'',100,3,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'code','vtiger_leadaddress',1,'1','code','Postal Code',1,2,'',100,3,15,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'city','vtiger_leadaddress',1,'1','city','City',1,2,'',100,4,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'city','vtiger_leadaddress',1,'1','city','City',1,2,'',100,2,15,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'country','vtiger_leadaddress',1,'1','country','Country',1,2,'',100,5,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'country','vtiger_leadaddress',1,'1','country','Country',1,2,'',100,1,15,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'state','vtiger_leadaddress',1,'1','state','State',1,2,'',100,6,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'state','vtiger_leadaddress',1,'1','state','State',1,2,'',100,5,15,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (7,".$this->db->getUniqueID("vtiger_field").",'pobox','vtiger_leadaddress',1,'1','pobox','Po Box',1,2,'',100,2,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'pobox','vtiger_leadaddress',1,'1','pobox','Po Box',1,2,'',100,6,15,1,'V~O',1,null,'BAS',1)");
        // JFV END
        //Block15 --End
        //Block16 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,16,1,'V~O',1,null,'BAS',1)");
        //Block16 -- End
        //Lead Details -- END
        //Contact Details -- START
        //Block4 -- Start
        // JFV - not display saluation (Mr Ms etc)
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'salutation','vtiger_contactdetails',1,'55','salutationtype','Salutation',1,0,'',100,1,4,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'salutation','vtiger_contactdetails',1,'55','salutationtype','Salutation',1,1,'',100,1,4,3,'V~O',1,null,'BAS',1)");
        // JFV END
        // JFV - change firstname and lastname order to japan/china way
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'firstname','vtiger_contactdetails',1,'55','firstname','First Name',1,0,'',100,2,4,1,'V~O',2,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'firstname','vtiger_contactdetails',1,'55','firstname','First Name',1,0,'',100,4,4,1,'V~O',2,1,'BAS',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'contact_no','vtiger_contactdetails',1,'4','contact_no','Contact Id',1,0,'',100,3,4,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_contactdetails',1,'11','phone','Office Phone',1,2,'',100,5,4,1,'V~O',2,4,'BAS',1)");
        // JFV - change firstname and lastname order to japan/china way
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'lastname','vtiger_contactdetails',1,'255','lastname','Last Name',1,0,'',100,4,4,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'lastname','vtiger_contactdetails',1,'255','lastname','Last Name',1,0,'',100,2,4,1,'V~M',0,2,'BAS',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mobile','vtiger_contactdetails',1,'1','mobile','Mobile',1,2,'',100,7,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_contactdetails',1,'51','account_id','Account Name',1,0,'',100,6,4,1,'I~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'homephone','vtiger_contactsubdetails',1,'11','homephone','Home Phone',1,2,'',100,9,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_contactsubdetails',1,'15','leadsource','Lead Source',1,2,'',100,8,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherphone','vtiger_contactsubdetails',1,'11','otherphone','Other Phone',1,2,'',100,11,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_contactdetails',1,'1','title','Title',1,2,'',100,10,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_contactdetails',1,'1','fax','Fax',1,2,'',100,13,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'department','vtiger_contactdetails',1,'1','department','Department',1,2,'',100,12,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'birthday','vtiger_contactsubdetails',1,'5','birthday','Birthdate',1,2,'',100,16,4,1,'D~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_contactdetails',1,'13','email','Email',1,2,'',100,15,4,1,'E~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'reportsto','vtiger_contactdetails',1,'57','contact_id','Reports To',1,2,'',100,18,4,1,'V~O',1,null,'ADV',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'assistant','vtiger_contactsubdetails',1,'1','assistant','Assistant',1,2,'',100,17,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'secondaryemail','vtiger_contactdetails',1,'13','secondaryemail','Secondary Email',1,2,'',100,20,4,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'assistantphone','vtiger_contactsubdetails',1,'11','assistantphone','Assistant Phone',1,2,'',100,19,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'donotcall','vtiger_contactdetails',1,'56','donotcall','Do Not Call',1,2,'',100,22,4,1,'C~O',1,null,'ADV',1)");
        // JFV - default "Email Opt Out" to true, contact not receive mail
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'emailoptout','vtiger_contactdetails',1,'56','emailoptout','Email Opt Out',1,2,'',100,21,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'emailoptout','vtiger_contactdetails',1,'56','emailoptout','Email Opt Out',1,2,'1',100,21,4,1,'C~O',1,null,'ADV',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,24,4,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'reference','vtiger_contactdetails',1,'56','reference','Reference',1,2,'',10,23,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'notify_owner','vtiger_contactdetails',1,'56','notify_owner','Notify Owner',1,2,'',10,26,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,25,4,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,27,4,2,'T~O',3,null,'BAS',0)");
        //Block4 -- End
        //Block6 - Begin Customer Portal
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'portal','vtiger_customerdetails',1,'56','portal','Portal User',1,2,'',100,1,6,1,'C~O',1,null,'ADV',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'support_start_date','vtiger_customerdetails',1,'5','support_start_date','Support Start Date',1,2,'',100,2,6,1,'D~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'support_end_date','vtiger_customerdetails',1,'5','support_end_date','Support End Date',1,2,'',100,3,6,1,'D~O~OTH~GE~support_start_date~Support Start Date',1,null,'ADV',1)");
        //Block6 - End Customer Portal
        //Block 7 -- Start
        // JFV - change address display order
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingstreet','vtiger_contactaddress',1,'21','mailingstreet','Mailing Street',1,2,'',100,1,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingstreet','vtiger_contactaddress',1,'21','mailingstreet','Mailing Street',1,2,'',100,9,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherstreet','vtiger_contactaddress',1,'21','otherstreet','Other Street',1,2,'',100,2,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherstreet','vtiger_contactaddress',1,'21','otherstreet','Other Street',1,2,'',100,10,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingcity','vtiger_contactaddress',1,'1','mailingcity','Mailing City',1,2,'',100,5,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingcity','vtiger_contactaddress',1,'1','mailingcity','Mailing City',1,2,'',100,7,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'othercity','vtiger_contactaddress',1,'1','othercity','Other City',1,2,'',100,6,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'othercity','vtiger_contactaddress',1,'1','othercity','Other City',1,2,'',100,8,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingstate','vtiger_contactaddress',1,'1','mailingstate','Mailing State',1,2,'',100,7,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingstate','vtiger_contactaddress',1,'1','mailingstate','Mailing State',1,2,'',100,5,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherstate','vtiger_contactaddress',1,'1','otherstate','Other State',1,2,'',100,8,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherstate','vtiger_contactaddress',1,'1','otherstate','Other State',1,2,'',100,6,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingzip','vtiger_contactaddress',1,'1','mailingzip','Mailing Zip',1,2,'',100,9,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingzip','vtiger_contactaddress',1,'1','mailingzip','Mailing Zip',1,2,'',100,3,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherzip','vtiger_contactaddress',1,'1','otherzip','Other Zip',1,2,'',100,10,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherzip','vtiger_contactaddress',1,'1','otherzip','Other Zip',1,2,'',100,4,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingcountry','vtiger_contactaddress',1,'1','mailingcountry','Mailing Country',1,2,'',100,11,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingcountry','vtiger_contactaddress',1,'1','mailingcountry','Mailing Country',1,2,'',100,1,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'othercountry','vtiger_contactaddress',1,'1','othercountry','Other Country',1,2,'',100,12,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'othercountry','vtiger_contactaddress',1,'1','othercountry','Other Country',1,2,'',100,2,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'mailingpobox','vtiger_contactaddress',1,'1','mailingpobox','Mailing Po Box',1,2,'',100,3,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingpobox','vtiger_contactaddress',1,'1','mailingpobox','Mailing Po Box',1,2,'',100,11,7,1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (4,".$this->db->getUniqueID("vtiger_field").",'otherpobox','vtiger_contactaddress',1,'1','otherpobox','Other Po Box',1,2,'',100,4,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherpobox','vtiger_contactaddress',1,'1','otherpobox','Other Po Box',1,2,'',100,12,7,1,'V~O',1,null,'BAS',1)");
        // JFV END
        //Block7 -- End
        //ContactImageInformation
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_contactdetails',1,'69','imagename','Contact Image',1,2,'',100,1,{$imageblockid},1,'V~O',3,null,'ADV',0)");
        //Block8 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,8,1,'V~O',1,null,'BAS',1)");
        //Block8 -- End
        //Contact Details -- END
        //Potential Details -- START
        //Block1 -- Start
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potentialname','vtiger_potential',1,'2','potentialname','Potential Name',1,0,'',100,1,1,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potential_no','vtiger_potential',1,'4','potential_no','Potential No',1,0,'',100,2,1,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'amount','vtiger_potential',1,71,'amount','Amount',1,2,'',100,4,1,1,'N~O',2,5,'BAS',1)");
        //changed for b2c model
        $fieldid = $this->db->getUniqueID("vtiger_field");
        $this->db->query("insert into vtiger_field values (2,{$fieldid},'related_to','vtiger_potential',1,'10','related_to','Related To',1,0,'',100,3,1,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_fieldmodulerel (fieldid, module, relmodule, status, sequence) values ({$fieldid}, 'Potentials', 'Accounts', NULL, 0), ({$fieldid}, 'Potentials', 'Contacts', NULL, 1)");
        //b2c model changes end
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'closingdate','vtiger_potential',1,'23','closingdate','Expected Close Date',1,2,'',100,7,1,1,'D~M',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potentialtype','vtiger_potential',1,'15','opportunity_type','Type',1,2,'',100,6,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'nextstep','vtiger_potential',1,'1','nextstep','Next Step',1,2,'',100,9,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_potential',1,'15','leadsource','Lead Source',1,2,'',100,8,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'sales_stage','vtiger_potential',1,'15','sales_stage','Sales Stage',1,2,'',100,11,1,1,'V~M',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,2,'',100,10,1,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'probability','vtiger_potential',1,'9','probability','Probability',1,2,'',100,13,1,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'campaignid','vtiger_potential',1,'58','campaignid','Campaign Source',1,2,'',100,12,1,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,15,1,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,14,1,2,'T~O',3,null,'BAS',0)");
        //Block1 -- End
        //Block3 -- Start
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,3,1,'V~O',1,null,'BAS',1)");
        //Block3 -- End
        //Potential Details -- END
        //campaign entries being added
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaignname','vtiger_campaign',1,'2','campaignname','Campaign Name',1,0,'',100,1,{$campaignbasicblockid},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaign_no','vtiger_campaign',1,'4','campaign_no','Campaign No',1,0,'',100,2,{$campaignbasicblockid},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaigntype','vtiger_campaign',1,15,'campaigntype','Campaign Type',1,2,'',100,5,{$campaignbasicblockid},1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_campaign',1,59,'product_id','Product',1,2,'',100,6,{$campaignbasicblockid},1,'I~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaignstatus','vtiger_campaign',1,15,'campaignstatus','Campaign Status',1,2,'',100,4,{$campaignbasicblockid},1,'V~O',2,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'closingdate','vtiger_campaign',1,'23','closingdate','Expected Close Date',1,2,'',100,8,{$campaignbasicblockid},1,'D~M',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,3,{$campaignbasicblockid},1,'V~M',0,7,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'numsent','vtiger_campaign',1,'9','numsent','Num Sent',1,2,'',100,12,{$campaignbasicblockid},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'sponsor','vtiger_campaign',1,'1','sponsor','Sponsor',1,2,'',100,9,{$campaignbasicblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'targetaudience','vtiger_campaign',1,'1','targetaudience','Target Audience',1,2,'',100,7,{$campaignbasicblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'targetsize','vtiger_campaign',1,'1','targetsize','TargetSize',1,2,'',100,10,{$campaignbasicblockid},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,11,{$campaignbasicblockid},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,13,{$campaignbasicblockid},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'expectedresponse','vtiger_campaign',1,'15','expectedresponse','Expected Response',1,2,'',100,3,{$campaignexpectedandactualsblock},1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'expectedrevenue','vtiger_campaign',1,'71','expectedrevenue','Expected Revenue',1,2,'',100,4,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'budgetcost','vtiger_campaign',1,'71','budgetcost','Budget Cost',1,2,'',100,1,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'actualcost','vtiger_campaign',1,'71','actualcost','Actual Cost',1,2,'',100,2,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedresponsecount','vtiger_campaign',1,'1','expectedresponsecount','Expected Response Count',1,2,'',100,7,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedsalescount','vtiger_campaign',1,'1','expectedsalescount','Expected Sales Count',1,2,'',100,5,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedroi','vtiger_campaign',1,'71','expectedroi','Expected ROI',1,2,'',100,9,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualresponsecount','vtiger_campaign',1,'1','actualresponsecount','Actual Response Count',1,2,'',100,8,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualsalescount','vtiger_campaign',1,'1','actualsalescount','Actual Sales Count',1,2,'',100,6,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualroi','vtiger_campaign',1,'71','actualroi','Actual ROI',1,2,'',100,10,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$campaidndescriptionblock},1,'V~O',1,null,'BAS',1)");
        //entry to vtiger_field to maintain account,contact,lead relationships
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Contacts') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Accounts') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Leads') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Campaigns') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        //Campaign entries end
        //Ticket Details -- START
        //Block25 -- Start
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'ticket_no','vtiger_troubletickets',1,'4','ticket_no','Ticket No',1,0,'',100,13,25,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,4,25,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'parent_id','vtiger_troubletickets',1,'68','parent_id','Related To',1,0,'',100,2,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_troubletickets',1,'15','ticketpriorities','Priority',1,2,'',100,6,25,1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_troubletickets',1,'59','product_id','Product Name',1,2,'',100,5,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'severity','vtiger_troubletickets',1,'15','ticketseverities','Severity',1,2,'',100,8,25,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_troubletickets',1,'15','ticketstatus','Status',1,2,'',100,7,25,1,'V~M',1,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_troubletickets',1,'15','ticketcategories','Category',1,2,'',100,10,25,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'update_log','vtiger_troubletickets',1,'19','update_log','Update History',1,0,'',100,11,25,3,'V~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'hours','vtiger_troubletickets',1,'1','hours','Hours',1,2,'',100,9,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'days','vtiger_troubletickets',1,'1','days','Days',1,2,'',100,10,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,9,25,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,12,25,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_troubletickets',1,'22','ticket_title','Title',1,0,'',100,1,25,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,28,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'solution','vtiger_troubletickets',1,'19','solution','Solution',1,0,'',100,1,29,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'comments','vtiger_ticketcomments',1,'19','comments','Add Comment',1,0,'',100,1,30,1,'V~O',3,null,'BAS',0)");
        //Block25-30 -- End
        //Ticket Details -- END
        //Product Details -- START
        //Block31-36 -- Start
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productname','vtiger_products',1,'2','productname','Product Name',1,0,'',100,1,31,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'product_no','vtiger_products',1,'4','product_no','Product No',1,0,'',100,2,31,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productcode','vtiger_products',1,'1','productcode','Part Number',1,2,'',100,4,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'discontinued','vtiger_products',1,'56','discontinued','Product Active',1,2,'',100,3,31,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'manufacturer','vtiger_products',1,'15','manufacturer','Manufacturer',1,2,'',100,6,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,2,'',100,6,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,2,'',100,5,31,1,'D~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,2,'',100,8,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,2,'',100,7,31,1,'D~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,2,'',100,10,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_products',1,'17','website','Website',1,2,'',100,14,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,2,'',100,13,31,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,2,'',100,16,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,2,'',100,15,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,2,'',100,18,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,2,'',100,17,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'glacct','vtiger_products',1,'15','glacct','GL Account',1,2,'',100,20,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,19,31,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,21,31,2,'T~O',3,null,'BAS',0)");
        //Block32 Pricing Information
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'unit_price','vtiger_products',1,'72','unit_price','Unit Price',1,2,'',100,1,32,1,'N~O',2,3,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'commissionrate','vtiger_products',1,'9','commissionrate','Commission Rate',1,2,'',100,2,32,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'taxclass','vtiger_products',1,'83','taxclass','Tax Class',1,2,'',100,4,32,1,'V~O',3,null,'BAS',1)");
        //Block 33 stock info
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'usageunit','vtiger_products',1,'15','usageunit','Usage Unit',1,2,'',100,1,33,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qty_per_unit','vtiger_products',1,'1','qty_per_unit','Qty/Unit',1,2,'',100,2,33,1,'N~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qtyinstock','vtiger_products',1,'1','qtyinstock','Qty In Stock',1,2,'',100,3,33,1,'NN~O',0,4,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'reorderlevel','vtiger_products',1,'1','reorderlevel','Reorder Level',1,2,'',100,4,33,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'handler','vtiger_products',1,'52','assigned_user_id','Handler',1,0,'',100,5,33,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qtyindemand','vtiger_products',1,'1','qtyindemand','Qty In Demand',1,2,'',100,6,33,1,'I~O',1,null,'ADV',1)");
        //ProductImageInformation
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_products',1,'69','imagename','Product Image',1,2,'',100,1,35,1,'V~O',3,null,'ADV',1)");
        //Block 36 Description Info
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,36,1,'V~O',1,null,'BAS',1)");
        //Product Details -- END
        //Documents Details -- START
        //Block17 -- Start
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_notes',1,'2','notes_title','Title',1,0,'',100,1,17,1,'V~M',0,1,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,5,17,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,6,17,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'filename','vtiger_notes',1,'28','filename','File Name',1,2,'',100,3," . $fileblockid . ",1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,4,17,1,'V~M',0,3,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'notecontent','vtiger_notes',1,'19','notecontent','Note',1,2,'',100,1,{$desc_blockid},1,'V~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filetype','vtiger_notes',1,1,'filetype','File Type',1,2,'',100,5," . $fileblockid . ",2,'V~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filesize','vtiger_notes',1,1,'filesize','File Size',1,2,'',100,4," . $fileblockid . ",2,'I~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filelocationtype','vtiger_notes',1,27,'filelocationtype','Download Type',1,0,'',100,1," . $fileblockid . ",1,'V~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'fileversion','vtiger_notes',1,1,'fileversion','Version',1,2,'',100,6,{$fileblockid},1,'V~O',1,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filestatus','vtiger_notes',1,56,'filestatus','Active',1,2,'',100,2," . $fileblockid . ",1,'V~O',1,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filedownloadcount','vtiger_notes',1,1,'filedownloadcount','Download Count',1,2,'',100,7," . $fileblockid . ",2,'I~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'folderid','vtiger_notes',1,26,'folderid','Folder Name',1,2,'',100,2,17,1,'V~O',2,2,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'note_no','vtiger_notes',1,'4','note_no','Document No',1,0,'',100,3,17,1,'V~O',3,null,'BAS',0)");
        //Block17 -- End
        //Documents Details -- END
        //Email Details -- START
        //Block21 -- Start
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Date & Time Sent',1,0,'',100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'semodule','vtiger_activity',1,'2','parent_type','Sales Enity Module',1,0,'',100,2,21,3,'',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'2','activitytype','Activtiy Type',1,0,'',100,3,21,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,5,21,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,'',100,1,23,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'name','vtiger_attachments',1,'61','filename','Attachment',1,0,'',100,2,23,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,'',100,1,24,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,'',100,9,23,1,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,10,22,1,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,11,21,2,'T~O',3,null,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field VALUES (10," . $this->db->getUniqueID("vtiger_field") . ", 'access_count', 'vtiger_email_track', '1', '25', 'access_count', 'Access Count', '1', '0', '0', '100', '6', '21', '3', 'V~O', '1', NULL, 'BAS', 0)");
        //Block21 -- End
        //Email Details -- END
        //Task Details --START
        //Block19 -- Start
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,'',100,1,19,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,2,19,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,'',100,3,19,1,'DT~M~time_start',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,'',100,4,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,'',100,4,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'due_date','vtiger_activity',1,'23','due_date','Due Date',1,0,'',100,5,19,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,'',100,7,19,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,'',100,8,19,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_activity',1,'15','taskstatus','Status',1,0,'',100,8,19,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,'',100,9,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_activity',1,'15','taskpriority','Priority',1,0,'',100,10,19,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,'',100,11,19,1,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,14,19,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,15,19,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,'',100,16,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,'',100,17,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,'',100,1,20,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,'',100,17,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,'',100,18,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'location','vtiger_activity',1,'1','location','Location',1,0,'',100,19,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,'',100,1,19,3,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,'',100,6,19,3,'O~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'notime','vtiger_activity',1,56,'notime','No Time',1,0,'',100,20,19,3,'C~O',1,null,'BAS',1)");
        //Block19 -- End
        //Task Details -- END
        //Event Details --START
        //Block41-43-- Start
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,'',100,1,41,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,2,41,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,'',100,3,41,1,'DT~M~time_start',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,'',100,4,41,3,'T~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'due_date','vtiger_activity',1,'23','due_date','End Date',1,0,'',100,5,41,1,'D~M~OTH~GE~date_start~Start Date & Time',0,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,'',100,5,41,3,'T~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,'',100,6,41,1,'O~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,'',100,7,41,1,'I~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,'',100,8,41,3,'O~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,'',100,9,41,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,'',100,10,41,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,'',100,11,41,1,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,'',100,12,41,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'location','vtiger_activity',1,'1','location','Location',1,0,'',100,13,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,14,41,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,15,41,2,'T~O',3,null,'BAS',0)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_activity',1,15,'taskpriority','Priority',1,0,'',100,16,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'notime','vtiger_activity',1,56,'notime','No Time',1,0,'',100,17,41,1,'C~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,'',100,18,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,'',100,1,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,'',100,1,40,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,'',100,1,19,1,'I~O',1,null,'BAS',1)");
        //Block41-43 -- End
        //Event Details -- END
        //Faq Details -- START
        //Block37-40 -- Start
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_faq',1,'59','product_id','Product Name',1,2,'',100,1,37,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'faq_no','vtiger_faq',1,'4','faq_no','Faq No',1,0,'',100,2,37,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_faq',1,'15','faqcategories','Category',1,2,'',100,4,37,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_faq',1,'15','faqstatus','Status',1,2,'',100,3,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'question','vtiger_faq',1,'20','question','Question',1,2,'',100,7,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'answer','vtiger_faq',1,'20','faq_answer','Answer',1,2,'',100,8,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'comments','vtiger_faqcomments',1,'19','comments','Add Comment',1,0,'',100,1,38,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,5,37,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,6,37,2,'T~O',3,null,'BAS',0)");
        //Block37-40 -- End
        //Ticket Details -- END
        //Vendor Details --START
        //Block44-47
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'vendorname','vtiger_vendor',1,'2','vendorname','Vendor Name',1,0,'',100,1,{$vendorbasicinfo},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'vendor_no','vtiger_vendor',1,'4','vendor_no','Vendor No',1,0,'',100,2,{$vendorbasicinfo},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_vendor',1,'1','phone','Phone',1,2,'',100,4,{$vendorbasicinfo},1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_vendor',1,'13','email','Email',1,2,'',100,3,{$vendorbasicinfo},1,'E~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_vendor',1,'17','website','Website',1,2,'',100,6,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'glacct','vtiger_vendor',1,'15','glacct','GL Account',1,2,'',100,5,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_vendor',1,'1','category','Category',1,2,'',100,8,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,7,{$vendorbasicinfo},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,9,{$vendorbasicinfo},2,'T~O',3,null,'BAS',0)");
        //Block 46
        // JFV - change address display order
        //		 $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'street','vtiger_vendor',1,'21','street','Street',1,2,'',100,1,$vendoraddressblock,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'street','vtiger_vendor',1,'21','street','Street',1,2,'',100,4,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //		 $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'pobox','vtiger_vendor',1,'1','pobox','Po Box',1,2,'',100,2,$vendoraddressblock,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'pobox','vtiger_vendor',1,'1','pobox','Po Box',1,2,'',100,6,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //		 $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'city','vtiger_vendor',1,'1','city','City',1,2,'',100,3,$vendoraddressblock,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'city','vtiger_vendor',1,'1','city','City',1,2,'',100,2,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //		 $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'state','vtiger_vendor',1,'1','state','State',1,2,'',100,4,$vendoraddressblock,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'state','vtiger_vendor',1,'1','state','State',1,2,'',100,5,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //		 $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'postalcode','vtiger_vendor',1,'1','postalcode','Postal Code',1,2,'',100,5,$vendoraddressblock,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'postalcode','vtiger_vendor',1,'1','postalcode','Postal Code',1,2,'',100,3,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //		 $this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'country','vtiger_vendor',1,'1','country','Country',1,2,'',100,6,$vendoraddressblock,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'country','vtiger_vendor',1,'1','country','Country',1,2,'',100,1,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        // JFV END
        //Block 47
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$vendordescriptionblock},1,'V~O',1,null,'ADV',1)");
        //Vendor Details -- END
        //PriceBook Details Start
        //Block48
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'bookname','vtiger_pricebook',1,'2','bookname','Price Book Name',1,0,'',100,1,{$pricebookbasicblock},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'pricebook_no','vtiger_pricebook',1,'4','pricebook_no','PriceBook No',1,0,'',100,3,{$pricebookbasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'active','vtiger_pricebook',1,'56','active','Active',1,2,'',100,2,{$pricebookbasicblock},1,'C~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,4,{$pricebookbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,5,{$pricebookbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_pricebook',1,'117','currency_id','Currency',1,0,'',100,5,{$pricebookbasicblock},1,'I~M',0,3,'BAS',0)");
        //Block50
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$pricebookdescription},1,'V~O',1,null,'BAS',1)");
        //PriceBook Details End
        //Quote Details -- START
        //Block51
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'quote_no','vtiger_quotes',1,'4','quote_no','Quote No',1,0,'',100,3,{$quotesbasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_quotes',1,'2','subject','Subject',1,0,'',100,1,{$quotesbasicblock},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'potentialid','vtiger_quotes',1,'76','potential_id','Potential Name',1,2,'',100,2,{$quotesbasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'quotestage','vtiger_quotes',1,'15','quotestage','Quote Stage',1,2,'',100,4,{$quotesbasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'validtill','vtiger_quotes',1,'5','validtill','Valid Till',1,2,'',100,5,{$quotesbasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_quotes',1,'57','contact_id','Contact Name',1,2,'',100,6,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_quotes',1,'15','carrier','Carrier',1,2,'',100,8,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_quotes',1,'72','hdnSubTotal','Sub Total',1,2,'',100,9,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'shipping','vtiger_quotes',1,'1','shipping','Shipping',1,2,'',100,10,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'inventorymanager','vtiger_quotes',1,'77','assigned_user_id1','Inventory Manager',1,2,'',100,11,{$quotesbasicblock},1,'I~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'tax','vtiger_quotes',1,'1','txtTax','Sales Tax',1,0,'',100,13,51,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_quotes',1,'72','txtAdjustment','Adjustment',1,2,'',100,20,{$quotesbasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_quotes',1,'72','hdnGrandTotal','Total',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_quotes',1,'16','hdnTaxType','Tax Type',1,2,'',100,14,{$quotesbasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_quotes',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_quotes',1,'72','hdnDiscountAmount','Discount Amount',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_quotes',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_quotes',1,'73','account_id','Account Name',1,2,'',100,16,{$quotesbasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,17,{$quotesbasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,18,{$quotesbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,19,{$quotesbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_quotes',1,'117','currency_id','Currency',1,2,1,100,20,{$quotesbasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_quotes',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 53
        // JFV - change address display order
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_quotesbillads',1,'24','bill_street','Billing Address',1,2,'',100,1,$quotesaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_quotesbillads',1,'24','bill_street','Billing Address',1,2,'',100,9,{$quotesaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_quotesshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,$quotesaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_quotesshipads',1,'24','ship_street','Shipping Address',1,2,'',100,10,{$quotesaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_quotesbillads',1,'1','bill_city','Billing City',1,2,'',100,5,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_quotesbillads',1,'1','bill_city','Billing City',1,2,'',100,7,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_quotesshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_quotesshipads',1,'1','ship_city','Shipping City',1,2,'',100,8,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_quotesbillads',1,'1','bill_state','Billing State',1,2,'',100,7,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_quotesbillads',1,'1','bill_state','Billing State',1,2,'',100,5,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_quotesshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_quotesshipads',1,'1','ship_state','Shipping State',1,2,'',100,6,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_quotesbillads',1,'1','bill_code','Billing Code',1,2,'',100,9,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_quotesbillads',1,'1','bill_code','Billing Code',1,2,'',100,3,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_quotesshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_quotesshipads',1,'1','ship_code','Shipping Code',1,2,'',100,4,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_quotesbillads',1,'1','bill_country','Billing Country',1,2,'',100,11,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_quotesbillads',1,'1','bill_country','Billing Country',1,2,'',100,1,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_quotesshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_quotesshipads',1,'1','ship_country','Shipping Country',1,2,'',100,2,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_quotesbillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_quotesbillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,11,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,$quotesaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,12,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        // JFV END
        //Block55
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$quotedescription},1,'V~O',3,null,'ADV',1)");
        //Block 56
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_quotes',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$quotetermsblock},1,'V~O',3,null,'ADV',1)");
        //Quote Details -- END
        //Purchase Order Details -- START
        //Block57
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder_no','vtiger_purchaseorder',1,'4','purchaseorder_no','PurchaseOrder No',1,0,'',100,2,{$pobasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_purchaseorder',1,'2','subject','Subject',1,0,'',100,1,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'vendorid','vtiger_purchaseorder',1,'81','vendor_id','Vendor Name',1,0,'',100,3,{$pobasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'requisition_no','vtiger_purchaseorder',1,'1','requisition_no','Requisition No',1,2,'',100,4,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'tracking_no','vtiger_purchaseorder',1,'1','tracking_no','Tracking Number',1,2,'',100,5,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_purchaseorder',1,'57','contact_id','Contact Name',1,2,'',100,6,{$pobasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_purchaseorder',1,'5','duedate','Due Date',1,2,'',100,7,{$pobasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_purchaseorder',1,'15','carrier','Carrier',1,2,'',100,8,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_purchaseorder',1,'1','txtTax','Sales Tax',1,0,'',100,10,57,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_purchaseorder',1,'72','txtAdjustment','Adjustment',1,2,'',100,10,{$pobasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_purchaseorder',1,'1','salescommission','Sales Commission',1,2,'',100,11,{$pobasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_purchaseorder',1,'1','exciseduty','Excise Duty',1,2,'',100,12,{$pobasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_purchaseorder',1,'72','hdnGrandTotal','Total',1,2,'',100,13,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_purchaseorder',1,'72','hdnSubTotal','Sub Total',1,2,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_purchaseorder',1,'16','hdnTaxType','Tax Type',1,2,'',100,14,{$pobasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_purchaseorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_purchaseorder',1,'72','hdnDiscountAmount','Discount Amount',1,0,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_purchaseorder',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'postatus','vtiger_purchaseorder',1,'15','postatus','Status',1,2,'',100,15,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,16,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,17,{$pobasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,18,{$pobasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_purchaseorder',1,'117','currency_id','Currency',1,2,1,100,19,{$pobasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_purchaseorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 59
        // JFV - change address display order
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_pobillads',1,'24','bill_street','Billing Address',1,2,'',100,1,$poaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_pobillads',1,'24','bill_street','Billing Address',1,2,'',100,9,{$poaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_poshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,$poaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_poshipads',1,'24','ship_street','Shipping Address',1,2,'',100,10,{$poaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_pobillads',1,'1','bill_city','Billing City',1,2,'',100,5,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_pobillads',1,'1','bill_city','Billing City',1,2,'',100,7,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_poshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_poshipads',1,'1','ship_city','Shipping City',1,2,'',100,8,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_pobillads',1,'1','bill_state','Billing State',1,2,'',100,7,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_pobillads',1,'1','bill_state','Billing State',1,2,'',100,5,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_poshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_poshipads',1,'1','ship_state','Shipping State',1,2,'',100,6,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_pobillads',1,'1','bill_code','Billing Code',1,2,'',100,9,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_pobillads',1,'1','bill_code','Billing Code',1,2,'',100,3,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_poshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_poshipads',1,'1','ship_code','Shipping Code',1,2,'',100,4,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_pobillads',1,'1','bill_country','Billing Country',1,2,'',100,11,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_pobillads',1,'1','bill_country','Billing Country',1,2,'',100,1,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_poshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_poshipads',1,'1','ship_country','Shipping Country',1,2,'',100,2,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_pobillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_pobillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,11,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_poshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,$poaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_poshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,12,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        // JFV END
        //Block61
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$podescription},1,'V~O',3,null,'ADV',1)");
        //Block62
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_purchaseorder',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$potermsblock},1,'V~O',3,null,'ADV',1)");
        //Purchase Order Details -- END
        //Sales Order Details -- START
        //Block63
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'salesorder_no','vtiger_salesorder',1,'4','salesorder_no','SalesOrder No',1,0,'',100,4,{$sobasicblock} ,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_salesorder',1,'2','subject','Subject',1,0,'',100,1,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'potentialid','vtiger_salesorder',1,'76','potential_id','Potential Name',1,2,'',100,2,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'customerno','vtiger_salesorder',1,'1','customerno','Customer No',1,2,'',100,3,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'quoteid','vtiger_salesorder',1,'78','quote_id','Quote Name',1,2,'',100,5,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder','vtiger_salesorder',1,'1','vtiger_purchaseorder','Purchase Order',1,2,'',100,5,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_salesorder',1,'57','contact_id','Contact Name',1,2,'',100,6,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_salesorder',1,'5','duedate','Due Date',1,2,'',100,8,{$sobasicblock} ,1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_salesorder',1,'15','carrier','Carrier',1,2,'',100,9,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'pending','vtiger_salesorder',1,'1','pending','Pending',1,2,'',100,10,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'sostatus','vtiger_salesorder',1,'15','sostatus','Status',1,2,'',100,11,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_salesorder',1,'1','txtTax','Sales Tax',1,0,'',100,12,63,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_salesorder',1,'72','txtAdjustment','Adjustment',1,2,'',100,12,{$sobasicblock} ,3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_salesorder',1,'1','salescommission','Sales Commission',1,2,'',100,13,{$sobasicblock} ,1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_salesorder',1,'1','exciseduty','Excise Duty',1,2,'',100,13,{$sobasicblock} ,1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_salesorder',1,'72','hdnGrandTotal','Total',1,2,'',100,14,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_salesorder',1,'72','hdnSubTotal','Sub Total',1,2,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_salesorder',1,'16','hdnTaxType','Tax Type',1,2,'',100,15,{$sobasicblock} ,3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_salesorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_salesorder',1,'72','hdnDiscountAmount','Discount Amount',1,0,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_salesorder',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_salesorder',1,'73','account_id','Account Name',1,2,'',100,16,{$sobasicblock} ,1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,17,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,18,{$sobasicblock} ,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,19,{$sobasicblock} ,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_salesorder',1,'117','currency_id','Currency',1,2,1,100,20,{$sobasicblock} ,3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_salesorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        //Block 65
        // JFV - change address display order
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_sobillads',1,'24','bill_street','Billing Address',1,2,'',100,1,$soaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_sobillads',1,'24','bill_street','Billing Address',1,2,'',100,9,{$soaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_soshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,$soaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_soshipads',1,'24','ship_street','Shipping Address',1,2,'',100,10,{$soaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_sobillads',1,'1','bill_city','Billing City',1,2,'',100,5,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_sobillads',1,'1','bill_city','Billing City',1,2,'',100,7,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_soshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_soshipads',1,'1','ship_city','Shipping City',1,2,'',100,8,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_sobillads',1,'1','bill_state','Billing State',1,2,'',100,7,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_sobillads',1,'1','bill_state','Billing State',1,2,'',100,5,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_soshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_soshipads',1,'1','ship_state','Shipping State',1,2,'',100,6,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_sobillads',1,'1','bill_code','Billing Code',1,2,'',100,9,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_sobillads',1,'1','bill_code','Billing Code',1,2,'',100,3,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_soshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_soshipads',1,'1','ship_code','Shipping Code',1,2,'',100,4,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_sobillads',1,'1','bill_country','Billing Country',1,2,'',100,11,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_sobillads',1,'1','bill_country','Billing Country',1,2,'',100,1,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_soshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_soshipads',1,'1','ship_country','Shipping Country',1,2,'',100,2,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_sobillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_sobillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,11,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_soshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,$soaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_soshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,12,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        // JFV END
        //Block67
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$sodescription},1,'V~O',3,null,'ADV',1)");
        //Block68
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_salesorder',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$sotermsblock},1,'V~O',3,null,'ADV',1)");
        // Add fields for the Recurring Information block - Block 86
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'enable_recurring','vtiger_salesorder',1,'56','enable_recurring','Enable Recurring',1,0,'',100,1,{$sorecurringinvoiceblock},1,'C~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'recurring_frequency','vtiger_invoice_recurring_info',1,'16','recurring_frequency','Frequency',1,0,'',100,2,{$sorecurringinvoiceblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'start_period','vtiger_invoice_recurring_info',1,'5','start_period','Start Period',1,0,'',100,3,{$sorecurringinvoiceblock},1,'D~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'end_period','vtiger_invoice_recurring_info',1,'5','end_period','End Period',1,0,'',100,4,{$sorecurringinvoiceblock},1,'D~O~OTH~G~start_period~Start Period',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'payment_duration','vtiger_invoice_recurring_info',1,'16','payment_duration','Payment Duration',1,0,'',100,5,{$sorecurringinvoiceblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'invoice_status','vtiger_invoice_recurring_info',1,'15','invoicestatus','Invoice Status',1,0,'',100,6,{$sorecurringinvoiceblock},1,'V~M',3,null,'BAS',0)");
        //Sales Order Details -- END
        //Invoice Details -- START
        //Block69
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_invoice',1,'2','subject','Subject',1,0,'',100,1,{$invoicebasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'salesorderid','vtiger_invoice',1,'80','salesorder_id','Sales Order',1,2,'',100,2,{$invoicebasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'customerno','vtiger_invoice',1,'1','customerno','Customer No',1,2,'',100,3,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        //to include contact name vtiger_field in Invoice-start
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_invoice',1,'57','contact_id','Contact Name',1,2,'',100,4,{$invoicebasicblock},1,'I~O',3,null,'BAS',1)");
        //end
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoicedate','vtiger_invoice',1,'5','invoicedate','Invoice Date',1,2,'',100,5,{$invoicebasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_invoice',1,'5','duedate','Due Date',1,2,'',100,6,{$invoicebasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder','vtiger_invoice',1,'1','vtiger_purchaseorder','Purchase Order',1,2,'',100,8,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_invoice',1,'1','txtTax','Sales Tax',1,0,'',100,9,69,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_invoice',1,'72','txtAdjustment','Adjustment',1,2,'',100,9,{$invoicebasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_invoice',1,'1','salescommission','Sales Commission',1,2,'',10,13,{$invoicebasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_invoice',1,'1','exciseduty','Excise Duty',1,2,'',100,11,{$invoicebasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_invoice',1,'72','hdnSubTotal','Sub Total',1,2,'',100,12,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_invoice',1,'72','hdnGrandTotal','Total',1,2,'',100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_invoice',1,'16','hdnTaxType','Tax Type',1,2,'',100,13,{$invoicebasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_invoice',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_invoice',1,'72','hdnDiscountAmount','Discount Amount',1,2,'',100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_invoice',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,14,57,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_invoice',1,'73','account_id','Account Name',1,2,'',100,14,{$invoicebasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoicestatus','vtiger_invoice',1,'15','invoicestatus','Status',1,2,'',100,15,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,16,{$invoicebasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,17,{$invoicebasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,18,{$invoicebasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_invoice',1,'117','currency_id','Currency',1,2,1,100,19,{$invoicebasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_invoice',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 71
        // JFV - change address display order
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_street','vtiger_invoicebillads',1,'24','bill_street','Billing Address',1,2,'',100,1,$invoiceaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_invoicebillads',1,'24','bill_street','Billing Address',1,2,'',100,9,{$invoiceaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_street','vtiger_invoiceshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,$invoiceaddressblock,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_invoiceshipads',1,'24','ship_street','Shipping Address',1,2,'',100,10,{$invoiceaddressblock},1,'V~M',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_city','vtiger_invoicebillads',1,'1','bill_city','Billing City',1,2,'',100,5,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_invoicebillads',1,'1','bill_city','Billing City',1,2,'',100,7,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_city','vtiger_invoiceshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_invoiceshipads',1,'1','ship_city','Shipping City',1,2,'',100,8,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_state','vtiger_invoicebillads',1,'1','bill_state','Billing State',1,2,'',100,7,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_invoicebillads',1,'1','bill_state','Billing State',1,2,'',100,5,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_state','vtiger_invoiceshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_invoiceshipads',1,'1','ship_state','Shipping State',1,2,'',100,6,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_code','vtiger_invoicebillads',1,'1','bill_code','Billing Code',1,2,'',100,9,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_invoicebillads',1,'1','bill_code','Billing Code',1,2,'',100,3,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_code','vtiger_invoiceshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_invoiceshipads',1,'1','ship_code','Shipping Code',1,2,'',100,4,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_country','vtiger_invoicebillads',1,'1','bill_country','Billing Country',1,2,'',100,11,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_invoicebillads',1,'1','bill_country','Billing Country',1,2,'',100,1,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_country','vtiger_invoiceshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_invoiceshipads',1,'1','ship_country','Shipping Country',1,2,'',100,2,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'bill_pobox','vtiger_invoicebillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_invoicebillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,11,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //		 $this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'ship_pobox','vtiger_invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,$invoiceaddressblock,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,12,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        // JFV END
        //Block73
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$invoicedescription},1,'V~O',3,null,'ADV',1)");
        //Block74
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$invoicetermsblock},1,'V~O',3,null,'ADV',1)");
        //Added for Custom invoice Number
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoice_no','vtiger_invoice',1,'4','invoice_no','Invoice No',1,0,'',100,3,{$invoicebasicblock},1,'V~O',3,null,'BAS',0)");
        //Invoice Details -- END
        //users Details Starts Block 79,80,81
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'user_name','vtiger_users',1,'106','user_name','User Name',1,0,'',11,1,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'is_admin','vtiger_users',1,'156','is_admin','Admin',1,0,'',3,2,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'user_password','vtiger_users',1,'99','user_password','Password',1,0,'',30,3,{$userloginandroleblockid},4,'P~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'confirm_password','vtiger_users',1,'99','confirm_password','Confirm Password',1,0,'',30,5,{$userloginandroleblockid},4,'P~M',1,null,'BAS',1)");
        // JFV - change firstname and lastname order to japan/china way
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'first_name','vtiger_users',1,'1','first_name','First Name',1,0,'',30,7,$userloginandroleblockid,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'first_name','vtiger_users',1,'1','first_name','First Name',1,0,'',30,11,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'last_name','vtiger_users',1,'2','last_name','Last Name',1,0,'',30,9,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'roleid','vtiger_user2role',1,'98','roleid','Role',1,0,'',200,11,$userloginandroleblockid,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'roleid','vtiger_user2role',1,'98','roleid','Role',1,0,'',200,7,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        // JFV END
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'email1','vtiger_users',1,'104','email1','Email',1,0,'',100,4,{$userloginandroleblockid},1,'E~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_users',1,'115','status','Status',1,0,'',100,6,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'activity_view','vtiger_users',1,'16','activity_view','Default Activity View',1,0,'',100,12,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'lead_view','vtiger_users',1,'16','lead_view','Default Lead View',1,0,'',100,10,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'hour_format','vtiger_users',1,'116','hour_format','Calendar Hour Format',1,0,'',100,13,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'end_hour','vtiger_users',1,'116','end_hour','Day ends at',1,0,'',100,15,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'start_hour','vtiger_users',1,'116','start_hour','Day starts at',1,0,'',100,14,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_users',1,'1','title','Title',1,0,'',50,1,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_work','vtiger_users',1,'1','phone_work','Office Phone',1,0,'',50,5,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'department','vtiger_users',1,'1','department','Department',1,0,'',50,3,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_mobile','vtiger_users',1,'1','phone_mobile','Mobile',1,0,'',50,7,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'reports_to_id','vtiger_users',1,'101','reports_to_id','Reports To',1,0,'',50,8,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_other','vtiger_users',1,'1','phone_other','Other Phone',1,0,'',50,11,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'email2','vtiger_users',1,'13','email2','Other Email',1,0,'',100,4,{$usermoreinfoblock},1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_fax','vtiger_users',1,'1','phone_fax','Fax',1,0,'',50,2,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'secondaryemail','vtiger_users',1,'13','secondaryemail','Secondary Email',1,0,'',100,6,{$usermoreinfoblock},1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_home','vtiger_users',1,'1','phone_home','Home Phone',1,0,'',50,9,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'date_format','vtiger_users',1,'16','date_format','Date Format',1,0,'',30,12,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'signature','vtiger_users',1,'21','signature','Signature',1,0,'',250,13,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_users',1,'21','description','Documents',1,0,'',250,14,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        // JFV - change address display order
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_street','vtiger_users',1,'21','address_street','Street Address',1,0,'',250,1,$useraddressblock,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_street','vtiger_users',1,'21','address_street','Street Address',1,0,'',250,4,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_city','vtiger_users',1,'1','address_city','City',1,0,'',100,3,$useraddressblock,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_city','vtiger_users',1,'1','address_city','City',1,0,'',100,2,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_state','vtiger_users',1,'1','address_state','State',1,0,'',100,5,$useraddressblock,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_state','vtiger_users',1,'1','address_state','State',1,0,'',100,5,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_postalcode','vtiger_users',1,'1','address_postalcode','Postal Code',1,0,'',100,4,$useraddressblock,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_postalcode','vtiger_users',1,'1','address_postalcode','Postal Code',1,0,'',100,3,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        //		$this->db->query("insert into vtiger_field values (29,".$this->db->getUniqueID("vtiger_field").",'address_country','vtiger_users',1,'1','address_country','Country',1,0,'',100,2,$useraddressblock,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_country','vtiger_users',1,'1','address_country','Country',1,0,'',100,1,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        // JFV EN
        $this->db->query("insert into vtiger_field values(29," . $this->db->getUniqueID("vtiger_field") . ",'accesskey','vtiger_users',1,3,'accesskey','Webservice Access Key',1,0,'',100,2,{$useradvanceblock},2,'V~O',1,null,'BAS',1);");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'time_zone','vtiger_users',1,'16','time_zone','Time Zone',1,0,'',200,15,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_users',1,'117','currency_id','Currency',1,0,'',100,1,{$usercurrencyinfoblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_grouping_pattern','vtiger_users',1,'16','currency_grouping_pattern','Digit Grouping Pattern',1,0,'',100,2,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_decimal_separator','vtiger_users',1,'16','currency_decimal_separator','Decimal Separator',1,0,'',2,3,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_grouping_separator','vtiger_users',1,'16','currency_grouping_separator','Digit Grouping Separator',1,0,'',2,4,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_symbol_placement','vtiger_users',1,'16','currency_symbol_placement','Symbol Placement',1,0,'',20,5,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        //User Image Information
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_users',1,'105','imagename','User Image',1,0,'',250,10,{$userblockid},1,'V~O',1,null,'BAS',1)");
        //added for internl_mailer
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'internal_mailer','vtiger_users',1,'56','internal_mailer','INTERNAL_MAIL_COMPOSER',1,0,'',50,15,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'theme','vtiger_users',1,'31','theme','Theme',1,0,'',100,16,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'language','vtiger_users',1,'32','language','Language',1,0,'',100,17,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'reminder_interval','vtiger_users',1,'16','reminder_interval','Reminder Interval',1,0,'',100,1,{$useradvanceblock},1,'V~O',1,null,'BAS',1)");
        //user Details End
        // Updated Phone field uitype
        $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=" . getTabid('Leads'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=" . getTabid('Contacts'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Leads'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Contacts'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Accounts'));
        $tab_field_array = array('Accounts' => array('accountname'), 'Contacts' => array('imagename'), 'Products' => array('imagename', 'product_id'), 'Invoice' => array('invoice_no', 'salesorder_id'), 'SalesOrder' => array('quote_id', 'salesorder_no'), 'PurchaseOrder' => array('purchaseorder_no'), 'Quotes' => array('quote_no'), 'HelpDesk' => array('filename'));
        foreach ($tab_field_array as $index => $value) {
            $tabid = getTabid($index);
            $this->db->pquery("UPDATE vtiger_field SET masseditable=0 WHERE tabid=? AND fieldname IN (" . generateQuestionMarks($value) . ")", array($tabid, $value));
        }
        //Emails field added here
        $email_Tabid = getTabid('Emails');
        $blockquery = "select blockid from vtiger_blocks where blocklabel = ?";
        $blockres = $this->db->pquery($blockquery, array('LBL_EMAIL_INFORMATION'));
        $blockid = $this->db->query_result($blockres, 0, 'blockid');
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'from_email','vtiger_emaildetails',1,12,'from_email','From',1,2,'',100,1,{$blockid},3,'V~M',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'to_email','vtiger_emaildetails',1,8,'saved_toid','To',1,2,'',100,2,{$blockid},1,'V~M',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'cc_email','vtiger_emaildetails',1,8,'ccmail','CC',1,2,'',1000,3,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'bcc_email','vtiger_emaildetails',1,8,'bccmail','BCC' ,1,2,'',1000,4,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'idlists','vtiger_emaildetails',1,357,'parent_id','Parent ID' ,1,2,'',1000,5,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'email_flag','vtiger_emaildetails',1,16,'email_flag','Email Flag' ,1,2,'',1000,6,{$blockid},3,'V~O',3,NULL,'BAS',0)");
        //Emails fields ends
        //The Entity Name for the modules are maintained in this table
        $this->db->query("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','lastname,firstname','leadid','leadid')");
        $this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid','account_id')");
        $this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid','contact_id')");
        $this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid','potential_id')");
        $this->db->query("insert into vtiger_entityname values(8,'Documents','vtiger_notes','title','notesid','notesid')");
        $this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid','ticketid')");
        $this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid','activityid')");
        $this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid','activityid')");
        $this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid','product_id')");
        $this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','last_name,first_name','id','id')");
        $this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid','invoiceid')");
        $this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid','quote_id')");
        $this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid','purchaseorderid')");
        $this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid','salesorder_id')");
        $this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid','vendor_id')");
        $this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid','pricebookid')");
        $this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid','campaignid')");
        $this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id','id')");
        // Insert End
        //Inserting values into org share action mapping
        $this->db->query("insert into vtiger_org_share_action_mapping values(0,'Public: Read Only')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(1,'Public: Read, Create/Edit')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(3,'Private')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(4,'Hide Details')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(5,'Hide Details and Add Events')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(6,'Show Details')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(7,'Show Details and Add Events')");
        //Inserting for all vtiger_tabs
        $def_org_tabid = array(2, 4, 6, 7, 8, 9, 10, 13, 16, 20, 21, 22, 23, 26);
        foreach ($def_org_tabid as $def_tabid) {
            $this->db->query("insert into vtiger_org_share_action2tab values(0," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(1," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(2," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(3," . $def_tabid . ")");
        }
        //Insert into default_org_sharingrule
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",2,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",4,2,2)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",6,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",7,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",9,3,1)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",13,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",16,3,2)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",20,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",21,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",22,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",23,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",26,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",8,2,0)");
        //Populating the DataShare Related Modules
        //Lead Related Module
        //Account Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,2)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,13)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,20)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,22)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,23)");
        //Potential Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",2,20)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",2,22)");
        //Quote Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",20,22)");
        //SO Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",22,23)");
        // New Secutity End
        //insert into the vtiger_notificationscheduler vtiger_table
        //insert into related list vtiger_table
        //Inserting for vtiger_account related lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Potentials") . ",'get_opportunities',2,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Quotes") . ",'get_quotes',3,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("SalesOrder") . ",'get_salesorder',4,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Invoice") . ",'get_invoices',5,'Invoice',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Calendar") . ",'get_activities',6,'Activities',0,'add')");
        //added for the ticket4109
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Emails") . ",'get_emails',7,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Calendar") . ",'get_history',8,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Documents") . ",'get_attachments',9,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("HelpDesk") . ",'get_tickets',10,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Products") . ",'get_products',11,'Products',0,'select')");
        //Inserting Lead Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Emails") . ",'get_emails',2,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Documents") . ",'get_attachments',4,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Products") . ",'get_products',5,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Campaigns") . ",'get_campaigns',6,'Campaigns',0,'select')");
        //Inserting for contact related lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Potentials") . ",'get_opportunities',1,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Calendar") . ",'get_activities',2,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Emails") . ",'get_emails',3,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("HelpDesk") . ",'get_tickets',4,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Quotes") . ",'get_quotes',5,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("PurchaseOrder") . ",'get_purchase_orders',6,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("SalesOrder") . ",'get_salesorder',7,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Products") . ",'get_products',8,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Calendar") . ",'get_history',9,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Documents") . ",'get_attachments',10,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Campaigns") . ",'get_campaigns',11,'Campaigns',0,'select')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid('Contacts') . "," . getTabid('Invoice') . ",'get_invoices',12,'Invoice',0, 'add')");
        //Inserting Potential Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Contacts") . ",'get_contacts',2,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Products") . ",'get_products',3,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . ",0,'get_stage_history',4,'Sales Stage History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Documents") . ",'get_attachments',5,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Quotes") . ",'get_Quotes',6,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("SalesOrder") . ",'get_salesorder',7,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Calendar") . ",'get_history',8,'Activity History',0,'')");
        //Inserting Product Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("HelpDesk") . ",'get_tickets',1,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Quotes") . ",'get_quotes',4,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("PurchaseOrder") . ",'get_purchase_orders',5,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("SalesOrder") . ",'get_salesorder',6,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Invoice") . ",'get_invoices',7,'Invoice',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("PriceBooks") . ",'get_product_pricebooks',8,'PriceBooks',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Leads") . ",'get_leads',9,'Leads',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Accounts") . ",'get_accounts',10,'Accounts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Contacts") . ",'get_contacts',11,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Potentials") . ",'get_opportunities',12,'Potentials',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Products") . ",'get_products',13,'Product Bundles',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Products") . ",'get_parent_products',14,'Parent Product',0,'')");
        //Inserting Emails Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'select,bulkmail')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . ",0,'get_users',2,'Users',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        //Inserting HelpDesk Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . ",0,'get_ticket_history',3,'Ticket History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Calendar") . ",'get_history',4,'Activity History',0,'')");
        //Inserting PriceBook Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PriceBooks") . ",14,'get_pricebook_products',2,'Products',0,'select')");
        // Inserting Vendor Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",14,'get_products',1,'Products',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",21,'get_purchase_orders',2,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",4,'get_contacts',3,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . "," . getTabid("Emails") . ",'get_emails',4,'Emails',0,'add')");
        // Inserting Quotes Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . "," . getTabid("SalesOrder") . ",'get_salesorder',1,'Sales Order',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",9,'get_activities',2,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",9,'get_history',4,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",0,'get_quotestagehistory',5,'Quote Stage History',0,'')");
        // Inserting Purchase order Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . ",0,'get_postatushistory',4,'PurchaseOrder Status History',0,'')");
        // Inserting Sales order Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Invoice") . ",'get_invoices',3,'Invoice',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Calendar") . ",'get_history',4,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . ",0,'get_sostatushistory',5,'SalesOrder Status History',0,'')");
        // Inserting Invoice Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . ",0,'get_invoicestatushistory',4,'Invoice Status History',0,'')");
        // Inserting Activities Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Calendar") . ",0,'get_users',1,'Users',0,'')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Calendar") . ",4,'get_contacts',2,'Contacts',0,'')");
        // Inserting Campaigns Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Leads") . ",'get_leads',2,'Leads',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Potentials") . ",'get_opportunities',3,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . ",9,'get_activities',4,'Activities',0,'add')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES (" . $this->db->getUniqueID('vtiger_relatedlists') . ", " . getTabid("Accounts") . ", " . getTabid("Campaigns") . ", 'get_campaigns', 13, 'Campaigns', 0, 'select')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES (" . $this->db->getUniqueID('vtiger_relatedlists') . ", " . getTabid("Campaigns") . ", " . getTabid("Accounts") . ", 'get_accounts', 5, 'Accounts', 0, 'add,select')");
        // Inserting Faq's Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Faq") . "," . getTabid("Documents") . ",'get_attachments',1,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_TASK_NOTIFICATION_DESCRITPION',1,'Task Delay Notification','Tasks delayed beyond 24 hrs ','LBL_TASK_NOTIFICATION')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_BIG_DEAL_DESCRIPTION' ,1,'Big Deal notification','Success! A big deal has been won! ','LBL_BIG_DEAL')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_TICKETS_DESCRIPTION',1,'Pending Tickets notification','Ticket pending please ','LBL_PENDING_TICKETS')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_MANY_TICKETS_DESCRIPTION',1,'Too many tickets Notification','Too many tickets pending against this entity ','LBL_MANY_TICKETS')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_START_DESCRIPTION' ,1,'Support Start Notification','10','LBL_START_NOTIFICATION','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_SUPPORT_DESCRIPTION',1,'Support ending please','11','LBL_SUPPORT_NOTICIATION','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_SUPPORT_DESCRIPTION_MONTH',1,'Support ending please','12','LBL_SUPPORT_NOTICIATION_MONTH','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notification','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')");
        //inserting actions for get_attachments
        $folderid = $this->db->getUniqueID("vtiger_attachmentsfolder");
        $this->db->query("insert into vtiger_attachmentsfolder values(" . $folderid . ",'Default','This is a Default Folder',1,1)");
        //Inserting Inventory Notifications
        $invoice_body = 'Dear {HANDLER},

The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. Kindly procure required number of units as the stock level is below reorder level {REORDERLEVELVALUE}.

Please treat this information as Urgent as the invoice is already sent  to the customer.

Severity: Critical

Thanks,
{CURRENTUSER}';
        // JFV - add japanese localization to inventry notification
        $invoice_body = '{HANDLER} 様

{PRODUCTNAME} の現在の在庫量は {CURRENTSTOCK} です。在庫レベルが再発注レベルを下回っているので、必要数を再調達して下さい。

請求書が既にお客様に発送済みのため、緊急対応をお願いします。

重要度: 極めて重要

宜しくお願いします
{CURRENTUSER}

---------------
' . $invoice_body;
        // JFV END
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','" . $invoice_body . " ','InvoiceNotificationDescription')");
        $quote_body = 'Dear {HANDLER},

Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 

Severity: Minor

Thanks,
{CURRENTUSER}';
        // JFV - add japanese localization to inventry notification
        $quote_body = '{HANDLER} 様

		{QUOTEQUANTITY} ユニットの {PRODUCTNAME} に対して 見積りが作成されました。{PRODUCTNAME} の現在の在庫数は {CURRENTSTOCK} です。

		重要度: 軽微

		宜しくお願いします
		{CURRENTUSER}

		---------------
		' . $quote_body;
        // JFV END
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'QuoteNotification','Quote given for {PRODUCTNAME}','" . $quote_body . " ','QuoteNotificationDescription')");
        $so_body = 'Dear {HANDLER},

SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 

Please treat this information  with priority as the sales order is already generated.

Severity: Major

Thanks,
{CURRENTUSER}';
        // JFV - add japanese localization to inventry notification
        $so_body = '{HANDLER} 様,

{SOQUANTITY} ユニットの {PRODUCTNAME} に対して 販売受注書が作成されました。{PRODUCTNAME} の現在の在庫数は {CURRENTSTOCK} です。

Please treat this information  with priority as the sales order is already generated.
販売受注書が既に作成済みのため、優先的に対応をお願いします。

重要度: 重要

宜しくお願いします
{CURRENTUSER}

---------------
' . $so_body;
        // JFV END
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'SalesOrderNotification','Sales Order generated for {PRODUCTNAME}','" . $so_body . " ','SalesOrderNotificationDescription')");
        //insert into inventory terms and conditions table
        $inv_tandc_text = '
 - Unless otherwise agreed in writing by the supplier all invoices are payable within thirty (30) days of the date of invoice, in the currency of the invoice, drawn on a bank based in India or by such other method as is agreed in advance by the Supplier.

 - All prices are not inclusive of VAT which shall be payable in addition by the Customer at the applicable rate.';
        // JFV - add japanese localization to terms and conditions
        $inv_tandc_text = '
 - サプライヤーによる書面による同意がある場合を除き、すべての請求書は発行日より 30 日以内に、請求書指定の貨幣により、インドに拠点を持つ銀行の drown on またはサプライヤーによる事前の同意を得た他の方法にて、支払われるものとします。

 - すべての価格は VAT を含まず、お客様により適切な比率の追加の支払いが行われるものとします。

---------------
' . $inv_tandc_text;
        // JFV END
        $this->db->query("insert into vtiger_inventory_tandc(id,type,tandc) values (" . $this->db->getUniqueID("vtiger_inventory_tandc") . ", 'Inventory', '" . $inv_tandc_text . "')");
        //insert into email template vtiger_table
        $body = 'Hello!   <br />
	<br />
	On behalf of the vtiger team,  I am pleased to announce the release of vtiger crm4.2 . This is a feature packed release including the mass email template handling, custom view feature, vtiger_reports feature and a host of other utilities. vtiger runs on all platforms.    <br />
        <br />
	Notable Features of vtiger are :   <br />
	<br />
	-Email Client Integration    <br />
	-Trouble Ticket Integration   <br />
	-Invoice Management Integration   <br />
	-Reports Integration   <br />
	-Portal Integration   <br />
	-Enhanced Word Plugin Support   <br />
	-Custom View Integration   <br />
	<br />
	Known Issues:   <br />
	-ABCD   <br />
	-EFGH   <br />
	-IJKL   <br />
	-MNOP   <br />
	-QRST';
        // JFV - add japanese localization to email template
        $body = 'いつもお世話になっております   <br />
	<br />
	vtiger チームに代わり、vtiger CRM 4.2 リリースの喜びをお伝え致します。このリリースには、E メール  テンプレート処理、カスタム ビュー機能、vtiger_reports 機能および多数のその他ユーティリティが含まれます。vtiger CRM はすべてのプラットフォームで稼働します。<br />
	<br />
	vtiger CRM の注目機能 :   <br />
	<br />
	-E メール クライアント統合    <br />
	-サポート依頼統合   <br />
	-請求書管理統合   <br />
	-レポート統合   <br />
	-ポータル統合   <br />
	-強化された Word プラグイン対応   <br />
	-カスタム ビュー統合   <br />
	<br />
	既知の問題:   <br />
	-ABCD   <br />
	-EFGH   <br />
	-IJKL   <br />
	-MNOP   <br />
	-QRST' . "<br /><br />----------<br />" . $body;
        //          $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Announcement for Release','Announcement for Release','Announcement of a release','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) リリースの報告 / Announcement for Release','リリースの報告 / Announcement for Release','リリース報告 / Announcement of a release','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = 'name <br />
street, <br />
city, <br />
state, <br />
 zip) <br />
  <br />
 Dear <br />
 <br />
 Please check the following invoices that are yet to be paid by you: <br />
 <br />
 No. Date      Amount <br />
 1   1/1/01    $4000 <br />
 2   2/2//01   $5000 <br />
 3   3/3/01    $10000 <br />
 4   7/4/01    $23560 <br />
 <br />
 Kindly let us know if there are any issues that you feel are pending to be discussed. <br />
 We will be more than happy to give you a call. <br />
 We would like to continue our business with you.';
        // JFV - add japanese localization to email template
        $body = 'name <br />
street, <br />
city, <br />
state, <br />
 zip) <br />
  <br />
  様 <br />
 <br />
 以下の請求が未払いですので、ご確認下さいませ。<br />
 <br />
 No. 日付                    金額 <br />
 1   2001/1/1    $4000 <br />
 2   2001/2/2    $5000 <br />
 3   2001/3/3    $10000 <br />
 4   2001/4/7    $23560 <br />
 <br />
 懸案事項がある場合は、ご遠慮なくお知らせ下さい。<br />
 お電話でのご相談が宜しければ喜んで対応いたします。<br />
 今後ともお引き立ての程を宜しくお願い致します。<br />' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Pending Invoices','Invoices Pending','Payment Due','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 未払い請求書 / Pending Invoices','請求書の未払いについて / Invoices Pending','支払い期限 / Payment Due','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = ' Dear <br />
 <br />
Your proposal on the project XYZW has been reviewed by us <br />
and is acceptable in its entirety. <br />
 <br />
We are eagerly looking forward to this project <br />
and are pleased about having the opportunity to work <br />
together. We look forward to a long standing relationship <br />
with your esteemed firm. <br />
<br />
I would like to take this opportunity to invite you <br />
to a game of golf on Wednesday morning 9am at the <br />
Cuff Links Ground. We will be waiting for you in the <br />
Executive Lounge. <br />
<br />
Looking forward to seeing you there.';
        // JFV - add japanese localization to email template
        $body = ' 様 <br />
<br />
XYZW 案件の提案書をレビューした結果、全般において受け入れ可能なものでした。<br />
<br />
私どもはこの案件に強い期待を抱いており、 協業の機会を持てることを喜んでいます。 <br />
貴社との長期的な関係を築けるよう望んでおります。<br />
<br />
この機会を大切にするため、水曜日の午前 9 時から Cuff Links Ground にて行われる<br />
ゴルフにお誘いしたいと考えています。<br />
エグゼクティブ ラウンジにてお待ちする予定です。<br />
<br />
ご参加頂けますようご検討お願い致します。' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Acceptance Proposal','Acceptance Proposal','Acceptance of Proposal','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 提案書の了承 / Acceptance Proposal','提案書の了承 / Acceptance Proposal','提案書の了承 / Acceptance of Proposal','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = ' The undersigned hereby acknowledges receipt and delivery of the goods. <br />
The undersigned will release the payment subject to the goods being discovered not satisfactory. <br />
<br />
Signed under seal this <date>';
        // JFV - add japanese localization to email template
        $body = '署名者は商品の授受を確認するものとします。 <br />
署名者は不十分な箇所が見つかった商品にかかわる支払いは保留するものとします。 <br />
<br />
以下署名<date>' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Goods received acknowledgement','Goods received acknowledgement','Acknowledged Receipt of Goods','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 商品授受の確認 / Goods received acknowledgement','商品授受の確認 / Goods received acknowledgement','商品授受の確認 / Acknowledged Receipt of Goods','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = ' Dear <br />
         We are in receipt of your order as contained in the <br />
   purchase order form.We consider this to be final and binding on both sides. <br />
If there be any exceptions noted, we shall consider them <br />
only if the objection is received within ten days of receipt of <br />
this notice. <br />
 <br />
Thank you for your patronage.';
        // JFV - add japanese localization to email template
        $body = ' 様 <br />
         注文書にてオーダーを受け取りました。 <br />
   これで双方による確定と考えております。 <br />
何らかの例外事項がある場合は、本通知の受け取りより 10 日以内に <br />
申し立てがあった場合にのみ考慮するものとさせて頂きます。 <br />
<br />
平素のご愛顧に心より御礼申し上げます。' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Accept Order','Accept Order','Acknowledgement/Acceptance of Order','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 注文の受け取り / Accept Order','注文の受け取り / Accept Order','注文の確認/受理 / Acknowledgement/Acceptance of Order','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = 'Dear <br />
 <br />
We are relocating our office to <br />
11111,XYZDEF Cross, <br />
UVWWX Circle <br />
The telephone number for this new location is (101) 1212-1328. <br />
<br />
Our Manufacturing Division will continue operations <br />
at 3250 Lovedale Square Avenue, in Frankfurt. <br />
<br />
We hope to keep in touch with you all. <br />
Please update your addressbooks.';
        // JFV - add japanese localization to email template
        $body = ' 様 <br />
 <br />
只今オフィスを以下の場所に移転中です。<br />
11111,XYZDEF Cross, <br />
UVWWX Circle <br />
新拠点の電話番号は、(101) 1212-1328 です。 <br />
<br />
製造部門は引き続き 3250 Lovedale Square Avenue, in Frankfurt<br />
が活動拠点となります。<br />
<br />
今後ともご連絡をお待ちしております。 <br />
アドレス帳の更新もお願い致します。' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Address Change','Change of Address','Address Change','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 住所の変更 / Address Change','住所の変更 / Change of Address','住所変更 / Address Change','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = 'Dear <br />
<br />
Thank you for extending us the opportunity to meet with <br />
you and members of your staff. <br />
<br />
I know that John Doe serviced your account <br />
for many years and made many friends at your firm. He has personally <br />
discussed with me the deep relationship that he had with your firm. <br />
While his presence will be missed, I can promise that we will <br />
continue to provide the fine service that was accorded by <br />
John to your firm. <br />
<br />
I was genuinely touched to receive such fine hospitality. <br />
<br />
Thank you once again.';
        // JFV - add japanese localization to email template
        $body = ' 様 <br />
<br />
スタッフの方々ともども、お会いできる機会を頂き、<br />
誠にありがとうございます。 <br />
<br />
John Doe が長年御社をお世話さえて頂き、 <br />
良好な関係を持つことができました。 <br />
御社との素晴らしい関係については、彼より個人的に聞いております。 <br />
今後彼の不在においても、John による御社へのサービスと同様に <br />
引き続き誠心誠意にお世話させていただくことを <br />
お約束いたします。 <br />
<br />
素晴らしい御もてなしに非常に感銘を受けた次第です。 <br />
<br />
改めてお礼を申し上げます。' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Follow Up','Follow Up','Follow Up of meeting','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) フォローアップ / Follow Up','フォローアップ / Follow Up','会議のフォローアップ / Follow Up of meeting','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = 'Congratulations! <br />
<br />
The numbers are in and I am proud to inform you that our <br />
total sales for the previous quarter <br />
amounts to $100,000,00.00!. This is the first time <br />
we have exceeded the target by almost 30%. <br />
We have also beat the previous quarter record by a <br />
whopping 75%! <br />
<br />
Let us meet at Smoking Joe for a drink in the evening! <br />

C you all there guys!';
        // JFV - add japanese localization to email template
        $body = 'おめでとうございます! <br />
<br />
前四半期の総売上高が、 $100,000,00 に <br />
達したことを喜びとともにお伝えします。 <br />
目標高を初めて 30% 超過することもできました。 <br />
また前四半期の記録を 75% も上回るものでした。<br />
<br />
今夜は Smoking Joe にて飲みましょう! <br />

皆さんの参加をお待ちしています。' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Target Crossed!','Target Crossed!','Fantastic Sales Spree!','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 目標達成 / Target Crossed!','目標達成 / Target Crossed!','素晴らしい売上 / Fantastic Sales Spree!','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        $body = 'Dear <br />
<br />
Thank you for your confidence in our ability to serve you. <br />
We are glad to be given the chance to serve you.I look <br />
forward to establishing a long term partnership with you. <br />
Consider me as a friend. <br />
Should any need arise,please do give us a call.';
        // JFV - add japanese localization to email template
        $body = ' 様 <br />
<br />
我々のサービスの力量を信頼頂いたことを感謝申し上げます。<br />
また、サービスを提供させていただく機会を頂けたことをお礼申し上げます。<br />
長期にわたる関係を築けることを願っております。<br />
友人のようにお付き合い頂ければ幸いです。<br />
何かございましたら、いつでもお電話をお待ちしております。' . "<br /><br />----------<br />" . $body;
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Thanks Note','Thanks Note','Note of thanks','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) お礼状 / Thanks Note','お礼状 / Thanks Note','お礼状 / Note of thanks','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        //Added for HTML Eemail templates..
        //for Customer Portal Login details
        // JFV - add japanese localization to email template
        // $body='<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td width="50"> </td>
        //             <td>
        //             <table width="100%" cellspacing="0" cellpadding="0" border="0">
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
        //                                 <tr>
        //                                     <td align="center" rowspan="4">$logo$</td>
        //                                     <td align="center"> </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM<br /> </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td> </td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
        //                                 <tr>
        //                                     <td valign="top">
        //                                     <table width="100%" cellspacing="0" cellpadding="5" border="0">
        //                                             <tr>
        //                                                 <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contact_name$, </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"> Thank you very much for subscribing to the vtiger CRM - annual support service.<br />Here is your self service portal login details:</td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="center">
        //                                                 <table width="75%" cellspacing="0" cellpadding="10" border="0" style="border: 2px solid rgb(180, 180, 179); background-color: rgb(226, 226, 225); font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal;">
        //                                                         <tr>
        //                                                             <td><br />User ID     : <font color="#990000"><strong> $login_name$</strong></font> </td>
        //                                                         </tr>
        //                                                         <tr>
        //                                                             <td>Password: <font color="#990000"><strong> $password$</strong></font> </td>
        //                                                         </tr>
        //                                                         <tr>
        //                                                             <td align="center"> <strong>  $URL$<br /> </strong> </td>
        //                                                         </tr>
        //                                                 </table>
        //                                                 </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"><strong>NOTE:</strong> We suggest you to change your password after logging in first time. <br /><br /> <strong><u>Help Documentation</u></strong><br />  <br /> After logging in to vtiger Self-service Portal first time, you can access the vtiger CRM documents from the <strong>Documents</strong> tab. Following documents are available for your reference:<br />
        //                                                 <ul>
        //                                                     <li>Installation Manual (Windows &amp; Linux OS)<br /> </li>
        //                                                     <li>User &amp; Administrator Manual<br /> </li>
        //                                                     <li>vtiger Customer Portal - User Manual<br /> </li>
        //                                                     <li>vtiger Outlook Plugin - User Manual<br /> </li>
        //                                                     <li>vtiger Office Plug-in - User Manual<br /> </li>
        //                                                     <li>vtiger Thunderbird Extension - User Manual<br /> </li>
        //                                                     <li>vtiger Web Forms - User Manual<br /> </li>
        //                                                     <li>vtiger Firefox Tool bar - User Manual<br /> </li>
        //                                                 </ul>
        //                                                 <br />  <br /> <strong><u>Knowledge Base</u></strong><br /> <br /> Periodically we update frequently asked question based on our customer experiences. You can access the latest articles from the <strong>FAQ</strong> tab.<br /> <br /> <strong><u>vtiger CRM - Details</u></strong><br /> <br /> Kindly let us know your current vtiger CRM version and system specification so that we can provide you necessary guidelines to enhance your vtiger CRM system performance. Based on your system specification we alert you about the latest security &amp; upgrade patches.<br />  <br />			 Thank you once again and wish you a wonderful experience with vtiger CRM.<br /> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Best Regards</strong></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">$support_team$ </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td> </td>
        //                                             </tr>
        //                                     </table>
        //                                     </td>
        //                                     <td width="1%" valign="top"> </td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
        //                                 <tr>
        //                                     <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:support@vtiger.com">support@vtiger.com</a></td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //             </table>
        //             </td>
        //             <td width="50"> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        // </table>';
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM<br /> </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contact_name$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"> vtiger CRM の通年サポート サービスをお選び頂き誠にありがとうございます。<br />セルフサービスのポータル ログインの詳細は以下の通りです:</td>
                                            </tr>
                                            <tr>
                                                <td align="center">
                                                <table width="75%" cellspacing="0" cellpadding="10" border="0" style="border: 2px solid rgb(180, 180, 179); background-color: rgb(226, 226, 225); font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal;">
                                                        <tr>
                                                            <td><br />ユーザー ID     : <font color="#990000"><strong> $login_name$</strong></font> </td>
                                                        </tr>
                                                        <tr>
                                                            <td>パスワード: <font color="#990000"><strong> $password$</strong></font> </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center"> <strong>  $URL$<br /> </strong> </td>
                                                        </tr>
                                                </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"><strong>NOTE:</strong> 初回ログインの後でパスワードを変更してください。 <br /><br /> <strong><u>ヘルプ ドキュメント</u></strong><br />  <br /> vtiger CRM セルフサービス ポータルにログインすると、<strong>ドキュメント</strong> タブより vtiger CRM ドキュメントにアクセスできます。以下のドキュメントがご利用できます:<br />
                                                <ul>
                                                    <li>Installation Manual (Windows &amp; Linux OS)<br /> </li>
                                                    <li>User &amp; Administrator Manual<br /> </li>
                                                    <li>vtiger Customer Portal - User Manual<br /> </li>
                                                    <li>vtiger Outlook Plugin - User Manual<br /> </li>
                                                    <li>vtiger Office Plug-in - User Manual<br /> </li>
                                                    <li>vtiger Thunderbird Extension - User Manual<br /> </li>
                                                    <li>vtiger Web Forms - User Manual<br /> </li>
                                                    <li>vtiger Firefox Tool bar - User Manual<br /> </li>
                                                </ul>
                                                <br />  <br /> <strong><u>Knowledge Base</u></strong><br /> <br /> お客様の情報に基づき、よくある質問を定期的に更新します。<strong>FAQ</strong> タブから最新の記事にアクセスできます。<br /> <br /> <strong><u>vtiger CRM - 詳細</u></strong><br /> <br /> お使いの vtiger CRM システムのバージョンとシステム仕様をお知らせ頂くことにより、vtiger CRM のパフォーマンスを強化するために必要なガイドラインを提供することができます。システムの仕様に応じて、 最新のセキュリティ &amp; アップデート パッチをお知らせします。<br />  <br />			 重ねてお礼を申し上げるとともに、vtiger CRM での素晴らしい体験をお祈りいたします。<br /> </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />宜しくお願いします</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">$support_team$ </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:support@vtiger.com">support@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Customer Login Details','Customer Portal Login Details','Send Portal login details to customer','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 顧客ログインの詳細','顧客ポータル ログインの詳細','ポータルログインの詳細を顧客に送付する','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        //for Support end notification before a week
        // JFV - add japanese localization to email template
        // $body='<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td width="50"> </td>
        //             <td>
        //             <table width="100%" cellspacing="0" cellpadding="0" border="0">
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
        //                                 <tr>
        //                                     <td align="center" rowspan="4">$logo$</td>
        //                                     <td align="center"> </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td> </td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
        //                                 <tr>
        //                                     <td valign="top">
        //                                     <table width="100%" cellspacing="0" cellpadding="5" border="0">
        //                                             <tr>
        //                                                 <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contacts-lastname$, </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">This is just a notification mail regarding your support end.<br /><span style="font-weight: bold;">Priority:</span> Urgent<br />Your Support is going to expire on next week<br />Please contact support@vtiger.com.<br /><br /><br /></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="center"><br /></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Sincerly</strong></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">Support Team </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td> </td>
        //                                             </tr>
        //                                     </table>
        //                                     </td>
        //                                     <td width="1%" valign="top"> </td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
        //                                 <tr>
        //                                     <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:info@vtiger.com">info@vtiger.com</a></td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //             </table>
        //             </td>
        //             <td width="50"> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        // </table>';
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">$contacts-lastname$ 様 </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">これはサポートの終了をお知らせするメールです。<br /><span style="font-weight: bold;">優先度:</span> 至急<br />サポートは翌週に終了する予定です。<br />連絡先: support@vtiger.com.<br /><br /><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="center"><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />宜しくお願い致します</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">サポート チーム </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:info@vtiger.com">info@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        //               $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Support end notification before a week','VtigerCRM Support Notification','Send Notification mail to customer before a week of support end date','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 一週間前のサポート終了通知','VtigerCRM サポート通知','サポート終了の一週間前に顧客へ通知メールを送信します','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        //for Support end notification before a month
        // JFV - add japanese localization to email template
        // $body='<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td width="50"> </td>
        //             <td>
        //             <table width="100%" cellspacing="0" cellpadding="0" border="0">
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
        //                                 <tr>
        //                                     <td align="center" rowspan="4">$logo$</td>
        //                                     <td align="center"> </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td> </td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
        //                                 <tr>
        //                                     <td valign="top">
        //                                     <table width="100%" cellspacing="0" cellpadding="5" border="0">
        //                                             <tr>
        //                                                 <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td> </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contacts-lastname$, </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">This is just a notification mail regarding your support end.<br /><span style="font-weight: bold;">Priority:</span> Normal<br />Your Support is going to expire on next month.<br />Please contact support@vtiger.com<br /><br /><br /></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="center"><br /></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Sincerly</strong></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">Support Team </td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td align="right"><a href="http://www.vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);">www.vtiger.com</a></td>
        //                                             </tr>
        //                                             <tr>
        //                                                 <td> </td>
        //                                             </tr>
        //                                     </table>
        //                                     </td>
        //                                     <td width="1%" valign="top"> </td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //                     <tr>
        //                         <td>
        //                         <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
        //                                 <tr>
        //                                     <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
        //                                 </tr>
        //                                 <tr>
        //                                     <td align="center">Email Id: <a href="mailto:info@vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);">info@vtiger.com</a></td>
        //                                 </tr>
        //                         </table>
        //                         </td>
        //                     </tr>
        //             </table>
        //             </td>
        //             <td width="50"> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        //         <tr>
        //             <td> </td>
        //             <td> </td>
        //             <td> </td>
        //         </tr>
        // </table>';
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">$contacts-lastname$ 様 </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">これはサポートの終了をお知らせするメールです。<br /><span style="font-weight: bold;">優先度:</span> 通常<br />サポートは翌月に終了する予定です。<br />連絡先: support@vtiger.com<br /><br /><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="center"><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />宜しくお願いします</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">サポート チーム </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a href="http://www.vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a href="mailto:info@vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);">info@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        //           $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Support end notification before a month','VtigerCRM Support Notification','Send Notification mail to customer before a month of support end date','".$body."',0,".$this->db->getUniqueID('vtiger_emailtemplates').")");
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','例) 一ヶ月前のサポート終了通知','VtigerCRM サポート通知','サポート終了の一ヶ月前に顧客へ通知メールを送信します','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        // JFV END
        //Insert into vtiger_organizationdetails vtiger_table
        $organizationId = $this->db->getUniqueID('vtiger_organizationdetails');
        // JFV - localize organization info from vtiger to vtigerCRM.jp
        $this->db->query("insert into vtiger_organizationdetails(organization_id,organizationname,address,city,state,country,code,phone,fax,website,logoname)\n\t\t\t\t\t\t\t\tvalues ({$organizationId},'vtigerCRM.jp','1-1','Chiyoda-ku',\n\t\t\t\t\t\t\t\t\t\t'Tokyo','Japan','100-0001','+81-12-3456-7890','+81-12-3456-7890','www.vtigerCRM.jp','vtigerCRM.jp_logo.png')");
        //	$this->db->query("insert into vtiger_organizationdetails(organization_id,organizationname,address,city,state,country,code,phone,fax,website,logoname)
        //								values ($organizationId,'vtiger',' 40-41-42, Sivasundar Apartments, Flat D-II, Shastri Street, Velachery','Chennai',
        //										'Tamil Nadu','India','600 042','+91-44-5202-1990','+91-44-5202-1990','www.vtiger.com','vtiger-crm-logo.gif')");
        // JFV END
        $this->db->query("insert into vtiger_actionmapping values(0,'Save',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'EditView',0)");
        $this->db->query("insert into vtiger_actionmapping values(2,'Delete',0)");
        $this->db->query("insert into vtiger_actionmapping values(3,'index',0)");
        $this->db->query("insert into vtiger_actionmapping values(4,'DetailView',0)");
        $this->db->query("insert into vtiger_actionmapping values(5,'Import',0)");
        $this->db->query("insert into vtiger_actionmapping values(6,'Export',0)");
        //$this->db->query("insert into vtiger_actionmapping values(7,'AddBusinessCard',0)");
        $this->db->query("insert into vtiger_actionmapping values(8,'Merge',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'VendorEditView',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'VendorDetailView',1)");
        $this->db->query("insert into vtiger_actionmapping values(0,'SaveVendor',1)");
        $this->db->query("insert into vtiger_actionmapping values(2,'DeleteVendor',1)");
        $this->db->query("insert into vtiger_actionmapping values(1,'PriceBookEditView',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'PriceBookDetailView',1)");
        $this->db->query("insert into vtiger_actionmapping values(0,'SavePriceBook',1)");
        $this->db->query("insert into vtiger_actionmapping values(2,'DeletePriceBook',1)");
        $this->db->query("insert into vtiger_actionmapping values(9,'ConvertLead',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'DetailViewAjax',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'TagCloud',1)");
        $this->db->query("insert into vtiger_actionmapping values(1,'QuickCreate',1)");
        $this->db->query("insert into vtiger_actionmapping values(3,'Popup',1)");
        $this->db->query("insert into vtiger_actionmapping values(10,'DuplicatesHandling',0)");
        //Insert values for vtiger_moduleowners vtiger_table which contains the modules and their vtiger_users. default user id admin - after 4.2 patch 2
        $module_array = array('Potentials', 'Contacts', 'Accounts', 'Leads', 'Documents', 'Calendar', 'Emails', 'HelpDesk', 'Products', 'Faq', 'Vendors', 'PriceBooks', 'Quotes', 'PurchaseOrder', 'SalesOrder', 'Invoice', 'Reports', 'Campaigns');
        foreach ($module_array as $mod) {
            $this->db->query("insert into vtiger_moduleowners values(" . getTabid($mod) . ",1)");
        }
        //added by jeri for category view from db
        $this->db->query("insert into vtiger_parenttab values (1,'My Home Page',1,0)");
        $this->db->query("insert into vtiger_parenttab values (2,'Marketing',2,0)");
        $this->db->query("insert into vtiger_parenttab values (3,'Sales',3,0)");
        $this->db->query("insert into vtiger_parenttab values (4,'Support',4,0)");
        $this->db->query("insert into vtiger_parenttab values (5,'Analytics',5,0)");
        $this->db->query("insert into vtiger_parenttab values (6,'Inventory',6,0)");
        $this->db->query("insert into vtiger_parenttab values (7,'Tools',7,0)");
        $this->db->query("insert into vtiger_parenttab values (8,'Settings',8,0)");
        $this->db->query("insert into vtiger_parenttabrel values (1,9,2)");
        $this->db->query("insert into vtiger_parenttabrel values (1,28,4)");
        $this->db->query("insert into vtiger_parenttabrel values (1,3,1)");
        $this->db->query("insert into vtiger_parenttabrel values (3,7,1)");
        $this->db->query("insert into vtiger_parenttabrel values (3,6,2)");
        $this->db->query("insert into vtiger_parenttabrel values (3,4,3)");
        $this->db->query("insert into vtiger_parenttabrel values (3,2,4)");
        $this->db->query("insert into vtiger_parenttabrel values (3,20,5)");
        $this->db->query("insert into vtiger_parenttabrel values (3,22,6)");
        $this->db->query("insert into vtiger_parenttabrel values (3,23,7)");
        $this->db->query("insert into vtiger_parenttabrel values (3,19,8)");
        $this->db->query("insert into vtiger_parenttabrel values (3,8,9)");
        $this->db->query("insert into vtiger_parenttabrel values (4,13,1)");
        $this->db->query("insert into vtiger_parenttabrel values (4,15,2)");
        $this->db->query("insert into vtiger_parenttabrel values (4,6,3)");
        $this->db->query("insert into vtiger_parenttabrel values (4,4,4)");
        $this->db->query("insert into vtiger_parenttabrel values (4,8,5)");
        $this->db->query("insert into vtiger_parenttabrel values (5,1,2)");
        $this->db->query("insert into vtiger_parenttabrel values (5,25,1)");
        $this->db->query("insert into vtiger_parenttabrel values (6,14,1)");
        $this->db->query("insert into vtiger_parenttabrel values (6,18,2)");
        $this->db->query("insert into vtiger_parenttabrel values (6,19,3)");
        $this->db->query("insert into vtiger_parenttabrel values (6,21,4)");
        $this->db->query("insert into vtiger_parenttabrel values (6,22,5)");
        $this->db->query("insert into vtiger_parenttabrel values (6,20,6)");
        $this->db->query("insert into vtiger_parenttabrel values (6,23,7)");
        $this->db->query("insert into vtiger_parenttabrel values (7,24,1)");
        $this->db->query("insert into vtiger_parenttabrel values (7,27,2)");
        $this->db->query("insert into vtiger_parenttabrel values (7,8,3)");
        $this->db->query("insert into vtiger_parenttabrel values (2,26,1)");
        $this->db->query("insert into vtiger_parenttabrel values (2,6,2)");
        $this->db->query("insert into vtiger_parenttabrel values (2,4,3)");
        $this->db->query("insert into vtiger_parenttabrel values (2,28,4)");
        $this->db->query("insert into vtiger_parenttabrel values (4,28,7)");
        $this->db->query("insert into vtiger_parenttabrel values (2,7,5)");
        $this->db->query("insert into vtiger_parenttabrel values (2,9,6)");
        $this->db->query("insert into vtiger_parenttabrel values (4,9,8)");
        $this->db->query("insert into vtiger_parenttabrel values (2,8,8)");
        $this->db->query("insert into vtiger_parenttabrel values (3,9,11)");
        //add settings page to database starts
        $this->addEntriesForSettings();
        //add settings page to database end
        //Added to populate the default inventory tax informations
        $vatid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $salesid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $serviceid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $this->db->query("insert into vtiger_inventorytaxinfo values({$vatid},'tax" . $vatid . "','VAT','4.50','0')");
        $this->db->query("insert into vtiger_inventorytaxinfo values({$salesid},'tax" . $salesid . "','Sales','10.00','0')");
        $this->db->query("insert into vtiger_inventorytaxinfo values({$serviceid},'tax" . $serviceid . "','Service','12.50','0')");
        //After added these taxes we should add these taxes as columns in vtiger_inventoryproductrel table
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$vatid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$salesid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$serviceid} decimal(7,3) default NULL");
        //Added to handle picklist uniqueid for the picklist values
        //$this->db->query("insert into vtiger_picklistvalues_seq values(1)");
        //Added to populate the default Shipping & Hanlding tax informations
        $shvatid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $shsalesid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $shserviceid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shvatid},'shtax" . $shvatid . "','VAT','4.50','0')");
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shsalesid},'shtax" . $shsalesid . "','Sales','10.00','0')");
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shserviceid},'shtax" . $shserviceid . "','Service','12.50','0')");
        //After added these taxes we should add these taxes as columns in vtiger_inventoryshippingrel table
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shvatid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shsalesid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shserviceid} decimal(7,3) default NULL");
        //version file is included here because without including this file version cannot be get
        include 'vtigerversion.php';
        $this->db->query("insert into vtiger_version values(" . $this->db->getUniqueID('vtiger_version') . ",'" . $vtiger_current_version . "','" . $vtiger_current_version . "')");
        //Register default language English
        require_once 'vtlib/Vtiger/Language.php';
        $vtlanguage = new Vtiger_Language();
        // JFV - set Japanese language info into vtiger_language table and set it as default, during default data populator operation. Default user language becomes ja
        //	$vtlanguage->register('en_us','US English','English',true,true,true);
        $vtlanguage->register('en_us', 'US English', 'English', false, true, true);
        $vtlanguage->register('ja', 'Japanese (日本語)', 'Japanese', true, true, true);
        // JFV END
        $this->initWebservices();
        /**
         * Setup module sequence numbering.
         */
        $modseq = array('Leads' => 'LEA', 'Accounts' => 'ACC', 'Campaigns' => 'CAM', 'Contacts' => 'CON', 'Potentials' => 'POT', 'HelpDesk' => 'TT', 'Quotes' => 'QUO', 'SalesOrder' => 'SO', 'PurchaseOrder' => 'PO', 'Invoice' => 'INV', 'Products' => 'PRO', 'Vendors' => 'VEN', 'PriceBooks' => 'PB', 'Faq' => 'FAQ', 'Documents' => 'DOC');
        foreach ($modseq as $modname => $prefix) {
            $this->addInventoryRows(array(array('semodule' => $modname, 'active' => '1', 'prefix' => $prefix, 'startid' => '1', 'curid' => '1')));
        }
        // Adding Sharing Types for Reports
        $this->db->query("insert into vtiger_reportfilters values(1,'Private')");
        $this->db->query("insert into vtiger_reportfilters values(2,'Public')");
        $this->db->query("insert into vtiger_reportfilters values(3,'Shared')");
        require 'modules/Utilities/Currencies.php';
        foreach ($currencies as $key => $value) {
            $this->db->query("insert into vtiger_currencies values(" . $this->db->getUniqueID("vtiger_currencies") . ",'{$key}','" . $value[0] . "','" . $value[1] . "')");
        }
    }
Example #2
0
function installVtlibModule($packagename, $packagepath, $customized = false)
{
    global $log;
    require_once 'vtlib/Vtiger/Package.php';
    require_once 'vtlib/Vtiger/Module.php';
    $Vtiger_Utils_Log = true;
    $package = new Vtiger_Package();
    if ($package->isLanguageType($packagepath)) {
        $package = new Vtiger_Language();
        $package->import($packagepath, true);
        return;
    }
    $module = $package->getModuleNameFromZip($packagepath);
    $module_exists = false;
    $module_dir_exists = false;
    if ($module == null) {
        $log->fatal("{$packagename} Module zipfile is not valid!");
    } else {
        if (Vtiger_Module::getInstance($module)) {
            $log->fatal("{$module} already exists!");
            $module_exists = true;
        }
    }
    if ($module_exists == false) {
        $log->debug("{$module} - Installation starts here");
        $package->import($packagepath, true);
        $moduleInstance = Vtiger_Module::getInstance($module);
        if (empty($moduleInstance)) {
            $log->fatal("{$module} module installation failed!");
        }
    }
}
Example #3
0
$invWorkFlow->test = '[{"fieldname":"subject","operation":"does not contain","value":"`!`"}]';
$invWorkFlow->description = "UpdateInventoryProducts On Every Save";
$vtWorkFlow->save($invWorkFlow);
$tm = new VTTaskManager($adb);
$task = $tm->createTask('VTEntityMethodTask', $invWorkFlow->id);
$task->active = true;
$task->methodName = "UpdateInventory";
$tm->saveTask($task);
/* Support to track if a module is of CrmEntity type or not */
ExecuteQuery("ALTER TABLE vtiger_tab ADD COLUMN isentitytype INT NOT NULL DEFAULT 1");
ExecuteQuery("UPDATE vtiger_tab SET isentitytype=0 WHERE name IN ('Home','Dashboard','Rss','Reports','Portal','Users','Recyclebin')");
/* Support for different languages to be stored in database instead of config file - Vtlib */
ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_language(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), " . "prefix VARCHAR(10), label VARCHAR(30), lastupdated DATETIME, sequence INT, isdefault INT(1), active INT(1)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
/* Register default language English. This will automatically register all the other langauges from config file */
require_once 'vtlib/Vtiger/Language.php';
$vtlanguage = new Vtiger_Language();
$vtlanguage->register('en_us', 'US English', 'English', true, true, true);
/* To store relationship between the modules in a common table */
ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_crmentityrel (crmid int(11) NOT NULL, module varchar(100) NOT NULL, relcrmid int(11) NOT NULL, relmodule varchar(100) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
/* To store the field to module relationship for uitype 10 */
ExecuteQuery("CREATE TABLE IF NOT EXISTS vtiger_fieldmodulerel (fieldid int(11) NOT NULL, module varchar(100) NOT NULL, relmodule varchar(100) NOT NULL,\n  \t\t\t\t\tstatus varchar(10) default NULL, sequence int(11) default NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
/* Making users and groups depends on vtiger_users_seq */
$max_grp_id = $adb->query("SELECT MAX(groupid) as maxid from vtiger_groups");
$maxid = $adb->query_result($max_grp_id, 0, "maxid");
$user_result = $adb->query("select max(id) as userid from vtiger_users");
$inc_num = $adb->query_result($user_result, 0, "userid");
$adb->getUniqueId("vtiger_users");
//Creates vtiger_users_seq table if not exists.
$seq_id = $inc_num + $maxid;
$adb->pquery("UPDATE vtiger_users_seq SET id=?", array($seq_id));
$tab_info = array("vtiger_group2grouprel" => array("fk_2_vtiger_group2grouprel", "(groupid)", "vtiger_groups(groupid)"), "vtiger_users2group" => array("fk_1_vtiger_users2group", "(groupid)", "vtiger_groups(groupid)"), "vtiger_group2role" => array("fk_1_vtiger_group2role", "(groupid)", "vtiger_groups(groupid)"), "vtiger_group2rs" => array("fk_1_vtiger_group2rs", "(groupid)", "vtiger_groups(groupid)"), "vtiger_datashare_grp2grp" => array("fk_2_vtiger_datashare_grp2grp", "(share_groupid)", "vtiger_groups(groupid)"), "vtiger_datashare_grp2grp" => array("fk_3_vtiger_datashare_grp2grp", "(to_groupid)", "vtiger_groups(groupid)"), "vtiger_datashare_grp2role" => array("fk_2_vtiger_datashare_grp2role", "(share_groupid)", "vtiger_groups(groupid)"), "vtiger_datashare_role2group" => array("fk_2_vtiger_datashare_role2group", "(to_groupid)", "vtiger_groups(groupid)"), "vtiger_datashare_grp2rs" => array("fk_2_vtiger_datashare_grp2rs", "(share_groupid)", "vtiger_groups(groupid)"), "vtiger_datashare_rs2grp" => array("fk_2_vtiger_datashare_rs2grp", "(to_groupid)", "vtiger_groups(groupid)"), "vtiger_tmp_read_group_sharing_per" => array("fk_1_vtiger_tmp_read_group_sharing_per", "(sharedgroupid)", "vtiger_groups(groupid)"), "vtiger_tmp_write_group_sharing_per" => array("fk_1_vtiger_tmp_write_group_sharing_per", "(sharedgroupid)", "vtiger_groups(groupid)"));
    /** Function to populate the default required data during installation  
     */
    function create_tables()
    {
        global $app_strings;
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (3,'Home',0,1,'Home',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (7,'Leads',0,4,'Leads',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (6,'Accounts',0,5,'Accounts',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (4,'Contacts',0,6,'Contacts',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (2,'Potentials',0,7,'Potentials',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (8,'Documents',0,9,'Documents',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (9,'Calendar',0,3,'Calendar',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (10,'Emails',0,10,'Emails',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (13,'HelpDesk',0,11,'HelpDesk',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (14,'Products',0,8,'Products',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (1,'Dashboard',0,12,'Dashboards',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (15,'Faq',0,14,'Faq',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (16,'Events',2,13,'Events',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (18,'Vendors',0,15,'Vendors',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (19,'PriceBooks',0,16,'PriceBooks',0,1,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (20,'Quotes',0,17,'Quotes',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (21,'PurchaseOrder',0,18,'PurchaseOrder',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (22,'SalesOrder',0,19,'SalesOrder',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (23,'Invoice',0,20,'Invoice',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (24,'Rss',0,21,'Rss',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (25,'Reports',0,22,'Reports',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (26,'Campaigns',0,23,'Campaigns',0,0,1)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (27,'Portal',0,24,'Portal',0,1,0)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) VALUES (28,'Webmails',0,25,'Webmails',0,1,1)");
        $this->db->query("insert into vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype) values (29,'Users',0,26,'Users',0,1,0)");
        // Populate the vtiger_blocks vtiger_table
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_DESCRIPTION_INFORMATION',5,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0,1,0)");
        $fileblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $fileblockid . ",8,'LBL_FILE_INFORMATION',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'LBL_TASK_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',4,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_COMMENTS',6,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0,1,0)");
        //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',2,1,0,0,0,0,1,0)");
        //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'',3,1,0,0,0,0,1,0)");
        $vendorbasicinfo = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendorbasicinfo . ",18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $vendoraddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendoraddressblock . ",18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $vendordescriptionblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendordescriptionblock . ",18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $pricebookbasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pricebookbasicblock . ",19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $pricebookdescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pricebookdescription . ",19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)");
        $quotesbasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotesbasicblock . ",20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $quotesaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotesaddressblock . ",20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $quotetermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotetermsblock . ",20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $quotedescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotedescription . ",20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $pobasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pobasicblock . ",21,'LBL_PO_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $poaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $poaddressblock . ",21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $potermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $potermsblock . ",21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $podescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $podescription . ",21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $sobasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sobasicblock . ",22,'LBL_SO_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",22,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $soaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $soaddressblock . ",22,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",22,'LBL_RELATED_PRODUCTS',5,0,0,0,0,0,1,0)");
        $sotermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sotermsblock . ",22,'LBL_TERMS_INFORMATION',6,0,0,0,0,0,1,0)");
        $sodescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sodescription . ",22,'LBL_DESCRIPTION_INFORMATION',7,0,0,0,0,0,1,0)");
        $invoicebasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicebasicblock . ",23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $invoiceaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoiceaddressblock . ",23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $invoicetermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicetermsblock . ",23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $invoicedescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicedescription . ",23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $imageblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $imageblockid . ",4,'LBL_IMAGE_INFORMATION',6,0,0,0,0,0,1,0)");
        $campaignbasicblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaignbasicblockid . ",26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0,1,0)");
        $campaigncustomblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaigncustomblock . ",26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $campaignexpectedandactualsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaignexpectedandactualsblock . ",26,'LBL_EXPECTATIONS_AND_ACTUALS',3,0,0,0,0,0,1,0)");
        $userloginandroleblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $userloginandroleblockid . ",29,'LBL_USERLOGIN_ROLE',1,0,0,0,0,0,1,0)");
        $usermoreinfoblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $usermoreinfoblock . ",29,'LBL_MORE_INFORMATION',2,0,0,0,0,0,1,0)");
        $useraddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $useraddressblock . ",29,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        //Added an extra block for new UI Settings in Campaigns module
        $campaidndescriptionblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaidndescriptionblock . ",26,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $userblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $userblockid . ",29,'LBL_USER_IMAGE_INFORMATION',4,0,0,0,0,0,1,0)");
        //Added a New Block User Image Info in Users Module
        $useradvanceblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $useradvanceblock . ",29,'LBL_USER_ADV_OPTIONS',5,0,0,0,0,0,1,0)");
        //Added a New Block User Image Info in Users Module
        //Added block 'File Information' to Documents module
        $desc_blockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $desc_blockid . ",8,'LBL_DESCRIPTION',2,0,0,0,0,0,1,0)");
        //Added block for storing the Recurring Inovice Informaiton in SalesOrder
        $sorecurringinvoiceblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sorecurringinvoiceblock . ",22,'Recurring Invoice Information',2,0,0,0,0,0,1,0)");
        //Added to support custom fields for Calendar
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)");
        //Account Details -- START
        //Block9
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'accountname','vtiger_account',1,'2','accountname','Account Name',1,0,0,100,1,9,1,'V~M',0,1,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'account_no','vtiger_account',1,'4','account_no','Account No',1,0,0,100,2,9,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_account',1,'11','phone','Phone',1,2,0,100,4,9,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_account',1,'17','website','Website',1,2,0,100,3,9,1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_account',1,'1','fax','Fax',1,2,0,100,6,9,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'tickersymbol','vtiger_account',1,'1','tickersymbol','Ticker Symbol',1,2,0,100,5,9,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'otherphone','vtiger_account',1,'11','otherphone','Other Phone',1,2,0,100,8,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'parentid','vtiger_account',1,'51','account_id','Member Of',1,2,0,100,7,9,1,'I~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'email1','vtiger_account',1,'13','email1','Email',1,2,0,100,10,9,1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'employees','vtiger_account',1,'7','employees','Employees',1,2,0,100,9,9,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'email2','vtiger_account',1,'13','email2','Other Email',1,2,0,100,11,9,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ownership','vtiger_account',1,'1','ownership','Ownership',1,2,0,100,12,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'rating','vtiger_account',1,'15','rating','Rating',1,2,0,100,14,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'industry','vtiger_account',1,'15','industry','industry',1,2,0,100,13,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'siccode','vtiger_account',1,'1','siccode','SIC Code',1,2,0,100,16,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'account_type','vtiger_account',1,'15','accounttype','Type',1,2,0,100,15,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'annualrevenue','vtiger_account',1,'71','annual_revenue','Annual Revenue',1,2,0,100,18,9,1,'I~O',1,null,'ADV',1)");
        //Added vtiger_field emailoptout for vtiger_accounts -- after 4.2 patch2
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'emailoptout','vtiger_account',1,'56','emailoptout','Email Opt Out',1,2,0,100,17,9,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'notify_owner','vtiger_account',1,56,'notify_owner','Notify Owner',1,2,0,10,20,9,1,'C~O',1,NULL,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,19,9,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,22,9,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,21,9,2,'T~O',3,null,'BAS',0)");
        //Block 11
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_accountbillads',1,'21','bill_street','Billing Address',1,2,0,100,1,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_accountshipads',1,'21','ship_street','Shipping Address',1,2,0,100,2,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_accountbillads',1,'1','bill_city','Billing City',1,2,0,100,5,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_accountshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_accountbillads',1,'1','bill_state','Billing State',1,2,0,100,7,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_accountshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_accountbillads',1,'1','bill_code','Billing Code',1,2,0,100,9,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_accountshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_accountbillads',1,'1','bill_country','Billing Country',1,2,0,100,11,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_accountshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_accountbillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_accountshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,11,1,'V~O',1,null,'BAS',1)");
        //Block12
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,12,1,'V~O',1,null,'BAS',1)");
        //Account Details -- END
        //Lead Details --- START
        //Block13 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'salutation','vtiger_leaddetails',1,'55','salutationtype','Salutation',1,0,0,100,1,13,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'firstname','vtiger_leaddetails',1,'55','firstname','First Name',1,2,0,100,2,13,1,'V~O',2,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lead_no','vtiger_leaddetails',1,'4','lead_no','Lead No',1,0,0,100,3,13,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_leadaddress',1,'11','phone','Phone',1,2,0,100,5,13,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lastname','vtiger_leaddetails',1,'255','lastname','Last Name',1,0,0,100,4,13,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'mobile','vtiger_leadaddress',1,'1','mobile','Mobile',1,2,0,100,7,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'company','vtiger_leaddetails',1,'2','company','Company',1,2,0,100,6,13,1,'V~M',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_leadaddress',1,'1','fax','Fax',1,2,0,100,9,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'designation','vtiger_leaddetails',1,'1','designation','Designation',1,2,0,100,8,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_leaddetails',1,'13','email','Email',1,2,0,100,11,13,1,'E~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_leaddetails',1,'15','leadsource','Lead Source',1,2,0,100,10,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_leadsubdetails',1,'17','website','Website',1,2,0,100,13,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'industry','vtiger_leaddetails',1,'15','industry','Industry',1,2,0,100,12,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'leadstatus','vtiger_leaddetails',1,'15','leadstatus','Lead Status',1,2,0,100,15,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'annualrevenue','vtiger_leaddetails',1,'71','annualrevenue','Annual Revenue',1,2,0,100,14,13,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'rating','vtiger_leaddetails',1,'15','rating','Rating',1,2,0,100,17,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'noofemployees','vtiger_leaddetails',1,'1','noofemployees','No Of Employees',1,2,0,100,16,13,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,19,13,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'yahooid','vtiger_leaddetails',1,'13','yahooid','Yahoo Id',1,2,0,100,18,13,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,21,13,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,20,13,2,'T~O',3,null,'BAS',0)");
        //Block13 -- End
        //Block15 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lane','vtiger_leadaddress',1,'21','lane','Street',1,2,0,100,1,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'code','vtiger_leadaddress',1,'1','code','Postal Code',1,2,0,100,3,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'city','vtiger_leadaddress',1,'1','city','City',1,2,0,100,4,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'country','vtiger_leadaddress',1,'1','country','Country',1,2,0,100,5,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'state','vtiger_leadaddress',1,'1','state','State',1,2,0,100,6,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'pobox','vtiger_leadaddress',1,'1','pobox','Po Box',1,2,0,100,2,15,1,'V~O',1,null,'BAS',1)");
        //Block15 --End
        //Block16 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,16,1,'V~O',1,null,'BAS',1)");
        //Block16 -- End
        //Lead Details -- END
        //Contact Details -- START
        //Block4 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'salutation','vtiger_contactdetails',1,'55','salutationtype','Salutation',1,0,0,100,1,4,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'firstname','vtiger_contactdetails',1,'55','firstname','First Name',1,2,0,100,2,4,1,'V~O',2,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'contact_no','vtiger_contactdetails',1,'4','contact_no','Contact Id',1,0,0,100,3,4,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_contactdetails',1,'11','phone','Office Phone',1,2,0,100,5,4,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'lastname','vtiger_contactdetails',1,'255','lastname','Last Name',1,0,0,100,4,4,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mobile','vtiger_contactdetails',1,'1','mobile','Mobile',1,2,0,100,7,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_contactdetails',1,'51','account_id','Account Name',1,0,0,100,6,4,1,'I~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'homephone','vtiger_contactsubdetails',1,'11','homephone','Home Phone',1,2,0,100,9,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_contactsubdetails',1,'15','leadsource','Lead Source',1,2,0,100,8,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherphone','vtiger_contactsubdetails',1,'11','otherphone','Other Phone',1,2,0,100,11,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_contactdetails',1,'1','title','Title',1,2,0,100,10,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_contactdetails',1,'1','fax','Fax',1,2,0,100,13,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'department','vtiger_contactdetails',1,'1','department','Department',1,2,0,100,12,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'birthday','vtiger_contactsubdetails',1,'5','birthday','Birthdate',1,2,0,100,16,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_contactdetails',1,'13','email','Email',1,2,0,100,15,4,1,'E~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'reportsto','vtiger_contactdetails',1,'57','contact_id','Reports To',1,2,0,100,18,4,1,'V~O',1,null,'ADV',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'assistant','vtiger_contactsubdetails',1,'1','assistant','Assistant',1,2,0,100,17,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'yahooid','vtiger_contactdetails',1,'13','yahooid','Yahoo Id',1,2,0,100,20,4,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'assistantphone','vtiger_contactsubdetails',1,'11','assistantphone','Assistant Phone',1,2,0,100,19,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'donotcall','vtiger_contactdetails',1,'56','donotcall','Do Not Call',1,2,0,100,22,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'emailoptout','vtiger_contactdetails',1,'56','emailoptout','Email Opt Out',1,2,0,100,21,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,24,4,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'reference','vtiger_contactdetails',1,'56','reference','Reference',1,2,0,10,23,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'notify_owner','vtiger_contactdetails',1,'56','notify_owner','Notify Owner',1,2,0,10,26,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,25,4,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,27,4,2,'T~O',3,null,'BAS',0)");
        //Block4 -- End
        //Block6 - Begin Customer Portal
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'portal','vtiger_customerdetails',1,'56','portal','Portal User',1,2,0,100,1,6,1,'C~O',1,null,'ADV',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'support_start_date','vtiger_customerdetails',1,'5','support_start_date','Support Start Date',1,2,0,100,2,6,1,'D~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'support_end_date','vtiger_customerdetails',1,'5','support_end_date','Support End Date',1,2,0,100,3,6,1,'D~O~OTH~GE~support_start_date~Support Start Date',1,null,'ADV',1)");
        //Block6 - End Customer Portal
        //Block 7 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingstreet','vtiger_contactaddress',1,'21','mailingstreet','Mailing Street',1,2,0,100,1,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherstreet','vtiger_contactaddress',1,'21','otherstreet','Other Street',1,2,0,100,2,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingcity','vtiger_contactaddress',1,'1','mailingcity','Mailing City',1,2,0,100,5,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'othercity','vtiger_contactaddress',1,'1','othercity','Other City',1,2,0,100,6,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingstate','vtiger_contactaddress',1,'1','mailingstate','Mailing State',1,2,0,100,7,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherstate','vtiger_contactaddress',1,'1','otherstate','Other State',1,2,0,100,8,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingzip','vtiger_contactaddress',1,'1','mailingzip','Mailing Zip',1,2,0,100,9,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherzip','vtiger_contactaddress',1,'1','otherzip','Other Zip',1,2,0,100,10,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingcountry','vtiger_contactaddress',1,'1','mailingcountry','Mailing Country',1,2,0,100,11,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'othercountry','vtiger_contactaddress',1,'1','othercountry','Other Country',1,2,0,100,12,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingpobox','vtiger_contactaddress',1,'1','mailingpobox','Mailing Po Box',1,2,0,100,3,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherpobox','vtiger_contactaddress',1,'1','otherpobox','Other Po Box',1,2,0,100,4,7,1,'V~O',1,null,'BAS',1)");
        //Block7 -- End
        //ContactImageInformation
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_contactdetails',1,'69','imagename','Contact Image',1,2,0,100,1,{$imageblockid},1,'V~O',3,null,'ADV',0)");
        //Block8 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,8,1,'V~O',1,null,'BAS',1)");
        //Block8 -- End
        //Contact Details -- END
        //Potential Details -- START
        //Block1 -- Start
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potentialname','vtiger_potential',1,'2','potentialname','Potential Name',1,0,0,100,1,1,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potential_no','vtiger_potential',1,'4','potential_no','Potential No',1,0,0,100,2,1,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'amount','vtiger_potential',1,71,'amount','Amount',1,2,0,100,4,1,1,'N~O',2,5,'BAS',1)");
        //changed for b2c model
        $fieldid = $this->db->getUniqueID("vtiger_field");
        $this->db->query("insert into vtiger_field values (2,{$fieldid},'related_to','vtiger_potential',1,'10','related_to','Related To',1,0,0,100,3,1,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_fieldmodulerel (fieldid, module, relmodule, status, sequence) values ({$fieldid}, 'Potentials', 'Accounts', NULL, 0), ({$fieldid}, 'Potentials', 'Contacts', NULL, 1)");
        //b2c model changes end
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'closingdate','vtiger_potential',1,'23','closingdate','Expected Close Date',1,2,0,100,7,1,1,'D~M',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potentialtype','vtiger_potential',1,'15','opportunity_type','Type',1,2,0,100,6,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'nextstep','vtiger_potential',1,'1','nextstep','Next Step',1,2,0,100,9,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_potential',1,'15','leadsource','Lead Source',1,2,0,100,8,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'sales_stage','vtiger_potential',1,'15','sales_stage','Sales Stage',1,2,0,100,11,1,1,'V~M',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,2,0,100,10,1,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'probability','vtiger_potential',1,'9','probability','Probability',1,2,0,100,13,1,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'campaignid','vtiger_potential',1,'58','campaignid','Campaign Source',1,2,0,100,12,1,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,15,1,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,14,1,2,'T~O',3,null,'BAS',0)");
        //Block1 -- End
        //Block3 -- Start
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,3,1,'V~O',1,null,'BAS',1)");
        //Block3 -- End
        //Potential Details -- END
        //campaign entries being added
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaignname','vtiger_campaign',1,'2','campaignname','Campaign Name',1,0,0,100,1,{$campaignbasicblockid},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaign_no','vtiger_campaign',1,'4','campaign_no','Campaign No',1,0,0,100,2,{$campaignbasicblockid},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaigntype','vtiger_campaign',1,15,'campaigntype','Campaign Type',1,2,0,100,5,{$campaignbasicblockid},1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_campaign',1,59,'product_id','Product',1,2,0,100,6,{$campaignbasicblockid},1,'I~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaignstatus','vtiger_campaign',1,15,'campaignstatus','Campaign Status',1,2,0,100,4,{$campaignbasicblockid},1,'V~O',2,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'closingdate','vtiger_campaign',1,'23','closingdate','Expected Close Date',1,2,0,100,8,{$campaignbasicblockid},1,'D~M',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,3,{$campaignbasicblockid},1,'V~M',0,7,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'numsent','vtiger_campaign',1,'9','numsent','Num Sent',1,2,0,100,12,{$campaignbasicblockid},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'sponsor','vtiger_campaign',1,'1','sponsor','Sponsor',1,2,0,100,9,{$campaignbasicblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'targetaudience','vtiger_campaign',1,'1','targetaudience','Target Audience',1,2,0,100,7,{$campaignbasicblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'targetsize','vtiger_campaign',1,'1','targetsize','TargetSize',1,2,0,100,10,{$campaignbasicblockid},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,11,{$campaignbasicblockid},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,13,{$campaignbasicblockid},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'expectedresponse','vtiger_campaign',1,'15','expectedresponse','Expected Response',1,2,0,100,3,{$campaignexpectedandactualsblock},1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'expectedrevenue','vtiger_campaign',1,'1','expectedrevenue','Expected Revenue',1,2,0,100,4,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'budgetcost','vtiger_campaign',1,'1','budgetcost','Budget Cost',1,2,0,100,1,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'actualcost','vtiger_campaign',1,'1','actualcost','Actual Cost',1,2,0,100,2,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedresponsecount','vtiger_campaign',1,'1','expectedresponsecount','Expected Response Count',1,2,0,100,7,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedsalescount','vtiger_campaign',1,'1','expectedsalescount','Expected Sales Count',1,2,0,100,5,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedroi','vtiger_campaign',1,'1','expectedroi','Expected ROI',1,2,0,100,9,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualresponsecount','vtiger_campaign',1,'1','actualresponsecount','Actual Response Count',1,2,0,100,8,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualsalescount','vtiger_campaign',1,'1','actualsalescount','Actual Sales Count',1,2,0,100,6,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualroi','vtiger_campaign',1,'1','actualroi','Actual ROI',1,2,0,100,10,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$campaidndescriptionblock},1,'V~O',1,null,'BAS',1)");
        //Campaign entries end
        //Ticket Details -- START
        //Block25 -- Start
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'ticket_no','vtiger_troubletickets',1,'4','ticket_no','Ticket No',1,0,0,100,13,25,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,4,25,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'parent_id','vtiger_troubletickets',1,'68','parent_id','Related To',1,0,0,100,2,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_troubletickets',1,'15','ticketpriorities','Priority',1,2,0,100,6,25,1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_troubletickets',1,'59','product_id','Product Name',1,2,0,100,5,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'severity','vtiger_troubletickets',1,'15','ticketseverities','Severity',1,2,0,100,8,25,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_troubletickets',1,'15','ticketstatus','Status',1,2,0,100,7,25,1,'V~M',1,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_troubletickets',1,'15','ticketcategories','Category',1,2,0,100,10,25,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'update_log','vtiger_troubletickets',1,'19','update_log','Update History',1,0,0,100,11,25,3,'V~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'hours','vtiger_troubletickets',1,'1','hours','Hours',1,2,0,100,9,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'days','vtiger_troubletickets',1,'1','days','Days',1,2,0,100,10,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,9,25,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,12,25,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_troubletickets',1,'22','ticket_title','Title',1,0,0,100,1,25,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,28,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'solution','vtiger_troubletickets',1,'19','solution','Solution',1,0,0,100,1,29,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'comments','vtiger_ticketcomments',1,'19','comments','Add Comment',1,0,0,100,1,30,1,'V~O',3,null,'BAS',0)");
        //Block25-30 -- End
        //Ticket Details -- END
        //Product Details -- START
        //Block31-36 -- Start
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productname','vtiger_products',1,'2','productname','Product Name',1,0,0,100,1,31,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'product_no','vtiger_products',1,'4','product_no','Product No',1,0,0,100,2,31,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productcode','vtiger_products',1,'1','productcode','Part Number',1,2,0,100,4,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'discontinued','vtiger_products',1,'56','discontinued','Product Active',1,2,0,100,3,31,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'manufacturer','vtiger_products',1,'15','manufacturer','Manufacturer',1,2,0,100,6,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,2,0,100,6,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,2,0,100,5,31,1,'D~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,2,0,100,8,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,2,0,100,7,31,1,'D~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,2,0,100,10,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_products',1,'17','website','Website',1,2,0,100,14,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,2,0,100,13,31,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,2,0,100,16,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,2,0,100,15,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,2,0,100,18,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,2,0,100,17,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'glacct','vtiger_products',1,'15','glacct','GL Account',1,2,0,100,20,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,19,31,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,21,31,2,'T~O',3,null,'BAS',0)");
        //Block32 Pricing Information
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'unit_price','vtiger_products',1,'71','unit_price','Unit Price',1,2,0,100,1,32,1,'N~O',2,3,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'commissionrate','vtiger_products',1,'9','commissionrate','Commission Rate',1,2,0,100,2,32,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'taxclass','vtiger_products',1,'83','taxclass','Tax Class',1,2,0,100,4,32,1,'V~O',3,null,'BAS',1)");
        //Block 33 stock info
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'usageunit','vtiger_products',1,'15','usageunit','Usage Unit',1,2,0,100,1,33,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qty_per_unit','vtiger_products',1,'1','qty_per_unit','Qty/Unit',1,2,0,100,2,33,1,'N~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qtyinstock','vtiger_products',1,'1','qtyinstock','Qty In Stock',1,2,0,100,3,33,1,'NN~O',0,4,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'reorderlevel','vtiger_products',1,'1','reorderlevel','Reorder Level',1,2,0,100,4,33,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'handler','vtiger_products',1,'52','assigned_user_id','Handler',1,0,0,100,5,33,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qtyindemand','vtiger_products',1,'1','qtyindemand','Qty In Demand',1,2,0,100,6,33,1,'I~O',1,null,'ADV',1)");
        //ProductImageInformation
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_products',1,'69','imagename','Product Image',1,2,0,100,1,35,1,'V~O',3,null,'ADV',1)");
        //Block 36 Description Info
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,36,1,'V~O',1,null,'BAS',1)");
        //Product Details -- END
        //Documents Details -- START
        //Block17 -- Start
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_notes',1,'2','notes_title','Title',1,0,0,100,1,17,1,'V~M',0,1,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,5,17,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,6,17,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'filename','vtiger_notes',1,'28','filename','File Name',1,2,0,100,3," . $fileblockid . ",1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,4,17,1,'V~M',0,3,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'notecontent','vtiger_notes',1,'19','notecontent','Note',1,2,0,100,1,{$desc_blockid},1,'V~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filetype','vtiger_notes',1,1,'filetype','File Type',1,2,0,100,5," . $fileblockid . ",2,'V~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filesize','vtiger_notes',1,1,'filesize','File Size',1,2,0,100,4," . $fileblockid . ",2,'V~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filelocationtype','vtiger_notes',1,27,'filelocationtype','Download Type',1,0,0,100,1," . $fileblockid . ",1,'V~O',1,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'fileversion','vtiger_notes',1,1,'fileversion','Version',1,2,0,100,6,{$fileblockid},1,'V~O',1,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filestatus','vtiger_notes',1,56,'filestatus','Active',1,2,0,100,2," . $fileblockid . ",1,'V~O',1,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filedownloadcount','vtiger_notes',1,1,'filedownloadcount','Download Count',1,2,0,100,7," . $fileblockid . ",2,'I~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'folderid','vtiger_notes',1,26,'folderid','Folder Name',1,2,0,100,2,17,1,'V~O',2,2,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'note_no','vtiger_notes',1,'4','note_no','Document No',1,0,0,100,3,17,1,'V~0',3,null,'BAS',0)");
        //Block17 -- End
        //Documents Details -- END
        //Email Details -- START
        //Block21 -- Start
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Date & Time Sent',1,0,0,100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'semodule','vtiger_activity',1,'2','parent_type','Sales Enity Module',1,0,0,100,2,21,3,'',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'2','activitytype','Activtiy Type',1,0,0,100,3,21,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'357','parent_id','Related To',1,0,0,100,1,22,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,5,21,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,23,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'name','vtiger_attachments',1,'61','filename','Attachment',1,0,0,100,2,23,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,24,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,9,23,1,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,10,22,1,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,11,21,2,'T~O',3,null,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field VALUES (10," . $this->db->getUniqueID("vtiger_field") . ", 'access_count', 'vtiger_email_track', '1', '25', 'access_count', 'Access Count', '1', '0', '0', '100', '6', '21', '3', 'V~O', '1', NULL, 'BAS', 0)");
        //Block21 -- End
        //Email Details -- END
        //Task Details --START
        //Block19 -- Start
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,19,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,19,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,19,1,'DT~M~time_start',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,4,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,0,100,4,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'due_date','vtiger_activity',1,'23','due_date','Due Date',1,0,0,100,5,19,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,0,100,7,19,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,8,19,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_activity',1,'15','taskstatus','Status',1,0,0,100,8,19,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,0,100,9,19,3,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_activity',1,'15','taskpriority','Priority',1,0,0,100,10,19,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,0,100,11,19,1,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,14,19,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,15,19,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,0,100,16,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,0,100,17,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,20,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,0,100,17,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,0,100,18,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'location','vtiger_activity',1,'1','location','Location',1,0,0,100,19,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,19,3,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,0,100,6,19,3,'O~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'notime','vtiger_activity',1,56,'notime','No Time',1,0,0,100,20,19,3,'C~O',1,null,'BAS',1)");
        //Block19 -- End
        //Task Details -- END
        //Event Details --START
        //Block41-43-- Start
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,0,100,1,41,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,2,41,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,0,100,3,41,1,'DT~M~time_start',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,0,100,4,41,3,'T~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'due_date','vtiger_activity',1,'23','due_date','End Date',1,0,0,100,5,41,1,'D~M~OTH~GE~date_start~Start Date & Time',0,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,0,100,5,41,3,'T~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,0,100,6,41,1,'O~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,0,100,7,41,1,'I~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,0,100,8,41,3,'O~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,0,100,9,41,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,0,100,10,41,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,0,100,11,41,1,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,0,100,12,41,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'location','vtiger_activity',1,'1','location','Location',1,0,0,100,13,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,14,41,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,15,41,2,'T~O',3,null,'BAS',0)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_activity',1,15,'taskpriority','Priority',1,0,0,100,16,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'notime','vtiger_activity',1,56,'notime','No Time',1,0,0,100,17,41,1,'C~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,0,100,18,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,0,100,1,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,0,100,1,40,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,0,100,1,19,1,'I~O',1,null,'BAS',1)");
        //Block41-43 -- End
        //Event Details -- END
        //Faq Details -- START
        //Block37-40 -- Start
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_faq',1,'59','product_id','Product Name',1,2,0,100,1,37,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'faq_no','vtiger_faq',1,'4','faq_no','Faq No',1,0,0,100,2,37,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_faq',1,'15','faqcategories','Category',1,2,0,100,4,37,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_faq',1,'15','faqstatus','Status',1,2,0,100,3,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'question','vtiger_faq',1,'20','question','Question',1,2,0,100,7,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'answer','vtiger_faq',1,'20','faq_answer','Answer',1,2,0,100,8,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'comments','vtiger_faqcomments',1,'19','comments','Add Comment',1,0,0,100,1,38,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,5,37,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,6,37,2,'T~O',3,null,'BAS',0)");
        //Block37-40 -- End
        //Ticket Details -- END
        //Vendor Details --START
        //Block44-47
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'vendorname','vtiger_vendor',1,'2','vendorname','Vendor Name',1,0,0,100,1,{$vendorbasicinfo},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'vendor_no','vtiger_vendor',1,'4','vendor_no','Vendor No',1,0,0,100,2,{$vendorbasicinfo},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_vendor',1,'1','phone','Phone',1,2,0,100,4,{$vendorbasicinfo},1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_vendor',1,'13','email','Email',1,2,0,100,3,{$vendorbasicinfo},1,'E~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_vendor',1,'17','website','Website',1,2,0,100,6,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'glacct','vtiger_vendor',1,'15','glacct','GL Account',1,2,0,100,5,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_vendor',1,'1','category','Category',1,2,0,100,8,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,7,{$vendorbasicinfo},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,9,{$vendorbasicinfo},2,'T~O',3,null,'BAS',0)");
        //Block 46
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'street','vtiger_vendor',1,'21','street','Street',1,2,0,100,1,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'pobox','vtiger_vendor',1,'1','pobox','Po Box',1,2,0,100,2,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'city','vtiger_vendor',1,'1','city','City',1,2,0,100,3,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'state','vtiger_vendor',1,'1','state','State',1,2,0,100,4,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'postalcode','vtiger_vendor',1,'1','postalcode','Postal Code',1,2,0,100,5,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'country','vtiger_vendor',1,'1','country','Country',1,2,0,100,6,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //Block 47
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$vendordescriptionblock},1,'V~O',1,null,'ADV',1)");
        //Vendor Details -- END
        //PriceBook Details Start
        //Block48
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'bookname','vtiger_pricebook',1,'2','bookname','Price Book Name',1,0,0,100,1,{$pricebookbasicblock},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'pricebook_no','vtiger_pricebook',1,'4','pricebook_no','PriceBook No',1,0,0,100,3,{$pricebookbasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'active','vtiger_pricebook',1,'56','active','Active',1,2,0,100,2,{$pricebookbasicblock},1,'C~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,4,{$pricebookbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,5,{$pricebookbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_pricebook',1,'117','currency_id','Currency',1,0,0,100,5,{$pricebookbasicblock},1,'I~M',0,3,'BAS',0)");
        //Block50
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$pricebookdescription},1,'V~O',1,null,'BAS',1)");
        //PriceBook Details End
        //Quote Details -- START
        //Block51
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'quote_no','vtiger_quotes',1,'4','quote_no','Quote No',1,0,0,100,3,{$quotesbasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_quotes',1,'2','subject','Subject',1,0,0,100,1,{$quotesbasicblock},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'potentialid','vtiger_quotes',1,'76','potential_id','Potential Name',1,2,0,100,2,{$quotesbasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'quotestage','vtiger_quotes',1,'15','quotestage','Quote Stage',1,2,0,100,4,{$quotesbasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'validtill','vtiger_quotes',1,'5','validtill','Valid Till',1,2,0,100,5,{$quotesbasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_quotes',1,'57','contact_id','Contact Name',1,2,0,100,6,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_quotes',1,'15','carrier','Carrier',1,2,0,100,8,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_quotes',1,'1','hdnSubTotal','Sub Total',1,2,0,100,9,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'shipping','vtiger_quotes',1,'1','shipping','Shipping',1,2,0,100,10,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'inventorymanager','vtiger_quotes',1,'77','assigned_user_id1','Inventory Manager',1,2,0,100,11,{$quotesbasicblock},1,'I~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'tax','vtiger_quotes',1,'1','txtTax','Sales Tax',1,0,0,100,13,51,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_quotes',1,'1','txtAdjustment','Adjustment',1,2,0,100,20,{$quotesbasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_quotes',1,'1','hdnGrandTotal','Total',1,2,0,100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_quotes',1,'16','hdnTaxType','Tax Type',1,2,0,100,14,{$quotesbasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_quotes',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_quotes',1,'1','hdnDiscountAmount','Discount Amount',1,2,0,100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_quotes',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_quotes',1,'73','account_id','Account Name',1,2,0,100,16,{$quotesbasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,{$quotesbasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,{$quotesbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,{$quotesbasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_quotes',1,'117','currency_id','Currency',1,2,1,100,20,{$quotesbasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_quotes',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 53
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_quotesbillads',1,'24','bill_street','Billing Address',1,2,0,100,1,{$quotesaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_quotesshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,{$quotesaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_quotesbillads',1,'1','bill_city','Billing City',1,2,0,100,5,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_quotesshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_quotesbillads',1,'1','bill_state','Billing State',1,2,0,100,7,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_quotesshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_quotesbillads',1,'1','bill_code','Billing Code',1,2,0,100,9,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_quotesshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_quotesbillads',1,'1','bill_country','Billing Country',1,2,0,100,11,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_quotesshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_quotesbillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,0,0,100,4,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block55
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$quotedescription},1,'V~O',3,null,'ADV',1)");
        //Block 56
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_quotes',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,{$quotetermsblock},1,'V~O',3,null,'ADV',1)");
        //Quote Details -- END
        //Purchase Order Details -- START
        //Block57
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder_no','vtiger_purchaseorder',1,'4','purchaseorder_no','PurchaseOrder No',1,0,0,100,2,{$pobasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_purchaseorder',1,'2','subject','Subject',1,0,0,100,1,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'vendorid','vtiger_purchaseorder',1,'81','vendor_id','Vendor Name',1,0,0,100,3,{$pobasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'requisition_no','vtiger_purchaseorder',1,'1','requisition_no','Requisition No',1,2,0,100,4,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'tracking_no','vtiger_purchaseorder',1,'1','tracking_no','Tracking Number',1,2,0,100,5,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_purchaseorder',1,'57','contact_id','Contact Name',1,2,0,100,6,{$pobasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_purchaseorder',1,'5','duedate','Due Date',1,2,0,100,7,{$pobasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_purchaseorder',1,'15','carrier','Carrier',1,2,0,100,8,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_purchaseorder',1,'1','txtTax','Sales Tax',1,0,0,100,10,57,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_purchaseorder',1,'1','txtAdjustment','Adjustment',1,2,0,100,10,{$pobasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_purchaseorder',1,'1','salescommission','Sales Commission',1,2,0,100,11,{$pobasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_purchaseorder',1,'1','exciseduty','Excise Duty',1,2,0,100,12,{$pobasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_purchaseorder',1,'1','hdnGrandTotal','Total',1,2,0,100,13,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_purchaseorder',1,'1','hdnSubTotal','Sub Total',1,2,0,100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_purchaseorder',1,'16','hdnTaxType','Tax Type',1,2,0,100,14,{$pobasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_purchaseorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_purchaseorder',1,'1','hdnDiscountAmount','Discount Amount',1,0,0,100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_purchaseorder',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'postatus','vtiger_purchaseorder',1,'15','postatus','Status',1,2,0,100,15,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,{$pobasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,{$pobasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_purchaseorder',1,'117','currency_id','Currency',1,2,1,100,19,{$pobasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_purchaseorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 59
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_pobillads',1,'24','bill_street','Billing Address',1,2,0,100,1,{$poaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_poshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,{$poaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_pobillads',1,'1','bill_city','Billing City',1,2,0,100,5,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_poshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_pobillads',1,'1','bill_state','Billing State',1,2,0,100,7,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_poshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_pobillads',1,'1','bill_code','Billing Code',1,2,0,100,9,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_poshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_pobillads',1,'1','bill_country','Billing Country',1,2,0,100,11,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_poshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_pobillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_poshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block61
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$podescription},1,'V~O',3,null,'ADV',1)");
        //Block62
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_purchaseorder',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,{$potermsblock},1,'V~O',3,null,'ADV',1)");
        //Purchase Order Details -- END
        //Sales Order Details -- START
        //Block63
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'salesorder_no','vtiger_salesorder',1,'4','salesorder_no','SalesOrder No',1,0,0,100,4,{$sobasicblock} ,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_salesorder',1,'2','subject','Subject',1,0,0,100,1,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'potentialid','vtiger_salesorder',1,'76','potential_id','Potential Name',1,2,0,100,2,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'customerno','vtiger_salesorder',1,'1','customerno','Customer No',1,2,0,100,3,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'quoteid','vtiger_salesorder',1,'78','quote_id','Quote Name',1,2,0,100,5,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder','vtiger_salesorder',1,'1','vtiger_purchaseorder','Purchase Order',1,2,0,100,5,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_salesorder',1,'57','contact_id','Contact Name',1,2,0,100,6,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_salesorder',1,'5','duedate','Due Date',1,2,0,100,8,{$sobasicblock} ,1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_salesorder',1,'15','carrier','Carrier',1,2,0,100,9,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'pending','vtiger_salesorder',1,'1','pending','Pending',1,2,0,100,10,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'sostatus','vtiger_salesorder',1,'15','sostatus','Status',1,2,0,100,11,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_salesorder',1,'1','txtTax','Sales Tax',1,0,0,100,12,63,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_salesorder',1,'1','txtAdjustment','Adjustment',1,2,0,100,12,{$sobasicblock} ,3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_salesorder',1,'1','salescommission','Sales Commission',1,2,0,100,13,{$sobasicblock} ,1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_salesorder',1,'1','exciseduty','Excise Duty',1,2,0,100,13,{$sobasicblock} ,1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_salesorder',1,'1','hdnGrandTotal','Total',1,2,0,100,14,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_salesorder',1,'1','hdnSubTotal','Sub Total',1,2,0,100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_salesorder',1,'16','hdnTaxType','Tax Type',1,2,0,100,15,{$sobasicblock} ,3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_salesorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_salesorder',1,'1','hdnDiscountAmount','Discount Amount',1,0,0,100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_salesorder',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_salesorder',1,'73','account_id','Account Name',1,2,0,100,16,{$sobasicblock} ,1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,17,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,18,{$sobasicblock} ,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,19,{$sobasicblock} ,2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_salesorder',1,'117','currency_id','Currency',1,2,1,100,20,{$sobasicblock} ,3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_salesorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        //Block 65
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_sobillads',1,'24','bill_street','Billing Address',1,2,0,100,1,{$soaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_soshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,{$soaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_sobillads',1,'1','bill_city','Billing City',1,2,0,100,5,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_soshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_sobillads',1,'1','bill_state','Billing State',1,2,0,100,7,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_soshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_sobillads',1,'1','bill_code','Billing Code',1,2,0,100,9,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_soshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_sobillads',1,'1','bill_country','Billing Country',1,2,0,100,11,{$soaddressblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_soshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,{$soaddressblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_sobillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_soshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block67
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$sodescription},1,'V~O',3,null,'ADV',1)");
        //Block68
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_salesorder',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,{$sotermsblock},1,'V~O',3,null,'ADV',1)");
        // Add fields for the Recurring Information block - Block 86
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'enable_recurring','vtiger_salesorder',1,'56','enable_recurring','Enable Recurring',1,0,0,100,1,{$sorecurringinvoiceblock},1,'C~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'recurring_frequency','vtiger_invoice_recurring_info',1,'16','recurring_frequency','Frequency',1,0,0,100,2,{$sorecurringinvoiceblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'start_period','vtiger_invoice_recurring_info',1,'5','start_period','Start Period',1,0,0,100,3,{$sorecurringinvoiceblock},1,'D~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'end_period','vtiger_invoice_recurring_info',1,'5','end_period','End Period',1,0,0,100,4,{$sorecurringinvoiceblock},1,'D~O~OTH~G~start_period~Start Period',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'payment_duration','vtiger_invoice_recurring_info',1,'16','payment_duration','Payment Duration',1,0,0,100,5,{$sorecurringinvoiceblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'invoice_status','vtiger_invoice_recurring_info',1,'15','invoicestatus','Invoice Status',1,0,0,100,6,{$sorecurringinvoiceblock},1,'V~M',3,null,'BAS',0)");
        //Sales Order Details -- END
        //Invoice Details -- START
        //Block69
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_invoice',1,'2','subject','Subject',1,0,0,100,1,{$invoicebasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'salesorderid','vtiger_invoice',1,'80','salesorder_id','Sales Order',1,2,0,100,2,{$invoicebasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'customerno','vtiger_invoice',1,'1','customerno','Customer No',1,2,0,100,3,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        //to include contact name vtiger_field in Invoice-start
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_invoice',1,'57','contact_id','Contact Name',1,2,0,100,4,{$invoicebasicblock},1,'I~O',3,null,'BAS',1)");
        //end
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoicedate','vtiger_invoice',1,'5','invoicedate','Invoice Date',1,2,0,100,5,{$invoicebasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_invoice',1,'5','duedate','Due Date',1,2,0,100,6,{$invoicebasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder','vtiger_invoice',1,'1','vtiger_purchaseorder','Purchase Order',1,2,0,100,8,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_invoice',1,'1','txtTax','Sales Tax',1,0,0,100,9,69,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_invoice',1,'1','txtAdjustment','Adjustment',1,2,0,100,9,{$invoicebasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_invoice',1,'1','salescommission','Sales Commission',1,2,0,10,13,{$invoicebasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_invoice',1,'1','exciseduty','Excise Duty',1,2,0,100,11,{$invoicebasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_invoice',1,'1','hdnSubTotal','Sub Total',1,2,0,100,12,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_invoice',1,'1','hdnGrandTotal','Total',1,2,0,100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_invoice',1,'16','hdnTaxType','Tax Type',1,2,0,100,13,{$invoicebasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_invoice',1,'1','hdnDiscountPercent','Discount Percent',1,2,0,100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_invoice',1,'1','hdnDiscountAmount','Discount Amount',1,2,0,100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_invoice',1,'1','hdnS_H_Amount','S&H Amount',1,2,0,100,14,57,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_invoice',1,'73','account_id','Account Name',1,2,0,100,14,{$invoicebasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoicestatus','vtiger_invoice',1,'15','invoicestatus','Status',1,2,0,100,15,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,0,100,16,{$invoicebasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,0,100,17,{$invoicebasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,0,100,18,{$invoicebasicblock},2,'T~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_invoice',1,'117','currency_id','Currency',1,2,1,100,19,{$invoicebasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_invoice',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 71
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_invoicebillads',1,'24','bill_street','Billing Address',1,2,0,100,1,{$invoiceaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_invoiceshipads',1,'24','ship_street','Shipping Address',1,2,0,100,2,{$invoiceaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_invoicebillads',1,'1','bill_city','Billing City',1,2,0,100,5,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_invoiceshipads',1,'1','ship_city','Shipping City',1,2,0,100,6,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_invoicebillads',1,'1','bill_state','Billing State',1,2,0,100,7,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_invoiceshipads',1,'1','ship_state','Shipping State',1,2,0,100,8,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_invoicebillads',1,'1','bill_code','Billing Code',1,2,0,100,9,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_invoiceshipads',1,'1','ship_code','Shipping Code',1,2,0,100,10,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_invoicebillads',1,'1','bill_country','Billing Country',1,2,0,100,11,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_invoiceshipads',1,'1','ship_country','Shipping Country',1,2,0,100,12,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_invoicebillads',1,'1','bill_pobox','Billing Po Box',1,2,0,100,3,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,2,0,100,4,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block73
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,0,100,1,{$invoicedescription},1,'V~O',3,null,'ADV',1)");
        //Block74
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,2,0,100,1,{$invoicetermsblock},1,'V~O',3,null,'ADV',1)");
        //Added for Custom invoice Number
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoice_no','vtiger_invoice',1,'4','invoice_no','Invoice No',1,0,0,100,3,{$invoicebasicblock},1,'V~O',3,null,'BAS',0)");
        //Invoice Details -- END
        //users Details Starts Block 79,80,81
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'user_name','vtiger_users',1,'106','user_name','User Name',1,0,0,11,1,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'is_admin','vtiger_users',1,'156','is_admin','Admin',1,0,0,3,2,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'user_password','vtiger_users',1,'99','user_password','Password',1,0,0,30,3,{$userloginandroleblockid},4,'P~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'confirm_password','vtiger_users',1,'99','confirm_password','Confirm Password',1,0,0,30,5,{$userloginandroleblockid},4,'P~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'first_name','vtiger_users',1,'1','first_name','First Name',1,0,0,30,7,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'last_name','vtiger_users',1,'2','last_name','Last Name',1,0,0,30,9,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'roleid','vtiger_user2role',1,'98','roleid','Role',1,0,0,200,11,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'email1','vtiger_users',1,'104','email1','Email',1,0,0,100,4,{$userloginandroleblockid},1,'E~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_users',1,'115','status','Status',1,0,0,100,6,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'activity_view','vtiger_users',1,'16','activity_view','Default Activity View',1,0,0,100,12,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'lead_view','vtiger_users',1,'16','lead_view','Default Lead View',1,0,0,100,10,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_users',1,'116','currency_id','Currency',1,0,0,100,8,{$userloginandroleblockid},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'hour_format','vtiger_users',1,'116','hour_format','Calendar Hour Format',1,0,0,100,13,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'end_hour','vtiger_users',1,'116','end_hour','Day ends at',1,0,0,100,15,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'start_hour','vtiger_users',1,'116','start_hour','Day starts at',1,0,0,100,14,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_users',1,'1','title','Title',1,0,0,50,1,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_work','vtiger_users',1,'1','phone_work','Office Phone',1,0,0,50,5,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'department','vtiger_users',1,'1','department','Department',1,0,0,50,3,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_mobile','vtiger_users',1,'1','phone_mobile','Mobile',1,0,0,50,7,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'reports_to_id','vtiger_users',1,'101','reports_to_id','Reports To',1,0,0,50,8,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_other','vtiger_users',1,'1','phone_other','Other Phone',1,0,0,50,11,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'email2','vtiger_users',1,'13','email2','Other Email',1,0,0,100,4,{$usermoreinfoblock},1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_fax','vtiger_users',1,'1','phone_fax','Fax',1,0,0,50,2,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'yahoo_id','vtiger_users',1,'13','yahoo_id','Yahoo id',1,0,0,100,6,{$usermoreinfoblock},1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_home','vtiger_users',1,'1','phone_home','Home Phone',1,0,0,50,9,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'date_format','vtiger_users',1,'16','date_format','Date Format',1,0,0,30,12,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'signature','vtiger_users',1,'21','signature','Signature',1,0,0,250,13,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_users',1,'21','description','Documents',1,0,0,250,14,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_street','vtiger_users',1,'21','address_street','Street Address',1,0,0,250,1,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_city','vtiger_users',1,'1','address_city','City',1,0,0,100,3,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_state','vtiger_users',1,'1','address_state','State',1,0,0,100,5,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_postalcode','vtiger_users',1,'1','address_postalcode','Postal Code',1,0,0,100,4,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_country','vtiger_users',1,'1','address_country','Country',1,0,0,100,2,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(29," . $this->db->getUniqueID("vtiger_field") . ",'accesskey','vtiger_users',1,3,'accesskey','Webservice Access Key',1,0,0,100,2,{$useradvanceblock},2,'V~O',1,null,'BAS',1);");
        //User Image Information
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_users',1,'105','imagename','User Image',1,0,0,250,10,{$userblockid},1,'V~O',1,null,'BAS',1)");
        //added for internl_mailer
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'internal_mailer','vtiger_users',1,'56','internal_mailer','INTERNAL_MAIL_COMPOSER',1,0,0,50,15,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'reminder_interval','vtiger_users',1,'16','reminder_interval','Reminder Interval',1,0,0,100,1,{$useradvanceblock},1,'V~O',1,null,'BAS',1)");
        //user Details End
        // Updated Phone field uitype
        $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=" . getTabid('Leads'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=" . getTabid('Contacts'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Leads'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Contacts'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Accounts'));
        $tab_field_array = array('Accounts' => array('accountname'), 'Contacts' => array('imagename'), 'Products' => array('imagename', 'product_id'), 'Invoice' => array('invoice_no', 'salesorder_id'), 'SalesOrder' => array('quote_id', 'salesorder_no'), 'PurchaseOrder' => array('purchaseorder_no'), 'Quotes' => array('quote_no'), 'HelpDesk' => array('filename'));
        foreach ($tab_field_array as $index => $value) {
            $tabid = getTabid($index);
            $this->db->pquery("UPDATE vtiger_field SET masseditable=0 WHERE tabid=? AND fieldname IN (" . generateQuestionMarks($value) . ")", array($tabid, $value));
        }
        //Emails field added here
        $email_Tabid = getTabid('Emails');
        $blockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'from_email','vtiger_emaildetails',1,12,'from_email','From',1,2,0,100,1,{$blockid},3,'V~M',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'to_email','vtiger_emaildetails',1,8,'saved_toid','To',1,2,0,100,2,{$blockid},1,'V~M',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'cc_email','vtiger_emaildetails',1,8,'ccmail','CC',1,2,0,1000,3,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'bcc_email','vtiger_emaildetails',1,8,'bccmail','BCC' ,1,2,0,1000,4,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'idlists','vtiger_emaildetails',1,1,'parent_id','Parent ID' ,1,2,0,1000,5,{$blockid},3,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'email_flag','vtiger_emaildetails',1,16,'email_flag','Email Flag' ,1,2,0,1000,6,{$blockid},3,'V~O',3,NULL,'BAS',0)");
        //Emails fields ends
        //The Entity Name for the modules are maintained in this table
        $this->db->query("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','lastname,firstname','leadid','leadid')");
        $this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid','account_id')");
        $this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid','contact_id')");
        $this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid','potential_id')");
        $this->db->query("insert into vtiger_entityname values(8,'Documents','vtiger_notes','title','notesid','notesid')");
        $this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid','ticketid')");
        $this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid','activityid')");
        $this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid','activityid')");
        $this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid','product_id')");
        $this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','last_name,first_name','id','id')");
        $this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid','invoiceid')");
        $this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid','quote_id')");
        $this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid','purchaseorderid')");
        $this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid','salesorder_id')");
        $this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid','vendor_id')");
        $this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid','pricebookid')");
        $this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid','campaignid')");
        $this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id','id')");
        // Insert End
        //Inserting values into org share action mapping
        $this->db->query("insert into vtiger_org_share_action_mapping values(0,'Public: Read Only')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(1,'Public: Read, Create/Edit')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(3,'Private')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(4,'Hide Details')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(5,'Hide Details and Add Events')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(6,'Show Details')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(7,'Show Details and Add Events')");
        //Inserting for all vtiger_tabs
        $def_org_tabid = array(2, 4, 6, 7, 8, 9, 10, 13, 16, 20, 21, 22, 23, 26);
        foreach ($def_org_tabid as $def_tabid) {
            $this->db->query("insert into vtiger_org_share_action2tab values(0," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(1," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(2," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(3," . $def_tabid . ")");
        }
        //Insert into default_org_sharingrule
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",2,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",4,2,2)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",6,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",7,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",9,3,1)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",13,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",16,3,2)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",20,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",21,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",22,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",23,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",26,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",8,2,0)");
        //Populating the DataShare Related Modules
        //Lead Related Module
        //Account Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,2)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,13)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,20)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,22)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,23)");
        //Potential Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",2,20)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",2,22)");
        //Quote Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",20,22)");
        //SO Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",22,23)");
        // New Secutity End
        //insert into the vtiger_notificationscheduler vtiger_table
        //insert into related list vtiger_table
        //Inserting for vtiger_account related lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Potentials") . ",'get_opportunities',2,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Quotes") . ",'get_quotes',3,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("SalesOrder") . ",'get_salesorder',4,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Invoice") . ",'get_invoices',5,'Invoice',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Calendar") . ",'get_activities',6,'Activities',0,'add')");
        //added for the ticket4109
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Emails") . ",'get_emails',7,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Calendar") . ",'get_history',8,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Documents") . ",'get_attachments',9,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("HelpDesk") . ",'get_tickets',10,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Products") . ",'get_products',11,'Products',0,'select')");
        //Inserting Lead Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Emails") . ",'get_emails',2,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Documents") . ",'get_attachments',4,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Products") . ",'get_products',5,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Campaigns") . ",'get_campaigns',6,'Campaigns',0,'select')");
        //Inserting for contact related lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Potentials") . ",'get_opportunities',1,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Calendar") . ",'get_activities',2,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Emails") . ",'get_emails',3,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("HelpDesk") . ",'get_tickets',4,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Quotes") . ",'get_quotes',5,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("PurchaseOrder") . ",'get_purchase_orders',6,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("SalesOrder") . ",'get_salesorder',7,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Products") . ",'get_products',8,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Calendar") . ",'get_history',9,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Documents") . ",'get_attachments',10,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Campaigns") . ",'get_campaigns',11,'Campaigns',0,'select')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid('Contacts') . "," . getTabid('Invoice') . ",'get_invoices',12,'Invoice',0, 'add')");
        //Inserting Potential Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Contacts") . ",'get_contacts',2,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Products") . ",'get_products',3,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . ",0,'get_stage_history',4,'Sales Stage History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Documents") . ",'get_attachments',5,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Quotes") . ",'get_Quotes',6,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("SalesOrder") . ",'get_salesorder',7,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Calendar") . ",'get_history',8,'Activity History',0,'')");
        //Inserting Product Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("HelpDesk") . ",'get_tickets',1,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Quotes") . ",'get_quotes',4,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("PurchaseOrder") . ",'get_purchase_orders',5,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("SalesOrder") . ",'get_salesorder',6,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Invoice") . ",'get_invoices',7,'Invoice',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("PriceBooks") . ",'get_product_pricebooks',8,'PriceBooks',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Leads") . ",'get_leads',9,'Leads',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Accounts") . ",'get_accounts',10,'Accounts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Contacts") . ",'get_contacts',11,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Potentials") . ",'get_opportunities',12,'Potentials',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Products") . ",'get_products',13,'Product Bundles',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Products") . ",'get_parent_products',14,'Parent Product',0,'')");
        //Inserting Emails Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'select,bulkmail')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . ",0,'get_users',2,'Users',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        //Inserting HelpDesk Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . ",0,'get_ticket_history',3,'Ticket History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Calendar") . ",'get_history',4,'Activity History',0,'')");
        //Inserting PriceBook Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PriceBooks") . ",14,'get_pricebook_products',2,'Products',0,'select')");
        // Inserting Vendor Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",14,'get_products',1,'Products',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",21,'get_purchase_orders',2,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",4,'get_contacts',3,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . "," . getTabid("Emails") . ",'get_emails',4,'Emails',0,'add')");
        // Inserting Quotes Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . "," . getTabid("SalesOrder") . ",'get_salesorder',1,'Sales Order',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",9,'get_activities',2,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",9,'get_history',4,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",0,'get_quotestagehistory',5,'Quote Stage History',0,'')");
        // Inserting Purchase order Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . ",0,'get_postatushistory',4,'PurchaseOrder Status History',0,'')");
        // Inserting Sales order Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Invoice") . ",'get_invoices',3,'Invoice',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Calendar") . ",'get_history',4,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . ",0,'get_sostatushistory',5,'SalesOrder Status History',0,'')");
        // Inserting Invoice Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . ",0,'get_invoicestatushistory',4,'Invoice Status History',0,'')");
        // Inserting Activities Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Calendar") . ",0,'get_users',1,'Users',0,'')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Calendar") . ",4,'get_contacts',2,'Contacts',0,'')");
        // Inserting Campaigns Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Leads") . ",'get_leads',2,'Leads',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Potentials") . ",'get_opportunities',3,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . ",9,'get_activities',4,'Activities',0,'add')");
        // Inserting Faq's Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Faq") . "," . getTabid("Documents") . ",'get_attachments',1,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_TASK_NOTIFICATION_DESCRITPION',1,'Task Delay Notification','Tasks delayed beyond 24 hrs ','LBL_TASK_NOTIFICATION')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_BIG_DEAL_DESCRIPTION' ,1,'Big Deal notification','Success! A big deal has been won! ','LBL_BIG_DEAL')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_TICKETS_DESCRIPTION',1,'Pending Tickets notification','Ticket pending please ','LBL_PENDING_TICKETS')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_MANY_TICKETS_DESCRIPTION',1,'Too many tickets Notification','Too many tickets pending against this entity ','LBL_MANY_TICKETS')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_START_DESCRIPTION' ,1,'Support Start Notification','10','LBL_START_NOTIFICATION','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_SUPPORT_DESCRIPTION',1,'Support ending please','11','LBL_SUPPORT_NOTICIATION','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_SUPPORT_DESCRIPTION_MONTH',1,'Support ending please','12','LBL_SUPPORT_NOTICIATION_MONTH','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notification','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')");
        //inserting actions for get_attachments
        $folderid = $this->db->getUniqueID("vtiger_attachmentsfolder");
        $this->db->query("insert into vtiger_attachmentsfolder values(" . $folderid . ",'Default','This is a Default Folder',1,1)");
        //Inserting Inventory Notifications
        $invoice_body = 'Dear {HANDLER},

The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. Kindly procure required number of units as the stock level is below reorder level {REORDERLEVELVALUE}.

Please treat this information as Urgent as the invoice is already sent  to the customer.

Severity: Critical

Thanks,
{CURRENTUSER}';
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','" . $invoice_body . " ','InvoiceNotificationDescription')");
        $quote_body = 'Dear {HANDLER},

Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 

Severity: Minor

Thanks,
{CURRENTUSER}';
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'QuoteNotification','Quote given for {PRODUCTNAME}','" . $quote_body . " ','QuoteNotificationDescription')");
        $so_body = 'Dear {HANDLER},

SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}. 

Please treat this information  with priority as the sales order is already generated.

Severity: Major

Thanks,
{CURRENTUSER}';
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'SalesOrderNotification','Sales Order generated for {PRODUCTNAME}','" . $so_body . " ','SalesOrderNotificationDescription')");
        //insert into inventory terms and conditions table
        $inv_tandc_text = '
 - Unless otherwise agreed in writing by the supplier all invoices are payable within thirty (30) days of the date of invoice, in the currency of the invoice, drawn on a bank based in India or by such other method as is agreed in advance by the Supplier.

 - All prices are not inclusive of VAT which shall be payable in addition by the Customer at the applicable rate.';
        $this->db->query("insert into vtiger_inventory_tandc(id,type,tandc) values (" . $this->db->getUniqueID("vtiger_inventory_tandc") . ", 'Inventory', '" . $inv_tandc_text . "')");
        //insert into email template vtiger_table
        $body = 'Hello!   <br />
	<br />
	On behalf of the vtiger team,  I am pleased to announce the release of vtiger crm4.2 . This is a feature packed release including the mass email template handling, custom view feature, vtiger_reports feature and a host of other utilities. vtiger runs on all platforms.    <br />
        <br />
	Notable Features of vtiger are :   <br />
	<br />
	-Email Client Integration    <br />
	-Trouble Ticket Integration   <br />
	-Invoice Management Integration   <br />
	-Reports Integration   <br />
	-Portal Integration   <br />
	-Enhanced Word Plugin Support   <br />
	-Custom View Integration   <br />
	<br />
	Known Issues:   <br />
	-ABCD   <br />
	-EFGH   <br />
	-IJKL   <br />
	-MNOP   <br />
	-QRST';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Announcement for Release','Announcement for Release','Announcement of a release','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'name <br />
street, <br />
city, <br />
state, <br />
 zip) <br />
  <br />
 Dear <br />
 <br />
 Please check the following invoices that are yet to be paid by you: <br />
 <br />
 No. Date      Amount <br />
 1   1/1/01    $4000 <br />
 2   2/2//01   $5000 <br />
 3   3/3/01    $10000 <br />
 4   7/4/01    $23560 <br />
 <br />
 Kindly let us know if there are any issues that you feel are pending to be discussed. <br />
 We will be more than happy to give you a call. <br />
 We would like to continue our business with you.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Pending Invoices','Invoices Pending','Payment Due','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = ' Dear <br />
 <br />
Your proposal on the project XYZW has been reviewed by us <br />
and is acceptable in its entirety. <br />
 <br />
We are eagerly looking forward to this project <br />
and are pleased about having the opportunity to work <br />
together. We look forward to a long standing relationship <br />
with your esteemed firm. <br />
<br />
I would like to take this opportunity to invite you <br />
to a game of golf on Wednesday morning 9am at the <br />
Cuff Links Ground. We will be waiting for you in the <br />
Executive Lounge. <br />
<br />
Looking forward to seeing you there.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Acceptance Proposal','Acceptance Proposal','Acceptance of Proposal','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = ' The undersigned hereby acknowledges receipt and delivery of the goods. <br />
The undersigned will release the payment subject to the goods being discovered not satisfactory. <br />
<br />
Signed under seal this <date>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Goods received acknowledgement','Goods received acknowledgement','Acknowledged Receipt of Goods','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = ' Dear <br />
         We are in receipt of your order as contained in the <br />
   purchase order form.We consider this to be final and binding on both sides. <br />
If there be any exceptions noted, we shall consider them <br />
only if the objection is received within ten days of receipt of <br />
this notice. <br />
 <br />
Thank you for your patronage.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Accept Order','Accept Order','Acknowledgement/Acceptance of Order','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Dear <br />
 <br />
We are relocating our office to <br />
11111,XYZDEF Cross, <br />
UVWWX Circle <br />
The telephone number for this new location is (101) 1212-1328. <br />
<br />
Our Manufacturing Division will continue operations <br />
at 3250 Lovedale Square Avenue, in Frankfurt. <br />
<br />
We hope to keep in touch with you all. <br />
Please update your addressbooks.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Address Change','Change of Address','Address Change','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Dear <br />
<br />
Thank you for extending us the opportunity to meet with <br />
you and members of your staff. <br />
<br />
I know that John Doe serviced your account <br />
for many years and made many friends at your firm. He has personally <br />
discussed with me the deep relationship that he had with your firm. <br />
While his presence will be missed, I can promise that we will <br />
continue to provide the fine service that was accorded by <br />
John to your firm. <br />
<br />
I was genuinely touched to receive such fine hospitality. <br />
<br />
Thank you once again.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Follow Up','Follow Up','Follow Up of meeting','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Congratulations! <br />
<br />
The numbers are in and I am proud to inform you that our <br />
total sales for the previous quarter <br />
amounts to $100,000,00.00!. This is the first time <br />
we have exceeded the target by almost 30%. <br />
We have also beat the previous quarter record by a <br />
whopping 75%! <br />
<br />
Let us meet at Smoking Joe for a drink in the evening! <br />

C you all there guys!';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Target Crossed!','Target Crossed!','Fantastic Sales Spree!','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Dear <br />
<br />
Thank you for your confidence in our ability to serve you. <br />
We are glad to be given the chance to serve you.I look <br />
forward to establishing a long term partnership with you. <br />
Consider me as a friend. <br />
Should any need arise,please do give us a call.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Thanks Note','Thanks Note','Note of thanks','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //Added for HTML Eemail templates..
        //for Customer Portal Login details
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM<br /> </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contact_name$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"> Thank you very much for subscribing to the vtiger CRM - annual support service.<br />Here is your self service portal login details:</td>
                                            </tr>
                                            <tr>
                                                <td align="center">
                                                <table width="75%" cellspacing="0" cellpadding="10" border="0" style="border: 2px solid rgb(180, 180, 179); background-color: rgb(226, 226, 225); font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal;">
                                                        <tr>
                                                            <td><br />User ID     : <font color="#990000"><strong> $login_name$</strong></font> </td>
                                                        </tr>
                                                        <tr>
                                                            <td>Password: <font color="#990000"><strong> $password$</strong></font> </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center"> <strong>  $URL$<br /> </strong> </td>
                                                        </tr>
                                                </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"><strong>NOTE:</strong> We suggest you to change your password after logging in first time. <br /><br /> <strong><u>Help Documentation</u></strong><br />  <br /> After logging in to vtiger Self-service Portal first time, you can access the vtiger CRM documents from the <strong>Documents</strong> tab. Following documents are available for your reference:<br />
                                                <ul>
                                                    <li>Installation Manual (Windows &amp; Linux OS)<br /> </li>
                                                    <li>User &amp; Administrator Manual<br /> </li>
                                                    <li>vtiger Customer Portal - User Manual<br /> </li>
                                                    <li>vtiger Outlook Plugin - User Manual<br /> </li>
                                                    <li>vtiger Office Plug-in - User Manual<br /> </li>
                                                    <li>vtiger Thunderbird Extension - User Manual<br /> </li>
                                                    <li>vtiger Web Forms - User Manual<br /> </li>
                                                    <li>vtiger Firefox Tool bar - User Manual<br /> </li>
                                                </ul>
                                                <br />  <br /> <strong><u>Knowledge Base</u></strong><br /> <br /> Periodically we update frequently asked question based on our customer experiences. You can access the latest articles from the <strong>FAQ</strong> tab.<br /> <br /> <strong><u>vtiger CRM - Details</u></strong><br /> <br /> Kindly let us know your current vtiger CRM version and system specification so that we can provide you necessary guidelines to enhance your vtiger CRM system performance. Based on your system specification we alert you about the latest security &amp; upgrade patches.<br />  <br />			 Thank you once again and wish you a wonderful experience with vtiger CRM.<br /> </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Best Regards</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">$support_team$ </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:support@vtiger.com">support@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Customer Login Details','Customer Portal Login Details','Send Portal login details to customer','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //for Support end notification before a week
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contacts-lastname$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">This is just a notification mail regarding your support end.<br /><span style="font-weight: bold;">Priority:</span> Urgent<br />Your Support is going to expire on next week<br />Please contact support@vtiger.com.<br /><br /><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="center"><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Sincerly</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">Support Team </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:info@vtiger.com">info@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Support end notification before a week','VtigerCRM Support Notification','Send Notification mail to customer before a week of support end date','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //for Support end notification before a month
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contacts-lastname$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">This is just a notification mail regarding your support end.<br /><span style="font-weight: bold;">Priority:</span> Normal<br />Your Support is going to expire on next month.<br />Please contact support@vtiger.com<br /><br /><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="center"><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Sincerly</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">Support Team </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a href="http://www.vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a href="mailto:info@vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);">info@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Support end notification before a month','VtigerCRM Support Notification','Send Notification mail to customer before a month of support end date','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //Insert into vtiger_organizationdetails vtiger_table
        $this->db->query("insert into vtiger_organizationdetails(organizationname,address,city,state,country,code,phone,fax,website,logoname) values ('vtiger',' 40-41-42, Sivasundar Apartments, Flat D-II, Shastri Street, Velachery','Chennai','Tamil Nadu','India','600 042','+91-44-5202-1990','+91-44-5202-1990','www.vtiger.com','vtiger-crm-logo.jpg')");
        $this->db->query("insert into vtiger_actionmapping values(0,'Save',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'EditView',0)");
        $this->db->query("insert into vtiger_actionmapping values(2,'Delete',0)");
        $this->db->query("insert into vtiger_actionmapping values(3,'index',0)");
        $this->db->query("insert into vtiger_actionmapping values(4,'DetailView',0)");
        $this->db->query("insert into vtiger_actionmapping values(5,'Import',0)");
        $this->db->query("insert into vtiger_actionmapping values(6,'Export',0)");
        //$this->db->query("insert into vtiger_actionmapping values(7,'AddBusinessCard',0)");
        $this->db->query("insert into vtiger_actionmapping values(8,'Merge',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'VendorEditView',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'VendorDetailView',1)");
        $this->db->query("insert into vtiger_actionmapping values(0,'SaveVendor',1)");
        $this->db->query("insert into vtiger_actionmapping values(2,'DeleteVendor',1)");
        $this->db->query("insert into vtiger_actionmapping values(1,'PriceBookEditView',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'PriceBookDetailView',1)");
        $this->db->query("insert into vtiger_actionmapping values(0,'SavePriceBook',1)");
        $this->db->query("insert into vtiger_actionmapping values(2,'DeletePriceBook',1)");
        $this->db->query("insert into vtiger_actionmapping values(9,'ConvertLead',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'DetailViewAjax',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'TagCloud',1)");
        $this->db->query("insert into vtiger_actionmapping values(1,'QuickCreate',1)");
        $this->db->query("insert into vtiger_actionmapping values(3,'Popup',1)");
        $this->db->query("insert into vtiger_actionmapping values(10,'DuplicatesHandling',0)");
        //Insert values for vtiger_moduleowners vtiger_table which contains the modules and their vtiger_users. default user id admin - after 4.2 patch 2
        $module_array = array('Potentials', 'Contacts', 'Accounts', 'Leads', 'Documents', 'Calendar', 'Emails', 'HelpDesk', 'Products', 'Faq', 'Vendors', 'PriceBooks', 'Quotes', 'PurchaseOrder', 'SalesOrder', 'Invoice', 'Reports', 'Campaigns');
        foreach ($module_array as $mod) {
            $this->db->query("insert into vtiger_moduleowners values(" . getTabid($mod) . ",1)");
        }
        //added by jeri for category view from db
        $this->db->query("insert into vtiger_parenttab values (1,'My Home Page',1,0)");
        $this->db->query("insert into vtiger_parenttab values (2,'Marketing',2,0)");
        $this->db->query("insert into vtiger_parenttab values (3,'Sales',3,0)");
        $this->db->query("insert into vtiger_parenttab values (4,'Support',4,0)");
        $this->db->query("insert into vtiger_parenttab values (5,'Analytics',5,0)");
        $this->db->query("insert into vtiger_parenttab values (6,'Inventory',6,0)");
        $this->db->query("insert into vtiger_parenttab values (7,'Tools',7,0)");
        $this->db->query("insert into vtiger_parenttab values (8,'Settings',8,0)");
        $this->db->query("insert into vtiger_parenttabrel values (1,9,2)");
        $this->db->query("insert into vtiger_parenttabrel values (1,28,4)");
        $this->db->query("insert into vtiger_parenttabrel values (1,3,1)");
        $this->db->query("insert into vtiger_parenttabrel values (3,7,1)");
        $this->db->query("insert into vtiger_parenttabrel values (3,6,2)");
        $this->db->query("insert into vtiger_parenttabrel values (3,4,3)");
        $this->db->query("insert into vtiger_parenttabrel values (3,2,4)");
        $this->db->query("insert into vtiger_parenttabrel values (3,20,5)");
        $this->db->query("insert into vtiger_parenttabrel values (3,22,6)");
        $this->db->query("insert into vtiger_parenttabrel values (3,23,7)");
        $this->db->query("insert into vtiger_parenttabrel values (3,19,8)");
        $this->db->query("insert into vtiger_parenttabrel values (3,8,9)");
        $this->db->query("insert into vtiger_parenttabrel values (4,13,1)");
        $this->db->query("insert into vtiger_parenttabrel values (4,15,2)");
        $this->db->query("insert into vtiger_parenttabrel values (4,6,3)");
        $this->db->query("insert into vtiger_parenttabrel values (4,4,4)");
        $this->db->query("insert into vtiger_parenttabrel values (4,8,5)");
        $this->db->query("insert into vtiger_parenttabrel values (5,1,2)");
        $this->db->query("insert into vtiger_parenttabrel values (5,25,1)");
        $this->db->query("insert into vtiger_parenttabrel values (6,14,1)");
        $this->db->query("insert into vtiger_parenttabrel values (6,18,2)");
        $this->db->query("insert into vtiger_parenttabrel values (6,19,3)");
        $this->db->query("insert into vtiger_parenttabrel values (6,21,4)");
        $this->db->query("insert into vtiger_parenttabrel values (6,22,5)");
        $this->db->query("insert into vtiger_parenttabrel values (6,20,6)");
        $this->db->query("insert into vtiger_parenttabrel values (6,23,7)");
        $this->db->query("insert into vtiger_parenttabrel values (7,24,1)");
        $this->db->query("insert into vtiger_parenttabrel values (7,27,2)");
        $this->db->query("insert into vtiger_parenttabrel values (7,8,3)");
        $this->db->query("insert into vtiger_parenttabrel values (2,26,1)");
        $this->db->query("insert into vtiger_parenttabrel values (2,6,2)");
        $this->db->query("insert into vtiger_parenttabrel values (2,4,3)");
        $this->db->query("insert into vtiger_parenttabrel values (2,28,4)");
        $this->db->query("insert into vtiger_parenttabrel values (4,28,7)");
        $this->db->query("insert into vtiger_parenttabrel values (2,7,5)");
        $this->db->query("insert into vtiger_parenttabrel values (2,9,6)");
        $this->db->query("insert into vtiger_parenttabrel values (4,9,8)");
        $this->db->query("insert into vtiger_parenttabrel values (2,8,8)");
        $this->db->query("insert into vtiger_parenttabrel values (3,9,11)");
        //add settings page to database starts
        $this->addEntriesForSettings();
        //add settings page to database end
        //Added to populate the default inventory tax informations
        $vatid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $salesid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $serviceid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $this->db->query("insert into vtiger_inventorytaxinfo values({$vatid},'tax" . $vatid . "','VAT','4.50','0')");
        $this->db->query("insert into vtiger_inventorytaxinfo values({$salesid},'tax" . $salesid . "','Sales','10.00','0')");
        $this->db->query("insert into vtiger_inventorytaxinfo values({$serviceid},'tax" . $serviceid . "','Service','12.50','0')");
        //After added these taxes we should add these taxes as columns in vtiger_inventoryproductrel table
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$vatid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$salesid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$serviceid} decimal(7,3) default NULL");
        //Added to handle picklist uniqueid for the picklist values
        //$this->db->query("insert into vtiger_picklistvalues_seq values(1)");
        //Added to populate the default Shipping & Hanlding tax informations
        $shvatid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $shsalesid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $shserviceid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shvatid},'shtax" . $shvatid . "','VAT','4.50','0')");
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shsalesid},'shtax" . $shsalesid . "','Sales','10.00','0')");
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shserviceid},'shtax" . $shserviceid . "','Service','12.50','0')");
        //After added these taxes we should add these taxes as columns in vtiger_inventoryshippingrel table
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shvatid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shsalesid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shserviceid} decimal(7,3) default NULL");
        //version file is included here because without including this file version cannot be get
        include 'vtigerversion.php';
        $this->db->query("insert into vtiger_version values(" . $this->db->getUniqueID('vtiger_version') . ",'" . $vtiger_current_version . "','" . $vtiger_current_version . "')");
        //Register default language English
        require_once 'vtlib/Vtiger/Language.php';
        $vtlanguage = new Vtiger_Language();
        $vtlanguage->register('en_us', 'US English', 'English', true, true, true);
        $this->insertUser2mergefields(0);
        $this->insertUser2mergefields(1);
        $this->db->query("update vtiger_user2mergefields set visible=1 where fieldid in(1,38,40,65,104,106,111,152,156,255)");
        $this->initWebservices();
        /**
         * Setup module sequence numbering.
         */
        $modseq = array('Leads' => 'LEA', 'Accounts' => 'ACC', 'Campaigns' => 'CAM', 'Contacts' => 'CON', 'Potentials' => 'POT', 'HelpDesk' => 'TT', 'Quotes' => 'QUO', 'SalesOrder' => 'SO', 'PurchaseOrder' => 'PO', 'Invoice' => 'INV', 'Products' => 'PRO', 'Vendors' => 'VEN', 'PriceBooks' => 'PB', 'Faq' => 'FAQ', 'Documents' => 'DOC');
        foreach ($modseq as $modname => $prefix) {
            $this->addInventoryRows(array(array('semodule' => $modname, 'active' => '1', 'prefix' => $prefix, 'startid' => '1', 'curid' => '1')));
        }
        // Adding Sharing Types for Reports
        $this->db->query("insert into vtiger_reportfilters values(1,'Private')");
        $this->db->query("insert into vtiger_reportfilters values(2,'Public')");
        $this->db->query("insert into vtiger_reportfilters values(3,'Shared')");
        require_once 'modules/Utilities/Currencies.php';
        foreach ($currencies as $key => $value) {
            $this->db->query("insert into vtiger_currencies values(" . $this->db->getUniqueID("vtiger_currencies") . ",'{$key}','" . $value[0] . "','" . $value[1] . "')");
        }
    }
Example #5
0
File: utils.php Project: yunter/crm
function updateVtlibModule($module, $packagepath)
{
    global $log, $_installOrUpdateVtlibModule;
    if (!file_exists($packagepath)) {
        return;
    }
    if (isset($_installOrUpdateVtlibModule[$module . $packagepath])) {
        return;
    }
    $_installOrUpdateVtlibModule[$module . $packagepath] = 'update';
    require_once 'vtlib/Vtiger/Package.php';
    require_once 'vtlib/Vtiger/Module.php';
    $Vtiger_Utils_Log = defined('INSTALLATION_MODE_DEBUG') ? INSTALLATION_MODE_DEBUG : true;
    $package = new Vtiger_Package();
    if ($package->isLanguageType($packagepath)) {
        require_once 'vtlib/Vtiger/Language.php';
        $languagePack = new Vtiger_Language();
        $languagePack->update(null, $packagepath, true);
        return;
    }
    if ($module == null) {
        $log->fatal("Module name is invalid");
    } else {
        $moduleInstance = Vtiger_Module::getInstance($module);
        if ($moduleInstance || $package->isModuleBundle($packagepath)) {
            $log->debug("{$module} - Module instance found - Update starts here");
            $package->update($moduleInstance, $packagepath);
        } else {
            $log->fatal("{$module} doesn't exists!");
        }
    }
}
Example #6
0
function updateVtlibModule($module, $packagepath)
{
    global $log;
    require_once 'vtlib/Vtiger/Package.php';
    require_once 'vtlib/Vtiger/Module.php';
    $Vtiger_Utils_Log = true;
    $package = new Vtiger_Package();
    if ($package->isLanguageType($packagepath)) {
        require_once 'vtlib/Vtiger/Language.php';
        $languagePack = new Vtiger_Language();
        $languagePack->update(null, $packagepath, true);
        return;
    }
    if ($module == null) {
        $log->fatal("Module name is invalid");
    } else {
        $moduleInstance = Vtiger_Module::getInstance($module);
        if ($moduleInstance || $package->isModuleBundle($packagepath)) {
            $log->debug("{$module} - Module instance found - Update starts here");
            $package->update($moduleInstance, $packagepath);
        } else {
            $log->fatal("{$module} doesn't exists!");
        }
    }
}
Example #7
0
 /**
  * Import Module from manifest.xml file. Other files should already be in place
  * @param String manifest.xml file path
  */
 function importManifest($manifestfile)
 {
     global $adb, $log;
     if (!$this->loadManifestFromFile($manifestfile)) {
         return false;
     }
     $module = (string) $this->_modulexml->name;
     if ($module != null) {
         if ($this->isLanguageType()) {
             require_once 'vtlib/Vtiger/Language.php';
             $languagePack = new Vtiger_Language();
             @$languagePack->register((string) $this->_modulexml->prefix, (string) $this->_modulexml->label, $module);
         } else {
             $sql = "select tabid from vtiger_tab where name=?";
             $result = $adb->pquery($sql, array($module));
             if ($result and $adb->num_rows($result) > 0) {
                 return false;
                 // module already installed
             }
             $this->import_Module();
         }
     } else {
         return false;
     }
     return true;
 }
Example #8
0
 /** Function to insert values in the specifed table for the specified module
  * @param $table_name -- table name:: Type varchar
  * @param $module -- module:: Type varchar
  */
 function insertIntoEntityTable($table_name, $module)
 {
     $log = vglobal('log');
     $log->info("function insertIntoEntityTable " . $module . ' vtiger_table name ' . $table_name);
     $adb = PearDatabase::getInstance();
     $current_user = vglobal('current_user');
     $insertion_mode = $this->mode;
     //Checkin whether an entry is already is present in the vtiger_table to update
     if ($insertion_mode == 'edit') {
         $check_query = "select * from " . $table_name . " where " . $this->tab_name_index[$table_name] . "=?";
         $check_result = $this->db->pquery($check_query, array($this->id));
         $num_rows = $this->db->num_rows($check_result);
         if ($num_rows <= 0) {
             $insertion_mode = '';
         }
     }
     // We will set the crypt_type based on the insertion_mode
     $crypt_type = '';
     if ($insertion_mode == 'edit') {
         $update = '';
         $update_params = array();
         $tabid = getTabid($module);
         $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,5) and vtiger_field.presence in (0,2)";
         $params = array($tabid, $table_name);
     } else {
         $column = $this->tab_name_index[$table_name];
         if ($column == 'id' && $table_name == 'vtiger_users') {
             $currentuser_id = $this->db->getUniqueID("vtiger_users");
             $this->id = $currentuser_id;
         }
         $qparams = array($this->id);
         $tabid = getTabid($module);
         $sql = "select * from vtiger_field where tabid=? and tablename=? and displaytype in (1,3,4,5) and vtiger_field.presence in (0,2)";
         $params = array($tabid, $table_name);
         $crypt_type = $this->DEFAULT_PASSWORD_CRYPT_TYPE;
     }
     $result = $this->db->pquery($sql, $params);
     $noofrows = $this->db->num_rows($result);
     for ($i = 0; $i < $noofrows; $i++) {
         $fieldname = $this->db->query_result($result, $i, "fieldname");
         $columname = $this->db->query_result($result, $i, "columnname");
         $uitype = $this->db->query_result($result, $i, "uitype");
         $typeofdata = $adb->query_result($result, $i, "typeofdata");
         $typeofdata_array = explode("~", $typeofdata);
         $datatype = $typeofdata_array[0];
         if (isset($this->column_fields[$fieldname])) {
             if ($uitype == 56) {
                 if ($this->column_fields[$fieldname] === 'on' || $this->column_fields[$fieldname] == 1) {
                     $fldvalue = 1;
                 } else {
                     $fldvalue = 0;
                 }
             } elseif ($uitype == 15) {
                 if ($this->column_fields[$fieldname] == $app_strings['LBL_NOT_ACCESSIBLE']) {
                     //If the value in the request is Not Accessible for a picklist, the existing value will be replaced instead of Not Accessible value.
                     $sql = "select {$columname} from  {$table_name} where " . $this->tab_name_index[$table_name] . "=?";
                     $res = $adb->pquery($sql, array($this->id));
                     $pick_val = $adb->query_result($res, 0, $columname);
                     $fldvalue = $pick_val;
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 5 || $uitype == 6 || $uitype == 23) {
                 if (isset($current_user->date_format)) {
                     $fldvalue = getValidDBInsertDateValue($this->column_fields[$fieldname]);
                 } else {
                     $fldvalue = $this->column_fields[$fieldname];
                 }
             } elseif ($uitype == 33) {
                 if (is_array($this->column_fields[$fieldname])) {
                     $field_list = implode(' |##| ', $this->column_fields[$fieldname]);
                 } else {
                     $field_list = $this->column_fields[$fieldname];
                 }
                 $fldvalue = $field_list;
             } elseif ($uitype == 99) {
                 $plain_text = $this->column_fields[$fieldname];
                 $fldvalue = $this->encrypt_password($plain_text, $crypt_type);
                 // Update the plain-text value with encrypted value and dependent fields
                 $this->column_fields[$fieldname] = $fldvalue;
                 $this->column_fields['crypt_type'] = $crypt_type;
                 $this->column_fields['user_hash'] = $this->get_user_hash($plain_text);
             } else {
                 $fldvalue = $this->column_fields[$fieldname];
                 $fldvalue = stripslashes($fldvalue);
             }
             $fldvalue = from_html($fldvalue, $insertion_mode == 'edit' ? true : false);
         } else {
             $fldvalue = '';
         }
         if ($uitype == 31) {
             $themeList = array_keys(Vtiger_Util_Helper::getAllSkins());
             if (!in_array($fldvalue, $themeList) || $fldvalue == '') {
                 global $default_theme;
                 if (!empty($default_theme) && in_array($default_theme, $themeList)) {
                     $fldvalue = $default_theme;
                 } else {
                     $fldvalue = $themeList[0];
                 }
             }
             if ($current_user->id == $this->id) {
                 $_SESSION['vtiger_authenticated_user_theme'] = $fldvalue;
             }
         } elseif ($uitype == 32) {
             $languageList = Vtiger_Language::getAll();
             $languageList = array_keys($languageList);
             if (!in_array($fldvalue, $languageList) || $fldvalue == '') {
                 $default_language = vglobal('default_language');
                 if (!empty($default_language) && in_array($default_language, $languageList)) {
                     $fldvalue = vglobal('default_language');
                 } else {
                     $fldvalue = $languageList[0];
                 }
             }
             if ($current_user->id == $this->id) {
                 $_SESSION['authenticated_user_language'] = $fldvalue;
             }
         }
         if ($fldvalue == '') {
             $fldvalue = $this->get_column_value($columname, $fldvalue, $fieldname, $uitype, $datatype);
             //$fldvalue =null;
         }
         if ($insertion_mode == 'edit') {
             if ($i == 0) {
                 $update = $columname . "=?";
             } else {
                 $update .= ', ' . $columname . "=?";
             }
             array_push($update_params, $fldvalue);
         } else {
             $column .= ", " . $columname;
             array_push($qparams, $fldvalue);
         }
     }
     if ($insertion_mode == 'edit') {
         //Check done by Don. If update is empty the the query fails
         if (trim($update) != '') {
             $sql1 = "update {$table_name} set {$update} where " . $this->tab_name_index[$table_name] . "=?";
             array_push($update_params, $this->id);
             $this->db->pquery($sql1, $update_params);
         }
     } else {
         // Set the crypt_type being used, to override the DB default constraint as it is not in vtiger_field
         if ($table_name == 'vtiger_users' && strpos('crypt_type', $column) === false) {
             $column .= ', crypt_type';
             $qparams[] = $crypt_type;
         }
         // END
         if ($table_name == 'vtiger_users' && strpos('user_hash', $column) === false) {
             $column .= ', user_hash';
             $qparams[] = $this->column_fields['user_hash'];
         }
         $sql1 = "insert into {$table_name} ({$column}) values(" . generateQuestionMarks($qparams) . ")";
         $this->db->pquery($sql1, $qparams);
     }
 }
 /**
  * Function to returns all language information
  * @return <Array>
  */
 public static function getAllLanguages()
 {
     return Vtiger_Language::getAll();
 }
Example #10
0
 /**
  *
  * @param String $packagepath - path to the package file.
  * @return Array
  */
 static function getOptionalModuleDetails($package, $optionalModulesInfo)
 {
     global $optionalModuleStrings;
     $moduleUpdateVersion = $package->getVersion();
     $moduleForVtigerVersion = $package->getDependentVtigerVersion();
     $moduleMaxVtigerVersion = $package->getDependentMaxVtigerVersion();
     if ($package->isLanguageType()) {
         $type = 'language';
     } else {
         $type = 'module';
     }
     $moduleDetails = null;
     $moduleName = $package->getModuleName();
     if ($moduleName != null) {
         $moduleDetails = array();
         $moduleDetails['description'] = $optionalModuleStrings[$moduleName . '_description'];
         if (Vtiger_Version::check($moduleForVtigerVersion, '>=') && Vtiger_Version::check($moduleMaxVtigerVersion, '<')) {
             $moduleDetails['selected'] = true;
             $moduleDetails['enabled'] = true;
         } else {
             $moduleDetails['selected'] = false;
             $moduleDetails['enabled'] = false;
         }
         $migrationAction = 'install';
         if (!$package->isLanguageType()) {
             $moduleInstance = null;
             if (Vtiger_Utils::checkTable('vtiger_tab')) {
                 $moduleInstance = Vtiger_Module::getInstance($moduleName);
             }
             if ($moduleInstance) {
                 $migrationAction = 'update';
                 if (version_compare($moduleUpdateVersion, $moduleInstance->version, '>=')) {
                     $moduleDetails['enabled'] = false;
                 }
             }
         } else {
             if (Vtiger_Utils::CheckTable(Vtiger_Language::TABLENAME)) {
                 $languageList = array_keys(Vtiger_Language::getAll());
                 $prefix = $package->getPrefix();
                 if (in_array($prefix, $languageList)) {
                     $migrationAction = 'update';
                 }
             }
         }
         $optionalModulesInfo[$migrationAction][$type][$moduleName] = $moduleDetails;
     }
     return $optionalModulesInfo;
 }
Example #11
0
 protected function uninstallExtension(Vtiger_Request $request)
 {
     $extensionName = $request->get('extensionName');
     $extensionInstance = Settings_ExtensionStore_Extension_Model::getModuleFromExtnName($extensionName);
     $extnType = $extensionInstance->get('extnType');
     $response = new Vtiger_Response();
     if ($extnType == 'module') {
         $extensionInstance->delete();
         //Remove extension files
         global $root_directory;
         $deletePaths = array();
         $pathToExtensionLayouts = $root_directory . "layouts/vlayout/modules/{$extensionName}";
         $layoutDirAccessible = isFileAccessible($pathToExtensionLayouts);
         if ($layoutDirAccessible) {
             $deletePaths['layouts'] = $pathToExtensionLayouts;
         }
         $pathToExtensionModule = $root_directory . "modules/{$extensionName}";
         $moduleDirAccessible = isFileAccessible($pathToExtensionModule);
         if ($moduleDirAccessible) {
             $deletePaths['modules'] = $pathToExtensionModule;
         }
         foreach ($deletePaths as $dirName) {
             $this->deleteRecursively($dirName);
         }
         $response->setResult(array('success' => true, 'message' => 'extension deleted'));
     } else {
         if ($extnType == 'language') {
             $languageInstance = Settings_ExtensionStore_Extension_Model::getLanguageInstance($extensionName);
             if ($languageInstance) {
                 $langPrefix = $languageInstance->get('prefix');
                 Vtiger_Language::deregister($langPrefix);
                 //remove files
                 $langDir = "languages/{$langPrefix}";
                 if (isFileAccessible($langDir)) {
                     $this->deleteRecursively($langDir);
                 }
             }
             $response->setResult(array('success' => true, 'message' => 'extension deleted'));
         } else {
             $response->setError('Error in deleting extension');
         }
     }
     $response->emit();
 }
    /** Function to populate the default required data during installation
     */
    function create_tables()
    {
        global $app_strings;
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (3,'Home',0,1,'Home',0,1,0,null)");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (7,'Leads',0,4,'Leads',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (6,'Accounts',0,5,'Accounts',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (4,'Contacts',0,6,'Contacts',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (2,'Potentials',0,7,'Potentials',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (8,'Documents',0,9,'Documents',0,0,1,'Tools')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (9,'Calendar',0,3,'Calendar',0,0,1,'Tools')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (10,'Emails',0,10,'Emails',0,1,1,'Tools')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (13,'HelpDesk',0,11,'HelpDesk',0,0,1,'Support')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (14,'Products',0,8,'Products',0,0,1,'Inventory')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (1,'Dashboard',0,12,'Dashboards',0,1,0,'Analytics')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (15,'Faq',0,-1,'Faq',0,1,1,'Support')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (16,'Events',2,-1,'Events',0,0,1,null)");
        // SalesPlatform.ru begin: Added sharing for Vendors
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (18,'Vendors',0,-1,'Vendors',0,0,1,'Inventory')");
        //$this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (18,'Vendors',0,-1,'Vendors',0,1,1,'Inventory')");
        // SalesPlatform.ru end
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (19,'PriceBooks',0,-1,'PriceBooks',0,1,1,'Inventory')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (20,'Quotes',0,-1,'Quotes',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (21,'PurchaseOrder',0,-1,'PurchaseOrder',0,0,1,'Inventory')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (22,'SalesOrder',0,-1,'SalesOrder',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (23,'Invoice',0,-1,'Invoice',0,0,1,'Sales')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (24,'Rss',0,-1,'Rss',0,1,0,'Tools')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (25,'Reports',0,-1,'Reports',0,1,0,'Analytics')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (26,'Campaigns',0,-1,'Campaigns',0,0,1,'Marketing')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (27,'Portal',0,-1,'Portal',0,1,0,'Tools')");
        $this->db->query("INSERT INTO vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) VALUES (28,'Webmails',0,-1,'Webmails',0,1,1,null)");
        $this->db->query("insert into vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) values (29,'Users',0,-1,'Users',0,1,0,null)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_tab(tabid,name,presence,tabsequence,tablabel,customized,ownedby,isentitytype,parent) values (30,'SPPDFTemplates',0,-1,'PDF Templates',0,1,0,'Tools')");
        // SalesPlatform.ru end
        // Populate the vtiger_blocks vtiger_table
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_OPPORTUNITY_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",2,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CONTACT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_CUSTOMER_PORTAL_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",4,'LBL_DESCRIPTION_INFORMATION',5,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_ACCOUNT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",6,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_LEAD_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",7,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",8,'LBL_NOTE_INFORMATION',1,0,0,0,0,0,1,0)");
        $fileblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $fileblockid . ",8,'LBL_FILE_INFORMATION',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'LBL_TASK_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'LBL_EMAIL_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",10,'',4,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_TICKET_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_TICKET_RESOLUTION',5,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",13,'LBL_COMMENTS',6,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_PRODUCT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_PRICING_INFORMATION',2,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_STOCK_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_IMAGE_INFORMATION',5,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",14,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",15,'LBL_FAQ_INFORMATION',1,0,0,0,0,0,1,0)");
        //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',2,1,0,0,0,0,1,0)");
        //$this->db->query("insert into vtiger_blocks values (".$this->db->getUniqueID('vtiger_blocks').",15,'',3,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",15,'LBL_COMMENT_INFORMATION',4,0,0,1,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'LBL_EVENT_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'',2,1,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'',3,1,0,0,0,0,1,0)");
        $vendorbasicinfo = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendorbasicinfo . ",18,'LBL_VENDOR_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",18,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $vendoraddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendoraddressblock . ",18,'LBL_VENDOR_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $vendordescriptionblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $vendordescriptionblock . ",18,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $pricebookbasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pricebookbasicblock . ",19,'LBL_PRICEBOOK_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",19,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $pricebookdescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pricebookdescription . ",19,'LBL_DESCRIPTION_INFORMATION',3,0,0,0,0,0,1,0)");
        $quotesbasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotesbasicblock . ",20,'LBL_QUOTE_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",20,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $quotesaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotesaddressblock . ",20,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",20,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $quotetermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotetermsblock . ",20,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $quotedescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $quotedescription . ",20,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $pobasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $pobasicblock . ",21,'LBL_PO_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",21,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $poaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $poaddressblock . ",21,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",21,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $potermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $potermsblock . ",21,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $podescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $podescription . ",21,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $sobasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sobasicblock . ",22,'LBL_SO_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",22,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $soaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $soaddressblock . ",22,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",22,'LBL_RELATED_PRODUCTS',5,0,0,0,0,0,1,0)");
        $sotermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sotermsblock . ",22,'LBL_TERMS_INFORMATION',6,0,0,0,0,0,1,0)");
        $sodescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sodescription . ",22,'LBL_DESCRIPTION_INFORMATION',7,0,0,0,0,0,1,0)");
        $invoicebasicblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicebasicblock . ",23,'LBL_INVOICE_INFORMATION',1,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",23,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $invoiceaddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoiceaddressblock . ",23,'LBL_ADDRESS_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",23,'LBL_RELATED_PRODUCTS',4,0,0,0,0,0,1,0)");
        $invoicetermsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicetermsblock . ",23,'LBL_TERMS_INFORMATION',5,0,0,0,0,0,1,0)");
        $invoicedescription = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $invoicedescription . ",23,'LBL_DESCRIPTION_INFORMATION',6,0,0,0,0,0,1,0)");
        $imageblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $imageblockid . ",4,'LBL_IMAGE_INFORMATION',6,0,0,0,0,0,1,0)");
        $campaignbasicblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaignbasicblockid . ",26,'LBL_CAMPAIGN_INFORMATION',1,0,0,0,0,0,1,0)");
        $campaigncustomblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaigncustomblock . ",26,'LBL_CUSTOM_INFORMATION',2,0,0,0,0,0,1,0)");
        $campaignexpectedandactualsblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaignexpectedandactualsblock . ",26,'LBL_EXPECTATIONS_AND_ACTUALS',3,0,0,0,0,0,1,0)");
        $userloginandroleblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $userloginandroleblockid . ",29,'LBL_USERLOGIN_ROLE',1,0,0,0,0,0,1,0)");
        $usercurrencyinfoblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $usercurrencyinfoblock . ",29,'LBL_CURRENCY_CONFIGURATION',2,0,0,0,0,0,1,0)");
        $usermoreinfoblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $usermoreinfoblock . ",29,'LBL_MORE_INFORMATION',3,0,0,0,0,0,1,0)");
        $useraddressblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $useraddressblock . ",29,'LBL_ADDRESS_INFORMATION',4,0,0,0,0,0,1,0)");
        //Added an extra block for new UI Settings in Campaigns module
        $campaidndescriptionblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $campaidndescriptionblock . ",26,'LBL_DESCRIPTION_INFORMATION',4,0,0,0,0,0,1,0)");
        $userblockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $userblockid . ",29,'LBL_USER_IMAGE_INFORMATION',4,0,0,0,0,0,1,0)");
        //Added a New Block User Image Info in Users Module
        $useradvanceblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $useradvanceblock . ",29,'LBL_USER_ADV_OPTIONS',5,0,0,0,0,0,1,0)");
        //Added a New Block User Image Info in Users Module
        //Added block 'File Information' to Documents module
        $desc_blockid = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $desc_blockid . ",8,'LBL_DESCRIPTION',2,0,0,0,0,0,1,0)");
        //Added block for storing the Recurring Inovice Informaiton in SalesOrder
        $sorecurringinvoiceblock = $this->db->getUniqueID('vtiger_blocks');
        $this->db->query("insert into vtiger_blocks values (" . $sorecurringinvoiceblock . ",22,'Recurring Invoice Information',2,0,0,0,0,0,1,0)");
        //Added to support custom fields for Calendar
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",9,'LBL_CUSTOM_INFORMATION',3,0,0,0,0,0,1,0)");
        $this->db->query("insert into vtiger_blocks values (" . $this->db->getUniqueID('vtiger_blocks') . ",16,'LBL_CUSTOM_INFORMATION',4,0,0,0,0,0,1,0)");
        //Account Details -- START
        //Block9
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'accountname','vtiger_account',1,'2','accountname','Account Name',1,0,'',100,1,9,1,'V~M',0,1,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'account_no','vtiger_account',1,'4','account_no','Account No',1,0,'',100,2,9,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_account',1,'11','phone','Phone',1,2,'',100,4,9,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_account',1,'17','website','Website',1,2,'',100,3,9,1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_account',1,'1','fax','Fax',1,2,'',100,6,9,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'tickersymbol','vtiger_account',1,'1','tickersymbol','Ticker Symbol',1,2,'',100,5,9,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'otherphone','vtiger_account',1,'11','otherphone','Other Phone',1,2,'',100,8,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'parentid','vtiger_account',1,'51','account_id','Member Of',1,2,'',100,7,9,1,'I~O',1,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'email1','vtiger_account',1,'13','email1','Email',1,2,'',100,10,9,1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'employees','vtiger_account',1,'7','employees','Employees',1,2,'',100,9,9,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'email2','vtiger_account',1,'13','email2','Other Email',1,2,'',100,11,9,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ownership','vtiger_account',1,'1','ownership','Ownership',1,2,'',100,12,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'rating','vtiger_account',1,'15','rating','Rating',1,2,'',100,14,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'industry','vtiger_account',1,'15','industry','industry',1,2,'',100,13,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'siccode','vtiger_account',1,'1','siccode','SIC Code',1,2,'',100,16,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'account_type','vtiger_account',1,'15','accounttype','Type',1,2,'',100,15,9,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'annualrevenue','vtiger_account',1,'71','annual_revenue','Annual Revenue',1,2,'',100,18,9,1,'I~O',1,null,'ADV',1)");
        //Added vtiger_field emailoptout for vtiger_accounts -- after 4.2 patch2
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'emailoptout','vtiger_account',1,'56','emailoptout','Email Opt Out',1,2,'',100,17,9,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'notify_owner','vtiger_account',1,56,'notify_owner','Notify Owner',1,2,'',10,20,9,1,'C~O',1,NULL,'ADV',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,19,9,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,22,9,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,21,9,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,23,9,3,'V~O',3,null,'BAS',0)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'inn', 'vtiger_account', 1, 1, 'inn', 'INN', 1, 2, '', 30, 24, 9, 1, 'V~O', 3, NULL, 'BAS', 0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'kpp', 'vtiger_account', 1, 1, 'kpp', 'KPP', 1, 2, '', 30, 25, 9, 1, 'V~O', 3, NULL, 'BAS', 0)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'splastsms', 'vtiger_account', 1, 70, 'splastsms', 'Last SMS Date', 1, 0, '', 100, 26, 9, 2, 'DT~O', 3, NULL, 'BAS', 0)");
        // SalesPlatform.ru end
        //Block 11
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_accountbillads',1,'21','bill_street','Billing Address',1,2,'',100,1,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_accountshipads',1,'21','ship_street','Shipping Address',1,2,'',100,2,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_accountbillads',1,'1','bill_city','Billing City',1,2,'',100,5,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_accountshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_accountbillads',1,'1','bill_state','Billing State',1,2,'',100,7,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_accountshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_accountbillads',1,'1','bill_code','Billing Code',1,2,'',100,9,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_accountshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_accountbillads',1,'1','bill_country','Billing Country',1,2,'',100,11,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_accountshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_accountbillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,11,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_accountshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,11,1,'V~O',1,null,'BAS',1)");
        //Block12
        $this->db->query("insert into vtiger_field values (6," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,12,1,'V~O',1,null,'BAS',1)");
        //Account Details -- END
        //Lead Details --- START
        //Block13 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'salutation','vtiger_leaddetails',1,'55','salutationtype','Salutation',1,0,'',100,1,13,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'firstname','vtiger_leaddetails',1,'55','firstname','First Name',1,0,'',100,2,13,1,'V~O',2,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lead_no','vtiger_leaddetails',1,'4','lead_no','Lead No',1,0,'',100,3,13,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_leadaddress',1,'11','phone','Phone',1,2,'',100,5,13,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lastname','vtiger_leaddetails',1,'255','lastname','Last Name',1,0,'',100,4,13,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'mobile','vtiger_leadaddress',1,'1','mobile','Mobile',1,2,'',100,7,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'company','vtiger_leaddetails',1,'2','company','Company',1,2,'',100,6,13,1,'V~M',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_leadaddress',1,'1','fax','Fax',1,2,'',100,9,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'designation','vtiger_leaddetails',1,'1','designation','Designation',1,2,'',100,8,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_leaddetails',1,'13','email','Email',1,2,'',100,11,13,1,'E~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_leaddetails',1,'15','leadsource','Lead Source',1,2,'',100,10,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_leadsubdetails',1,'17','website','Website',1,2,'',100,13,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'industry','vtiger_leaddetails',1,'15','industry','Industry',1,2,'',100,12,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'leadstatus','vtiger_leaddetails',1,'15','leadstatus','Lead Status',1,2,'',100,15,13,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'annualrevenue','vtiger_leaddetails',1,'71','annualrevenue','Annual Revenue',1,2,'',100,14,13,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'rating','vtiger_leaddetails',1,'15','rating','Rating',1,2,'',100,17,13,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'noofemployees','vtiger_leaddetails',1,'1','noofemployees','No Of Employees',1,2,'',100,16,13,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,19,13,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'secondaryemail','vtiger_leaddetails',1,'13','secondaryemail','Secondary Email',1,2,'',100,18,13,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,21,13,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,20,13,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,23,13,3,'V~O',3,null,'BAS',0)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'splastsms', 'vtiger_leaddetails', 1, 70, 'splastsms', 'Last SMS Date', 1, 0, '', 100, 24, 13, 2, 'DT~O', 3, NULL, 'BAS', 0)");
        // SalesPlatform.ru end
        //Block13 -- End
        //Block15 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'lane','vtiger_leadaddress',1,'21','lane','Street',1,2,'',100,1,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'code','vtiger_leadaddress',1,'1','code','Postal Code',1,2,'',100,3,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'city','vtiger_leadaddress',1,'1','city','City',1,2,'',100,4,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'country','vtiger_leadaddress',1,'1','country','Country',1,2,'',100,5,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'state','vtiger_leadaddress',1,'1','state','State',1,2,'',100,6,15,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'pobox','vtiger_leadaddress',1,'1','pobox','Po Box',1,2,'',100,2,15,1,'V~O',1,null,'BAS',1)");
        //Block15 --End
        //Block16 -- Start
        $this->db->query("insert into vtiger_field values (7," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,16,1,'V~O',1,null,'BAS',1)");
        //Block16 -- End
        //Lead Details -- END
        //Contact Details -- START
        //Block4 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'salutation','vtiger_contactdetails',1,'55','salutationtype','Salutation',1,0,'',100,1,4,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'firstname','vtiger_contactdetails',1,'55','firstname','First Name',1,0,'',100,2,4,1,'V~O',2,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'contact_no','vtiger_contactdetails',1,'4','contact_no','Contact Id',1,0,'',100,3,4,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_contactdetails',1,'11','phone','Office Phone',1,2,'',100,5,4,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'lastname','vtiger_contactdetails',1,'255','lastname','Last Name',1,0,'',100,4,4,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mobile','vtiger_contactdetails',1,'1','mobile','Mobile',1,2,'',100,7,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_contactdetails',1,'51','account_id','Account Name',1,0,'',100,6,4,1,'I~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'homephone','vtiger_contactsubdetails',1,'11','homephone','Home Phone',1,2,'',100,9,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_contactsubdetails',1,'15','leadsource','Lead Source',1,2,'',100,8,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherphone','vtiger_contactsubdetails',1,'11','otherphone','Other Phone',1,2,'',100,11,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_contactdetails',1,'1','title','Title',1,2,'',100,10,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'fax','vtiger_contactdetails',1,'1','fax','Fax',1,2,'',100,13,4,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'department','vtiger_contactdetails',1,'1','department','Department',1,2,'',100,12,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'birthday','vtiger_contactsubdetails',1,'5','birthday','Birthdate',1,2,'',100,16,4,1,'D~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_contactdetails',1,'13','email','Email',1,2,'',100,15,4,1,'E~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'reportsto','vtiger_contactdetails',1,'57','contact_id','Reports To',1,2,'',100,18,4,1,'V~O',1,null,'ADV',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'assistant','vtiger_contactsubdetails',1,'1','assistant','Assistant',1,2,'',100,17,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'secondaryemail','vtiger_contactdetails',1,'13','secondaryemail','Secondary Email',1,2,'',100,20,4,1,'E~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'assistantphone','vtiger_contactsubdetails',1,'11','assistantphone','Assistant Phone',1,2,'',100,19,4,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'donotcall','vtiger_contactdetails',1,'56','donotcall','Do Not Call',1,2,'',100,22,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'emailoptout','vtiger_contactdetails',1,'56','emailoptout','Email Opt Out',1,2,'',100,21,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,24,4,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'reference','vtiger_contactdetails',1,'56','reference','Reference',1,2,'',10,23,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'notify_owner','vtiger_contactdetails',1,'56','notify_owner','Notify Owner',1,2,'',10,26,4,1,'C~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,25,4,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,27,4,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,28,4,3,'V~O',3,null,'BAS',0)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'splastsms', 'vtiger_contactdetails', 1, 70, 'splastsms', 'Last SMS Date', 1, 0, '', 100, 29, 4, 2, 'DT~O', 3, NULL, 'BAS', 0)");
        // SalesPlatform.ru end
        //Block4 -- End
        //Block6 - Begin Customer Portal
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'portal','vtiger_customerdetails',1,'56','portal','Portal User',1,2,'',100,1,6,1,'C~O',1,null,'ADV',0)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'support_start_date','vtiger_customerdetails',1,'5','support_start_date','Support Start Date',1,2,'',100,2,6,1,'D~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'support_end_date','vtiger_customerdetails',1,'5','support_end_date','Support End Date',1,2,'',100,3,6,1,'D~O~OTH~GE~support_start_date~Support Start Date',1,null,'ADV',1)");
        //Block6 - End Customer Portal
        //Block 7 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingstreet','vtiger_contactaddress',1,'21','mailingstreet','Mailing Street',1,2,'',100,1,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherstreet','vtiger_contactaddress',1,'21','otherstreet','Other Street',1,2,'',100,2,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingcity','vtiger_contactaddress',1,'1','mailingcity','Mailing City',1,2,'',100,5,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'othercity','vtiger_contactaddress',1,'1','othercity','Other City',1,2,'',100,6,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingstate','vtiger_contactaddress',1,'1','mailingstate','Mailing State',1,2,'',100,7,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherstate','vtiger_contactaddress',1,'1','otherstate','Other State',1,2,'',100,8,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingzip','vtiger_contactaddress',1,'1','mailingzip','Mailing Zip',1,2,'',100,9,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherzip','vtiger_contactaddress',1,'1','otherzip','Other Zip',1,2,'',100,10,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingcountry','vtiger_contactaddress',1,'1','mailingcountry','Mailing Country',1,2,'',100,11,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'othercountry','vtiger_contactaddress',1,'1','othercountry','Other Country',1,2,'',100,12,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'mailingpobox','vtiger_contactaddress',1,'1','mailingpobox','Mailing Po Box',1,2,'',100,3,7,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'otherpobox','vtiger_contactaddress',1,'1','otherpobox','Other Po Box',1,2,'',100,4,7,1,'V~O',1,null,'BAS',1)");
        //Block7 -- End
        //ContactImageInformation
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_contactdetails',1,'69','imagename','Contact Image',1,2,'',100,1,{$imageblockid},1,'V~O',3,null,'ADV',0)");
        //Block8 -- Start
        $this->db->query("insert into vtiger_field values (4," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,8,1,'V~O',1,null,'BAS',1)");
        //Block8 -- End
        //Contact Details -- END
        //Potential Details -- START
        //Block1 -- Start
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potentialname','vtiger_potential',1,'2','potentialname','Potential Name',1,0,'',100,1,1,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potential_no','vtiger_potential',1,'4','potential_no','Potential No',1,0,'',100,2,1,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'amount','vtiger_potential',1,71,'amount','Amount',1,2,'',100,4,1,1,'N~O',2,5,'BAS',1)");
        //changed for b2c model
        $fieldid = $this->db->getUniqueID("vtiger_field");
        $this->db->query("insert into vtiger_field values (2,{$fieldid},'related_to','vtiger_potential',1,'10','related_to','Related To',1,0,'',100,3,1,1,'V~M',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_fieldmodulerel (fieldid, module, relmodule, status, sequence) values ({$fieldid}, 'Potentials', 'Accounts', NULL, 0), ({$fieldid}, 'Potentials', 'Contacts', NULL, 1)");
        //b2c model changes end
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'closingdate','vtiger_potential',1,'23','closingdate','Expected Close Date',1,2,'',100,7,1,1,'D~M',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'potentialtype','vtiger_potential',1,'15','opportunity_type','Type',1,2,'',100,6,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'nextstep','vtiger_potential',1,'1','nextstep','Next Step',1,2,'',100,9,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'leadsource','vtiger_potential',1,'15','leadsource','Lead Source',1,2,'',100,8,1,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'sales_stage','vtiger_potential',1,'15','sales_stage','Sales Stage',1,2,'',100,11,1,1,'V~M',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,2,'',100,10,1,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'probability','vtiger_potential',1,'9','probability','Probability',1,2,'',100,13,1,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'campaignid','vtiger_potential',1,'58','campaignid','Campaign Source',1,2,'',100,12,1,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,15,1,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,14,1,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,16,1,3,'V~O',3,null,'BAS',0)");
        //Block1 -- End
        //Block3 -- Start
        $this->db->query("insert into vtiger_field values (2," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,3,1,'V~O',1,null,'BAS',1)");
        //Block3 -- End
        //Potential Details -- END
        //campaign entries being added
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaignname','vtiger_campaign',1,'2','campaignname','Campaign Name',1,0,'',100,1,{$campaignbasicblockid},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaign_no','vtiger_campaign',1,'4','campaign_no','Campaign No',1,0,'',100,2,{$campaignbasicblockid},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaigntype','vtiger_campaign',1,15,'campaigntype','Campaign Type',1,2,'',100,5,{$campaignbasicblockid},1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_campaign',1,59,'product_id','Product',1,2,'',100,6,{$campaignbasicblockid},1,'I~O',2,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'campaignstatus','vtiger_campaign',1,15,'campaignstatus','Campaign Status',1,2,'',100,4,{$campaignbasicblockid},1,'V~O',2,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'closingdate','vtiger_campaign',1,'23','closingdate','Expected Close Date',1,2,'',100,8,{$campaignbasicblockid},1,'D~M',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,3,{$campaignbasicblockid},1,'V~M',0,7,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'numsent','vtiger_campaign',1,'9','numsent','Num Sent',1,2,'',100,12,{$campaignbasicblockid},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'sponsor','vtiger_campaign',1,'1','sponsor','Sponsor',1,2,'',100,9,{$campaignbasicblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'targetaudience','vtiger_campaign',1,'1','targetaudience','Target Audience',1,2,'',100,7,{$campaignbasicblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'targetsize','vtiger_campaign',1,'1','targetsize','TargetSize',1,2,'',100,10,{$campaignbasicblockid},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,11,{$campaignbasicblockid},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,13,{$campaignbasicblockid},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,16,{$campaignbasicblockid},3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'expectedresponse','vtiger_campaign',1,'15','expectedresponse','Expected Response',1,2,'',100,3,{$campaignexpectedandactualsblock},1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'expectedrevenue','vtiger_campaign',1,'71','expectedrevenue','Expected Revenue',1,2,'',100,4,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'budgetcost','vtiger_campaign',1,'71','budgetcost','Budget Cost',1,2,'',100,1,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'actualcost','vtiger_campaign',1,'71','actualcost','Actual Cost',1,2,'',100,2,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedresponsecount','vtiger_campaign',1,'1','expectedresponsecount','Expected Response Count',1,2,'',100,7,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedsalescount','vtiger_campaign',1,'1','expectedsalescount','Expected Sales Count',1,2,'',100,5,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'expectedroi','vtiger_campaign',1,'71','expectedroi','Expected ROI',1,2,'',100,9,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualresponsecount','vtiger_campaign',1,'1','actualresponsecount','Actual Response Count',1,2,'',100,8,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualsalescount','vtiger_campaign',1,'1','actualsalescount','Actual Sales Count',1,2,'',100,6,{$campaignexpectedandactualsblock},1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(26," . $this->db->getUniqueID("vtiger_field") . ",'actualroi','vtiger_campaign',1,'71','actualroi','Actual ROI',1,2,'',100,10,{$campaignexpectedandactualsblock},1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (26," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$campaidndescriptionblock},1,'V~O',1,null,'BAS',1)");
        //entry to vtiger_field to maintain account,contact,lead relationships
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Contacts') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Accounts') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Leads') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        $this->db->query("INSERT INTO vtiger_field(tabid, fieldid, columnname, tablename, generatedtype, uitype, fieldname, fieldlabel, readonly, presence, defaultvalue, maximumlength, sequence, block, displaytype, typeofdata, quickcreate, quickcreatesequence, info_type, masseditable) VALUES (" . getTabid('Campaigns') . "," . $this->db->getUniqueID('vtiger_field') . ", 'campaignrelstatus', 'vtiger_campaignrelstatus', 1, '16', 'campaignrelstatus', 'Status', 1, 0, 0, 100, 1, NULL, 1, 'V~O', 1, NULL, 'BAS', 0)");
        //Campaign entries end
        //Ticket Details -- START
        //Block25 -- Start
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'ticket_no','vtiger_troubletickets',1,'4','ticket_no','Ticket No',1,0,'',100,13,25,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,4,25,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'parent_id','vtiger_troubletickets',1,'68','parent_id','Related To',1,0,'',100,2,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_troubletickets',1,'15','ticketpriorities','Priority',1,2,'',100,6,25,1,'V~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_troubletickets',1,'59','product_id','Product Name',1,2,'',100,5,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'severity','vtiger_troubletickets',1,'15','ticketseverities','Severity',1,2,'',100,8,25,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_troubletickets',1,'15','ticketstatus','Status',1,2,'',100,7,25,1,'V~M',1,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_troubletickets',1,'15','ticketcategories','Category',1,2,'',100,10,25,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'update_log','vtiger_troubletickets',1,'19','update_log','Update History',1,0,'',100,11,25,3,'V~O',1,null,'BAS',0)");
        // SalesPlatform.ru begin: Change ticket hours data type
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'hours','vtiger_troubletickets',1,'1','hours','Hours',1,2,'',100,9,25,1,'N~O',1,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'hours','vtiger_troubletickets',1,'1','hours','Hours',1,2,'',100,9,25,1,'I~O',1,null,'BAS',1)");
        // SalesPlatform.ru end
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'days','vtiger_troubletickets',1,'1','days','Days',1,2,'',100,10,25,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,9,25,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,12,25,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,16,25,3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_troubletickets',1,'22','ticket_title','Title',1,0,'',100,1,25,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,28,1,'V~O',2,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'solution','vtiger_troubletickets',1,'19','solution','Solution',1,0,'',100,1,29,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (13," . $this->db->getUniqueID("vtiger_field") . ",'comments','vtiger_ticketcomments',1,'19','comments','Add Comment',1,0,'',100,1,30,1,'V~O',3,null,'BAS',0)");
        //Block25-30 -- End
        //Ticket Details -- END
        //Product Details -- START
        //Block31-36 -- Start
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productname','vtiger_products',1,'2','productname','Product Name',1,0,'',100,1,31,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'product_no','vtiger_products',1,'4','product_no','Product No',1,0,'',100,2,31,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productcode','vtiger_products',1,'1','productcode','Part Number',1,2,'',100,4,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'discontinued','vtiger_products',1,'56','discontinued','Product Active',1,2,'',100,3,31,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'manufacturer','vtiger_products',1,'15','manufacturer','Manufacturer',1,2,'',100,6,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productcategory','vtiger_products',1,'15','productcategory','Product Category',1,2,'',100,6,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'sales_start_date','vtiger_products',1,'5','sales_start_date','Sales Start Date',1,2,'',100,5,31,1,'D~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'sales_end_date','vtiger_products',1,'5','sales_end_date','Sales End Date',1,2,'',100,8,31,1,'D~O~OTH~GE~sales_start_date~Sales Start Date',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'start_date','vtiger_products',1,'5','start_date','Support Start Date',1,2,'',100,7,31,1,'D~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'expiry_date','vtiger_products',1,'5','expiry_date','Support Expiry Date',1,2,'',100,10,31,1,'D~O~OTH~GE~start_date~Start Date',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_products',1,'17','website','Website',1,2,'',100,14,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'vendor_id','vtiger_products',1,'75','vendor_id','Vendor Name',1,2,'',100,13,31,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'mfr_part_no','vtiger_products',1,'1','mfr_part_no','Mfr PartNo',1,2,'',100,16,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'vendor_part_no','vtiger_products',1,'1','vendor_part_no','Vendor PartNo',1,2,'',100,15,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'serialno','vtiger_products',1,'1','serial_no','Serial No',1,2,'',100,18,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'productsheet','vtiger_products',1,'1','productsheet','Product Sheet',1,2,'',100,17,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'glacct','vtiger_products',1,'15','glacct','GL Account',1,2,'',100,20,31,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,19,31,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,21,31,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,31,3,'V~O',3,null,'BAS',0)");
        //Block32 Pricing Information
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'unit_price','vtiger_products',1,'72','unit_price','Unit Price',1,2,'',100,1,32,1,'N~O',2,3,'BAS',0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'commissionrate','vtiger_products',1,'9','commissionrate','Commission Rate',1,2,'',100,2,32,1,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'taxclass','vtiger_products',1,'83','taxclass','Tax Class',1,2,'',100,4,32,1,'V~O',3,null,'BAS',1)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'manuf_country', 'vtiger_products', 1, 1, 'manuf_country', 'Manuf. Country', 1, 2, '', 100, 22, 31, 1, 'V~O', 3, NULL, 'BAS', 0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'customs_id', 'vtiger_products', 1, 1, 'customs_id', 'Customs ID', 1, 2, '', 100, 23, 31, 1, 'V~O', 3, NULL, 'BAS', 0)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'manuf_country_code', 'vtiger_products', 1, 1, 'manuf_country_code', 'Mf. Country Code', 1, 2, '', 100, 24, 31, 1, 'V~O', 3, NULL, 'BAS', 0)");
        // SalesPlatform.ru end
        //Block 33 stock info
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'usageunit','vtiger_products',1,'15','usageunit','Usage Unit',1,2,'',100,1,33,1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qty_per_unit','vtiger_products',1,'1','qty_per_unit','Qty/Unit',1,2,'',100,2,33,1,'N~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qtyinstock','vtiger_products',1,'1','qtyinstock','Qty In Stock',1,2,'',100,3,33,1,'NN~O',0,4,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'reorderlevel','vtiger_products',1,'1','reorderlevel','Reorder Level',1,2,'',100,4,33,1,'I~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Handler',1,0,'',100,5,33,1,'V~M',0,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'qtyindemand','vtiger_products',1,'1','qtyindemand','Qty In Demand',1,2,'',100,6,33,1,'I~O',1,null,'ADV',1)");
        // SalesPlatform.ru begin
        //$this->db->query("insert into vtiger_field values (14,".$this->db->getUniqueID("vtiger_field").",'unit_code','vtiger_products',1,'1','unit_code','Unit Code',1,2,'',100,7,33,1,'V~O',1,null,'ADV',1)");
        // SalesPlatform.ru end
        //ProductImageInformation
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_products',1,'69','imagename','Product Image',1,2,'',100,1,35,1,'V~O',3,null,'ADV',1)");
        //Block 36 Description Info
        $this->db->query("insert into vtiger_field values (14," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,36,1,'V~O',1,null,'BAS',1)");
        //Product Details -- END
        //Documents Details -- START
        //Block17 -- Start
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_notes',1,'2','notes_title','Title',1,0,'',100,1,17,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,5,17,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,6,17,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'filename','vtiger_notes',1,'28','filename','File Name',1,2,'',100,3," . $fileblockid . ",1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,4,17,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'notecontent','vtiger_notes',1,'19','notecontent','Note',1,2,'',100,1,{$desc_blockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filetype','vtiger_notes',1,1,'filetype','File Type',1,2,'',100,5," . $fileblockid . ",2,'V~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filesize','vtiger_notes',1,1,'filesize','File Size',1,2,'',100,4," . $fileblockid . ",2,'I~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filelocationtype','vtiger_notes',1,27,'filelocationtype','Download Type',1,0,'',100,1," . $fileblockid . ",1,'V~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'fileversion','vtiger_notes',1,1,'fileversion','Version',1,2,'',100,6,{$fileblockid},1,'V~O',1,'','BAS',1)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filestatus','vtiger_notes',1,56,'filestatus','Active',1,2,'',100,2," . $fileblockid . ",1,'V~O',1,'','BAS',1)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'filedownloadcount','vtiger_notes',1,1,'filedownloadcount','Download Count',1,2,'',100,7," . $fileblockid . ",2,'I~O',3,'','BAS',0)");
        $this->db->query("insert into vtiger_field values(8," . $this->db->getUniqueID("vtiger_field") . ",'folderid','vtiger_notes',1,26,'folderid','Folder Name',1,2,'',100,2,17,1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'note_no','vtiger_notes',1,'4','note_no','Document No',1,0,'',100,3,17,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (8," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,12,17,3,'V~O',3,null,'BAS',0)");
        //Block17 -- End
        //Documents Details -- END
        //Email Details -- START
        //Block21 -- Start
        // SalesPlatform.ru begin localization for Calendar
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date',1,0,'',100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Date & Time Sent',1,0,'',100,1,21,1,'DT~M~time_start~Time Start',1,null,'BAS',1)");
        // SalesPlatform.ru end
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'semodule','vtiger_activity',1,'2','parent_type','Sales Enity Module',1,0,'',100,2,21,3,'',1,null,'BAS',1)");
        // SalesPlatform.ru begin localization for Calendar
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'2','activitytype','Activity Type',1,0,'',100,3,21,3,'V~O',1,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'2','activitytype','Activtiy Type',1,0,'',100,3,21,3,'V~O',1,null,'BAS',1)");
        // SalesPlatform.ru end
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,5,21,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,'',100,1,23,1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'name','vtiger_attachments',1,'61','filename','Attachment',1,0,'',100,2,23,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,'',100,1,24,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,'',100,9,23,1,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,10,22,1,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,11,21,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field VALUES (10," . $this->db->getUniqueID("vtiger_field") . ", 'access_count', 'vtiger_email_track', '1', '25', 'access_count', 'Access Count', '1', '0', '0', '100', '6', '21', '3', 'V~O', '1', NULL, 'BAS', 0)");
        $this->db->query("insert into vtiger_field values (10," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,12,21,3,'V~O',3,null,'BAS',0)");
        //Block21 -- End
        //Email Details -- END
        //Task Details --START
        //Block19 -- Start
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,'',100,1,19,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,2,19,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,'',100,3,19,1,'DT~M~time_start',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,'',100,4,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,'',100,4,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'due_date','vtiger_activity',1,'23','due_date','Due Date',1,0,'',100,5,19,1,'D~M~OTH~GE~date_start~Start Date & Time',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,'',100,7,19,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,'',100,8,19,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_activity',1,'15','taskstatus','Status',1,0,'',100,8,19,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,'',100,9,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_activity',1,'15','taskpriority','Priority',1,0,'',100,10,19,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,'',100,11,19,1,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,14,19,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,15,19,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,'',100,16,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,'',100,17,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,'',100,1,20,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,'',100,17,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,'',100,18,19,3,'T~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'location','vtiger_activity',1,'1','location','Location',1,0,'',100,19,19,3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,'',100,1,19,3,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,'',100,6,19,3,'O~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'notime','vtiger_activity',1,56,'notime','No Time',1,0,'',100,20,19,3,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (9," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,19,3,'V~O',3,null,'BAS',0)");
        //Block19 -- End
        //Task Details -- END
        //Event Details --START
        //Block41-43-- Start
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_activity',1,'2','subject','Subject',1,0,'',100,1,41,1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,2,41,1,'V~M',0,6,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'date_start','vtiger_activity',1,'6','date_start','Start Date & Time',1,0,'',100,3,41,1,'DT~M~time_start',0,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'time_start','vtiger_activity',1,'2','time_start','Time Start',1,0,'',100,4,41,3,'T~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'due_date','vtiger_activity',1,'23','due_date','End Date',1,0,'',100,5,41,1,'D~M~OTH~GE~date_start~Start Date & Time',0,5,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'time_end','vtiger_activity',1,'2','time_end','End Time',1,0,'',100,5,41,3,'T~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'recurringtype','vtiger_activity',1,'16','recurringtype','Recurrence',1,0,'',100,6,41,1,'O~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'duration_hours','vtiger_activity',1,'63','duration_hours','Duration',1,0,'',100,7,41,1,'I~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'duration_minutes','vtiger_activity',1,'16','duration_minutes','Duration Minutes',1,0,'',100,8,41,3,'O~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'crmid','vtiger_seactivityrel',1,'66','parent_id','Related To',1,0,'',100,9,41,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'eventstatus','vtiger_activity',1,'15','eventstatus','Status',1,0,'',100,10,41,1,'V~M',0,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'sendnotification','vtiger_activity',1,'56','sendnotification','Send Notification',1,0,'',100,11,41,1,'C~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'activitytype','vtiger_activity',1,'15','activitytype','Activity Type',1,0,'',100,12,41,1,'V~M',0,4,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'location','vtiger_activity',1,'1','location','Location',1,0,'',100,13,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,14,41,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,15,41,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'priority','vtiger_activity',1,15,'taskpriority','Priority',1,0,'',100,16,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'notime','vtiger_activity',1,56,'notime','No Time',1,0,'',100,17,41,1,'C~O',1,null,'BAS',1)");
        $this->db->query("Insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'visibility','vtiger_activity',1,'16','visibility','Visibility',1,0,'',100,18,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,41,3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,0,'',100,1,41,1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'reminder_time','vtiger_activity_reminder',1,'30','reminder_time','Send Reminder',1,0,'',100,1,40,1,'I~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (16," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_cntactivityrel',1,'57','contact_id','Contact Name',1,0,'',100,1,19,1,'I~O',1,null,'BAS',1)");
        //Block41-43 -- End
        //Event Details -- END
        //Faq Details -- START
        //Block37-40 -- Start
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'product_id','vtiger_faq',1,'59','product_id','Product Name',1,2,'',100,1,37,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'faq_no','vtiger_faq',1,'4','faq_no','Faq No',1,0,'',100,2,37,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_faq',1,'15','faqcategories','Category',1,2,'',100,4,37,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_faq',1,'15','faqstatus','Status',1,2,'',100,3,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'question','vtiger_faq',1,'20','question','Question',1,2,'',100,7,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'answer','vtiger_faq',1,'20','faq_answer','Answer',1,2,'',100,8,37,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'comments','vtiger_faqcomments',1,'19','comments','Add Comment',1,0,'',100,1,38,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,5,37,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,6,37,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (15," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,7,37,3,'V~O',3,null,'BAS',0)");
        //Block37-40 -- End
        //Ticket Details -- END
        //Vendor Details --START
        //Block44-47
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'vendorname','vtiger_vendor',1,'2','vendorname','Vendor Name',1,0,'',100,1,{$vendorbasicinfo},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'vendor_no','vtiger_vendor',1,'4','vendor_no','Vendor No',1,0,'',100,2,{$vendorbasicinfo},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'phone','vtiger_vendor',1,'1','phone','Phone',1,2,'',100,4,{$vendorbasicinfo},1,'V~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'email','vtiger_vendor',1,'13','email','Email',1,2,'',100,3,{$vendorbasicinfo},1,'E~O',2,3,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'website','vtiger_vendor',1,'17','website','Website',1,2,'',100,6,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'glacct','vtiger_vendor',1,'15','glacct','GL Account',1,2,'',100,5,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'category','vtiger_vendor',1,'1','category','Category',1,2,'',100,8,{$vendorbasicinfo},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,7,{$vendorbasicinfo},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,9,{$vendorbasicinfo},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,12,{$vendorbasicinfo},3,'V~O',3,null,'BAS',0)");
        // SalesPlatform.ru begin Added Vendors assigned_user_id
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,13,{$vendorbasicinfo},1,'V~M',0,4,'BAS',1)");
        // SalesPlatform.ru end
        //Block 46
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'street','vtiger_vendor',1,'21','street','Street',1,2,'',100,1,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'pobox','vtiger_vendor',1,'1','pobox','Po Box',1,2,'',100,2,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'city','vtiger_vendor',1,'1','city','City',1,2,'',100,3,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'state','vtiger_vendor',1,'1','state','State',1,2,'',100,4,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'postalcode','vtiger_vendor',1,'1','postalcode','Postal Code',1,2,'',100,5,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'country','vtiger_vendor',1,'1','country','Country',1,2,'',100,6,{$vendoraddressblock},1,'V~O',1,null,'ADV',1)");
        //Block 47
        $this->db->query("insert into vtiger_field values (18," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$vendordescriptionblock},1,'V~O',1,null,'ADV',1)");
        //Vendor Details -- END
        //PriceBook Details Start
        //Block48
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'bookname','vtiger_pricebook',1,'2','bookname','Price Book Name',1,0,'',100,1,{$pricebookbasicblock},1,'V~M',0,1,'BAS',1)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'pricebook_no','vtiger_pricebook',1,'4','pricebook_no','PriceBook No',1,0,'',100,3,{$pricebookbasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'active','vtiger_pricebook',1,'56','active','Active',1,2,'',100,2,{$pricebookbasicblock},1,'C~O',2,2,'BAS',1)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,4,{$pricebookbasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,5,{$pricebookbasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_pricebook',1,'117','currency_id','Currency',1,0,'',100,5,{$pricebookbasicblock},1,'I~M',0,3,'BAS',0)");
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,7,{$pricebookbasicblock},3,'V~O',3,null,'BAS',0)");
        //Block50
        $this->db->query("insert into vtiger_field values (19," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$pricebookdescription},1,'V~O',1,null,'BAS',1)");
        //PriceBook Details End
        //Quote Details -- START
        //Block51
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'quote_no','vtiger_quotes',1,'4','quote_no','Quote No',1,0,'',100,3,{$quotesbasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_quotes',1,'2','subject','Subject',1,0,'',100,1,{$quotesbasicblock},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'potentialid','vtiger_quotes',1,'76','potential_id','Potential Name',1,2,'',100,2,{$quotesbasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'quotestage','vtiger_quotes',1,'15','quotestage','Quote Stage',1,2,'',100,4,{$quotesbasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'validtill','vtiger_quotes',1,'5','validtill','Valid Till',1,2,'',100,5,{$quotesbasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_quotes',1,'57','contact_id','Contact Name',1,2,'',100,6,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_quotes',1,'15','carrier','Carrier',1,2,'',100,8,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_quotes',1,'72','hdnSubTotal','Sub Total',1,2,'',100,9,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'shipping','vtiger_quotes',1,'1','shipping','Shipping',1,2,'',100,10,{$quotesbasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'inventorymanager','vtiger_quotes',1,'77','assigned_user_id1','Inventory Manager',1,2,'',100,11,{$quotesbasicblock},1,'I~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (20,".$this->db->getUniqueID("vtiger_field").",'tax','vtiger_quotes',1,'1','txtTax','Sales Tax',1,0,'',100,13,51,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_quotes',1,'72','txtAdjustment','Adjustment',1,2,'',100,20,{$quotesbasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_quotes',1,'72','hdnGrandTotal','Total',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_quotes',1,'16','hdnTaxType','Tax Type',1,2,'',100,14,{$quotesbasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_quotes',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_quotes',1,'72','hdnDiscountAmount','Discount Amount',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_quotes',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,14,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_quotes',1,'73','account_id','Account Name',1,2,'',100,16,{$quotesbasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,17,{$quotesbasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,18,{$quotesbasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,19,{$quotesbasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,{$quotesbasicblock},3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_quotes',1,'117','currency_id','Currency',1,2,1,100,20,{$quotesbasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_quotes',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,{$quotesbasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 53
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_quotesbillads',1,'24','bill_street','Billing Address',1,2,'',100,1,{$quotesaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_quotesshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,{$quotesaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_quotesbillads',1,'1','bill_city','Billing City',1,2,'',100,5,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_quotesshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_quotesbillads',1,'1','bill_state','Billing State',1,2,'',100,7,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_quotesshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_quotesbillads',1,'1','bill_code','Billing Code',1,2,'',100,9,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_quotesshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_quotesbillads',1,'1','bill_country','Billing Country',1,2,'',100,11,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_quotesshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_quotesbillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_quotesshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,{$quotesaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block55
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$quotedescription},1,'V~O',3,null,'ADV',1)");
        //Block 56
        $this->db->query("insert into vtiger_field values (20," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_quotes',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$quotetermsblock},1,'V~O',3,null,'ADV',1)");
        //Quote Details -- END
        //Purchase Order Details -- START
        //Block57
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder_no','vtiger_purchaseorder',1,'4','purchaseorder_no','PurchaseOrder No',1,0,'',100,2,{$pobasicblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_purchaseorder',1,'2','subject','Subject',1,0,'',100,1,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'vendorid','vtiger_purchaseorder',1,'81','vendor_id','Vendor Name',1,0,'',100,3,{$pobasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'requisition_no','vtiger_purchaseorder',1,'1','requisition_no','Requisition No',1,2,'',100,4,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'tracking_no','vtiger_purchaseorder',1,'1','tracking_no','Tracking Number',1,2,'',100,5,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_purchaseorder',1,'57','contact_id','Contact Name',1,2,'',100,6,{$pobasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_purchaseorder',1,'5','duedate','Due Date',1,2,'',100,7,{$pobasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_purchaseorder',1,'15','carrier','Carrier',1,2,'',100,8,{$pobasicblock},1,'V~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (21,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_purchaseorder',1,'1','txtTax','Sales Tax',1,0,'',100,10,57,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_purchaseorder',1,'72','txtAdjustment','Adjustment',1,2,'',100,10,{$pobasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_purchaseorder',1,'1','salescommission','Sales Commission',1,2,'',100,11,{$pobasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_purchaseorder',1,'1','exciseduty','Excise Duty',1,2,'',100,12,{$pobasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_purchaseorder',1,'72','hdnGrandTotal','Total',1,2,'',100,13,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_purchaseorder',1,'72','hdnSubTotal','Sub Total',1,2,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_purchaseorder',1,'16','hdnTaxType','Tax Type',1,2,'',100,14,{$pobasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_purchaseorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_purchaseorder',1,'72','hdnDiscountAmount','Discount Amount',1,0,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_purchaseorder',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,14,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'postatus','vtiger_purchaseorder',1,'15','postatus','Status',1,2,'',100,15,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,16,{$pobasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,17,{$pobasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,18,{$pobasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,{$pobasicblock},3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_purchaseorder',1,'117','currency_id','Currency',1,2,1,100,19,{$pobasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_purchaseorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,{$pobasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 59
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_pobillads',1,'24','bill_street','Billing Address',1,2,'',100,1,{$poaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_poshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,{$poaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_pobillads',1,'1','bill_city','Billing City',1,2,'',100,5,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_poshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_pobillads',1,'1','bill_state','Billing State',1,2,'',100,7,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_poshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_pobillads',1,'1','bill_code','Billing Code',1,2,'',100,9,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_poshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_pobillads',1,'1','bill_country','Billing Country',1,2,'',100,11,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_poshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_pobillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_poshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,{$poaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block61
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$podescription},1,'V~O',3,null,'ADV',1)");
        //Block62
        $this->db->query("insert into vtiger_field values (21," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_purchaseorder',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$potermsblock},1,'V~O',3,null,'ADV',1)");
        //Purchase Order Details -- END
        //Sales Order Details -- START
        //Block63
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'salesorder_no','vtiger_salesorder',1,'4','salesorder_no','SalesOrder No',1,0,'',100,4,{$sobasicblock} ,1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_salesorder',1,'2','subject','Subject',1,0,'',100,1,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'potentialid','vtiger_salesorder',1,'76','potential_id','Potential Name',1,2,'',100,2,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'customerno','vtiger_salesorder',1,'1','customerno','Customer No',1,2,'',100,3,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'quoteid','vtiger_salesorder',1,'78','quote_id','Quote Name',1,2,'',100,5,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder','vtiger_salesorder',1,'1','vtiger_purchaseorder','Purchase Order',1,2,'',100,5,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_salesorder',1,'57','contact_id','Contact Name',1,2,'',100,6,{$sobasicblock} ,1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_salesorder',1,'5','duedate','Due Date',1,2,'',100,8,{$sobasicblock} ,1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'carrier','vtiger_salesorder',1,'15','carrier','Carrier',1,2,'',100,9,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'pending','vtiger_salesorder',1,'1','pending','Pending',1,2,'',100,10,{$sobasicblock} ,1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'sostatus','vtiger_salesorder',1,'15','sostatus','Status',1,2,'',100,11,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (22,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_salesorder',1,'1','txtTax','Sales Tax',1,0,'',100,12,63,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_salesorder',1,'72','txtAdjustment','Adjustment',1,2,'',100,12,{$sobasicblock} ,3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_salesorder',1,'1','salescommission','Sales Commission',1,2,'',100,13,{$sobasicblock} ,1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_salesorder',1,'1','exciseduty','Excise Duty',1,2,'',100,13,{$sobasicblock} ,1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_salesorder',1,'72','hdnGrandTotal','Total',1,2,'',100,14,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_salesorder',1,'72','hdnSubTotal','Sub Total',1,2,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_salesorder',1,'16','hdnTaxType','Tax Type',1,2,'',100,15,{$sobasicblock} ,3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_salesorder',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_salesorder',1,'72','hdnDiscountAmount','Discount Amount',1,0,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_salesorder',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,15,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_salesorder',1,'73','account_id','Account Name',1,2,'',100,16,{$sobasicblock} ,1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,17,{$sobasicblock} ,1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,18,{$sobasicblock} ,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,19,{$sobasicblock} ,2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,{$sobasicblock},3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_salesorder',1,'117','currency_id','Currency',1,2,1,100,20,{$sobasicblock} ,3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_salesorder',1,'1','conversion_rate','Conversion Rate',1,2,1,100,21,{$sobasicblock} ,3,'N~O',3,null,'BAS',1)");
        //Block 65
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_sobillads',1,'24','bill_street','Billing Address',1,2,'',100,1,{$soaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_soshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,{$soaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_sobillads',1,'1','bill_city','Billing City',1,2,'',100,5,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_soshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_sobillads',1,'1','bill_state','Billing State',1,2,'',100,7,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_soshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_sobillads',1,'1','bill_code','Billing Code',1,2,'',100,9,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_soshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_sobillads',1,'1','bill_country','Billing Country',1,2,'',100,11,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_soshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_sobillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_soshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,{$soaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block67
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$sodescription},1,'V~O',3,null,'ADV',1)");
        //Block68
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_salesorder',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$sotermsblock},1,'V~O',3,null,'ADV',1)");
        // Add fields for the Recurring Information block - Block 86
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'enable_recurring','vtiger_salesorder',1,'56','enable_recurring','Enable Recurring',1,0,'',100,1,{$sorecurringinvoiceblock},1,'C~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'recurring_frequency','vtiger_invoice_recurring_info',1,'16','recurring_frequency','Frequency',1,0,'',100,2,{$sorecurringinvoiceblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'start_period','vtiger_invoice_recurring_info',1,'5','start_period','Start Period',1,0,'',100,3,{$sorecurringinvoiceblock},1,'D~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'end_period','vtiger_invoice_recurring_info',1,'5','end_period','End Period',1,0,'',100,4,{$sorecurringinvoiceblock},1,'D~O~OTH~G~start_period~Start Period',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'payment_duration','vtiger_invoice_recurring_info',1,'16','payment_duration','Payment Duration',1,0,'',100,5,{$sorecurringinvoiceblock},1,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (22," . $this->db->getUniqueID('vtiger_field') . ",'invoice_status','vtiger_invoice_recurring_info',1,'15','invoicestatus','Invoice Status',1,0,'',100,6,{$sorecurringinvoiceblock},1,'V~M',3,null,'BAS',0)");
        //Sales Order Details -- END
        //Invoice Details -- START
        //Block69
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'subject','vtiger_invoice',1,'2','subject','Subject',1,0,'',100,1,{$invoicebasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'salesorderid','vtiger_invoice',1,'80','salesorder_id','Sales Order',1,2,'',100,2,{$invoicebasicblock},1,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'customerno','vtiger_invoice',1,'1','customerno','Customer No',1,2,'',100,3,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        //to include contact name vtiger_field in Invoice-start
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'contactid','vtiger_invoice',1,'57','contact_id','Contact Name',1,2,'',100,4,{$invoicebasicblock},1,'I~O',3,null,'BAS',1)");
        //end
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoicedate','vtiger_invoice',1,'5','invoicedate','Invoice Date',1,2,'',100,5,{$invoicebasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'duedate','vtiger_invoice',1,'5','duedate','Due Date',1,2,'',100,6,{$invoicebasicblock},1,'D~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'purchaseorder','vtiger_invoice',1,'1','vtiger_purchaseorder','Purchase Order',1,2,'',100,8,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (23,".$this->db->getUniqueID("vtiger_field").",'salestax','vtiger_invoice',1,'1','txtTax','Sales Tax',1,0,'',100,9,69,3,'N~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'adjustment','vtiger_invoice',1,'72','txtAdjustment','Adjustment',1,2,'',100,9,{$invoicebasicblock},3,'NN~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'salescommission','vtiger_invoice',1,'1','salescommission','Sales Commission',1,2,'',10,13,{$invoicebasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'exciseduty','vtiger_invoice',1,'1','exciseduty','Excise Duty',1,2,'',100,11,{$invoicebasicblock},1,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'subtotal','vtiger_invoice',1,'72','hdnSubTotal','Sub Total',1,2,'',100,12,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'total','vtiger_invoice',1,'72','hdnGrandTotal','Total',1,2,'',100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        //Added fields taxtype, discount percent, discount amount and S&H amount for Tax process
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'taxtype','vtiger_invoice',1,'16','hdnTaxType','Tax Type',1,2,'',100,13,{$invoicebasicblock},3,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'discount_percent','vtiger_invoice',1,'1','hdnDiscountPercent','Discount Percent',1,2,'',100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'discount_amount','vtiger_invoice',1,'72','hdnDiscountAmount','Discount Amount',1,2,'',100,13,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'s_h_amount','vtiger_invoice',1,'72','hdnS_H_Amount','S&H Amount',1,2,'',100,14,67,3,'N~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'accountid','vtiger_invoice',1,'73','account_id','Account Name',1,2,'',100,14,{$invoicebasicblock},1,'I~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoicestatus','vtiger_invoice',1,'15','invoicestatus','Status',1,2,'',100,15,{$invoicebasicblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'smownerid','vtiger_crmentity',1,'53','assigned_user_id','Assigned To',1,0,'',100,16,{$invoicebasicblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'createdtime','vtiger_crmentity',1,'70','createdtime','Created Time',1,0,'',100,17,{$invoicebasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'modifiedtime','vtiger_crmentity',1,'70','modifiedtime','Modified Time',1,0,'',100,18,{$invoicebasicblock},2,'DT~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'modifiedby','vtiger_crmentity',1,'52','modifiedby','Last Modified By',1,0,'',100,22,{$invoicebasicblock},3,'V~O',3,null,'BAS',0)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_invoice',1,'117','currency_id','Currency',1,2,1,100,19,{$invoicebasicblock},3,'I~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'conversion_rate','vtiger_invoice',1,'1','conversion_rate','Conversion Rate',1,2,1,100,20,{$invoicebasicblock},3,'N~O',3,null,'BAS',1)");
        //Block 71
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_street','vtiger_invoicebillads',1,'24','bill_street','Billing Address',1,2,'',100,1,{$invoiceaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_street','vtiger_invoiceshipads',1,'24','ship_street','Shipping Address',1,2,'',100,2,{$invoiceaddressblock},1,'V~M',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_city','vtiger_invoicebillads',1,'1','bill_city','Billing City',1,2,'',100,5,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_city','vtiger_invoiceshipads',1,'1','ship_city','Shipping City',1,2,'',100,6,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_state','vtiger_invoicebillads',1,'1','bill_state','Billing State',1,2,'',100,7,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_state','vtiger_invoiceshipads',1,'1','ship_state','Shipping State',1,2,'',100,8,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_code','vtiger_invoicebillads',1,'1','bill_code','Billing Code',1,2,'',100,9,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_code','vtiger_invoiceshipads',1,'1','ship_code','Shipping Code',1,2,'',100,10,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_country','vtiger_invoicebillads',1,'1','bill_country','Billing Country',1,2,'',100,11,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_country','vtiger_invoiceshipads',1,'1','ship_country','Shipping Country',1,2,'',100,12,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'bill_pobox','vtiger_invoicebillads',1,'1','bill_pobox','Billing Po Box',1,2,'',100,3,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'ship_pobox','vtiger_invoiceshipads',1,'1','ship_pobox','Shipping Po Box',1,2,'',100,4,{$invoiceaddressblock},1,'V~O',3,null,'BAS',1)");
        //Block73
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_crmentity',1,'19','description','Description',1,2,'',100,1,{$invoicedescription},1,'V~O',3,null,'ADV',1)");
        //Block74
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'terms_conditions','vtiger_invoice',1,'19','terms_conditions','Terms & Conditions',1,2,'',100,1,{$invoicetermsblock},1,'V~O',3,null,'ADV',1)");
        //Added for Custom invoice Number
        $this->db->query("insert into vtiger_field values (23," . $this->db->getUniqueID("vtiger_field") . ",'invoice_no','vtiger_invoice',1,'4','invoice_no','Invoice No',1,0,'',100,3,{$invoicebasicblock},1,'V~O',3,null,'BAS',0)");
        // SalesPlatform.ru begin
        $this->db->query('INSERT INTO `sp_templates` VALUES (' . $this->db->getUniqueID('sp_templates') . ',\'Счет\',\'Invoice\',\'{header}\\n\\n<p style="font-weight: bold; text-decoration: underline">{$orgName}</p>\\n\\n<p style="font-weight: bold">Адрес: {$orgBillingAddress}, тел.: {$orgPhone}</p>\\n\\n<div style="font-weight: bold; text-align: center">Образец заполнения платежного поручения</div>\\n\\n<table border="1" cellpadding="2">\\n<tr>\\n  <td width="140">ИНН {$orgInn}</td><td width="140">КПП {$orgKpp}</td><td rowspan="2" width="50"><br/><br/>Сч. №</td><td rowspan="2" width="200"><br/><br/>{$orgBankAccount}</td>\\n</tr>\\n<tr>\\n<td colspan="2" width="280"><span style="font-size: 8pt">Получатель</span><br/>{$orgName}</td>\\n</tr>\\n<tr>\\n<td colspan="2" rowspan="2" width="280"><span style="font-size: 8pt">Банк получателя</span><br/>{$orgBankName}</td>\\n<td width="50">БИК</td>\\n<td rowspan="2" width="200">{$orgBankId}<br/>{$orgCorrAccount}</td>\\n</tr>\\n<tr>\\n<td width="50">Сч. №</td>\\n</tr>\\n</table>\\n<br/>\\n<h1 style="text-align: center">СЧЕТ № {$invoice_no} от {$invoice_invoicedate}</h1>\\n<br/><br/>\\n<table border="0">\\n<tr>\\n<td width="100">Плательщик:</td><td width="450"><span style="font-weight: bold">{$account_accountname}</span></td>\\n</tr>\\n<tr>\\n<td width="100">Грузополучатель:</td><td width="450"><span style="font-weight: bold">{$account_accountname}</span></td>\\n</tr>\\n</table>\\n\\n{/header}\\n\\n{table_head}\\n<table border="1" style="font-size: 8pt" cellpadding="2">\\n    <tr style="text-align: center; font-weight: bold">\\n	<td width="30">№</td>\\n      <td width="260">Наименование<br/>товара</td>\\n      <td width="65">Единица<br/>изме-<br/>рения</td>\\n      <td width="35">Коли-<br/>чество</td>\\n	<td width="70">Цена</td>\\n	<td width="70">Сумма</td>\\n	</tr>\\n{/table_head}\\n\\n{table_row}\\n    <tr>\\n	<td width="30">{$productNumber}</td>\\n      <td width="260">{$productName} {$productComment}</td>\\n	<td width="65" style="text-align: center">{$productUnits}</td>\\n	<td width="35" style="text-align: right">{$productQuantityInt}</td>\\n	<td width="70" style="text-align: right">{$productPriceWithTax}</td>\\n	<td width="70" style="text-align: right">{$productTotal}</td>\\n    </tr>\\n{/table_row}\\n\\n{summary}\\n</table>\\n<table border="0" style="font-size: 8pt;font-weight: bold">\\n    <tr>\\n      <td width="460">\\n        <table border="0" cellpadding="2">\\n          <tr><td width="460" style="text-align: right">Итого:</td></tr>\\n          <tr><td width="460" style="text-align: right">В т.ч. НДС:</td></tr>\\n          <tr><td width="460" style="text-align: right">Всего к оплате:</td></tr>\\n        </table>\\n      </td>\\n      <td width="70">\\n        <table border="1" cellpadding="2">\\n          <tr><td width="70" style="text-align: right">{$summaryGrandTotal}</td></tr>\\n          <tr><td width="70" style="text-align: right">{$summaryTax}</td></tr>\\n          <tr><td width="70" style="text-align: right">{$summaryGrandTotal}</td></tr>\\n        </table>\\n      </td>\\n  </tr>\\n</table>\\n\\n<p>\\nВсего наименований {$summaryTotalItems}, на сумму {$summaryGrandTotal} руб.<br/>\\n<span style="font-weight: bold">{$summaryGrandTotalLiteral}</span>\\n</p>\\n\\n{/summary}\\n\\n{ending}\\n<br/>\\n    <p>Руководитель предприятия  __________________ ( {$orgDirector} ) <br/>\\n    <br/>\\n    Главный бухгалтер  __________________ ( {$orgBookkeeper} )\\n    </p>\\n{/ending}\',110,50,\'P\'),(' . $this->db->getUniqueID('sp_templates') . ',\'Накладная\',\'SalesOrder\',\'{header}\\n<h1 style=\\"font-size: 14pt\\">Расходная накладная № {$salesorder_no}</h1>\\n<hr>\\n<table border=\\"0\\" style=\\"font-size: 9pt\\">\\n<tr>\\n<td width=\\"80\\">Поставщик:</td><td width=\\"450\\"><span style=\\"font-weight: bold\\">{$orgName}</span></td>\\n</tr>\\n<tr>\\n<td width=\\"80\\">Покупатель:</td><td width=\\"450\\"><span style=\\"font-weight: bold\\">{$account_accountname}</span></td>\\n</tr>\\n</table>\\n{/header}\\n\\n{table_head}\\n<table border=\\"1\\" style=\\"font-size: 8pt\\" cellpadding=\\"2\\">\\n    <tr style=\\"text-align: center; font-weight: bold\\">\\n	<td width=\\"30\\" rowspan=\\"2\\">№</td>\\n	<td width=\\"200\\" rowspan=\\"2\\">Товар</td>\\n	<td width=\\"50\\" rowspan=\\"2\\" colspan=\\"2\\">Мест</td>\\n	<td width=\\"60\\" rowspan=\\"2\\" colspan=\\"2\\">Количество</td>\\n	<td width=\\"60\\" rowspan=\\"2\\">Цена</td>\\n	<td width=\\"60\\" rowspan=\\"2\\">Сумма</td>\\n	<td width=\\"70\\">Номер ГТД</td>\\n    </tr>\\n    <tr style=\\"text-align: center; font-weight: bold\\">\\n	<td width=\\"70\\">Страна<br/>происхождения</td>\\n    </tr>\\n{/table_head}\\n\\n{table_row}\\n    <tr>\\n	<td width=\\"30\\" rowspan=\\"2\\">{$productNumber}</td>\\n	<td width=\\"200\\" rowspan=\\"2\\">{$productName}</td>\\n	<td width=\\"25\\" rowspan=\\"2\\"></td>\\n	<td width=\\"25\\" rowspan=\\"2\\">шт.</td>\\n	<td width=\\"30\\" rowspan=\\"2\\" style=\\"text-align: right\\">{$productQuantityInt}</td>\\n	<td width=\\"30\\" rowspan=\\"2\\">{$productUnits}</td>\\n	<td width=\\"60\\" rowspan=\\"2\\" style=\\"text-align: right\\">{$productPrice}</td>\\n	<td width=\\"60\\" rowspan=\\"2\\" style=\\"text-align: right\\">{$productNetTotal}</td>\\n	<td width=\\"70\\">{$customsId}</td>\\n    </tr>\\n    <tr>\\n	<td width=\\"70\\">{$manufCountry}</td>\\n    </tr>\\n{/table_row}\\n\\n{summary}\\n</table>\\n<p></p>\\n<table border=\\"0\\" style=\\"font-weight: bold\\">\\n    <tr>\\n	<td width=\\"400\\" style=\\"text-align: right\\">Итого:</td>\\n	<td width=\\"60\\" style=\\"text-align: right\\">{$summaryNetTotal}</td>\\n    </tr>\\n    <tr>\\n	<td width=\\"400\\" style=\\"text-align: right\\">Сумма НДС:</td>\\n	<td width=\\"60\\" style=\\"text-align: right\\">{$summaryTax}</td>\\n    </tr>\\n</table>\\n\\n<p>\\nВсего наименований {$summaryTotalItems}, на сумму {$summaryGrandTotal} руб.<br/>\\n<span style=\\"font-weight: bold\\">{$summaryGrandTotalLiteral}</span>\\n</p>\\n\\n{/summary}\\n\\n{ending}\\n    <hr size=\\"2\\">\\n    <table border=\\"0\\">\\n    <tr>\\n	<td>Отпустил  __________ </td><td>Получил  __________ </td>\\n    </tr>\\n    </table>\\n{/ending}\\n\',50,0,\'P\'),(' . $this->db->getUniqueID('sp_templates') . ',\'Предложение\',\'Quotes\',\'\\n{header}\\n\\n<p align="right">{$orgLogo}</p>\\n<p style=\\"font-weight: bold\\">\\n{$orgName}<br/>\\nИНН {$orgInn}<br/>\\nКПП {$orgKpp}<br/>\\n{$orgBillingAddress}<br/>\\nТел.: {$orgPhone}<br/>\\nФакс: {$orgFax}<br/>\\n{$orgWebsite}\\n</p>\\n\\n<h1>Коммерческое предложение № {$quote_no}</h1>\\n<p>Действительно до: {$quote_validtill}</p>\\n<hr size=\\"2\\">\\n\\n<p style=\\"font-weight: bold\\">\\n{$account_accountname}<br/>\\n{$billingAddress}\\n</p>\\n{/header}\\n\\n{table_head}\\n<table border=\\"1\\" style=\\"font-size: 8pt\\" cellpadding=\\"2\\">\\n    <tr style=\\"text-align: center; font-weight: bold\\">\\n	<td width=\\"30\\">№</td>\\n	<td width=\\"260\\">Товары (работы, услуги)</td>\\n	<td width=\\"70\\">Ед.</td>\\n	<td width=\\"30\\">Кол-во</td>\\n	<td width=\\"70\\">Цена</td>\\n	<td width=\\"70\\">Сумма</td>\\n	</tr>\\n{/table_head}\\n\\n{table_row}\\n    <tr>\\n	<td width=\\"30\\">{$productNumber}</td>\\n	<td width=\\"260\\">{$productName}</td>\\n	<td width=\\"70\\">{$productUnits}</td>\\n	<td width=\\"30\\" style=\\"text-align: right\\">{$productQuantity}</td>\\n	<td width=\\"70\\" style=\\"text-align: right\\">{$productPrice}</td>\\n	<td width=\\"70\\" style=\\"text-align: right\\">{$productNetTotal}</td>\\n    </tr>\\n{/table_row}\\n\\n{summary}\\n</table>\\n<p></p>\\n<table border=\\"0\\">\\n    <tr>\\n	<td width=\\"460\\" style=\\"text-align: right\\">Итого:</td>\\n	<td width=\\"70\\" style=\\"text-align: right\\">{$summaryNetTotal}</td>\\n    </tr>\\n    <tr>\\n	<td width=\\"460\\" style=\\"text-align: right\\">Сумма НДС:</td>\\n	<td width=\\"70\\" style=\\"text-align: right\\">{$summaryTax}</td>\\n    </tr>\\n</table>\\n\\n<p style=\\"font-weight: bold\\">\\nВсего: {$summaryGrandTotal} руб. ( {$summaryGrandTotalLiteral} )\\n</p>\\n\\n{/summary}\\n\\n{ending}\\n    <hr size=\\"2\\">\\n    <p>Руководитель предприятия  __________ ( {$orgDirector} ) <br/>\\n    </p>\\n{/ending}\\n\',100,0,\'P\'),(' . $this->db->getUniqueID('sp_templates') . ',\'Заказ на закупку\',\'PurchaseOrder\',\'{header}\\n<h1 style=\\"font-size: 14pt\\">Заказ на закупку № {$purchaseorder_no}</h1>\\n<hr>\\n<table border=\\"0\\" style=\\"font-size: 9pt\\">\\n<tr>\\n<td width=\\"80\\">Поставщик:</td><td width=\\"450\\"><span style=\\"font-weight: bold\\">{$vendor_vendorname}</span></td>\\n</tr>\\n<tr>\\n<td width=\\"80\\">Покупатель:</td><td width=\\"450\\"><span style=\\"font-weight: bold\\">{$orgName}</span></td>\\n</tr>\\n</table>\\n{/header}\\n{table_head}\\n<table border=\\"1\\" style=\\"font-size: 8pt\\" cellpadding=\\"2\\">\\n<tr style=\\"text-align: center; font-weight: bold\\">\\n<td width=\\"30\\">№</td>\\n<td width=\\"200\\">Товар</td>\\n<td width=\\"60\\" colspan=\\"2\\">Количество</td>\\n<td width=\\"60\\">Цена</td>\\n<td width=\\"60\\">Сумма</td>\\n</tr>\\n{/table_head}\\n{table_row}\\n<tr>\\n<td width=\\"30\\">{$productNumber}</td>\\n<td width=\\"200\\">{$productName}</td>\\n<td width=\\"30\\" style=\\"text-align: right\\">{$productQuantityInt}</td>\\n<td width=\\"30\\">{$productUnits}</td>\\n<td width=\\"60\\" style=\\"text-align: right\\">{$productPrice}</td>\\n<td width=\\"60\\" style=\\"text-align: right\\">{$productNetTotal}</td>\\n</tr>\\n{/table_row}\\n{summary}\\n</table>\\n<p></p>\\n<table border=\\"0\\" style=\\"font-weight: bold\\">\\n<tr>\\n<td width=\\"350\\" style=\\"text-align: right\\">Итого:</td>\\n<td width=\\"60\\" style=\\"text-align: right\\">{$summaryNetTotal}</td>\\n</tr>\\n<tr>\\n<td width=\\"350\\" style=\\"text-align: right\\">Сумма НДС:</td>\\n<td width=\\"60\\" style=\\"text-align: right\\">{$summaryTax}</td>\\n</tr>\\n</table>\\n<p>\\nВсего наименований {$summaryTotalItems}, на сумму {$summaryGrandTotal} руб.<br/>\\n<span style=\\"font-weight: bold\\">{$summaryGrandTotalLiteral}</span>\\n</p>\\n{/summary}\\n{ending}\\n{/ending}\',50,0,\'P\')', array());
        // SalesPlatform.ru end
        //Invoice Details -- END
        //users Details Starts Block 79,80,81
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'user_name','vtiger_users',1,'106','user_name','User Name',1,0,'',11,1,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'is_admin','vtiger_users',1,'156','is_admin','Admin',1,0,'',3,2,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'user_password','vtiger_users',1,'99','user_password','Password',1,0,'',30,3,{$userloginandroleblockid},4,'P~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'confirm_password','vtiger_users',1,'99','confirm_password','Confirm Password',1,0,'',30,5,{$userloginandroleblockid},4,'P~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'first_name','vtiger_users',1,'1','first_name','First Name',1,0,'',30,7,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'last_name','vtiger_users',1,'2','last_name','Last Name',1,0,'',30,9,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'roleid','vtiger_user2role',1,'98','roleid','Role',1,0,'',200,11,{$userloginandroleblockid},1,'V~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'email1','vtiger_users',1,'104','email1','Email',1,0,'',100,4,{$userloginandroleblockid},1,'E~M',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'status','vtiger_users',1,'115','status','Status',1,0,'',100,6,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'activity_view','vtiger_users',1,'16','activity_view','Default Activity View',1,0,'',100,12,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'lead_view','vtiger_users',1,'16','lead_view','Default Lead View',1,0,'',100,10,{$userloginandroleblockid},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'hour_format','vtiger_users',1,'116','hour_format','Calendar Hour Format',1,0,'',100,13,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'end_hour','vtiger_users',1,'116','end_hour','Day ends at',1,0,'',100,15,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'start_hour','vtiger_users',1,'116','start_hour','Day starts at',1,0,'',100,14,{$userloginandroleblockid},3,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'title','vtiger_users',1,'1','title','Title',1,0,'',50,1,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_work','vtiger_users',1,'11','phone_work','Office Phone',1,0,'',50,5,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'department','vtiger_users',1,'1','department','Department',1,0,'',50,3,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_mobile','vtiger_users',1,'11','phone_mobile','Mobile',1,0,'',50,7,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'reports_to_id','vtiger_users',1,'101','reports_to_id','Reports To',1,0,'',50,8,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_other','vtiger_users',1,'11','phone_other','Other Phone',1,0,'',50,11,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'email2','vtiger_users',1,'13','email2','Other Email',1,0,'',100,4,{$usermoreinfoblock},1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_fax','vtiger_users',1,'11','phone_fax','Fax',1,0,'',50,2,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'secondaryemail','vtiger_users',1,'13','secondaryemail','Secondary Email',1,0,'',100,6,{$usermoreinfoblock},1,'E~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'phone_home','vtiger_users',1,'11','phone_home','Home Phone',1,0,'',50,9,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'date_format','vtiger_users',1,'16','date_format','Date Format',1,0,'',30,12,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'signature','vtiger_users',1,'21','signature','Signature',1,0,'',250,13,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'description','vtiger_users',1,'21','description','Documents',1,0,'',250,14,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_street','vtiger_users',1,'21','address_street','Street Address',1,0,'',250,1,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_city','vtiger_users',1,'1','address_city','City',1,0,'',100,3,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_state','vtiger_users',1,'1','address_state','State',1,0,'',100,5,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_postalcode','vtiger_users',1,'1','address_postalcode','Postal Code',1,0,'',100,4,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'address_country','vtiger_users',1,'1','address_country','Country',1,0,'',100,2,{$useraddressblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values(29," . $this->db->getUniqueID("vtiger_field") . ",'accesskey','vtiger_users',1,3,'accesskey','Webservice Access Key',1,0,'',100,2,{$useradvanceblock},2,'V~O',1,null,'BAS',1);");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'time_zone','vtiger_users',1,'16','time_zone','Time Zone',1,0,'',200,15,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_id','vtiger_users',1,'117','currency_id','Currency',1,0,'',100,1,{$usercurrencyinfoblock},1,'I~O',1,null,'BAS',1)");
        //SalesPlatform.ru begin
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_grouping_pattern','vtiger_users',1,'16','currency_grouping_pattern','Digit Grouping Pattern',1,0,'123456789',100,2,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_decimal_separator','vtiger_users',1,'16','currency_decimal_separator','Decimal Separator',1,0,',',2,3,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        /*vtiger commented code
        		$this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_grouping_pattern','vtiger_users',1,'16','currency_grouping_pattern','Digit Grouping Pattern',1,0,'',100,2,$usercurrencyinfoblock,1,'V~O',1,null,'BAS',1)");
        		$this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_decimal_separator','vtiger_users',1,'16','currency_decimal_separator','Decimal Separator',1,0,'',2,3,$usercurrencyinfoblock,1,'V~O',1,null,'BAS',1)");
        		*/
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_grouping_separator','vtiger_users',1,'16','currency_grouping_separator','Digit Grouping Separator',1,0,'\\'',2,4,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        //$this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_grouping_separator','vtiger_users',1,'16','currency_grouping_separator','Digit Grouping Separator',1,0,'',2,4,$usercurrencyinfoblock,1,'V~O',1,null,'BAS',1)");
        //SalesPlatform.ru end
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'currency_symbol_placement','vtiger_users',1,'16','currency_symbol_placement','Symbol Placement',1,0,'',20,5,{$usercurrencyinfoblock},1,'V~O',1,null,'BAS',1)");
        //User Image Information
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'imagename','vtiger_users',1,'105','imagename','User Image',1,0,'',250,10,{$userblockid},1,'V~O',1,null,'BAS',1)");
        //added for internl_mailer
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'internal_mailer','vtiger_users',1,'56','internal_mailer','INTERNAL_MAIL_COMPOSER',1,0,'',50,15,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'theme','vtiger_users',1,'31','theme','Theme',1,0,'',100,16,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'language','vtiger_users',1,'32','language','Language',1,0,'',100,17,{$usermoreinfoblock},1,'V~O',1,null,'BAS',1)");
        $this->db->query("insert into vtiger_field values (29," . $this->db->getUniqueID("vtiger_field") . ",'reminder_interval','vtiger_users',1,'16','reminder_interval','Reminder Interval',1,0,'',100,1,{$useradvanceblock},1,'V~O',1,null,'BAS',1)");
        //user Details End
        // Updated Phone field uitype
        $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=" . getTabid('Leads'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='mobile' and tabid=" . getTabid('Contacts'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Leads'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Contacts'));
        $this->db->query("update vtiger_field set uitype='11' where fieldname='fax' and tabid=" . getTabid('Accounts'));
        // SalesPlatform.ru begin: Fix Users phone fields type
        $this->db->query("UPDATE vtiger_field SET uitype=11 WHERE columnname LIKE 'phone_%' and tabid=" . getTabid('Users'));
        // SalesPlatform.ru end
        $tab_field_array = array('Accounts' => array('accountname'), 'Contacts' => array('imagename'), 'Products' => array('imagename', 'product_id'), 'Invoice' => array('invoice_no', 'salesorder_id'), 'SalesOrder' => array('quote_id', 'salesorder_no'), 'PurchaseOrder' => array('purchaseorder_no'), 'Quotes' => array('quote_no'), 'HelpDesk' => array('filename'));
        foreach ($tab_field_array as $index => $value) {
            $tabid = getTabid($index);
            $this->db->pquery("UPDATE vtiger_field SET masseditable=0 WHERE tabid=? AND fieldname IN (" . generateQuestionMarks($value) . ")", array($tabid, $value));
        }
        //Emails field added here
        $email_Tabid = getTabid('Emails');
        $blockquery = "select blockid from vtiger_blocks where blocklabel = ?";
        $blockres = $this->db->pquery($blockquery, array('LBL_EMAIL_INFORMATION'));
        $blockid = $this->db->query_result($blockres, 0, 'blockid');
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'from_email','vtiger_emaildetails',1,12,'from_email','From',1,2,'',100,1,{$blockid},3,'V~M',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'to_email','vtiger_emaildetails',1,8,'saved_toid','To',1,2,'',100,2,{$blockid},1,'V~M',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'cc_email','vtiger_emaildetails',1,8,'ccmail','CC',1,2,'',1000,3,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'bcc_email','vtiger_emaildetails',1,8,'bccmail','BCC' ,1,2,'',1000,4,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'idlists','vtiger_emaildetails',1,357,'parent_id','Parent ID' ,1,2,'',1000,5,{$blockid},1,'V~O',3,NULL,'BAS',0)");
        $this->db->query("INSERT INTO vtiger_field values({$email_Tabid}," . $this->db->getUniqueID("vtiger_field") . ",'email_flag','vtiger_emaildetails',1,16,'email_flag','Email Flag' ,1,2,'',1000,6,{$blockid},3,'V~O',3,NULL,'BAS',0)");
        //Emails fields ends
        //The Entity Name for the modules are maintained in this table
        $this->db->query("insert into vtiger_entityname values(7,'Leads','vtiger_leaddetails','firstname,lastname','leadid','leadid')");
        $this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid','account_id')");
        $this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','firstname,lastname','contactid','contact_id')");
        $this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid','potential_id')");
        $this->db->query("insert into vtiger_entityname values(8,'Documents','vtiger_notes','title','notesid','notesid')");
        $this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid','ticketid')");
        $this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid','activityid')");
        $this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid','activityid')");
        $this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid','product_id')");
        $this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','first_name,last_name','id','id')");
        $this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid','invoiceid')");
        $this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid','quote_id')");
        $this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid','purchaseorderid')");
        $this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid','salesorder_id')");
        $this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid','vendor_id')");
        $this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid','pricebookid')");
        $this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid','campaignid')");
        $this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id','id')");
        // Insert End
        //Inserting values into org share action mapping
        $this->db->query("insert into vtiger_org_share_action_mapping values(0,'Public: Read Only')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(1,'Public: Read, Create/Edit')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(2,'Public: Read, Create/Edit, Delete')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(3,'Private')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(4,'Hide Details')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(5,'Hide Details and Add Events')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(6,'Show Details')");
        $this->db->query("insert into vtiger_org_share_action_mapping values(7,'Show Details and Add Events')");
        //Inserting for all vtiger_tabs
        // SalesPlatform.ru begin: Added sharing for Vendors
        $def_org_tabid = array(2, 4, 6, 7, 8, 9, 10, 13, 14, 16, 18, 20, 21, 22, 23, 26);
        //$def_org_tabid = Array(2, 4, 6, 7, 8, 9, 10, 13, 14, 16, 20, 21, 22, 23, 26);
        // SalesPlatform.ru end
        foreach ($def_org_tabid as $def_tabid) {
            $this->db->query("insert into vtiger_org_share_action2tab values(0," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(1," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(2," . $def_tabid . ")");
            $this->db->query("insert into vtiger_org_share_action2tab values(3," . $def_tabid . ")");
        }
        //Insert into default_org_sharingrule
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",2,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",4,2,2)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",6,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",7,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",9,3,1)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",13,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",16,3,2)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",20,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",21,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",22,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",23,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",26,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",8,2,0)");
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",14,2,0)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",10,3,0)");
        // Added sharing for Vendors
        $this->db->query("insert into vtiger_def_org_share values (" . $this->db->getUniqueID('vtiger_def_org_share') . ",18,2,0)");
        // SalesPlatform.ru end
        //Populating the DataShare Related Modules
        //Lead Related Module
        //Account Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,2)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,13)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,20)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,22)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",6,23)");
        //Potential Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",2,20)");
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",2,22)");
        //Quote Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",20,22)");
        //SO Related Module
        $this->db->query("insert into vtiger_datashare_relatedmodules values (" . $this->db->getUniqueID('vtiger_datashare_relatedmodules') . ",22,23)");
        // New Secutity End
        //insert into the vtiger_notificationscheduler vtiger_table
        //insert into related list vtiger_table
        //Inserting for vtiger_account related lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Potentials") . ",'get_opportunities',2,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Quotes") . ",'get_quotes',3,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("SalesOrder") . ",'get_salesorder',4,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Invoice") . ",'get_invoices',5,'Invoice',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Calendar") . ",'get_activities',6,'Activities',0,'add')");
        //added for the ticket4109
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Emails") . ",'get_emails',7,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Calendar") . ",'get_history',8,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Documents") . ",'get_attachments',9,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("HelpDesk") . ",'get_tickets',10,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Accounts") . "," . getTabid("Products") . ",'get_products',11,'Products',0,'select')");
        //Inserting Lead Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Emails") . ",'get_emails',2,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Documents") . ",'get_attachments',4,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Products") . ",'get_products',5,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Leads") . "," . getTabid("Campaigns") . ",'get_campaigns',6,'Campaigns',0,'select')");
        //Inserting for contact related lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Potentials") . ",'get_opportunities',1,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Calendar") . ",'get_activities',2,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Emails") . ",'get_emails',3,'Emails',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("HelpDesk") . ",'get_tickets',4,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Quotes") . ",'get_quotes',5,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("PurchaseOrder") . ",'get_purchase_orders',6,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("SalesOrder") . ",'get_salesorder',7,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Products") . ",'get_products',8,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Calendar") . ",'get_history',9,'Activity History',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Documents") . ",'get_attachments',10,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Contacts") . "," . getTabid("Campaigns") . ",'get_campaigns',11,'Campaigns',0,'select')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid('Contacts') . "," . getTabid('Invoice') . ",'get_invoices',12,'Invoice',0, 'add')");
        //Inserting Potential Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Contacts") . ",'get_contacts',2,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Products") . ",'get_products',3,'Products',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . ",0,'get_stage_history',4,'Sales Stage History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Documents") . ",'get_attachments',5,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Quotes") . ",'get_Quotes',6,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("SalesOrder") . ",'get_salesorder',7,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Calendar") . ",'get_history',8,'Activity History',0,'')");
        // SalesPlatform.ru begin: Added Potentials to Invoice relation
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Potentials") . "," . getTabid("Invoice") . ",'get_related_list',9,'Invoice',0,'add,select')");
        // SalesPlatform.ru end
        //Inserting Product Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("HelpDesk") . ",'get_tickets',1,'HelpDesk',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Quotes") . ",'get_quotes',4,'Quotes',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("PurchaseOrder") . ",'get_purchase_orders',5,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("SalesOrder") . ",'get_salesorder',6,'Sales Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Invoice") . ",'get_invoices',7,'Invoice',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("PriceBooks") . ",'get_product_pricebooks',8,'PriceBooks',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Leads") . ",'get_leads',9,'Leads',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Accounts") . ",'get_accounts',10,'Accounts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Contacts") . ",'get_contacts',11,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Potentials") . ",'get_opportunities',12,'Potentials',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Products") . ",'get_products',13,'Product Bundles',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Products") . "," . getTabid("Products") . ",'get_parent_products',14,'Parent Product',0,'')");
        //Inserting Emails Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'select,bulkmail')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . ",0,'get_users',2,'Users',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Emails") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        //Inserting HelpDesk Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Calendar") . ",'get_activities',1,'Activities',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . ",0,'get_ticket_history',3,'Ticket History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("HelpDesk") . "," . getTabid("Calendar") . ",'get_history',4,'Activity History',0,'')");
        //Inserting PriceBook Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PriceBooks") . ",14,'get_pricebook_products',2,'Products',0,'select')");
        // Inserting Vendor Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",14,'get_products',1,'Products',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",21,'get_purchase_orders',2,'Purchase Order',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . ",4,'get_contacts',3,'Contacts',0,'select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . "," . getTabid("Emails") . ",'get_emails',4,'Emails',0,'add')");
        // SalesPlatform.ru begin 5.4.0-201308
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . "," . getTabid("Documents") . ",'get_attachments',5,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . "," . getTabid("Calendar") . ",'get_activities',6,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Vendors") . "," . getTabid("Calendar") . ",'get_history',7,'Activity History',0,'add')");
        // SalesPlatform.ru end
        // Inserting Quotes Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . "," . getTabid("SalesOrder") . ",'get_salesorder',1,'Sales Order',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",9,'get_activities',2,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . "," . getTabid("Documents") . ",'get_attachments',3,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",9,'get_history',4,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Quotes") . ",0,'get_quotestagehistory',5,'Quote Stage History',0,'')");
        // Inserting Purchase order Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("PurchaseOrder") . ",0,'get_postatushistory',4,'PurchaseOrder Status History',0,'')");
        // Inserting Sales order Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Invoice") . ",'get_invoices',3,'Invoice',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . "," . getTabid("Calendar") . ",'get_history',4,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("SalesOrder") . ",0,'get_sostatushistory',5,'SalesOrder Status History',0,'')");
        // Inserting Invoice Related Lists
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . ",9,'get_activities',1,'Activities',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . "," . getTabid("Documents") . ",'get_attachments',2,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . "," . getTabid("Calendar") . ",'get_history',3,'Activity History',0,'')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Invoice") . ",0,'get_invoicestatushistory',4,'Invoice Status History',0,'')");
        // Inserting Activities Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Calendar") . ",0,'get_users',1,'Users',0,'')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Calendar") . ",4,'get_contacts',2,'Contacts',0,'')");
        // Inserting Campaigns Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Contacts") . ",'get_contacts',1,'Contacts',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Leads") . ",'get_leads',2,'Leads',0,'add,select')");
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . "," . getTabid("Potentials") . ",'get_opportunities',3,'Potentials',0,'add')");
        $this->db->query("insert into vtiger_relatedlists values(" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Campaigns") . ",9,'get_activities',4,'Activities',0,'add')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES (" . $this->db->getUniqueID('vtiger_relatedlists') . ", " . getTabid("Accounts") . ", " . getTabid("Campaigns") . ", 'get_campaigns', 13, 'Campaigns', 0, 'select')");
        $this->db->query("INSERT INTO vtiger_relatedlists VALUES (" . $this->db->getUniqueID('vtiger_relatedlists') . ", " . getTabid("Campaigns") . ", " . getTabid("Accounts") . ", 'get_accounts', 5, 'Accounts', 0, 'add,select')");
        // Inserting Faq's Related Lists
        $this->db->query("insert into vtiger_relatedlists values (" . $this->db->getUniqueID('vtiger_relatedlists') . "," . getTabid("Faq") . "," . getTabid("Documents") . ",'get_attachments',1,'Documents',0,'add,select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_TASK_NOTIFICATION_DESCRITPION',1,'Task Delay Notification','Tasks delayed beyond 24 hrs ','LBL_TASK_NOTIFICATION')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_BIG_DEAL_DESCRIPTION' ,1,'Big Deal notification','Success! A big deal has been won! ','LBL_BIG_DEAL')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_TICKETS_DESCRIPTION',1,'Pending Tickets notification','Ticket pending please ','LBL_PENDING_TICKETS')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_MANY_TICKETS_DESCRIPTION',1,'Too many tickets Notification','Too many tickets pending against this entity ','LBL_MANY_TICKETS')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_START_DESCRIPTION' ,1,'Support Start Notification','10','LBL_START_NOTIFICATION','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_SUPPORT_DESCRIPTION',1,'Support ending please','11','LBL_SUPPORT_NOTICIATION','select')");
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label,type) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_SUPPORT_DESCRIPTION_MONTH',1,'Support ending please','12','LBL_SUPPORT_NOTICIATION_MONTH','select')");
        // SalesPlatform.ru begin localization for Activity(call/meet)
        $this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Уведомление о событии','Напоминание о событии Календаря.','LBL_ACTIVITY_NOTIFICATION')");
        //$this->db->query("insert into vtiger_notificationscheduler(schedulednotificationid,schedulednotificationname,active,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_notificationscheduler") . ",'LBL_ACTIVITY_REMINDER_DESCRIPTION' ,1,'Activity Reminder Notification','This is a reminder notification for the Activity','LBL_ACTIVITY_NOTIFICATION')");
        // SalesPlatform.ru end
        //inserting actions for get_attachments
        $folderid = $this->db->getUniqueID("vtiger_attachmentsfolder");
        // SalesPlatform.ru begin localization for 5.4.0
        $this->db->query("insert into vtiger_attachmentsfolder values(" . $folderid . ",'По умолчанию','Это папка по умолчанию',1,1)");
        //$this->db->query("insert into vtiger_attachmentsfolder values(" . $folderid . ",'Default','This is a Default Folder',1,1)");
        // SalesPlatform.ru end
        //Inserting Inventory Notifications
        //vtiger-ru-fork 27.10.2010 Eugene Babiy
        $invoice_body = 'Уважаемый(ая) {HANDLER},

Текущий остаток товара "{PRODUCTNAME}" на нашем складе составляет {CURRENTSTOCK}. Просим вас обеспечить поставку необходимого количества товара, так как уровень запасов ниже минимального {REORDERLEVELVALUE}.

Примите это сообщение во внимание, так как Счет уже выставлен Клиенту.

Важность: Критическая

С уважением,
{CURRENTUSER}';
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'InvoiceNotification','{PRODUCTNAME} Stock Level is Low','" . $invoice_body . " ','InvoiceNotificationDescription')");
        $quote_body = 'Dear {HANDLER},

Quote is generated for {QUOTEQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}.

Severity: Minor

Thanks,
{CURRENTUSER}';
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'QuoteNotification','Quote given for {PRODUCTNAME}','" . $quote_body . " ','QuoteNotificationDescription')");
        $so_body = 'Dear {HANDLER},

SalesOrder is generated for {SOQUANTITY} units of {PRODUCTNAME}. The current stock of {PRODUCTNAME} in our warehouse is {CURRENTSTOCK}.

Please treat this information  with priority as the sales order is already generated.

Severity: Major

Thanks,
{CURRENTUSER}';
        $this->db->query("insert into vtiger_inventorynotification(notificationid,notificationname,notificationsubject,notificationbody,label) values (" . $this->db->getUniqueID("vtiger_inventorynotification") . ",'SalesOrderNotification','Сформирован Заказ на Продажу для {PRODUCTNAME}','" . $so_body . " ','SalesOrderNotificationDescription')");
        //insert into inventory terms and conditions table
        // SalesPlatform begin Localizaton
        $inv_tandc_text = '
 - Счет действителен на протяжении 14 календарных дней с даты его выставления, если другое не оговорено в письменной форме. Оплата счета Покупателем означает согласие с условиями поставки.';
        /*$inv_tandc_text = '
         - Unless otherwise agreed in writing by the supplier all invoices are payable within thirty (30) days of the date of invoice, in the currency of the invoice, drawn on a bank based in India or by such other method as is agreed in advance by the Supplier.
        
         - All prices are not inclusive of VAT which shall be payable in addition by the Customer at the applicable rate.';*/
        //SalesPlatform end;
        $this->db->query("insert into vtiger_inventory_tandc(id,type,tandc) values (" . $this->db->getUniqueID("vtiger_inventory_tandc") . ", 'Inventory', '" . $inv_tandc_text . "')");
        //insert into email template vtiger_table
        $body = 'Hello!   <br />
	<br />
	On behalf of the vtiger team,  I am pleased to announce the release of vtiger crm4.2 . This is a feature packed release including the mass email template handling, custom view feature, vtiger_reports feature and a host of other utilities. vtiger runs on all platforms.    <br />
        <br />
	Notable Features of vtiger are :   <br />
	<br />
	-Email Client Integration    <br />
	-Trouble Ticket Integration   <br />
	-Invoice Management Integration   <br />
	-Reports Integration   <br />
	-Portal Integration   <br />
	-Enhanced Word Plugin Support   <br />
	-Custom View Integration   <br />
	<br />
	Known Issues:   <br />
	-ABCD   <br />
	-EFGH   <br />
	-IJKL   <br />
	-MNOP   <br />
	-QRST';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Announcement for Release','Announcement for Release','Announcement of a release','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'name <br />
street, <br />
city, <br />
state, <br />
 zip) <br />
  <br />
 Dear <br />
 <br />
 Please check the following invoices that are yet to be paid by you: <br />
 <br />
 No. Date      Amount <br />
 1   1/1/01    $4000 <br />
 2   2/2//01   $5000 <br />
 3   3/3/01    $10000 <br />
 4   7/4/01    $23560 <br />
 <br />
 Kindly let us know if there are any issues that you feel are pending to be discussed. <br />
 We will be more than happy to give you a call. <br />
 We would like to continue our business with you.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Pending Invoices','Invoices Pending','Payment Due','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = ' Dear <br />
 <br />
Your proposal on the project XYZW has been reviewed by us <br />
and is acceptable in its entirety. <br />
 <br />
We are eagerly looking forward to this project <br />
and are pleased about having the opportunity to work <br />
together. We look forward to a long standing relationship <br />
with your esteemed firm. <br />
<br />
I would like to take this opportunity to invite you <br />
to a game of golf on Wednesday morning 9am at the <br />
Cuff Links Ground. We will be waiting for you in the <br />
Executive Lounge. <br />
<br />
Looking forward to seeing you there.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Acceptance Proposal','Acceptance Proposal','Acceptance of Proposal','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = ' The undersigned hereby acknowledges receipt and delivery of the goods. <br />
The undersigned will release the payment subject to the goods being discovered not satisfactory. <br />
<br />
Signed under seal this <date>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Goods received acknowledgement','Goods received acknowledgement','Acknowledged Receipt of Goods','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = ' Dear <br />
         We are in receipt of your order as contained in the <br />
   purchase order form.We consider this to be final and binding on both sides. <br />
If there be any exceptions noted, we shall consider them <br />
only if the objection is received within ten days of receipt of <br />
this notice. <br />
 <br />
Thank you for your patronage.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Accept Order','Accept Order','Acknowledgement/Acceptance of Order','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Dear <br />
 <br />
We are relocating our office to <br />
11111,XYZDEF Cross, <br />
UVWWX Circle <br />
The telephone number for this new location is (101) 1212-1328. <br />
<br />
Our Manufacturing Division will continue operations <br />
at 3250 Lovedale Square Avenue, in Frankfurt. <br />
<br />
We hope to keep in touch with you all. <br />
Please update your addressbooks.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Address Change','Change of Address','Address Change','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Dear <br />
<br />
Thank you for extending us the opportunity to meet with <br />
you and members of your staff. <br />
<br />
I know that John Doe serviced your account <br />
for many years and made many friends at your firm. He has personally <br />
discussed with me the deep relationship that he had with your firm. <br />
While his presence will be missed, I can promise that we will <br />
continue to provide the fine service that was accorded by <br />
John to your firm. <br />
<br />
I was genuinely touched to receive such fine hospitality. <br />
<br />
Thank you once again.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Follow Up','Follow Up','Follow Up of meeting','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Congratulations! <br />
<br />
The numbers are in and I am proud to inform you that our <br />
total sales for the previous quarter <br />
amounts to $100,000,00.00!. This is the first time <br />
we have exceeded the target by almost 30%. <br />
We have also beat the previous quarter record by a <br />
whopping 75%! <br />
<br />
Let us meet at Smoking Joe for a drink in the evening! <br />

C you all there guys!';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Target Crossed!','Target Crossed!','Fantastic Sales Spree!','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        $body = 'Dear <br />
<br />
Thank you for your confidence in our ability to serve you. <br />
We are glad to be given the chance to serve you.I look <br />
forward to establishing a long term partnership with you. <br />
Consider me as a friend. <br />
Should any need arise,please do give us a call.';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Thanks Note','Thanks Note','Note of thanks','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //Added for HTML Eemail templates..
        //for Customer Portal Login details
        //SalesPlatform.ru begin
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM<br /> </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Уважаемый(ая) $contact_name$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"> Выражаем вам благодарность за подключение услуги ежегодного сервисного обслуживания Vtiger CRM.<br />Далее приведена информация для регистрации на портале самообслуживания:</td>                                            
                                            </tr>
                                            <tr>
                                                <td align="center">
                                                <table width="75%" cellspacing="0" cellpadding="10" border="0" style="border: 2px solid rgb(180, 180, 179); background-color: rgb(226, 226, 225); font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal;">
                                                        <tr>
                                                            <td><br />ID Пользователя     : <font color="#990000"><strong> $login_name$</strong></font> </td>
                                                        </tr>
                                                        <tr>
                                                            <td>Пароль: <font color="#990000"><strong> $password$</strong></font> </td>
                                                        </tr>
                                                        <tr>
                                                            <td align="center"> <strong>  $URL$<br /> </strong> </td>
                                                        </tr>
                                                </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;"><strong>Примечание:</strong> Мы предлагаем вам изменить пароль после первой авторизации. <br /><br /> <strong><u>Справочная информация</u></strong><br />  <br /> После первой авторизации на портале самообслуживания вы можете воспользоваться документацией Vtiger CRM, расположенной во вкладке <strong>Документация(Documents)</strong>. Для ознакомления доступны следующие документы:<br />
                                                <ul>
                                                    <li>Руководство по установке (Windows и Linux ОС)<br /> </li>
                                                    <li>Руководство пользователя и администратора<br /> </li>
                                                    <li>Клиентский портал Vtiger CRM - Руководство пользователя<br /> </li>
                                                    <li>Vtiger CRM плагин для Outlook - Руководство пользователя<br /> </li>
                                                    <li>Vtiger CRM Office плагин - Руководство пользователя<br /> </li>
                                                    <li>Vtiger CRM дополнение Thunderbird - Руководство пользователя<br /> </li>
                                                    <li>Vtiger CRM Веб формы - Руководство пользователя<br /> </li>
                                                    <li>Vtiger CRM панель инструментов Firefox - Руководство пользователя<br /> </li>
                                                </ul>
                                                <br />  <br /> <strong><u>Базовые знания</u></strong><br /> <br /> Мы периодически обновляем часто задаваемые вопросы, основываясь на опыте наших клиентов. Вы можете получить доступ к последним статьям через вкладку <strong>ЧаВо(FAQ)</strong>.<br /> <br /> <strong><u>Vtiger CRM - Информация</u></strong><br /> <br /> Пожалуйста, предоставьте информацию о вашей текущей версии vtiger CRM и о особенностях вашей системы, чтобы мы могли дать вам рекомендации по увеличению производительности работы Vtiger CRM. Основываясь на особенностях вашей системы, мы сообщим вам о последних обновлениях Vtiger CRM.<br />  <br />			 Еще раз благодарим вас и желаем приятной работы с системой Vtiger CRM.<br /> </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />С уважением,</strong></td>                               
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">$support_team$ </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.salesplatform.ru">www.salesplatform.ru</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="left" style="background-color: rgb(27, 77, 140);"><br /> </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Регистрационная информация клиента','Регистрационная информация клиентского портала','Посылает регистрационную информацию портала клиенту','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //$this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Customer Login Details','Customer Portal Login Details','Send Portal login details to customer','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //SalesPlatform.ru end
        //for Support end notification before a week
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contacts-lastname$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">This is just a notification mail regarding your support end.<br /><span style="font-weight: bold;">Priority:</span> Urgent<br />Your Support is going to expire on next week<br />Please contact support@vtiger.com.<br /><br /><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="center"><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Sincerly</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">Support Team </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);" href="http://www.vtiger.com">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);" href="mailto:info@vtiger.com">info@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Support end notification before a week','VtigerCRM Support Notification','Send Notification mail to customer before a week of support end date','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //for Support end notification before a month
        $body = '<table width="700" cellspacing="0" cellpadding="0" border="0" align="center" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; text-decoration: none; background-color: rgb(122, 122, 254);">
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td width="50"> </td>
            <td>
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(255, 255, 255); font-weight: normal; line-height: 25px;">
                                <tr>
                                    <td align="center" rowspan="4">$logo$</td>
                                    <td align="center"> </td>
                                </tr>
                                <tr>
                                    <td align="left" style="background-color: rgb(27, 77, 140); font-family: Arial,Helvetica,sans-serif; font-size: 24px; color: rgb(255, 255, 255); font-weight: bolder; line-height: 35px;">vtiger CRM </td>
                                </tr>
                                <tr>
                                    <td align="right" style="padding-right: 100px;">The honest Open Source CRM </td>
                                </tr>
                                <tr>
                                    <td> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="0" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: normal; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
                                <tr>
                                    <td valign="top">
                                    <table width="100%" cellspacing="0" cellpadding="5" border="0">
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);"> </td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 14px; color: rgb(22, 72, 134); font-weight: bolder; line-height: 15px;">Dear $contacts-lastname$, </td>
                                            </tr>
                                            <tr>
                                                <td style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; text-align: justify; line-height: 20px;">This is just a notification mail regarding your support end.<br /><span style="font-weight: bold;">Priority:</span> Normal<br />Your Support is going to expire on next month.<br />Please contact support@vtiger.com<br /><br /><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="center"><br /></td>
                                            </tr>
                                            <tr>
                                                <td align="right"><strong style="padding: 2px; font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: bold;"><br /><br />Sincerly</strong></td>
                                            </tr>
                                            <tr>
                                                <td align="right" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; line-height: 20px;">Support Team </td>
                                            </tr>
                                            <tr>
                                                <td align="right"><a href="http://www.vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(66, 66, 253);">www.vtiger.com</a></td>
                                            </tr>
                                            <tr>
                                                <td> </td>
                                            </tr>
                                    </table>
                                    </td>
                                    <td width="1%" valign="top"> </td>
                                </tr>
                        </table>
                        </td>
                    </tr>
                    <tr>
                        <td>
                        <table width="100%" cellspacing="0" cellpadding="5" border="0" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; color: rgb(255, 255, 255); font-weight: normal; line-height: 15px; background-color: rgb(51, 51, 51);">
                                <tr>
                                    <td align="center">Shree Narayana Complex, No 11 Sarathy Nagar, Vijaya Nagar , Velachery, Chennai - 600 042 India </td>
                                </tr>
                                <tr>
                                    <td align="center">Telephone No: +91 - 44 - 4202 - 1990     Toll Free No: +1 877 788 4437</td>
                                </tr>
                                <tr>
                                    <td align="center">Email Id: <a href="mailto:info@vtiger.com" style="font-family: Arial,Helvetica,sans-serif; font-size: 12px; font-weight: bolder; text-decoration: none; color: rgb(255, 255, 255);">info@vtiger.com</a></td>
                                </tr>
                        </table>
                        </td>
                    </tr>
            </table>
            </td>
            <td width="50"> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
            <td> </td>
        </tr>
</table>';
        $this->db->query("insert into vtiger_emailtemplates(foldername,templatename,subject,description,body,deleted,templateid) values ('Public','Support end notification before a month','VtigerCRM Support Notification','Send Notification mail to customer before a month of support end date','" . $body . "',0," . $this->db->getUniqueID('vtiger_emailtemplates') . ")");
        //Insert into vtiger_organizationdetails vtiger_table
        $organizationId = $this->db->getUniqueID('vtiger_organizationdetails');
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_organizationdetails(organization_id,organizationname,address,city,state,country,code,phone,fax,website,logoname,inn,kpp,bankaccount,bankname,bankid,corraccount,director,bookkeeper,entrepreneur,entrepreneurreg) values ({$organizationId},'vtiger CRM','ул. Большая Монетная, 13','Санкт-Петербург','','Россия','190000','+78125556622','+78125556623','www.example.com','vtiger-crm-logo.png','7897658534','783432324','23853467893467893278', 'Банк Санкт-Петербург', '044092039', '154141561565165','Иванов И.И.','Кузьмина Л.И.','','')");
        //	$this->db->query("insert into vtiger_organizationdetails(organization_id,organizationname,address,city,state,country,code,phone,fax,website,logoname)
        //								values ($organizationId,'vtiger',' 40-41-42, Sivasundar Apartments, Flat D-II, Shastri Street, Velachery','Chennai',
        //										'Tamil Nadu','India','600 042','+91-44-5202-1990','+91-44-5202-1990','www.vtiger.com','vtiger-crm-logo.gif')");
        // SalesPlatform.ru end
        $this->db->query("insert into vtiger_actionmapping values(0,'Save',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'EditView',0)");
        $this->db->query("insert into vtiger_actionmapping values(2,'Delete',0)");
        $this->db->query("insert into vtiger_actionmapping values(3,'index',0)");
        $this->db->query("insert into vtiger_actionmapping values(4,'DetailView',0)");
        $this->db->query("insert into vtiger_actionmapping values(5,'Import',0)");
        $this->db->query("insert into vtiger_actionmapping values(6,'Export',0)");
        //$this->db->query("insert into vtiger_actionmapping values(7,'AddBusinessCard',0)");
        $this->db->query("insert into vtiger_actionmapping values(8,'Merge',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'VendorEditView',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'VendorDetailView',1)");
        $this->db->query("insert into vtiger_actionmapping values(0,'SaveVendor',1)");
        $this->db->query("insert into vtiger_actionmapping values(2,'DeleteVendor',1)");
        $this->db->query("insert into vtiger_actionmapping values(1,'PriceBookEditView',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'PriceBookDetailView',1)");
        $this->db->query("insert into vtiger_actionmapping values(0,'SavePriceBook',1)");
        $this->db->query("insert into vtiger_actionmapping values(2,'DeletePriceBook',1)");
        $this->db->query("insert into vtiger_actionmapping values(9,'ConvertLead',0)");
        $this->db->query("insert into vtiger_actionmapping values(1,'DetailViewAjax',1)");
        $this->db->query("insert into vtiger_actionmapping values(4,'TagCloud',1)");
        $this->db->query("insert into vtiger_actionmapping values(1,'QuickCreate',1)");
        $this->db->query("insert into vtiger_actionmapping values(3,'Popup',1)");
        $this->db->query("insert into vtiger_actionmapping values(10,'DuplicatesHandling',0)");
        //added by jeri for category view from db
        $this->db->query("insert into vtiger_parenttab values (1,'My Home Page',1,0)");
        $this->db->query("insert into vtiger_parenttab values (2,'Marketing',2,0)");
        $this->db->query("insert into vtiger_parenttab values (3,'Sales',3,0)");
        $this->db->query("insert into vtiger_parenttab values (4,'Support',4,0)");
        $this->db->query("insert into vtiger_parenttab values (5,'Analytics',5,0)");
        $this->db->query("insert into vtiger_parenttab values (6,'Inventory',6,0)");
        $this->db->query("insert into vtiger_parenttab values (7,'Tools',7,0)");
        $this->db->query("insert into vtiger_parenttab values (8,'Settings',8,0)");
        $this->db->query("insert into vtiger_parenttabrel values (1,9,2)");
        $this->db->query("insert into vtiger_parenttabrel values (1,28,4)");
        $this->db->query("insert into vtiger_parenttabrel values (1,3,1)");
        $this->db->query("insert into vtiger_parenttabrel values (3,7,1)");
        $this->db->query("insert into vtiger_parenttabrel values (3,6,2)");
        $this->db->query("insert into vtiger_parenttabrel values (3,4,3)");
        $this->db->query("insert into vtiger_parenttabrel values (3,2,4)");
        $this->db->query("insert into vtiger_parenttabrel values (3,20,5)");
        $this->db->query("insert into vtiger_parenttabrel values (3,22,6)");
        $this->db->query("insert into vtiger_parenttabrel values (3,23,7)");
        $this->db->query("insert into vtiger_parenttabrel values (3,19,8)");
        $this->db->query("insert into vtiger_parenttabrel values (3,8,9)");
        $this->db->query("insert into vtiger_parenttabrel values (4,13,1)");
        $this->db->query("insert into vtiger_parenttabrel values (4,15,2)");
        $this->db->query("insert into vtiger_parenttabrel values (4,6,3)");
        $this->db->query("insert into vtiger_parenttabrel values (4,4,4)");
        $this->db->query("insert into vtiger_parenttabrel values (4,8,5)");
        $this->db->query("insert into vtiger_parenttabrel values (5,1,2)");
        $this->db->query("insert into vtiger_parenttabrel values (5,25,1)");
        $this->db->query("insert into vtiger_parenttabrel values (6,14,1)");
        $this->db->query("insert into vtiger_parenttabrel values (6,18,2)");
        $this->db->query("insert into vtiger_parenttabrel values (6,19,3)");
        $this->db->query("insert into vtiger_parenttabrel values (6,21,4)");
        $this->db->query("insert into vtiger_parenttabrel values (6,22,5)");
        $this->db->query("insert into vtiger_parenttabrel values (6,20,6)");
        $this->db->query("insert into vtiger_parenttabrel values (6,23,7)");
        $this->db->query("insert into vtiger_parenttabrel values (7,24,1)");
        $this->db->query("insert into vtiger_parenttabrel values (7,27,2)");
        $this->db->query("insert into vtiger_parenttabrel values (7,8,3)");
        // SalesPlatform.ru begin
        $this->db->query("insert into vtiger_parenttabrel values (7,30,4)");
        // SalesPlatform.ru end
        $this->db->query("insert into vtiger_parenttabrel values (2,26,1)");
        $this->db->query("insert into vtiger_parenttabrel values (2,6,2)");
        $this->db->query("insert into vtiger_parenttabrel values (2,4,3)");
        $this->db->query("insert into vtiger_parenttabrel values (2,28,4)");
        $this->db->query("insert into vtiger_parenttabrel values (4,28,7)");
        $this->db->query("insert into vtiger_parenttabrel values (2,7,5)");
        $this->db->query("insert into vtiger_parenttabrel values (2,9,6)");
        $this->db->query("insert into vtiger_parenttabrel values (4,9,8)");
        $this->db->query("insert into vtiger_parenttabrel values (2,8,8)");
        $this->db->query("insert into vtiger_parenttabrel values (3,9,11)");
        //add settings page to database starts
        $this->addEntriesForSettings();
        //add settings page to database end
        //Added to populate the default inventory tax informations
        $vatid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $salesid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        $serviceid = $this->db->getUniqueID("vtiger_inventorytaxinfo");
        //vtiger-ru-fork 27.10.2010 Eugene Babiy
        $this->db->query("insert into vtiger_inventorytaxinfo values({$vatid},'tax" . $vatid . "','НДС','18','0')");
        //$this->db->query("insert into vtiger_inventorytaxinfo values($salesid,'tax".$salesid."','Sales','10.00','0')");
        //$this->db->query("insert into vtiger_inventorytaxinfo values($serviceid,'tax".$serviceid."','Service','12.50','0')");
        //After added these taxes we should add these taxes as columns in vtiger_inventoryproductrel table
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$vatid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$salesid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryproductrel add column tax{$serviceid} decimal(7,3) default NULL");
        //Added to handle picklist uniqueid for the picklist values
        //$this->db->query("insert into vtiger_picklistvalues_seq values(1)");
        //Added to populate the default Shipping & Hanlding tax informations
        $shvatid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $shsalesid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        $shserviceid = $this->db->getUniqueID("vtiger_shippingtaxinfo");
        //vtiger-ru-fork 27.10.2010 Eugene Babiy
        $this->db->query("insert into vtiger_shippingtaxinfo values({$shvatid},'shtax" . $shvatid . "','НДС','18','0')");
        //$this->db->query("insert into vtiger_shippingtaxinfo values($shsalesid,'shtax".$shsalesid."','Sales','10.00','0')");
        //$this->db->query("insert into vtiger_shippingtaxinfo values($shserviceid,'shtax".$shserviceid."','Service','12.50','0')");
        //After added these taxes we should add these taxes as columns in vtiger_inventoryshippingrel table
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shvatid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shsalesid} decimal(7,3) default NULL");
        $this->db->query("alter table vtiger_inventoryshippingrel add column shtax{$shserviceid} decimal(7,3) default NULL");
        //version file is included here because without including this file version cannot be get
        include 'vtigerversion.php';
        $this->db->query("insert into vtiger_version values(" . $this->db->getUniqueID('vtiger_version') . ",'" . $vtiger_current_version . "','" . $vtiger_current_version . "')");
        //Register default language English
        require_once 'vtlib/Vtiger/Language.php';
        $vtlanguage = new Vtiger_Language();
        $vtlanguage->register('en_us', 'US English', 'English', true, true, true);
        // vtiger-ru-fork 2010-10-27 22:29:43 Eugene Babiy
        $vtlanguage->register('ru_ru', 'RU Русский', 'Русский', true, true, true);
        $this->initWebservices();
        /**
         * Setup module sequence numbering.
         */
        $modseq = array('Leads' => 'ОБР_', 'Accounts' => 'КОНТР_', 'Campaigns' => 'КАМП_', 'Contacts' => 'КОНТАКТ_', 'Potentials' => 'СДЕЛКА_', 'HelpDesk' => 'ЗАЯВКА_', 'Quotes' => 'ПР_', 'SalesOrder' => '', 'PurchaseOrder' => 'ЗАК_', 'Invoice' => '', 'Products' => 'ТОВ_', 'Vendors' => 'ПОСТ_', 'PriceBooks' => 'КАТ_', 'Faq' => 'ЧаВо_', 'Documents' => 'ДОК_');
        foreach ($modseq as $modname => $prefix) {
            $this->addInventoryRows(array(array('semodule' => $modname, 'active' => '1', 'prefix' => $prefix, 'startid' => '1', 'curid' => '1')));
        }
        // Adding Sharing Types for Reports
        $this->db->query("insert into vtiger_reportfilters values(1,'Private')");
        $this->db->query("insert into vtiger_reportfilters values(2,'Public')");
        $this->db->query("insert into vtiger_reportfilters values(3,'Shared')");
        require 'modules/Utilities/Currencies.php';
        foreach ($currencies as $key => $value) {
            $this->db->query("insert into vtiger_currencies values(" . $this->db->getUniqueID("vtiger_currencies") . ",'{$key}','" . $value[0] . "','" . $value[1] . "')");
        }
        $this->addDefaultLeadMapping();
    }
Example #13
0
$taskManager->saveTask($task);
$task = $taskManager->createTask('VTEntityMethodTask', $helpDeskWorkflow->id);
$task->active = true;
$task->summary = 'Notify Related Customer on Ticket Change, which is not done from Portal';
$task->methodName = "NotifyParentOnTicketChange";
$taskManager->saveTask($task);
putMsg('Workflow "' . $helpDeskWorkflow->description . '" created!');
$delmods = array('EmailTemplates', 'Google');
foreach ($delmods as $module) {
    $mod = Vtiger_Module::getInstance($module);
    if ($mod) {
        $mod->deleteRelatedLists();
        $mod->deleteLinks();
        $mod->deinitWebservice();
        $mod->delete();
        echo "<b>Module {$module} EXTERMINATED!</b><br>";
    }
}
$delmods = array('ar_ae', 'sv_se', 'tr_tr', 'pl_pl', 'ro_ro', 'ru_ru');
require_once 'vtlib/Vtiger/Language.php';
foreach ($delmods as $prefix) {
    $languagePack = new Vtiger_Language();
    @$languagePack->deregister($prefix);
}
$insmods = array('CronTasks', 'ConfigEditor', 'PBXManager', 'cbupdater');
foreach ($insmods as $module) {
    $package = new Vtiger_Package();
    $rdo = $package->importManifest("modules/{$module}/manifest.xml");
}
$mod = Vtiger_Module::getInstance('ModTracker');
$mod->addLink('HEADERSCRIPT', 'ModTrackerCommon_JS', 'modules/ModTracker/ModTrackerCommon.js');
Example #14
0
/** This function returns the vtiger_field details for a given vtiger_fieldname.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $maxlength - maximum length of the vtiger_field
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $module_name - module name
 * Return type is an array
 */
function getOutputHtml($uitype, $fieldname, $fieldlabel, $maxlength, $col_fields, $generatedtype, $module_name, $mode = '', $typeofdata = null)
{
    global $log, $app_strings, $adb, $default_charset, $theme, $mod_strings, $current_user;
    $log->debug("Entering getOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $maxlength . "," . print_r($col_fields, true) . "," . $generatedtype . "," . $module_name . ") method ...");
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $fieldvalue = array();
    $final_arr = array();
    $value = $col_fields[$fieldname];
    $custfld = '';
    $ui_type[] = $uitype;
    $editview_fldname[] = $fieldname;
    // vtlib customization: Related type field
    if ($uitype == '10') {
        global $adb;
        $fldmod_result = $adb->pquery('SELECT relmodule, status FROM vtiger_fieldmodulerel WHERE fieldid=
			(SELECT fieldid FROM vtiger_field, vtiger_tab WHERE vtiger_field.tabid=vtiger_tab.tabid AND fieldname=? AND name=? and vtiger_field.presence in (0,2)) order by sequence', array($fieldname, $module_name));
        $entityTypes = array();
        $parent_id = $value;
        for ($index = 0; $index < $adb->num_rows($fldmod_result); ++$index) {
            $entityTypes[] = $adb->query_result($fldmod_result, $index, 'relmodule');
        }
        if (!empty($value)) {
            if ($adb->num_rows($fldmod_result) == 1) {
                $valueType = $adb->query_result($fldmod_result, 0, 0);
            } else {
                $valueType = getSalesEntityType($value);
            }
            $displayValueArray = getEntityName($valueType, $value);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
        } else {
            $displayValue = '';
            $valueType = '';
            $value = '';
        }
        $editview_label[] = array('options' => $entityTypes, 'selected' => $valueType, 'displaylabel' => getTranslatedString($fieldlabel, $module_name));
        $fieldvalue[] = array('displayvalue' => $displayValue, 'entityid' => $parent_id);
    } else {
        if ($uitype == 5 || $uitype == 6 || $uitype == 23) {
            $log->info("uitype is " . $uitype);
            if ($value == '') {
                //modified to fix the issue in trac(http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/1469)
                if ($fieldname != 'birthday' && $generatedtype != 2 && getTabid($module_name) != 14) {
                    $disp_value = getNewDisplayDate();
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 6) {
                    $curr_time = date('H:i', strtotime('+5 minutes'));
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    $curr_time = date('H:i', strtotime('+10 minutes'));
                }
                //Added to display the Contact - Support End Date as one year future instead of
                //today's date -- 30-11-2005
                if ($fieldname == 'support_end_date' && $_REQUEST['module'] == 'Contacts') {
                    $addyear = strtotime("+1 year");
                    $disp_value = DateTimeField::convertToUserFormat(date('Y-m-d', $addyear));
                } elseif ($fieldname == 'validtill' && $_REQUEST['module'] == 'Quotes') {
                    $disp_value = '';
                }
            } else {
                if ($uitype == 6) {
                    if ($col_fields['time_start'] != '' && ($module_name == 'Events' || $module_name == 'Calendar')) {
                        $curr_time = $col_fields['time_start'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+5 minutes'));
                    }
                }
                if (($module_name == 'Events' || $module_name == 'Calendar') && $uitype == 23) {
                    if ($col_fields['time_end'] != '') {
                        $curr_time = $col_fields['time_end'];
                        $value = $value . ' ' . $curr_time;
                    } else {
                        $curr_time = date('H:i', strtotime('+10 minutes'));
                    }
                }
                $disp_value = getValidDisplayDate($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            if (!empty($curr_time)) {
                if (($module_name == 'Events' || $module_name == 'Calendar') && ($uitype == 23 || $uitype == 6)) {
                    $curr_time = DateTimeField::convertToUserTimeZone($curr_time);
                    $curr_time = $curr_time->format('H:i');
                }
            } else {
                $curr_time = '';
            }
            if (empty($disp_value)) {
                $disp_value = '';
            }
            $fieldvalue[] = array($disp_value => $curr_time);
            if ($uitype == 5 || $uitype == 23) {
                if ($module_name == 'Events' && $uitype == 23) {
                    $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
                } else {
                    $fieldvalue[] = array($date_format => $current_user->date_format);
                }
            } else {
                $fieldvalue[] = array($date_format => $current_user->date_format . ' ' . $app_strings['YEAR_MONTH_DATE']);
            }
        } elseif ($uitype == 16) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $pickcount = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $value = decode_html($value);
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                }
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 1613) {
            require_once 'modules/PickList/PickListUtils.php';
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pickListResult = getAllowedPicklistModules();
            $options = array();
            $options[] = "";
            $pickcount = 0;
            $found = false;
            foreach ($pickListResult as $pKey => $pValue) {
                $value = decode_html($value);
                $pickListValue = decode_html($pValue);
                if ($value == trim($pickListValue)) {
                    $chk_val = "selected";
                    $pickcount++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                    $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                } else {
                    $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val);
                }
            }
            uasort($options, function ($a, $b) {
                return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1;
            });
            $fieldvalue[] = $options;
        } elseif ($uitype == 15 || $uitype == 33) {
            require_once 'modules/PickList/PickListUtils.php';
            $roleid = $current_user->roleid;
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $valueArr = explode("|##|", $value);
            foreach ($valueArr as $key => $value) {
                $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset));
            }
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), $valueArr)) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $options;
        } elseif ($uitype == 3313) {
            require_once 'modules/PickList/PickListUtils.php';
            $picklistValues = getAllowedPicklistModules();
            $valueArr = explode("|##|", $value);
            foreach ($valueArr as $key => $value) {
                $valueArr[$key] = trim(html_entity_decode($value, ENT_QUOTES, $default_charset));
            }
            $pickcount = 0;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), $valueArr)) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue, $pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue, $pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            uasort($options, function ($a, $b) {
                return strtolower($a[0]) < strtolower($b[0]) ? -1 : 1;
            });
            $fieldvalue[] = $options;
        } elseif ($uitype == 1024) {
            $options = array();
            $arr_evo = explode(' |##| ', $value);
            $roleid = $current_user->roleid;
            $subrole = getRoleSubordinates($roleid);
            $uservalues = array_merge($subrole, array($roleid));
            for ($i = 0; $i < sizeof($uservalues); $i++) {
                $currentValId = $uservalues[$i];
                $currentValName = getRoleName($currentValId);
                if (in_array(trim($currentValId), $arr_evo)) {
                    $chk_val = 'selected';
                } else {
                    $chk_val = '';
                }
                $options[] = array($currentValName, $currentValId, $chk_val);
            }
            $fieldvalue[] = $options;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 17) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 85) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 14) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 19 || $uitype == 20) {
            if (isset($_REQUEST['body'])) {
                $value = $_REQUEST['body'];
            }
            if ($fieldname == 'terms_conditions') {
                //Assign the value from focus->column_fields (if we create Invoice from SO the SO's terms and conditions will be loaded to Invoice's terms and conditions, etc.,)
                $value = $col_fields['terms_conditions'];
                //if the value is empty then only we should get the default Terms and Conditions
                if ($value == '' && $mode != 'edit') {
                    $value = getTermsandConditions();
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 21 || $uitype == 24) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 22) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 52 || $uitype == 77) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            global $current_user;
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($uitype == 52) {
                $combo_lbl_name = 'assigned_user_id';
            } elseif ($uitype == 77) {
                $combo_lbl_name = 'assigned_user_id1';
            }
            //Control will come here only for Products - Handler and Quotes - Inventory Manager
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            $fieldvalue[] = $users_combo;
        } elseif ($uitype == 53) {
            global $noof_group_rows;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            $assigned_user_id = empty($value) ? $current_user->id : $value;
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $assigned_user_id), $assigned_user_id);
                }
            }
            $fieldvalue[] = $users_combo;
            $fieldvalue[] = $groups_combo;
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            if (!isset($_REQUEST['convertmode']) || $_REQUEST['convertmode'] != 'update_quote_val' && $_REQUEST['convertmode'] != 'update_so_val') {
                if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                    $value = vtlib_purify($_REQUEST['account_id']);
                }
            }
            if ($value != '') {
                $account_name = getAccountName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $account_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 54) {
            $options = array();
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_groups";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "name");
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == 55 || $uitype == 255) {
            require_once 'modules/PickList/PickListUtils.php';
            if ($uitype == 255) {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'firstname', 'readwrite');
            }
            if ($uitype == 255 && $fieldpermission == '0') {
                $fieldvalue[] = '';
            } else {
                $fieldpermission = getFieldVisibilityPermission($module_name, $current_user->id, 'salutationtype', 'readwrite');
                if ($fieldpermission == '0') {
                    $roleid = $current_user->roleid;
                    $picklistValues = getAssignedPicklistValues('salutationtype', $roleid, $adb);
                    $pickcount = 0;
                    $salt_value = $col_fields["salutationtype"];
                    foreach ($picklistValues as $order => $pickListValue) {
                        if ($salt_value == trim($pickListValue)) {
                            $chk_val = "selected";
                            $pickcount++;
                        } else {
                            $chk_val = '';
                        }
                        if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                            $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                        } else {
                            $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                        }
                    }
                    if ($pickcount == 0 && $salt_value != '') {
                        $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $salt_value, 'selected');
                    }
                    $fieldvalue[] = $options;
                } else {
                    $fieldvalue[] = '';
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 59) {
            if ($_REQUEST['module'] == 'HelpDesk') {
                if (isset($_REQUEST['product_id']) & $_REQUEST['product_id'] != '') {
                    $value = $_REQUEST['product_id'];
                }
            } elseif (isset($_REQUEST['parent_id']) & $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $product_name = getProductName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $product_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 63) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($value == '') {
                $value = 1;
            }
            $options = array();
            $pick_query = "select * from vtiger_duration_minutes order by sortorderid";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $salt_value = $col_fields["duration_minutes"];
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, "duration_minutes");
                if ($salt_value == $pickListValue) {
                    $chk_val = "selected";
                } else {
                    $chk_val = '';
                }
                $options[$pickListValue] = $chk_val;
            }
            $fieldvalue[] = $value;
            $fieldvalue[] = $options;
        } elseif ($uitype == 64) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $date_format = parse_calendardate($app_strings['NTC_DATE_FORMAT']);
            $fieldvalue[] = $value;
        } elseif ($uitype == 156) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 56) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
        } elseif ($uitype == 57) {
            if ($value != '') {
                $displayValueArray = getEntityName('Contacts', $value);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                }
            } elseif (isset($_REQUEST['contact_id']) && $_REQUEST['contact_id'] != '') {
                if ($_REQUEST['module'] == 'Contacts' && ($fieldname = 'contact_id')) {
                    $contact_name = '';
                } else {
                    $value = $_REQUEST['contact_id'];
                    $displayValueArray = getEntityName('Contacts', $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                }
            }
            //Checking for contacts duplicate
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $contact_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 58) {
            if ($value != '') {
                $campaign_name = getCampaignName($value);
            } elseif (isset($_REQUEST['campaignid']) && $_REQUEST['campaignid'] != '') {
                if ($_REQUEST['module'] == 'Campaigns' && ($fieldname = 'campaignid')) {
                    $campaign_name = '';
                } else {
                    $value = $_REQUEST['campaignid'];
                    $campaign_name = getCampaignName($value);
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $campaign_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 61) {
            if ($value != '') {
                $assigned_user_id = $value;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if ($module_name == 'Emails' && $col_fields['record_id'] != '') {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                //to fix the issue in mail attachment on forwarding mails
                if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                    global $att_id_list;
                }
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $fieldvalue[$attachmentid] = '[ ' . $attachmentsname . ' ]';
                        }
                        if (isset($_REQUEST['forward']) && $_REQUEST['forward'] != '') {
                            $att_id_list .= $attachmentid . ';';
                        }
                    }
                }
            } else {
                if ($col_fields['record_id'] != '') {
                    $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                    if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                    }
                }
                if ($value != '') {
                    $filename = ' [ ' . $value . ' ]';
                }
                if ($filename != '') {
                    $fieldvalue[] = $filename;
                }
                if ($value != '') {
                    $fieldvalue[] = $value;
                }
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 28) {
            if ($col_fields['record_id'] != '') {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $value = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
            }
            if ($value != '' && $module_name != 'Documents') {
                $filename = ' [ ' . $value . ' ]';
            } elseif ($value != '' && $module_name == 'Documents') {
                $filename = $value;
            }
            if ($filename != '') {
                $fieldvalue[] = $filename;
            }
            if ($value != '') {
                $fieldvalue[] = $value;
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
        } elseif ($uitype == 69) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($col_fields['record_id'] != "") {
                if ($module_name == 'Products') {
                    $query = 'select vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name ,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                    $params = array($col_fields['record_id']);
                } else {
                    if ($module_name == 'Contacts') {
                        $imageattachment = 'Image';
                    } else {
                        $imageattachment = 'Attachment';
                    }
                    $query = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t\t from vtiger_attachments\n\t\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_attachments.attachmentsid\n\t\t\t\t where vtiger_crmentity.setype='{$module_name} {$imageattachment}'\n\t\t\t\t  and vtiger_attachments.name = ?\n\t\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                    $params = array($col_fields[$fieldname], $col_fields['record_id']);
                }
                $result_image = $adb->pquery($query, $params);
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (is_array($image_array)) {
                    for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                        $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr] . $image_id_array[$img_itr] . "_", "orgname" => $image_orgname_array[$img_itr]);
                    }
                } else {
                    $fieldvalue[] = '';
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 62) {
            if (isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
            }
            if (isset($_REQUEST['account_id']) && $_REQUEST['account_id'] != '') {
                $parent_module = "Accounts";
                $value = $_REQUEST['account_id'];
            }
            if ($parent_module != 'Contacts') {
                if ($parent_module == "Leads") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $lead_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } elseif ($parent_module == "Potentials") {
                    $sql = "select * from vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "potentialname");
                    $potential_selected = "selected";
                } elseif ($parent_module == "Products") {
                    $sql = "select * from vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "productname");
                    $product_selected = "selected";
                } elseif ($parent_module == "PurchaseOrder") {
                    $sql = "select * from vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $porder_selected = "selected";
                } elseif ($parent_module == "SalesOrder") {
                    $sql = "select * from vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $sorder_selected = "selected";
                } elseif ($parent_module == "Invoice") {
                    $sql = "select * from vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $invoice_selected = "selected";
                } elseif ($parent_module == "Quotes") {
                    $sql = "select * from vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "subject");
                    $quote_selected = "selected";
                } elseif ($parent_module == "HelpDesk") {
                    $sql = "select * from vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "title");
                    $ticket_selected = "selected";
                }
            }
            $editview_label[] = array($app_strings['COMBO_LEADS'], $app_strings['COMBO_ACCOUNTS'], $app_strings['COMBO_POTENTIALS'], $app_strings['COMBO_PRODUCTS'], $app_strings['COMBO_INVOICES'], $app_strings['COMBO_PORDER'], $app_strings['COMBO_SORDER'], $app_strings['COMBO_QUOTES'], $app_strings['COMBO_HELPDESK']);
            $editview_label[] = array($lead_selected, $account_selected, $potential_selected, $product_selected, $invoice_selected, $porder_selected, $sorder_selected, $quote_selected, $ticket_selected);
            $editview_label[] = array("Leads&action=Popup", "Accounts&action=Popup", "Potentials&action=Popup", "Products&action=Popup", "Invoice&action=Popup", "PurchaseOrder&action=Popup", "SalesOrder&action=Popup", "Quotes&action=Popup", "HelpDesk&action=Popup");
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 66) {
            if (!empty($_REQUEST['parent_id'])) {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if (!empty($value)) {
                $parent_module = getSalesEntityType($value);
                if ($parent_module != "Contacts") {
                    $entity_names = getEntityName($parent_module, $value);
                    $parent_name = $entity_names[$value];
                    $fieldvalue[] = $parent_name;
                    $fieldvalue[] = $value;
                }
            }
            // Check for vtiger_activity type if task orders to be added in select option
            $act_mode = $_REQUEST['activity_mode'];
            $parentModulesList = array('Leads' => $app_strings['COMBO_LEADS'], 'Accounts' => $app_strings['COMBO_ACCOUNTS'], 'Potentials' => $app_strings['COMBO_POTENTIALS'], 'HelpDesk' => $app_strings['COMBO_HELPDESK'], 'Campaigns' => $app_strings['COMBO_CAMPAIGNS'], 'Vendors' => $app_strings['COMBO_VENDORS']);
            if ($act_mode == "Task") {
                $parentModulesList['Quotes'] = $app_strings['COMBO_QUOTES'];
                $parentModulesList['PurchaseOrder'] = $app_strings['COMBO_PORDER'];
                $parentModulesList['SalesOrder'] = $app_strings['COMBO_SORDER'];
                $parentModulesList['Invoice'] = $app_strings['COMBO_INVOICES'];
            }
            $parentModuleNames = array_keys($parentModulesList);
            $parentModuleLabels = array_values($parentModulesList);
            $editview_label[0] = $parentModuleLabels;
            $editview_label[1] = array_fill(0, count($parentModulesList), '');
            $selectedModuleIndex = array_search($parent_module, $parentModuleNames);
            if ($selectedModuleIndex > -1) {
                $editview_label[1][$selectedModuleIndex] = 'selected';
            }
            $parentModulePopupUrl = array();
            foreach ($parentModuleNames as $parentModule) {
                $parentModulePopupUrl[] = $parentModule . '&action=Popup';
            }
            $editview_label[2] = $parentModulePopupUrl;
        } elseif ($uitype == 357) {
            $pmodule = $_REQUEST['pmodule'];
            if (empty($pmodule)) {
                $pmodule = $_REQUEST['par_module'];
            }
            if ($pmodule == 'Contacts') {
                $contact_selected = 'selected';
            } elseif ($pmodule == 'Accounts') {
                $account_selected = 'selected';
            } elseif ($pmodule == 'Leads') {
                $lead_selected = 'selected';
            } elseif ($pmodule == 'Vendors') {
                $vendor_selected = 'selected';
            } elseif ($pmodule == 'Users') {
                $user_selected = 'selected';
            } elseif ($pmodule == 'Project') {
                $project_selected = 'selected';
            } elseif ($pmodule == 'ProjectTask') {
                $projecttask_selected = 'selected';
            } elseif ($pmodule == 'Potentials') {
                $potentials_selected = 'selected';
            } elseif ($pmodule == 'HelpDesk') {
                $helpdesk_selected = 'selected';
            }
            if (isset($_REQUEST['emailids']) && $_REQUEST['emailids'] != '') {
                $parent_id = $_REQUEST['emailids'];
                $parent_name = '';
                $myids = explode("|", $parent_id);
                for ($i = 0; $i < count($myids) - 1; $i++) {
                    $realid = explode("@", $myids[$i]);
                    $entityid = $realid[0];
                    $nemail = count($realid);
                    if ($pmodule == 'Accounts') {
                        require_once 'modules/Accounts/Accounts.php';
                        $myfocus = new Accounts();
                        $myfocus->retrieve_entity_info($entityid, "Accounts");
                        $fullname = br2nl($myfocus->column_fields['accountname']);
                        $account_selected = 'selected';
                    } elseif ($pmodule == 'Contacts') {
                        require_once 'modules/Contacts/Contacts.php';
                        $myfocus = new Contacts();
                        $myfocus->retrieve_entity_info($entityid, "Contacts");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $contact_selected = 'selected';
                    } elseif ($pmodule == 'Leads') {
                        require_once 'modules/Leads/Leads.php';
                        $myfocus = new Leads();
                        $myfocus->retrieve_entity_info($entityid, "Leads");
                        $fname = br2nl($myfocus->column_fields['firstname']);
                        $lname = br2nl($myfocus->column_fields['lastname']);
                        $fullname = $lname . ' ' . $fname;
                        $lead_selected = 'selected';
                    } elseif ($pmodule == 'Project') {
                        require_once 'modules/Project/Project.php';
                        $myfocus = new Project();
                        $myfocus->retrieve_entity_info($entityid, "Project");
                        $fname = br2nl($myfocus->column_fields['projectname']);
                        $lname = br2nl($myfocus->column_fields['projectid']);
                        $fullname = $fname;
                        $project_selected = 'selected';
                    } elseif ($pmodule == 'ProjectTask') {
                        require_once 'modules/ProjectTask/ProjectTask.php';
                        $myfocus = new ProjectTask();
                        $myfocus->retrieve_entity_info($entityid, "ProjectTask");
                        $fname = br2nl($myfocus->column_fields['projecttaskname']);
                        $lname = br2nl($myfocus->column_fields['projecttaskid']);
                        $fullname = $fname;
                        $projecttask_selected = 'selected';
                    } elseif ($pmodule == 'Potentials') {
                        require_once 'modules/Potentials/Potentials.php';
                        $myfocus = new Potentials();
                        $myfocus->retrieve_entity_info($entityid, "Potentials");
                        $fname = br2nl($myfocus->column_fields['potentialname']);
                        $lname = br2nl($myfocus->column_fields['potentialid']);
                        $fullname = $fname;
                        $potentials_selected = 'selected';
                    } elseif ($pmodule == 'HelpDesk') {
                        require_once 'modules/HelpDesk/HelpDesk.php';
                        $myfocus = new HelpDesk();
                        $myfocus->retrieve_entity_info($entityid, "HelpDesk");
                        $fname = br2nl($myfocus->column_fields['title']);
                        $lname = br2nl($myfocus->column_fields['ticketid']);
                        $fullname = $fname;
                        $helpdesk_selected = 'selected';
                    }
                    for ($j = 1; $j < $nemail; $j++) {
                        $querystr = 'select columnname from vtiger_field where fieldid=? and vtiger_field.presence in (0,2)';
                        $result = $adb->pquery($querystr, array($realid[$j]));
                        $temp = $adb->query_result($result, 0, 'columnname');
                        $temp1 = br2nl($myfocus->column_fields[$temp]);
                        //Modified to display the entities in red which don't have email id
                        if (!empty($temp_parent_name) && strlen($temp_parent_name) > 150) {
                            $parent_name .= '<br>';
                            $temp_parent_name = '';
                        }
                        if ($temp1 != '') {
                            $parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                            $temp_parent_name .= $fullname . '&lt;' . $temp1 . '&gt;; ';
                        } else {
                            $parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                            $temp_parent_name .= "<b style='color:red'>" . $fullname . '&lt;' . $temp1 . '&gt;; ' . "</b>";
                        }
                    }
                }
            } else {
                if ($_REQUEST['record'] != '' && $_REQUEST['record'] != NULL) {
                    $parent_name = '';
                    $parent_id = '';
                    $myemailid = $_REQUEST['record'];
                    $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                    $myresult = $adb->pquery($mysql, array($myemailid));
                    $mycount = $adb->num_rows($myresult);
                    if ($mycount > 0) {
                        for ($i = 0; $i < $mycount; $i++) {
                            $mycrmid = $adb->query_result($myresult, $i, 'crmid');
                            $parent_module = getSalesEntityType($mycrmid);
                            if ($parent_module == "Leads") {
                                $sql = "select firstname,lastname,email from vtiger_leaddetails where leadid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Leads");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $lead_selected = 'selected';
                            } elseif ($parent_module == "Contacts") {
                                $sql = "select * from vtiger_contactdetails where contactid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $full_name = getFullNameFromQResult($result, 0, "Contacts");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $full_name . '<' . $myemail . '>; ';
                                $contact_selected = 'selected';
                            } elseif ($parent_module == "Accounts") {
                                $sql = "select * from vtiger_account where accountid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "accountname");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $account_selected = 'selected';
                            } elseif ($parent_module == "Users") {
                                $sql = "select user_name,email1 from vtiger_users where id=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $account_name = $adb->query_result($result, 0, "user_name");
                                $myemail = $adb->query_result($result, 0, "email1");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $account_name . '<' . $myemail . '>; ';
                                $user_selected = 'selected';
                            } elseif ($parent_module == "Vendors") {
                                $sql = "select * from vtiger_vendor where vendorid=?";
                                $result = $adb->pquery($sql, array($mycrmid));
                                $vendor_name = $adb->query_result($result, 0, "vendorname");
                                $myemail = $adb->query_result($result, 0, "email");
                                $parent_id .= $mycrmid . '@0|';
                                //make it such that the email adress sent is remebered and only that one is retrived
                                $parent_name .= $vendor_name . '<' . $myemail . '>; ';
                                $vendor_selected = 'selected';
                            }
                        }
                    }
                }
                $custfld .= '<td width="20%" class="dataLabel">' . $app_strings['To'] . '&nbsp;</td>';
                $custfld .= '<td width="90%" colspan="3"><input name="parent_id" type="hidden" value="' . $parent_id . '"><textarea readonly name="parent_name" cols="70" rows="2">' . $parent_name . '</textarea>&nbsp;<select name="parent_type" >';
                $custfld .= '<OPTION value="Contacts" selected>' . $app_strings['COMBO_CONTACTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Accounts" >' . $app_strings['COMBO_ACCOUNTS'] . '</OPTION>';
                $custfld .= '<OPTION value="Leads" >' . $app_strings['COMBO_LEADS'] . '</OPTION>';
                $custfld .= '<OPTION value="Vendors" >' . $app_strings['COMBO_VENDORS'] . '</OPTION></select><img src="' . vtiger_imageurl('select.gif', $theme) . '" alt="Select" title="Select" LANGUAGE=javascript onclick=\'$log->debug("Exiting getOutputHtml method ..."); return window.open("index.php?module="+ document.EditView.parent_type.value +"&action=Popup&popuptype=set_$log->debug("Exiting getOutputHtml method ..."); return_emails&form=EmailEditView&form_submit=false","test","width=600,height=400,resizable=1,scrollbars=1,top=150,left=200");\' align="absmiddle" style=\'cursor:hand;cursor:pointer\'>&nbsp;<input type="image" src="' . vtiger_imageurl('clear_field.gif', $theme) . '" alt="Clear" title="Clear" LANGUAGE=javascript onClick="this.form.parent_id.value=\'\';this.form.parent_name.value=\'\';$log->debug("Exiting getOutputHtml method ..."); return false;" align="absmiddle" style=\'cursor:hand;cursor:pointer\'></td>';
                $editview_label[] = array('Contacts' => $contact_selected, 'Accounts' => $account_selected, 'Vendors' => $vendor_selected, 'Leads' => $lead_selected, 'Users' => $user_selected);
                $fieldvalue[] = $parent_name;
                $fieldvalue[] = $parent_id;
            }
        } elseif ($uitype == 68) {
            if (empty($value) && isset($_REQUEST['parent_id']) && $_REQUEST['parent_id'] != '') {
                $value = vtlib_purify($_REQUEST['parent_id']);
            }
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $parent_name = $field_value;
                        }
                    }
                    $contact_selected = "selected";
                } elseif ($parent_module == "Accounts") {
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $parent_name = $adb->query_result($result, 0, "accountname");
                    $account_selected = "selected";
                } else {
                    $parent_name = "";
                    $value = "";
                }
            }
            $editview_label[0] = array();
            $editview_label[1] = array();
            $editview_label[2] = array();
            if (vtlib_isModuleActive('Accounts')) {
                array_push($editview_label[0], $app_strings['COMBO_ACCOUNTS']);
                array_push($editview_label[1], $account_selected);
                array_push($editview_label[2], "Accounts");
            }
            if (vtlib_isModuleActive('Contacts')) {
                array_push($editview_label[0], $app_strings['COMBO_CONTACTS']);
                array_push($editview_label[1], $contact_selected);
                array_push($editview_label[2], "Contacts");
            }
            $fieldvalue[] = $parent_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 9 || $uitype == 7) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fldrs = $adb->pquery('select typeofdata from vtiger_field
			where vtiger_field.fieldname=? and vtiger_field.tabid=?', array($fieldname, getTabid($module_name)));
            $typeofdata = $adb->query_result($fldrs, 0, 0);
            $typeinfo = explode('~', $typeofdata);
            if ($typeinfo[0] == 'I') {
                $fieldvalue[] = $value;
            } else {
                $currencyField = new CurrencyField($value);
                $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata);
                $currencyField->initialize($current_user);
                $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces()));
                $fieldvalue[] = $currencyField->getDisplayValue(null, false, true);
            }
        } elseif ($uitype == 71 || $uitype == 72) {
            $currencyField = new CurrencyField($value);
            // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
            if ($col_fields['record_id'] != '' && $uitype == 72) {
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module_name));
                    $currencySymbol = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $currencySymbol = $currency_info['currency_symbol'];
                }
                $fieldvalue[] = $currencyField->getDisplayValue(null, true);
            } else {
                $decimals = CurrencyField::getDecimalsFromTypeOfData($typeofdata);
                $currencyField->initialize($current_user);
                $currencyField->setNumberofDecimals(min($decimals, $currencyField->getCurrencyDecimalPlaces()));
                $fieldvalue[] = $currencyField->getDisplayValue(null, false, true);
                $currencySymbol = $currencyField->getCurrencySymbol();
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name) . ': (' . $currencySymbol . ')';
        } elseif ($uitype == 75 || $uitype == 81) {
            if ($value != '') {
                $vendor_name = getVendorName($value);
            } elseif (isset($_REQUEST['vendor_id']) && $_REQUEST['vendor_id'] != '') {
                $value = $_REQUEST['vendor_id'];
                $vendor_name = getVendorName($value);
            }
            $pop_type = 'specific';
            if ($uitype == 81) {
                $pop_type = 'specific_vendor_address';
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $vendor_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 76) {
            if ($value != '') {
                $potential_name = getPotentialName($value);
            } elseif (isset($_REQUEST['potential_id']) && $_REQUEST['potential_id'] != '') {
                $value = $_REQUEST['potental_id'];
                $potential_name = getPotentialName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $potential_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 78) {
            if ($value != '') {
                $quote_name = getQuoteName($value);
            } elseif (isset($_REQUEST['quote_id']) && $_REQUEST['quote_id'] != '') {
                $value = $_REQUEST['quote_id'];
                $potential_name = getQuoteName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $quote_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 79) {
            if ($value != '') {
                $purchaseorder_name = getPoName($value);
            } elseif (isset($_REQUEST['purchaseorder_id']) && $_REQUEST['purchaseorder_id'] != '') {
                $value = $_REQUEST['purchaseorder_id'];
                $purchaseorder_name = getPoName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $purchaseorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 80) {
            if ($value != '') {
                $salesorder_name = getSoName($value);
            } elseif (isset($_REQUEST['salesorder_id']) && $_REQUEST['salesorder_id'] != '') {
                $value = $_REQUEST['salesorder_id'];
                $salesorder_name = getSoName($value);
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $salesorder_name;
            $fieldvalue[] = $value;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            if ($value != '') {
                $SET_REM = 'CHECKED';
            } else {
                $SET_REM = '';
            }
            $rem_days = floor($col_fields[$fieldname] / (24 * 60));
            $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60);
            $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60;
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $day_options = getReminderSelectOption(0, 31, 'remdays', $rem_days);
            $hr_options = getReminderSelectOption(0, 23, 'remhrs', $rem_hrs);
            $min_options = getReminderSelectOption(10, 59, 'remmin', $rem_min);
            $fieldvalue[] = array(array(0, 32, 'remdays', getTranslatedString('LBL_DAYS', 'Calendar'), $rem_days), array(0, 24, 'remhrs', getTranslatedString('LBL_HOURS', 'Calendar'), $rem_hrs), array(10, 60, 'remmin', getTranslatedString('LBL_MINUTES', 'Calendar') . '&nbsp;&nbsp;' . getTranslatedString('LBL_BEFORE_EVENT', 'Calendar'), $rem_min));
            $fieldvalue[] = array($SET_REM, getTranslatedString('LBL_YES'), getTranslatedString('LBL_NO'));
            $SET_REM = '';
        } elseif ($uitype == 115) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($value == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 116 || $uitype == 117) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($value == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $fieldvalue[] = $options;
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 98) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = getRoleName($value);
            $fieldvalue[] = $is_admin;
        } elseif ($uitype == 105) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if (isset($col_fields['record_id']) && $col_fields['record_id'] != '') {
                $query = "select vtiger_attachments.path, vtiger_attachments.name from vtiger_contactdetails left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_contactdetails.contactid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid where vtiger_contactdetails.imagename=vtiger_attachments.name and contactid=?";
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_array[] = $adb->query_result($result_image, $image_iter, 'name');
                    $image_path_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
            }
            if (is_array($image_array)) {
                for ($img_itr = 0; $img_itr < count($image_array); $img_itr++) {
                    $fieldvalue[] = array('name' => $image_array[$img_itr], 'path' => $image_path_array[$img_itr]);
                }
            } else {
                $fieldvalue[] = '';
            }
        } elseif ($uitype == 101) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = getOwnerName($value);
            $fieldvalue[] = $value;
        } elseif ($uitype == 26) {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $folderid = $col_fields['folderid'];
            $foldername_query = 'select foldername from vtiger_attachmentsfolder where folderid = ?';
            $res = $adb->pquery($foldername_query, array($folderid));
            $foldername = $adb->query_result($res, 0, 'foldername');
            if ($foldername != '' && $folderid != '') {
                $fldr_name[$folderid] = $foldername;
            }
            $sql = "select foldername,folderid from vtiger_attachmentsfolder order by foldername";
            $res = $adb->pquery($sql, array());
            for ($i = 0; $i < $adb->num_rows($res); $i++) {
                $fid = $adb->query_result($res, $i, "folderid");
                $fldr_name[$fid] = $adb->query_result($res, $i, "foldername");
            }
            $fieldvalue[] = $fldr_name;
        } elseif ($uitype == 27) {
            if ($value == 'E') {
                $external_selected = "selected";
                $filename = $col_fields['filename'];
            } else {
                $internal_selected = "selected";
                $filename = $col_fields['filename'];
            }
            $editview_label[] = array(getTranslatedString('Internal'), getTranslatedString('External'));
            $editview_label[] = array($internal_selected, $external_selected);
            $editview_label[] = array("I", "E");
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $fieldvalue[] = $value;
            $fieldvalue[] = $filename;
        } elseif ($uitype == '31') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($value == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $fieldvalue[] = $options;
        } elseif ($uitype == '32') {
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            $options = array();
            $languageList = Vtiger_Language::getAll();
            foreach ($languageList as $prefix => $label) {
                if ($value == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $fieldvalue[] = $options;
        } else {
            //Added condition to set the subject if click Reply All from web mail
            if ($_REQUEST['module'] == 'Emails' && $_REQUEST['mg_subject'] != '') {
                $value = $_REQUEST['mg_subject'];
            }
            $editview_label[] = getTranslatedString($fieldlabel, $module_name);
            if ($fieldname == 'fileversion') {
                if (empty($value)) {
                    $value = '';
                } else {
                    $fieldvalue[] = $value;
                }
            } else {
                $fieldvalue[] = $value;
            }
        }
    }
    // Mike Crowe Mod --------------------------------------------------------force numerics right justified.
    if (!preg_match("/id=/i", $custfld)) {
        $custfld = preg_replace("/<input/iS", "<input id='{$fieldname}' ", $custfld);
    }
    if (in_array($uitype, array(71, 72, 7, 9, 90))) {
        $custfld = preg_replace("/<input/iS", "<input align=right ", $custfld);
    }
    $final_arr[] = $ui_type;
    $final_arr[] = $editview_label;
    $final_arr[] = $editview_fldname;
    $final_arr[] = $fieldvalue;
    $type_of_data = explode('~', $typeofdata);
    $final_arr[] = $type_of_data[1];
    $log->debug('Exiting getOutputHtml method ...');
    return $final_arr;
}
Example #15
-1
echo get_select_options_with_id(get_themes(), $display_theme);
?>
								</select></td>
							</tr>
							<tr bgcolor="#f5f5f5">
								<td class="small" align="right" width="30%"><?php 
echo $current_module_strings['LBL_LANGUAGE'];
?>
</td>
								<td class="small" align="left" width="70%"><select class="small" name='login_language' style="width:70%" tabindex="4">
									<!-- vtlib Customization -->
									<?php 
/* php echo get_select_options_with_id(get_languages(), $display_language) */
?>
									<?php 
echo get_select_options_with_id(Vtiger_Language::getAll(), $display_language);
?>
								</select></td>		
							</tr>
							<?php 
if (isset($_SESSION['validation'])) {
    ?>
							<tr>
								<td colspan="2"><font color="Red"> <?php 
    echo $current_module_strings['VLD_ERROR'];
    ?>
 </font></td>
							</tr>
							<?php 
} else {
    if (isset($login_error) && $login_error != "") {
Example #16
-1
/** This function returns the detail view form vtiger_field and and its properties in array format.
 * Param $uitype - UI type of the vtiger_field
 * Param $fieldname - Form vtiger_field name
 * Param $fieldlabel - Form vtiger_field label name
 * Param $col_fields - array contains the vtiger_fieldname and values
 * Param $generatedtype - Field generated type (default is 1)
 * Param $tabid - vtiger_tab id to which the Field belongs to (default is "")
 * Return type is an array
 */
function getDetailViewOutputHtml($uitype, $fieldname, $fieldlabel, $col_fields, $generatedtype, $tabid = '', $module = '')
{
    global $log;
    $log->debug("Entering getDetailViewOutputHtml(" . $uitype . "," . $fieldname . "," . $fieldlabel . "," . $col_fields . "," . $generatedtype . "," . $tabid . ") method ...");
    global $adb;
    global $mod_strings;
    global $app_strings;
    global $current_user;
    global $theme;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $fieldlabel = from_html($fieldlabel);
    $custfld = '';
    $value = '';
    $arr_data = array();
    $label_fld = array();
    $data_fld = array();
    require 'user_privileges/user_privileges_' . $current_user->id . '.php';
    require 'user_privileges/sharing_privileges_' . $current_user->id . '.php';
    // vtlib customization: New uitype to handle relation between modules
    if ($uitype == '10') {
        $fieldlabel = getTranslatedString($fieldlabel, $module);
        $parent_id = $col_fields[$fieldname];
        if (!empty($parent_id)) {
            $parent_module = getSalesEntityType($parent_id);
            $valueTitle = getTranslatedString($parent_module, $parent_module);
            $displayValueArray = getEntityName($parent_module, $parent_id);
            if (!empty($displayValueArray)) {
                foreach ($displayValueArray as $key => $value) {
                    $displayValue = $value;
                }
            }
            // vtlib customization: For listview javascript triggers
            $modMetaInfo = getEntityFieldNames($parent_module);
            $modEName = is_array($modMetaInfo['fieldname']) ? $modMetaInfo['fieldname'][0] : $modMetaInfo['fieldname'];
            $vtlib_metainfo = "<span type='vtlib_metainfo' vtrecordid='{$parent_id}' vtfieldname=" . "'{$modEName}' vtmodule='{$parent_module}' style='display:none;'></span>";
            // END
            $label_fld = array($fieldlabel, "<a href='index.php?module={$parent_module}&action=DetailView&record={$parent_id}' title='{$valueTitle}'>{$displayValue}</a>{$vtlib_metainfo}");
        } else {
            $moduleSpecificMessage = 'MODULE_NOT_SELECTED';
            if ($mod_strings[$moduleSpecificMessage] != "") {
                $moduleSpecificMessage = $mod_strings[$moduleSpecificMessage];
            }
            $label_fld = array($fieldlabel, '');
        }
    } else {
        if ($uitype == 99) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            if ($fieldname == 'confirm_password') {
                return null;
            }
        } elseif ($uitype == 116 || $uitype == 117) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getCurrencyName($col_fields[$fieldname]);
            $pick_query = "select * from vtiger_currency_info where currency_status = 'Active' and deleted=0";
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, 'currency_name');
                $currency_id = $adb->query_result($pickListResult, $j, 'id');
                if ($col_fields[$fieldname] == $currency_id) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[$currency_id] = array($pickListValue => $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 13 || $uitype == 104) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 16) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getTranslatedString($col_fields[$fieldname], $module);
            $fieldname = $adb->sql_escape_string($fieldname);
            $pick_query = "select {$fieldname} from vtiger_{$fieldname} order by sortorderid";
            $params = array();
            $pickListResult = $adb->pquery($pick_query, $params);
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $count = 0;
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = decode_html($adb->query_result($pickListResult, $j, strtolower($fieldname)));
                $col_fields[$fieldname] = decode_html($col_fields[$fieldname]);
                if ($col_fields[$fieldname] == $pickListValue) {
                    $chk_val = "selected";
                    $count++;
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $pickListValue = to_html($pickListValue);
                $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 15) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            $roleid = $current_user->roleid;
            $valueArr = explode("|##|", $col_fields[$fieldname]);
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            //Mikecrowe fix to correctly default for custom pick lists
            $options = array();
            $count = 0;
            $found = false;
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    if (in_array(trim($pickListValue), array_map("trim", $valueArr))) {
                        $chk_val = "selected";
                        $pickcount++;
                    } else {
                        $chk_val = '';
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $options[] = array($app_strings['LBL_NOT_ACCESSIBLE'], $value, 'selected');
                }
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 115) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = getTranslatedString($col_fields[$fieldname]);
            $pick_query = "select * from vtiger_" . $adb->sql_escape_string($fieldname);
            $pickListResult = $adb->pquery($pick_query, array());
            $noofpickrows = $adb->num_rows($pickListResult);
            $options = array();
            $found = false;
            for ($j = 0; $j < $noofpickrows; $j++) {
                $pickListValue = $adb->query_result($pickListResult, $j, strtolower($fieldname));
                if ($col_fields[$fieldname] == $pickListValue) {
                    $chk_val = "selected";
                    $found = true;
                } else {
                    $chk_val = '';
                }
                $options[] = array($pickListValue => $chk_val);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 33) {
            //uitype 33 added for multiselector picklist - Jeri
            $roleid = $current_user->roleid;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = str_ireplace(' |##| ', ', ', $col_fields[$fieldname]);
            $picklistValues = getAssignedPicklistValues($fieldname, $roleid, $adb);
            $options = array();
            $selected_entries = array();
            $selected_entries = explode(' |##| ', $col_fields[$fieldname]);
            if (!empty($picklistValues)) {
                foreach ($picklistValues as $order => $pickListValue) {
                    foreach ($selected_entries as $selected_entries_value) {
                        if (trim($selected_entries_value) == trim(htmlentities($pickListValue, ENT_QUOTES, $default_charset))) {
                            $chk_val = 'selected';
                            $pickcount++;
                            break;
                        } else {
                            $chk_val = '';
                        }
                    }
                    if (isset($_REQUEST['file']) && $_REQUEST['file'] == 'QuickCreate') {
                        $options[] = array(htmlentities(getTranslatedString($pickListValue), ENT_QUOTES, $default_charset), $pickListValue, $chk_val);
                    } else {
                        $options[] = array(getTranslatedString($pickListValue), $pickListValue, $chk_val);
                    }
                }
                if ($pickcount == 0 && !empty($value)) {
                    $not_access_lbl = "<font color='red'>" . $app_strings['LBL_NOT_ACCESSIBLE'] . "</font>";
                    $options[] = array($not_access_lbl, trim($selected_entries_value), 'selected');
                }
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 17) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $matchPattern = "^[\\w]+:\\/\\/^";
            $value = $col_fields[$fieldname];
            preg_match($matchPattern, $value, $matches);
            if (!empty($matches[0])) {
                $fieldValue = str_replace($matches, "", $value);
                $label_fld[] = $value;
            } else {
                if ($value != null) {
                    $label_fld[] = 'http://' . $value;
                } else {
                    $label_fld[] = '';
                }
            }
        } elseif ($uitype == 19) {
            if ($fieldname == 'notecontent' or $module == 'Timecontrol') {
                $col_fields[$fieldname] = decode_html($col_fields[$fieldname]);
            } else {
                $col_fields[$fieldname] = str_replace("&lt;br /&gt;", "<br>", $col_fields[$fieldname]);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 20 || $uitype == 21 || $uitype == 22 || $uitype == 24) {
            // Armando LC<scher 11.08.2005 -> B'descriptionSpan -> Desc: removed $uitype == 19 and made an aditional elseif above
            if ($uitype == 20) {
                //Fix the issue #4680
                $col_fields[$fieldname] = $col_fields[$fieldname];
            } else {
                $col_fields[$fieldname] = nl2br($col_fields[$fieldname]);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 51 || $uitype == 50 || $uitype == 73) {
            $account_id = $col_fields[$fieldname];
            if ($account_id != '') {
                $account_name = getAccountName($account_id);
            }
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $account_name;
            $label_fld["secid"] = $account_id;
            $label_fld["link"] = "index.php?module=Accounts&action=DetailView&record=" . $account_id;
            //Account Name View
        } elseif ($uitype == 52 || $uitype == 77 || $uitype == 101) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $user_id = $col_fields[$fieldname];
            $user_name = getOwnerName($user_id);
            if ($user_id != '') {
                $assigned_user_id = $user_id;
            } else {
                $assigned_user_id = $current_user->id;
            }
            if (is_admin($current_user)) {
                $label_fld[] = '<a href="index.php?module=Users&action=DetailView&record=' . $user_id . '">' . $user_name . '</a>';
            } else {
                $label_fld[] = $user_name;
            }
            if ($is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $assigned_user_id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $user_id), $assigned_user_id);
            }
            $label_fld["options"] = $users_combo;
        } elseif ($uitype == 11) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 53) {
            global $noof_group_rows, $adb;
            $owner_id = $col_fields[$fieldname];
            $user = '******';
            $result = $adb->pquery("SELECT count(*) as count from vtiger_users where id = ?", array($owner_id));
            if ($adb->query_result($result, 0, 'count') > 0) {
                $user = '******';
            }
            $owner_name = getOwnerName($owner_id);
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $owner_name;
            if (is_admin($current_user)) {
                $label_fld["secid"][] = $owner_id;
                if ($user == 'no') {
                    $label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=" . $owner_id;
                } else {
                    $label_fld["link"][] = "index.php?module=Users&action=DetailView&record=" . $owner_id;
                }
                //$label_fld["secid"][] = $groupid;
                //$label_fld["link"][] = "index.php?module=Settings&action=GroupDetailView&groupId=".$groupid;
            }
            //Security Checks
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module_name)] == 3 or $defaultOrgSharingPermission[getTabid($module_name)] == 0)) {
                $result = get_current_user_access_groups($module_name);
            } else {
                $result = get_group_options();
            }
            if ($result) {
                $nameArray = $adb->fetch_array($result);
            }
            global $current_user;
            //$value = $user_id;
            if ($owner_id != '') {
                if ($user == 'yes') {
                    $label_fld["options"][] = 'User';
                    $assigned_user_id = $owner_id;
                    $user_checked = "checked";
                    $team_checked = '';
                    $user_style = 'display:block';
                    $team_style = 'display:none';
                } else {
                    //$record = $col_fields["record_id"];
                    //$module = $col_fields["record_module"];
                    $label_fld["options"][] = 'Group';
                    $assigned_group_id = $owner_id;
                    $user_checked = '';
                    $team_checked = 'checked';
                    $user_style = 'display:none';
                    $team_style = 'display:block';
                }
            } else {
                $label_fld["options"][] = 'User';
                $assigned_user_id = $current_user->id;
                $user_checked = "checked";
                $team_checked = '';
                $user_style = 'display:block';
                $team_style = 'display:none';
            }
            if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id, 'private'), $assigned_user_id);
            } else {
                $users_combo = get_select_options_array(get_user_array(FALSE, "Active", $current_user->id), $assigned_user_id);
            }
            if ($noof_group_rows != 0) {
                if ($fieldname == 'assigned_user_id' && $is_admin == false && $profileGlobalPermission[2] == 1 && ($defaultOrgSharingPermission[getTabid($module)] == 3 or $defaultOrgSharingPermission[getTabid($module)] == 0)) {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id, 'private'), $current_user->id);
                } else {
                    $groups_combo = get_select_options_array(get_group_array(FALSE, "Active", $current_user->id), $current_user->id);
                }
            }
            $label_fld["options"][] = $users_combo;
            $label_fld["options"][] = $groups_combo;
        } elseif ($uitype == 55 || $uitype == 255) {
            if ($tabid == 4) {
                $query = "select vtiger_contactdetails.imagename from vtiger_contactdetails where contactid=?";
                $result = $adb->pquery($query, array($col_fields['record_id']));
                $imagename = $adb->query_result($result, 0, 'imagename');
                if ($imagename != '') {
                    $imgpath = "test/contact/" . $imagename;
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                } else {
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
            }
            $value = $col_fields[$fieldname];
            if ($uitype == 255) {
                global $currentModule;
                $fieldpermission = getFieldVisibilityPermission($currentModule, $current_user->id, 'firstname');
            }
            if ($uitype == 255 && $fieldpermission == 0 && $fieldpermission != '') {
                $fieldvalue[] = '';
            } else {
                $roleid = $current_user->roleid;
                $subrole = getRoleSubordinates($roleid);
                if (count($subrole) > 0) {
                    $roleids = implode("','", $subrole);
                    $roleids = $roleids . "','" . $roleid;
                } else {
                    $roleids = $roleid;
                }
                if ($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0) {
                    $pick_query = "select salutationtype from vtiger_salutationtype order by salutationtype";
                    $params = array();
                } else {
                    $pick_query = "select * from vtiger_salutationtype left join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid=vtiger_salutationtype.picklist_valueid where picklistid in (select picklistid from vtiger_picklist where name='salutationtype') and roleid=? order by salutationtype";
                    $params = array($current_user->roleid);
                }
                $pickListResult = $adb->pquery($pick_query, $params);
                $noofpickrows = $adb->num_rows($pickListResult);
                $sal_value = $col_fields["salutationtype"];
                $salcount = 0;
                for ($j = 0; $j < $noofpickrows; $j++) {
                    $pickListValue = $adb->query_result($pickListResult, $j, "salutationtype");
                    if ($sal_value == $pickListValue) {
                        $chk_val = "selected";
                        $salcount++;
                    } else {
                        $chk_val = '';
                    }
                }
                if ($salcount == 0 && $sal_value != '') {
                    $notacc = $app_strings['LBL_NOT_ACCESSIBLE'];
                }
                $sal_value = $col_fields["salutationtype"];
                if ($sal_value == '--None--') {
                    $sal_value = '';
                }
                $label_fld["salut"] = getTranslatedString($sal_value);
                $label_fld["notaccess"] = $notacc;
            }
            $label_fld[] = $value;
        } elseif ($uitype == 56) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $value = $col_fields[$fieldname];
            if ($value == 1) {
                //Since "yes" is not been translated it is given as app strings here..
                $displayValue = $app_strings['yes'];
            } else {
                $displayValue = $app_strings['no'];
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 156) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $value = $col_fields[$fieldname];
            if ($value == 'on') {
                //Since "yes" is not been translated it is given as app strings here..
                $displayValue = $app_strings['yes'];
            } else {
                $displayValue = $app_strings['no'];
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 57) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $contact_id = $col_fields[$fieldname];
            if ($contact_id != '') {
                $displayValueArray = getEntityName('Contacts', $contact_id);
                if (!empty($displayValueArray)) {
                    foreach ($displayValueArray as $key => $field_value) {
                        $contact_name = $field_value;
                    }
                } else {
                    $contact_name = '';
                }
            }
            $label_fld[] = $contact_name;
            $label_fld["secid"] = $contact_id;
            $label_fld["link"] = "index.php?module=Contacts&action=DetailView&record=" . $contact_id;
        } elseif ($uitype == 58) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $campaign_id = $col_fields[$fieldname];
            if ($campaign_id != '') {
                $campaign_name = getCampaignName($campaign_id);
            }
            $label_fld[] = $campaign_name;
            $label_fld["secid"] = $campaign_id;
            $label_fld["link"] = "index.php?module=Campaigns&action=DetailView&record=" . $campaign_id;
        } elseif ($uitype == 59) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $product_id = $col_fields[$fieldname];
            if ($product_id != '') {
                $product_name = getProductName($product_id);
            }
            //Account Name View
            $label_fld[] = $product_name;
            $label_fld["secid"] = $product_id;
            $label_fld["link"] = "index.php?module=Products&action=DetailView&record=" . $product_id;
        } elseif ($uitype == 61) {
            global $adb;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($tabid == 10) {
                $attach_result = $adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id']));
                for ($ii = 0; $ii < $adb->num_rows($attach_result); $ii++) {
                    $attachmentid = $adb->query_result($attach_result, $ii, 'attachmentsid');
                    if ($attachmentid != '') {
                        $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                        $attachmentsname = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                        if ($attachmentsname != '') {
                            $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '">' . $attachmentsname . '</a>';
                        } else {
                            $custfldval = '';
                        }
                    }
                    $label_fld['options'][] = $custfldval;
                }
            } else {
                $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
                if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                    $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                    $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
                }
                //This is added to strip the crmid and _ from the file name and show the original filename
                //$org_filename = ltrim($col_fields[$fieldname],$col_fields['record_id'].'_');
                /* Above line is not required as the filename in the database is stored as it is and doesn't have crmid attached to it.
                	  This was the cause for the issue reported in ticket #4645 */
                $org_filename = $col_fields[$fieldname];
                // For Backward Compatibility version < 5.0.4
                $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_');
                if ($filename_pos === 0) {
                    $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_');
                    $org_filename = substr($org_filename, $start_idx);
                }
                if ($org_filename != '') {
                    if ($col_fields['filelocationtype'] == 'E') {
                        if ($col_fields['filestatus'] == 1) {
                            //&& strlen($col_fields['filename']) > 7  ){
                            $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                        } else {
                            $custfldval = $col_fields[$fieldname];
                        }
                    } elseif ($col_fields['filelocationtype'] == 'I') {
                        if ($col_fields['filestatus'] == 1) {
                            $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                        } else {
                            $custfldval = $col_fields[$fieldname];
                        }
                    } else {
                        $custfldval = '';
                    }
                }
                $label_fld[] = $custfldval;
            }
        } elseif ($uitype == 28) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $attachmentid = $adb->query_result($adb->pquery("select * from vtiger_seattachmentsrel where crmid = ?", array($col_fields['record_id'])), 0, 'attachmentsid');
            if ($col_fields[$fieldname] == '' && $attachmentid != '') {
                $attachquery = "select * from vtiger_attachments where attachmentsid=?";
                $col_fields[$fieldname] = $adb->query_result($adb->pquery($attachquery, array($attachmentid)), 0, 'name');
            }
            $org_filename = $col_fields[$fieldname];
            // For Backward Compatibility version < 5.0.4
            $filename_pos = strpos($org_filename, $col_fields['record_id'] . '_');
            if ($filename_pos === 0) {
                $start_idx = $filename_pos + strlen($col_fields['record_id'] . '_');
                $org_filename = substr($org_filename, $start_idx);
            }
            if ($org_filename != '') {
                if ($col_fields['filelocationtype'] == 'E') {
                    if ($col_fields['filestatus'] == 1) {
                        //&& strlen($col_fields['filename']) > 7  ){
                        $custfldval = '<a target="_blank" href =' . $col_fields['filename'] . ' onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                    } else {
                        $custfldval = $col_fields[$fieldname];
                    }
                } elseif ($col_fields['filelocationtype'] == 'I') {
                    if ($col_fields['filestatus'] == 1) {
                        $custfldval = '<a href = "index.php?module=uploads&action=downloadfile&return_module=' . $col_fields['record_module'] . '&fileid=' . $attachmentid . '&entityid=' . $col_fields['record_id'] . '" onclick=\'javascript:dldCntIncrease(' . $col_fields['record_id'] . ');\'>' . $col_fields[$fieldname] . '</a>';
                    } else {
                        $custfldval = $col_fields[$fieldname];
                    }
                } else {
                    $custfldval = '';
                }
            }
            $label_fld[] = $custfldval;
        } elseif ($uitype == 69) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($tabid == 14) {
                $images = array();
                $query = 'select productname, vtiger_attachments.path, vtiger_attachments.attachmentsid, vtiger_attachments.name,vtiger_crmentity.setype from vtiger_products left join vtiger_seattachmentsrel on vtiger_seattachmentsrel.crmid=vtiger_products.productid inner join vtiger_attachments on vtiger_attachments.attachmentsid=vtiger_seattachmentsrel.attachmentsid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid where vtiger_crmentity.setype="Products Image" and productid=?';
                $result_image = $adb->pquery($query, array($col_fields['record_id']));
                for ($image_iter = 0; $image_iter < $adb->num_rows($result_image); $image_iter++) {
                    $image_id_array[] = $adb->query_result($result_image, $image_iter, 'attachmentsid');
                    //decode_html  - added to handle UTF-8   characters in file names
                    //urlencode    - added to handle special characters like #, %, etc.,
                    $image_array[] = urlencode(decode_html($adb->query_result($result_image, $image_iter, 'name')));
                    $image_orgname_array[] = decode_html($adb->query_result($result_image, $image_iter, 'name'));
                    $imagepath_array[] = $adb->query_result($result_image, $image_iter, 'path');
                }
                if (count($image_array) > 1) {
                    if (count($image_array) < 4) {
                        $sides = count($image_array) * 2;
                    } else {
                        $sides = 8;
                    }
                    $image_lists = '<div id="Carousel" style="position:relative;vertical-align: middle;">
					<img src="modules/Products/placeholder.gif" width="571" height="117" style="position:relative;">
					</div><script>var Car_NoOfSides=' . $sides . '; Car_Image_Sources=new Array(';
                    for ($image_iter = 0; $image_iter < count($image_array); $image_iter++) {
                        $images[] = '"' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '","' . $imagepath_array[$image_iter] . $image_id_array[$image_iter] . "_" . $image_array[$image_iter] . '"';
                    }
                    $image_lists .= implode(',', $images) . ');</script><script language="JavaScript" type="text/javascript" src="modules/Products/Productsslide.js"></script><script language="JavaScript" type="text/javascript">Carousel();</script>';
                    $label_fld[] = $image_lists;
                } elseif (count($image_array) == 1) {
                    list($pro_image_width, $pro_image_height) = getimagesize($imagepath_array[0] . $image_id_array[0] . "_" . $image_orgname_array[0]);
                    if ($pro_image_width > 450 || $pro_image_height > 300) {
                        $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="450" height="300">';
                    } else {
                        $label_fld[] = '<img src="' . $imagepath_array[0] . $image_id_array[0] . "_" . $image_array[0] . '" border="0" width="' . $pro_image_width . '" height="' . $pro_image_height . '">';
                    }
                } else {
                    $label_fld[] = '';
                }
            } else {
                if ($module == 'Contacts') {
                    $imageattachment = 'Image';
                } else {
                    $imageattachment = 'Attachment';
                }
                //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
                $sql = "select vtiger_attachments.*,vtiger_crmentity.setype\n\t\t\t from vtiger_attachments\n\t\t\t inner join vtiger_seattachmentsrel on vtiger_seattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid\n\t\t\t inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_attachments.attachmentsid\n\t\t\t where vtiger_crmentity.setype='{$module} {$imageattachment}'\n\t\t\t  and vtiger_attachments.name = ?\n\t\t\t  and vtiger_seattachmentsrel.crmid=?";
                $image_res = $adb->pquery($sql, array($col_fields[$fieldname], $col_fields['record_id']));
                $image_id = $adb->query_result($image_res, 0, 'attachmentsid');
                $image_path = $adb->query_result($image_res, 0, 'path');
                //decode_html  - added to handle UTF-8   characters in file names
                //urlencode    - added to handle special characters like #, %, etc.,
                $image_name = urlencode(decode_html($adb->query_result($image_res, 0, 'name')));
                $imgpath = $image_path . $image_id . "_" . $image_name;
                if ($image_name != '') {
                    $ftype = $adb->query_result($image_res, 0, 'type');
                    $isimage = stripos($ftype, 'image') !== false;
                    if ($isimage) {
                        $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('Image');
                        $label_fld[] = '<img src="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '" style="max-width: 500px;">';
                    } else {
                        $imgtxt = getTranslatedString('SINGLE_' . $module, $module) . ' ' . getTranslatedString('SINGLE_Documents');
                        $label_fld[] = '<a href="' . $imgpath . '" alt="' . $imgtxt . '" title= "' . $imgtxt . '">' . $image_name . '</a>';
                    }
                } else {
                    $label_fld[] = '';
                }
            }
        } elseif ($uitype == 62) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } elseif ($parent_module == "Potentials") {
                    $label_fld[] = $app_strings['LBL_POTENTIAL_NAME'];
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $potentialname = $adb->query_result($result, 0, "potentialname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>';
                } elseif ($parent_module == "Products") {
                    $label_fld[] = $app_strings['LBL_PRODUCT_NAME'];
                    $sql = "select * from  vtiger_products where productid=?";
                    $result = $adb->pquery($sql, array($value));
                    $productname = $adb->query_result($result, 0, "productname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $productname . '</a>';
                } elseif ($parent_module == "PurchaseOrder") {
                    $label_fld[] = $app_strings['LBL_PORDER_NAME'];
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $pordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>';
                } elseif ($parent_module == "SalesOrder") {
                    $label_fld[] = $app_strings['LBL_SORDER_NAME'];
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $sordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>';
                } elseif ($parent_module == "Invoice") {
                    $label_fld[] = $app_strings['LBL_INVOICE_NAME'];
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $invoicename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>';
                } elseif ($parent_module == "Quotes") {
                    $label_fld[] = $app_strings['LBL_QUOTES_NAME'];
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $quotename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>';
                } elseif ($parent_module == "HelpDesk") {
                    $label_fld[] = $app_strings['LBL_HELPDESK_NAME'];
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $title = $adb->query_result($result, 0, "title");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $title . '</a>';
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 105) {
            //Added for user image
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            //$imgpath = getModuleFileStoragePath('Contacts').$col_fields[$fieldname];
            $sql = "select vtiger_attachments.* from vtiger_attachments left join vtiger_salesmanattachmentsrel on vtiger_salesmanattachmentsrel.attachmentsid = vtiger_attachments.attachmentsid where vtiger_salesmanattachmentsrel.smid=?";
            $image_res = $adb->pquery($sql, array($col_fields['record_id']));
            $image_id = $adb->query_result($image_res, 0, 'attachmentsid');
            $image_path = $adb->query_result($image_res, 0, 'path');
            $image_name = $adb->query_result($image_res, 0, 'name');
            $imgpath = $image_path . $image_id . "_" . $image_name;
            if ($image_name != '') {
                //Added the following check for the image to retain its in original size.
                list($pro_image_width, $pro_image_height) = getimagesize(decode_html($imgpath));
                $label_fld[] = '<a href="' . $imgpath . '" target="_blank"><img src="' . $imgpath . '" width="' . $pro_image_width . '" height="' . $pro_image_height . '" alt="' . $col_fields['user_name'] . '" title="' . $col_fields['user_name'] . '" border="0"></a>';
            } else {
                $label_fld[] = '';
            }
        } elseif ($uitype == 66) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from  vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } elseif ($parent_module == "Potentials") {
                    $label_fld[] = $app_strings['LBL_POTENTIAL_NAME'];
                    $sql = "select * from  vtiger_potential where potentialid=?";
                    $result = $adb->pquery($sql, array($value));
                    $potentialname = $adb->query_result($result, 0, "potentialname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $potentialname . '</a>';
                } elseif ($parent_module == "Quotes") {
                    $label_fld[] = $app_strings['LBL_QUOTE_NAME'];
                    $sql = "select * from  vtiger_quotes where quoteid=?";
                    $result = $adb->pquery($sql, array($value));
                    $quotename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $quotename . '</a>';
                } elseif ($parent_module == "PurchaseOrder") {
                    $label_fld[] = $app_strings['LBL_PORDER_NAME'];
                    $sql = "select * from  vtiger_purchaseorder where purchaseorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $pordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $pordername . '</a>';
                } elseif ($parent_module == "SalesOrder") {
                    $label_fld[] = $app_strings['LBL_SORDER_NAME'];
                    $sql = "select * from  vtiger_salesorder where salesorderid=?";
                    $result = $adb->pquery($sql, array($value));
                    $sordername = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $sordername . '</a>';
                } elseif ($parent_module == "Invoice") {
                    $label_fld[] = $app_strings['LBL_INVOICE_NAME'];
                    $sql = "select * from  vtiger_invoice where invoiceid=?";
                    $result = $adb->pquery($sql, array($value));
                    $invoicename = $adb->query_result($result, 0, "subject");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $invoicename . '</a>';
                } elseif ($parent_module == "Campaigns") {
                    $label_fld[] = $app_strings['LBL_CAMPAIGN_NAME'];
                    $sql = "select * from  vtiger_campaign where campaignid=?";
                    $result = $adb->pquery($sql, array($value));
                    $campaignname = $adb->query_result($result, 0, "campaignname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $campaignname . '</a>';
                } elseif ($parent_module == "HelpDesk") {
                    $label_fld[] = $app_strings['LBL_HELPDESK_NAME'];
                    $sql = "select * from  vtiger_troubletickets where ticketid=?";
                    $result = $adb->pquery($sql, array($value));
                    $tickettitle = $adb->query_result($result, 0, "title");
                    if (strlen($tickettitle) > 25) {
                        $tickettitle = substr($tickettitle, 0, 25) . '...';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $tickettitle . '</a>';
                } elseif ($parent_module == "Vendors") {
                    //MSL
                    $label_fld[] = $app_strings['LBL_VENDOR_NAME'];
                    $sql = "select vendorname from  vtiger_vendor where vendorid=?";
                    $result = $adb->pquery($sql, array($value));
                    $vendor_name = $adb->query_result($result, 0, "vendorname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $vendor_name . '</a>';
                }
                //MSL -------------------------------------------
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 67) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Leads") {
                    $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $lead_name = $field_value;
                        }
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                } elseif ($parent_module == "Contacts") {
                    $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 357) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_name = '';
                $parent_id = '';
                $myemailid = $_REQUEST['record'];
                $mysql = "select crmid from vtiger_seactivityrel where activityid=?";
                $myresult = $adb->pquery($mysql, array($myemailid));
                $mycount = $adb->num_rows($myresult);
                if ($mycount > 1) {
                    $label_fld[] = $app_strings['LBL_RELATED_TO'];
                    $label_fld[] = $app_strings['LBL_MULTIPLE'];
                } else {
                    $parent_module = getSalesEntityType($value);
                    if ($parent_module == "Leads") {
                        $label_fld[] = $app_strings['LBL_LEAD_NAME'];
                        $displayValueArray = getEntityName($parent_module, $value);
                        if (!empty($displayValueArray)) {
                            foreach ($displayValueArray as $key => $field_value) {
                                $lead_name = $field_value;
                            }
                        }
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $lead_name . '</a>';
                    } elseif ($parent_module == "Contacts") {
                        $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                        $displayValueArray = getEntityName($parent_module, $value);
                        if (!empty($displayValueArray)) {
                            foreach ($displayValueArray as $key => $field_value) {
                                $contact_name = $field_value;
                            }
                        } else {
                            $contact_name = '';
                        }
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                    } elseif ($parent_module == "Accounts") {
                        $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                        $sql = "select * from  vtiger_account where accountid=?";
                        $result = $adb->pquery($sql, array($value));
                        $accountname = $adb->query_result($result, 0, "accountname");
                        $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $accountname . '</a>';
                    }
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 68) {
            $value = $col_fields[$fieldname];
            if ($value != '') {
                $parent_module = getSalesEntityType($value);
                if ($parent_module == "Contacts") {
                    $label_fld[] = $app_strings['LBL_CONTACT_NAME'];
                    $displayValueArray = getEntityName($parent_module, $value);
                    if (!empty($displayValueArray)) {
                        foreach ($displayValueArray as $key => $field_value) {
                            $contact_name = $field_value;
                        }
                    } else {
                        $contact_name = '';
                    }
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $contact_name . '</a>';
                } elseif ($parent_module == "Accounts") {
                    $label_fld[] = $app_strings['LBL_ACCOUNT_NAME'];
                    $sql = "select * from vtiger_account where accountid=?";
                    $result = $adb->pquery($sql, array($value));
                    $account_name = $adb->query_result($result, 0, "accountname");
                    $label_fld[] = '<a href="index.php?module=' . $parent_module . '&action=DetailView&record=' . $value . '">' . $account_name . '</a>';
                } else {
                    $value = '';
                    $label_fld[] = getTranslatedString($fieldlabel, $module);
                    $label_fld[] = $value;
                }
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $value;
            }
        } elseif ($uitype == 63) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname] . 'h&nbsp; ' . $col_fields['duration_minutes'] . 'm';
        } elseif ($uitype == 6) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname] == '0') {
                $col_fields[$fieldname] = '';
            }
            if ($col_fields['time_start'] != '') {
                $start_time = $col_fields['time_start'];
            }
            $dateValue = $col_fields[$fieldname];
            if ($col_fields[$fieldname] == '0000-00-00' || empty($dateValue)) {
                $displayValue = '';
            } else {
                if (empty($start_time) && strpos($col_fields[$fieldname], ' ') == false) {
                    $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]);
                } else {
                    if (!empty($start_time)) {
                        $date = new DateTimeField($col_fields[$fieldname] . ' ' . $start_time);
                    } else {
                        $date = new DateTimeField($col_fields[$fieldname]);
                    }
                    $displayValue = $date->getDisplayDateTimeValue();
                }
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 5 || $uitype == 23 || $uitype == 70) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $dateValue = $col_fields[$fieldname];
            if ($col_fields['time_end'] != '' && ($tabid == 9 || $tabid == 16) && $uitype == 23) {
                $end_time = $col_fields['time_end'];
            }
            if ($dateValue == '0000-00-00' || empty($dateValue)) {
                $displayValue = '';
            } else {
                if (empty($end_time) && strpos($dateValue, ' ') == false) {
                    $displayValue = DateTimeField::convertToUserFormat($col_fields[$fieldname]);
                } else {
                    if (!empty($end_time)) {
                        $date = new DateTimeField($col_fields[$fieldname] . ' ' . $end_time);
                    } else {
                        $date = new DateTimeField($col_fields[$fieldname]);
                    }
                    $displayValue = $date->getDisplayDateTimeValue();
                }
            }
            $label_fld[] = $displayValue;
        } elseif ($uitype == 71 || $uitype == 72) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $currencyField = new CurrencyField($col_fields[$fieldname]);
            if ($uitype == 72) {
                // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
                if ($fieldname == 'unit_price') {
                    $rate_symbol = getCurrencySymbolandCRate(getProductBaseCurrency($col_fields['record_id'], $module));
                    $label_fld[] = $currencyField->getDisplayValue(null, true);
                    $label_fld["cursymb"] = $rate_symbol['symbol'];
                } else {
                    $currency_info = getInventoryCurrencyInfo($module, $col_fields['record_id']);
                    $label_fld[] = $currencyField->getDisplayValue(null, true);
                    $label_fld["cursymb"] = $currency_info['currency_symbol'];
                }
            } else {
                $label_fld[] = $currencyField->getDisplayValue();
                $label_fld["cursymb"] = $currencyField->getCurrencySymbol();
            }
        } elseif ($uitype == 75 || $uitype == 81) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $vendor_id = $col_fields[$fieldname];
            if ($vendor_id != '') {
                $vendor_name = getVendorName($vendor_id);
            }
            $label_fld[] = $vendor_name;
            $label_fld["secid"] = $vendor_id;
            $label_fld["link"] = "index.php?module=Vendors&action=DetailView&record=" . $vendor_id;
        } elseif ($uitype == 76) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $potential_id = $col_fields[$fieldname];
            if ($potential_id != '') {
                $potential_name = getPotentialName($potential_id);
            }
            $label_fld[] = $potential_name;
            $label_fld["secid"] = $potential_id;
            $label_fld["link"] = "index.php?module=Potentials&action=DetailView&record=" . $potential_id;
        } elseif ($uitype == 78) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $quote_id = $col_fields[$fieldname];
            if ($quote_id != '') {
                $quote_name = getQuoteName($quote_id);
            }
            $label_fld[] = $quote_name;
            $label_fld["secid"] = $quote_id;
            $label_fld["link"] = "index.php?module=Quotes&action=DetailView&record=" . $quote_id;
        } elseif ($uitype == 79) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $purchaseorder_id = $col_fields[$fieldname];
            if ($purchaseorder_id != '') {
                $purchaseorder_name = getPoName($purchaseorder_id);
            }
            $label_fld[] = $purchaseorder_name;
            $label_fld["secid"] = $purchaseorder_id;
            $label_fld["link"] = "index.php?module=PurchaseOrder&action=DetailView&record=" . $purchaseorder_id;
        } elseif ($uitype == 80) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $salesorder_id = $col_fields[$fieldname];
            if ($salesorder_id != '') {
                $salesorder_name = getSoName($salesorder_id);
            }
            $label_fld[] = $salesorder_name;
            $label_fld["secid"] = $salesorder_id;
            $label_fld["link"] = "index.php?module=SalesOrder&action=DetailView&record=" . $salesorder_id;
        } elseif ($uitype == 30) {
            $rem_days = 0;
            $rem_hrs = 0;
            $rem_min = 0;
            $reminder_str = "";
            $rem_days = floor($col_fields[$fieldname] / (24 * 60));
            $rem_hrs = floor(($col_fields[$fieldname] - $rem_days * 24 * 60) / 60);
            $rem_min = ($col_fields[$fieldname] - $rem_days * 24 * 60) % 60;
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname]) {
                $reminder_str = $rem_days . '&nbsp;' . $mod_strings['LBL_DAYS'] . '&nbsp;' . $rem_hrs . '&nbsp;' . $mod_strings['LBL_HOURS'] . '&nbsp;' . $rem_min . '&nbsp;' . $mod_strings['LBL_MINUTES'] . '&nbsp;&nbsp;' . $mod_strings['LBL_BEFORE_EVENT'];
            }
            $label_fld[] = '&nbsp;' . $reminder_str;
        } elseif ($uitype == 98) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if (is_admin($current_user)) {
                $label_fld[] = '<a href="index.php?module=Settings&action=RoleDetailView&roleid=' . $col_fields[$fieldname] . '">' . getRoleName($col_fields[$fieldname]) . '</a>';
            } else {
                $label_fld[] = getRoleName($col_fields[$fieldname]);
            }
        } elseif ($uitype == 85) {
            //Added for Skype by Minnie
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
        } elseif ($uitype == 26) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $query = "select foldername from vtiger_attachmentsfolder where folderid = ?";
            $result = $adb->pquery($query, array($col_fields[$fieldname]));
            $folder_name = $adb->query_result($result, 0, "foldername");
            $label_fld[] = $folder_name;
        } elseif ($uitype == 27) {
            if ($col_fields[$fieldname] == 'I') {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $mod_strings['LBL_INTERNAL'];
            } else {
                $label_fld[] = getTranslatedString($fieldlabel, $module);
                $label_fld[] = $mod_strings['LBL_EXTERNAL'];
            }
        } elseif ($uitype == 31) {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = $col_fields[$fieldname];
            $options = array();
            $themeList = get_themes();
            foreach ($themeList as $theme) {
                if ($current_user->theme == $theme) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($theme), $theme, $selected);
            }
            $label_fld["options"] = $options;
        } elseif ($uitype == 32) {
            $options = array();
            $languageList = Vtiger_Language::getAll();
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            $label_fld[] = isset($languageList[$col_fields[$fieldname]]) ? $languageList[$col_fields[$fieldname]] : $col_fields[$fieldname];
            foreach ($languageList as $prefix => $label) {
                if ($current_user->language == $prefix) {
                    $selected = 'selected';
                } else {
                    $selected = '';
                }
                $options[] = array(getTranslatedString($label), $prefix, $selected);
            }
            $label_fld["options"] = $options;
        } else {
            $label_fld[] = getTranslatedString($fieldlabel, $module);
            if ($col_fields[$fieldname] == '0' && $fieldname != 'filedownloadcount' && $fieldname != 'filestatus' && $fieldname != 'filesize') {
                $col_fields[$fieldname] = '';
            }
            //code for Documents module :start
            if ($tabid == 8) {
                $downloadtype = $col_fields['filelocationtype'];
                if ($fieldname == 'filename') {
                    if ($downloadtype == 'I') {
                        //$file_value = $mod_strings['LBL_INTERNAL'];
                        $fld_value = $col_fields['filename'];
                        $ext_pos = strrpos($fld_value, ".");
                        $ext = substr($fld_value, $ext_pos + 1);
                        $ext = strtolower($ext);
                        if ($ext == 'bin' || $ext == 'exe' || $ext == 'rpm') {
                            $fileicon = "<img src='" . vtiger_imageurl('fExeBin.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'jpg' || $ext == 'gif' || $ext == 'bmp') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbImageFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'txt' || $ext == 'doc' || $ext == 'xls') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbTextFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        } elseif ($ext == 'zip' || $ext == 'gz' || $ext == 'rar') {
                            $fileicon = "<img src='" . vtiger_imageurl('fbZipFile.gif', $theme) . "' hspace='3' align='absmiddle'\tborder='0'>";
                        } else {
                            $fileicon = "<img src='" . vtiger_imageurl('fbUnknownFile.gif', $theme) . "' hspace='3' align='absmiddle' border='0'>";
                        }
                    } else {
                        $fld_value = $col_fields['filename'];
                        $fileicon = "<img src='" . vtiger_imageurl('fbLink.gif', $theme) . "' alt='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' title='" . $mod_strings['LBL_EXTERNAL_LNK'] . "' hspace='3' align='absmiddle' border='0'>";
                    }
                    $label_fld[] = $fileicon . $fld_value;
                }
                if ($fieldname == 'filesize') {
                    if ($col_fields['filelocationtype'] == 'I') {
                        $filesize = $col_fields[$fieldname];
                        if ($filesize < 1024) {
                            $label_fld[] = $filesize . ' B';
                        } elseif ($filesize > 1024 && $filesize < 1048576) {
                            $label_fld[] = round($filesize / 1024, 2) . ' KB';
                        } else {
                            if ($filesize > 1048576) {
                                $label_fld[] = round($filesize / (1024 * 1024), 2) . ' MB';
                            }
                        }
                    } else {
                        $label_fld[] = ' --';
                    }
                }
                if ($fieldname == 'filetype' && $col_fields['filelocationtype'] == 'E') {
                    $label_fld[] = ' --';
                }
                /* if($fieldname == 'filestatus')
                	  {
                	  $filestatus = $col_fields[$fieldname];
                	  if($filestatus == 0)
                	  $label_fld[]=$mod_strings['LBL_ACTIVE'];
                	  else
                	  $label_fld[]=$mod_strings['LBL_INACTIVE'];
                	  } */
            }
            //code for Documents module :end
            $label_fld[] = $col_fields[$fieldname];
        }
    }
    $label_fld[] = $uitype;
    //sets whether the currenct user is admin or not
    if (is_admin($current_user)) {
        $label_fld["isadmin"] = 1;
    } else {
        $label_fld["isadmin"] = 0;
    }
    $log->debug("Exiting getDetailViewOutputHtml method ...");
    return $label_fld;
}
Example #17
-1
 /**
  * Delete this instance
  */
 function delete()
 {
     $moduleInstance = Vtiger_Module_Model::getInstance($this->name);
     require_once "modules/{$this->name}/{$this->name}.php";
     $focus = new $this->name();
     $this->tableName = $focus->table_name;
     if ($this->isentitytype) {
         $this->deleteFromCRMEntity();
         Vtiger_Access::deleteTools($this);
         Vtiger_Filter::deleteForModule($this);
         Vtiger_Block::deleteForModule($this);
         if (method_exists($this, 'deinitWebservice')) {
             $this->deinitWebservice();
         }
     }
     $this->deleteIcons();
     $this->unsetAllRelatedList($moduleInstance);
     ModComments_Module_Model::deleteForModule($moduleInstance);
     Vtiger_Language::deleteForModule($moduleInstance);
     Vtiger_Access::deleteSharing($moduleInstance);
     $this->deleteFromModentityNum();
     Vtiger_Cron::deleteForModule($moduleInstance);
     Vtiger_Profile::deleteForModule($moduleInstance);
     Settings_Workflows_Module_Model::deleteForModule($moduleInstance);
     Vtiger_Menu::deleteForModule($moduleInstance);
     $this->deleteGroup2Modules();
     $this->deleteModuleTables();
     $this->deleteCRMEntityRel();
     Vtiger_Profile::deleteForModule($this);
     Vtiger_Link::deleteAll($this->id);
     $this->deleteDir($moduleInstance);
     $this->__delete();
     self::syncfile();
 }