Esempio n. 1
0
session_start();
if (!isset($_SESSION['authuser']) || !isset($_GET['target_id']) || !isset($_GET['product_id'])) {
    exit;
}
require_once "./include/config.inc";
require_once "./horse_inc.php";
$target_id = $_GET['target_id'];
$product_id = $_GET['product_id'];
$rt = array('query_status' => 0, 'query_msg' => '');
$rt = check_horse($product_id);
if ($rt['query_status'] == 1) {
    echo json_encode($rt);
    exit;
}
$rt = sync_horse($target_id, $product_id);
$horse = get_horse($target_id, $product_id);
if (isset($_GET['action']) && $_GET['action'] == 'start_horse') {
    $sql = sprintf("UPDATE horse, workflow_object \n\t\t\t\t\t\tSET horse.start_time = now(), workflow_object.status = %d, workflow_object.start_time = now() \n\t\t\t\t\t\tWHERE workflow_object.id = %d AND horse.workflow_object_id = workflow_object.id", STARTED, $horse['workflow_object_id']);
    $st = mysql_query($sql);
    $rt['query_status'] = $st ? 0 : 1;
    $rt['start_sql'] = $sql;
    $rt['query_msg'] = $st ? 'Horse started' : 'Error starting horse:' . mysql_error();
    if ($rt['query_status'] == 0) {
        $rt['horse'] = '<img src="./images/play-disabled.png" />&nbsp;
							<img src="./images/stop.png" onClick="stop_horse($(this).parent());" />&nbsp;
							<img src="./images/eject.png" onClick="cancel_horse($(this).parent());" />&nbsp;';
    }
    echo json_encode($rt);
    exit;
}
if (isset($_GET['action']) && $_GET['action'] == 'stop_horse') {
Esempio n. 2
0
     $delete_sql = preg_replace('/, $/', ')', $delete_sql);
     $del_st = mysql_query($delete_sql);
     if (!$del_st) {
         $error = "DELETE ERROR: " . mysql_error();
     }
 }
 if (isset($_GET['add_to_assignment'])) {
     // init horse if it is not created already
     // get product_id
     $sql = "SELECT product_id FROM task WHERE id = " . $_GET['task_id'];
     $st = mysql_query($sql);
     $row = mysql_fetch_assoc($st);
     $product_id = $row['product_id'];
     require_once 'horse_inc.php';
     sync_horse($_GET['target_id'], $product_id);
     $horse = get_horse($_GET['target_id'], $product_id);
     $horse_id = $horse['id'];
     // get goal_object_id based on horse_id and task_id
     $go_sql = sprintf("SELECT horse.id AS horse_id, goal_object.goal_id, goal_object.id AS goal_object_id, goal_object.status, goal.duration\n\t\t\t\t\t\t\tFROM horse, workflow_object, sequence_object, goal_object, task, goal\n\t\t\t\t\t\t\tWHERE horse.workflow_object_id = workflow_object.id\n\t\t\t\t\t\t\t\tAND workflow_object.id = sequence_object.workflow_object_id \n\t\t\t\t\t\t\t\tAND sequence_object.id = goal_object.sequence_object_id \n\t\t\t\t\t\t\t\tAND goal_object.goal_id = task.goal_id \n\t\t\t\t\t\t\t\tAND goal_object.goal_id = goal.id\n\t\t\t\t\t\t\t\tAND horse.id = %d and task.id = %d", $horse_id, $_GET['task_id']);
     $go_st = mysql_query($go_sql);
     $go_row = mysql_fetch_assoc($go_st);
     // update task_assignment with horse_id and goal_object_id
     // if the goal object is started, set TA status to 1, start_time = now(), due_time = start_time + goal duration
     if ($go_row['status'] == 2) {
         // goal object already started
         $status = 1;
         $start_time = "now()";
         $due_time = "NOW() + INTERVAL " . $go_row['duration'] . " DAY";
     } else {
         $status = 0;
         $start_time = "NULL";