/
product_delete.php
67 lines (57 loc) · 2.29 KB
/
product_delete.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
// delete_product.php
//
// SiT (Support Incident Tracker) - Support call tracking system
// Copyright (C) 2000-2009 Salford Software Ltd. and Contributors
//
// This software may be used and distributed according to the terms
// of the GNU General Public License, incorporated herein by reference.
//
// Author: Ivan Lucas <ivanlucas[at]users.sourceforge.net>
// Removes a product
$permission = 65; // Delete products
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
// External variables
$productid = cleanvar($_REQUEST['id']);
if (!empty($productid))
{
$errors = 0;
// Check there are no contracts with this product
$sql = "SELECT id FROM `{$dbMaintenance}` WHERE product={$productid} LIMIT 1";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) >= 1) $errors++;
// check there are no incidents with this product
$sql = "SELECT id FROM `{$dbIncidents}` WHERE product={$productid} LIMIT 1";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) >= 1) $errors++;
// Check there is no software linked to this product
$sql = "SELECT productid FROM `{$dbSoftwareProducts}` WHERE productid={$productid} LIMIT 1";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_WARNING);
if (mysql_num_rows($result) >= 1) $errors++;
if ($errors == 0)
{
$sql = "DELETE FROM `{$dbProducts}` WHERE id = $productid LIMIT 1";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(),E_USER_ERROR);
journal(CFG_LOGGING_NORMAL, 'Product Removed', "Product $productid was removed", CFG_JOURNAL_PRODUCTS, $productid);
html_redirect("products.php");
}
else
{
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
echo "<p class='error'>{$strSorryProductCantBeDeteled}</p>";
echo "<p align='center'><a href='products.php#{$productid}'>{$strReturnToProductList}</a></p>";
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
}
else
{
trigger_error($strInvalidParameter, E_USER_ERROR);
}
?>