Example #1
0
function merge_workorders($wo1, $wo2)
{
    $loc = rmabs(__FILE__ . ".merge_workorders");
    $wid1 = $wo1["WID"];
    $wid2 = $wo2["WID"];
    $wo1["Description"] .= "\n\n" . $wo2["Description"];
    UpdateWorkOrder($wid1, $wo1);
    $data = GetAppendedData($wid2);
    $nd = 0;
    foreach ($data as $d) {
        if ($d["UserID"] == 0) {
            continue;
        }
        // Skip sys generated msg.
        if ($d["Removed"]) {
            continue;
        }
        // Skip deleted data.
        AppendWorkOrderData($wid1, $d["UserID"], $d["TextInfo"], $d["PicID"], false);
        $nd++;
    }
    $workers = GetAssignedWorkers($wid2);
    $nw = 0;
    foreach ($workers as $w) {
        MakeAssignment($wid1, $w["UserID"]);
        RemoveAssignment($wid2, $w["UserID"]);
        $nw++;
    }
    $userid = GetUserID();
    $userinfo = GetUserInfo($userid);
    $username = MakeFullName($userinfo);
    if (!$wo2["Closed"]) {
        ChangeWOStatus($wid2, $username, "Closed", true);
    }
    $newwostr = WIDStr($wid1, $wo1["Revision"], $wo1["IsApproved"]);
    AttachSystemNote($wid2, "This WO Merged into " . $newwostr . " by " . $username . '.');
    $oldwostr = WIDStr($wid2, $wo2["Revision"], $wo2["IsApproved"]);
    AttachSystemNote($wid1, "Data from " . $oldwostr . " merged into this one by " . $username . '.');
    $msg = 'Workorder ' . $oldwostr . ' merged into ' . $newwostr . '.  ';
    $msg .= 'Number Items Copied=' . $nd . '. ';
    $msg .= 'Number of Workers Reassigned=' . $nw . '. ';
    log_msg($loc, array($msg, "By " . $username));
    return $msg;
}
    if (!empty($_POST["Remove"])) {
        if (empty($_POST["Workers"])) {
            $error_msg = "No worker found. Cannot assign.";
            goto SetupForm;
        }
        $workername = $_POST["Workers"];
        $workerid = FindUser("FullName", $workername);
        $workerinfo = GetUserInfo($workerid);
        if (!$workerinfo) {
            $error_msg = "Worker not in database!  Cannot remove.";
            log_error($loc, array($error_msg, "Worker Name: " . $_POST["Workers"]));
            goto SetupForm;
        }
        RemoveAssignment($wid, $workerid);
        $msg = 'Deleted Assignment: "' . $workername . '" unassigned by ' . $username;
        AttachSystemNote($wid, $msg);
        goto SetupForm;
    }
    DieWithMsg($loc, "Incorrect Post.");
}
SetupForm:
$pagetabtitle = "Epic " . $wo["WIDStr"];
$all_workers = GetAllWorkers();
$cur_workers = GetAssignedWorkers($wid);
$possible_workers = RemoveWorkers($all_workers, $cur_workers);
$possible_workers = SortForIPTTeam($possible_workers, $wo["Receiver"]);
$workers = array();
foreach ($possible_workers as $w) {
    $workers[] = $w["FirstName"] . ' ' . $w["LastName"];
}
$currentworkers = array();
Example #3
0
function ChangeWOStatus($wid, $username, $statusField, $state)
{
    $loc = rmabs(__FILE__ . "ChangeWOStatus");
    DenyGuest();
    // Don't allow Guests to do this...
    $sql = 'UPDATE WorkOrders SET ' . $statusField . ' = ' . TFstr($state) . ' WHERE WID=' . intval($wid);
    SqlQuery($loc, $sql);
    $msg = 'Status "' . $statusField . '" changed to ' . TFstr($state) . ' by ' . $username . '.';
    AttachSystemNote($wid, $msg);
}
Example #4
0
        $dgood = $d4;
    }
    if (empty($dgood)) {
        $error_msg = "Bad Date input.  Use yyyy-mm-dd or mm/dd/yy.";
        goto GenerateHtml;
    }
    $dtt = sprintf("%04d-%02d-%02d", $dgood["year"], $dgood["month"], $dgood["day"]);
    $data = ExtractValuesFromParamList($param_list);
    $date["DateNeededBy"] = $dtt;
    $error_msg = UpdateWorkOrder($wid, $data);
    if ($error_msg) {
        $doform = true;
        goto GenerateHtml;
    }
    $userinfo = GetUserInfo($userid);
    $username = MakeFullName($userinfo);
    AttachSystemNote($wid, "Workorder edited by " . $username);
    IncrementRevision($wid);
    $success_msg = "Workorder updated! The revision has been increased.";
    $wo = GetWO($wid);
    $doform = false;
    goto GenerateHtml;
}
GenerateHtml:
$stylesheet = array("../css/global.css", "../css/nav.css", "../css/wo_head.css", "../css/wo_new.css");
include "forms/header.php";
include "forms/nav_form.php";
include "forms/wo_display_menubar.php";
include "forms/wo_edit_form.php";
// !!! Change this when feature is ready.
include "forms/footer.php";