예제 #1
0
    case 'notify':
        $variable_id = COM_applyFilter($_POST['variable_id'], true);
        $notifyUID = $currentlyAssignedUID;
        $email = DB_getItem($_TABLES['users'], 'email', "uid='{$notifyUID}'");
        $message = nl2br($_POST['message']) . "\n\n";
        if ($email != '') {
            $sql = "SELECT a.id, a.nf_templateDataID,  b.taskname FROM {$_TABLES['nf_queue']} a ";
            $sql .= "LEFT JOIN {$_TABLES['nf_templatedata']} b on a.nf_templateDataID = b.id ";
            $sql .= "WHERE a.id='{$taskid}' ";
            $A = DB_fetchArray(DB_query($sql), false);
            $notifyUser = COM_getDisplayName($notifyUID);
            if ($CONF_NF['debug']) {
                COM_errorLog("Nexflow: Send task reminder notificaton for task id: {$A['id']} ({$A['nf_templateDataID']}), {$A['taskname']} to: {$notifyUser} ");
            }
            $subject = 'Workflow Task Reminder Notification';
            list($subject, $msg) = nf_formatEmailMessage('reminder', $A['nf_templateDataID'], $A['id'], $notifyUser);
            $message .= $msg;
            nf_sendEmail($email, $subject, $message);
        }
        break;
}
echo COM_siteHeader('menu');
echo COM_startBlock("Outstanding Tasks");
echo taskconsoleShowNavbar('Outstanding Tasks');
$p = new Template($_CONF['path_layout'] . 'nexflow/admin');
$p->set_file(array('report' => 'view_outstandingtasks.thtml', 'tasks' => 'view_outstandingtask_record.thtml'));
$imgset = $_CONF['layout_url'] . '/nexflow/images';
$actionurl = $_CONF['site_admin_url'] . '/plugins/nexflow/outstanding.php';
$p->set_var('layout_url', $_CONF['layout_url']);
$p->set_var('site_url', $_CONF['site_url']);
$p->set_var('imgset', $imgset);
예제 #2
0
 function private_sendTaskReminders()
 {
     global $_TABLES, $_CONF;
     // Retrieve all the un-completed interactive type tasks in the queue that have a reminder task time set
     $fields = 'a.id, a.nextReminderTime, a.status, a.nf_templateDataID, a.numRemindersSent, a.uid, a.createdDate, ';
     $fields .= 'c.nf_templateID,c.taskname,c.reminderInterval,c.subsequentReminderInterval,c.assignedByVariable, ';
     $fields .= 'c.numReminders,c.escalateVariableID, b.id AS processID ';
     $sql = "SELECT distinct {$fields} ";
     $sql .= "FROM {$_TABLES['nf_queue']} a ";
     $sql .= "INNER JOIN {$_TABLES['nf_process']} b on a.nf_processID = b.id ";
     $sql .= "INNER JOIN {$_TABLES['nf_templatedata']} c on a.nf_templateDataID = c.id ";
     $sql .= "WHERE a.status = 0 AND  a.nextReminderTime > 0 ";
     // Uncompleted task and reminder datetime set
     $sql .= "AND c.reminderInterval > 0 ";
     // Interval set for reminder in number of days
     $sql .= "AND (c.nf_stepType=1 OR c.nf_stepType=7 OR c.nf_stepType=8) ";
     // Interactive Task Types
     $sql .= "AND (a.archived <> 1 OR a.archived IS NULL OR a.archived=0 ) AND (b.complete=0) ";
     $sql .= "AND NOW() > a.nextReminderTime ";
     // Current time has passed reminder time
     $q1 = DB_query($sql);
     // For each un-completed task in the queue - check if reminder notification should be sent out.
     while ($A = DB_fetchArray($q1)) {
         // Check if have exceeded the number of notifications and need to send out Escalation email.
         if ($A['numReminders'] != 0 and $A['numReminders'] == $A['numRemindersSent'] + 1) {
             $notifyUID = DB_getItem($_TABLES['nf_processvariables'], 'variableValue', "nf_templateVariableID = '{$A['escalateVariableID']}' AND nf_processID = '{$A['processID']}'");
             $email = DB_getItem($_TABLES['users'], 'email', "uid='{$notifyUID}'");
             $notifyUser = COM_getDisplayName($notifyUID);
             $subject = 'Workflow Task Escalation Notification';
             list($subject, $message) = nf_formatEmailMessage('escalation', $A['nf_templateDataID'], $A['id'], $notifyUser);
             nf_sendEmail($email, $subject, $message);
             DB_query("UPDATE {$_TABLES['nf_queue']} SET numRemindersSent = '0' WHERE id = '{$A['id']}';");
         } else {
             $subject = 'Workflow Task Reminder Notification';
             $message = "Task: {$A['taskname']} is un-completed.";
             DB_query("UPDATE {$_TABLES['nf_queue']} SET numRemindersSent = numRemindersSent + 1 WHERE id = '{$A['id']}';");
             // Determine which process variables contain users to send reminder to
             $sql = "SELECT DISTINCT b.variableValue FROM {$_TABLES['nf_templateassignment']} a, {$_TABLES['nf_processvariables']} b ";
             $sql .= "WHERE a.nf_remindernotifyVariable=b.nf_templateVariableID AND b.nf_processID='{$A['processID']}'";
             $sql .= "AND b.variableValue > 1 AND a.nf_templateDataID={$A['nf_templateDataID']}";
             $q2 = DB_query($sql);
             // Loop through users setup to receive reminders for this task
             while (list($notifyUID) = DB_fetchArray($q2)) {
                 if (strpos($notifyUID, ':') !== false) {
                     $notifyUIDs = explode(':', $notifyUIDs);
                 } else {
                     $notifyUIDs = array($notifyUID);
                 }
                 foreach ($notifyUIDs as $notifyUID) {
                     nf_logNotification("Nexflow: Send reminder for task id: {$A['id']} ({$A['nf_templateDataID']}), {$A['taskname']} to: {$notifyUID} ");
                     $email = DB_getItem($_TABLES['users'], 'email', "uid='{$notifyUID}'");
                     if ($email != '') {
                         $notifyUser = COM_getDisplayName($notifyUID);
                         $logmsg = "Nexflow: Send task reminder notification for task id: {$A['id']} ";
                         $logmsg .= "({$A['nf_templateDataID']}), {$A['taskname']} to: {$notifyUser} ";
                         nf_notificationLog($logmsg);
                         list($subject, $message) = nf_formatEmailMessage('reminder', $A['nf_templateDataID'], $A['id'], $notifyUser);
                         nf_sendEmail($email, $subject, $message);
                     }
                 }
             }
             // Now check and see if this task has a reminder set for the special "TASK_OWNER" resource variable (id=999)
             if (DB_count($_TABLES['nf_templateassignment'], array('nf_templateDataID', 'nf_remindernotifyVariable'), array($A['nf_templateDataID'], 999)) == 1) {
                 // Check if this task is assigned by variable or UID - Get all assigned users
                 $sql = "SELECT b.uid,b.nf_processVariable FROM {$_TABLES['nf_templateassignment']} b ";
                 $sql .= "WHERE b.nf_templateDataID = '{$A['nf_templateDataID']}' ";
                 $sql .= "AND (uid IS NOT NULL OR nf_processVariable IS NOT NULL) ";
                 $q3 = DB_query($sql);
                 while (list($notifyUID, $variableid) = DB_fetchArray($q3)) {
                     $email = '';
                     if ($variableid != NULL and $A['assignedByVariable'] == 1) {
                         $notifyUID = DB_getItem($_TABLES['nf_processvariables'], 'variableValue', "nf_processID='{$A['processID']}' AND nf_templateVariableID='{$variableid}'");
                         $email = DB_getItem($_TABLES['users'], 'email', "uid='{$notifyUID}'");
                     } elseif ($A['assignedByVariable'] == 0) {
                         $email = DB_getItem($_TABLES['users'], 'email', "uid='{$notifyUID}'");
                     }
                     if ($email != '') {
                         $notifyUser = COM_getDisplayName($notifyUID);
                         $logmsg = "Nexflow: Send task reminder notification for task id: {$A['id']} ";
                         $logmsg .= "({$A['nf_templateDataID']}), {$A['taskname']} to: {$notifyUser} ";
                         nf_logNotification($logmsg);
                         list($subject, $message) = nf_formatEmailMessage('reminder', $A['nf_templateDataID'], $A['id'], $notifyUser);
                         nf_sendEmail($email, $subject, $message);
                     }
                 }
             }
             // Update the nextReminder Timestamp for this task in the queue
             if ($A['subsequentReminderInterval'] > 0) {
                 $reminderInterval = $A['subsequentReminderInterval'];
             } else {
                 $reminderInterval = $A['reminderInterval'];
             }
             $sql = "UPDATE {$_TABLES['nf_queue']} SET nextReminderTime = DATE_ADD( NOW(), INTERVAL {$reminderInterval} DAY) WHERE id='{$A['id']}'";
             DB_query($sql);
         }
     }
 }