<?php //Object Back $objVar = new bVariable(); // Arrays $arrData = array(); // VIEW : Get Data if (!empty($_GET['id'])) { $arrVariable = $objVar->getOne(array("variable_id" => $_GET['id'])); $arrData['variable'] = $arrVariable; } else { //return to list header('Location: list.php?module=' . $module); exit; } ?> <!-- Headers --> <?php include SITE_DIR . '/back/include/header.php'; ?> <!-- Module Content --> <div id="moduleContent" class="wrapper"> <!-- View--> <div id="record"> <?php if (!empty($_GET['action'])) { if ($_GET['action'] == 'update') {
<?php /**************************************************************************/ // AJAX Build List // file called by the dataTables Jquery in list.php to load data /**************************************************************************/ require_once $_SERVER['DOCUMENT_ROOT'] . '/include/config.php'; $objVariable = new bVariable(); $arrVariable = $objVariable->get(); $module = $_GET['module']; $output['aaData'] = array(); foreach ($arrVariable as $key => $data) { $row = array(); // O => hidden ID $row[] = $data['variable_id']; // 1 => Actions (view, update..) $action_view = '<a href="view.php?module=' . $module . '&id=' . $data['variable_id'] . '"><img alt="view" title="View" src="theme/img/view.gif" /></a>'; $action_update = '<a href="form.php?module=' . $module . '&id=' . $data['variable_id'] . '"><img alt="update" title="Update" src="theme/img/update.gif" /></a>'; $action_delete = '<a href="module/' . $module . '/ajax/delete.php?module=' . $module . '&id=' . $data['variable_id'] . '" class="ajaxDeleteRow" title="delete-row"><img alt="delete" title="Delete" src="theme/img/delete.gif" /></a>'; $row[] = '<span class="iconAction">' . $action_view . $action_update . $action_delete . '</span>'; // 2 => Name $row[] = $data['variable_name']; // 3 => Value $row[] = $data['variable_value']; $output['aaData'][] = $row; } echo json_encode($output); ?>
<?php //Object Back $objVariable = new bVariable(); // Arrays $arrData = array(); $arrErrors = array(); //POST if (!empty($_POST)) { $action = ""; $return = false; // GET POST $arrData = $_POST; $id = $arrData['content_id']; //ADD Variables $arrData['variable_id'] = $_POST['content_id']; if (empty($arrErrors)) { try { if (empty($arrData['variable_id'])) { //add $objVariable->add($arrData); $action = "create"; $return = false; } else { //update $objVariable->update($arrData); $action = "update"; } header('Location: view.php?module=' . $module . '&id=' . $id . '&action=' . $action); exit; } catch (Exception $e) {
<?php /**************************************************************************/ // AJAX Delete // PARAMS $_GET : LINK in LIST /**************************************************************************/ require_once $_SERVER['DOCUMENT_ROOT'] . '/include/config.php'; $return = 'false'; $message = ''; if (!empty($_GET['id'])) { $obj = new bVariable(); $contentID = $_GET['id']; $arrContent = $obj->getOne(array("variable_id" => $_GET['id'])); if (!empty($arrContent)) { $obj->delete(array("variable_id" => $_GET['id'])); $message = "Variable " . $arrContent['variable_name'] . " deleted"; $return = 'true'; } else { $message = 'Content already deleted.'; } } else { $message = 'Error deleting, please try again.'; } echo $return . "|" . $message;