'.__('You are not authorized to view this section').''); } $in_pop_up = false; // check if we are inside pop-up window if (isset($_GET['inPopUp'])) { $in_pop_up = true; } /* REMOVE IMAGE */ if (isset($_POST['removeImage']) && isset($_POST['bimg']) && isset($_POST['img'])) { $_delete = $dbs->query(sprintf('UPDATE biblio SET image=NULL WHERE biblio_id=%d', $_POST['bimg'])); $_delete2 = $dbs->query(sprintf('UPDATE search_biblio SET image=NULL WHERE biblio_id=%d', $_POST['bimg'])); if ($_delete) { @unlink(sprintf(IMGBS.'docs/%s',$_POST['img'])); exit(''); } exit(); } /* RECORD OPERATION */ if (isset($_POST['saveData']) AND $can_read AND $can_write) { $title = trim(strip_tags($_POST['title'])); // check form validity if (empty($title)) { utility::jsAlert(__('Title can not be empty')); exit(); } else { // include custom fields file if (file_exists(MDLBS.'karya_ilmiah/custom_fields.inc.php')) { include MDLBS.'karya_ilmiah/custom_fields.inc.php'; } // create biblio_indexer class instance $indexer = new biblio_indexer($dbs); /** * Custom fields */ if (isset($biblio_custom_fields)) { if (is_array($biblio_custom_fields) && $biblio_custom_fields) { foreach ($biblio_custom_fields as $fid => $cfield) { // custom field data $cf_dbfield = $cfield['dbfield']; if (isset($_POST[$cf_dbfield])) { $cf_val = $dbs->escape_string(strip_tags(trim($_POST[$cf_dbfield]), $sysconf['content']['allowable_tags'])); if ($cf_val) { $custom_data[$cf_dbfield] = $cf_val; } else { $custom_data[$cf_dbfield] = 'literal{\'\'}'; } } } } } $data['title'] = $dbs->escape_string($title); /* modified by hendro */ $data['sor'] = trim($dbs->escape_string(strip_tags($_POST['sor']))); /* end of modification */ $data['edition'] = trim($dbs->escape_string(strip_tags($_POST['edition']))); $data['gmd_id'] = $_POST['gmdID']; $data['isbn_issn'] = trim($dbs->escape_string(strip_tags($_POST['isbn_issn']))); $class = str_ireplace('NEW:', '', trim(strip_tags($_POST['class']))); $data['classification'] = trim($dbs->escape_string(strip_tags($class))); // check publisher // echo stripos($_POST['publisherID'], 'NEW:'); if (stripos($_POST['publisherID'], 'NEW:') === 0) { $new_publisher = str_ireplace('NEW:', '', trim(strip_tags($_POST['publisherID']))); $new_id = utility::getID($dbs, 'mst_publisher', 'publisher_id', 'publisher_name', $new_publisher); $data['publisher_id'] = $new_id; } else { $data['publisher_id'] = intval($_POST['publisherID']); } $data['publish_year'] = trim($dbs->escape_string(strip_tags($_POST['year']))); $data['collation'] = trim($dbs->escape_string(strip_tags($_POST['collation']))); $data['series_title'] = trim($dbs->escape_string(strip_tags($_POST['seriesTitle']))); $data['call_number'] = trim($dbs->escape_string(strip_tags($_POST['callNumber']))); $data['language_id'] = trim($dbs->escape_string(strip_tags($_POST['languageID']))); // check place if (stripos($_POST['placeID'], 'NEW:') === 0) { $new_place = str_ireplace('NEW:', '', trim(strip_tags($_POST['placeID']))); $new_id = utility::getID($dbs, 'mst_place', 'place_id', 'place_name', $new_place); $data['publish_place_id'] = $new_id; } else { $data['publish_place_id'] = intval($_POST['placeID']); } $data['notes'] = trim($dbs->escape_string(strip_tags($_POST['notes'], '

s'))); //~ $data['opac_hide'] = ($_POST['opacHide'] == '0')?'literal{0}':'1'; $data['opac_hide'] = 0; $data['promoted'] = ($_POST['promote'] == '0')?'literal{0}':'1'; // labels $arr_label = array(); if ($_POST['labels']) { foreach ($_POST['labels'] as $label) { if (trim($label) != '') { $arr_label[] = array($label, isset($_POST['label_urls'][$label])?$_POST['label_urls'][$label]:null ); } } } $data['labels'] = $arr_label?serialize($arr_label):'literal{NULL}'; $data['frequency_id'] = ($_POST['frequencyID'] == '0')?'literal{0}':(integer)$_POST['frequencyID']; $data['spec_detail_info'] = trim($dbs->escape_string(strip_tags($_POST['specDetailInfo']))); $data['input_date'] = date('Y-m-d H:i:s'); $data['last_update'] = date('Y-m-d H:i:s'); // image uploading if (!empty($_FILES['image']) AND $_FILES['image']['size']) { // create upload object $image_upload = new simbio_file_upload(); $image_upload->setAllowableFormat($sysconf['allowed_images']); $image_upload->setMaxSize($sysconf['max_image_upload']*1024); $image_upload->setUploadDir(IMGBS.'docs'); // upload the file and change all space characters to underscore $img_upload_status = $image_upload->doUpload('image', preg_replace('@\s+@i', '_', $_FILES['image']['name'])); if ($img_upload_status == UPLOAD_SUCCESS) { $data['image'] = $dbs->escape_string($image_upload->new_filename); // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'].' upload image file '.$image_upload->new_filename); utility::jsAlert(__('Image Uploaded Successfully')); } else { // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', 'ERROR : '.$_SESSION['realname'].' FAILED TO upload image file '.$image_upload->new_filename.', with error ('.$image_upload->error.')'); utility::jsAlert(__('Image Uploaded Failed')); } } else if (!empty($_POST['base64picstring'])) { list($filedata, $filedom) = explode('#image/type#', $_POST['base64picstring']); $filedata = base64_decode($filedata); $fileinfo = getimagesizefromstring($filedata); $valid = strlen($filedata)/1024 < $sysconf['max_image_upload']; $valid = (!$fileinfo || $valid === false) ? false : in_array($fileinfo['mime'], $sysconf['allowed_images_mimetype']); $new_filename = strtolower('cover_' .preg_replace("/[^a-zA-Z0-9]+/", "_", $data['title']) .'.'.$filedom); if ($valid AND file_put_contents(IMGBS.'docs/'.$new_filename, $filedata)) { $data['image'] = $dbs->escape_string($new_filename); if (!defined('UPLOAD_SUCCESS')) define('UPLOAD_SUCCESS', 1); $upload_status = UPLOAD_SUCCESS; } } // create sql op object $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 data $update = $sql_op->update('biblio', $data, 'biblio_id='.$updateRecordID); // send an alert if ($update) { // update custom data if (isset($custom_data)) { // check if custom data for this record exists $_sql_check_custom_q = sprintf('SELECT biblio_id FROM biblio_custom WHERE biblio_id=%d', $updateRecordID); $check_custom_q = $dbs->query($_sql_check_custom_q); if ($check_custom_q->num_rows) { $update2 = @$sql_op->update('biblio_custom', $custom_data, 'biblio_id='.$updateRecordID); } else { $custom_data['biblio_id'] = $updateRecordID; @$sql_op->insert('biblio_custom', $custom_data); } } if ($sysconf['bibliography_update_notification']) { utility::jsAlert(__('Dissertations/Thesis Data Successfully Updated')); } // auto insert catalog to UCS if enabled if ($sysconf['ucs']['enable']) { echo ''; } // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'].' update bibliographic data ('.$data['title'].') with biblio_id ('.$_POST['itemID'].')'); // close window OR redirect main page if ($in_pop_up) { $itemCollID = (integer)$_POST['itemCollID']; echo ''; echo ''; } else { echo ''; } // update index // delete from index first $sql_op->delete('search_biblio', "biblio_id=$updateRecordID"); $indexer->makeIndex($updateRecordID); } else { utility::jsAlert(__('Bibliography Data FAILED to Updated. Please Contact System Administrator')."\n".$sql_op->error); } } else { /* INSERT RECORD MODE */ // insert the data $insert = $sql_op->insert('biblio', $data); if ($insert) { // get auto id of this record $last_biblio_id = $sql_op->insert_id; // add authors if ($_SESSION['biblioAuthor']) { foreach ($_SESSION['biblioAuthor'] as $author) { $sql_op->insert('biblio_author', array('biblio_id' => $last_biblio_id, 'author_id' => $author[0], 'level' => $author[1])); } } // add topics if ($_SESSION['biblioTopic']) { foreach ($_SESSION['biblioTopic'] as $topic) { $sql_op->insert('biblio_topic', array('biblio_id' => $last_biblio_id, 'topic_id' => $topic[0], 'level' => $topic[1])); } } // add attachment if ($_SESSION['biblioAttach']) { foreach ($_SESSION['biblioAttach'] as $attachment) { $sql_op->insert('biblio_attachment', array('biblio_id' => $last_biblio_id, 'file_id' => $attachment['file_id'], 'access_type' => $attachment['access_type'])); } } // insert custom data if ($custom_data) { $custom_data['biblio_id'] = $last_biblio_id; @$sql_op->insert('biblio_custom', $custom_data); } utility::jsAlert(__('New Dissertations/Thesis Data Successfully Saved')); // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'].' insert bibliographic data ('.$data['title'].') with biblio_id ('.$last_biblio_id.')'); // clear related sessions $_SESSION['biblioAuthor'] = array(); $_SESSION['biblioTopic'] = array(); $_SESSION['biblioAttach'] = array(); // update index $indexer->makeIndex($last_biblio_id); // auto insert catalog to UCS if enabled if ($sysconf['ucs']['enable'] && $sysconf['ucs']['auto_insert']) { echo ''; } } else { utility::jsAlert(__('Bibliography Data FAILED to Save. Please Contact System Administrator')."\n".$sql_op->error); } } // item batch insert if (trim($_POST['itemCodePattern']) != '' && $_POST['itemCodeStart'] > 0 && $_POST['itemCodeEnd'] > 0) { $hasil = array(); $pattern = trim($_POST['itemCodePattern']); // get last zero chars preg_match('@0+$@i', $pattern, $hasil); $zeros = strlen($hasil[0]); $start = (integer)$_POST['itemCodeStart']; $end = (integer)$_POST['itemCodeEnd']; for ($b = $start; $b <= $end; $b++) { $len = strlen($b); if ($zeros > 0) { $itemcode = preg_replace('@0{'.$len.'}$@i', $b, $pattern); } else { $itemcode = $pattern.$b; } $item_insert_sql = sprintf("INSERT IGNORE INTO item (biblio_id, item_code, call_number, coll_type_id) VALUES (%d, '%s', '%s', %d)", $updateRecordID?$updateRecordID:$last_biblio_id, $itemcode, $data['call_number'], $_POST['collTypeID']); @$dbs->query($item_insert_sql); } } 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 */ // create sql op object $sql_op = new simbio_dbop($dbs); $failed_array = array(); $error_num = 0; $still_have_item = array(); if (!is_array($_POST['itemID'])) { // make an array $_POST['itemID'] = array((integer)$_POST['itemID']); } // loop array $http_query = ''; foreach ($_POST['itemID'] as $itemID) { $itemID = (integer)$itemID; // check if this biblio data still have an item $_sql_biblio_item_q = sprintf('SELECT b.title, COUNT(item_id) FROM biblio AS b LEFT JOIN item AS i ON b.biblio_id=i.biblio_id WHERE b.biblio_id=%d GROUP BY title', $itemID); $biblio_item_q = $dbs->query($_sql_biblio_item_q); $biblio_item_d = $biblio_item_q->fetch_row(); if ($biblio_item_d[1] < 1) { if (!$sql_op->delete('biblio', "biblio_id=$itemID")) { $error_num++; } else { // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'bibliography', $_SESSION['realname'].' DELETE bibliographic data ('.$biblio_item_d[0].') with biblio_id ('.$itemID.')'); // delete related data $sql_op->delete('biblio_topic', "biblio_id=$itemID"); $sql_op->delete('biblio_author', "biblio_id=$itemID"); $sql_op->delete('biblio_attachment', "biblio_id=$itemID"); $sql_op->delete('search_biblio', "biblio_id=$itemID"); // add to http query for UCS delete $http_query .= "itemID[]=$itemID&"; } } else { $still_have_item[] = substr($biblio_item_d[0], 0, 45).'... still have '.$biblio_item_d[1].' copies'; $error_num++; } } if ($still_have_item) { $titles = ''; foreach ($still_have_item as $title) { $titles .= $title."\n"; } utility::jsAlert(__('Below data can not be deleted:')."\n".$titles); echo ''; exit(); } // auto delete data on UCS if enabled if ($http_query && $sysconf['ucs']['enable'] && $sysconf['ucs']['auto_delete']) { echo ''; } // error alerting if ($error_num == 0) { utility::jsAlert(__('All Data Successfully Deleted')); echo ''; } else { utility::jsAlert(__('Some or All Data NOT deleted successfully!\nPlease contact system administrator')); echo ''; } exit(); } /* RECORD OPERATION END */ if (!$in_pop_up) { /* search form */ ?> '.__('You are not authorized to view this section').'
'); } /* RECORD FORM */ // try query $itemID = (integer)isset($_POST['itemID'])?$_POST['itemID']:0; $_sql_rec_q = sprintf('SELECT b.*, p.publisher_name, pl.place_name FROM biblio AS b LEFT JOIN mst_publisher AS p ON b.publisher_id=p.publisher_id LEFT JOIN mst_place AS pl ON b.publish_place_id=pl.place_id WHERE biblio_id=%d', $itemID); $rec_q = $dbs->query($_sql_rec_q); $rec_d = $rec_q->fetch_assoc(); // create new instance $form = new simbio_form_table_AJAX('mainForm', $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'], 'post'); $form->submit_button_attr = 'name="saveData" value="'.__('Save').'" class="btn btn-default"'; // form table attributes $form->table_attr = 'align="center" id="dataList" cellpadding="5" cellspacing="0"'; $form->table_header_attr = 'class="alterCell" style="font-weight: bold;"'; $form->table_content_attr = 'class="alterCell2"'; $visibility = 'makeVisible'; // edit mode flag set if ($rec_q->num_rows > 0) { $form->edit_mode = true; // record ID for delete process if (!$in_pop_up) { // form record id $form->record_id = $itemID; } else { $form->addHidden('updateRecordID', $itemID); $form->addHidden('itemCollID', $_POST['itemCollID']); $form->back_button = false; } // form record title $form->record_title = $rec_d['title']; // submit button attribute $form->submit_button_attr = 'name="saveData" value="'.__('Update').'" class="btn btn-default"'; // element visibility class toogle $visibility = 'makeHidden'; // custom field data query $_sql_rec_cust_q = sprintf('SELECT * FROM biblio_custom WHERE biblio_id=%d', $itemID); $rec_cust_q = $dbs->query($_sql_rec_cust_q); $rec_cust_d = $rec_cust_q->fetch_assoc(); } // include custom fields file if (file_exists(MDLBS.'karya_ilmiah/custom_fields.inc.php')) { include MDLBS.'karya_ilmiah/custom_fields.inc.php'; } /* Form Element(s) */ // biblio title $form->addTextField('textarea', 'title', __('Title').'*', $rec_d['title'], 'rows="1" style="width: 100%; overflow: auto;"', __('Main title of collection. Separate child title with colon and pararel title with equal (=) sign.')); // biblio note $form->addTextField('textarea', 'notes', __('Abstract/Notes'), $rec_d['notes'], 'style="width: 100%;" rows="2"', __('Insert here any abstract or notes from the publication.')); // biblio cover image $str_input = ''; if ($rec_d['image']) { $str_input = ''; } $str_input .= simbio_form_element::textField('file', 'image'); $str_input .= ' Maximum '.$sysconf['max_image_upload'].' KB'; if ($sysconf['scanner'] !== false) { $str_input .= '

'.__('or scan a cover').'

'; $str_input .= ''; if ($sysconf['scanner'] == 'html5') { $str_input .= ''; $str_input .= ''; $str_input .= ''; } } $form->addAnything(__('Image'), $str_input); // biblio file attachment // $str_input = ''; $str_input = ''; $str_input .= ''; $form->addAnything(__('File Attachment'), $str_input); /** * Custom fields */ if (isset($biblio_custom_fields)) { if (is_array($biblio_custom_fields) && $biblio_custom_fields) { foreach ($biblio_custom_fields as $fid => $cfield) { // custom field properties $cf_dbfield = $cfield['dbfield']; $cf_label = $cfield['label']; $cf_default = $cfield['default']; $cf_data = (isset($cfield['data']) && $cfield['data'])?$cfield['data']:array(); // custom field processing if (in_array($cfield['type'], array('text', 'longtext', 'numeric'))) { $cf_max = isset($cfield['max'])?$cfield['max']:'200'; $cf_width = isset($cfield['width'])?$cfield['width']:'50'; $form->addTextField( ($cfield['type'] == 'longtext')?'textarea':'text', $cf_dbfield, $cf_label, isset($rec_cust_d[$cf_dbfield])?$rec_cust_d[$cf_dbfield]:$cf_default, 'style="width: '.$cf_width.'%;" maxlength="'.$cf_max.'"'); } else if ($cfield['type'] == 'dropdown') { $form->addSelectList($cf_dbfield, $cf_label, $cf_data, isset($rec_cust_d[$cf_dbfield])?$rec_cust_d[$cf_dbfield]:$cf_default); } else if ($cfield['type'] == 'checklist') { $form->addCheckBox($cf_dbfield, $cf_label, $cf_data, isset($rec_cust_d[$cf_dbfield])?$rec_cust_d[$cf_dbfield]:$cf_default); } else if ($cfield['type'] == 'choice') { $form->addRadio($cf_dbfield, $cf_label, $cf_data, isset($rec_cust_d[$cf_dbfield])?$rec_cust_d[$cf_dbfield]:$cf_default); } else if ($cfield['type'] == 'date') { $form->addDateField($cf_dbfield, $cf_label, isset($rec_cust_d[$cf_dbfield])?$rec_cust_d[$cf_dbfield]:$cf_default); } } } } // edit mode messagge if ($form->edit_mode) { echo '
' .'
'.__('You are going to edit Dissertations data').' : '.$rec_d['title'].'
'.__('Last Updated').' '. $rec_d['last_update'].'
'; //mfc if ($rec_d['image']) { if (file_exists(IMGBS.'docs/'.$rec_d['image'])) { $upper_dir = ''; if ($in_pop_up) { $upper_dir = '../../'; } echo '
'; } } echo '
'."\n"; } // print out the form object echo $form->printOut(); // javascript ?>