require 'path.php'; init_cobalt('Delete service'); if (isset($_GET['service_id'])) { $service_id = urldecode($_GET['service_id']); require_once 'form_data_service.php'; } if (xsrf_guard()) { init_var($_POST['btn_cancel']); init_var($_POST['btn_delete']); require 'components/query_string_standard.php'; if ($_POST['btn_cancel']) { log_action('Pressed cancel button'); redirect("listview_service.php?{$query_string}"); } elseif ($_POST['btn_delete']) { log_action('Pressed delete button'); require_once 'subclasses/service.php'; $dbh_service = new service(); $object_name = 'dbh_service'; require 'components/create_form_data.php'; $dbh_service->delete($arr_form_data); redirect("listview_service.php?{$query_string}"); } } require 'subclasses/service_html.php'; $html = new service_html(); $html->draw_header('Delete Service', $message, $message_type); $html->draw_listview_referrer_info($filter_field_used, $filter_used, $page_from, $filter_sort_asc, $filter_sort_desc); $html->draw_hidden('service_id'); $html->detail_view = TRUE; $html->draw_controls('delete'); $html->draw_footer();
/** DELETE */ function delete($VAR) { $this->invoice_construct(); $dbx = new CORE_database(); $db =& DB(); ### Get the array if (isset($VAR["delete_id"])) { $id = explode(',', $VAR["delete_id"]); } elseif (isset($VAR["id"])) { $id = explode(',', $VAR["id"]); } ### Load the service module include_once PATH_MODULES . 'service/service.inc.php'; $service = new service(); ### Loop: for ($i = 0; $i < count($id); $i++) { ### Loop through all services for this invoice and delete: $q = "SELECT * FROM " . AGILE_DB_PREFIX . "service WHERE\n\t\t\t\t invoice_id = " . $db->qstr($id[$i]) . " AND\n\t\t\t\t site_id = " . $db->qstr(DEFAULT_SITE); $rs = $db->Execute($q); if ($rs === false) { global $C_debug; $C_debug->error('invoice.inc.php', 'delete', $db->ErrorMsg()); return false; } if (@$rs->RecordCount() > 0) { while (!$rs->EOF) { $arr['id'] = $rs->fields['id']; $service->delete($arr, $service); $rs->MoveNext(); } } ### Delete the service record $arr['id'] = $id[$i]; $this->associated_DELETE[] = array('table' => 'invoice_commission', 'field' => 'invoice_id'); $this->associated_DELETE[] = array('table' => 'invoice_item', 'field' => 'invoice_id'); $this->associated_DELETE[] = array('table' => 'invoice_memo', 'field' => 'invoice_id'); $this->associated_DELETE[] = array('table' => 'service', 'field' => 'invoice_id'); $this->associated_DELETE[] = array('table' => 'invoice_item_tax', 'field' => 'invoice_id'); $this->associated_DELETE[] = array('table' => 'invoice_item_discount', 'field' => 'invoice_id'); $dbx->mass_delete($arr, $this, ""); } }
</script> </head> <body> <h2>Service Übersicht</h2> <div style="text-align:right"> <a href="service_details.php?action=new" target="detail_service">Neu</a> </div>'; if (isset($_GET['action']) && $_GET['action'] == 'delete') { if (!$rechte->isBerechtigt('basis/service', null, 'suid')) { die('Sie haben keine Berechtigung fuer diese Seite'); } if (!isset($_GET['service_id'])) { die('Fehlender Parameter ServiceID'); } $service = new service(); if ($service->delete($_GET['service_id'])) { echo '<span class="ok">Eintrag wurde erfolgreich gelöscht</span>'; } else { echo '<span class="error">' . $serivce->errormsg . '</span>'; } } $oe_kurzbz = isset($_GET['oe_kurzbz']) ? $_GET['oe_kurzbz'] : ''; $service = new service(); echo '<form action="' . $_SERVER['PHP_SELF'] . '" method="GET">'; echo 'Organisationseinheit: '; echo '<SELECT name="oe_kurzbz"> <OPTION value="">-- Alle --</OPTION>'; $oe = new organisationseinheit(); $oe->getAll(); foreach ($oe->result as $row) { if ($row->oe_kurzbz == $oe_kurzbz) {