Exemplo n.º 1
0
function deletePlotter($plotterId)
{
    $obj->successful = true;
    $obj->method = 'deletePlotter';
    // If plotter to delete is already cutted we need to restablish mts to the rolls
    // (i'm doing a restore plotter just to reuse code, it will be deleted later anywise)
    $query = "SELECT * FROM plotters WHERE id = '{$plotterId}'";
    $result = mysql_query($query);
    $rows = fetch_array($result);
    // unique result
    if ($rows[0]['cutted'] == true || $rows[0]['cutted'] == '1') {
        $plotter = new stdClass();
        $plotter->id = $plotterId;
        $plotter->cuts = array();
        $query = "SELECT * FROM plottercuts WHERE plotterId = '{$plotterId}'";
        $result = mysql_query($query);
        $cutsrows = fetch_array($result);
        foreach ($cutsrows as $row) {
            $cut = new stdClass();
            $cut->mtsCutted = $row['mtsCutted'];
            $cut->rollId = $row['rollId'];
            array_push($plotter->cuts, $cut);
        }
        restorePlotter($plotter);
    }
    // insert in removed plotters
    $query = "INSERT INTO removedplotters SELECT *, now() FROM plotters WHERE id = '{$plotterId}'";
    if (!mysql_query($query)) {
        $obj->successful = false;
        $obj->query = $query;
    }
    // delete plotter
    $query = "DELETE FROM plotters WHERE id = '" . $plotterId . "'";
    if (!mysql_query($query)) {
        $obj->successful = false;
        $obj->query = $query;
    }
    // delete assigned cuts (Note: plotter cuts assigned but not cutted are not reduced from roll mts so no need to restore nothing here)
    $query = "DELETE FROM plottercuts WHERE plotterId = '{$plotterId}'";
    if (!mysql_query($query)) {
        $obj->successful = false;
        $obj->query = $query;
    }
    // TODO possible after removing a plotter the prevision get in allCutted state -> include info in response
    $prevision = checkAllClothsCutted($rows[0]['previsionId']);
    $obj->allCutted = $prevision['allCutted'];
    $obj->plotterId = $plotterId;
    $obj->row0 = $rows[0];
    return $obj;
}
Exemplo n.º 2
0
 if (isset($_GET['clothId'])) {
     $value = getPrevisions($_GET['clothId'], $designed, $expand, null);
 } else {
     if (isset($_GET['listForProduction'])) {
         // deprecated - use with POST
         $value = getPrevisions(null, null, $expand, true, null, $_GET['sellerCode'], $filters);
     } else {
         if (isset($_GET['listHistoric'])) {
             // deprecated - use with POST
             $value = getPrevisions(null, null, $expand, null, true, $_GET['sellerCode']);
         } else {
             if (isset($_GET['expand']) && $_GET['expand'] == 'NONE') {
                 $value = getPrevisionsBasic();
             } else {
                 if (isset($_GET['checkAllClothsCutted'])) {
                     $value = checkAllClothsCutted($_GET['previsionId']);
                 } else {
                     if (isset($_GET['updateAllPrevisionsStates'])) {
                         $value = updateAllPrevisionsStates($_GET['updateClothId'], $_GET['limit'], $_GET['offset']);
                     } else {
                         if (isset($_GET['updatePrevisionState'])) {
                             $value = updatePrevisionState($_GET['updateClothId']);
                         } else {
                             if (isset($_GET['weeksBySeason'])) {
                                 $value = getWeeksBySeason($_GET['weeksBySeason']);
                             } else {
                                 $value = getPrevisions(null, $designed, $expand, null);
                             }
                         }
                     }
                 }