diff --git a/layouts/v7/modules/Vtiger/ModuleRelatedTabs.tpl b/layouts/v7/modules/Vtiger/ModuleRelatedTabs.tpl index d3bc58e83963f4bc05aab5658259e1bb3ae37b3e..3a81505a997bfa8aeaf39078ce82f0105f94a7c7 100644 --- a/layouts/v7/modules/Vtiger/ModuleRelatedTabs.tpl +++ b/layouts/v7/modules/Vtiger/ModuleRelatedTabs.tpl @@ -11,16 +11,9 @@ <div class='related-tabs row'> <ul class="nav nav-tabs"> {foreach item=RELATED_LINK from=$DETAILVIEW_LINKS['DETAILVIEWTAB']} - {$engagementEnabledModules = ['Accounts','Contacts','Leads']} - {if $MODULE_NAME|in_array:$engagementEnabledModules && (trim($RELATED_LINK->getLabel()) == 'LBL_UPDATES')} - {assign var=RELATEDLINK_URL value="index.php?view=Detail&mode=showHistory&page=1&module="|cat:$MODULE_NAME|cat:"&record="|cat:$RECORD->getId()} - {assign var=RELATEDLINK_LABEL value="LBL_HISTORY"} - {assign var=RELATED_TAB_LABEL value="LBL_HISTORY"} - {else} - {assign var=RELATEDLINK_URL value=$RELATED_LINK->getUrl()} - {assign var=RELATEDLINK_LABEL value=$RELATED_LINK->getLabel()} - {assign var=RELATED_TAB_LABEL value={vtranslate('SINGLE_'|cat:$MODULE_NAME, $MODULE_NAME)}|cat:" "|cat:$RELATEDLINK_LABEL} - {/if} + {assign var=RELATEDLINK_URL value=$RELATED_LINK->getUrl()} + {assign var=RELATEDLINK_LABEL value=$RELATED_LINK->getLabel()} + {assign var=RELATED_TAB_LABEL value={vtranslate('SINGLE_'|cat:$MODULE_NAME, $MODULE_NAME)}|cat:" "|cat:$RELATEDLINK_LABEL} <li class="tab-item {if $RELATED_TAB_LABEL==$SELECTED_TAB_LABEL}active{/if}" data-url="{$RELATEDLINK_URL}&tab_label={$RELATED_TAB_LABEL}&app={$SELECTED_MENU_CATEGORY}" data-label-key="{$RELATEDLINK_LABEL}" data-link-key="{$RELATED_LINK->get('linkKey')}" > <a href="{$RELATEDLINK_URL}&tab_label={$RELATEDLINK_LABEL}&app={$SELECTED_MENU_CATEGORY}" class="textOverflowEllipsis"> <span class="tab-label"><strong>{vtranslate($RELATEDLINK_LABEL,{$MODULE_NAME})}</strong></span> @@ -43,7 +36,7 @@ {assign var=RELATEDMODULENAME value=$RELATED_LINK->getRelatedModuleName()} {assign var=RELATEDFIELDNAME value=$RELATED_LINK->get('linkFieldName')} {assign var="DETAILVIEWRELATEDLINKLBL" value= vtranslate($RELATED_LINK->getLabel(),$RELATEDMODULENAME)} - <li class="tab-item {if (trim($RELATED_LINK->getLabel())== trim($SELECTED_TAB_LABEL)) && ($RELATED_LINK->getId() == $SELECTED_RELATION_ID)}active{/if}" data-url="{$RELATED_LINK->getUrl()}&tab_label={$RELATED_LINK->getLabel()}&app={$SELECTED_MENU_CATEGORY}" data-label-key="{$RELATED_LINK->getLabel()}" + <li class="tab-item {if (trim($RELATED_LINK->getLabel())== trim($SELECTED_TAB_LABEL)) && ($RELATED_LINK->getId() == $SELECTED_RELATION_ID)}active{/if}" data-url="{$RELATED_LINK->getUrl()}&tab_label={$RELATED_LINK->getLabel()}&app={$SELECTED_MENU_CATEGORY}" data-label-key="{$RELATED_LINK->getLabel()}" data-module="{$RELATEDMODULENAME}" data-relation-id="{$RELATED_LINK->getId()}" {if $RELATEDMODULENAME eq "ModComments"} title {else} title="{$DETAILVIEWRELATEDLINKLBL}"{/if} {if $RELATEDFIELDNAME}data-relatedfield ="{$RELATEDFIELDNAME}"{/if}> <a href="index.php?{$RELATED_LINK->getUrl()}&tab_label={$RELATED_LINK->getLabel()}&app={$SELECTED_MENU_CATEGORY}" class="textOverflowEllipsis" displaylabel="{$DETAILVIEWRELATEDLINKLBL}" recordsCount="" > {if $RELATEDMODULENAME eq "ModComments"} diff --git a/modules/Migration/schema/600_to_610.php b/modules/Migration/schema/600_to_610.php index 66643c132b58e9e94da56f2489d10b602bd8d60b..57bbf34979838d2ac9a1260572fb41a6ab0d9f00 100644 --- a/modules/Migration/schema/600_to_610.php +++ b/modules/Migration/schema/600_to_610.php @@ -677,8 +677,8 @@ $query = 'SELECT max(sequence) as maxsequence FROM vtiger_relatedlists where tab $result = $adb->pquery($query, array($contactTabId)); $sequence = $adb->query_result($result, 0 ,'maxsequence'); -$query = 'INSERT INTO vtiger_relatedlists VALUES(?,?,?,?,?,?,?,?)'; -$result = Migration_Index_View::ExecuteQuery($query, array($relationId, $contactTabId,$vendorTabId,'get_vendors',($sequence+1),'Vendors',0,$actions)); +$query = 'INSERT INTO vtiger_relatedlists VALUES(?,?,?,?,?,?,?,?,?,?,?)'; +$result = Migration_Index_View::ExecuteQuery($query, array($relationId, $contactTabId,$vendorTabId,'get_vendors',($sequence+1),'Vendors',0,$actions,'','','')); //Schema changes for vtiger_troubletickets hours & days column Migration_Index_View::ExecuteQuery('UPDATE vtiger_field set typeofdata=? WHERE fieldname IN(?,?) AND tablename = ?', array('N~O', 'hours', 'days', 'vtiger_troubletickets')); diff --git a/modules/Migration/schema/660_to_700.php b/modules/Migration/schema/660_to_700.php index b2df87fc7c5451187c8b062be2bd4ace2ea9aa37..46d364dd06c1394a491abad77f674d7893bb6dad 100644 --- a/modules/Migration/schema/660_to_700.php +++ b/modules/Migration/schema/660_to_700.php @@ -1125,9 +1125,13 @@ if(defined('VTIGER_UPGRADE')) { //Multiple attachment support for comments $db->pquery('ALTER TABLE vtiger_seattachmentsrel DROP PRIMARY KEY', array()); $db->pquery('ALTER TABLE vtiger_seattachmentsrel ADD CONSTRAINT PRIMARY KEY (crmid,attachmentsid)', array()); - $db->pquery('ALTER TABLE vtiger_seattachmentsrel ADD CONSTRAINT fk_2_vtiger_seattachmentsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE', array()); $db->pquery('ALTER TABLE vtiger_project MODIFY COLUMN projectid INT(19) PRIMARY KEY'); + $keyResult = $db->pquery("SHOW INDEX FROM vtiger_seattachmentsrel WHERE key_name='fk_2_vtiger_seattachmentsrel'", array()); + if (!$db->num_rows($keyResult)) { + $db->pquery('ALTER TABLE vtiger_seattachmentsrel ADD CONSTRAINT fk_2_vtiger_seattachmentsrel FOREIGN KEY (crmid) REFERENCES vtiger_crmentity(crmid) ON DELETE CASCADE', array()); + } + if (!Vtiger_Utils::CheckTable('vtiger_wsapp_logs_basic')) { Vtiger_Utils::CreateTable('vtiger_wsapp_logs_basic', '(`id` int(25) NOT NULL AUTO_INCREMENT, @@ -1782,7 +1786,10 @@ if(defined('VTIGER_UPGRADE')) { } $db->pquery('ALTER TABLE vtiger_cvstdfilter DROP PRIMARY KEY', array()); - $db->pquery('ALTER TABLE vtiger_cvstdfilter DROP KEY cvstdfilter_cvid_idx', array()); + $keyResult = $db->pquery("SHOW INDEX FROM vtiger_cvstdfilter WHERE key_name='cvstdfilter_cvid_idx'", array()); + if ($db->num_rows($keyResult)) { + $db->pquery('ALTER TABLE vtiger_cvstdfilter DROP FOREIGN KEY cvstdfilter_cvid_idx', array()); + } $keyResult = $db->pquery("SHOW INDEX FROM vtiger_cvstdfilter WHERE key_name='fk_1_vtiger_cvstdfilter'", array()); if ($db->num_rows($keyResult)) { diff --git a/modules/Users/DefaultDataPopulator.php b/modules/Users/DefaultDataPopulator.php index 32adec71372d1678164a312086691d1dc83debdf..f7db6e1bedd79f6689e086f8f1315cd8a490c3db 100644 --- a/modules/Users/DefaultDataPopulator.php +++ b/modules/Users/DefaultDataPopulator.php @@ -1115,7 +1115,7 @@ class DefaultDataPopulator extends CRMEntity { $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("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','','','')"); diff --git a/modules/Vtiger/handlers/FollowRecordHandler.php b/modules/Vtiger/handlers/FollowRecordHandler.php index 2f25f57654ddd87d5c98aaab255787e3a2137c9d..dad1cd2264a74f31f07a01bb06c24a87cbbfa820 100644 --- a/modules/Vtiger/handlers/FollowRecordHandler.php +++ b/modules/Vtiger/handlers/FollowRecordHandler.php @@ -23,60 +23,63 @@ class FollowRecordHandler extends VTEventHandler { //record details $recordId = $entityData->getId(); $moduleName = $entityData->getModuleName(); - $tableName = Vtiger_Functions::getUserSpecificTableName($moduleName); - - //following users - $userIdsList = array(); - $result = $db->pquery("SELECT userid FROM $tableName WHERE recordid = ? AND starred = ? AND userid != ?", array($recordId, '1', $currentUserId)); - if ($result && $db->num_rows($result)) { - while ($rowData = $db->fetch_row($result)) { - $userIdsList[] = $rowData['userid']; + + if ($moduleName != 'Users') { + $tableName = Vtiger_Functions::getUserSpecificTableName($moduleName); + + //following users + $userIdsList = array(); + $result = $db->pquery("SELECT userid FROM $tableName WHERE recordid = ? AND starred = ? AND userid != ?", array($recordId, '1', $currentUserId)); + if ($result && $db->num_rows($result)) { + while ($rowData = $db->fetch_row($result)) { + $userIdsList[] = $rowData['userid']; + } } - } - if ($userIdsList) { - //changed fields data - $vtEntityDelta = new VTEntityDelta(); - $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true); - - if ($delta) { - $newEntity = $vtEntityDelta->getNewEntity($moduleName, $recordId); - $label = decode_html(trim($newEntity->get('label'))); - - $fieldModels = array(); - $changedValues = array(); - $skipFields = array('modifiedtime', 'modifiedby', 'label'); - $moduleModel = Vtiger_Module_Model::getInstance($moduleName); - - foreach ($delta as $fieldName => $fieldInfo) { - if (!in_array($fieldName, $skipFields)) { - $fieldModel = Vtiger_Field_Model::getInstance($fieldName, $moduleModel); - if ($fieldModel) { - $fieldModels[$fieldName] = $fieldModel; - $changedValues[$fieldName] = $fieldInfo; + if ($userIdsList) { + //changed fields data + $vtEntityDelta = new VTEntityDelta(); + $delta = $vtEntityDelta->getEntityDelta($moduleName, $recordId, true); + + if ($delta) { + $newEntity = $vtEntityDelta->getNewEntity($moduleName, $recordId); + $label = decode_html(trim($newEntity->get('label'))); + + $fieldModels = array(); + $changedValues = array(); + $skipFields = array('modifiedtime', 'modifiedby', 'label'); + $moduleModel = Vtiger_Module_Model::getInstance($moduleName); + + foreach ($delta as $fieldName => $fieldInfo) { + if (!in_array($fieldName, $skipFields)) { + $fieldModel = Vtiger_Field_Model::getInstance($fieldName, $moduleModel); + if ($fieldModel) { + $fieldModels[$fieldName] = $fieldModel; + $changedValues[$fieldName] = $fieldInfo; + } } } - } - if ($fieldModels) { - $companyDetails = getCompanyDetails(); - $userModuleModel = Users_Module_Model::getInstance('Users'); + if ($fieldModels) { + $companyDetails = getCompanyDetails(); + $userModuleModel = Users_Module_Model::getInstance('Users'); - foreach ($userIdsList as $userId) { - $userRecordModel = Users_Record_Model::getInstanceById($userId, $userModuleModel); - if ($userRecordModel && $userRecordModel->get('status') == 'Active') { + foreach ($userIdsList as $userId) { + $userRecordModel = Users_Record_Model::getInstanceById($userId, $userModuleModel); + if ($userRecordModel && $userRecordModel->get('status') == 'Active') { - $changedFieldString = $this->getChangedFieldString($fieldModels, $changedValues, $userRecordModel); - $detailViewLink = "$site_URL/index.php?module=$moduleName&view=Detail&record=$recordId"; - $recordDetailViewLink = '<a style="text-decoration:none;" target="_blank" href="'.$detailViewLink.'">'.$label.'</a>'; + $changedFieldString = $this->getChangedFieldString($fieldModels, $changedValues, $userRecordModel); + $detailViewLink = "$site_URL/index.php?module=$moduleName&view=Detail&record=$recordId"; + $recordDetailViewLink = '<a style="text-decoration:none;" target="_blank" href="'.$detailViewLink.'">'.$label.'</a>'; - $data = vtranslate('LBL_STARRED_RECORD_UPDATED', $moduleName, $currentUserModel->getName(), $recordDetailViewLink).$changedFieldString; - $body = '<table><tbody><tr><td style="padding:10px">'.nl2br(decode_html($data)).'</td></tr></tbody></table>'; + $data = vtranslate('LBL_STARRED_RECORD_UPDATED', $moduleName, $currentUserModel->getName(), $recordDetailViewLink).$changedFieldString; + $body = '<table><tbody><tr><td style="padding:10px">'.nl2br(decode_html($data)).'</td></tr></tbody></table>'; - $notificationMessage = ucwords($companyDetails['companyname']).' '.vtranslate('LBL_NOTIFICATION', $moduleName).' - '.$currentUserModel->getName(); - $subject = vtranslate('LBL_STARRED_RECORD_UPDATED', $moduleName, $notificationMessage, $label); + $notificationMessage = ucwords($companyDetails['companyname']).' '.vtranslate('LBL_NOTIFICATION', $moduleName).' - '.$currentUserModel->getName(); + $subject = vtranslate('LBL_STARRED_RECORD_UPDATED', $moduleName, $notificationMessage, $label); - $this->sendEmail($userRecordModel->get('email1'), $subject, $body, $recordId); + $this->sendEmail($userRecordModel->get('email1'), $subject, $body, $recordId); + } } } } diff --git a/modules/Vtiger/models/DashBoard.php b/modules/Vtiger/models/DashBoard.php index fe590e3838f6599be6c57d7c969214acb9425ab4..74d758fc7f137e75eb12633c7a1335729fa8508e 100644 --- a/modules/Vtiger/models/DashBoard.php +++ b/modules/Vtiger/models/DashBoard.php @@ -62,9 +62,7 @@ class Vtiger_DashBoard_Model extends Vtiger_Base_Model { } } - $sql = 'SELECT * FROM vtiger_links WHERE linktype = ? - AND tabid IN ('. generateQuestionMarks($moduleTabIdList) .') AND linkid NOT IN (SELECT linkid FROM vtiger_module_dashboard_widgets - WHERE userid = ? and dashboardtabid=? )'; + $sql = 'SELECT * FROM vtiger_links WHERE linktype = ? AND tabid IN ('. generateQuestionMarks($moduleTabIdList) .') AND linkid NOT IN (SELECT linkid FROM vtiger_module_dashboard_widgets WHERE userid = ? and dashboardtabid=? )'; $params = array('DASHBOARDWIDGET'); $params = array_merge($params, $moduleTabIdList); $params = array_merge($params, array($currentUser->getId(), $dashBoardTabId)); diff --git a/modules/Vtiger/views/Detail.php b/modules/Vtiger/views/Detail.php index 2d478f277ed2f94339633fa7f59487445f267cf0..c55fc36932afdaa098bf1e8be8968d2ede6b4bdd 100644 --- a/modules/Vtiger/views/Detail.php +++ b/modules/Vtiger/views/Detail.php @@ -18,7 +18,6 @@ class Vtiger_Detail_View extends Vtiger_Index_View { $this->exposeMethod('showModuleDetailView'); $this->exposeMethod('showModuleSummaryView'); $this->exposeMethod('showModuleBasicView'); - $this->exposeMethod('showHistory'); $this->exposeMethod('showRecentActivities'); $this->exposeMethod('showRecentComments'); $this->exposeMethod('showRelatedList'); @@ -384,17 +383,6 @@ class Vtiger_Detail_View extends Vtiger_Index_View { echo $viewer->view('DetailViewSummaryContents.tpl', $moduleName, true); } - /** - * Funtion to show History view - * @param Vtiger_Request $request - */ - function showHistory(Vtiger_Request $request){ - $moduleName = $request->getModule(); - - $viewer = $this->getViewer($request); - echo $viewer->view('History.tpl', $moduleName, true); - } - /** * Added to support Engagements view in Vtiger7 * @param Vtiger_Request $request diff --git a/schema/DatabaseSchema.xml b/schema/DatabaseSchema.xml index 91791027b1a70c5d762ee1563e879afcfb242490..5e9a2bdbee92313c467cd037b807e7fe4556fd39 100644 --- a/schema/DatabaseSchema.xml +++ b/schema/DatabaseSchema.xml @@ -6994,4 +6994,45 @@ <opt platform="mysql">Engine=InnoDB</opt> </table> + <table name="vtiger_dashboard_tabs"> + <field name="id" type="I" size="19"> + <key /> + </field> + <field name="tabname" type="C" size="50" > + <unique /> + </field> + <field name="isdefault" type="I" size="1" > + <default value="0" /> + </field> + <field name="sequence" type="I" size="5" > + <default value="2" /> + </field> + <field name="appname" type="C" size="20" /> + <field name="modulename" type="C" size="50" /> + <field name="userid" type="I" size="11"> + <unique /> + </field> + + <opt platform="mysql">Engine=InnoDB</opt> + </table> + + <table name="vtiger_dashboard_tabs" alter="true"> + <constraint>ADD CONSTRAINT vtiger_dashboard_tabs_ibfk_1 FOREIGN KEY (userid) REFERENCES vtiger_users(id) ON DELETE CASCADE</constraint> + <opt>Engine=InnoDB</opt> + </table> + + <table name="vtiger_app2tab"> + <field name="tabid" type="I" size="11" /> + <field name="appname" type="C" size="20" /> + <field name="sequence" type="I" size="19" /> + <field name="visible" type="I" size="3" > + <default value="1" /> + </field> + <opt platform="mysql">Engine=InnoDB</opt> + </table> + + <table name="vtiger_app2tab" alter="true"> + <constraint>ADD CONSTRAINT vtiger_app2tab_fk_tab FOREIGN KEY (tabid) REFERENCES vtiger_tab(tabid) ON DELETE CASCADE</constraint> + <opt>Engine=InnoDB</opt> + </table> </schema>