コード例 #1
0
 $username = MakeFullName($userinfo);
 //MakeAbbrivatedName($userinfo);
 if (!empty($_POST["Add"])) {
     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 assign.";
         log_error($loc, array($error_msg, "Worker Name: " . $_POST["Workers"]));
         goto SetupForm;
     }
     MakeAssignment($wid, $workerid);
     $msg = 'New Assigment: "' . $workername . '" assigned by ' . $username;
     AttachSystemNote($wid, $msg);
     goto SetupForm;
 }
 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"]));
コード例 #2
0
ファイル: utils_merge.php プロジェクト: VCHSRobots/EpicTeam
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;
}
コード例 #3
0
ファイル: utils_bulkwo.php プロジェクト: VCHSRobots/EpicTeam
function GenerateBulkWO($params)
{
    global $WOIPTeams;
    $loc = rmabs(__FILE__ . "GenerateBulkWO");
    $sql = 'SELECT * FROM AllActiveUsersView ORDER BY LastName, FirstName';
    $result = SqlQuery($loc, $sql);
    $d = array();
    $num = 0;
    $matchtags = ArrayFromSlashStr($params["FilterTags"]);
    if (empty($matchtags)) {
        $matchtags = array("Worker");
    }
    $title_template = $params["Title"];
    $nerr = 0;
    $nok = 0;
    $wid0 = 0;
    $wid1 = 0;
    $num = 0;
    while ($userinfo = $result->fetch_assoc()) {
        // Decide if this person should get a WO.
        $taglist = ArrayFromSlashStr($userinfo["Tags"]);
        if (TagMatch(array("Guest"), $taglist)) {
            continue;
        }
        // Guests NEVER get one.
        if (!TagMatch($matchtags, $taglist)) {
            continue;
        }
        // We passed the test, this person gets one!
        // Figure out the receiving IPT.
        $ipt = $userinfo["IPT"];
        if (empty($ipt)) {
            $ipt = $WOIPTeams[8];
        }
        // Hopefully this is management.
        $params["Receiver"] = $ipt;
        $num++;
        $snum = sprintf("%d", $num);
        $params["Title"] = TemplateReplace($title_template, $snum, "##");
        $rwo = CreateNewWorkOrder($params);
        $wid = $rwo[0];
        if ($wid == 0) {
            // failed.
            log_error($loc, array("Failed to Create Bulk WO. Reason: " . $rwo[1], 'WO Title: ' . $params["Title"]));
            $nerr++;
            continue;
        }
        // Add assingment
        MakeAssignment($wid, $userinfo["UserID"]);
        if ($nok == 0) {
            $wid0 = $wid;
        }
        $wid1 = $wid;
        $nok++;
    }
    $msg = 'Number of WOs Created = ' . $nok . '.  Number of Failures = ' . $nerr . '.';
    $msg .= "  WID=" . $wid0 . " to " . $wid1 . ".";
    log_msg($loc, "Bulk WO Created. WIDs " . $wid0 . " to " . $wid1);
    return $msg;
}