[Vtigercrm-commits] [vtiger-commits] r5877 - in /vtigercrm/trunk/modules/Calendar: Appointment.php Calendar.php addEventUI.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Thu May 11 09:17:35 EDT 2006
Author: saraj
Date: Thu May 11 07:17:30 2006
New Revision: 5877
Log:
changes made for new calendar functionality
Modified:
vtigercrm/trunk/modules/Calendar/Appointment.php
vtigercrm/trunk/modules/Calendar/Calendar.php
vtigercrm/trunk/modules/Calendar/addEventUI.php
Modified: vtigercrm/trunk/modules/Calendar/Appointment.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/Appointment.php (original)
+++ vtigercrm/trunk/modules/Calendar/Appointment.php Thu May 11 07:17:30 2006
@@ -27,6 +27,8 @@
var $record;
var $image_name;
var $formatted_datetime;
+ var $duration_min;
+ var $duration_hour;
function Appointment()
{
@@ -34,11 +36,11 @@
$this->participant_state = Array();
$this->description = "";
}
- function readAppointment($userid, &$from_datetime, &$to_datetime)
+ function readAppointment($userid, &$from_datetime, &$to_datetime, $view)
{
global $current_user,$adb;
$shared_ids = getSharedCalendarId($current_user->id,'shared');
- $q= "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 ";
+ $q= "select activity.*, crmentity.*, account.accountname,account.accountid,activitygrouprelation.groupname FROM activity inner join crmentity on activity.activityid = crmentity.crmid left 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))
{
@@ -52,10 +54,10 @@
{
$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 .= " AND crmentity.deleted = 0) AND recurringevents.activityid is NULL ";
$q .= " ORDER by activity.date_start,activity.time_start";
-
+ //echo $q;
$r = $adb->query($q);
$n = $adb->getRowCount($r);
$a = 0;
@@ -65,18 +67,48 @@
$obj = &new Appointment();
$result = $adb->fetchByAssoc($r);
//echo '<pre>' print_r($result);echo '</pre>';
- $obj->readResult($result);
+ $obj->readResult($result, $view);
//$list_arr[$obj->record] = $obj;
$a++;
$list[] = $obj;
unset($obj);
}
+ //Get Recurring events
+ $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 ";
+ if(!is_admin($current_user))
+ {
+ $q .= " ( ";
+ }
+ $q .= " (recurringdate < '".$to_datetime->get_formatted_date()."' AND recurringdate >= '".$from_datetime->get_formatted_date(). "') ";
+ 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 = $adb->query($q);
+ $n = $adb->getRowCount($r);
+ $a = 0;
+ while ( $a < $n )
+ {
+ $obj = &new Appointment();
+ $result = $adb->fetchByAssoc($r);
+ $obj->readResult($result,$view);
+ $a++;
+ $list[] = $obj;
+ unset($obj);
+ }
+
+
usort($list,'compare');
//echo '<pre>';print_r($list);echo '</pre>';
return $list;
}
- function readResult($act_array)
+ function readResult($act_array, $view)
{
$format_sthour='';
$format_stmin='';
@@ -137,6 +169,8 @@
$this->end_time = new DateTime($end_date_arr,true);
$this->subject = $act_array["subject"];
$this->activity_type = $act_array["activitytype"];
+ $this->duration_hour = $act_array["duration_hours"];
+ $this->duration_minute = $act_array["duration_minutes"];
if($act_array["activitytype"] == 'Call')
{
$this->image_name = 'Calls.gif';
@@ -146,7 +180,10 @@
$this->image_name = 'Meetings.gif';
}
$this->record = $act_array["activityid"];
- $this->formatted_datetime= $act_array["date_start"].":".$st_hour;
+ if($view == 'day')
+ $this->formatted_datetime= $act_array["date_start"].":".$st_hour;
+ else
+ $this->formatted_datetime= $act_array["date_start"];
return;
}
Modified: vtigercrm/trunk/modules/Calendar/Calendar.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/Calendar.php (original)
+++ vtigercrm/trunk/modules/Calendar/Calendar.php Thu May 11 07:17:30 2006
@@ -53,8 +53,8 @@
case 'day':
$day_start_hour = $this->day_start_hour;
$day_end_hour = $this->day_end_hour;
- $dayview_hours = $day_end_hour - $day_start_hour;
- for($i=0;$i<=$dayview_hours;$i++)
+ //$dayview_hours = $day_end_hour - $day_start_hour;
+ for($i=$day_start_hour;$i<=$day_end_hour;$i++)
{
$layout = new Layout('hour',$this->date_time->getTodayDatetimebyIndex($i));
$this->day_slice[$layout->start_time->get_formatted_date().':'.$layout->start_time->hour] = $layout;
@@ -128,20 +128,40 @@
if ( $this->view == 'week')
{
$end_datetime = $this->date_time->get_first_day_of_changed_week('increment');
- } else {
+ } elseif($this->view == 'month') {
+ $end_datetime = $this->date_time->get_first_day_of_changed_month('increment');
+ } else {
$end_datetime = $this->date_time->get_changed_day('increment');
}
$activities = Array();
- $activities = Appointment::readAppointment($current_user->id,$this->date_time,$end_datetime);
+ $activities = Appointment::readAppointment($current_user->id,$this->date_time,$end_datetime,$this->view);
+
if(!empty($activities))
{
foreach($activities as $key=>$value)
{
if($this->view == 'day')
- array_push($this->day_slice[$value->formatted_datetime]->activities, $value);
+ {
+ array_push($this->day_slice[$value->formatted_datetime]->activities, $value);
+ }
+ elseif($this->view == 'week')
+ {
+
+ }
+ elseif($this->view == 'month')
+ {
+ array_push($this->month_array[$value->formatted_datetime]->activities,$value);
+ }
+ elseif($this->view == 'year')
+ {
+ }
+ else
+ die("view:".$this->view." is not defined");
+
}
}
+ //echo '<pre>';print_r($this->month_array);echo'</pre>';
}
Modified: vtigercrm/trunk/modules/Calendar/addEventUI.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/addEventUI.php (original)
+++ vtigercrm/trunk/modules/Calendar/addEventUI.php Thu May 11 07:17:30 2006
@@ -59,15 +59,15 @@
<td width=50% valign=top style="border-right:1px solid #dddddd">
<table border=0 cellspacing=0 cellpadding=2 width=90%>
<tr><td colspan=3 ><b>Event starts at</b></td></tr>
- <tr><td><input type="text" name="time_start" value="12:00 AM" class="textbox" style="width:90px"></td><td width=50%><img border=0 src="<?echo $image_path?>btnL3Clock.gif" alt="Set time.." title="Set time.."></td></tr>
- <tr><td><input type="text" name="date_start" value="20 Dec 2005" class="textbox" style="width:90px"></td><td width=50%><img border=0 src="<?echo $image_path?>btnL3Calendar.gif" alt="Set date.." title="Set date.."></td></tr>
+ <tr><td><input type="text" name="time_start" id="time_start" value="" class="textbox" style="width:90px"></td><td width=50%><img border=0 src="<?echo $image_path?>btnL3Clock.gif" alt="Set time.." title="Set time.."></td></tr>
+ <tr><td><input type="text" name="date_start" id="date_start" value="" class="textbox" style="width:90px"></td><td width=50%><img border=0 src="<?echo $image_path?>btnL3Calendar.gif" alt="Set date.." title="Set date.."></td></tr>
</table>
</td>
<td width=50% valign=top >
<table border=0 cellspacing=0 cellpadding=2 width=90%>
<tr><td><b>Event ends on</b></td></tr>
- <tr><td><input type="text" value="12:00 AM" class="textbox" style="width:90px"></td><td width=100%><img border=0 src="<?echo $image_path?>btnL3Clock.gif" alt="Set time.." title="Set time.."></td></tr>
- <tr><td><input type="text" name="due_date" value="20 Dec 2005" class="textbox" style="width:90px"></td><td width=100%><img border=0 src="<?echo $image_path?>btnL3Calendar.gif" alt="Set date.." title="Set date.."></td></tr>
+ <tr><td><input type="text" name="time_end" id="time_end" value="" class="textbox" style="width:90px"></td><td width=100%><img border=0 src="<?echo $image_path?>btnL3Clock.gif" alt="Set time.." title="Set time.."></td></tr>
+ <tr><td><input type="text" name="due_date" id="due_date" value="" class="textbox" style="width:90px"></td><td width=100%><img border=0 src="<?echo $image_path?>btnL3Calendar.gif" alt="Set date.." title="Set date.."></td></tr>
</table>
</td>
</tr>
More information about the vtigercrm-commits
mailing list