Esempio n. 1
0
function parseReminderSubject($inputline)
{
    // get when - caldate , hr in 00 to 23
    // get rest of the subject with out the
    // $inputline should be in format "sunday 9am blah blah" , "25th 10am blah blah", "tomorrow 5pm blah blah", "Aug 7th 6am blah blah",
    // if you can not figure out time of day - default 9 am.
    $poscomma = strpos($inputline, ',');
    if ($poscomma !== false) {
        $reminder_text = trim(substr(strstr($inputline, ','), 1));
        list($inputline) = explode(',', $inputline);
    } else {
        $reminder_text = $inputline;
    }
    $reminder_caldate = date("Y-m-d");
    // default reminder assume today
    preg_match('/(\\d+(am|pm))/i', strtolower($inputline), $matches);
    if (count($matches)) {
        $reminder_timeofday = (int) $matches[0];
        if (trim($matches[2]) == 'am' && trim($matches[0]) == '12am') {
            $reminder_timeofday = '00';
        }
        if (trim($matches[2]) == 'pm' && trim($matches[0]) != '12pm') {
            $reminder_timeofday = (int) $matches[0] + 12;
        }
    } else {
        $reminder_timeofday = '08';
        // default 9 am
    }
    preg_match('/(today|tomorrow|tommorrow|2maro|2morow|2moro|2morro|2marow|2marrow|2morrow|tomoro|tomaro|tomarrow|tomarow|sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun|mon|tue|wed|thu|fri|sat)/', strtolower($inputline), $matches);
    if (count($matches)) {
        $tmp_days = array();
        // $tmp_days[getTomorrowDayofWeek(0)] = getTomorrowCaldate(0); // do not consider today
        $tmp_days[strtolower(getTomorrowDayofWeek(1))] = $tmp_days[strtolower(getTomorrowDayofWeek(1, false))] = getTomorrowCaldate(1);
        // $tmp_days['Wednesday'] = '2009-07-22' ;
        $tmp_days[strtolower(getTomorrowDayofWeek(2))] = $tmp_days[strtolower(getTomorrowDayofWeek(2, false))] = getTomorrowCaldate(2);
        $tmp_days[strtolower(getTomorrowDayofWeek(3))] = $tmp_days[strtolower(getTomorrowDayofWeek(3, false))] = getTomorrowCaldate(3);
        $tmp_days[strtolower(getTomorrowDayofWeek(4))] = $tmp_days[strtolower(getTomorrowDayofWeek(4, false))] = getTomorrowCaldate(4);
        $tmp_days[strtolower(getTomorrowDayofWeek(5))] = $tmp_days[strtolower(getTomorrowDayofWeek(5, false))] = getTomorrowCaldate(5);
        $tmp_days[strtolower(getTomorrowDayofWeek(6))] = $tmp_days[strtolower(getTomorrowDayofWeek(6, false))] = getTomorrowCaldate(6);
        $tmp_days[strtolower(getTomorrowDayofWeek(7))] = $tmp_days[strtolower(getTomorrowDayofWeek(7, false))] = getTomorrowCaldate(7);
        switch ($matches[1]) {
            case "today":
                $reminder_caldate = date("Y-m-d");
                break;
            case "tomorrow":
            case 'tommorrow':
            case '2morow':
            case '2maro':
            case '2moro':
            case '2morro':
            case '2marow':
            case '2marrow':
            case '2morrow':
            case 'tomoro':
            case 'tomaro':
            case 'tomarow':
            case 'tomarrow':
                $reminder_caldate = getTomorrowCaldate();
                break;
            default:
                $reminder_caldate = $tmp_days[$matches[1]];
                break;
        }
    } else {
        $reminder_dayofmonth = date("d");
        $reminder_month = date("m");
        // default current month
        preg_match('/((jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|january|february|march|april|june|july|august|september|october|november|december))/i', strtolower($inputline), $matches);
        if (count($matches)) {
            switch (trim($matches[0])) {
                case "jan":
                case "january":
                    $reminder_month = "01";
                    break;
                case "feb":
                case "february":
                    $reminder_month = "02";
                    break;
                case "mar":
                case "march":
                    $reminder_month = "03";
                    break;
                case "apr":
                case "april":
                    $reminder_month = "04";
                    break;
                case "may":
                    $reminder_month = "05";
                    break;
                case "jun":
                case "june":
                    $reminder_month = "06";
                    break;
                case "jul":
                case "july":
                    $reminder_month = "07";
                    break;
                case "aug":
                case "august":
                    $reminder_month = "08";
                    break;
                case "sep":
                case "september":
                    $reminder_month = "09";
                    break;
                case "oct":
                case "october":
                    $reminder_month = "10";
                    break;
                case "nov":
                case "november":
                    $reminder_month = "11";
                    break;
                case "dec":
                case "december":
                    $reminder_month = "12";
                    break;
            }
        }
        preg_match('/(\\d+(st|nd|rd|th))/i', $inputline, $matches);
        if (count($matches) == 0) {
            // preg_match('/(\d+)/i', $inputline, $matches);
            // todo eliminate words with pm/am
        }
        if (count($matches)) {
            $reminder_dayofmonth = (int) $matches[0];
            $reminder_caldate = date("Y") . "-" . $reminder_month . "-" . $reminder_dayofmonth;
        }
    }
    $processemail_debugoutput = "\n\t\ttrying to parse input line parseReminderSubject(' {$inputline} ');\n\t\tReminder Cal Date : {$reminder_caldate}\n\t\tReminder time of Day : {$reminder_timeofday} ";
    //fwrite($fp, "$processemail_debugoutput \n" );
    // if reminder is for today and hour is already passed, assume next day
    if (date("Y-m-d") == $reminder_caldate && (int) date('G') >= (int) $reminder_timeofday) {
        $reminder_caldate = getTomorrowCaldate(1);
    }
    return array($reminder_caldate, $reminder_timeofday, $reminder_text);
}
Esempio n. 2
0
<script>

var show_scheduleEmailForm = function(subj , body ){
	//My_JsLibrary.showdeadcenterdiv( 'ScheduleEmail_Form' );
	if(!subj){ var subj = '';}
	if(!body){ var body = '';}
	EDIT_SCHEDULEDEMAILID = 0 ;
	<?php 
$manageUsers = new manageUsers();
$username = $_SESSION["uname"];
echo "var myemail='" . $manageUsers->get_userSingleDetail($username, 'user_primaryEmail') . "';";
echo "var TomorrowCaldate='" . getTomorrowCaldate(1) . "';";
?>
	$("#ScheduleEmail_Form_Title").html('Schedule a Reminder');
	_$('nu_scEmail_to').value = myemail ;
	_$('nu_scEmail_when').value = TomorrowCaldate ;
	_$('nu_scEmail_subject').value = subj ;
	_$('nu_scEmail_body').value = body ;

	$('#ScheduleEmail_Form').showWithBg();
	_$('nu_scEmail_subject').focus();
};


var schedule_newTask = function(){
	var emailTo = My_JsLibrary.getFieldValue('nu_scEmail_to');
	var emailSubject = My_JsLibrary.getFieldValue('nu_scEmail_subject');
	var emailBody = My_JsLibrary.getFieldValue('nu_scEmail_body');
	var emailWhen = My_JsLibrary.getFieldValue('nu_scEmail_when');
	var emailHour = My_JsLibrary.getFieldValue('nu_scEmail_hr');
	if( ! My_JsLibrary.checkRequiredFields( ['nu_scEmail_to', 'nu_scEmail_subject', 'nu_scEmail_when'] ) ){
Esempio n. 3
0
    public function listJSWORKS()
    {
        ?>
		<script>

			ManageTasksJsFunction.allClosedThisYear = function(p){
				if(p && p == 'all'){
					My_JsLibrary.updatePageWithGetVar('ctperiod', 'allclosed');
				}else{
					My_JsLibrary.updatePageWithGetVar('ctperiod', 'thisyear');
				}
			};

			ManageTasksJsFunction.DELETETHISTASK = function(taskid){
				if(!confirm('Are you sure? \n\n Task will be deleted permanently.\n There is no Undo for this action. ')){return;}
				DE_USER_action( 'deleteTask',
				{
					workid : taskid,
					callback:function(a){
						if(a){
							My_JsLibrary.windowReload();
						}else{
							alert(My_JsLibrary.responsemsg);
						}
					}
				});
			};
		
			ManageTasksJsFunction.startTask = function(wId){
				DE_USER_action('startTask', {
					workid : wId,
					callback:function(a){
						if(a){
							My_JsLibrary.windowReload();
						}else{
							My_JsLibrary.showErrMsg() ;
						}
					}
				});
			};

			ManageTasksJsFunction.resetWorkToNew = function(wId){ // ManageTasksJsFunction.resetWorkToNew( taskNo );
				DE_USER_action('resetWorkToNew', {
					workid : wId,
					callback:function(a){
						if(a){
							My_JsLibrary.windowReload();
						}else{
							My_JsLibrary.showErrMsg() ;
						}
					}
				});
			};

			ManageTasksJsFunction.completeWork = function(wId){ // ManageTasksJsFunction.completeWork( taskNo );
				DE_USER_action('completeWork', {
					workid : wId,
					callback:function(a){
						if(a){
							My_JsLibrary.windowReload();
						}else{
							My_JsLibrary.showErrMsg() ;
						}
					}
				});
			};

			ManageTasksJsFunction.closeWork = function(wId){ // ManageTasksJsFunction.closeWork( taskNo );
				DE_USER_action('closeWork', {
					workid : wId,
					callback:function(a){
						if(a){
							My_JsLibrary.windowReload();
						}else{
							My_JsLibrary.showErrMsg() ;
						}
					}
				});
			};


			$(document).ready(function() {
				$("TD.TREDITEMAILWORKS").click(function(){
					_$('nutask_project').selectedIndex = -1;
					_$('nutask_Private').checked = true;
					$('#nutask_Private_explanation').html('Uncheck to make this task public');
					_$('chk_ScheduleTask').checked = false ;
					_$('chk_taskontask').checked = false ;
					_$('text_daysb4deadline').disabled = true;
					_$('text_oncompletionof').disabled = true;
					_$('text_daysb4deadline').value = '' ;
					_$('text_oncompletionof').value = '' ;

					var this_workid = $(this).attr('workid') ; EDITEMAILTASKID = this_workid;
					var this_projectname = $(this).attr('projectName') ;
					var this_userAssigned = $(this).attr('userassigned') ;
					var this_addedBy = $(this).attr('addedBy') ;
					var this_deadline = $(this).attr('deadline') ;							
					// My_JsLibrary.showdeadcenterdiv( 'CreateTask_Form' );
					$('#CreateTask_Form').showWithBg();

					My_JsLibrary.selectbox.selectOption( _$('nutask_priority') ,  'N' );
					My_JsLibrary.selectbox.selectOption( _$('nutask_project') ,  this_projectname );
					update_ProjectUsers();
					My_JsLibrary.selectbox.selectOption( _$('nutask_userassigned') ,  this_userAssigned );
					_$('nutask_deadline').value = this_deadline;
					_$('nutask_bdesc').value = $(this).html().trim();
				});
			});


			ManageTasksJsFunction.createNewTask_form = function(afterid){ // ManageTasksJsFunction.createNewTask_form();
				EDITEMAILTASKID = '';
				NEWTASKFORM_VISIBLE = true;
				// My_JsLibrary.showdeadcenterdiv( 'CreateTask_Form' );
				$('#CreateTask_Form').showWithBg();
				_$('nutask_project').selectedIndex = -1;
				My_JsLibrary.selectbox.clear(_$('nutask_userassigned'));
				_$('nutask_Private').checked = true;
				$('#nutask_Private_explanation').html('Uncheck to make this task public');
				var curl = window.location.href;
				if( curl.contains('list=ptasks') ){
					My_JsLibrary.selectbox.selectOption( _$('nutask_project') ,  '<?php 
        echo DEFAULTPERSONALPROJECT;
        ?>
' );
					update_ProjectUsers();
				}
				_$('chk_ScheduleTask').checked = false ;
				_$('text_daysb4deadline').disabled = true;
				_$('text_oncompletionof').disabled = true;

				if(afterid){
					_$('text_oncompletionof').disabled = false;
					_$('chk_taskontask').checked = true;
					_$('text_oncompletionof').value = afterid;
				}

				_$('nutask_deadline').value = '<?php 
        echo getTomorrowCaldate(1);
        ?>
' ;
			};

			ManageTasksJsFunction.setUpcomingTask = function(wId, isNext){
				DE_USER_action('setUpcomingTask', {
					workid : wId,
					isNext : isNext,
					callback:function(a){
						if(a){
							My_JsLibrary.windowReload();
						}else{
							My_JsLibrary.showErrMsg() ;
						}
					}
				});
			};

		</script>
	<?php 
    }
Esempio n. 4
0
<?php

include_once "include_db.php";
include_once "include_functions.php";
$USERNAME = $_POST['username'];
$USERPASS = $_POST['password'];
if (!authenticateUser($USERNAME, $USERPASS)) {
    echo "Invalid Username or Password!";
    exit;
} else {
    $_SESSION["uname"] = $USERNAME;
}
$projectName = DEFAULTPERSONALPROJECT;
$briefDesc = urldecode($_POST['newtask']);
$deadline = getTomorrowCaldate(2);
$manageWorks = new manageWorks();
$manageWorks->newWork(array(work_userAssigned => $USERNAME, work_addedBy => $USERNAME, work_deadLine => $deadline, work_briefDesc => $briefDesc, work_Notes => '', work_status => $DE_GLOBALS_WORK_NEW, work_priority => 'N', work_projectName => $projectName, work_isPrivate => 'Y', daysb4deadline => 0, afterCompletionID => 0));
$this_taskid = mysql_insert_id();
$COMMENTLOGMESSAGE = "<B>{$USERNAME}</B> Created New Task -- User Assigned:{$USERNAME}, DeadLine:{$deadline}, Project:{$projectName}";
$manageWorks->addComment($this_taskid, APPNAME, $COMMENTLOGMESSAGE);
echo "Task '{$this_taskid}' Created !";