/
contract_delete_contact.php
122 lines (106 loc) · 4.24 KB
/
contract_delete_contact.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
// delete_maintenance_support_contact.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.
//
// Removes an Association between a contact and a maintenance contract
// Author: Ivan Lucas <ivanlucas[at]users.sourceforge.net>
// FIXME i18n
// This Page Is Valid XHTML 1.0 Transitional! 31Oct05
$permission=32; // Edit Supported Products
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
// External variables
$action = $_REQUEST['action'];
$context = cleanvar($_REQUEST['context']);
$maintid =cleanvar($_REQUEST['maintid']);
$contactid = cleanvar($_REQUEST['contactid']);
$title = ("$strContract - $strRemoveASupportedContact");
if (empty($action) OR $action == "showform")
{
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
echo "<h2>{$strRemoveLinkContractAndSupportContact}</h2>";
echo "<p align='center'>{$strRemoveLinkContractAndSupportContactText}</p>";
echo "<form action='{$_SERVER['PHP_SELF']}?action=delete' method='post' onsubmit='return confirm_action(\"{$strAreYouSureDeleteMaintenceContract}\")'>";
echo "<input type='hidden' name='context' value='{$context}' />";
echo "<table align='center' class='vertical'>";
if (empty($maintid))
{
echo "<tr><th>{$strContract} ".icon('contract', 16)."</th>";
echo "<td>";
maintenance_drop_down("maintid", 0);
echo "</td></tr>";
}
else
{
echo "<tr><th>{$strContract} ".icon('contract', 16)."</th>";
echo "<td>$maintid - ".contract_product($maintid)." for ".contract_site($maintid);
echo "<input name=\"maintid\" type=\"hidden\" value=\"$maintid\" /></td></tr>";
}
if (empty($contactid))
{
echo "<tr><th>{$strSupport} {$strContact} ".icon('contact', 16)."</th><td width='400'>";
echo contact_drop_down("contactid", 0)."</td></tr>";
}
else
{
echo "<tr><th>{$strContact} ".icon('contact', 16)."</th><td>{$contactid} - ".contact_realname($contactid);
echo "<input name='contactid' type='hidden' value='$contactid' /></td></tr>";
}
echo "</table>";
echo "<p align='center'><input name='submit' type='submit' value='{$strContinue}' /></p>";
echo "</form>";
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
elseif ($action == "delete")
{
// Delete the chosen support contact
$errors = 0;
// check for blank contact
if ($contactid == 0)
{
$errors = 1;
$errors_string .= user_alert("{$strYouMustSelectAsupportContact}", E_USER_ERROR);
}
// check for blank maintenance id
if ($maintid == 0)
{
$errors = 1;
$errors_string .= user_alert("{$strYouMustSelectAmaintenanceContract}", E_USER_ERROR);
}
// delete maintenance support contact if no errors
if ($errors == 0)
{
$sql = "DELETE FROM `{$dbSupportContacts}` WHERE maintenanceid='$maintid' AND contactid='$contactid'";
$result = mysql_query($sql);
if (mysql_error()) trigger_error("MySQL Query Error ".mysql_error(), E_USER_ERROR);
// show error message if deletion failed
if (!$result)
{
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
trigger_error("Deletion of maintenance support conact failed: {$sql}", E_USER_WARNING);
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
// update db and show success message
else
{
journal(CFG_LOGGING_NORMAL, 'Supported Contact Removed', "Contact $contactid removed from maintenance contract $maintid", CFG_JOURNAL_MAINTENANCED, $maintid);
if ($context == 'maintenance') html_redirect("contract_details.php?id={$maintid}");
else html_redirect("contact_details.php?id={$contactid}");
}
}
else
{
// show error message if errors
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
echo $errors_string;
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
}
?>