function applyChange()
 {
     global $adb;
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         global $adb;
         $vendorsInstance = Vtiger_Module::getInstance('Vendors');
         $blockInstance = Vtiger_Block::getInstance('LBL_VENDOR_INFORMATION', $vendorsInstance);
         $field = Vtiger_Field::getInstance('assigned_user_id', $vendorsInstance);
         if ($field) {
             $this->ExecuteQuery('update vtiger_field set presence=2 where fieldid=' . $field->id);
         } else {
             $field = new Vtiger_Field();
             $field->name = 'assigned_user_id';
             $field->label = 'Assigned To';
             $field->table = 'vtiger_crmentity';
             $field->column = 'smownerid';
             $field->columntype = 'INT(11)';
             $field->uitype = 53;
             $field->displaytype = 1;
             $field->typeofdata = 'V~M';
             $field->presence = 2;
             $field->quickcreate = 0;
             $field->quicksequence = 5;
             $blockInstance->addField($field);
             // Allow Sharing access and role-based security for Vendors
             Vtiger_Access::deleteSharing($vendorsInstance);
             Vtiger_Access::initSharing($vendorsInstance);
             Vtiger_Access::allowSharing($vendorsInstance);
             Vtiger_Access::setDefaultSharing($vendorsInstance);
         }
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
Exemplo n.º 2
0
 function applyChange()
 {
     if ($this->hasError()) {
         $this->sendError();
     }
     if ($this->isApplied()) {
         $this->sendMsg('Changeset ' . get_class($this) . ' already applied!');
     } else {
         $emailsInstance = Vtiger_Module::getInstance('Emails');
         // Allow Sharing access and role-based security for Vendors
         Vtiger_Access::deleteSharing($emailsInstance);
         Vtiger_Access::initSharing($emailsInstance);
         Vtiger_Access::allowSharing($emailsInstance);
         Vtiger_Access::setDefaultSharing($emailsInstance, 'private');
         Vtiger_Profile::initForModule($emailsInstance);
         // Email Reporting - set reports to public because access is private by default and configurable now
         $emrpts = "UPDATE vtiger_report SET sharingtype='Public' WHERE reportname in ('Contacts Email Report','Accounts Email Report','Leads Email Report','Vendors Email Report')";
         $this->ExecuteQuery($emrpts, array());
         $this->sendMsg('Changeset ' . get_class($this) . ' applied!');
         $this->markApplied();
     }
     $this->finishExecution();
 }
Exemplo n.º 3
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     global $adb;
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->pquery("INSERT INTO vtiger_tab (tabid,name,presence,tabsequence,tablabel,modifiedby,\n\t\t\tmodifiedtime,customized,ownedby,version,parent) VALUES (?,?,?,?,?,?,?,?,?,?,?)", array($this->id, $this->name, $this->presence, -1, $this->label, NULL, NULL, $customized, $this->ownedby, $this->version, $this->parent));
     $useisentitytype = $this->isentitytype ? 1 : 0;
     $adb->pquery('UPDATE vtiger_tab set isentitytype=? WHERE tabid=?', array($useisentitytype, $this->id));
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
         $menuInstance = Vtiger_Menu::getInstance($parentTab);
         $menuInstance->addModule($moduleInstance);
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
if (!$vendorAssignedToField) {
    $vendorBlock = Vtiger_Block::getInstance('LBL_VENDOR_INFORMATION', $vendorInstance);
    $vendorAssignedToField = new Vtiger_Field();
    $vendorAssignedToField->name = 'assigned_user_id';
    $vendorAssignedToField->label = 'Assigned To';
    $vendorAssignedToField->table = 'vtiger_crmentity';
    $vendorAssignedToField->column = 'smownerid';
    $vendorAssignedToField->uitype = 53;
    $vendorAssignedToField->typeofdata = 'V~M';
    $vendorBlock->addField($vendorAssignedToField);
    $vendorAllFilter = Vtiger_Filter::getInstance('All', $vendorInstance);
    $vendorAllFilter->addField($vendorAssignedToField, 5);
}
// Allow Sharing access and role-based security for Vendors
Vtiger_Access::deleteSharing($vendorInstance);
Vtiger_Access::initSharing($vendorInstance);
Vtiger_Access::allowSharing($vendorInstance);
Vtiger_Access::setDefaultSharing($vendorInstance);
Vtiger_Module::syncfile();
// Add Email Opt-out for Leads
$leadsInstance = Vtiger_Module::getInstance('Leads');
$leadsOptOutField = Vtiger_Field::getInstance('emailoptout', $leadsInstance);
if (!$leadsOptOutField) {
    $leadsOptOutField = new Vtiger_Field();
    $leadsOptOutField->name = 'emailoptout';
    $leadsOptOutField->label = 'Email Opt Out';
    $leadsOptOutField->table = 'vtiger_leaddetails';
    $leadsOptOutField->column = $leadsOptOutField->name;
    $leadsOptOutField->columntype = 'VARCHAR(3)';
    $leadsOptOutField->uitype = 56;
    $leadsOptOutField->typeofdata = 'C~O';
Exemplo n.º 5
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     $adb = PearDatabase::getInstance();
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->insert('vtiger_tab', ['tabid' => $this->id, 'name' => $this->name, 'presence' => $this->presence, 'tabsequence' => -1, 'tablabel' => $this->label, 'modifiedby' => NULL, 'modifiedtime' => NULL, 'customized' => $customized, 'ownedby' => $this->ownedby, 'version' => $this->version, 'parent' => $this->parent, 'isentitytype' => $this->isentitytype ? 1 : 0, 'type' => $this->type]);
     if (!Vtiger_Utils::CheckTable('vtiger_tab_info')) {
         Vtiger_Utils::CreateTable('vtiger_tab_info', '(tabid INT, prefname VARCHAR(256), prefvalue VARCHAR(256), FOREIGN KEY fk_1_vtiger_tab_info(tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE ON UPDATE CASCADE)', true);
     }
     if ($this->minversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_min_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_min_version'", array($this->minversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_min_version', $this->minversion));
         }
     }
     if ($this->maxversion) {
         $tabResult = $adb->pquery("SELECT 1 FROM vtiger_tab_info WHERE tabid=? AND prefname='vtiger_max_version'", array($this->id));
         if ($adb->num_rows($tabResult) > 0) {
             $adb->pquery("UPDATE vtiger_tab_info SET prefvalue=? WHERE tabid=? AND prefname='vtiger_max_version'", array($this->maxversion, $this->id));
         } else {
             $adb->pquery('INSERT INTO vtiger_tab_info(tabid, prefname, prefvalue) VALUES (?,?,?)', array($this->id, 'vtiger_max_version', $this->maxversion));
         }
     }
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     $moduleInstance = Vtiger_Module::getInstance($this->name);
     $parentTab = $this->parent;
     if (!empty($parentTab)) {
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
Exemplo n.º 6
0
ExecutePQuery("UPDATE vtiger_cvcolumnlist SET columnname=? WHERE columnname=?", array($newProductHandlerColumnName, $oldProductHandlerColumnName));
ExecutePQuery("UPDATE vtiger_cvadvfilter SET columnname=? WHERE columnname=?", array($newProductHandlerColumnName, $oldProductHandlerColumnName));
ExecuteQuery("UPDATE vtiger_crmentity, vtiger_service SET vtiger_crmentity.smownerid = vtiger_service.handler WHERE vtiger_crmentity.crmid = vtiger_service.serviceid");
ExecuteQuery("ALTER TABLE vtiger_service DROP COLUMN handler");
ExecutePQuery("UPDATE vtiger_field SET columnname = 'smownerid', tablename = 'vtiger_crmentity', uitype = '53', typeofdata = 'V~M', info_type = 'BAS', quickcreate = 0, quickcreatesequence = 4\r\n\t\t\t\tWHERE columnname = 'handler' AND tablename = 'vtiger_service' AND tabid = ?", array($servicesTabId));
$oldServiceOwnerColumnName = 'vtiger_service:handler:assigned_user_id:Services_Owner:V';
$newServiceOwnerColumnName = 'vtiger_crmentity:smownerid:assigned_user_id:Services_Owner:V';
ExecutePQuery("UPDATE vtiger_cvcolumnlist SET columnname=? WHERE columnname=?", array($newServiceOwnerColumnName, $oldServiceOwnerColumnName));
ExecutePQuery("UPDATE vtiger_cvadvfilter SET columnname=? WHERE columnname=?", array($newServiceOwnerColumnName, $oldServiceOwnerColumnName));
// Allow Sharing access and role-based security for Products and Services
Vtiger_Access::deleteSharing($productInstance);
Vtiger_Access::initSharing($productInstance);
Vtiger_Access::allowSharing($productInstance);
Vtiger_Access::setDefaultSharing($productInstance);
Vtiger_Access::deleteSharing($serviceInstance);
Vtiger_Access::initSharing($serviceInstance);
Vtiger_Access::allowSharing($serviceInstance);
Vtiger_Access::setDefaultSharing($serviceInstance);
Vtiger_Module::syncfile();
/* Replace 'Handler' field with 'Assigned to' field for Products and Services - ends */
ExecutePQuery("UPDATE vtiger_entityname SET fieldname = 'firstname,lastname' WHERE tabid= ? ", array($contactTab));
ExecutePQuery("UPDATE vtiger_entityname SET fieldname = 'firstname,lastname' WHERE tabid= ? ", array($leadTab));
ExecutePQuery("UPDATE vtiger_entityname SET fieldname = 'first_name,last_name' WHERE tabid= ? ", array($usersTab));
require_once 'include/utils/utils.php';
$usersQuery = "SELECT * FROM vtiger_users";
$usersResult = $adb->query($usersQuery);
$usersCount = $adb->num_rows($usersResult);
for ($i = 0; $i < $usersCount; ++$i) {
    $userId = $adb->query_result($usersResult, $i, 'id');
    $userName = $adb->query_result($usersResult, $i, 'user_name');
    $firstName = $adb->query_result($usersResult, $i, 'first_name');
Exemplo n.º 7
0
 /**
  * Create this module instance
  * @access private
  */
 function __create()
 {
     global $adb;
     self::log("Creating Module {$this->name} ... STARTED");
     $this->id = $this->__getUniqueId();
     if (!$this->tabsequence) {
         $this->tabsequence = $this->__getNextSequence();
     }
     if (!$this->label) {
         $this->label = $this->name;
     }
     $customized = 1;
     // To indicate this is a Custom Module
     $this->__handleVtigerCoreSchemaChanges();
     $adb->pquery("INSERT INTO vtiger_tab (tabid,name,presence,tabsequence,tablabel,modifiedby,\n\t\t\tmodifiedtime,customized,ownedby,version) VALUES (?,?,?,?,?,?,?,?,?,?)", array($this->id, $this->name, $this->presence, $this->tabsequence, $this->label, NULL, NULL, $customized, $this->ownedby, $this->version));
     $useisentitytype = $this->isentitytype ? 1 : 0;
     $adb->pquery('UPDATE vtiger_tab set isentitytype=? WHERE tabid=?', array($useisentitytype, $this->id));
     Vtiger_Profile::initForModule($this);
     self::syncfile();
     if ($this->isentitytype) {
         Vtiger_Access::initSharing($this);
     }
     self::log("Creating Module {$this->name} ... DONE");
 }
Exemplo n.º 8
0
    function databaseData()
    {
        global $log, $adb;
        $log->debug("Entering YetiForceUpdate::databaseData() method ...");
        $adb->pquery("UPDATE `vtiger_eventhandlers` SET `event_name` = ? WHERE `event_name` = ?", ['vtiger.entity.unlink.before', 'vtiger.entity.beforeunlink']);
        $adb->pquery("UPDATE `vtiger_eventhandlers` SET `event_name` = ? WHERE `event_name` = ?", ['vtiger.entity.unlink.after', 'vtiger.entity.afterunlink']);
        $addHandler[] = ['vtiger.entity.link.after', 'modules/ModTracker/handlers/ModTrackerHandler.php', 'ModTrackerHandler', '', 1, '[]'];
        $addHandler[] = ['vtiger.entity.unlink.after', 'modules/ModTracker/handlers/ModTrackerHandler.php', 'ModTrackerHandler', '', 1, '[]'];
        $addHandler[] = ['user.logout.before', 'modules/Users/handlers/LogoutHandler.php', 'LogoutHandler', '', 1, '[]'];
        foreach ($addHandler as $handler) {
            if (!$em) {
                $em = new VTEventsManager($adb);
            }
            $result = $adb->pquery("SELECT * FROM `vtiger_eventhandlers` WHERE event_name = ? AND handler_class = ?;", [$handler[0], $handler[3]]);
            if ($adb->num_rows($result) == 0) {
                $em->registerHandler($handler[0], $handler[1], $handler[2], $handler[3], $handler[5]);
            }
        }
        $updateColumList = [];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_leaddetails:email:email:Leads_Email:E', 'after' => 'vtiger_leaddetails:email:email:Leads_Email:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_contactdetails:email:email:Contacts_Email:E', 'after' => 'vtiger_contactdetails:email:email:Contacts_Email:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_To:I', 'after' => 'vtiger_troubletickets:parent_id:parent_id:HelpDesk_Related_To:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:I', 'after' => 'vtiger_quotes:accountid:account_id:Quotes_Account_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:I', 'after' => 'vtiger_quotes:potentialid:potential_id:Quotes_Potential_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:I', 'after' => 'vtiger_quotes:total:hdnGrandTotal:Quotes_Total:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:I', 'after' => 'vtiger_invoice:salesorderid:salesorder_id:Invoice_Sales_Order:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_invoice:total:hdnGrandTotal:Invoice_Total:I', 'after' => 'vtiger_invoice:total:hdnGrandTotal:Invoice_Total:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_pricebook:currency_id:currency_id:PriceBooks_Currency:I', 'after' => 'vtiger_pricebook:currency_id:currency_id:PriceBooks_Currency:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:I', 'after' => 'vtiger_purchaseorder:vendorid:vendor_id:PurchaseOrder_Vendor_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:I', 'after' => 'vtiger_salesorder:accountid:account_id:SalesOrder_Account_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:I', 'after' => 'vtiger_salesorder:quoteid:quote_id:SalesOrder_Quote_Name:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_vendor:email:email:Vendors_Email:E', 'after' => 'vtiger_vendor:email:email:Vendors_Email:V'];
        $updateColumList[] = ['columnname' => '', 'before' => 'vtiger_faq:product_id:product_id:Faq_Product_Name:I', 'after' => 'vtiger_faq:product_id:product_id:Faq_Product_Name:V'];
        foreach ($updateColumList as $column) {
            $result = $adb->pquery("SELECT * FROM `vtiger_cvcolumnlist` WHERE columnname = ?;", [$column['before']]);
            if ($adb->num_rows($result) > 0) {
                $adb->pquery("UPDATE `vtiger_cvcolumnlist` SET `columnname` = ? WHERE `columnname` = ? ;", [$column['after'], $column['before']]);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_backup_settings` WHERE `type` = ? AND `param` = ?;", ['folder', 'storage_folder']);
        if ($adb->num_rows($result) == 2) {
            $adb->pquery("UPDATE `vtiger_backup_settings` SET `param` = ? WHERE `type` = ? AND `param` = ? LIMIT 1 ;", ['backup_folder', 'folder', 'storage_folder']);
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_backup_settings` WHERE `type` = ? AND `param` = ?;", ['notifications', 'users']);
        if ($adb->num_rows($result) == 0) {
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['notifications', 'users', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['main', 'type', 'false']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'host', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'login', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'password', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'port', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'path', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'active', '']);
            $adb->pquery("insert  into `vtiger_backup_settings`(`type`,`param`,`value`) values (?,?,?);", ['ftp', 'status', '']);
        }
        $sql = "SELECT tabid  FROM `vtiger_tab` WHERE `name` = 'PriceBooks';";
        $result = $adb->query($sql);
        $id = $adb->query_result($result, 0, 'actionid');
        $sql = "SELECT * FROM `vtiger_actionmapping` WHERE `actionname` IN ('Export','Import','DuplicatesHandling');";
        $result = $adb->query($sql);
        $num = $adb->num_rows($result);
        for ($k = 0; $k < $num; $k++) {
            $key = $adb->query_result_raw($result, $k, 'actionid');
            $action = $adb->query_result_raw($result, $k, 'actionname');
            $permission = 1;
            if ($action == 'DuplicatesHandling') {
                $permission = 0;
            }
            $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
            $numP = $adb->num_rows($resultP);
            for ($i = 0; $i < $numP; $i++) {
                $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
                $resultQ = $adb->pquery("SELECT * FROM vtiger_profile2utility WHERE profileid = ? AND tabid = ? AND activityid = ?;", [$profileId, $id, $key]);
                if ($adb->num_rows($resultQ)) {
                    $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", [$profileId, $id, $key, $permission]);
                }
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_no_of_currency_decimals` WHERE `no_of_currency_decimals` = 0;");
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `vtiger_no_of_currency_decimals`(`no_of_currency_decimalsid`,`no_of_currency_decimals`,`sortorderid`,`presence`) values (0,'0',0,1)");
            $adb->query("insert  into `vtiger_no_of_currency_decimals`(`no_of_currency_decimalsid`,`no_of_currency_decimals`,`sortorderid`,`presence`) values (1,'1',1,1)");
        }
        $this->picklists();
        $adb->pquery("UPDATE `vtiger_field` SET `generatedtype` = ?, `presence` = ?, `typeofdata` = ?, `quickcreate` = ? WHERE `columnname` = ? AND `tablename` = ?;", [1, 2, 'V~M', 2, 'related_to', 'vtiger_potential']);
        $adb->pquery("UPDATE `vtiger_ossmailtemplates_type` SET `presence` = 0 WHERE `ossmailtemplates_type` IN (?,?) ;", ['PLL_RECORD', 'PLL_MAIL']);
        $adb->pquery("UPDATE `vtiger_relatedlists` SET actions = '' WHERE tabid = ? AND related_tabid = ? AND name = ?;", [getTabid('Quotes'), getTabid('Calculations'), 'get_related_list']);
        $adb->pquery("UPDATE `com_vtiger_workflow_tasktypes` SET modules = ? WHERE tasktypename = ?;", ['{"include":["Contacts","OSSEmployees","Accounts","Leads","Vendors"],"exclude":[]}', 'VTAddressBookTask']);
        $adb->pquery("UPDATE `vtiger_links` \n\t\t\tSET\n\t\t\t  linkicon = (\n\t\t\t\tCASE\n\t\t\t\t  WHEN linkicon = 'icon-file' \n\t\t\t\t  THEN 'glyphicon glyphicon-file' \n\t\t\t\t  WHEN linkicon = 'icon-align-justify' \n\t\t\t\t  THEN 'glyphicon glyphicon-align-justify'\n\t\t\t\t  WHEN linkicon = 'icon-tasks' \n\t\t\t\t  THEN 'glyphicon glyphicon-tasks'\n\t\t\t\t  WHEN linkicon = 'icon-user' \n\t\t\t\t  THEN 'glyphicon glyphicon-user'\n\t\t\t\t  ELSE linkicon \n\t\t\t\tEND\n\t\t\t  ) \n\t\t\tWHERE linkicon IN ('icon-file','icon-align-justify','icon-tasks','icon-user');");
        $result = $adb->pquery("SELECT * FROM `vtiger_osspdf` WHERE `title` = 'Calculation PDF' AND `content` = '';");
        if ($adb->num_rows($result)) {
            $adb->pquery("UPDATE `vtiger_osspdf` SET `content` = ? WHERE `title` = ?;", ['<title></title>
<table width="537px">
	<tbody>
		<tr>
			<td colspan="6" rowspan="2"><img src="#special_function#siteUrl#end_special_function#storage/Logo/logo_yetiforce.png" style="width: 200px;" width="200" /></td>
			<td colspan="4"><span style="font-size:6px;">#company_organizationname# #company_address# #company_code# #company_city#. VAT:#company_vatid#</span></td>
		</tr>
		<tr>
			<td colspan="5">
			<table border="1">
				<tbody>
					<tr>
						<td>
						<table cellpadding="1">
							<tbody>
								<tr>
									<td style="text-align: center;"><span style="font-size:9px;">Calculation confirmation: <strong>#calculations_no#</strong></span></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<table cellpadding="1">
							<tbody>
								<tr>
									<td style="text-align: center;"><span style="font-size:9px;">Date: #special_function#CreatedDateTime#end_special_function#</span></td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="7">&nbsp;</td>
			<td colspan="5" rowspan="2">
			<table border="1">
				<tbody>
					<tr>
						<td>
						<table cellpadding="5">
							<tbody>
								<tr>
									<td>
									<table cellpadding="0" style="font-size:8px;">
										<tbody>
											<tr>
												<td colspan="2">Issued by:</td>
												<td colspan="3">#Users_first_name# #Users_last_name#</td>
											</tr>
											<tr>
												<td colspan="2">Email:</td>
												<td colspan="3">#Users_email1#</td>
											</tr>
										</tbody>
									</table>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
		</tr>
		<tr>
			<td colspan="3">
			<table>
				<tbody>
					<tr>
						<td><span style="font-size:10px;">&nbsp;<span style="font-size:8px;">#Accounts_account_no#</span></span></td>
					</tr>
					<tr>
						<td>
						<table>
							<tbody>
								<tr>
									<td>
									<p><span style="font-size:10px;">#Accounts_accountname#<br />
									<span style="font-size:8px;">#Accounts_addresslevel8b# #Accounts_buildingnumberb# #Accounts_localnumberb#<br />
									#Accounts_addresslevel7b#, #Accounts_addresslevel5b#<br />
									<span style="font-size:10px;">#Accounts_addresslevel1b#</span><br />
									#Accounts_vat_id#</span></span></p>
									</td>
								</tr>
							</tbody>
						</table>
						</td>
					</tr>
				</tbody>
			</table>
			</td>
			<td colspan="3">&nbsp;</td>
		</tr>
	</tbody>
</table>
&nbsp;

<table>
	<tbody>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>#special_function#replaceProductTable#end_special_function#</td>
		</tr>
	</tbody>
</table>', 'Calculation PDF']);
            $adb->pquery("UPDATE `vtiger_osspdf` SET `footer_content` = '' WHERE `title` = ?;", ['Calculation PDF']);
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_marketing` WHERE `param` = 'create_always';");
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values ('conversion','create_always','false')");
        }
        $adb->pquery("UPDATE `vtiger_field` SET `fieldlabel` = ? WHERE `columnname` = ? AND `tablename` = ?;", ['Id', 'id', 'vtiger_ossmailview']);
        $adb->pquery("UPDATE `vtiger_def_org_share` SET `editstatus` = ? WHERE `ruleid` = ? AND `tabid` = ?;", [0, 5, getTabid('Calendar')]);
        $actions = [26 => 'Dashboard', 27 => 'CreateDashboardFilter', 28 => 'QuickExportToExcel'];
        foreach ($actions as $key => $action) {
            $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
            if ($adb->num_rows($result) == 0) {
                $adb->pquery("INSERT INTO `vtiger_actionmapping` (`actionid`, `actionname`, `securitycheck`) VALUES (?, ?,'0');", [$key, $action]);
            }
            $sql = "SELECT tabid, `name`  FROM `vtiger_tab` WHERE `isentitytype` = '1' AND `name` not in ('SMSNotifier','ModComments','PBXManager','Events','Emails','CallHistory','OSSMailView','');";
            $result = $adb->query($sql);
            $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
            for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
                $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
                for ($k = 0; $k < $adb->num_rows($result); $k++) {
                    $row = $adb->query_result_rowdata($result, $k);
                    $tabid = $row['tabid'];
                    $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $key]);
                    if ($adb->num_rows($resultC) == 0) {
                        $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $key, 0));
                    }
                }
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_osspdf`");
        $pdfContent = $this->pdfContent();
        while ($row = $adb->fetch_array($result)) {
            if (array_key_exists($row['title'], $pdfContent) && strpos($row['content'], '#Contacts_lastname#') !== FALSE) {
                $adb->pquery("UPDATE `vtiger_osspdf` SET `content` = ? WHERE `title` = ? ;", [$pdfContent[$row['title']], $row['title']]);
            }
        }
        $result = $adb->pquery("SELECT * FROM `vtiger_calendar_config` WHERE `type` = ? AND `name` = ? ", ['colors', 'Call']);
        if (!$adb->num_rows($result)) {
            $adb->query("insert  into `vtiger_calendar_config`(`type`,`name`,`label`,`value`) values ('colors','Call','Call','#80B584');");
        }
        $result = $adb->query('SELECT MAX(linkid) AS max_linkId FROM `vtiger_links`;');
        $maxLink = $adb->query_result_rowdata($result, 0);
        if ($maxLink[0]) {
            $maxLink = $maxLink[0];
        } else {
            $maxLink = $maxLink['max_linkId'];
        }
        $adb->pquery("UPDATE `vtiger_links_seq` SET `id` = " . $maxLink . ";");
        //sequance
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [7, getTabid('HelpDesk'), 'smownerid']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [2, getTabid('HelpDesk'), 'parent_id']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [5, getTabid('HelpDesk'), 'priority']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [4, getTabid('HelpDesk'), 'status']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [6, getTabid('HelpDesk'), 'description']);
        $adb->pquery("UPDATE `vtiger_field` SET `quickcreatesequence` = ? WHERE `tabid` = ? AND `columnname` = ?;", [3, getTabid('HelpDesk'), 'projectid']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['V~M', getTabid('SalesOrder'), 'recurring_frequency']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['D~M', getTabid('SalesOrder'), 'start_period']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['D~M~OTH~G~start_period~Start Period', getTabid('SalesOrder'), 'end_period']);
        $adb->pquery("UPDATE `vtiger_field` SET `typeofdata` = ? WHERE `tabid` = ? AND `columnname` = ?;", ['V~M', getTabid('SalesOrder'), 'payment_duration']);
        $adb->pquery("UPDATE `vtiger_field` SET `summaryfield` = ? WHERE `tabid` = ? AND `columnname` = ?;", [0, getTabid('OSSPasswords'), 'link_adres']);
        $adb->pquery("UPDATE `vtiger_field` SET `generatedtype` = ? WHERE `tabid` = ? AND `columnname` = ?;", [1, getTabid('Contacts'), 'smownerid']);
        $adb->pquery("UPDATE `vtiger_field` \n\t\t\t\t\tSET\tfieldlabel = (\n\t\t\t\t\t\tCASE\n\t\t\t\t\t\t  WHEN columnname = 'name' \n\t\t\t\t\t\t  THEN 'LBL_ATTACHMENT' \n\t\t\t\t\t\t  WHEN columnname = 'from_email' \n\t\t\t\t\t\t  THEN 'LBL_FROM' \n\t\t\t\t\t\t  WHEN columnname = 'to_email' \n\t\t\t\t\t\t  THEN 'LBL_TO' \n\t\t\t\t\t\t  WHEN columnname = 'cc_email' \n\t\t\t\t\t\t  THEN 'LBL_CC' \n\t\t\t\t\t\t  WHEN columnname = 'bcc_email' \n\t\t\t\t\t\t  THEN 'LBL_BCC' \n\t\t\t\t\t\t  ELSE fieldlabel \n\t\t\t\t\t\tEND\n\t\t\t\t\t  ) \n\t\t\t\t\tWHERE tabid = ? AND columnname IN ('name','from_email','to_email','cc_email','bcc_email');", [getTabid('Emails')]);
        $adb->pquery("UPDATE `com_vtiger_workflows` SET `test` = ? WHERE `module_name` = ? AND `summary` = ?;", ['[{"fieldname":"(related_to : (HelpDesk) from_portal)","operation":"is","value":"1","valuetype":"rawtext","joincondition":"","groupjoin":"and","groupid":"0"}]', 'ModComments', 'New comment added to ticket from portal']);
        $adb->pquery("UPDATE `vtiger_field` SET `fieldlabel` = ? WHERE `fieldlabel` = ?;", ['Verification data', 'Werification data']);
        $result = $adb->pquery("SELECT * FROM `vtiger_settings_field` WHERE `name` = ? ", ['LBL_TIMECONTROL_PROCESSES']);
        if (!$adb->num_rows($result)) {
            $blockid = $adb->query_result($adb->pquery("SELECT blockid FROM vtiger_settings_blocks WHERE label='LBL_PROCESSES'", array()), 0, 'blockid');
            $sequence = (int) $adb->query_result($adb->pquery("SELECT max(sequence) as sequence FROM vtiger_settings_field WHERE blockid=?", array($blockid)), 0, 'sequence') + 1;
            $fieldid = $adb->getUniqueId('vtiger_settings_field');
            $adb->pquery("INSERT INTO vtiger_settings_field (fieldid,blockid,sequence,name,iconpath,description,linkto)\n\t\t\tVALUES (?,?,?,?,?,?,?)", array($fieldid, $blockid, $sequence, 'LBL_TIMECONTROL_PROCESSES', '', 'LBL_TIMECONTROL_PROCESSES_DESCRIPTION', 'index.php?module=TimeControlProcesses&parent=Settings&view=Index'));
            $adb->pquery("insert  into `yetiforce_proc_tc`(`type`,`param`,`value`) values ('general','oneDay','false');");
            $adb->pquery("insert  into `yetiforce_proc_tc`(`type`,`param`,`value`) values ('general','timeOverlap','false')");
        }
        $result = $adb->pquery("SELECT * FROM `yetiforce_proc_marketing` WHERE `type` = ? AND `param` =? ;", ['conversion', 'mapping']);
        if (!$adb->num_rows($result)) {
            $adb->pquery("insert  into `yetiforce_proc_marketing`(`type`,`param`,`value`) values (?,?,?);", ['conversion', 'mapping', '[{"company":"accountname"}]']);
        }
        $adb->pquery("UPDATE `vtiger_currencies` SET `currency_symbol` = ? WHERE `currency_name` = ?;", ['₽', 'Russia, Rubles']);
        $adb->query('delete from vtiger_def_org_share where tabid NOT IN (SELECT tabid FROM `vtiger_field`)');
        $result = $adb->pquery("SELECT * FROM `vtiger_def_org_share` WHERE `tabid` IN (?,?) ", [getTabid('Faq'), getTabid('PriceBooks')]);
        if (!$adb->num_rows($result)) {
            $moduleInstance = Vtiger_Module::getInstance('Faq');
            Vtiger_Access::setDefaultSharing($moduleInstance, 'public_readwritedelete');
            Vtiger_Access::initSharing($moduleInstance);
            $moduleInstance = Vtiger_Module::getInstance('PriceBooks');
            Vtiger_Access::setDefaultSharing($moduleInstance, 'public_readwritedelete');
            Vtiger_Access::initSharing($moduleInstance);
        }
        $this->rebootSeq();
        $languageInformation = ['prefix' => 'nl_nl', 'label' => 'Dutch'];
        $result = $adb->pquery('SELECT * FROM `vtiger_language` WHERE `prefix` = ?;', ['nl_nl']);
        if (!$adb->num_rows($result)) {
            $adb->pquery('INSERT INTO vtiger_language (id,name,prefix,label,lastupdated,isdefault,active) VALUES(?,?,?,?,?,?,?)', [$adb->getUniqueId('vtiger_language'), $languageInformation['label'], $languageInformation['prefix'], $languageInformation['label'], date('Y-m-d H:i:s'), 0, 1]);
        }
        $actions = ['Import', 'Export', 'DuplicatesHandling', 'Dashboard', 'CreateDashboardFilter'];
        foreach ($actions as $action) {
            $result = $adb->pquery('SELECT actionid FROM vtiger_actionmapping WHERE actionname=?;', [$action]);
            if ($adb->num_rows($result) == 0) {
                continue;
            } else {
                $actionId = $adb->query_result_raw($result, 0, 'actionid');
            }
            $tabids = [];
            if (in_array($action, ['Import', 'Export', 'DuplicatesHandling'])) {
                $tabids[] = getTabid('PriceBooks');
            } else {
                $tabids[] = getTabid('OSSMailView');
                $tabids[] = getTabid('CallHistory');
            }
            $permission = 0;
            if (in_array($action, ['Import', 'Export'])) {
                $permission = 1;
            }
            $resultP = $adb->query("SELECT profileid FROM vtiger_profile;");
            for ($i = 0; $i < $adb->num_rows($resultP); $i++) {
                $profileId = $adb->query_result_raw($resultP, $i, 'profileid');
                foreach ($tabids as $tabid) {
                    $resultC = $adb->pquery("SELECT activityid FROM vtiger_profile2utility WHERE profileid=? AND tabid=? AND activityid=? ;", [$profileId, $tabid, $actionId]);
                    if ($adb->num_rows($resultC) == 0) {
                        $adb->pquery("INSERT INTO vtiger_profile2utility (profileid, tabid, activityid, permission) VALUES  (?, ?, ?, ?)", array($profileId, $tabid, $actionId, $permission));
                    }
                }
            }
        }
        $adb->query("UPDATE `yetiforce_menu` SET `label` = 'MEN_COMPANIES_CONTACTS' WHERE `label` = 'MEN_LEADS' AND `role` = 0;");
        $adb->pquery("UPDATE `yetiforce_menu` SET `sequence` = '24' WHERE `module` = ? AND `role` = 0 AND `type` = 0;", [getTabid('NewOrders')]);
        $adb->pquery("UPDATE `yetiforce_menu` SET `sequence` = '23' WHERE `module` = ? AND `role` = 0 AND `type` = 0;", [getTabid('Reports')]);
        $modules = [getTabid('Rss') => [0, 84, 0, 20, getTabid('Rss'), NULL, 0, NULL, 0, NULL, NULL, ''], getTabid('Portal') => [0, 84, 0, 21, getTabid('Portal'), NULL, 0, NULL, 0, NULL, NULL, ''], 'isNull' => [0, 84, 3, 22, NULL, NULL, 0, NULL, 0, NULL, NULL, NULL]];
        $result2 = $adb->pquery('SELECT * FROM yetiforce_menu WHERE role = ? AND `label` = ? AND parentid = ?;', [0, 'MEN_DATABESES', 0]);
        $parent = (int) $adb->query_result_raw($result2, 0, 'id');
        foreach ($modules as $tabid => $params) {
            if ($tabid != 'isNull') {
                $result = $adb->pquery("SELECT * FROM `yetiforce_menu` WHERE `type` = ? AND `role` =? AND `module` = ? AND parentid = ?;", [0, 0, $tabid, $parent]);
            } else {
                $result = $adb->pquery("SELECT * FROM `yetiforce_menu` WHERE `type` = ? AND `role` =? AND parentid = ? AND `module` IS NULL ;", [3, 0, $parent]);
            }
            if (!$adb->num_rows($result) || $adb->num_rows($result) == 3) {
                $params[1] = $parent;
                $adb->pquery("insert  into `yetiforce_menu`(`role`,`parentid`,`type`,`sequence`,`module`,`label`,`newwindow`,`dataurl`,`showicon`,`icon`,`sizeicon`,`hotkey`) values (" . generateQuestionMarks($params) . ");", $params);
            }
        }
        $adb->query('delete from vtiger_def_org_share where tabid NOT IN (SELECT tabid FROM `vtiger_field`)');
        $adb->query('delete from vtiger_backup;');
        $adb->query('delete from vtiger_backup_db;');
        $adb->query('delete from vtiger_backup_files;');
        $adb->query('delete from vtiger_backup_tmp;');
        $adb->query("ALTER TABLE `vtiger_contactdetails` \n\t\t\t\t\tCHANGE `contactstatus` `contactstatus` varchar(255) NULL DEFAULT '' after `notifilanguage` , \n\t\t\t\t\tCHANGE `jobtitle` `jobtitle` varchar(100) NULL DEFAULT '' after `dav_status`;");
        $adb->query("UPDATE `vtiger_users` SET `theme` = 'twilight';");
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['process', 'vtiger_activity', getTabid('Calendar')]);
        $fieldId = $adb->query_result($result1, 0, 'fieldid');
        if ($fieldId) {
            $rel = ['HelpDesk', 'Campaigns', 'Potentials'];
            $adb->pquery('delete from vtiger_fieldmodulerel WHERE fieldid = ?;', [$fieldId]);
            foreach ($rel as $relmodule) {
                $adb->pquery("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (?,?,?);", [$fieldId, 'Calendar', $relmodule]);
            }
        }
        $result1 = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['link', 'vtiger_activity', getTabid('Calendar')]);
        $fieldId = $adb->query_result($result1, 0, 'fieldid');
        if ($fieldId) {
            $rel = ['Contacts', 'Leads', 'OSSEmployees', 'Vendors', 'Accounts'];
            $adb->pquery('delete from vtiger_fieldmodulerel WHERE fieldid = ?;', [$fieldId]);
            foreach ($rel as $relmodule) {
                $adb->pquery("insert  into `vtiger_fieldmodulerel`(`fieldid`,`module`,`relmodule`) values (?,?,?);", [$fieldId, 'Calendar', $relmodule]);
            }
        }
        // add new field
        $result = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['sum_time', 'vtiger_account', getTabid('Accounts')]);
        if (!$adb->num_rows($result)) {
            $moduleInstance = Vtiger_Module::getInstance('Accounts');
            $blockInstance = Vtiger_Block::getInstance('LBL_FINANSIAL_SUMMARY', $moduleInstance);
            $fieldInstance = new Vtiger_Field();
            $fieldInstance->name = 'sum_time';
            $fieldInstance->table = 'vtiger_account';
            $fieldInstance->label = 'Total time [h]';
            $fieldInstance->column = 'sum_time';
            $fieldInstance->columntype = 'decimal(10,2)';
            $fieldInstance->uitype = 7;
            $fieldInstance->displaytype = 10;
            $fieldInstance->typeofdata = 'NN~O';
            $blockInstance->addField($fieldInstance);
        }
        $adb->pquery('delete from vtiger_ws_referencetype WHERE `fieldtypeid` = ? AND `type` = ?;', [31, 'Campaigns']);
        $result = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['legal_form', 'vtiger_leaddetails', getTabid('Leads')]);
        $leadfid = $adb->query_result($result, 0, 'fieldid');
        if ($leadfid) {
            $result = $adb->pquery("SELECT * FROM `vtiger_convertleadmapping` WHERE leadfid = ?;", [$leadfid]);
            if (!$adb->num_rows($result)) {
                $result = $adb->pquery("SELECT fieldid FROM `vtiger_field` WHERE columnname = ? AND tablename = ? AND tabid = ? ;", ['legal_form', 'vtiger_account', getTabid('Accounts')]);
                $accountfid = $adb->query_result($result, 0, 'fieldid');
                $query = "INSERT INTO vtiger_convertleadmapping (leadfid, accountfid, contactfid, potentialfid, editable) values (?,?,?,?,?);";
                $adb->pquery($query, array($leadfid, $accountfid, 0, 0, 1));
            }
        }
        $result = $adb->query('SELECT accountid FROM `vtiger_account` INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_account.accountid WHERE vtiger_crmentity.deleted=0;');
        $num = $adb->num_rows($result);
        for ($i = 0; $i < $num; $i++) {
            $accountId = $adb->query_result($result, $i, 'accountid');
            $adb->query("UPDATE `vtiger_account` SET `sum_time` = (SELECT SUM(sum_time) FROM vtiger_osstimecontrol\n\t\t\t\tINNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_osstimecontrol.osstimecontrolid\n\t\t\t\tWHERE vtiger_crmentity.deleted=0 AND  vtiger_osstimecontrol.accountid = " . $accountId . " AND osstimecontrol_status = '" . 'Accepted' . "') WHERE vtiger_account.accountid = " . $accountId . " ;");
        }
        $result = $adb->query("SELECT * FROM `vtiger_crmentity` WHERE `label` = 'Send Notification Email to Record Owner' AND `searchlabel` = 'Send Notification Email to Record Owner';");
        $num = $adb->num_rows($result);
        if ($num > 1) {
            $result = $adb->query("SELECT ossmailtemplatesid FROM `vtiger_ossmailtemplates` WHERE `name` = 'Send invitations';");
            $ossmailtemplatesid = $adb->query_result($result, 0, 'ossmailtemplatesid');
            $adb->pquery("UPDATE `vtiger_crmentity` SET `label` = ?, `searchlabel` = ? WHERE `crmid` = ? ;", ['Send invitations', 'Send invitations', $ossmailtemplatesid]);
        }
        $result = $adb->query('SELECT * FROM `vtiger_module_dashboard_widgets` WHERE `module` NOT IN (0)');
        if (!$adb->num_rows($result)) {
            $adb->query("UPDATE `vtiger_module_dashboard_widgets` w, `vtiger_links` l SET `module` = l.tabid WHERE w.linkid = l.linkid;");
        }
        $this->addFields();
        $log->debug("Exiting YetiForceUpdate::databaseData() method ...");
    }