[Vtigercrm-commits] [vtiger-commits] r5836 - in /vtigercrm/trunk/modules/Calendar: Appointment.php Calendar.php calendarLayout.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Wed May 10 09:46:17 EDT 2006


Author: saraj
Date: Wed May 10 07:46:11 2006
New Revision: 5836

Log:
changes made for new calendar UI

Modified:
    vtigercrm/trunk/modules/Calendar/Appointment.php
    vtigercrm/trunk/modules/Calendar/Calendar.php
    vtigercrm/trunk/modules/Calendar/calendarLayout.php

Modified: vtigercrm/trunk/modules/Calendar/Appointment.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/Appointment.php (original)
+++ vtigercrm/trunk/modules/Calendar/Appointment.php Wed May 10 07:46:11 2006
@@ -13,25 +13,28 @@
 require_once('modules/Activities/Activity.php');
 class Appointment
 {
-	var $db;
 	var $start_time;
 	var $end_time;
 	var $subject;
-	var $participant = Array();
-	var $participant_state = Array();
+	var $participant;
+	var $participant_state;
 	var $contact_name;
 	var $account_id;
 	var $account_name;
 	var $eventstatus;
 	var $activity_type;
-	var $description = "";
+	var $description;
 	var $record;
+	var $image_name;
+	var $formatted_datetime;
 
 	function Appointment()
 	{
-		$this->db = new PearDatabase();
+		$this->participant = Array();
+		$this->participant_state = Array();
+		$this->description = "";
 	}	
-	function read_appointment($userid, &$from_datetime, &$to_datetime)
+	function readAppointment($userid, &$from_datetime, &$to_datetime)
 	{
 		global $current_user,$adb;
 		$shared_ids = getSharedCalendarId($current_user->id,'shared');		
@@ -53,31 +56,109 @@
                 $q .= " ORDER by activity.date_start,activity.time_start";
 
 
-		/*$r = $adb->query($q);
+		$r = $adb->query($q);
                 $n = $adb->getRowCount($r);
                 $a = 0;
-
+		$list = Array();
                 while ( $a < $n )
                 {
-                        $o = &new Appointment();
+                        $obj = &new Appointment();
                         $result = $adb->fetchByAssoc($r);
-			echo '<pre>';print_r($result);echo '</pre>';
                         //echo '<pre>' print_r($result);echo '</pre>';
-                        //print_r($result);
-                        //$o->read_result($r,$a);
-                        $o->read_result($result);
+                        $obj->readResult($result);
+			//$list_arr[$obj->record] = $obj;
                         $a++;
-                        if ( $o->see_ok() ) {
-                                //Get all participants 
-                                //$o->read_participants();
-                                //print("GS --> see");
-                                $obj->callist[$o->record_id] = &$o;
-                        }
-                        unset($o);
-                }*/
+			$list[] = $obj;
+                        unset($obj);
+                }
+		usort($list,'compare');
+		//echo '<pre>';print_r($list);echo '</pre>';
+		return $list;
+	}
+
+	function readResult($act_array)
+	{
+		$format_sthour='';
+                $format_stmin='';
+                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;
+                }
+		list($styear,$stmonth,$stday) = explode("-",$act_array["date_start"]);
+                $startdate = $act_array["date_start"] .' ' . $format_sthour .":" . $format_stmin .":00";
+		$start_date_arr = Array(
+					'min'   => $format_stmin,
+					'hour'  => $format_sthour,
+					'day'   => $stday,
+					'month' => $stmonth,
+					'year'  => $styear
+				       );
+                //end time calculation
+                $end_hour = 0;
+                $end_min = $st_min + $act_array["duration_minutes"];
+                if($end_min <= 9) $end_min= '0'.$end_min;
+		if($end_min >= 60)
+                {
+                        $end_min = $end_min%60;
+                        if($end_min <= 9) $end_min= '0'.$end_min;
+                        $end_hour++;
+                }
+                $end_hour = $end_hour + $st_hour + $act_array["duration_hours"];
+                if($end_hour <= 9) $end_hour= '0'.$end_hour;
+                if ($end_hour > 23) $end_hour = 23;
+		list($eyear,$emonth,$eday) = explode("-",$act_array["due_date"]);
+		$enddate = $act_array["date_start"] .' ' . $end_hour .":" . $end_min .":00";
+		$end_date_arr = Array(
+                                        'min'   => $end_min,
+                                        'hour'  => $end_hour,
+                                        'day'   => $eday,
+                                        'month' => $emonth,
+                                        'year'  => $eyear
+                                       );
+
+                $this->description       = $act_array["description"];
+                $this->start_time        = new DateTime($start_date_arr,true);
+                $this->account_name      = $act_array["accountname"];    
+                $this->account_id        = $act_array["accountid"];      
+                $this->eventstatus       = $act_array["eventstatus"];    
+                $this->end_time          = new DateTime($end_date_arr,true);
+                $this->subject           = $act_array["subject"];
+                $this->activity_type     = $act_array["activitytype"];
+		if($act_array["activitytype"] == 'Call')
+		{
+			$this->image_name = 'Calls.gif';
+		}
+		if($act_array["activitytype"] == 'Meeting')
+		{
+			$this->image_name = 'Meetings.gif';
+		}
+                $this->record            = $act_array["activityid"];
+		$this->formatted_datetime= $act_array["date_start"].":".$st_hour;
 		return;
 	}
 	
 	
 }
+
+function compare($a,$b)
+{
+	if ($a->start_time->ts == $b->start_time->ts)
+	{
+		return 0;
+   	}
+	return ($a->start_time->ts < $b->start_time->ts) ? -1 : 1;
+}
 ?>

Modified: vtigercrm/trunk/modules/Calendar/Calendar.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/Calendar.php (original)
+++ vtigercrm/trunk/modules/Calendar/Calendar.php Wed May 10 07:46:11 2006
@@ -133,7 +133,15 @@
                 }
 		
 		$activities = Array();
-		$activities = Appointment::read_appointment($current_user->id,$this->date_time,$end_datetime);
+		$activities = Appointment::readAppointment($current_user->id,$this->date_time,$end_datetime);
+		if(!empty($activities))
+		{
+			foreach($activities as $key=>$value)
+			{
+				if($this->view == 'day')
+					array_push($this->day_slice[$value->formatted_datetime]->activities,  $value);
+			}
+		}
 		
 	}
 	

Modified: vtigercrm/trunk/modules/Calendar/calendarLayout.php
==============================================================================
--- vtigercrm/trunk/modules/Calendar/calendarLayout.php (original)
+++ vtigercrm/trunk/modules/Calendar/calendarLayout.php Wed May 10 07:46:11 2006
@@ -295,15 +295,19 @@
 						<span class="genHeaderBig">'.$hour.'</span>
 						<span class="genHeaderGray">'.$sub_str.'</span>
 					</td>
-					<td style="border-bottom: 1px solid rgb(204, 204, 204);" onmouseover="show(\''.$hour.''.$sub_str.'\')" onmouseout="hide(\''.$hour.''.$sub_str.'\')" height="65">
+					<td style="border-bottom: 1px solid rgb(204, 204, 204); width:5%;" onmouseover="show(\''.$hour.''.$sub_str.'\')" onmouseout="hide(\''.$hour.''.$sub_str.'\')" height="65">
 			                	<div id="'.$hour.''.$sub_str.'" style="display: none;">
 							<a onClick="gshow(\'addEvent\')" href="javascript:void(0)"><img src="'.$cal['IMAGE_PATH'].'cal_add.jpg" border="0"></a>
 						</div>
-					</td>';
+					</td>
+					<td style="border-bottom: 1px solid rgb(204, 204, 204);">';
+		//echo '<pre>';print_r($cal);echo '</pre>';
+		
+		$dayview_layout .= getEventLayer($cal,$cal['calendar']->slices[$i]);
 		/*get events/tasks that has current date as starting time
 			*/
 		//$dayview_layout .= 
-		$dayview_layout .='		
+		$dayview_layout .=' </td>		
 				    </tr>';
 	}
 	$dayview_layout .= '<tr><td style="border-right: 1px solid rgb(102, 102, 102);">&nbsp;</td><td>&nbsp;</td></tr>
@@ -454,6 +458,47 @@
 {
 }
 
+
+function getEventLayer(& $cal,$slice)
+{
+	$eventlayer = '';
+	$arrow_img_name = '';
+	$act = $cal['calendar']->day_slice[$slice]->activities;
+	if(!empty($act))
+	{
+		for($i=0;$i<count($act);$i++)
+		{
+			$arrow_img_name = 'event'.$cal['calendar']->day_slice[$slice]->start_time->hour.'_'.$i;
+			$subject = $act[$i]->subject;
+			if(strlen($subject)>25)
+				$subject = substr($subject,0,25)."...";
+			$start_hour = $act[$i]->start_time->hour;
+			$account_name = $act[$i]->accountname;
+			$image = $cal['IMAGE_PATH'].''.$act[$i]->image_name;
+		$eventlayer .='<div class ="eventLay" id="'.$cal['calendar']->day_slice[$slice]->start_time->hour.'_'.$i.'">
+					<table border="0" cellpadding="0" cellspacing="0" width="95%">
+						<tr onmouseover="show(\''.$arrow_img_name.'\');" onmouseout="hide(\''.$arrow_img_name.'\');">
+						<td align="left" width="5%"><img src="'.$image.'" align="right top"></td>
+						<td align="left" width="85%"><span class="fontBold">'.$account_name.'</span><br>
+							'.$start_hour.',<span class="orgTab">'.$subject.'</span>&nbsp;
+							<a href="#" class="webMnu">[More...]</a>
+					
+						</td>
+						<td align="right" width="5%">
+							<div id="'.$arrow_img_name.'" style="display: none;">
+								<a href="#" onclick="fnvshobj(this,\'reportLay\');" onmouseout="fninvsh(\'reportLay\')">
+								<img src="'.$cal['IMAGE_PATH'].'cal_event.jpg" border="0"></a>
+							</div>
+						</td>
+						</tr>
+					</table>
+				</div><br>';
+		}
+		return $eventlayer;
+	}
+}
+
+
 function getEventList(& $calendar,$start_date,$end_date,$info='')
 {
 	$Entries = Array();
@@ -484,51 +529,93 @@
                 $duration_min = $adb->query_result($result,$i,"duration_minutes");
 		$start_time = $adb->query_result($result,$i,"time_start");
 		$end_time = '';
+		list($hour,$min) = explode(":",$start_time);
 		if($calendar['calendar']->hour_format == 'am/pm')
 		{
 			//echo $start_time;
-			if($start_time>'12:00')
+			if($hour>'12')
 			{
-				$time = explode(":",$start_time);
-				$hour = $time[0] - 12;
-				$min = $time[1];
-				$start_time = $hour.":".$min."pm";
+				$hour = $hour - 12;
+				$start_hour = $hour;
+				if($start_hour <= 9 && strlen(trim($start_hour)) < 2)
+                                        $start_hour = "0".$start_hour;
+				$start_time = $start_hour.":".$min."pm";
 				$end_min = $min+$duration_min;
 				$end_hour = $hour+$duration_hour;
-				if($end_min>60)
+				if($end_min>=60)
 				{
-					$end_min = $end_min - 60;
-					$end_hour = $end_hour + 1;
+					$end_min = $end_min%60;
+					$end_hour++;
 				}
-				if($end_min == 0)
-					$end_min = "00";
+				if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
+                                        $end_hour = "0".$end_hour;
+				if($end_min <= 9 && strlen(trim($end_min)) < 2)
+					$end_min = "0".$end_min;
 				$end_time = $end_hour.":".$end_min."pm";
 				//echo $start_time;
 			}
+			elseif($hour == '12')
+			{
+				$start_hour = $hour;
+                                if($start_hour <= 9 && strlen(trim($start_hour)) < 2)
+                                        $start_hour = "0".$start_hour;
+				$start_time = $start_hour.":".$min."pm";
+				$end_min = $min+$duration_min;
+                                $end_hour = $hour+$duration_hour;
+				if($end_min>=60)
+                                {
+                                        $end_min = $end_min%60;
+                                        $end_hour++;
+                                }
+				if($end_hour>'12')
+                                {
+                                        $end_hour = $end_hour - 12;
+					if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
+	                                        $end_hour = "0".$end_hour;
+                                        if($end_min <= 9 && strlen(trim($end_min)) < 2)
+                                                $end_min = "0".$end_min;
+                                        $end_time = $end_hour.":".$end_min."pm";
+                                }
+                                else
+                                {
+					if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
+	                                        $end_hour = "0".$end_hour;
+                                        if($end_min <= 9 && strlen(trim($end_min)) < 2)
+                                                $end_min = "0".$end_min;
+                                        $end_time  = $end_hour.":".$end_min."am";
+                                }
+			}
 			else
 			{
-				$time = explode(":",$start_time);
-                                $hour = $time[0];
-                                $min = $time[1];
-				$start_time = $start_time."am";
+				$start_hour = $hour;
+                                if($start_hour <= 9 && strlen(trim($start_hour)) < 2)
+                                        $start_hour = "0".$start_hour;
+				$start_time = $start_hour.":".$min."am";
 				$end_min = $min+$duration_min;
                                 $end_hour = $hour+$duration_hour;
-				if($end_min>60)
+				if($end_min>=60)
                                 {
-                                        $end_min = $end_min - 60;
-                                        $end_hour = $end_hour + 1;
+                                        $end_min = $end_min%60;
+                                        $end_hour++;
                                 }
-				if($end_hour>'12')
+				if($end_hour>='12')
 				{
-					$hour = $end_hour - 12;
-					if($end_min == 0)
-	                                        $end_min = "00";
+					if($end_hour == '12' && $end_hour > '00')
+						$end_hour = $end_hour;
+					else
+						$end_hour = $end_hour - 12;
+					if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
+	                                        $end_hour = "0".$end_hour;
+					if($end_min <= 9 && strlen(trim($end_min)) < 2)
+	                                        $end_min = "0".$end_min;
 					$end_time = $end_hour.":".$end_min."pm";
 				}
 				else
 				{
-					if($end_min == 0)
-	                                        $end_min = "00";
+					if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
+	                                        $end_hour = "0".$end_hour;
+					if($end_min <= 9 && strlen(trim($end_min)) < 2)
+	                                        $end_min = "0".$end_min;
 				 	$end_time  = $end_hour.":".$end_min."am";
 				}
 				
@@ -538,18 +625,19 @@
 		}
 		else
 		{
-			$time = explode(":",$start_time);
-                        $hour = $time[0];
-                        $min = $time[1];
+                        $hour = $hour;
+                        $min = $min;
 			$end_min = $min+$duration_min;
                         $end_hour = $hour+$duration_hour;
-			if($end_min>60)
+			if($end_min>=60)
                         {
-                                $end_min = $end_min - 60;
-                                $end_hour = $end_hour + 1;
+                                $end_min = $end_min%60;
+                                $end_hour++;
                         }
-			if($end_min == 0)
-	                        $end_min = "00";
+			if($end_hour <= 9 && strlen(trim($end_hour)) < 2)
+				$end_hour = "0".$end_hour;
+			if($end_min <= 9 && strlen(trim($end_min)) < 2)
+	                        $end_min = "0".$end_min;
 			$end_time  = $end_hour.":".$end_min;
 			$element['starttime'] = $start_time;
 			$element['endtime'] = $end_time;
@@ -557,6 +645,8 @@
 		$contact_id = $adb->query_result($result,$i,"contactid");
 		$id = $adb->query_result($result,$i,"activityid");
 		$subject = $adb->query_result($result,$i,"subject");
+                if(strlen($subject)>25)
+	                $subject = substr($subject,0,25)."...";
 		if($contact_id != '')
 		{
 			$contactname = getContactName($contact_id);





More information about the vtigercrm-commits mailing list