function toDesignPlotter($plotter) { $obj->successful = true; $obj->method = 'toDesignPlotter'; logPrevisionUpdateFull($plotter->previsionId, 'toDesignPlotter'); // prevision back to in design state $update = "UPDATE previsions set designed = false where id = '" . $plotter->previsionId . "'"; if (!mysql_query($update)) { $obj->successful = false; $obj->updatePrevision = $update; } else { $select = "SELECT * from previsions where id = '" . $plotter->previsionId . "'"; $result = mysql_query($select); $obj->prevision = reset(fetch_array($result)); $obj->query = $select; } // remove all plotters with the same prevision id $query = "SELECT p.* FROM plotters p join previsions pre on pre.id = p.previsionId WHERE pre.id = '" . $plotter->previsionId . "'"; $result = mysql_query($query); $obj->deletePlotterResults = array(); $rows = fetch_array($result); foreach ($rows as $row) { $result = deletePlotter($row['id']); if (!$result->successful) { $obj->successful = false; $obj->query = $result->query; $obj->submethod = $result->method; } array_push($obj->deletePlotterResults, $result); } return $obj; }
<?php // insert new user or update it if already exists include_once '../include/headers.php'; include_once '../include/dbutils.php'; include_once '../include/main.php'; include_once 'domain/plotters.php'; include_once 'domain/previsions.php'; db_connect(); if ($_SERVER['REQUEST_METHOD'] == 'DELETE') { if (isset($_GET['cutId'])) { $response = deletePlotterCut($_GET['cutId']); //return JSON array exit(json_encode($response)); } else { if (isset($_GET['removePlotter'])) { $response = deletePlotter($_GET['id']); //return JSON array exit(json_encode($response)); } else { if (isset($_GET['removeManualPlotter'])) { $response = deleteManualPlotter($_GET['id']); //return JSON array exit(json_encode($response)); } } } }