'.__('You don\'t have enough privileges to view this section').''); } /* RECORD OPERATION */ if (isset($_POST['saveData'])) { $contentTitle = trim(strip_tags($_POST['contentTitle'])); $contentPath = trim(strip_tags($_POST['contentPath'])); // check form validity if (empty($contentTitle) OR empty($contentPath)) { utility::jsAlert(__('Title or Path can\'t be empty!')); exit(); } else { $data['content_title'] = $dbs->escape_string(strip_tags(trim($contentTitle))); $data['content_path'] = strtolower($dbs->escape_string(strip_tags(trim($contentPath)))); if ($_POST['isNews'] && $_POST['isNews'] == '1') { $data['is_news'] = 1; } $data['content_desc'] = $dbs->escape_string(trim($_POST['contentDesc'])); $data['input_date'] = date('Y-m-d H:i:s'); $data['last_update'] = date('Y-m-d H:i:s'); // 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 the data $update = $sql_op->update('content', $data, 'content_id='.$updateRecordID); if ($update) { // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'system', $_SESSION['content_title'].' update content data ('.$data['content_title'].') with contentname ('.$data['contentname'].')'); utility::jsAlert(__('Content data updated')); echo ''; } else { utility::jsAlert(__('Content data FAILED to update!')."\nDEBUG : ".$sql_op->error); } exit(); } else { /* INSERT RECORD MODE */ // insert the data if ($sql_op->insert('content', $data)) { // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'system', $_SESSION['realname'].' add new content ('.$data['content_title'].') with contentname ('.$data['contentname'].')'); utility::jsAlert(__('Content data saved')); echo ''; } else { utility::jsAlert(__('Content data FAILED to save!')."\n".$sql_op->error); } 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']); } // loop array foreach ($_POST['itemID'] as $itemID) { $itemID = (integer)$itemID; // get content data $content_q = $dbs->query('SELECT content_title FROM content WHERE content_id='.$itemID); $content_d = $content_q->fetch_row(); if (!$sql_op->delete('content', "content_id='$itemID'")) { $error_num++; } else { // write log utility::writeLogs($dbs, 'staff', $_SESSION['uid'], 'system', $_SESSION['realname'].' DELETE content ('.$content_d[0].')'); } } // 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 */ /* search form */ ?>
'.__('You don\'t have enough privileges to view this section').''); } /* RECORD FORM */ // try query $itemID = (integer)isset($_POST['itemID'])?$_POST['itemID']:0; $rec_q = $dbs->query('SELECT * FROM content WHERE content_id='.$itemID); $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"'; // edit mode flag set if ($rec_q->num_rows > 0) { $form->edit_mode = true; // record ID for delete process // form record id $form->record_id = $itemID; // form record title $form->record_title = $rec_d['content_title']; // submit button attribute $form->submit_button_attr = 'name="saveData" value="'.__('Update').'" class="btn btn-default"'; } /* Form Element(s) */ // content title $form->addTextField('text', 'contentTitle', __('Content Title').'*', $rec_d['content_title'], 'style="width: 100%;"'); // content news flag $news_chbox[0] = array('0', __('No')); $news_chbox[1] = array('1', __('Yes')); $form->addRadio('isNews', __('This is News'), $news_chbox, $rec_d['is_news']); // content path $form->addTextField('text', 'contentPath', __('Path (Must be unique)').'*', $rec_d['content_path'], 'style="width: 50%;"'); // content description $form->addTextField('textarea', 'contentDesc', __('Content Description'), htmlentities($rec_d['content_desc'], ENT_QUOTES), 'class="texteditor" tyle="width: 100%; height: 500px;"'); // edit mode messagge if ($form->edit_mode) { echo '