[Vtigercrm-commits] [vtiger-commits] r10127 - /vtigercrm/branches/5.0.3/modules/Calendar/Appointment.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu Feb 1 06:55:24 EST 2007
Author: richie
Date: Thu Feb 1 04:55:19 2007
New Revision: 10127
Log:
changes made to display multiple day events --Minnie
Modified:
vtigercrm/branches/5.0.3/modules/Calendar/Appointment.php
Modified: vtigercrm/branches/5.0.3/modules/Calendar/Appointment.php
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Calendar/Appointment.php (original)
+++ vtigercrm/branches/5.0.3/modules/Calendar/Appointment.php Thu Feb 1 04:55:19 2007
@@ -33,11 +33,15 @@
var $activity_type;
var $description;
var $record;
+ var $temphour;
+ var $tempmin;
var $image_name;
var $formatted_datetime;
var $duration_min;
var $duration_hour;
var $shared = false;
+ var $recurring;
+ var $dur_hour;
function Appointment()
{
@@ -60,7 +64,9 @@
require('user_privileges/user_privileges_'.$current_user->id.'.php');
require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
$shared_ids = getSharedCalendarId($current_user->id);
- $q= "select vtiger_activity.*, vtiger_crmentity.*, vtiger_activitygrouprelation.groupname FROM vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid left join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname WHERE vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') AND (vtiger_activity.date_start < '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start >= '". $from_datetime->get_formatted_date()."') ";
+ $and = "AND ((vtiger_activity.date_start between '". $from_datetime->get_formatted_date() ."' AND '". $to_datetime->get_formatted_date()."') OR (vtiger_activity.date_start between '". $from_datetime->get_formatted_date() ."' AND '". $to_datetime->get_formatted_date()."') OR (vtiger_activity.date_start < '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start < '". $from_datetime->get_formatted_date()."') OR (vtiger_activity.date_start > '". $to_datetime->get_formatted_date() ."' AND vtiger_activity.date_start < '". $from_datetime->get_formatted_date()."'))";
+
+ $q= "select vtiger_activity.*, vtiger_crmentity.*, vtiger_activitygrouprelation.groupname FROM vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid left join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname WHERE vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') $and ";
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)
{
$sec_parameter=getListViewSecurityParameter('Calendar');
@@ -73,19 +79,48 @@
$n = $adb->getRowCount($r);
$a = 0;
$list = Array();
+
while ( $a < $n )
{
- $obj = &new Appointment();
- $result = $adb->fetchByAssoc($r);
- $obj->readResult($result, $view);
- $a++;
- $list[] = $obj;
- unset($obj);
+
+ $result = $adb->fetchByAssoc($r);
+ $start_timestamp = strtotime($result["date_start"]);
+ $end_timestamp = strtotime($result["due_date"]);
+ if($from_datetime->ts <= $start_timestamp) $from = $start_timestamp;
+ else $from = $from_datetime->ts;
+ if($to_datetime->ts <= $end_timestamp) $to = $to_datetime->ts;
+ else $to = $end_timestamp;
+ for($j = $from; $j <= $to; $j=$j+(60*60*24))
+ {
+
+ $obj = &new Appointment();
+ $temp_start = date("Y-m-d",$j);
+ $result["date_start"]= $temp_start ;
+ list($obj->temphour,$obj->tempmin) = explode(":",$result["time_start"]);
+ if($start_timestamp != $end_timestamp && $view == 'day'){
+ if($j == $start_timestamp){
+ $result["duration_hours"] = 24 - $obj->temphour;
+ }elseif($j > $start_timestamp && $j < $end_timestamp){
+ list($obj->temphour,$obj->tempmin)= $current_user->start_hour !=''?explode(":",$current_user->start_hour):explode(":","08:00");
+ $result["duration_hours"] = 24 - $obj->temphour;
+ }elseif($j == $end_timestamp){
+ list($obj->temphour,$obj->tempmin)= $current_user->start_hour !=''?explode(":",$current_user->start_hour):explode(":","08:00");
+ list($ehr,$emin) = explode(":",$result["time_end"]);
+ $result["duration_hours"] = $ehr - $obj->temphour;
+ }
+ }
+ $obj->readResult($result, $view);
+ $list[] = $obj;
+ unset($obj);
+
+ }
+ $a++;
+
}
//Get Recurring events
$q = "SELECT vtiger_activity.activityid, vtiger_activity.subject, vtiger_activity.activitytype, vtiger_crmentity.description, vtiger_activity.time_start,vtiger_activity.time_end, vtiger_activity.duration_hours, vtiger_activity.duration_minutes,vtiger_activity.due_date, vtiger_activity.priority, vtiger_activity.location,vtiger_activity.eventstatus, vtiger_crmentity.*, vtiger_recurringevents.recurringid, vtiger_recurringevents.recurringdate as date_start ,vtiger_recurringevents.recurringtype,vtiger_activitygrouprelation.groupname from vtiger_activity inner join vtiger_crmentity on vtiger_activity.activityid = vtiger_crmentity.crmid inner join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_activitygrouprelation on vtiger_activitygrouprelation.activityid=vtiger_activity.activityid left join vtiger_groups on vtiger_groups.groupname = vtiger_activitygrouprelation.groupname ";
- $q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') AND (recurringdate < '".$to_datetime->get_formatted_date()."' AND recurringdate >= '".$from_datetime->get_formatted_date(). "') ";
+ $q.=" where vtiger_crmentity.deleted = 0 and vtiger_activity.activitytype in ('Call','Meeting') AND (recurringdate between '".$from_datetime->get_formatted_date()."' and '".$to_datetime->get_formatted_date(). "') ";
if($is_admin==false && $profileGlobalPermission[1] == 1 && $profileGlobalPermission[2] == 1 && $defaultOrgSharingPermission[16] == 3)
{
@@ -94,6 +129,7 @@
}
$q .= " ORDER by vtiger_recurringevents.recurringid";
+ //echo $q;
$r = $adb->query($q);
$n = $adb->getRowCount($r);
$a = 0;
@@ -101,6 +137,7 @@
{
$obj = &new Appointment();
$result = $adb->fetchByAssoc($r);
+ list($obj->temphour,$obj->tempmin) = explode(":",$result["time_start"]);
$obj->readResult($result,$view);
$a++;
$list[] = $obj;
@@ -123,8 +160,6 @@
$format_sthour='';
$format_stmin='';
$this->description = $act_array["description"];
- //$this->account_name = $act_array["accountname"];
- //$this->account_id = $act_array["accountid"];
$this->eventstatus = $act_array["eventstatus"];
$this->priority = $act_array["priority"];
$this->subject = $act_array["subject"];
@@ -144,8 +179,13 @@
$this->ownerid = $act_array["smownerid"];
if(!is_admin($current_user))
{
- if($act_array["smownerid"] != $current_user->id)
- $this->shared = true;
+ if($act_array["smownerid"] != $current_user->id && $act_array["visibility"] == "Public"){
+ $que = "select * from vtiger_sharedcalendar where sharedid=".$current_user->id." and userid=".$act_array["smownerid"];
+ $row = $adb->query($que);
+ $no = $adb->getRowCount($row);
+ if($no > 0)
+ $this->shared = true;
+ }
}
$this->owner = getUserName($act_array["smownerid"]);
$query="SELECT cal_color FROM vtiger_users where id = ".$this->ownerid;
@@ -156,74 +196,26 @@
$this->color = $res['cal_color'];
}
}
- if($act_array["activitytype"] == 'Call')
- {
- $this->image_name = 'Call.gif';
- }
- if($act_array["activitytype"] == 'Meeting')
- {
- $this->image_name = 'Meeting.gif';
- }
+ $this->image_name = $act_array["activitytype"].".gif";
+ if(!empty($act_array["recurringid"]) && !empty($act_array["recurringtype"]))
+ $this->recurring="Recurring.gif";
+
$this->record = $act_array["activityid"];
list($styear,$stmonth,$stday) = explode("-",$act_array["date_start"]);
- if($act_array["time_start"] != null)
- {
- list($st_hour,$st_min,$st_sec) = split(":",$act_array["time_start"]);
- if($st_hour <= 9 && strlen(trim($st_hour)) < 2)
- {
- $format_sthour= '0'.$st_hour;
- }
- else
- {
- $format_sthour= $st_hour;
- }
- if($st_min <= 9 && strlen(trim($st_min)) < 2)
- {
- $format_stmin= '0'.$st_min;
- }
- else
- {
- $format_stmin = $st_min;
- }
- $st_hour= $format_sthour;
- }
- else
- {
+ if($act_array["notime"] != 1){
+ $st_hour = twoDigit($this->temphour);
+ list($sthour,$stmin) = split(":",$act_array["time_start"]);
+ }else{
$st_hour = 'notime';
- $format_stmin = '00';
- $format_sthour= '00';
+ $stmin = '00';
+ $sthour= '00';
}
list($eyear,$emonth,$eday) = explode("-",$act_array["due_date"]);
- if($act_array["time_end"] != '')
- {
- list($end_hour,$end_min,$end_sec) = split(":",$act_array["time_end"]);
- if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
- {
- $format_endhour= '0'.$end_hour;
- }
- else
- {
- $format_endhour= $end_hour;
- }
- if($end_min <= 9 && strlen(trim($end_min)) < 2)
- {
- $format_endmin= '0'.$end_min;
- }
- else
- {
- $format_endmin = $end_min;
- }
- $end_hour= $format_endhour;
- }
- else
- {
- $end_min = '50';
- $end_hour= '23';
- }
+ list($end_hour,$end_min) = split(":",$act_array["time_end"]);
$start_date_arr = Array(
- 'min' => $format_stmin,
- 'hour' => $format_sthour,
+ 'min' => $stmin,
+ 'hour' => $sthour,
'day' => $stday,
'month' => $stmonth,
'year' => $styear
More information about the vtigercrm-commits
mailing list