Esempio n. 1
0
function restorePlotter($plotter)
{
    $obj->successful = true;
    $obj->successfulRolls = true;
    $obj->method = "restorePlotter";
    $obj->plotter = $plotter;
    $update = "UPDATE plotters SET cutted = false, cuttedOn = null, cuttedBy = null WHERE id = '" . $plotter->id . "'";
    if (!mysql_query($update)) {
        $obj->successful = false;
    } else {
        $select = "SELECT * from previsions where id = '" . $plotter->previsionId . "'";
        $result = mysql_query($select);
        $obj->prevision = reset(fetch_array($result));
        // $obj->query = $select;
    }
    // increment mts from the mts of the rolls of the plotter
    foreach ($plotter->cuts as $cut) {
        logRollPreviousModification($cut->rollId, 'plotters.restorePlotter(' . $plotter->id . ')', null);
        $update = "UPDATE rolls SET mts = mts + " . $cut->mtsCutted . " WHERE id = '" . $cut->rollId . "'";
        if (!mysql_query($update)) {
            $obj->successfulRolls = false;
        }
    }
    return $obj;
}
Esempio n. 2
0
function updateRollField($roll, $rollField, $value)
{
    $obj->successful = true;
    $obj->method = "updateRollField";
    $obj->roll = $roll;
    // special case mtsOriginal, if that changes also the available mts should be updated
    $extraUpdate = "";
    if ($rollField == 'mtsOriginal') {
        $query = "SELECT * FROM rolls r WHERE r.id = '" . $roll->id . "' ";
        $result = mysql_query($query);
        while ($subrow = mysql_fetch_array($result, MYSQL_ASSOC)) {
            // unique result
            $currentMtsOrig = $subrow['mtsOriginal'];
            $difference = $value - $currentMtsOrig;
            $newMts = $subrow['mts'] + $difference;
            if ($newMts < 0) {
                $newMts = 0;
            }
        }
        $extraUpdate = ", mts = {$newMts} ";
        $obj->roll->mts = $newMts;
    }
    $obj->log = logRollPreviousModification($roll->id, "rolls.updateRollField({$rollField})", null);
    $update = "UPDATE rolls SET {$rollField} = '" . $value . "' {$extraUpdate} WHERE id = '" . $roll->id . "'";
    mysql_query($update);
    return $obj;
}