[Vtigercrm-commits] [vtiger-commits] r10903 - in /vtigercrm/branches/5.0.3: include/utils/ListViewUtils.php modules/CustomView/CustomView.php modules/CustomView/EditView.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Mon May 14 04:23:26 EDT 2007
Author: richie
Date: Mon May 14 02:23:13 2007
New Revision: 10903
Log:
* Fixed the issues in advance filter when we select related entity for an entity, like ticket 3755 and some others, Fixed #3755
Modified:
vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php
vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php
vtigercrm/branches/5.0.3/modules/CustomView/EditView.php
Modified: vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php
==============================================================================
--- vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php (original)
+++ vtigercrm/branches/5.0.3/include/utils/ListViewUtils.php Mon May 14 02:23:13 2007
@@ -1123,6 +1123,13 @@
{
$value = getUserName($adb->query_result($list_result,$list_result_count,'handler'));
}
+ elseif($uitype == 51)//Accounts - Member Of
+ {
+ $parentid = $adb->query_result($list_result,$list_result_count,"parentid");
+ $account_name = getAccountName($parentid);
+ $value = '<a href="index.php?module=Accounts&action=DetailView&record='.$parentid.'&parenttab='.$tabname.'" style="'.$P_FONT_COLOR.'">'.$account_name.'</a>';
+
+ }
elseif($uitype == 77)
{
$value = getUserName($adb->query_result($list_result,$list_result_count,'inventorymanager'));
@@ -1857,6 +1864,8 @@
ON vtiger_groups.groupname = vtiger_accountgrouprelation.groupname
LEFT JOIN vtiger_users
ON vtiger_users.id = vtiger_crmentity.smownerid
+ LEFT JOIN vtiger_account vtiger_account2
+ ON vtiger_account.parentid = vtiger_account2.accountid
WHERE vtiger_crmentity.deleted = 0 ";
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[$tab_id] == 3)
@@ -1985,6 +1994,22 @@
ON vtiger_senotesrel.notesid = vtiger_notes.notesid
LEFT JOIN vtiger_contactdetails
ON vtiger_contactdetails.contactid = vtiger_notes.contact_id
+ LEFT JOIN vtiger_leaddetails
+ ON vtiger_senotesrel.crmid = vtiger_leaddetails.leadid
+ LEFT JOIN vtiger_potential
+ ON vtiger_senotesrel.crmid = vtiger_potential.potentialid
+ LEFT JOIN vtiger_account
+ ON vtiger_senotesrel.crmid = vtiger_account.accountid
+ LEFT JOIN vtiger_products
+ ON vtiger_senotesrel.crmid = vtiger_products.productid
+ LEFT JOIN vtiger_invoice
+ ON vtiger_senotesrel.crmid = vtiger_invoice.invoiceid
+ LEFT JOIN vtiger_purchaseorder
+ ON vtiger_senotesrel.crmid = vtiger_purchaseorder.purchaseorderid
+ LEFT JOIN vtiger_salesorder
+ ON vtiger_senotesrel.crmid = vtiger_salesorder.salesorderid
+ LEFT JOIN vtiger_quotes
+ ON vtiger_senotesrel.crmid = vtiger_quotes.quoteid
WHERE vtiger_crmentity.deleted = 0
AND ((vtiger_senotesrel.crmid IS NULL
AND (vtiger_notes.contact_id = 0
@@ -2015,6 +2040,8 @@
ON vtiger_contactdetails.contactid = vtiger_contactscf.contactid
LEFT JOIN vtiger_account
ON vtiger_account.accountid = vtiger_contactdetails.accountid
+ LEFT JOIN vtiger_contactdetails vtiger_contactdetails2
+ ON vtiger_contactdetails.reportsto = vtiger_contactdetails2.contactid
LEFT JOIN vtiger_contactgrouprelation
ON vtiger_contactscf.contactid = vtiger_contactgrouprelation.contactid
LEFT JOIN vtiger_groups
@@ -2055,6 +2082,14 @@
ON vtiger_users.id = vtiger_crmentity.smownerid
LEFT OUTER JOIN vtiger_account
ON vtiger_account.accountid = vtiger_contactdetails.accountid
+ LEFT OUTER JOIN vtiger_leaddetails
+ ON vtiger_leaddetails.leadid = vtiger_seactivityrel.crmid
+ LEFT OUTER JOIN vtiger_account vtiger_account2
+ ON vtiger_account2.accountid = vtiger_seactivityrel.crmid
+ LEFT OUTER JOIN vtiger_potential
+ ON vtiger_potential.potentialid = vtiger_seactivityrel.crmid
+ LEFT OUTER JOIN vtiger_troubletickets
+ ON vtiger_troubletickets.ticketid = vtiger_seactivityrel.crmid
LEFT OUTER JOIN vtiger_recurringevents
ON vtiger_recurringevents.activityid = vtiger_activity.activityid
LEFT OUTER JOIN vtiger_activity_reminder
@@ -2234,6 +2269,8 @@
ON vtiger_account.accountid = vtiger_salesorder.accountid
LEFT JOIN vtiger_contactdetails
ON vtiger_salesorder.contactid = vtiger_contactdetails.contactid
+ LEFT JOIN vtiger_potential
+ ON vtiger_potential.potentialid = vtiger_salesorder.potentialid
LEFT JOIN vtiger_sogrouprelation
ON vtiger_salesorder.salesorderid = vtiger_sogrouprelation.salesorderid
LEFT JOIN vtiger_groups
Modified: vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/CustomView.php Mon May 14 02:23:13 2007
@@ -262,7 +262,7 @@
}
$fieldlabel1 = str_replace(" ","_",$fieldlabel);
- if($fieldname == 'account_id')//Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name
+ if($fieldname == 'account_id' && $fieldtablename != 'vtiger_account')//Potential,Contacts,Invoice,SalesOrder & Quotes records sort by Account Name . But for account member of we have to avoid this
$optionvalue = "vtiger_account:accountname:accountname:".$module."_".$fieldlabel1.":".$fieldtypeofdata;
else
$optionvalue = $fieldtablename.":".$fieldcolname.":".$fieldname.":".$module."_".$fieldlabel1.":".$fieldtypeofdata;
@@ -919,6 +919,26 @@
*/
function getRealValues($tablename,$fieldname,$comparator,$value,$datatype)
{
+ //we have to add the fieldname/tablename.fieldname and the corresponding value (which we want) we can add here. So that when these LHS field comes then RHS value will be replaced for LHS in the where condition of the query
+ global $adb;
+ $change_table_field = Array(
+
+ "product_id"=>"vtiger_products.productname",
+ "contactid"=>"concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)",
+ "contact_id"=>"concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)",
+ "accountid"=>"",//in cvadvfilter accountname is stored for Contact, Potential, Quotes, SO, Invoice
+ "account_id"=>"",//Same like accountid. No need to change
+ "vendorid"=>"vtiger_vendor.vendorname",
+ "vendor_id"=>"vtiger_vendor.vendorname",
+ "potentialid"=>"vtiger_potential.potentialname",
+
+ "vtiger_account.parentid"=>"vtiger_account2.accountname",
+ "quoteid"=>"vtiger_quotes.subject",
+ "salesorderid"=>"vtiger_salesorder.subject",
+ "campaignid"=>"vtiger_campaign.campaignname",
+ "vtiger_contactdetails.reportsto"=>"concat(vtiger_contactdetails2.lastname,' ',vtiger_contactdetails2.firstname)",
+ );
+
if($fieldname == "smownerid")
{
$temp_value = "( vtiger_users.user_name".$this->getAdvComparator($comparator,$value,$datatype);
@@ -927,90 +947,90 @@
}elseif( $fieldname == "inventorymanager")
{
$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,getUserId_Ol($value),$datatype);
- }else if($fieldname == "parentid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getAccountId($value),$datatype);
- }else if($fieldname == "accountid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getAccountId($value),$datatype);
- }else if($fieldname == "contactid" || $fieldname == 'contact_id')
- {
- $value = "concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)".$this->getAdvComparator($comparator,$value,$datatype);
- //$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getContactId($value),$datatype);
- }else if($fieldname == "vendor_id" || $fieldname == "vendorid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getVendorId($value),$datatype);
- }else if($fieldname == "potentialid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getPotentialId($value),$datatype);
- }else if($fieldname == "quoteid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getQuoteId($value),$datatype);
- }
- else if($fieldname == "product_id")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getProductId($value),$datatype);
+ }
+ elseif($change_table_field[$fieldname] != '')//Added to handle special cases
+ {
+ $value = $change_table_field[$fieldname].$this->getAdvComparator($comparator,$value,$datatype);
+ }
+ elseif($change_table_field[$tablename.".".$fieldname] != '')//Added to handle special cases
+ {
+ $value = $change_table_field[$tablename.".".$fieldname].$this->getAdvComparator($comparator,$value,$datatype);
}
else if($fieldname == "handler")
{
$value = "vtiger_users.user_name".$this->getAdvComparator($comparator,$value,$datatype);
}
- else if($fieldname == "discontinued")
- {
- if($value == 'yes')
- $value=1;
- else if($value == 'no')
- $value=0;
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$value,$datatype);
- }
- else if($fieldname == "salesorderid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$this->getSoId($value),$datatype);
- }
else if($fieldname == "crmid" || $fieldname == "parent_id")
{
- //Added on 14-10-2005 -- for HelpDesk
- if($this->customviewmodule == 'HelpDesk' && $fieldname == "crmid")
- {
- $value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$value,$datatype);
- }
- else
- {
- $value = $tablename.".".$fieldname." in (".$this->getSalesEntityId($value).") ";
- }
+ $value = $this->getSalesRelatedName($comparator,$value,$datatype,$tablename,$fieldname);
}
else
{
+ //For checkbox type values, we have to convert yes/no as 1/0 to get the values
+ if(getUItype($this->customviewmodule, $fieldname) == 56)
+ {
+ if($value == 'yes') $value = 1;
+ elseif($value == 'no') $value = 0;
+ }
+
$value = $tablename.".".$fieldname.$this->getAdvComparator($comparator,$value,$datatype);
}
return $value;
}
-
- /** to get the entityId for the given module
- * @param $setype :: type string
- * @returns $parent_id as a string of comma seperated id
- * $id,$id1,$id2, ---- $idn
+
+ /** to get the related name for the given module
+ * @param $comparator :: type string,
+ * @param $value :: type string,
+ * @param $datatype :: type string,
+ * @returns $value :: string
*/
- function getSalesEntityId($setype)
- {
- global $log;
- $log->info("in getSalesEntityId ".$setype);
- global $adb;
- $sql = "select crmid from vtiger_crmentity where setype='".$setype."' and deleted = 0";
- $result = $adb->query($sql);
- while($row = $adb->fetch_array($result))
- {
- $parent_id[] = $row["crmid"];
- }
- if(isset($parent_id))
- {
- $parent_id = implode(",",$parent_id);
- }else
- {
- $parent_id = 0;
- }
- return $parent_id;
+ function getSalesRelatedName($comparator,$value,$datatype,$tablename,$fieldname)
+ {
+ global $log;
+ $log->info("in getSalesRelatedName ".$comparator."==".$value."==".$datatype."==".$tablename."==".$fieldname);
+ global $adb;
+
+ $adv_chk_value = $value;
+ $value = '(';
+ $sql = "select distinct(setype) from vtiger_crmentity where crmid in (select ".$fieldname." from ".$tablename.")";
+ $res=$adb->query($sql);
+ for($s=0;$s<$adb->num_rows($res);$s++)
+ {
+ if($s != 0)
+ $value .= ' or ';
+ $modulename=$adb->query_result($res,$s,"setype");
+ if($modulename == 'Accounts')
+ {
+ if($this->customviewmodule == 'Calendar')
+ $value .= 'vtiger_account2.accountname';
+ else
+ $value .= 'vtiger_account.accountname';
+ }
+ if($modulename == 'Leads')
+ $value .= "concat(vtiger_leaddetails.lastname,' ',vtiger_leaddetails.firstname)";
+ if($modulename == 'Potentials')
+ $value .= 'vtiger_potential.potentialname';
+ if($modulename == 'Products')
+ $value .= 'vtiger_products.productname';
+ if($modulename == 'Invoice')
+ $value .= 'vtiger_invoice.subject';
+ if($modulename == 'PurchaseOrder')
+ $value .= 'vtiger_purchaseorder.subject';
+ if($modulename == 'SalesOrder')
+ $value .= 'vtiger_salesorder.subject';
+ if($modulename == 'Quotes')
+ $value .= 'vtiger_quotes.subject';
+ if($modulename == 'Contacts')
+ $value .= "concat(vtiger_contactdetails.lastname,' ',vtiger_contactdetails.firstname)";
+ if($modulename == 'HelpDesk')
+ $value .= 'vtiger_troubletickets.title';
+
+ $value .= $this->getAdvComparator($comparator,$adv_chk_value,$datatype);
+ }
+ $value .= ")";
+ $log->info("in getSalesRelatedName ".$comparator."==".$value."==".$datatype."==".$tablename."==".$fieldname);
+ return $value;
}
/** to get the salesorder id for the given sales order subject
Modified: vtigercrm/branches/5.0.3/modules/CustomView/EditView.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/CustomView/EditView.php (original)
+++ vtigercrm/branches/5.0.3/modules/CustomView/EditView.php Mon May 14 02:23:13 2007
@@ -421,6 +421,7 @@
"vtiger_contactdetails:email:email:Contacts_Email:E"=>"vtiger_contactdetails:email:email:Contacts_Email:V",
"vtiger_contactdetails:yahooid:yahooid:Contacts_Yahoo_Id:E"=>"vtiger_contactdetails:yahooid:yahooid:Contacts_Yahoo_Id:V",
"vtiger_account:accountname:accountname:Contacts_Account_Name:I"=>"vtiger_account:accountname:accountname:Contacts_Account_Name:V",
+"vtiger_account:parentid:account_id:Accounts_Member_Of:I"=>"vtiger_account:parentid:account_id:Accounts_Member_Of:V",
"vtiger_leaddetails:email:email:Leads_Email:E"=>"vtiger_leaddetails:email:email:Leads_Email:V",
"vtiger_leaddetails:yahooid:yahooid:Leads_Yahoo_Id:E"=>"vtiger_leaddetails:yahooid:yahooid:Leads_Yahoo_Id:V",
"vtiger_activity_reminder:reminder_time:reminder_time:Calendar_Send_Reminder:I"=>"vtiger_activity_reminder:reminder_time:reminder_time:Calendar_Send_Reminder:C",
More information about the vtigercrm-commits
mailing list