onblur="validatePassword()" required> <div id="passVal"></div> </td> </tr> <tr> <td>Gender:</td> <td> <input type="radio" name="gender" id="g" value="M" required>M <input type="radio" name="gender" id="g"value="F" required>F </td> </tr> <tr> <td>Department:</td><td><select name="dpt" required> <?php include_once 'department.php'; $obj = new departments(); $obj->get_all_departments(); $rows = $obj->fetch(); $counter = 0; echo '<option value="" id="dpt">--select a department--</option>'; while ($rows) { $counter = $rows['department_id']; $department_name = $rows['department_name']; echo "<option value='{$counter}'>{$department_name}</option>"; $rows = $obj->fetch(); } ?> </select> </td> </tr> <tr class="add-button">
public function main() { ?> <div id="main"> <?php $departments = departments::get(); ?> <table class="ui table segment square-corners celled"> <thead> <tr class="header"> <th class="numeric">#</th> <th>Наименование кафедры</th> <th colspan="2" class="right icon-add"><i class="icon add sign pointer" title="Добавить" onclick="$('#add_modal').modal('show');"></i></th> </tr> </thead> <tbody> <?php foreach ($departments as $department) { ?> <tr id="department-<?php echo $department->id; ?> "> <td class="small numeric"><?php echo $department->id; ?> </td> <td><?php echo $department->name; ?> </td> <td class="icon first no-border"> <a href="#" onclick="$('#edit_modal').modal('show'); $('.id').val('<?php echo $department->id; ?> '); $('.editname').val('<?php echo $department->name; ?> ');"> <i class="icon edit" title="Редактировать"></i> </a> </td> <td class="icon last no-border"> <a href="#" onclick="$.post('<?php echo template_url::ajax('departments', 'remove', $department->id); ?> ').done(function(answer) { answer_removed(answer, <?php echo $department->id; ?> ); }); return false;"> <i class="icon remove circle" title="Удалить"></i> </a> </td> </tr> <?php } ?> </tbody> </table> </div> <script> function answer_removed(answer, department_id) { console.log(answer); switch(answer) { case '<?php echo RUDE_AJAX_ERROR; ?> ': break; case '<?php echo RUDE_AJAX_OK; ?> ': console.log(this); $('#department-' + department_id).fadeOut('slow'); break; case '<?php echo RUDE_AJAX_ACCESS_VIOLATION; ?> ': $('#access-violation').modal('show'); break; default: break; } return false; } </script> <div id="add_modal" class="ui modal"> <i class="close icon"></i> <div class="header"> Добавить кафедру </div> <div class="content"> <div class="ui form segment"> <div class="field"> <label for="name">Наименование кафедры</label> <div class="ui left labeled input"> <input class="name" name="name" type="text" placeholder="Наименование кафедры"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="ui error message"> <div class="header">Найдены ошибки при заполнении формы</div> </div> <div class="ui blue submit button" value="add">Добавить</div> </div> </div> </div> <script> $('#add_modal .ui.form') .form({ name: { identifier : 'name', rules: [ { type : 'empty', prompt : 'Пожалуйста, укажите наименование кафедры.' } ] } }, { onSuccess: function() { var name = $('.name').val(); $.post('/?page=departments&task=add&name='+name+'&ajax=true') .done(function(answer) { $('#add_modal').modal('hide'); rude.redirect('/?page=departments');}); return false; } }) ; </script> <div id="edit_modal" class="ui modal"> <i class="close icon"></i> <div class="header"> Редактировать кафедру </div> <div class="content"> <div class="ui form segment"> <div class="field"> <label for="editname">Наименование кафедры</label> <div class="ui left labeled input"> <input class="editname" name="editname" type="text" placeholder="Наименование кафедры"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="field" hidden> <label for="id">id</label> <div class="ui left labeled input"> <input class="id" name="id" type="text" placeholder="id"> <div class="ui corner label"> <i class="icon asterisk"></i> </div> </div> </div> <div class="ui error message"> <div class="header">Найдены ошибки при заполнении формы</div> </div> <div class="ui blue submit button" value="edit">Изменить</div> </div> </div> </div> <script> $('#edit_modal .ui.form') .form({ editname: { identifier : 'editname', rules: [ { type : 'empty', prompt : 'Пожалуйста, укажите наименование кафедры.' } ] } }, { onSuccess: function() { var name = $('.editname').val(); var id = $('.id').val(); $.post('/?page=departments&task=edit&id='+id+'&name='+name+'&ajax=true') .done(function() { $('#edit_modal').modal('hide'); rude.redirect('/?page=departments');}); return false; } }) ; </script> <?php }
if (isset($_REQUEST['dn']) && isset($_REQUEST['did'])) { include_once "department.php"; $dn = $_REQUEST['dn']; $did = $_REQUEST['did']; $obj = new departments(); if (!$obj->edit_department($dn, $did)) { echo '<div id="divStatus" class="error"> Could Not Update Department Information <span class="ti-face-sad" ></span> </div>'; } else { echo '<div id="divStatus" class="success"> Department Information Updated <span class="ti-face-smile" ></span> </div> '; } } break; case 5: include_once 'department.php'; if (isset($_REQUEST["id"])) { $did = intval($_REQUEST['id']); $obj = new departments(); if (!$obj->delete_department($did)) { echo '<div id="divStatus" class="error" onclick=hideStatus()> Could Not Delete <span class="ti-face-sad" ></span></div>'; } else { echo '<div id="divStatus" class="success"> Delete Successful <span class="ti-face-smile" ></span></div> '; } } break; }
function getXMLHttp(){ if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } return xmlhttp; } </script> <?php $did = intval($_REQUEST['id']); include_once 'department.php'; $obj = new departments(); if (!$obj->get_department($did)) { echo 'could not find'; } $row = $obj->fetch(); $dname = $row['department_name']; ?> <form action="" method="post" id="add-form"> <legend> Department Information </legend> <table class="add"> <tr id="add-icon"> <td colspan="2"> <span class="flaticon-hospital14"></span> </td>
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ This File: deptman.php Description: System File ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ if (!defined('PARENT')) { $HEADERS->err403(true); } // Access.. if (!in_array($cmd, $userAccess) && $MSTEAM->id != '1') { $HEADERS->err403(true); } // Class.. include_once PATH . 'control/classes/class.departments.php'; $MSDEPT = new departments(); // Delete departments.. if (isset($_POST['delete']) && USER_DEL_PRIV == 'yes') { $count = $MSDEPT->delete(); $OK1 = true; } // Update order sequence.. if (isset($_POST['update-order'])) { $MSDEPT->order(); $OK2 = true; } $title = $msg_dept9; $loadJQAlertify = true; include PATH . 'templates/header.php'; include PATH . 'templates/system/dept/deptman.php'; include PATH . 'templates/footer.php';
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ This File: dept.php Description: System File ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ if (!defined('PARENT')) { $HEADERS->err403(true); } // Access.. if (!in_array($cmd, $userAccess) && $MSTEAM->id != '1') { $HEADERS->err403(true); } // Class.. include_once PATH . 'control/classes/class.departments.php'; $MSDEPT = new departments(); // Add.. if (isset($_POST['process'])) { if (trim($_POST['name'])) { $MSDEPT->add($MSTEAM->id); $OK1 = true; } } // Update.. if (isset($_POST['update'])) { if (trim($_POST['name'])) { $MSDEPT->update(); $OK2 = true; } } $title = isset($_GET['edit']) ? $msg_dept5 : $msg_dept2;