[Vtigercrm-commits] [vtiger-commits] r9657 - in /vtigercrm/branches/5.0.2: data/Tracker.php include/utils/CommonUtils.php modules/Users/DefaultDataPopulator.php schema/DatabaseSchema.xml
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Wed Oct 18 08:52:09 EDT 2006
Author: jerrydgeorge
Date: Wed Oct 18 06:51:09 2006
New Revision: 9657
Log:
entity name,corresponding tablename,entityid field obtained from database--Jeri
Modified:
vtigercrm/branches/5.0.2/data/Tracker.php
vtigercrm/branches/5.0.2/include/utils/CommonUtils.php
vtigercrm/branches/5.0.2/modules/Users/DefaultDataPopulator.php
vtigercrm/branches/5.0.2/schema/DatabaseSchema.xml
Modified: vtigercrm/branches/5.0.2/data/Tracker.php
==============================================================================
--- vtigercrm/branches/5.0.2/data/Tracker.php (original)
+++ vtigercrm/branches/5.0.2/data/Tracker.php Wed Oct 18 06:51:09 2006
@@ -73,144 +73,28 @@
//No genius required. Just add an if case and change the query so that it puts the tracker entry whenever you touch on the DetailView of the required entity
//get the first name and last name from the respective modules
- if($current_module =='Leads')
- {
- $query = 'select firstname,lastname from vtiger_leaddetails where leadid=' .$item_id;
- $result = $this->db->query($query);
- $firstname = $adb->query_result($result,0,'firstname');
- $lastname = $adb->query_result($result,0,'lastname');
- $item_summary = $lastname.' '.$firstname;
- }
- elseif ($current_module =='Accounts')
- {
- $query = 'select accountname from vtiger_account where accountid=' .$item_id;
- $result = $this->db->query($query);
- $accountname = $adb->query_result($result,0,'accountname');
- $item_summary = $accountname;
-
- }
- elseif($current_module =='Contacts')
- {
- $query = 'select firstname,lastname from vtiger_contactdetails where contactid=' .$item_id;
- $result = $this->db->query($query);
- $firstname = $adb->query_result($result,0,'firstname');
- $lastname = $adb->query_result($result,0,'lastname');
- $item_summary = $lastname.' '.$firstname;
-
- }
- elseif($current_module =='Potentials')
- {
- $query = 'select potentialname from vtiger_potential where potentialid=' .$item_id;
- $result = $this->db->query($query);
- $potentialname = $adb->query_result($result,0,'potentialname');
- $item_summary = $potentialname;
- }
- elseif($current_module =='Notes')
- {
- $query = 'select title from vtiger_notes where notesid=' .$item_id;
- $result = $this->db->query($query);
- $title = $adb->query_result($result,0,'title');
- $item_summary = $title;
-
- }
- elseif($current_module =='HelpDesk')
- {
- $query = 'select title from vtiger_troubletickets where ticketid=' .$item_id;
- $result = $this->db->query($query);
- $title = $adb->query_result($result,0,'title');
- $item_summary = $title;
- }
- elseif($current_module =='Calendar')
- {
- //$query = 'select name from calls where callid=' .$item_id;
- $query = 'select subject from vtiger_activity where activityid=' .$item_id;
- $result = $this->db->query($query);
- $name = $adb->query_result($result,0,'subject');
- $item_summary = $name;
- }
- elseif($current_module =='Emails')
- {
- //$query = 'select name from emails where emailid=' .$item_id;
- $query = 'select subject from vtiger_activity where activityid=' .$item_id;
- $result = $this->db->query($query);
- $name = $adb->query_result($result,0,'subject');
- $item_summary = $name;
- }
- elseif($current_module =='Products')
- {
- $query = 'select productname from vtiger_products where productid=' .$item_id;
- $result = $this->db->query($query);
- $productname = $adb->query_result($result,0,'productname');
- $item_summary = $productname;
- }
- elseif($current_module =='Users')
- {
- $query = 'select first_name,last_name from vtiger_users where id=' .$item_id;
- $result = $this->db->query($query);
- $firstname = $adb->query_result($result,0,'first_name');
- $lastname = $adb->query_result($result,0,'last_name');
- $item_summary = $lastname.' '.$firstname;
- }
- elseif($current_module =='Invoice')
- {
- $query = 'select subject from vtiger_invoice where invoiceid=' .$item_id;
- $result = $this->db->query($query);
- $invoice = $adb->query_result($result,0,'subject');
- $item_summary = $invoice;
- }
- elseif($current_module =='Quotes')
- {
- $query = 'select subject from vtiger_quotes where quoteid=' .$item_id;
- $result = $this->db->query($query);
- $quote = $adb->query_result($result,0,'subject');
- $item_summary = $quote;
- }
- elseif($current_module =='PurchaseOrder')
- {
- $query = 'select subject from vtiger_purchaseorder where purchaseorderid=' .$item_id;
- $result = $this->db->query($query);
- $po = $adb->query_result($result,0,'subject');
- $item_summary = $po;
- }
- elseif($current_module =='SalesOrder')
- {
- $query = 'select subject from vtiger_salesorder where salesorderid=' .$item_id;
- $result = $this->db->query($query);
- $so = $adb->query_result($result,0,'subject');
- $item_summary = $so;
- }
- elseif($current_module =='Vendors')
- {
- $query = 'select vendorname from vtiger_vendor where vendorid=' .$item_id;
- $result = $this->db->query($query);
- $vendor = $adb->query_result($result,0,'vendorname');
- $item_summary = $vendor;
- }
- elseif($current_module =='PriceBooks')
- {
- $query = 'select bookname from vtiger_pricebook where pricebookid=' .$item_id;
- $result = $this->db->query($query);
- $pb = $adb->query_result($result,0,'bookname');
- $item_summary = $pb;
- }
- elseif($current_module =='Campaigns')
- {
- $query = 'select campaignname from vtiger_campaign where campaignid=' .$item_id;
- $result = $this->db->query($query);
- $pb = $adb->query_result($result,0,'campaignname');
- $item_summary = $pb;
- }
- elseif($current_module =='Faq')
- {
- $query = 'select question from vtiger_faq where id=' .$item_id;
- $result = $this->db->query($query);
- $pb = $adb->query_result($result,0,'question');
- if(strlen($pb) > 30)
- {
- $pb=substr($pb,0,30).'...';
- }
- $item_summary = $pb;
- }
+ if($current_module != '')
+ {
+ $query = "select fieldname,tablename,entityidfield from vtiger_entityname where modulename = '$current_module'";
+ $result = $adb->query($query);
+ $fieldsname = $adb->query_result($result,0,'fieldname');
+ $tablename = $adb->query_result($result,0,'tablename');
+ $entityidfield = $adb->query_result($result,0,'entityidfield');
+ if(!(strpos($fieldsname,',') === false))
+ {
+ $fieldlists = explode(',',$fieldsname);
+ $fieldsname = "concat(";
+ $fieldsname = $fieldsname.implode(",' ',",$fieldlists);
+ $fieldsname = $fieldsname.")";
+ }
+ $query1 = "select $fieldsname as entityname from $tablename where $entityidfield =" .$item_id;
+ $result = $adb->query($query1);
+ $item_summary = $adb->query_result($result,0,'entityname');
+ if(strlen($item_summary) > 30)
+ {
+ $item_summary=substr($item_summary,0,30).'...';
+ }
+ }
#if condition added to skip vtiger_faq in last viewed history
$query = "INSERT into $this->table_name (user_id, module_name, item_id, item_summary) values ('$user_id', '$current_module', '$esc_item_id', ".$this->db->formatString($this->table_name,'item_summary',$item_summary).")";
Modified: vtigercrm/branches/5.0.2/include/utils/CommonUtils.php
==============================================================================
--- vtigercrm/branches/5.0.2/include/utils/CommonUtils.php (original)
+++ vtigercrm/branches/5.0.2/include/utils/CommonUtils.php Wed Oct 18 06:51:09 2006
@@ -2039,214 +2039,30 @@
global $log;
$log->debug("Entering getEntityName(".$module.") method ...");
- switch ($module)
- {
- case "Accounts" : $query = "select accountname from vtiger_account where accountid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $account_name = array();
- for ($i = 0; $i < $numrows; $i++)
- {
- $acc_id = $ids_list[$i];
- $account_name[$acc_id] = $adb->query_result($result,$i,'accountname');
- }
- return $account_name;
- break;
-
- case "Leads" : $query = "select concat(firstname,' ',lastname) as leadname from vtiger_leaddetails where leadid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $lead_name = array();
- for($i = 0; $i < $numrows; $i++)
- {
- $lead_id = $ids_list[$i];
- $lead_name[$lead_id] = $adb->query_result($result,$i,'leadname');
- }
-
- return $lead_name;
- break;
-
- case "Contacts" : $query = "select concat(firstname,' ',lastname) as contactname from vtiger_contactdetails where contactid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $contact_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $cont_id = $ids_list[$i];
- $contact_name[$cont_id] = $adb->query_result($result,$i,'contactname');
- }
-
- return $contact_name;
- break;
-
- case "Potentials" : $query = "select potentialname from vtiger_potential where potentialid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $potential_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $pot_id = $ids_list[$i];
- $potential_name[$pot_id] = $adb->query_result($result,$i,'potentialname');
- }
-
- return $potential_name;
- break;
-
- case "Quotes" : $query = "select subject from vtiger_quotes where quoteid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $quote_subject = array();
- for($i=0; $i < $numrows; $i++)
- {
- $quote_id = $ids_list[$i];
- $quote_subject[$quote_id] = $adb->query_result($result,$i,'subject');
- }
-
- return $quote_subject;
- break;
-
- case "SalesOrder" : $query = "select subject from vtiger_salesorder where salesorderid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $so_subject = array();
- for($i=0; $i < $numrows; $i++)
- {
- $so_id = $ids_list[$i];
- $so_subject[$so_id] = $adb->query_result($result,$i,'subject');
- }
-
- return $so_subject;
- break;
-
- case "Invoice" : $query = "select subject from vtiger_invoice where invoiceid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $inv_subject = array();
- for($i=0; $i < $numrows; $i++)
- {
- $inv_id = $ids_list[$i];
- $inv_subject[$inv_id] = $adb->query_result($result,$i,'subject');
- }
-
- return $inv_subject;
- break;
-
- case "Products" : $query = "select productname from vtiger_products where productid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $product_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $prod_id = $ids_list[$i];
- $product_name[$prod_id] = $adb->query_result($result,$i,'productname');
- }
-
- return $product_name;
- break;
-
- case "PriceBooks" : $query = "select bookname from vtiger_pricebook where pricebookid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $pbook_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $pbook_id = $ids_list[$i];
- $pbook_name[$pbook_id] = $adb->query_result($result,$i,'bookname');
- }
-
- return $pbook_name;
- break;
-
- case "Notes" : $query = "select title from vtiger_notes where notesid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $notes_title = array();
- for($i=0; $i < $numrows; $i++)
- {
- $note_id = $ids_list[$i];
- $notes_title[$note_id] = $adb->query_result($result,$i,'title');
- }
-
- return $notes_title;
- break;
-
- case "Calendar" : $query = "select subject from vtiger_activity where activityid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $activity_subject = array();
- for($i=0; $i < $numrows; $i++)
- {
- $act_id = $ids_list[$i];
- $activity_subject[$act_id] = $adb->query_result($result,$i,'subject');
- }
-
- return $activity_subject;
- break;
-
- case "Campaigns" : $query = "select campaignname from vtiger_campaign where campaignid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $campaign_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $cmpn_id = $ids_list[$i];
- $campaign_name[$cmpn_id] = $adb->query_result($result,$i,'campaignname');
- }
-
- return $campaign_name;
- break;
-
- case "Faq" : $query = "select question from vtiger_faq where id in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $faq_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $faq_id = $ids_list[$i];
- $faq_name[$faq_id] = $adb->query_result($result,$i,'question');
- }
-
- return $faq_name;
- break;
-
- case "Vendors" : $query = "select vendorname from vtiger_vendor where vendorid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $vendor_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $ven_id = $ids_list[$i];
- $vendor_name[$ven_id] = $adb->query_result($result,$i,'vendorname');
- }
-
- return $vendor_name;
- break;
-
- case "PurchaseOrder" : $query = "select subject from vtiger_purchaseorder where purchaseorderid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $po_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $po_id = $ids_list[$i];
- $po_name[$po_id] = $adb->query_result($result,$i,'subject');
- }
-
- return $po_name;
- break;
-
- case "HelpDesk" : $query = "select title from vtiger_troubletickets where ticketid in (".$list.")";
- $result = $adb->query($query);
- $numrows = $adb->num_rows($result);
- $ticket_name = array();
- for($i=0; $i < $numrows; $i++)
- {
- $tick_id = $ids_list[$i];
- $ticket_name[$tick_id] = $adb->query_result($result,$i,'title');
- }
-
- return $ticket_name;
- break;
+ if($module != '')
+ {
+ $query = "select fieldname,tablename,entityidfield from vtiger_entityname where modulename = '$module'";
+ $result = $adb->query($query);
+ $fieldsname = $adb->query_result($result,0,'fieldname');
+ $tablename = $adb->query_result($result,0,'tablename');
+ $entityidfield = $adb->query_result($result,0,'entityidfield');
+ if(!(strpos($fieldsname,',') === false))
+ {
+ $fieldlists = explode(',',$fieldsname);
+ $fieldsname = "concat(";
+ $fieldsname = $fieldsname.implode(",' ',",$fieldlists);
+ $fieldsname = $fieldsname.")";
+ }
+ $query1 = "select $fieldsname as entityname from $tablename where $entityidfield in (".$list.")";
+ $result = $adb->query($query1);
+ $numrows = $adb->num_rows($result);
+ $account_name = array();
+ for ($i = 0; $i < $numrows; $i++)
+ {
+ $entity_id = $ids_list[$i];
+ $entity_info[$entity_id] = $adb->query_result($result,$i,'entityname');
+ }
+ return $entity_info;
}
$log->debug("Exiting getEntityName method ...");
}
Modified: vtigercrm/branches/5.0.2/modules/Users/DefaultDataPopulator.php
==============================================================================
--- vtigercrm/branches/5.0.2/modules/Users/DefaultDataPopulator.php (original)
+++ vtigercrm/branches/5.0.2/modules/Users/DefaultDataPopulator.php Wed Oct 18 06:51:09 2006
@@ -912,6 +912,25 @@
//user Details End
+//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')");
+$this->db->query("insert into vtiger_entityname values(6,'Accounts','vtiger_account','accountname','accountid')");
+$this->db->query("insert into vtiger_entityname values(4,'Contacts','vtiger_contactdetails','lastname,firstname','contactid')");
+$this->db->query("insert into vtiger_entityname values(2,'Potentials','vtiger_potential','potentialname','potentialid')");
+$this->db->query("insert into vtiger_entityname values(8,'Notes','vtiger_notes','title','notestid')");
+$this->db->query("insert into vtiger_entityname values(13,'HelpDesk','vtiger_troubletickets','title','ticketid')");
+$this->db->query("insert into vtiger_entityname values(9,'Calendar','vtiger_activity','subject','activityid')");
+$this->db->query("insert into vtiger_entityname values(10,'Emails','vtiger_activity','subject','activityid')");
+$this->db->query("insert into vtiger_entityname values(14,'Products','vtiger_products','productname','productid')");
+$this->db->query("insert into vtiger_entityname values(29,'Users','vtiger_users','lastname,firstname','id')");
+$this->db->query("insert into vtiger_entityname values(23,'Invoice','vtiger_invoice','subject','invoiceid')");
+$this->db->query("insert into vtiger_entityname values(20,'Quotes','vtiger_quotes','subject','quoteid')");
+$this->db->query("insert into vtiger_entityname values(21,'PurchaseOrder','vtiger_purchaseorder','subject','purchaseorderid')");
+$this->db->query("insert into vtiger_entityname values(22,'SalesOrder','vtiger_salesorder','subject','salesorderid')");
+$this->db->query("insert into vtiger_entityname values(18,'Vendors','vtiger_vendor','vendorname','vendorid')");
+$this->db->query("insert into vtiger_entityname values(19,'PriceBooks','vtiger_pricebook','bookname','pricebookid')");
+$this->db->query("insert into vtiger_entityname values(26,'Campaigns','vtiger_campaign','campaignname','campaignid')");
+$this->db->query("insert into vtiger_entityname values(15,'Faq','vtiger_faq','question','id')");
// Insert End
Modified: vtigercrm/branches/5.0.2/schema/DatabaseSchema.xml
==============================================================================
--- vtigercrm/branches/5.0.2/schema/DatabaseSchema.xml (original)
+++ vtigercrm/branches/5.0.2/schema/DatabaseSchema.xml Wed Oct 18 06:51:09 2006
@@ -6082,6 +6082,29 @@
<data>
</data>
</table>
+ <table name="vtiger_entityname">
+ <field name="tabid" type="I" size="19">
+ <key />
+ <default value="0" />
+ </field>
+ <field name="modulename" type="C" size="50">
+ <notnull />
+ </field>
+ <field name="tablename" type="C" size="100">
+ <notnull />
+ </field>
+ <field name="fieldname" type="C" size="150">
+ <notnull />
+ </field>
+ <field name="entityidfield" type="C" size="150">
+ <notnull />
+ </field>
+ <index name="entityname_tabid_idx">
+ <col>tabid</col>
+ </index>
+ <opt platform="mysql">Type=InnoDB</opt>
+ </table>
+
</schema>
More information about the vtigercrm-commits
mailing list