00001 <?php 00002 // delete_product.php 00003 // 00004 // SiT (Support Incident Tracker) - Support call tracking system 00005 // Copyright (C) 2010-2011 The Support Incident Tracker Project 00006 // Copyright (C) 2000-2009 Salford Software Ltd. and Contributors 00007 // 00008 // This software may be used and distributed according to the terms 00009 // of the GNU General Public License, incorporated herein by reference. 00010 // 00011 00012 // Author: Ivan Lucas <ivanlucas[at]users.sourceforge.net> 00013 00014 // Removes a product 00015 00016 00017 $permission = 65; // Delete products 00018 require ('core.php'); 00019 require (APPLICATION_LIBPATH . 'functions.inc.php'); 00020 00021 // This page requires authentication 00022 require (APPLICATION_LIBPATH . 'auth.inc.php'); 00023 00024 // External variables 00025 $productid = clean_int($_REQUEST['id']); 00026 00027 if (!empty($productid)) 00028 { 00029 $errors = 0; 00030 // Check there are no contracts with this product 00031 $sql = "SELECT id FROM `{$dbMaintenance}` WHERE product={$productid} LIMIT 1"; 00032 $result = mysql_query($sql); 00033 if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING); 00034 if (mysql_num_rows($result) >= 1) $errors++; 00035 00036 // check there are no incidents with this product 00037 $sql = "SELECT id FROM `{$dbIncidents}` WHERE product={$productid} LIMIT 1"; 00038 $result = mysql_query($sql); 00039 if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING); 00040 if (mysql_num_rows($result) >= 1) $errors++; 00041 00042 // Check there is no software linked to this product 00043 $sql = "SELECT productid FROM `{$dbSoftwareProducts}` WHERE productid={$productid} LIMIT 1"; 00044 $result = mysql_query($sql); 00045 if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING); 00046 if (mysql_num_rows($result) >= 1) $errors++; 00047 00048 if ($errors == 0) 00049 { 00050 $sql = "DELETE FROM `{$dbProducts}` WHERE id = $productid LIMIT 1"; 00051 $result = mysql_query($sql); 00052 if (mysql_error()) trigger_error(mysql_error(),E_USER_ERROR); 00053 journal(CFG_LOGGING_NORMAL, 'Product Removed', "Product $productid was removed", CFG_JOURNAL_PRODUCTS, $productid); 00054 html_redirect("products.php"); 00055 } 00056 else 00057 { 00058 include (APPLICATION_INCPATH . 'htmlheader.inc.php'); 00059 echo "<p class='error'>{$strSorryProductCantBeDeleted}</p>"; 00060 echo "<p align='center'><a href='products.php#{$productid}'>{$strReturnToProductList}</a></p>"; 00061 include (APPLICATION_INCPATH . 'htmlfooter.inc.php'); 00062 } 00063 } 00064 else 00065 { 00066 trigger_error($strInvalidParameter, E_USER_ERROR); 00067 } 00068 ?>
For more help developing with SiT! see http://sitracker.org/wiki/DevelopmentHowTo