$debet) { utility::jsAlert(''.__('Value of Credit can not be higher that Debet Value').''); } else { $data['member_id'] = $_SESSION['memberID']; $data['fines_date'] = trim($dbs->escape_string(strip_tags($_POST['finesDate']))); $data['description'] = trim($dbs->escape_string(strip_tags($_POST['finesDesc']))); $data['debet'] = $debet; $data['credit'] = $credit; $sql_op = new simbio_dbop($dbs); if (isset($_POST['updateRecordID'])) { /* UPDATE RECORD MODE */ // remove input date unset($data['input_date']); // filter update record ID $updateRecordID = (integer)$_POST['updateRecordID']; // update the data $update = $sql_op->update('fines', $data, 'fines_id='.$updateRecordID); if ($update) { utility::jsAlert(__('Fines Data Successfully Updated')); } else { utility::jsAlert(__('Fines Data FAILED to Updated. Please Contact System Administrator')."\nDEBUG : ".$sql_op->error); } } else { /* INSERT RECORD MODE */ // insert the data $insert = $sql_op->insert('fines', $data); if ($insert) { utility::jsAlert(__('New Fines Data Successfully Saved')); } else { utility::jsAlert(__('Fines Data FAILED to Save. Please Contact System Administrator')."\n".$sql_op->error); } } } } else if ($_SESSION['uid'] == 1 && isset($_POST['itemID']) && !empty($_POST['itemID']) && isset($_POST['itemAction'])) { // only admin can delete if (!($can_read AND $can_write)) { die(); } /* DATA DELETION PROCESS */ $sql_op = new simbio_dbop($dbs); $failed_array = array(); $error_num = 0; if (!is_array($_POST['itemID'])) { // make an array $_POST['itemID'] = array((integer)$_POST['itemID']); } // loop array foreach ($_POST['itemID'] as $itemID) { $itemID = (integer)$itemID; if (!$sql_op->delete('fines', 'fines_id='.$itemID)) { $error_num++; } } // error alerting if ($error_num == 0) { utility::jsAlert('Fines data succesfully deleted!'); } else { utility::jsAlert('Fines data FAILED to delete!'); } } /* RECORD OPERATION END */ /* header */ ?>
query('SELECT * FROM fines WHERE fines_id='.$itemID); $rec_d = $rec_q->fetch_assoc(); // create new instance $form = new simbio_form_table('mainForm', $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'], 'post'); $form->submit_button_attr = 'name="saveData" value="'.__('Save').'" class="button"'; // form table attributes $form->table_attr = 'align="center" id="dataList" style="width: 100%;" cellpadding="5" cellspacing="0"'; $form->table_header_attr = 'class="alterCell" style="font-weight: bold;"'; $form->table_content_attr = 'class="alterCell2"'; // edit mode flag set if ($rec_q->num_rows > 0) { $form->edit_mode = true; // record ID for delete process $form->record_id = $itemID; // delete button only showed for admin user if ($_SESSION['uid'] != 1) { $form->delete_button = false; } // form record title $form->record_title = 'Fines Detail'; // submit button attribute $form->submit_button_attr = 'name="saveData" value="'.__('Update').'" class="button"'; } /* Form Element(s) */ // fines dates $form->addDateField('finesDate', __('Fines Date'), $rec_d['fines_date']); // fines description $form->addTextField('text', 'finesDesc', __('Description/Name').'*', $rec_d['description'], 'style="width: 60%;"'); // fines debet $form->addTextField('text', 'debet', __('Debit').'*', !empty($rec_d['debet'])?$rec_d['debet']:'0', 'style="width: 60%;"'); // fines credit $form->addTextField('text', 'credit', __('Credit'), !empty($rec_d['credit'])?$rec_d['credit']:'0', 'style="width: 60%;"'); // edit mode messagge if ($form->edit_mode) { echo '