[Vtigercrm-commits] [vtiger-commits] r6088 - /vtigercrm/trunk/modules/Calendar/appointment.pinc
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Tue May 16 22:08:59 EDT 2006
Author: allanbush
Date: Tue May 16 20:08:54 2006
New Revision: 6088
Log:
Refs #795. Cleaned up query formatting.
Modified:
vtigercrm/trunk/modules/Calendar/appointment.pinc
Modified: vtigercrm/trunk/modules/Calendar/appointment.pinc
==============================================================================
--- vtigercrm/trunk/modules/Calendar/appointment.pinc (original)
+++ vtigercrm/trunk/modules/Calendar/appointment.pinc Tue May 16 20:08:54 2006
@@ -1842,33 +1842,46 @@
#
#
// query extended for fetching the accountname from Fredy's patch
- $q=" Select activity.*,crmentity.*,account.accountname,account.accountid,activitygrouprelation.groupname FROM ";
- $q.=" activity inner join crmentity on activity.activityid = crmentity.crmid ";
- $q.=" left outer join activitygrouprelation on activitygrouprelation.activityid=activity.activityid";
- $q.=" left join cntactivityrel on activity.activityid = cntactivityrel.activityid left join ";
- $q.=" contactdetails on cntactivityrel.contactid = contactdetails.contactid left join";
- $q.=" account on contactdetails.accountid = account.accountid";
- $q.=" inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid"; // When adding the users to the event then to show it in the users Calendar of particular user - Jaguar
- $q.=" WHERE ";
- $q.=" activity.activitytype in ('Call','Meeting') AND ";
+ $query = "SELECT activity.*,
+ crmentity.*,
+ account.accountname, account.accountid,
+ activitygrouprelation.groupname
+ FROM activity
+ INNER JOIN crmentity
+ ON activity.activityid = crmentity.crmid
+ LEFT OUTER JOIN activitygrouprelation
+ ON activitygrouprelation.activityid = activity.activityid
+ LEFT JOIN cntactivityrel
+ ON activity.activityid = cntactivityrel.activityid
+ LEFT JOIN contactdetails
+ ON cntactivityrel.contactid = contactdetails.contactid
+ LEFT JOIN account
+ ON contactdetails.accountid = account.accountid
+ INNER JOIN salesmanactivityrel
+ ON salesmanactivityrel.activityid = activity.activityid
+ WHERE activity.activitytype in ('Call','Meeting')
+ AND ";
if(!is_admin($current_user))
{
- $q .= " ( ";
- }
-
- $q.=" ((activity.date_start < '". $sx2 ."' AND activity.date_start >= '". $sx1."')";
- $q.=" and (activity.date_start like (activity.due_date) or (activity.date_start != '0000-00-00' ))";//query modified by Jag
- #$q .= " OR (a_end < ". $x2 ." AND a_end >= ". $x1 .")";
- #$q .= " OR (a_start < ". $x1 ." AND a_end >= ". $x2 .")";
- #$q .= " OR (date_start < ". $sx1 .")";
-
+ $query .= " ( ";
+ }
+
+ $query .= " ((activity.date_start < '". $sx2 ."'
+ AND activity.date_start >= '". $sx1."')
+ AND (activity.date_start LIKE activity.due_date
+ OR (activity.date_start != '0000-00-00' ))";
if(!is_admin($current_user))
{
- $q .= " ) AND ((crmentity.smownerid ='".$current_user->id."' and salesmanactivityrel.smid = '".$current_user->id."') or (crmentity.smownerid in ($shared_ids) and salesmanactivityrel.smid in ($shared_ids) and activity.visibility='Public'))";
- }
- $q .= " AND crmentity.deleted = 0)";
- $q .= " ORDER by activity.date_start,activity.time_start";
- $r = $this->db->query($q);
+ $query .= " )
+ AND ((crmentity.smownerid = '".$current_user->id."'
+ AND salesmanactivityrel.smid = '".$current_user->id."')
+ OR (crmentity.smownerid IN ($shared_ids)
+ AND salesmanactivityrel.smid IN ($shared_ids)
+ AND activity.visibility = 'Public'))";
+ }
+ $query .= " AND crmentity.deleted = 0)
+ ORDER by activity.date_start, activity.time_start";
+ $r = $this->db->query($query);
$n = $this->db->getRowCount($r);
$a = 0;
@@ -1890,21 +1903,51 @@
# Second query ( Get Recurring appointments )
#
#
- $q = "SELECT activity.activityid, activity.subject, activity.activitytype, crmentity.description, activity.time_start, activity.duration_hours, activity.duration_minutes, activity.priority, activity.location,activity.eventstatus, crmentity.*, recurringevents.recurringid, recurringevents.recurringdate as date_start ,recurringevents.recurringtype,account.accountname,account.accountid,activitygrouprelation.groupname from activity inner join crmentity on activity.activityid = crmentity.crmid inner join recurringevents on activity.activityid=recurringevents.activityid left outer join activitygrouprelation on activitygrouprelation.activityid=activity.activityid left join cntactivityrel on activity.activityid = cntactivityrel.activityid left join contactdetails on cntactivityrel.contactid = contactdetails.contactid left join account on contactdetails.accountid = account.accountid inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid";
-
- $q.=" where ( activity.activitytype in ('Call','Meeting') AND ";
+ $query = "SELECT activity.activityid, activity.subject,
+ activity.activitytype, activity.time_start,
+ activity.duration_hours, activity.duration_minutes,
+ activity.priority, activity.location,
+ activity.eventstatus,
+ crmentity.*,
+ recurringevents.recurringid, recurringevents.recurringtype,
+ recurringevents.recurringdate AS date_start,
+ account.accountname, account.accountid,
+ activitygrouprelation.groupname
+ FROM activity
+ INNER JOIN crmentity
+ ON activity.activityid = crmentity.crmid
+ INNER JOIN recurringevents
+ ON activity.activityid = recurringevents.activityid
+ LEFT OUTER JOIN activitygrouprelation
+ ON activitygrouprelation.activityid = activity.activityid
+ LEFT JOIN cntactivityrel
+ ON activity.activityid = cntactivityrel.activityid
+ LEFT JOIN contactdetails
+ ON cntactivityrel.contactid = contactdetails.contactid
+ LEFT JOIN account
+ ON contactdetails.accountid = account.accountid
+ INNER JOIN salesmanactivityrel
+ ON salesmanactivityrel.activityid = activity.activityid
+ WHERE ( activity.activitytype IN ('Call','Meeting')
+ AND ";
if(!is_admin($current_user))
{
- $q .= " ( ";
- }
- $q .= " (recurringdate < '". $sx2 ."' AND recurringdate >= '". $sx1 . "') ";
+ $query .= " ( ";
+ }
+ $query .= " (recurringdate < '". $sx2 ."'
+ AND recurringdate >= '". $sx1 . "') ";
if(!is_admin($current_user))
{
- $q .= " ) AND ((crmentity.smownerid ='".$current_user->id."' and salesmanactivityrel.smid = '".$current_user->id."' ) or (crmentity.smownerid in ($shared_ids) and salesmanactivityrel.smid in ($shared_ids) and activity.visibility='Public'))";
- }
- $q .= " AND crmentity.deleted = 0 )" ;
- $q .= " ORDER by recurringid";
- $r = $this->db->query($q);
+ $query .= " )
+ AND ((crmentity.smownerid = '".$current_user->id."'
+ AND salesmanactivityrel.smid = '".$current_user->id."' )
+ OR (crmentity.smownerid IN ($shared_ids)
+ AND salesmanactivityrel.smid IN ($shared_ids)
+ AND activity.visibility = 'Public'))";
+ }
+ $query .= " AND crmentity.deleted = 0 )
+ ORDER by recurringid";
+ $r = $this->db->query($query);
$n = $this->db->getRowCount($r);
$a = 0;
while ( $a < $n )
@@ -1923,25 +1966,36 @@
// Query created by Jagaur
# query ( Get Group activities in the calendar )
#
- $q=" Select activity.*,crmentity.*,account.accountname,account.accountid,activitygrouprelation.groupname FROM ";
- $q.=" activity inner join crmentity on activity.activityid = crmentity.crmid ";
- $q.=" inner join activitygrouprelation on activitygrouprelation.activityid=activity.activityid";
- $q.=" inner join users2group on users2group.groupname=activitygrouprelation.groupname ";
- $q.=" left join cntactivityrel on activity.activityid = cntactivityrel.activityid left join ";
- $q.=" contactdetails on cntactivityrel.contactid = contactdetails.contactid left join";
- $q.=" account on contactdetails.accountid = account.accountid";
- $q.=" inner join salesmanactivityrel on salesmanactivityrel.activityid=activity.activityid";
- $q.=" WHERE ";
- $q.=" activity.activitytype in ('Call','Meeting') AND ";
-
- $q.=" ((activity.date_start < '". $sx2 ."' AND activity.date_start >= '". $sx1."')";
- $q.=" and (activity.date_start like (activity.due_date) or (activity.date_start != '0000-00-00' ))";//query modified by Jag
-
- $q .= " AND crmentity.deleted = 0)";
- $q .= " and crmentity.smownerid=0 and users2group.userid=".$current_user->id;
- $q .= " ORDER by activity.date_start,activity.time_start";
-
- $r = $this->db->query($q);
+ $query="SELECT activity.*,
+ crmentity.*,
+ account.accountname, account.accountid,
+ activitygrouprelation.groupname
+ FROM activity
+ INNER JOIN crmentity
+ ON activity.activityid = crmentity.crmid
+ INNER JOIN activitygrouprelation
+ ON activitygrouprelation.activityid = activity.activityid
+ INNER JOIN users2group
+ ON users2group.groupname = activitygrouprelation.groupname
+ LEFT JOIN cntactivityrel
+ ON activity.activityid = cntactivityrel.activityid
+ LEFT JOIN contactdetails
+ ON cntactivityrel.contactid = contactdetails.contactid
+ LEFT JOIN account
+ ON contactdetails.accountid = account.accountid
+ INNER JOIN salesmanactivityrel
+ ON salesmanactivityrel.activityid = activity.activityid
+ WHERE activity.activitytype IN ('Call','Meeting')
+ AND ((activity.date_start < '". $sx2 ."'
+ AND activity.date_start >= '". $sx1."')
+ AND (activity.date_start LIKE activity.due_date
+ OR (activity.date_start != '0000-00-00' ))
+ AND crmentity.deleted = 0)
+ AND crmentity.smownerid = 0
+ AND users2group.userid = ".$current_user->id."
+ ORDER BY activity.date_start, activity.time_start";
+
+ $r = $this->db->query($query);
$n = $this->db->getRowCount($r);
$a = 0;
More information about the vtigercrm-commits
mailing list