/** * Delete all work and work_parent records for a work unit * Make sure to delete all children of this record as they depend on it * * @param $work_id */ function delete_work($work_id) { global $db; $db->StartTrans(); $sql = "SELECT work_id\r\n\t\tFROM work_parent\r\n\t\tWHERE parent_work_id = '{$work_id}'"; $children = $db->GetAll($sql); if (!empty($children)) { foreach ($children as $c) { delete_work($c['work_id']); } } $sql = "DELETE FROM work\r\n\t\tWHERE work_id = '{$work_id}'"; $db->Execute($sql); $sql = "DELETE FROM work_parent\r\n\t\tWHERE work_id = '{$work_id}'"; $db->Execute($sql); $db->CompleteTrans(); }
* XHTML functions */ include "../functions/functions.xhtml.php"; /** * DB functions */ include "../db.inc.php"; /** * Work functions */ include "../functions/functions.work.php"; if (isset($_GET['del'])) { $work_id = intval($_GET['del']); $db->StartTrans(); //Delete all work that is dependend on this, including this: delete_work($work_id); $db->CompleteTrans(); } xhtml_head(T_("Work remaining"), true, array("../css/table.css"), array("../js/display.js")); $data_id = 0; if (isset($_GET['data_id'])) { $data_id = intval($_GET['data_id']); } //Select a data file $sql = "SELECT data_id as value,description, CASE WHEN data_id = '{$data_id}' THEN 'selected=\\'selected\\'' ELSE '' END AS selected\r\n\tFROM data"; print "<div>" . T_("Select data file: "); display_chooser($db->GetAll($sql), 'data_id', 'data_id'); print "</div>"; //List work to do for this data_id $sql = "SELECT count(*) as count, d.description as datad, p.description as processd, c.name, o.description as odes, CONCAT('<a href=\\'?del=',w.work_id,'\\'>" . T_("Delete") . "</a>') as dele\r\n\tFROM `work` AS w\r\n\tLEFT JOIN work_parent AS wp ON ( wp.work_id = w.work_id )\r\n\tJOIN `process` AS p ON ( p.process_id = w.process_id )\r\n\tJOIN `column` AS c ON ( c.column_id = w.column_id )\r\n\tJOIN `data` AS d ON ( d.data_id = c.data_id)\r\n\tJOIN cell AS ce ON ( ce.column_id = w.column_id )\r\n\tLEFT JOIN work_unit AS wu2 ON ( wu2.cell_id = ce.cell_id AND wu2.work_id = wp.parent_work_id AND wu2.completed IS NOT NULL )\r\n\tLEFT JOIN work_unit AS wu ON ( wu.cell_id = ce.cell_id AND wu.process_id = w.process_id AND w.work_id = wu.work_id )\r\n\tLEFT JOIN code_group AS cg ON ( cg.code_group_id = p.code_group_id )\r\n\tLEFT JOIN operator AS o ON (w.operator_id = o.operator_id)\r\n\tWHERE wu.cell_id IS NULL\r\n\tAND (wp.work_id IS NULL OR wu2.cell_id IS NOT NULL)"; if ($data_id != 0) {