[Vtigercrm-commits] [vtiger-commits] r10126 - /vtigercrm/branches/5.0.3/modules/Calendar/script.js

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Thu Feb 1 06:53:54 EST 2007


Author: richie
Date: Thu Feb  1 04:53:50 2007
New Revision: 10126

Log:
changes made for followup events --Minnie

Modified:
    vtigercrm/branches/5.0.3/modules/Calendar/script.js

Modified: vtigercrm/branches/5.0.3/modules/Calendar/script.js
==============================================================================
--- vtigercrm/branches/5.0.3/modules/Calendar/script.js (original)
+++ vtigercrm/branches/5.0.3/modules/Calendar/script.js Thu Feb  1 04:53:50 2007
@@ -92,6 +92,8 @@
 
 function gshow(argg1,type,startdate,enddate,starthr,startmin,startfmt,endhr,endmin,endfmt,viewOption,subtab)
 {
+	smin = parseInt(startmin,10);
+        smin = smin - (smin%5);
 	var y=document.getElementById(argg1).style;
 	
 		if(type == 'call' || type == 'meeting')
@@ -100,24 +102,22 @@
 	                        document.EditView.activitytype[0].checked = true;
 	                if(type == 'meeting')
         	                document.EditView.activitytype[1].checked = true;
-
+                        smin = _2digit(smin);
 			document.EditView.date_start.value = startdate;
-			document.EditView.due_date.value = enddate;
 			document.EditView.starthr.value = starthr;
-			document.EditView.startmin.value = startmin;
+			document.EditView.startmin.value = smin;
 			document.EditView.startfmt.value = startfmt;
-			document.EditView.endhr.value = endhr;
-			document.EditView.endmin.value = endmin;
-			document.EditView.endfmt.value = endfmt;
 			document.EditView.viewOption.value = viewOption;
                         document.EditView.subtab.value = subtab;
+			calDuedatetime(type);
 		}
 		if(type == 'todo')
 		{
+                        smin = _2digit(smin);
 			document.createTodo.task_date_start.value = startdate;
 			document.createTodo.task_due_date.value = enddate;
 			document.createTodo.starthr.value = starthr;
-                        document.createTodo.startmin.value = startmin;
+                        document.createTodo.startmin.value = smin;
                         document.createTodo.startfmt.value = startfmt;
 			document.createTodo.viewOption.value = viewOption;
                         document.createTodo.subtab.value = subtab;
@@ -191,56 +191,57 @@
 function maincheck_form()
 {
 	formSelectColumnString('inviteesid','selectedusers');
-	starthour = document.EditView.starthr.value;
-        startmin  = document.EditView.startmin.value;
+	starthour = parseInt(document.EditView.starthr.value,10);
+        startmin  = parseInt(document.EditView.startmin.value,10);
         startformat = document.EditView.startfmt.value;
-	endhour = document.EditView.endhr.value;
-	endmin  = document.EditView.endmin.value;
-	endformat = document.EditView.endfmt.value;	
+        endhour = parseInt(document.EditView.endhr.value,10);
+        endmin  = parseInt(document.EditView.endmin.value,10);
+        endformat = document.EditView.endfmt.value;
+	followupformat = document.EditView.followup_startfmt.value;
+        followuphour = parseInt(document.EditView.followup_starthr.value,10);
+        followupmin = parseInt(document.EditView.followup_startmin.value,10);
 	if(formValidate())
 	{
 		if(startformat != '')
 		{
 			if(startformat == 'pm')
 			{
-				if(starthour == '12')
+				if(starthour == 12)
 					starthour = 12;
 				else
-					starthour = eval(starthour) + 12;
-				startmin  = startmin;
+					starthour = starthour + 12;
 			}
 			else
 			{
-				if(starthour == '12')
+				if(starthour == 12)
                                         starthour = 0;
 				else
 					starthour = starthour;
-				startmin  = startmin;
 			}
 		}
 		if(endformat != '')
 		{
 			if(endformat == 'pm')
 			{
-				if(endhour == '12')
+				if(endhour == 12)
 					endhour = 12;
 				else
-					endhour = eval(endhour) + 12;
-				endmin = endmin;
+					endhour = endhour + 12;
 			}
 			else
 			{
-				if(endhour == '12')
+				if(endhour == 12)
 					endhour = 0;
 				else
 					endhour = endhour;
-				endmin = endmin;
 			}
 		}
 		var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
 	        var dateval2=getObj('due_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
-		var dateelements1=splitDateVal(dateval1)
-      		var dateelements2=splitDateVal(dateval2)
+		var dateval3=getObj('followup_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+		var dateelements1=splitDateVal(dateval1);
+      		var dateelements2=splitDateVal(dateval2);
+		var dateelements3=splitDateVal(dateval3);
 
 	        dd1=dateelements1[0]
         	mm1=dateelements1[1]
@@ -249,8 +250,14 @@
         	dd2=dateelements2[0]
 	        mm2=dateelements2[1]
         	yyyy2=dateelements2[2]
+
+		dd3=dateelements3[0]
+                mm3=dateelements3[1]
+                yyyy3=dateelements3[2]
+
 		var date1=new Date()
 	        var date2=new Date()
+		var date3=new Date()
 
         	date1.setYear(yyyy1)
 	        date1.setMonth(mm1-1)
@@ -259,9 +266,14 @@
 	        date2.setYear(yyyy2)
         	date2.setMonth(mm2-1)
 	        date2.setDate(dd2)
+		
+		date3.setYear(yyyy3)
+                date3.setMonth(mm3-1)
+                date3.setDate(dd3)
+
 		if (date2<=date1)
 		{
-			if((eval(endhour)*60+eval(endmin)) <= (eval(starthour)*60+eval(startmin)))
+			if((endhour*60+endmin) <= (starthour*60+startmin))
 			{
 				alert("End Time should be greater than Start Time ");
 				document.EditView.endhr.focus();
@@ -269,7 +281,7 @@
 			}
 			else
 			{
-				durationinmin = (eval(endhour)*60+eval(endmin)) - (eval(starthour)*60+eval(startmin));
+				durationinmin = (endhour*60+endmin) - (starthour*60+startmin);
                 		if(durationinmin >= 60)
               			{
               				hour = durationinmin/60;
@@ -284,8 +296,67 @@
                 		document.EditView.duration_minutes.value = minute;
 			}
 		}
-		document.EditView.time_start.value = starthour+':'+startmin;
-		document.EditView.time_end.value = endhour+':'+endmin;
+		event_starthour = _2digit(starthour);
+		event_startmin = _2digit(startmin);
+		event_endhour = _2digit(endhour);
+		event_endmin = _2digit(endmin);
+                document.EditView.time_start.value = event_starthour+':'+event_startmin;
+                document.EditView.time_end.value = event_endhour+':'+event_endmin;
+		// Added for Aydin Kurt-Elli requirement START -by Minnie
+                if (document.EditView.followup.checked == true && document.getElementById('date_table_thirdtd').style.display == 'block' )
+                {
+                        if(!dateValidate('followup_date','Followup Date','OTH'))
+                        {
+                                return false;
+                        }
+                        if(followupformat != '')
+                        {
+                                if(followupformat == 'pm')
+                                {
+                                        if(followuphour == 12)
+                                                followuphour = 12;
+                                        else
+                                                followuphour = followuphour + 12;
+                                }
+                                else
+                                {
+                                        if(followuphour == 12)
+                                                followuphour = 0;
+                                        else
+                                                followuphour = followuphour;
+                                }
+                        }
+
+                        if ( compareDates(date3,'Followup Date',date2,'End Date','GE'))
+			{
+			 	if (date3 <= date2)
+                                {
+                                        if((followuphour*60+followupmin) <= (endhour*60+endmin))
+                                        {
+                                                alert("Followup Time should be greater than End Time ");
+                                                document.EditView.followup_starthr.focus();
+                                                return false;
+                                        }
+                                }
+                        }
+                        else
+                                return false;
+
+                        followupendhour = followuphour;
+                        followupendmin = followupmin + 5;
+                        if(followupendmin == 60)
+                        {
+                                followupendmin = 0;
+                                followupendhour = followupendhour + 1;
+                        }
+			followuphour = _2digit(followuphour);
+			followupmin = _2digit(followupmin);
+			followupendhour = _2digit(followupendhour);
+			followupendmin = _2digit(followupendmin);
+                        document.EditView.followup_time_start.value = followuphour+':'+followupmin;
+                        document.EditView.followup_time_end.value = followupendhour+':'+followupendmin;
+                }
+                // Added for Aydin Kurt-Elli requirement END -by Minnie
 		return true;
 	}
 	else return false;
@@ -311,48 +382,47 @@
 		{
 			document.EditView.mode.value = 'create';
 		}
-		starthour = document.EditView.starthr.value;
-		startmin  = document.EditView.startmin.value;
-		startformat = document.EditView.startfmt.value;
-		endhour = document.EditView.endhr.value;
-                endmin  = document.EditView.endmin.value;
+		starthour = parseInt(document.EditView.starthr.value,10);
+                startmin  = parseInt(document.EditView.startmin.value,10);
+                startformat = document.EditView.startfmt.value;
+                endhour = parseInt(document.EditView.endhr.value,10);
+                endmin  = parseInt(document.EditView.endmin.value,10);
                 endformat = document.EditView.endfmt.value;
+		followupformat = document.EditView.followup_startfmt.value;
+                followuphour = parseInt(document.EditView.followup_starthr.value,10);
+                followupmin = parseInt(document.EditView.followup_startmin.value,10);
 		if(startformat != '')
 		{
 			if(startformat == 'pm')
 			{
-				if(starthour == '12')
+				if(starthour == 12)
 					starthour = 12;
 				else
-					starthour = eval(starthour) + 12;
-				startmin  = startmin;
+					starthour = starthour + 12;
 			}
 			else
 			{
-				if(starthour == '12')
+				if(starthour == 12)
                                 	starthour = 0;
 				else
 					starthour = starthour;
-				startmin  = startmin;
 			}
 		}
 		if(endformat != '')
 		{
 			if(endformat == 'pm')
                         {
-				if(endhour == '12')
+				if(endhour == 12)
                                         endhour = 12;
                                 else
-                                        endhour = eval(endhour) + 12;
-				endmin = endmin;
+                                        endhour = endhour + 12;
                         }
 			else
 			{
-				if(endhour == '12')
+				if(endhour == 12)
 					endhour == 0;
 				else
 					endhour = endhour;
-				endmin = endmin;
 			}
 		}
 		if(!dateValidate('date_start','Start date','OTH'))
@@ -367,8 +437,11 @@
 		{
 			var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
         	        var dateval2=getObj('due_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+			var dateval3=getObj('followup_date').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+
 	                var dateelements1=splitDateVal(dateval1)
                 	var dateelements2=splitDateVal(dateval2)
+			var dateelements3=splitDateVal(dateval3)
 
 	                dd1=dateelements1[0]
         	        mm1=dateelements1[1]
@@ -377,8 +450,14 @@
 	                dd2=dateelements2[0]
         	        mm2=dateelements2[1]
                 	yyyy2=dateelements2[2]
+
+			dd3=dateelements3[0]
+                        mm3=dateelements3[1]
+                        yyyy3=dateelements3[2]
+
 	                var date1=new Date()
         	        var date2=new Date()
+			var date3=new Date()
 
                 	date1.setYear(yyyy1)
 	                date1.setMonth(mm1-1)
@@ -387,15 +466,19 @@
         	        date2.setYear(yyyy2)
 	                date2.setMonth(mm2-1)
                 	date2.setDate(dd2)
+
+			date3.setYear(yyyy3)
+                        date3.setMonth(mm3-1)
+                        date3.setDate(dd3)
                 	if (date2<=date1)
                 	{
-                        	if((eval(endhour)*60+eval(endmin)) <= (eval(starthour)*60+eval(startmin)))
+                        	if((endhour*60+endmin) <= (starthour*60+startmin))
           	        	{
                 	                alert("End Time should be greater than Start Time ");
                                 	document.EditView.endhr.focus();
      		                        return false;
                 	        }
-				durationinmin = (eval(endhour)*60+eval(endmin)) - (eval(starthour)*60+eval(startmin));
+				durationinmin = (endhour*60+endmin) - (starthour*60+startmin);
 	                        if(durationinmin >= 60)
         	                {
                 	                hour = durationinmin/60;
@@ -410,11 +493,70 @@
 	                        document.EditView.duration_minutes.value = minute;
 
            		}
+			
+                        event_starthour = _2digit(starthour);
+                        event_startmin = _2digit(startmin);
+                        event_endhour = _2digit(endhour);
+                        event_endmin = _2digit(endmin);
+                        document.EditView.time_start.value = event_starthour+':'+event_startmin;
+                        document.EditView.time_end.value = event_endhour+':'+event_endmin;
+			// Added for Aydin Kurt-Elli requirement START -by Minnie
+                        if (document.EditView.followup.checked == true && document.getElementById('date_table_thirdtd').style.display == 'block')
+                        {
+                                if(!dateValidate('followup_date','Followup Date','OTH'))
+                                {
+                                        return false;
+                                }
+                                if(followupformat != '')
+                                {
+                                        if(followupformat == 'pm')
+                                        {
+                                                if(followuphour == 12)
+                                                        followuphour = 12;
+                                                else
+                                                        followuphour = followuphour + 12;
+                                        }
+                                        else
+                                        {
+                                                if(followuphour == 12)
+                                                        followuphour = 0;
+                                                else
+                                                        followuphour = followuphour;
+                                        }
+                                }
+				
+				if ( compareDates(date3,'Followup Date',date2,'End Date','GE'))
+                                {
+                                        if (date3 <= date2)
+                                        {
+                                                if((followuphour*60+followupmin) <= (endhour*60+endmin))
+                                                {
+                                                        alert("Followup Time should be greater than End Time ");
+                                                        document.EditView.followup_starthr.focus();
+                                                        return false;
+                                                }
+                                        }
+                                }
+                                else return false;
+
+                                followupendhour = followuphour;
+                                followupendmin = followupmin + 5;
+                                if(followupendmin == 60)
+                                {
+                                        followupendmin = 0;
+                                        followupendhour = followupendhour + 1;
+                                }
+				followuphour = _2digit(followuphour);
+			        followupmin = _2digit(followupmin);
+				followupendhour = _2digit(followupendhour);
+			        followupendmin = _2digit(followupendmin);
+                                document.EditView.followup_time_start.value = followuphour+':'+followupmin;
+                                document.EditView.followup_time_end.value = followupendhour+':'+followupendmin;
+                        }
+                        // Added for Aydin Kurt-Elli requirement END -by Minnie -->
 		}	
 		else
 			return false;
-		document.EditView.time_start.value = starthour+':'+startmin;
-		document.EditView.time_end.value = endhour+':'+endmin;
 		if(document.EditView.recurringcheck.checked == false)
                 {
                         document.EditView.recurringtype.value = '--None--';
@@ -425,30 +567,30 @@
 
 function task_check_form()
 {
-	starthour = document.createTodo.starthr.value;
-	startmin  = document.createTodo.startmin.value;
+	starthour = parseInt(document.createTodo.starthr.value,10);
+        startmin  = parseInt(document.createTodo.startmin.value,10);
         startformat = document.createTodo.startfmt.value;
 	if(startformat != '')
 	{
         	if(startformat == 'pm')
                 {
-			if(starthour == '12')
+			if(starthour == 12)
 				starthour = 12;
 			else
-                		starthour = eval(starthour) + 12;
-			
-                        startmin  = startmin;
+                		starthour = starthour + 12;
+
                 }
                 else
                 {
-			if(starthour == '12')
+			if(starthour == 12)
 				starthour = 0;
 			else
 				starthour = starthour;
-                        startmin  = startmin;
-                }
-        }
-	document.createTodo.task_time_start.value = starthour+':'+startmin;
+                }
+        }
+	starthour = _2digit(starthour);
+        startmin = _2digit(startmin);
+        document.createTodo.task_time_start.value = starthour+':'+startmin;
 	if(document.createTodo.record.value != '')
         {
         	document.createTodo.mode.value = 'edit';
@@ -463,28 +605,28 @@
 
 function maintask_check_form()
 {
-        starthour = document.EditView.starthr.value;
-        startmin  = document.EditView.startmin.value;
+	starthour = parseInt(document.EditView.starthr.value,10);
+        startmin  = parseInt(document.EditView.startmin.value,10);
         startformat = document.EditView.startfmt.value;
         if(startformat != '')
         {
                 if(startformat == 'pm')
                 {
-			if(starthour == '12')
+			if(starthour == 12)
 				starthour = 12;
 			else
-				starthour = eval(starthour) + 12;
-                        startmin  = startmin;
+				starthour = starthour + 12;
                 }
                 else
                 {
-			if(starthour == '12')
+			if(starthour == 12)
                                 starthour = 0;
                         else
                                 starthour = starthour;
-                        startmin  = startmin;
-                }
-        }
+                }
+        }
+	starthour = _2digit(starthour);
+        startmin = _2digit(startmin);
         document.EditView.time_start.value = starthour+':'+startmin;
 }
 
@@ -1117,3 +1259,222 @@
         }
 }
 
+function dochange(start,end)
+{
+        var startdate = document.getElementById(start);
+        document.getElementById(end).value = startdate.value;
+}
+
+function getSelectedStatus()
+{
+        var chosen = document.EditView.eventstatus.value;
+        if(chosen == "Held")
+        {
+                document.getElementById('date_table_firsttd').style.width = "33%";
+                document.getElementById('date_table_secondtd').style.width = "33%";
+                document.getElementById('date_table_thirdtd').style.display = 'block';
+        }
+        else
+        {
+                document.getElementById('date_table_firsttd').style.width = "50%";
+                document.getElementById('date_table_secondtd').style.width = "50%";
+                document.getElementById('date_table_thirdtd').style.display = 'none';
+        }
+
+}
+
+function changeEndtime_StartTime()
+{
+        var select_call = document.EditView.activitytype[0].checked;
+        var select_meeting = document.EditView.activitytype[1].checked;
+        if(select_call)
+                calDuedatetime('call');
+        else if(select_meeting)
+                calDuedatetime('meeting');
+        else
+                alert('Event Type is not selected');
+}
+
+function calDuedatetime(type)
+{
+        var datefmt = document.EditView.dateformat.value;
+        var dateval1=getObj('date_start').value.replace(/^\s+/g, '').replace(/\s+$/g, '');
+        var dateelements1=splitDateVal(dateval1);
+        dd1=parseInt(dateelements1[0],10);
+        mm1=dateelements1[1];
+        yyyy1=dateelements1[2];
+        var date1=new Date();
+        //date1.setDate(dd1+1);
+        date1.setYear(yyyy1);
+        date1.setMonth(mm1-1,dd1+1);
+        var yy = date1.getFullYear();
+        var mm = parseInt(date1.getMonth(),10) + 1;
+        var dd = date1.getDate();
+        var date = document.EditView.date_start.value;
+        var hour = parseInt(document.EditView.starthr.value,10);
+        var min = parseInt(document.EditView.startmin.value,10);
+        var fmt = document.EditView.startfmt.value;
+	dd = _2digit(dd);
+        mm = _2digit(mm);	
+        if(datefmt == '%d-%m-%Y')
+        {
+                var tempdate = dd+'-'+mm+'-'+yy;
+        }else if(datefmt == '%m-%d-%Y')
+        {
+                var tempdate = mm+'-'+dd+'-'+yy;
+        }else
+        {
+                var tempdate = yy+'-'+mm+'-'+dd;
+        }
+	if(type == 'meeting')
+        {
+                if(fmt == 'pm')
+                {
+                        if(hour == 11)
+                        {
+                                date = tempdate;
+                                hour = 12;
+                                min = min;
+                                fmt = 'am';
+
+                        }else if(hour == 12)
+                        {
+                                hour = 1;
+                                min = min;
+                                fmt = 'pm';
+			}
+                	else hour = hour + 1;
+			hour = _2digit(hour);
+                        min = _2digit(min);
+			document.EditView.due_date.value = date;
+			document.EditView.endhr.value = hour;
+			document.EditView.endmin.value = min;
+			document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+		}else if(fmt == 'am')
+		{
+                        if(hour == 11)
+                        {
+                                hour = 12;
+                                min = min;
+                                fmt = 'pm';
+                        }else if(hour == 12)
+                        {
+                                hour = 1;
+                                min = min;
+                                fmt = 'am';
+                        }
+                        else hour = hour + 1;
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+                        document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+                }else
+		{
+                        hour = hour + 1;
+                        if(hour == 24)
+                        {
+                                hour = 0;
+                                date =  tempdate;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                }
+        }
+	if(type == 'call')
+        {
+                if(fmt == 'pm')
+                {
+                        if(hour == 11 && min == 55)
+                        {
+                                hour = 12;
+                                min = 0;
+                                fmt = 'am';
+                                date = tempdate;
+                        }
+                        else
+                        {
+                                if(min == 55)
+                                {
+                                        min = 0;
+                                        hour = hour + 1;
+                                }
+                                else    min = min + 5;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+                        document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+                }else if(fmt == 'am')
+		{
+                        if(hour == 11 && min == 55)
+                        {
+                                hour = 12;
+                                min = 0;
+                                fmt = 'pm';
+                        }
+                        else
+                        {
+                                if(min == 55)
+                                {
+                                        min = 0;
+                                        hour = hour + 1;
+                                }
+                                else    min = min + 5;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+                        document.EditView.endfmt.value = fmt;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                        document.EditView.followup_startfmt.value = fmt;
+                }
+                else
+		{
+                        if(min == 55)
+                        {
+                                min = 0;
+                                hour = hour + 1;
+                        }else min = min + 5;
+                        if(hour == 24)
+                        {
+                                hour = 0;
+                                date =  tempdate;
+                        }
+			hour = _2digit(hour);
+                        min = _2digit(min);
+                        document.EditView.due_date.value = date;
+                        document.EditView.endhr.value = hour;
+                        document.EditView.endmin.value = min;
+			document.EditView.followup_date.value = date;
+                        document.EditView.followup_starthr.value = hour;
+                        document.EditView.followup_startmin.value = min;
+                }
+        }
+}
+





More information about the vtigercrm-commits mailing list