function handle_milestone_completed($params)
{
    $milestone_id = get_form_param($params, 'objectId');
    $milestone = get_milestone($milestone_id);
    $project_name = trim($milestone['project-name']);
    $milestone_name = trim($milestone['title']);
    error_log('project name is ' . $project_name);
    error_log('milestone name is ' . $milestone_name);
    $task = find_task(['where' => json_encode(['taskTemplate.name' => ['_eq' => $milestone_name], 'checklistRevision.checklist.name' => ['_eq' => $project_name], 'checklistRevision.checklist.status' => ['_eq' => 'Active'], 'checklistRevision.status' => ['_eq' => 'Active']]), 'include' => 'taskTemplate,checklistRevision.checklist', 'orderBy' => '+checklistRevision.createdDate', 'limit' => 1]);
    if (!empty($task)) {
        update_task($task['id'], ['status' => 'Completed']);
        error_log("succeeded to update task '{$task['id']}'");
    } else {
        error_log("no task found in Process Street for milestone '{$milestone_name}' in project '{$project_name}'");
    }
    http_response_code(200);
    exit;
}
Beispiel #2
0
/** FINALIZE SCAN TASK 
 * 
 * @param $tid - TASK ID
 * @param $type - TASK TYPE
 * @param $status - TASK STATUS (STOPPED - PERFORMED)
 * 
 **/
function finalize_scan($tid, $type, $status)
{
    //global $log;
    //$log->info('Task #'.$tid.' '.$type.' '.$status);
    //$log->info('Task #'.$tid.' start finalizing');
    //LOAD DB
    $db = new Database();
    //GET TASK
    $task = $db->query('select * from sys_tasks where id=' . $tid);
    //GET TASK ATTRIBUTES
    $attributes = json_decode($task['attributes'], TRUE);
    if ($type == 'scan_r' || $type == 'scan_p' || ($type = "scan_s")) {
        sleep(5);
        $id_obj = $attributes['id_obj'];
        if ($attributes['new'] == 'true') {
            // CREATE & ADD OBJ
            $_obj_data['obj_name'] = $attributes['obj_name'] == '' ? 'No name object' : $attributes['obj_name'];
            //$_obj_data['obj_name']        = 'scan_'.$_task_id.'_'.$_attributes['time'];
            $_obj_data['obj_description'] = 'Object created from scanning  on ' . date('l jS \\of F Y h:i:s A');
            $_obj_data['date_insert'] = 'now()';
            $_obj_data['user'] = $task['user'];
            $id_obj = $db->insert('sys_objects', $_obj_data);
        }
        if (!isset($attributes['pprocess_file'])) {
            $attributes['pprocess_file'] = 'cloud_' . $tid . '.asc';
        }
        // INSERT ASC FILE RECORD TO DB
        $_data_file['file_name'] = $attributes['pprocess_file'];
        $_data_file['file_type'] = 'application/octet-stream';
        $_data_file['file_path'] = '/var/www/upload/asc/';
        $_data_file['full_path'] = '/var/www/upload/asc/' . $attributes['pprocess_file'];
        $_data_file['raw_name'] = str_replace('.asc', '', $attributes['pprocess_file']);
        $_data_file['orig_name'] = $attributes['pprocess_file'];
        $_data_file['client_name'] = $attributes['pprocess_file'];
        $_data_file['file_ext'] = '.asc';
        $_data_file['file_size'] = filesize($attributes['folder'] . $attributes['pprocess_file']);
        $_data_file['insert_date'] = 'now()';
        $_data_file['note'] = 'Cloud data file obtained by scanning in ' . ucfirst($attributes['mode_name']) . ' mode on ' . date('l jS \\of F Y h:i:s A');
        $id_file = $db->insert('sys_files', $_data_file);
        /** MOVE ASC FILE TO UPLOAD/ASC */
        rename($attributes['folder'] . $attributes['pprocess_file'], $_data_file['full_path']);
        /** ASSOCIATE FILE TO OBJECT */
        $_data_assoc['id_obj'] = $id_obj;
        $_data_assoc['id_file'] = $id_file;
        $id_assoc = $db->insert('sys_obj_files', $_data_assoc);
        /** UPDATE TASK */
        $attributes['id_obj'] = $id_obj;
        $attributes['id_file'] = $id_file;
        $_data_update['attributes'] = json_encode($attributes);
        $db->update('sys_tasks', array('column' => 'id', 'value' => $tid, 'sign' => '='), $_data_update);
        $db->close();
    }
    // EXEC MACRO END_SCAN
    $_time = time();
    $_destination_trace = $attributes['folder'] . 'end_scan.trace';
    $_destination_response = $attributes['folder'] . 'end_scan.log';
    write_file($_destination_trace, '', 'w');
    chmod($_destination_trace, 0777);
    write_file($_destination_response, '', 'w');
    chmod($_destination_response, 0777);
    /** EXEC */
    $_command = 'sudo python ' . PYTHON_PATH . 'gmacro.py end_scan ' . $_destination_trace . ' ' . $_destination_response . '  ';
    $_output_command = shell_exec($_command);
    //UPDATE TASK
    update_task($tid, $status);
    sleep(5);
    //REMOVE ALL TEMPORARY FILES
    shell_exec('sudo rm -rf ' . $attributes['folder']);
    //$log->info('Task #'.$tid.' end finalizing');
}
<?php

if (isset($_REQUEST['cmd'])) {
    $cmd = $_REQUEST['cmd'];
    switch ($cmd) {
        case 1:
            task_preview();
            break;
        case 2:
            delete_task();
            break;
        case 3:
            add_task();
            break;
        case 4:
            update_task();
            break;
        case 5:
            display_tasks();
            break;
        case 6:
            search_task();
            break;
        case 7:
            user_login();
            break;
        case 8:
            delete_tasks();
            break;
        case 9:
            select_collaborator();
Beispiel #4
0
         $return['error'] = 'Vous devez &eacute;tre connect&eacute; pour effectuer cette action';
     }
     break;
 case 'deleteTask':
     if ($myUser != false) {
         delete_task($_['i']);
         $return['info'] = 'T&acirc;che correctement suprim&eacute;e.';
     } else {
         $return['error'] = 'Vous devez &eacute;tre connect&eacute; pour effectuer cette action';
     }
     break;
 case 'changeTaskState':
     if ($myUser != false) {
         $task = get_task($_['i']);
         $task['s'] = $_['s'];
         update_task($task);
     } else {
         $return['error'] = 'Vous devez &eacute;tre connect&eacute; pour effectuer cette action';
     }
     break;
 case 'login':
     if ($_['login'] == USER_LOGIN && $_['password'] == USER_PASSWORD) {
         $myUser = new stdClass();
         $myUser->login = USER_LOGIN;
         $myUser->password = USER_PASSWORD;
         $_SESSION['currentUser'] = serialize($myUser);
     }
     header('location: ./index.php');
     break;
 case 'logout':
     $_SESSION = array();
Beispiel #5
0
 function update_revisions()
 {
     $projectid = $this->input->post('id');
     $employeeid = $_SESSION['id'];
     $description = $this->input->post('description');
     $background = $this->input->post('background');
     $significance = $this->input->post('significance');
     $latitude = $this->input->post('latitude');
     $longitude = $this->input->post('longitude');
     $locationname = $this->input->post('locationname');
     $oldworkplans = json_decode($this->input->post('oldworkplans'), true);
     $newworkplans = json_decode($this->input->post('newworkplans'), true);
     $oldobjectives = json_decode($this->input->post('oldobjective'));
     $newobjectives = json_decode($this->input->post('newobjective'));
     $oldoutputs = json_decode($this->input->post('oldoutputs'));
     $newoutputs = json_decode($this->input->post('newoutputs'));
     if ($oldworkplans != "") {
         for ($x = 0; $x < count($oldworkplans); $x++) {
             $owp = $oldworkplans[$x];
             $this->tasks_model->delete_employee_task($owp['id']);
             $this->tasks_model->delete_task_skillset($owp['id']);
             if ((int) $owp['type'] == 1) {
                 if ((int) $owp['inv'] == 1) {
                     $this->employee_model->add_task_to_employee($owp['id']);
                 }
                 for ($y = 0; $y < count($oldworkplans[$x]['workskills']); $y++) {
                     $ws = $owp['workskills'][$y];
                     $this->tasks_model->add_skillset_to_task($ws, $owp['id']);
                 }
                 $fromto = $this->convertFormattedDate($owp['taskfrom'], $owp['taskto']);
                 $this->tasks_model->update_task($owp['name'], $owp['milestone'], $fromto[0], $fromto[1], (int) $owp['numemp'], (int) $owp['priority'], $owp['outputs'], (int) $owp['id']);
             } else {
                 $this->tasks_model->delete_task($owp['id']);
             }
         }
     }
     if ($newworkplans != "") {
         for ($x = 0; $x < count($newworkplans); $x++) {
             $nwp = $newworkplans[$x];
             $fromto = $this->convertFormattedDate($nwp['taskfrom'], $owp['taskto']);
             update_task($nwp['name'], $nwp['milestone'], $fromto[0], $fromto[1], (int) $nwp['numemp'], (int) $nwp['priority'], $nwp['outputs'], 0);
             $id = $this->task_model->get_last_inserted_task();
             for ($y = 0; count($nwp->workskills); $y++) {
                 $ws = $nwp['workskills'][$y];
                 $this->tasks_model->add_skillset_to_task($ws, $nwp['id']);
             }
             if ((int) $nwp['inv'] == 1) {
                 $this->employee_model->add_task_to_employee($id);
             }
         }
     }
     if ($oldobjectives != "") {
         for ($x = 0; $x < count($oldobjectives); $x++) {
             $oo = $oldobjectives[$x];
             if ((int) $oo->stat == 1) {
                 $this->objectives_model->update_objective($oo->value, $oo->id);
             } else {
                 $this->objectives_model->delete_objective($oo->id);
             }
         }
     }
     if ($newobjectives != "") {
         for ($x = 0; $x < count($newobjectives); $x++) {
             $no = $newobjectives[$x];
             $this->objectives_model->add_objective($oo->value, $projectid);
         }
     }
     if ($oldoutputs != "") {
         for ($x = 0; $x < count($oldoutputs); $x++) {
             $oo = $oldoutputs[$x];
             if ((int) $oo->type == 1) {
                 $this->outputs_model->update_output($oo->eoutput, $oo->pindicator, (int) $oo->id);
             } else {
                 $this->outputs_model->delete_output((int) $oo->id);
             }
         }
     }
     if ($newoutputs != "") {
         for ($x = 0; $x < count($newoutputs); $x++) {
             $no = $newoutputs[$x];
             $this->outputs_model->update_output($no->eoutput, $no->pindicator, 0, $projectid);
         }
     }
     /*$this->project_model->update_project_details($description,$background,$significance,$latitude,$longitude,$locationname,$projectid);
       $this->delete_director_revisions($projectid);*/
 }