Exemplo n.º 1
0
function processDetailGetOutstandingTasks($project_id, &$template)
{
    global $_TABLES, $CONF_NF, $usermodeUID;
    // Retrieve any Outstanding Tasks
    // Determine the unique process id's for this project
    $sql = "SELECT wf_process_id,related_processes FROM {$_TABLES['nf_projects']} WHERE id='{$project_id}'";
    $query = DB_QUERY($sql);
    $A = DB_fetchArray($query);
    if ($A['related_processes'] != '') {
        $projectProcesses = explode(',', $A['related_processes']);
    } else {
        $projectProcesses = array();
    }
    array_push($projectProcesses, $A['wf_process_id']);
    // Check and see if there are any child process of this parent process - will if this is a regenerated process
    $A['wf_process_id'] = NXCOM_filterInt($A['wf_process_id']);
    $query = DB_query("SELECT id FROM {$_TABLES['nf_process']} WHERE pid={$A['wf_process_id']}");
    while ($P = DB_fetchArray($query)) {
        array_push($projectProcesses, $P['id']);
    }
    $cid = 1;
    if (count($projectProcesses > 0)) {
        foreach ($projectProcesses as $process_id) {
            // Get tasks that have assignment by variable
            $template->set_var('taskuser', $usermodeUID);
            $template->set_var('user_options', nf_listUsers());
            if ($process_id > 0) {
                $sql = "SELECT distinct a.id, a.nf_processID,d.taskname, d.nf_templateID, a.status, a.archived, ";
                $sql .= "a.createdDate, c.uid, c.nf_processVariable, a.nf_templateDataID FROM {$_TABLES['nf_queue']} a ";
                $sql .= "LEFT JOIN {$_TABLES['nf_templateassignment']} b ON a.nf_templateDataID = b.nf_templateDataID ";
                $sql .= "LEFT JOIN {$_TABLES['nf_productionassignments']} c ON c.task_id = a.id ";
                $sql .= "LEFT JOIN {$_TABLES['nf_templatedata']} d on a.nf_templateDataID = d.id ";
                $sql .= "WHERE a.nf_processID = '{$process_id}' AND (a.archived IS NULL OR a.archived = 0)";
                $sql .= "ORDER BY a.id";
                $q2 = DB_query($sql);
                while ($B = DB_fetchArray($q2, false)) {
                    if ($B['nf_processVariable'] == '') {
                        continue;
                    }
                    $template->set_var('taskassign_mode', 'variable');
                    $template->set_var('otaskid', $B['id']);
                    if (SEC_hasRights('nexflow.edit')) {
                        $template->set_var('otask_span', 1);
                        $template->set_var('show_otaskaction', '');
                    } else {
                        $template->set_var('otask_span', 2);
                        $template->set_var('show_otaskaction', 'none');
                    }
                    $template->set_var('otask_user', COM_getDisplayName($B['uid']));
                    $template->set_var('otask_name', $B['taskname']);
                    $template->set_var('otask_date', $B['createdDate']);
                    $template->set_var('otask_id', $B['id']);
                    $template->set_var('variable_id', $B['nf_processVariable']);
                    if ($cid == 1) {
                        $template->parse('outstandingtask_records', 'outstandingtasks');
                    } else {
                        $template->parse('outstandingtask_records', 'outstandingtasks', true);
                    }
                    $cid++;
                }
                // while
            }
        }
    }
}
Exemplo n.º 2
0
function nf_getSortedTaskArray($tasks, $taskFilterOptions = '', $taskSortOption, $srchText = '', $appGroup = '', $statusOption = '', $sortDirection)
{
    global $_CONF, $_TABLES, $CONF_NF;
    $sortedTasks = array();
    // Setup simple variable names for use in the function
    $filterdate = $options['filterdate'];
    $pagesize = $options['pagesize'];
    $page = $options['page'];
    //there is only one filter option and only one sort option in our case
    //taskFilterOptions can be title, desc, appgroup
    foreach ($tasks as $taskrec) {
        $includeTask = false;
        $currentTask = array();
        // Holds current task detail information
        $nfclass = new nexflow($taskrec['processid']);
        $templateID = DB_getItem($_TABLES['nf_process'], 'nf_templateID', "id='{$taskrec['processid']}'");
        $sql = "SELECT a.id FROM {$_TABLES['nf_appgroups']} a ";
        $sql .= "INNER JOIN {$_TABLES['nf_template']} b ON b.AppGroup=a.id ";
        $sql .= "WHERE b.id='{$templateID}' LIMIT 1";
        $res = DB_query($sql);
        list($appname) = DB_fetchArray($res);
        $currentTask['taskname'] = $taskrec['taskname'];
        $currentTask['flowname'] = DB_getItem($_TABLES['nf_template'], 'templateName', "id='{$templateID}'");
        $currentTask['requestdescription'] = DB_getItem($_TABLES['nf_projects'], 'description', "wf_process_id='{$taskrec['processid']}'");
        $currentTask['appgroup'] = NXCOM_filterInt($appname);
        $currentTask['startedDate'] = DB_getItem($_TABLES['nf_queue'], 'startedDate', "id='{$taskrec['id']}'");
        $currentTask['status'] = DB_getItem($_TABLES['nf_queue'], 'status', "id='{$taskrec['id']}'");
        if ($taskFilterOptions == 'cdate') {
            if ($taskrec['cdate'] >= $filterdate) {
                $includeTask = true;
            } else {
                $includeTask = false;
            }
        } elseif ($taskFilterOptions == 'title' || $taskFilterOptions == '') {
            if ($srchText == '') {
                $includeTask = true;
            } else {
                $pos1 = stripos($currentTask['taskname'], $srchText);
                $pos2 = stripos($currentTask['flowname'], $srchText);
                if ($pos1 === false) {
                    $includeTask = false;
                } else {
                    $includeTask = true;
                }
            }
        } elseif ($taskFilterOptions == 'desc') {
            if ($srchText == '') {
                $includeTask = true;
            } else {
                if (strpos($currentTask['requestdescription'], $srchText) !== FALSE) {
                    $includeTask = true;
                } else {
                    $includeTask = false;
                }
            }
        } elseif ($taskFilterOptions == 'appgroup') {
            if ($currentTask['appgroup'] == $appGroup) {
                $includeTask = true;
            } else {
                $includeTask = false;
            }
        }
        if ($includeTask and $statusOption == 3 || $statusOption == 4) {
            if ($statusOption == 3) {
                if (!isset($currentTask['startedDate'])) {
                    $includeTask = false;
                }
            } else {
                if (isset($currentTask['startedDate'])) {
                    $includeTask = false;
                }
            }
        } elseif ($currentTask['status'] == $statusOption || $statusOption == '-1' || $statusOption == '') {
            $includeTask = $includeTask && 1;
        } else {
            $includeTask = false;
        }
        if ($includeTask or $includeAllTasks) {
            array_push($sortedTasks, $taskrec);
        }
    }
    // Now sort the task record Multi-Dimensional Array using selected sort field
    if ($sortDirection == 'asc') {
        $sortDirection = SORT_ASC;
    } else {
        $sortDirection = SORT_DESC;
    }
    if (count($sortedTasks) > 0) {
        if ($taskSortOption != '') {
            foreach ($sortedTasks as $sortrec) {
                $sortAux[] = $sortrec[$taskSortOption];
            }
            array_multisort($sortAux, $sortDirection, $sortedTasks);
        } else {
            // No sortoptions enabled - sort by most recent first
            arsort($sortedTasks);
        }
        if ($pagesize > 0) {
            if ($page > 1) {
                $offset = ($page - 1) * $pagesize;
            } else {
                $offset = 0;
            }
            $sortedTasks = array_slice($sortedTasks, $offset, $pagesize);
        }
    }
    return $sortedTasks;
}
Exemplo n.º 3
0
function performVariableMatch($originalString, $pattern, $patternPrefix, $mode = 'variables', $_ARR)
{
    if ($mode == '') {
        $mode = 'variables';
    }
    preg_match($pattern, $originalString, $matches, PREG_OFFSET_CAPTURE);
    $replacestr = $matches[0][0];
    $tempstr = str_replace($patternPrefix, "", $replacestr);
    $tempstr = str_replace("'}", "", $tempstr);
    switch ($mode) {
        case 'variables':
            $tempval = NXCOM_filterInt(fetchNewVariableID($tempstr, $_ARR));
            break;
        case 'templatedataid':
            $tempval = NXCOM_filterInt(fetchNewTemplateDataID($tempstr, $_ARR));
            break;
    }
    $retval = str_replace($replacestr, "'" . $tempval . "'", $originalString);
    return $retval;
}
Exemplo n.º 4
0
function display_mytasks()
{
    global $CONF_NF, $_USER, $_CONF, $_POST, $_TABLES, $actionurl, $formstatus_options, $usermodeUID, $optLinkVars, $errmsg, $LANG_NF00;
    $nfclass = new nexflow();
    $nfclass->_nfUserId = $usermodeUID;
    $nfclass->set_debug(false);
    $nfclass->getQueue();
    $srchFilter = COM_applyFilter($_REQUEST['srchFilter']);
    $srchText = COM_applyFilter($_REQUEST['srchText']);
    $idForAppGroup = COM_applyFilter($_REQUEST['idAppGroup'], true);
    $searchString = COM_applyFilter($_REQUEST['srchText']);
    $srchStatus = COM_applyFilter($_REQUEST['srchStatus']);
    $doSearch = COM_applyFilter($_POST['dosearch']);
    $taskconsolefilter = COM_applyFilter($_POST['taskconsolefilter'], true);
    $taskSort = COM_applyFilter($_REQUEST['tasksort']);
    $sortDirection = COM_applyFilter($_REQUEST['sortorder']);
    if (empty($taskSort)) {
        $taskSort = 'cdate';
    }
    if (empty($sortDirection)) {
        $sortDirection = 'desc';
    }
    //RK included these items here for future filtering abilities
    $pagesize = COM_applyFilter($_REQUEST['$pagesize'], true);
    $filterdate = COM_applyFilter($_REQUEST['filterdate']);
    $page = COM_applyFilter($_REQUEST['$page'], true);
    $imgset = $_CONF['layout_url'] . '/nexflow/images';
    $headingFilterOptions = '&taskuser='******'desc') {
        $headingFilterOptions .= '&sortorder=asc';
    } else {
        $headingFilterOptions .= '&sortorder=desc';
    }
    if (!empty($srchFilter)) {
        $headingFilterOptions .= "&srchFilter={$srchFilter}";
    }
    if (!empty($srchText)) {
        $headingFilterOptions .= "&srchText={$srchText}";
    }
    if (!empty($idForAppGroup)) {
        $headingFilterOptions .= "&idAppGroup={$idForAppGroup}";
    }
    if (!empty($srchStatus)) {
        $headingFilterOptions .= "&srchStatus={$srchStatus}";
    }
    $p = new Template($_CONF['path_layout'] . 'nexflow');
    $p->set_file(array('report' => 'taskconsole/viewtasks.thtml', 'records' => 'taskconsole/viewtask_record.thtml', 'javascript' => 'taskconsole/javascript/taskconsole.thtml'));
    $p->set_var('layout_url', $_CONF['layout_url']);
    $p->set_var('site_url', $_CONF['site_url']);
    $p->set_var('imgset', $imgset);
    $p->set_var('actionurl', $actionurl);
    $p->set_var('taskuser', $usermodeUID);
    $p->set_var('show_awaystatus', 'none');
    $heading1 = "<a href=\"{$actionurl}?tasksort=template{$headingFilterOptions}\">Flow Name</a>";
    if ($taskSort == 'template') {
        if ($sortDirection == 'asc') {
            $heading1 .= '<span style="padding-left:10px;"><img src="' . $imgset . '/bararrowdown.gif" border="0"></span>';
        } else {
            $heading1 .= '<span style="padding-left:10px;"><img src="' . $imgset . '/bararrowup.gif" border="0"></span>';
        }
    }
    $p->set_var('heading1', $heading1);
    $heading2 = "<a href=\"{$actionurl}?tasksort=taskname{$headingFilterOptions}\">Task Name</a>";
    if ($taskSort == 'taskname') {
        if ($sortDirection == 'asc') {
            $heading2 .= '<span style="padding-left:10px;"><img src="' . $imgset . '/bararrowdown.gif" border="0"></span>';
        } else {
            $heading2 .= '<span style="padding-left:10px;"><img src="' . $imgset . '/bararrowup.gif" border="0"></span>';
        }
    }
    $heading2 .= '<span style="padding-left:5px;font-weight:normal;font-size:9px;">[click on task name to perform]</span>';
    $p->set_var('heading2', $heading2);
    $heading3 = "<a href=\"{$actionurl}?tasksort=cdate{$headingFilterOptions}\">Assigned</a>";
    if ($taskSort == 'cdate') {
        if ($sortDirection == 'asc') {
            $heading3 .= '<span style="padding-left:10px;"><img src="' . $imgset . '/bararrowdown.gif" border="0"></span>';
        } else {
            $heading3 .= '<span style="padding-left:10px;"><img src="' . $imgset . '/bararrowup.gif" border="0"></span>';
        }
    }
    $p->set_var('heading3', $heading3);
    $p->set_var('srchText', $LANG_NF00['srchText']);
    $p->set_var('srchFilter', $LANG_NF00['srchFilter']);
    $p->set_var('srchFilterTitle', $LANG_NF00['srchFilterTitle']);
    $p->set_var('srchFilterReqDesc', $LANG_NF00['srchFilterReqDesc']);
    $p->set_var('srchFilterPrjName', $LANG_NF00['srchFilterPrjName']);
    $p->set_var('srchDoSearch', $LANG_NF00['srchDoSearch']);
    //search/filter area setup
    $appGroupDDL = COM_optionList($_TABLES['nf_appgroups'], 'id,AppGroup');
    $p->set_var('show_selectappfield', 'none');
    $p->set_var('show_searchtextfield', '');
    switch (strtolower($srchFilter)) {
        case 'appgroup':
            $appGroupDDL = COM_optionList($_TABLES['nf_appgroups'], 'id,AppGroup', $idForAppGroup);
            $p->set_var('srchselappgroup', 'selected');
            $p->set_var('show_selectappfield', '');
            $p->set_var('show_searchtextfield', 'none');
        case 'title':
            $p->set_var('srchseltitle', 'selected');
            break;
        case 'desc':
            $p->set_var('srchselreqdesc', 'selected');
            break;
    }
    $p->set_var('srchTextValue', $srchText);
    $p->set_var('srchApplicationGroups', $appGroupDDL);
    switch ($srchStatus) {
        case 1:
            $srchStatus = 0;
            //since the COM_applyfilter makes everything zero, we need to change this from 1 to 0 in code.
            $p->set_var('srchselactive', 'selected');
            break;
        case 2:
            $p->set_var('srchselonhold', 'selected');
            break;
        case 3:
            $p->set_var('srchselstarted', 'selected');
            break;
        case 4:
            $p->set_var('srchselunstarted', 'selected');
            break;
        case -1:
            $p->set_var('srchselany', 'selected');
            break;
    }
    $sel_sort_options = '';
    foreach ($CONF_NF['sortOptions'] as $value => $label) {
        if ($taskSort == $value) {
            $sel_sort_options .= '<option value="' . $value . '" SELECTED=SELECTED>' . $label . '</option>';
            $p->set_var('selected_tasksort_option', $value);
        } else {
            $sel_sort_options .= '<option value="' . $value . '">' . $label . '</option>';
        }
    }
    $p->set_var('sel_sort_options', $sel_sort_options);
    //end of search/filter area
    if (trim($errmsg) != '') {
        $p->set_var('error_message', $errmsg);
    } else {
        $p->set_var('show_message', 'none');
    }
    // Test to see if we enable the ability to select taskconsole view for another user
    if (SEC_hasRights('nexflow.admin')) {
        $p->set_var('show_seltaskuser', '');
        $p->set_var('sel_user_options', COM_optionList($_TABLES['users'], 'uid,username', $usermodeUID));
    } else {
        $p->set_var('show_seltaskuser', 'none');
        $p->set_var('sel_user_options', '');
    }
    if ($_REQUEST['autoclose']) {
        $autoclose = '<script type="text/javascript">' . LB;
        $autoclose .= 'window.onload = function() { ' . LB;
        $autoclose .= '    self.close();' . LB;
        $autoclose .= '    return true;' . LB;
        $autoclose .= '}' . LB;
        $autoclose .= '</script>' . LB;
        $p->set_var('javascript_close_onload', $autoclose);
    }
    $LANG_CONFIRM = 'Please confirm that you want to delete this process and task records';
    /* Clicking on Task Name triggers action and need to use icon in Actions Column to display project Details */
    $newFormLink = $actionurl . '?op=edit&formid=%s&projectid=%s&taskid=%s' . $optLinkVars;
    $editFormLink = $actionurl . '?op=edit&formid=%s&result=%s&taskid=%s' . $optLinkVars;
    $onClick_action = 'OnClick="ajaxStartTask(%s);"';
    /* @TODO: Commented out for now (Blaine)
       //$holdTaskLink = '<a href="#" onclick="ajaxPutOnHold(%s,%s);"><img src="' . $_CONF['layout_url'] . '/nexflow/images/onhold.png" border=0 alt="%s"></a>';
       */
    // Check if this user has any tasks that were reassigned
    $reassignedTaskCount = DB_count($_TABLES['nf_productionassignments'], 'assignBack_uid', $usermodeUID);
    if ($reassignedTaskCount > 0) {
        $reassignment_message .= '<div style="font-weight:normal;padding-left:20px;">';
        if ($reassignedTaskCount == 1) {
            $reassignment_message .= "You have 1 task that has been re-assigned. Click ";
        } else {
            $reassignment_message .= "You have {$reassignedTaskCount} tasks that have been re-assigned. Click ";
        }
        $reassignment_message .= '<a href="' . $actionurl . '?op=reassignments' . $optLinkVars . '">here</a> to view them</div>';
        $p->set_var('reassignment_message', $reassignment_message);
    } else {
        $p->set_var('show_reassignmentmessage', 'none');
    }
    /* This delete feature is disabled for production use via a config option. It will delete all related records for the project this task is linked to */
    $deleteLink = '<a href="' . $actionurl . '?op=delete&taskid=%s&project_id=%s' . $optLinkVars . '" onclick="return confirm(\'' . $LANG_CONFIRM . '\');">';
    $deleteLink .= '<img src="' . $_CONF['layout_url'] . '/nexflow/images/delete.gif" border="0" TITLE="Delete Record"></a>';
    $tasks = $nfclass->get_tasks();
    if ($taskconsolefilter) {
        $p->set_var('lang_hidefilter', 'hide filter');
        $sortedtasks = nf_getSortedTaskArray($tasks, $srchFilter, $taskSort, $srchText, $idForAppGroup, $srchStatus, $sortDirection);
    } elseif (!empty($taskSort)) {
        $p->set_var('hidefilter', 'none');
        $p->set_var('lang_hidefilter', 'show filter');
        $sortedtasks = nf_getSortedTaskArray($tasks, $srchFilter, $taskSort, $srchText, $idForAppGroup, $srchStatus, $sortDirection);
    } else {
        $p->set_var('hidefilter', 'none');
        $p->set_var('lang_hidefilter', 'show filter');
        if (is_array($tasks) and count($tasks) > 0) {
            arsort($tasks);
            // Show latest task first
            $sortedtasks = $tasks;
        } else {
            $sortedtasks = '';
        }
    }
    if (is_array($sortedtasks) and count($sortedtasks) > 0) {
        $i = 1;
        $p->set_var('num_records', count($sortedtasks));
        foreach ($sortedtasks as $taskrec) {
            $p->set_var('task_action_url', '');
            $p->set_var('task_onclick', '');
            $p->set_var('edit', '<span style="padding-left:2px;">&nbsp;</span>');
            $p->set_var('rowid', $i);
            $p->set_var('csscode', $i % 2 + 1);
            $p->set_var('class_newtask', '');
            $startedDate = DB_getItem($_TABLES['nf_queue'], 'startedDate', "id='{$taskrec['id']}'");
            $taskStatus = DB_getItem($_TABLES['nf_queue'], 'status', "id='{$taskrec['id']}'");
            $p->set_var('on_hold_notice', '');
            if ($taskStatus == 2) {
                $p->set_var('task_icon', 'onhold2.png');
                $p->set_var('on_hold_notice', '<p style="margin-bottom:5px;color:red">This Task is ON HOLD. It cannot be executed until it is put back into active status.</p>');
            } else {
                $p->set_var('task_icon', 'task.gif');
            }
            if ($startedDate == NULL or $startedDate == 0) {
                $p->set_var('task_icon', 'new_task.gif');
                $p->set_var('task_started_date', ",task not started");
                $p->set_var('task_onclick', sprintf($onClick_action, $taskrec['id']));
            } else {
                $p->set_var('task_started_date', ",started:{$startedDate}");
                $p->set_var('task_onclick', '');
            }
            $nfclass->_nfProcessId = $taskrec['processid'];
            $project_id = $nfclass->get_ProcessVariable('PID');
            $project_id = NXCOM_filterInt($project_id);
            if ($project_id == 0) {
                //lets try to do a simple select in the nfprojects table to ensure no project exists.
                $sql = "SELECT id from {$_TABLES['nf_projects']} where wf_process_id='{$taskrec['processid']}'";
                $res = DB_query($sql);
                list($project_id) = DB_fetchArray($res);
                $project_id = NXCOM_filterInt($project_id);
            }
            //at this point, if the project_id is still 0, then we have no project data to show
            //show a general task console line item for execution by the end user.
            $taskStatus = DB_getItem($_TABLES['nf_queue'], 'status', "id='{$taskrec['id']}'");
            if (SEC_hasRights('nexflow.admin')) {
                if ($taskStatus == 2) {
                    $p->set_var('hold', sprintf($holdTaskLink, $i, $taskrec['id'], 'Re-activate'));
                } else {
                    $p->set_var('hold', sprintf($holdTaskLink, $i, $taskrec['id'], 'Toggle On-Hold'));
                }
            }
            if ($project_id > 0) {
                $p->set_var('hidetaskinfo', '');
                $project_detailsLink = '<a href="#" onClick=\'ajaxViewProjectDetails(%s,%s,%s,%s);\'>';
                $project_detailsLink .= '<img src="' . $_CONF['layout_url'] . '/nexflow/images/details.png" border="0" TITLE="View Project Details"></a>&nbsp;';
                $project_detailsLink .= '<a href="#" onClick=\'ajaxViewProjectComments(%s,%s,%s,%s);\'>';
                $project_detailsLink .= '<img src="' . $_CONF['layout_url'] . '/nexflow/images/comment.gif" border="0" TITLE="View Project Comments"></a>&nbsp;';
                // If task is for a project on hold or in a Recycled or Killed status then do not show it
                // There should never be any tasks appearing is status is Killed as that workflow should have been forced to complete state.
                $project_state = DB_getItem($_TABLES['nf_projects'], 'status', "id='{$project_id}'");
                if ($project_state != 6 && $project_state != 7) {
                    if ($nfclass->_debug) {
                        $logmsg = "Row:{$i} -> Project ID:{$project_id},Task ID:{$taskrec['id']}. ";
                        $logmsg .= "Processid:{$taskrec['processid']}, Task:{$taskrec['taskname']}, ";
                        $logmsg .= "TaskID: {$taskrec['templateTaskid']}, TaskType: {$taskrec['stepType']}";
                        COM_errorLog($logmsg);
                    }
                    $p->set_var('task_id', $taskrec['id']);
                    $p->set_var('project_id', $project_id);
                    $p->set_var('project_details', sprintf($project_detailsLink, $i, $project_id, $usermodeUID, $taskrec['id'], $i, $project_id, $usermodeUID, $taskrec['id']));
                    // Determine if this task is for a regenerated workflow and we need to update the main project/request record
                    $parentProcessID = DB_getItem($_TABLES['nf_process'], 'pid', "id='{$taskrec['processid']}'");
                    if ($parentProcessID > 0) {
                        // Now check if this same template task id was executed in the previous process - if so then it is a recycled task
                        // Don't show the re-generated attribute if in this instance of the process we proceed further and are executing new tasks
                        if (DB_count($_TABLES['nf_queue'], array('nf_processID', 'nf_templateDataId'), array($parentProcessID, $taskrec['templateTaskid'])) > 0) {
                            $taskrec['taskname'] = '<div style="color:red;padding-right:5px;display:inline;">[R]</div>' . $taskrec['taskname'];
                        }
                    }
                    $pquery = DB_query("SELECT wf_process_id  FROM {$_TABLES['nf_projects']} WHERE id='{$project_id}'");
                    list($wf_process_id) = DB_fetchArray($pquery);
                    if ($wf_process_id > 0 and $wf_process_id == $parentProcessID) {
                        if ($nfclass->_debug) {
                            COM_errorLog("Taskconsole: Updated wf_process_id for project: {$project_id} from {$wf_process_id} to {$taskrec['processid']}");
                        }
                        DB_query("UPDATE {$_TABLES['nf_projects']} SET wf_process_id='{$taskrec['processid']}' WHERE id='{$project_id}'");
                    }
                    $p->set_var('project_number', $project_id);
                    // Retrieve any Project Comments
                    $comment_count = DB_count($_TABLES['nf_projectcomments'], 'project_id', $project_id);
                    if ($comment_count > 0) {
                        $csql = "SELECT timestamp, b.username FROM {$_TABLES['nf_projectcomments']} a ";
                        $csql .= "LEFT JOIN {$_TABLES['users']} b on a.uid=b.uid WHERE project_id='{$project_id}' ";
                        $csql .= "ORDER BY timestamp DESC LIMIT 1";
                        list($timestamp, $username) = DB_fetchArray(DB_query($csql));
                        $p->set_var('comments_note', "({$comment_count}) <b>Last by:</b>&nbsp;{$username}, " . strftime('%m/%d/%Y %H:%M', $timestamp));
                    } else {
                        $p->set_var('comments_note', 'No Comments');
                    }
                    // If this this is an interactive tasktype - Check and see if taskhistory record has a "started" timestamp set.
                    if ($taskrec['stepType'] == 1 or $taskrec['stepType'] == 7 or $taskrec['stepType'] == 8) {
                        $q1 = DB_query("SELECT project_id,date_started FROM {$_TABLES['nf_projecttaskhistory']} WHERE task_id='{$taskrec['id']}'");
                        if (DB_numRows($q1) == 0) {
                            // No task history record yet
                            $p->set_var('class_newtask', 'class="nexflowNewTask"');
                            $q2 = DB_query("SELECT UNIX_TIMESTAMP(createdDate) FROM {$_TABLES['nf_queue']} WHERE id='{$taskrec['id']}' ");
                            list($date_assigned) = DB_fetchArray($q2);
                            DB_query("INSERT INTO {$_TABLES['nf_projecttaskhistory']} (project_id,process_id,task_id,assigned_uid,date_assigned)\r\n                                VALUES ('{$project_id}','{$taskrec['processid']}','{$taskrec['id']}','{$usermodeUID}','{$date_assigned}') ");
                        } else {
                            list($xprj_id, $xdate_started) = DB_fetchArray($q1);
                            if ($xprj_id == 0) {
                                // Task history record - but missing project_id
                                $p->set_var('class_newtask', 'class="nexflowNewTask"');
                                DB_query("UPDATE {$_TABLES['nf_projecttaskhistory']} SET project_id='{$project_id}' WHERE task_id='{$taskrec['id']}'");
                            }
                        }
                    } else {
                        unset($xdate_started);
                    }
                    // Retrieve the project description for this task - used as Project Title
                    $pquery = DB_query("SELECT description,originator_uid FROM {$_TABLES['nf_projects']} WHERE id='{$project_id}'");
                    list($description, $originator) = DB_fetchArray($pquery);
                    $submitted_date = DB_getItem($_TABLES['nf_process'], 'initiatedDate', "id={$taskrec['processid']}");
                    $submitter_info = COM_getDisplayName($originator) . " / {$submitted_date}";
                    // Retrieve the flow name dynamic custom functions for appending to the display name to be used for the description
                    $descSQL = "SELECT b.templateName, a.customFlowName FROM {$_TABLES['nf_process']} a ";
                    $descSQL .= "INNER JOIN {$_TABLES['nf_template']} b on b.id=a.nf_templateId ";
                    $descSQL .= "WHERE a.id={$taskrec['processid']} ";
                    $descRes = DB_query($descSQL);
                    list($templateName, $processCustomName) = DB_fetchArray($descRes);
                    if (trim($description) != '') {
                        $p->set_var('description', $description);
                    } else {
                        $p->set_var('description', $templateName);
                    }
                    if ($processCustomName != '') {
                        $p->set_var('project_title', $processCustomName);
                    } else {
                        $p->set_var('project_title', $templateName);
                    }
                    $p->set_var('assigned_date', $taskrec['cdate']);
                    $p->set_var('submitter_info', $submitter_info);
                    if ($taskrec['stepType'] == 8) {
                        // This is a nexform autotag handler
                        $form_id = $taskrec['url'];
                        // Check and see if the same form has been submitted for this task yet.
                        $sql = "SELECT a.id,a.formtype,a.results_id,a.status,a.created_by_taskid, b.nf_templateDataID ";
                        $sql .= "FROM {$_TABLES['nf_projectforms']} a ";
                        $sql .= "LEFT JOIN {$_TABLES['nf_queue']} b on b.id=a.created_by_taskid ";
                        $sql .= "WHERE project_id='{$project_id}' AND form_id='{$form_id}' ";
                        $query = DB_query($sql);
                        $newFormRecord = false;
                        if (DB_numRows($query) >= 1) {
                            $newFormRecord = true;
                            while (list($prj_formid, $formtype, $result_id, $state, $created_by_taskid, $form_taskTemplateDataID) = DB_fetchArray($query)) {
                                // Check if this is the same task editing, Rejected form so Task is a new queue ID but same templateDataID or Final Edit Task
                                if ($taskrec['id'] == $created_by_taskid || $form_taskTemplateDataID == $taskrec['templateTaskid'] || in_array($taskrec['templateTaskid'], $CONF_NF['final_edit_tasks'])) {
                                    // Check and see if the created_by_taskid has been updated - since it will have the original task id
                                    if ($processPID != 0 and $created_by_taskid != $taskrec['id']) {
                                        DB_query("UPDATE {$_TABLES['nf_projectforms']} SET created_by_taskid='{$taskrec['id']}' WHERE id='{$prj_formid}'");
                                    }
                                    $p->set_var('state', $formstatus_options[$state]);
                                    if ($state == 0 or $state == 2 or $state == 3 or $state == 6) {
                                        // Not final distributed version or rejected
                                        // Need to reset the process variable used to check the form approval result
                                        $nfclass->_nfProcessId = $taskrec['processid'];
                                        $nfclass->set_ProcessVariable('Review_Approval', 0);
                                        /* Using Click on Task to trigger action method */
                                        if ($taskStatus != 2) {
                                            $p->set_var('task_action_url', sprintf($editFormLink, $form_id, $result_id, $taskrec['id']));
                                        } else {
                                            $p->set_var('task_action_url', "#");
                                        }
                                    }
                                    $sql = "SELECT timestamp FROM {$_TABLES['nf_projecttimestamps']} ";
                                    $sql .= "WHERE project_id={$project_id} ORDER BY timestamp DESC LIMIT 1";
                                    $q = DB_query($sql);
                                    list($timestamp) = DB_fetchArray($q);
                                    if ($timestamp > 0) {
                                        $p->set_var('date', strftime("%Y-%m-%d", $timestamp));
                                    } else {
                                        $q2 = DB_query("SELECT UNIX_TIMESTAMP(createdDate) FROM {$_TABLES['nf_queue']} WHERE id='{$taskrec['id']}' ");
                                        list($date_assigned) = DB_fetchArray($q2);
                                        $p->set_var('date', strftime("%Y-%m-%d", $date_assigned));
                                    }
                                    $newFormRecord = false;
                                }
                            }
                        }
                        if (DB_numRows($query) == 0 or $newFormRecord) {
                            // No record yet for this form and process - create mode
                            $p->set_var('state', 'New Task');
                            $p->set_var('class_newtask', 'class="nexflowNewTask"');
                            /* Using Click on Task to trigger action method */
                            if ($taskStatus != 2) {
                                $p->set_var('task_action_url', sprintf($newFormLink, $form_id, $project_id, $taskrec['id']));
                            } else {
                                $p->set_var('task_action_url', "#");
                            }
                            $q2 = DB_query("SELECT UNIX_TIMESTAMP(createdDate) FROM {$_TABLES['nf_queue']} WHERE id='{$taskrec['id']}' ");
                            list($date_assigned) = DB_fetchArray($q2);
                            $p->set_var('date', strftime("%Y-%m-%d", $date_assigned));
                        }
                        $q = DB_QUERY("SELECT statusmsg FROM {$_TABLES['nf_projecttimestamps']} WHERE project_id = '{$project_id}' ORDER BY timestamp DESC LIMIT 1");
                        list($statusmsg) = DB_fetchArray($q);
                        $p->set_var('full_statusmsg', $statusmsg);
                        $msglen = strpos($statusmsg, '.');
                        if ($msglen > 0 and $pos !== FALSE) {
                            $statusmsg = substr($statusmsg, 0, $msglen);
                        }
                        $p->set_var('statusmsg', $statusmsg);
                        $p->set_var('id', $project_id);
                        $p->set_var('task_name', $taskrec['taskname']);
                        $p->set_var('view', '');
                        $p->set_var('action_record', '');
                    } else {
                        // Nexflow task - not a form, Check for interactive function or manualweb step type
                        $p->set_var('id', $taskrec['id']);
                        $p->set_var('process_id', $taskrec['processid']);
                        /* Task date is in format yyyy-mm-dd hh:mm:ss -- only want to show date portion */
                        $showdate = explode(' ', $taskrec['cdate']);
                        $p->set_var('date', $showdate[0]);
                        $sql = "SELECT timestamp,statusmsg FROM {$_TABLES['nf_projecttimestamps']} ";
                        $sql .= "WHERE project_id = '{$project_id}' ORDER BY timestamp DESC LIMIT 1";
                        $q = DB_query($sql);
                        list($timestamp, $statusmsg) = DB_fetchArray($q);
                        $p->set_var('full_statusmsg', $statusmsg);
                        $msglen = strpos($statusmsg, '.');
                        if ($msglen > 0 and $pos !== FALSE) {
                            $statusmsg = substr($statusmsg, 0, $msglen);
                        }
                        $p->set_var('statusmsg', $statusmsg);
                        /* @TODO: $xdate_started has not be set  */
                        if (isset($xdate_started) and $xdate_started == 0) {
                            // Task exists in the taskhistory table but no start_date yet
                            $p->set_var('state', 'New Task');
                        } else {
                            $p->set_var('state', 'Started');
                        }
                        $p->set_var('task_name', $taskrec['taskname']);
                        if (strrpos($taskrec['url'], '?') > 0) {
                            $url = "{$_CONF['site_url']}/nexflow/{$taskrec['url']}&processid={$taskrec['processid']}&taskid={$taskrec['id']}";
                        } else {
                            $url = "{$_CONF['site_url']}/nexflow/{$taskrec['url']}?processid={$taskrec['processid']}&taskid={$taskrec['id']}";
                        }
                        $url .= $optLinkVars;
                        /* Using Click on Task to trigger action method */
                        if ($taskStatus != 2) {
                            $p->set_var('task_action_url', '#');
                            $p->set_var('task_onclick', "onClick=\"togglerec('action',{$i});ajaxStartTask({$taskrec['id']});\" ");
                        } else {
                            $p->set_var('task_action_url', '#');
                            $p->set_var('task_onclick', "");
                        }
                        $p->set_var('chk_accept', '');
                        $p->set_var('chk_reject', '');
                        $p->set_var('project_id', $project_id);
                        $p->set_var('project_id', $project_id);
                        $p->set_var('form_id', $form_id);
                        $p->set_var('taskuser', $usermodeUID);
                        /* Check for any specific tasks that will then over-ride the action url link */
                        if ($taskrec['stepType'] == 7) {
                            // Interactive Function
                            $function = $taskrec['url'];
                            if (function_exists($function)) {
                                /* Call the interactive function passing
                                 *  taskrec, template, rowid and current user if using the user-switch feature
                                 */
                                $function($taskrec, $p, $i, $usermodeUID);
                            }
                        } elseif ($taskrec['stepType'] == 8) {
                            //nexform
                            /* @TODO: What should we be doing in this case?  */
                        } else {
                            /* Using Click on Task to trigger action method */
                            if ($taskStatus != 2) {
                                $p->set_var('task_action_url', $url);
                                $p->set_var('task_onclick', sprintf($onClick_action, $taskrec['id']));
                            } else {
                                $p->set_var('task_action_url', "#");
                                $p->set_var('task_onclick', "");
                            }
                            $p->set_var('action_record', '');
                        }
                    }
                    if (!is_numeric($project_id)) {
                        // Disable the icon to show the task/project detail
                        $p->set_var('project_details', '<span style="padding-right:14px;">&nbsp;</span>');
                        $p->set_var('project_detail', '');
                    }
                }
            } else {
                //there is no project ID to be found.
                //we'll display the non-project formatted item instead
                $project_detailsLink = '<a href="#" onClick=\'ajaxViewProjectDetails(%s,%s,%s,%s);\'>';
                $project_detailsLink .= '<img src="' . $_CONF['layout_url'] . '/nexflow/images/details.png" border="0" TITLE="View Details"></a>&nbsp;';
                $project_detailsLink .= '<a href="#" onClick=\'ajaxViewProjectComments(%s,%s,%s,%s);\'>';
                $project_detailsLink .= '<img src="' . $_CONF['layout_url'] . '/nexflow/images/comment.gif" border="0" TITLE="View Project Comments"></a>&nbsp;';
                $p->set_var('hidetaskinfo', 'none');
                $p->set_var('task_id', $taskrec['id']);
                $p->set_var('project_id', $project_id);
                $p->set_var('project_details', sprintf($project_detailsLink, $i, $project_id, $usermodeUID, $taskrec['id'], $i, $project_id, $usermodeUID, $taskrec['id']));
                $p->set_var('id', $taskrec['id']);
                $p->set_var('process_id', $taskrec['processid']);
                //get the template name here:
                $sql = "SELECT  c.templateName, d.customFlowName FROM {$_TABLES['nf_queue']} a ";
                $sql .= "inner join {$_TABLES['nf_templatedata']} b on a.nf_templatedataid=b.id ";
                $sql .= "inner join {$_TABLES['nf_template']} c on b.nf_templateid=c.id ";
                $sql .= "inner join {$_TABLES['nf_process']} d on a.nf_processid=d.id ";
                $sql .= "WHERE a.id={$taskrec['id']}";
                $res2 = DB_query($sql);
                list($tname, $customDisplay) = DB_fetchArray($res2);
                if ($customDisplay != '') {
                    $tname .= $customDisplay;
                }
                $p->set_var('project_title', $tname);
                /* Task date is in format yyyy-mm-dd hh:mm:ss -- only want to show date portion */
                $showdate = explode(' ', $taskrec['cdate']);
                $p->set_var('date', $showdate[0]);
                $q = DB_QUERY("SELECT timestamp,statusmsg FROM {$_TABLES['nf_projecttimestamps']} WHERE project_id={$project_id} ORDER BY timestamp DESC LIMIT 1");
                list($timestamp, $statusmsg) = DB_fetchArray($q);
                $p->set_var('full_statusmsg', $statusmsg);
                $msglen = strpos($statusmsg, '.');
                if ($msglen > 0 and $pos !== FALSE) {
                    $statusmsg = substr($statusmsg, 0, $msglen);
                }
                $p->set_var('statusmsg', $statusmsg);
                if (isset($xdate_started) and $xdate_started == 0) {
                    // Task exists in the taskhistory table but no start_date yet
                    $p->set_var('state', 'New Task');
                } else {
                    $p->set_var('state', 'Started');
                }
                $p->set_var('task_name', $taskrec['taskname']);
                if (strrpos($taskrec['url'], '?') > 0) {
                    $url = "{$_CONF['site_url']}/nexflow/{$taskrec['url']}&processid={$taskrec['processid']}&taskid={$taskrec['id']}";
                } else {
                    $url = "{$_CONF['site_url']}/nexflow/{$taskrec['url']}?processid={$taskrec['processid']}&taskid={$taskrec['id']}";
                }
                $url .= $optLinkVars;
                /* Using Click on Task to trigger action method */
                $p->set_var('task_action_url', '#');
                if ($taskStatus != 2) {
                    $p->set_var('task_onclick', "onClick=\"togglerec('action',{$i});ajaxStartTask({$taskrec['id']});\" ");
                } else {
                    $p->set_var('task_onclick', "");
                }
                $p->set_var('task_name', $taskrec['taskname']);
                $p->set_var('chk_accept', '');
                $p->set_var('chk_reject', '');
                $p->set_var('project_id', $project_id);
                $p->set_var('form_id', $form_id);
                $p->set_var('taskuser', $usermodeUID);
                /* Check for any specific tasks that will then over-ride the action url link */
                if ($taskrec['stepType'] == 7) {
                    // Interactive Function
                    $function = $taskrec['url'];
                    if (function_exists($function)) {
                        /* Call the interactive function passing
                         *  taskrec, template, rowid and current user if using the user-switch feature
                         */
                        $function($taskrec, $p, $i, $usermodeUID);
                    }
                } elseif ($taskrec['stepType'] == 8) {
                    // nexform Task
                    $form_id = $taskrec['url'];
                    /* Using Click on Task to trigger action method */
                    if ($taskStatus != 2) {
                        $p->set_var('task_action_url', sprintf($newFormLink, $form_id, $project_id, $taskrec['id']));
                    } else {
                        $p->set_var('task_action_url', "#");
                    }
                } else {
                    /* Using Click on Task to trigger action method */
                    if ($taskStatus != 2) {
                        $p->set_var('task_action_url', $url);
                        $p->set_var('task_onclick', sprintf($onClick_action, $taskrec['id']));
                    } else {
                        $p->set_var('task_action_url', "#");
                        $p->set_var('task_onclick', "");
                    }
                    $p->set_var('action_record', '');
                }
                $p->set_var('project_details', '<span style="padding-right:14px;">&nbsp;</span>');
                $p->set_var('project_detail', '');
            }
            //end if - test for valid project_id
            $p->parse('view_records', 'records', true);
            $i++;
        }
        //end foreach
    } else {
        $p->set_var('num_records', 0);
        $p->set_var('view_records', '<tr><td colspan=5 style="padding-left:20px;">No Tasks</td></tr>');
    }
    $p->parse('javascript_code', 'javascript');
    $p->parse('output', 'report');
    return $p->finish($p->get_var('output'));
}
Exemplo n.º 5
0
function nf_copyTemplate($templateID)
{
    global $_TABLES;
    $templateID = NXCOM_filterInt($templateID);
    $sql = "SELECT * FROM {$_TABLES['nf_template']} WHERE id='{$templateID}'";
    $A = DB_fetchArray(DB_Query($sql));
    DB_query("INSERT INTO {$_TABLES['nf_template']}(templateName,useProject,AppGroup) values('{$A['templateName']}-copy',{$A['AppGroup']},{$A['useProject']})");
    $newTemplateId = DB_insertID();
    // Need to copy all the Template Data records
    $sql = "SELECT * FROM {$_TABLES['nf_templatedata']} WHERE nf_templateID='{$templateID}'";
    $q1 = DB_Query($sql);
    $fields = 'nf_templateID, logicalID, nf_stepType, nf_handlerId, firstTask, taskname, ';
    $fields .= 'assignedByVariable, argumentVariable, argumentProcess, operator, ifValue, regenerate,';
    $fields .= 'regenAllLiveTasks, isDynamicForm, dynamicFormVariableID, isDynamicTaskName, dynamicTaskNameVariableID, ';
    $fields .= 'function, formid, optionalParm ';
    /* Need to update fields that are linked to template variables */
    while ($A = DB_fetchArray($q1)) {
        $values = "{$newTemplateId}, {$A['logicalID']}, {$A['nf_stepType']}, ";
        $values .= "{$A['nf_handlerId']}, {$A['firstTask']}, '{$A['taskname']}', {$A['assignedByVariable']}, ";
        $values .= "'{$A['argumentVariable']}', '{$A['argumentProcess']}', '{$A['operator']}', ";
        $values .= "'{$A['ifValue']}', {$A['regenerate']}, {$A['regenAllLiveTasks']},{$A['isDynamicForm']},";
        $values .= "{$A['dynamicFormVariableID']}, {$A['isDynamicTaskName']}, {$A['dynamicTaskNameVariableID']},";
        $values .= "'{$A['function']}', {$A['formid']}, '{$A['optionalParm']}'";
        $sql = "INSERT INTO {$_TABLES['nf_templatedata']} ({$fields}) VALUES ({$values}) ";
        DB_Query($sql);
        $newTemplateDataId = DB_insertID();
        // Need to copy all the Template DataNextStep record matching the source templateData record
        $sql = "SELECT * FROM {$_TABLES['nf_templatedatanextstep']} WHERE nf_templateDataFrom='{$A['id']}'";
        $q2 = DB_Query($sql);
        if (DB_numRows($q2) > 0) {
            $B = DB_fetchArray($q2);
            if ($newTemplateDataId != 0) {
                $sql = "INSERT INTO {$_TABLES['nf_templatedatanextstep']} (nf_templateDataFrom) VALUES ('{$newTemplateDataId}') ";
                DB_query($sql);
            }
        }
    }
    // Now we can cycle thru these tasks again and update the values for the fields linking the tasks
    $sql = "SELECT a.id, a.logicalID, b.nf_templateDataTo, b.nf_templateDataToFalse FROM {$_TABLES['nf_templatedata']} a ";
    $sql .= "INNER JOIN {$_TABLES['nf_templatedatanextstep']} b on a.id = b.nf_templateDataFrom ";
    $sql .= "WHERE nf_templateID='{$templateID}'";
    $q2 = DB_Query($sql);
    $test = DB_numRows($q2);
    while (list($sourceTaskid, $sourceLogicalID, $sourceToTaskid, $sourceFalseTaskid) = DB_fetchArray($q2)) {
        // Get the ID of the matching source logical task in the new template
        $newFromTaskid = DB_getItem($_TABLES['nf_templatedata'], 'id', "logicalID={$sourceLogicalID} AND nf_templateID={$newTemplateId}");
        // Get the ID of the matching source logical task in the new template
        $targetLogicalId = nfidtolid($sourceToTaskid);
        $test = nfidtolid($sourceToTaskid);
        // DB_getItem($_TABLES['nf_templatedata'],'logicalID', "id=$sourceToTaskid");
        $newToTaskid = DB_getItem($_TABLES['nf_templatedata'], 'id', "logicalID={$targetLogicalId} AND nf_templateID={$newTemplateId}");
        // Update the record field nf_templateTo for the new template
        DB_query("UPDATE {$_TABLES['nf_templatedatanextstep']} SET nf_templateDataTo={$newToTaskid} WHERE nf_templateDataFrom={$newFromTaskid}");
        if ($sourceFalseTaskid > 0) {
            $targetFalseLogicalId = nfidtolid($sourceFalseTaskid);
            //DB_getItem($_TABLES['nf_templatedata'],'logicalID', "id=$sourceFalseTaskid");
            $newFalseTaskid = DB_getItem($_TABLES['nf_templatedata'], 'id', "logicalID={$targetFalseLogicalId} AND nf_templateID={$newTemplateId}");
            DB_query("UPDATE {$_TABLES['nf_templatedatanextstep']} SET nf_templateDataToFalse={$newFalseTaskid} WHERE nf_templateDataFrom={$newFromTaskid}");
        }
    }
    // Need to now copy and update the template Variable records
    $query = DB_query("SELECT id, nf_variableTypeID, variableName, variableValue FROM {$_TABLES['nf_templatevariables']} WHERE nf_templateID={$templateID}");
    $templateVariableMap = array();
    while (list($variableID, $variableTypeID, $variableName, $variableValue) = DB_fetchArray($query)) {
        $sql = "INSERT INTO {$_TABLES['nf_templatevariables']} (nf_templateID,nf_variableTypeID,variableName,variableValue) ";
        $sql .= "VALUES ({$newTemplateId}, {$variableTypeID},'{$variableName}','{$variableValue}')";
        DB_query($sql);
        $newVariableID = DB_insertID();
        $sql = "UPDATE {$_TABLES['nf_templatedata']} SET dynamicTaskNameVariableID={$newVariableID} ";
        $sql .= "WHERE id={$newFromTaskid} AND dynamicTaskNameVariableID={$variableID}";
        DB_query($sql);
        // Create a mapping of the original to new template variable ID's so we can update the template task records
        $templateVariableMap[$variableID] = $newVariableID;
    }
    // Retrieve the assignment records for the interactive tasks and insert / update for the copied template
    $sql = "SELECT a.id,a.logicalID,b.uid,b.gid,b.nf_processVariable,b.nf_prenotifyVariable,b.nf_postnotifyVariable,b.nf_remindernotifyVariable ";
    $sql .= "FROM {$_TABLES['nf_templatedata']} a INNER JOIN {$_TABLES['nf_templateassignment']} b on a.id=b.nf_templateDataID ";
    $sql .= "WHERE a.nf_templateID = {$templateID} ";
    $query = DB_query($sql);
    $fields = 'nf_templateDataID,uid,gid,nf_processVariable,nf_prenotifyVariable,nf_postnotifyVariable,nf_remindernotifyVariable';
    while ($A = DB_fetchArray($query)) {
        // Determine the matching taskid in the new template
        $newTaskid = DB_getItem($_TABLES['nf_templatedata'], 'id', "logicalID={$A['logicalID']} AND nf_templateID={$newTemplateId}");
        $sql = "INSERT INTO {$_TABLES['nf_templateassignment']} ({$fields}) VALUES ";
        $sql .= "( {$newTaskid},{$A['uid']},{$A['gid']},{$A['nf_processVariable']},{$A['nf_prenotifyVariable']},";
        $sql .= "{$A['nf_postnotifyVariable']},{$A['nf_remindernotifyVariable']} )";
        DB_query($sql);
        $newAssignmentRecord = DB_insertID();
        // Update field with matching template variable ID
        if ($A['nf_processVariable'] > 0) {
            $variableID = $templateVariableMap[$A['nf_processVariable']];
            DB_query("UPDATE {$_TABLES['nf_templateassignment']} SET nf_processVariable={$variableID} WHERE id={$newAssignmentRecord}");
        }
    }
}
Exemplo n.º 6
0
 function setCustomFlowName($processid, $txt)
 {
     global $_TABLES;
     $processid = NXCOM_filterInt($processid);
     if ($txt != '' && $processid > 0) {
         if (!get_magic_quotes_gpc()) {
             $txt = addslashes($txt);
         }
         $sql = "UPDATE {$_TABLES['nf_process']} set customFlowName='{$txt}' where id={$processid}";
         DB_query($sql);
     }
 }
Exemplo n.º 7
0
}
//now output the templatedata
$sql = "SELECT * from {$_TABLES['nf_templatedata']} where nf_templateID={$origTemplate}";
$res = DB_query($sql);
$cntr = 0;
$tids = '';
while (list($fid, $nf_templateID, $logicalID, $nf_stepType, $nf_handlerId, $firstTask, $taskname, $assignedByVariable, $argumentVariable, $argumentProcess, $operator, $ifValue, $regenerate, $regenAllLiveTasks, $isDynamicForm, $dynamicFormVariableID, $isDynamicTaskName, $dynamicTaskNameVariableID, $function, $formid, $optionalParm, $reminderInterval, $subsequentReminderInterval, $last_updated, $prenotify_message, $postnotify_message, $reminder_message, $numReminders, $escalateVariableID) = DB_fetchArray($res)) {
    $output .= "{$prefix}['templatedata'][{$cntr}]['origid']=\"{$fid}\";";
    $output .= $newline;
    $output .= "{$prefix}['templatedata'][{$cntr}]['SQL']=\"INSERT INTO {$_TABLES['nf_templatedata']} (";
    $output .= "nf_templateID,logicalID,nf_stepType,nf_handlerId,firstTask,taskname, assignedByVariable,argumentVariable,argumentProcess,";
    $output .= "operator,ifValue,regenerate,regenAllLiveTasks,isDynamicForm, dynamicFormVariableID,isDynamicTaskName,dynamicTaskNameVariableID,";
    $output .= "function,formid,optionalParm,reminderInterval,subsequentReminderInterval, last_updated,prenotify_message,postnotify_message,";
    $output .= "reminder_message,numReminders,escalateVariableID";
    $output .= ") values (";
    $output .= "{templateID},{$logicalID},{$nf_stepType},{$nf_handlerId},{$firstTask},'{$taskname}', " . NXCOM_filterInt($assignedByVariable) . ",{argumentvariable:'{$argumentVariable}'},'{$argumentProcess}',";
    $output .= "'{$operator}','{$ifValue}',{$regenerate},{$regenAllLiveTasks},{$isDynamicForm}, {dynamicformvariable:'{$dynamicFormVariableID}'},{$isDynamicTaskName},{dynamictasknamevariable:'{$dynamicTaskNameVariableID}'},";
    $output .= "'{$function}','{$formid}','{$optionalParm}',{$reminderInterval},{$subsequentReminderInterval}, '{$last_updated}','{$prenotify_message}','{$postnotify_message}',";
    $output .= "'{$reminder_message}',{$numReminders},{$escalateVariableID} ";
    $output .= ")\";";
    $output .= $newline;
    $output .= "{$prefix}['templatedata'][{$cntr}]['newid']=\"\";";
    $output .= $newline;
    if ($tids != '') {
        $tids .= ",";
    }
    $tids .= $fid;
    $cntr += 1;
}
//during the import process, the argumentVariable field value will be updated with the ${$prefix}['variables'][xxx]['newid'] field
//based on what the argumentVariable=${$prefix}['variables'][xxx]['origid'].. 'newid' is filled in by the import process and made available
Exemplo n.º 8
0
} elseif ($op == 'holdtask') {
    $status = DB_getItem($_TABLES['nf_queue'], 'status', "id='{$taskid}'");
    $status = NXCOM_filterInt($status);
    if ($status != 2) {
        $nfclass->hold_task($taskid);
    } else {
        $nfclass->unhold_task($taskid);
    }
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("content-type: text/xml");
    $XML = "<result>";
    $XML .= "</result>";
    print $XML;
} elseif ($op == 'holdprocess') {
    $status = DB_getItem($_TABLES['nf_process'], 'complete', "id='{$taskid}'");
    $status = NXCOM_filterInt($status);
    if ($status == 0) {
        $nfclass->hold_process($taskid);
    } elseif ($status == 3) {
        $nfclass->unhold_process($taskid);
    }
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("content-type: text/xml");
    $XML = "<result>";
    $XML .= "</result>";
    print $XML;
} elseif ($op == 'setowner') {
    if (SEC_hasRights('nexflow.admin')) {
        $proessessid = DB_getItem($_TABLES['nf_queue'], 'nf_processID', "id={$taskid}");
        $assigneduid = DB_getItem($_TABLES['nf_productionassignments'], 'uid', "task_id={$taskid}");
        nf_reassign_task($taskid, $taskuser, $assigneduid, $variableid);