'.__('You are not authorized to view this section').''); } // page title $page_title = 'Subscription List'; $biblioID = 0; if (isset($_GET['biblioID'])) { $biblioID = (integer)$_GET['biblioID']; } if (isset($_POST['biblioID'])) { $biblioID = (integer)$_POST['biblioID']; } /* RECORD OPERATION */ if (isset($_POST['saveData'])) { $dateStart = trim($dbs->escape_string(strip_tags($_POST['dateStart']))); // $dateEnd = trim($dbs->escape_string(strip_tags($_POST['dateEnd']))); $period = trim($dbs->escape_string(strip_tags($_POST['period']))); // check form validity if (!$period OR !$dateStart) { utility::jsAlert(__('Error inserting subscription data, Subscription Date must be filled!')); } else { $data['biblio_id'] = $biblioID; $data['date_start'] = $dateStart; // $data['date_end'] = $dateEnd; $data['period'] = $period; $data['notes'] = trim($_POST['notes'])==''?'literal{NULL}':trim($dbs->escape_string(strip_tags($_POST['notes']))); $data['input_date'] = date('Y-m-d'); $data['last_update'] = date('Y-m-d'); $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('serial', $data, 'serial_id='.$updateRecordID); if ($update) { utility::jsAlert(__('Subscription Data Successfully Updated')); utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'serial_control', $_SESSION['realname'].' update subcription('.$updateRecordID.') '.$period); } else { utility::jsAlert(__('Subscription Data FAILED to Updated. Please Contact System Administrator')."\nDEBUG : ".$sql_op->error); } echo ''; exit(); } else { /* INSERT RECORD MODE */ // insert the data $insert = $sql_op->insert('serial', $data); $serial_id = $sql_op->insert_id; if ($insert) { $exemplar = (integer)$_POST['exemplar']; // generate kardex entry $serial = new serial($dbs, $serial_id); $serial->generateKardexes($exemplar, true); // alert utility::jsAlert(__('New Subscription Data Successfully Saved')); utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'serial_control', $_SESSION['realname'].' add new subcription('.$sql_op->insert_id.') '.$period); } else { utility::jsAlert(__('Subscription Data FAILED to Save. Please Contact System Administrator')."\n".$sql_op->error); } echo ''; exit(); } } exit(); } else if (isset($_POST['itemID']) AND !empty($_POST['itemID']) AND isset($_POST['itemAction'])) { 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']); } // get biblio ID for this subcription $biblio_q = $dbs->query('SELECT biblio_id FROM serial WHERE serial_id='.( isset($_POST['itemID'][0])?$_POST['itemID'][0]:'0' ).' LIMIT 1'); $biblio_d = $biblio_q->fetch_row(); $biblioID = $biblio_d[0]; // loop array foreach ($_POST['itemID'] as $itemID) { $itemID = (integer)$itemID; if (!$sql_op->delete('serial', 'serial_id='.$itemID)) { $error_num++; } else { // also delete kardex data $sql_op->delete('kardex', 'serial_id='.$itemID); } } // error alerting if ($error_num == 0) { utility::jsAlert(__('Subscription data successfully deleted')); } else { utility::jsAlert(__('Subscription data FAILED to deleted!')); } } /* RECORD OPERATION END */ // start the output buffering ob_start(); /* main content */ if ($can_write AND ( isset($_POST['detail']) OR (isset($_GET['detail']) AND $_GET['detail'] == 'true') )) { /* RECORD FORM */ $biblioID = (integer)isset($_GET['biblioID'])?$_GET['biblioID']:0; $itemID = (integer)isset($_GET['itemID'])?$_GET['itemID']:0; $rec_q = $dbs->query('SELECT * FROM serial WHERE biblio_id='.$biblioID.' AND serial_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; // form record title $form->record_title = $rec_d['period']; // submit button attribute $form->submit_button_attr = 'name="saveData" value="'.__('Update').'" class="button"'; } /* Form Element(s) */ // serial date start $form->addDateField('dateStart', __('Subscription Start').'*', $rec_d['date_start']); if (!$form->edit_mode) { // serial exemplar $form->addTextField('text', 'exemplar', __('Total Exemplar Expected').'*', '1'); } // serial periode name $form->addTextField('text', 'period', __('Period Name').'*', $rec_d['period'], 'style="width: 100%;"'); // serial notes $form->addTextField('textarea', 'notes', __('Subscription Notes'), $rec_d['notes'], 'style="width: 100%;" rows="3"'); // serial gmd // get gmd data related to this record from database $gmd_q = $dbs->query('SELECT gmd_id, gmd_name FROM mst_gmd'); $gmd_options = array(); while ($gmd_d = $gmd_q->fetch_row()) { $gmd_options[] = array($gmd_d[0], $gmd_d[1]); } $form->addSelectList('gmdID', __('GMD'), $gmd_options, $rec_d['gmd_id']); // serial biblio ID $form->addHidden('biblioID', $biblioID); // edit mode messagge if ($form->edit_mode) { echo '