[Vtigercrm-commits] [vtiger-commits] r7963 - /branches/VTIGERCRM-5.0.2-MMBRICH/modules/Campaigns/Campaign.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Wed Jul 12 05:41:17 EDT 2006
Author: mmbrich
Date: Wed Jul 12 03:41:15 2006
New Revision: 7963
Log:
an attempt at _some_ kind of useful API for data manipulation/etc
Modified:
branches/VTIGERCRM-5.0.2-MMBRICH/modules/Campaigns/Campaign.php
Modified: branches/VTIGERCRM-5.0.2-MMBRICH/modules/Campaigns/Campaign.php
==============================================================================
--- branches/VTIGERCRM-5.0.2-MMBRICH/modules/Campaigns/Campaign.php (original)
+++ branches/VTIGERCRM-5.0.2-MMBRICH/modules/Campaigns/Campaign.php Wed Jul 12 03:41:15 2006
@@ -81,26 +81,104 @@
$focus = new Contact();
$button = '';
$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
- $query = 'select vtiger_contactdetails.accountid, vtiger_users.user_name,vtiger_groups.groupname, vtiger_contactdetails.contactid, vtiger_contactdetails.lastname, vtiger_contactdetails.firstname, vtiger_contactdetails.title, vtiger_contactdetails.department, vtiger_contactdetails.email, vtiger_contactdetails.phone, vtiger_crmentity.crmid, vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime from vtiger_contactdetails inner join vtiger_campaigncontrel on vtiger_campaigncontrel.contactid = vtiger_contactdetails.contactid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid left join vtiger_contactgrouprelation on vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid left join vtiger_groups on vtiger_groups.groupname=vtiger_contactgrouprelation.groupname left join vtiger_users on vtiger_crmentity.smownerid=vtiger_users.id where vtiger_campaigncontrel.campaignid = '.$id.' and vtiger_crmentity.deleted=0';
+ $query = $this->get_related_contacts_query($id);
$log->debug("Exiting get_contacts method ...");
return GetRelatedList('Campaigns','Contacts',$focus,$query,$button,$returnset);
}
+ function get_related_contacts_query($id) {
+ global $log;
+ $log->debug("Entering get_contacts_query(".$id.") method ...");
+
+ $query = "SELECT vtiger_contactdetails.accountid"
+ ." ,vtiger_users.user_name,vtiger_groups.groupname"
+ ." ,vtiger_contactdetails.contactid, vtiger_contactdetails.lastname"
+ ." ,vtiger_contactdetails.firstname, vtiger_contactdetails.title"
+ ." ,vtiger_contactdetails.department, vtiger_contactdetails.email"
+ ." ,vtiger_contactdetails.phone, vtiger_crmentity.crmid"
+ ." ,vtiger_crmentity.smownerid, vtiger_crmentity.modifiedtime"
+ ." FROM vtiger_contactdetails"
+ ." INNER JOIN vtiger_campaigncontrel"
+ ." ON vtiger_campaigncontrel.contactid=vtiger_contactdetails.contactid"
+ ." INNER JOIN vtiger_crmentity"
+ ." ON vtiger_crmentity.crmid=vtiger_contactdetails.contactid"
+ ." LEFT JOIN vtiger_contactgrouprelation"
+ ." ON vtiger_contactdetails.contactid=vtiger_contactgrouprelation.contactid"
+ ." LEFT JOIN vtiger_groups"
+ ." ON vtiger_groups.groupname=vtiger_contactgrouprelation.groupname"
+ ." LEFT JOIN vtiger_users"
+ ." ON vtiger_crmentity.smownerid=vtiger_users.id"
+ ." WHERE vtiger_campaigncontrel.campaignid='".$id."' AND vtiger_crmentity.deleted='0'"
+ ;
+
+ return $query;
+ }
function get_leads($id)
{
global $log;
$log->debug("Entering get_leads(".$id.") method ...");
global $mod_strings;
+ $returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
+
$focus = new Lead();
$button = '';
- $returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
-
- $query = 'SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid, vtiger_users.user_name, vtiger_groups.groupname, vtiger_crmentity.smownerid from vtiger_leaddetails inner join vtiger_campaignleadrel on vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_leaddetails.leadid left join vtiger_users on vtiger_crmentity.smownerid = vtiger_users.id left join vtiger_leadgrouprelation on vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid left join vtiger_groups on vtiger_groups.groupname=vtiger_leadgrouprelation.groupname where vtiger_crmentity.deleted=0 and vtiger_campaignleadrel.campaignid = '.$id;
- $log->debug("Exiting get_leads method ...");
+ $query = $this->get_related_leads_query($id);
return GetRelatedList('Campaigns','Leads',$focus,$query,$button,$returnset);
}
+ function get_related_leads_query($id) {
+ global $log;
+ $log->debug("Entering get_leads_query(".$id.") method ...");
+
+ $query = "SELECT vtiger_leaddetails.*, vtiger_crmentity.crmid, vtiger_users.user_name"
+ ." ,vtiger_groups.groupname, vtiger_crmentity.smownerid"
+ ." FROM vtiger_leaddetails"
+ ." INNER JOIN vtiger_campaignleadrel"
+ ." ON vtiger_campaignleadrel.leadid=vtiger_leaddetails.leadid"
+ ." INNER JOIN vtiger_crmentity"
+ ." ON vtiger_crmentity.crmid=vtiger_leaddetails.leadid"
+ ." LEFT JOIN vtiger_users"
+ ." ON vtiger_crmentity.smownerid=vtiger_users.id"
+ ." LEFT JOIN vtiger_leadgrouprelation"
+ ." ON vtiger_leaddetails.leadid=vtiger_leadgrouprelation.leadid"
+ ." LEFT JOIN vtiger_groups"
+ ." ON vtiger_groups.groupname=vtiger_leadgrouprelation.groupname"
+ ." WHERE vtiger_crmentity.deleted='0' AND vtiger_campaignleadrel.campaignid='".$id."'"
+ ;
+
+ $log->debug("Exiting get_leads method ...");
+ return $query;
+ }
+ /*
+ * @param integer - id of campaign to retrieve list from
+ * @return array - array of all contacts and leads from the get_related_[leads,contacts]_query function
+ *
+ */
+ function get_related_entities($id) {
+ $ret = array();
+ // first lets get the leads
+ $lead_rs = $this->db->query($this->get_related_leads_query($id));
+
+ $i=0;
+ while($lrow = $this->db->fetch_array($lead_rs)) {
+ $ret[$i]=$row;
+ $i++;
+ }
+ // now the contacts
+ $contact_rs = $this->db->query($this->get_related_contacts_query($id));
+ while($crow = $this->db->fetch_array($contact_rs)) {
+ $ret[$i]=$row;
+ $i++;
+ }
+ return $ret;
+ }
+ function get_related_actions($id) {
+
+ }
+ function get_related_oportunities($id) {
+
+ }
function get_opportunities($id)
{
global $log;
@@ -112,12 +190,73 @@
$button = '';
$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
- $query = 'select vtiger_users.user_name,vtiger_groups.groupname, vtiger_potential.potentialid, vtiger_potential.potentialname, vtiger_potential.potentialtype, vtiger_potential.sales_stage, vtiger_potential.amount, vtiger_potential.closingdate, vtiger_crmentity.crmid, vtiger_crmentity.smownerid from vtiger_campaign inner join vtiger_potential on vtiger_campaign.campaignid = vtiger_potential.campaignid inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_potential.potentialid left join vtiger_potentialgrouprelation on vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid left join vtiger_groups on vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname left join vtiger_users on vtiger_users.id=vtiger_crmentity.smownerid where vtiger_campaign.campaignid = '.$id.' and vtiger_crmentity.deleted=0';
+ $query = $this->get_related_opportunities_query($id);
if($this->column_fields['account_id'] != 0)
$log->debug("Exiting get_opportunities method ...");
return GetRelatedList('Campaigns','Potentials',$focus,$query,$button,$returnset);
}
+ function get_related_opportunities_query($id) {
+ global $log;
+ $log->debug("Entering get_related_opportunities_query(".$id.") method ...");
+
+ $query = "SELECT vtiger_users.user_name,vtiger_groups.groupname,"
+ ." vtiger_potential.potentialid, vtiger_potential.potentialname,"
+ ." vtiger_potential.potentialtype, vtiger_potential.sales_stage,"
+ ." vtiger_potential.amount, vtiger_potential.closingdate,"
+ ." vtiger_crmentity.crmid, vtiger_crmentity.smownerid"
+ ." FROM vtiger_campaign"
+ ." INNER JOIN vtiger_potential"
+ ." ON vtiger_campaign.campaignid = vtiger_potential.campaignid"
+ ." INNER JOIN vtiger_crmentity"
+ ." ON vtiger_crmentity.crmid = vtiger_potential.potentialid"
+ ." LEFT JOIN vtiger_potentialgrouprelation"
+ ." ON vtiger_potential.potentialid=vtiger_potentialgrouprelation.potentialid"
+ ." LEFT JOIN vtiger_groups"
+ ." ON vtiger_groups.groupname=vtiger_potentialgrouprelation.groupname"
+ ." LEFT JOIN vtiger_users"
+ ." ON vtiger_users.id=vtiger_crmentity.smownerid"
+ ." WHERE vtiger_campaign.campaignid='".$id."' AND vtiger_crmentity.deleted='0'"
+ ;
+ return $query;
+ }
+ function get_related_activities_query($id) {
+ global $log;
+ $log->debug("Entering get_related_activities_query(".$id.") method ...");
+
+ $query = "SELECT vtiger_contactdetails.lastname,"
+ ." vtiger_contactdetails.firstname,"
+ ." vtiger_contactdetails.contactid,"
+ ." vtiger_activity.*,"
+ ." vtiger_seactivityrel.*,"
+ ." vtiger_crmentity.crmid, vtiger_crmentity.smownerid,"
+ ." vtiger_crmentity.modifiedtime,"
+ ." vtiger_users.user_name,"
+ ." vtiger_recurringevents.recurringtype"
+ ." FROM vtiger_activity"
+ ." INNER JOIN vtiger_seactivityrel"
+ ." ON vtiger_seactivityrel.activityid = vtiger_activity.activityid"
+ ." INNER JOIN vtiger_crmentity"
+ ." ON vtiger_crmentity.crmid=vtiger_activity.activityid"
+ ." LEFT JOIN vtiger_cntactivityrel"
+ ." ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid"
+ ." LEFT JOIN vtiger_contactdetails"
+ ." ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid"
+ ." LEFT JOIN vtiger_users"
+ ." ON vtiger_users.id = vtiger_crmentity.smownerid"
+ ." LEFT OUTER JOIN vtiger_recurringevents"
+ ." ON vtiger_recurringevents.activityid = vtiger_activity.activityid"
+ ." LEFT JOIN vtiger_activitygrouprelation"
+ ." ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid"
+ ." LEFT JOIN vtiger_groups"
+ ." ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname"
+ ." WHERE vtiger_seactivityrel.crmid='".$id."'"
+ ." AND (activitytype = 'Task'"
+ ." OR activitytype = 'Call'"
+ ." OR activitytype = 'Meeting')"
+ ;
+ return $query;
+ }
function get_activities($id)
{
global $log;
@@ -132,36 +271,8 @@
$returnset = '&return_module=Campaigns&return_action=CallRelatedList&return_id='.$id;
- $query = "SELECT vtiger_contactdetails.lastname,
- vtiger_contactdetails.firstname,
- vtiger_contactdetails.contactid,
- vtiger_activity.*,
- vtiger_seactivityrel.*,
- vtiger_crmentity.crmid, vtiger_crmentity.smownerid,
- vtiger_crmentity.modifiedtime,
- vtiger_users.user_name,
- vtiger_recurringevents.recurringtype
- FROM vtiger_activity
- INNER JOIN vtiger_seactivityrel
- ON vtiger_seactivityrel.activityid = vtiger_activity.activityid
- INNER JOIN vtiger_crmentity
- ON vtiger_crmentity.crmid=vtiger_activity.activityid
- LEFT JOIN vtiger_cntactivityrel
- ON vtiger_cntactivityrel.activityid = vtiger_activity.activityid
- LEFT JOIN vtiger_contactdetails
- ON vtiger_contactdetails.contactid = vtiger_cntactivityrel.contactid
- LEFT JOIN vtiger_users
- ON vtiger_users.id = vtiger_crmentity.smownerid
- LEFT OUTER JOIN vtiger_recurringevents
- ON vtiger_recurringevents.activityid = vtiger_activity.activityid
- LEFT JOIN vtiger_activitygrouprelation
- ON vtiger_activitygrouprelation.activityid = vtiger_crmentity.crmid
- LEFT JOIN vtiger_groups
- ON vtiger_groups.groupname = vtiger_activitygrouprelation.groupname
- WHERE vtiger_seactivityrel.crmid=".$id."
- AND (activitytype = 'Task'
- OR activitytype = 'Call'
- OR activitytype = 'Meeting')";
+ $query = $this->get_related_activities_query($id);
+
$log->debug("Exiting get_activities method ...");
return GetRelatedList('Campaigns','Activities',$focus,$query,$button,$returnset);
}
More information about the vtigercrm-commits
mailing list