function createtask_POST(Web &$w) { $w->Task->navigation($w, "Create Task"); // unserialise input from step I and store in array: arr_req $arr_req = unserialize($w->request('formone')); // set relevant dt variables with: Today. $arr_req['dt_assigned'] = Date('c'); $arr_req['dt_first_assigned'] = Date('c'); // insert Task into database $task = new Task($w); $task->fill($arr_req); $task->insert(); // if insert is successful, store additional fields as task data // we do not want to store data from step I, the task_id (as a key=>value pair) nor the FLOW_SID if ($task->id) { foreach ($_POST as $name => $value) { if ($name != "formone" && $name != "FLOW_SID" && $name != "task_id" && $name !== CSRF::getTokenID()) { $tdata = new TaskData($w); $arr = array("task_id" => $task->id, "key" => $name, "value" => $value); $tdata->fill($arr); $tdata->insert(); unset($arr); } } // return to task dashboard $w->msg("Task " . $task->title . " added", "/task/viewtask/" . $task->id); } else { // if task insert was unsuccessful, say as much $w->msg("The Task could not be created. Please inform the IT Group", "/task/index/"); } }
<?php if (count($_POST) > 0) { $user = TaskData::getById($_POST["id"]); $user->title = $_POST["title"]; $category_id = "NULL"; if ($_POST["category_id"] != "") { $category_id = $_POST["category_id"]; } $user->category_id = $category_id; $project_id = "NULL"; if ($_POST["project_id"] != "") { $project_id = $_POST["project_id"]; } $user->project_id = $project_id; $user->description = $_POST["description"]; $user->update(); print "<script>window.location='index.php?view=tasks';</script>"; }
<?php $task = TaskData::getById($_GET["task_id"]); $task->is_done = isset($_GET["is_done"]) ? 1 : 0; $task->done();
function edit_POST($w) { $p = $w->pathMatch("id"); $task = !empty($p["id"]) ? $w->Task->getTask($p["id"]) : new Task($w); $taskdata = null; if (!empty($p["id"])) { $taskdata = $w->Task->getTaskData($p['id']); } $task->fill($_POST['edit']); $task->assignee_id = intval($_POST['edit']['assignee_id']); if (empty($task->dt_due)) { $task->dt_due = $w->Task->getNextMonth(); } $task->insertOrUpdate(); // Tell the template what the task id is (this post action is being called via ajax) $w->setLayout(null); $w->out($task->id); // Get existing task_data objects for this task and update them $existing_task_data = $w->Task->getTaskData($task->id); if (!empty($existing_task_data)) { foreach ($existing_task_data as $e_task_data) { foreach ($_POST["extra"] as $key => $data) { if ($key == \CSRF::getTokenId()) { unset($_POST["extra"][\CSRF::getTokenID()]); continue; } if ($e_task_data->data_key == $key) { $e_task_data->value = $data; $e_task_data->update(); unset($_POST["extra"][$key]); continue; } // If we get here then remove the existing data? // $e_task_data->delete(); } } } // Insert data that didn't exist above as new task_data objects if (!empty($_POST["extra"])) { foreach ($_POST["extra"] as $key => $data) { $tdata = new TaskData($w); $tdata->task_id = $task->id; $tdata->data_key = $key; $tdata->value = $data; $tdata->insert(); } } }
<?php $user = TaskData::getById($_GET["id"]); $user->del(); print "<script>window.location='index.php?view=tasks';</script>";
} if ($_GET["project_id"] != "") { if ($_GET["q"] != "") { $sql .= " and "; } $sql .= " project_id = " . $_GET["project_id"]; } if ($_GET["category_id"] != "") { if ($_GET["q"] != "" || $_GET["project_id"] != "") { $sql .= " and "; } $sql .= " category_id = " . $_GET["category_id"]; } $users = TaskData::getBySQL($sql); } else { $users = TaskData::getAll(); } if (count($users) > 0) { // si hay usuarios ?> <table class="table table-bordered table-hover"> <thead> <th></th> <th>Titulo</th> <th>Proyecto</th> <th>Categoria</th> <th>Creacion</th> <th></th> </thead> <?php foreach ($users as $user) {
<?php $reservation = TaskData::getById($_GET["id"]); $pacients = ProjectData::getAll(); $medics = CategoryData::getAll(); ?> <div class="row"> <div class="col-md-10"> <h1>Editar Tarea</h1> <br> <form class="form-horizontal" role="form" method="post" action="./?action=updatetask"> <div class="form-group"> <label for="inputEmail1" class="col-lg-2 control-label">Titulo</label> <div class="col-lg-10"> <input type="text" name="title" value="<?php echo $reservation->title; ?> " required class="form-control" id="inputEmail1" placeholder="Titulo"> </div> </div> <div class="form-group"> <label for="inputEmail1" class="col-lg-2 control-label">Descripcion</label> <div class="col-lg-10"> <textarea class="form-control" rows="5" name="description" placeholder="Descripcion"><?php echo $reservation->description; ?> </textarea> </div> </div> <div class="form-group">
<?php $r = new TaskData(); $r->title = $_POST["title"]; $r->description = $_POST["description"]; $category_id = "NULL"; if ($_POST["category_id"] != "") { $category_id = $_POST["category_id"]; } $r->category_id = $category_id; $project_id = "NULL"; if ($_POST["project_id"] != "") { $project_id = $_POST["project_id"]; } $r->project_id = $project_id; $r->user_id = $_SESSION["user_id"]; $r->add(); Core::redir("./index.php?view=tasks");
/** * * Set an extra data value field * * @param unknown_type $key * @param unknown_type $value */ function setDataValue($key, $value) { if ($this->id) { $c = $this->Task->getObject("TaskData", array("task_id" => $this->id, "data_key" => $key)); if ($c) { $c->value = $value; $c->update(); } else { $c = new TaskData($this->w); $c->data_key = $key; $c->value = $value; $c->task_id = $this->id; $c->insert(); } } }