Example #1
0
 function delete()
 {
     $id = $this->input->get('id');
     if ($id == "1") {
         redirect(base_url(roleURIUser() . 'content/tags'), 'refresh');
     } else {
         deleteTerm($id);
         redirect(base_url(roleURIUser() . 'content/tags'), 'refresh');
     }
 }
    $_POST["startdate"] = converttodb($_POST["startdate"]);
    $_POST["enddate"] = converttodb($_POST["enddate"]);
    $query = mysql_query("INSERT INTO terms VALUES ('', '{$_POST['title']}', '{$_POST['startdate']}', '{$_POST['enddate']}')") or die("ManageTerms.php: Unable to insert new term - " . mysql_error());
}
// Edit the term if one is being edited //
if ($_POST["editterm"] == 1 && $_POST["startdate"] != "" && $_POST["title"] != "" && $_POST["enddate"] != "") {
    $_POST["startdate"] = converttodb($_POST["startdate"]);
    $_POST["enddate"] = converttodb($_POST["enddate"]);
    $query = mysql_query("UPDATE `terms` SET `title`='{$_POST['title']}', `startdate`='{$_POST['startdate']}', `enddate`='{$_POST['enddate']}' WHERE `termid`='{$_POST['termid']}' LIMIT 1") or die("ManageTerms.php: Unable to update the term information - " . mysql_error());
}
// Delete the terms that the user has requested as well as the classes belonging to those terms //
if ($_POST["deleteterm"] == 1) {
    require_once "DeleteFunctions.php";
    $delete = $_POST["delete"];
    for ($i = 0; $i < sizeof($delete); $i++) {
        deleteTerm($delete[$i]);
    }
}
print "<script language='JavaScript'>\n  // Function to make sure the user wants to delete the term(s) //\n  function validate()\n  {\n   if( document.terms.selectterm.value > 0 )\n   {\n\tvar confirmed = confirm(\"Deleteing a term will also delete the semesters, classes, bulletins, tardies, attendance, assignments, and registrations that occured during that term. \\n \\nAre you sure?\");\n\n\tif( confirmed == true )\n\t{\n\t document.terms.submit();\n\t}\n   }\n   else\n   {\n\talert('You must select a term to delete.');\n   }\n  }\n\n\n  // Function to make sure only one checkbox has been selected //\n  function checkboxes()\n  {\n   if( document.terms.selectterm.value == 1 )\n   {\n\tdocument.terms.submit();\n   }\n   else\n   {\n\tif( document.terms.selectterm.value > 1 )\n\t{\n\t alert('You can only edit one term at a time.');\n\t}\n\telse\n\t{\n\t alert('You must select a term to edit.');\n\t}\n   }\n  }\n\n\n  // Function to keep track of how many checkboxes are checked //\n  function updateboxes(row)\n  {\n   row = row + 2;\n   if(document.terms.elements[row].checked)\n   {\n\tdocument.terms.selectterm.value = Math.round(document.terms.selectterm.value) + 1;\n   }\n   else\n   {\n\tdocument.terms.selectterm.value = Math.round(document.terms.selectterm.value) - 1;\n   }\n  }\n </script>\n\n <h1>Manage Terms</h1>\n <br><br>\n <table align='center' width='450' cellspacing='0' cellpadding='0' border='0'>\n <tr>\n <td>\n <form name='terms' action='./index.php' method='POST'>\n  <input type='button' value='Add' onClick='document.terms.page2.value=8;document.terms.submit();'>\n  <input type='button' value='Edit' onClick='document.terms.page2.value=12;checkboxes();'>\n  <input type='button' value='Delete' onClick='document.terms.deleteterm.value=1;validate();'>\n  <br><br>\n  <table cellspacing='0' width='450' cellpadding='8' class='dynamiclist'>\n   <tr class='header'>\n   <td>&nbsp;</td>\n   <th>Term Name</th>\n   <th>Start Date</th>\n   <th>End Date</th>\n   </tr>";
// Get the total number of teachers to know how many pages to have //
$query = mysql_query("SELECT COUNT(*) FROM terms") or die("ManageTerms.php: Unable to retrieve total number of terms - " . mysql_error());
$numrows = mysql_result($query, 0);
$numpages = ceil($numrows / 25);
if ($_POST["onpage"] == "") {
    $_POST["onpage"] = 1;
}
// Get and display the terms //
$query = mysql_query("SELECT termid,title,startdate,enddate FROM terms ORDER BY enddate DESC");
$row = 0;
$actualrow = 0;
while ($term = mysql_fetch_row($query)) {
Example #3
0
 function delete()
 {
     $id = $this->input->post('id');
     $s = array('term_pareng' => $id);
     $this->m_database->deleteRow('terms', $s);
     deleteTerm($id);
     echo json_encode('ok');
 }