} $status = array('status_code' => $status_code, 'status_message' => $status_mssg, 'plan_id' => $plan_id, 'plan_title' => $plan_name); echo json_encode($status); break; } } else { if (strlen($plan_id) > 0) { submitChanges($plan_id, $added_rules, $removed_rules); } } $status = array('status_code' => '000', 'status_message' => 'Success', 'plan_id' => $plan_id, 'plan_title' => $plan_name); echo json_encode($status); break; case "deletePlan": $plan_id = $_GET["plan_id"]; deletePlan($plan_id); break; case "togglePlanStatus": $dataToggle = json_decode(file_get_contents('php://input'), true); $plan_id_toggle = $dataToggle['selected_plan']; $plan_pid_toggle = $dataToggle['selected_plan_pid']; $active_inactive = $dataToggle['plan_status']; if ($active_inactive == 'deactivate') { $nm_flag = 0; } else { $nm_flag = 1; } try { togglePlanStatus($plan_id_toggle, $nm_flag); } catch (Exception $e) { if ($e->getMessage() == "007") {
<?php include_once "conn.php"; include_once "planDB.php"; $action = $_REQUEST["action"]; $res = ""; switch ($action) { case "addPlan": $res = addPlan($_POST); break; case "deletePlan": $res = deletePlan($_REQUEST["id"]); break; case "deletePlanByProjectId": $res = deletePlanByProjectId($_REQUEST["projectId"]); break; case "editPlan": $res = editPlan($_POST); break; case "getPlan": $res = getPlan($_REQUEST["id"]); break; case "getPlanByProjectId": $res = getPlanByProjectId($_REQUEST["projectId"]); break; default: throw new Exception("unknown action:" . $action); } echo json_encode($res);
$con = mysql_connect("localhost:3306", "root", "5656123ljx"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("capstone", $con); function insertPlan($sid, $plannerId, $nickName) { $sql = "insert into stu_plan(sid,plannerId,nickName) VALUES ('" . $sid . "','" . $plannerId . "','" . $nickName . "')"; mysql_query($sql); } function deletePlan($sid, $plannerId) { $sql = "delete from stu_plan where sid='" . $sid . "' and plannerId='" . $plannerId . "'"; echo $sql; mysql_query($sql); } $deleteId = $_GET['deleteId']; if ($deleteId == null) { session_start(); $sid = $_SESSION['sid']; $nickName = $_GET['nickName']; $plannerId = mysql_fetch_array(getMaxPlannerIdBySid($sid))[0]; $plannerId++; insertPlan($sid, $plannerId, $nickName); header("location:../view/displayPlanner.php?plannerId=" . $plannerId); } else { session_start(); $sid = $_SESSION['sid']; deletePlan($sid, $deleteId); header("location:../view/selectTermToSetPlanner.php"); }