/
report_customer_contracts.php
131 lines (121 loc) · 5.43 KB
/
report_customer_contracts.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
123
124
125
126
127
128
129
130
131
<?php
// supportbycontract.php - Shows sites and their contracts
//
// 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
// Email: ivanlucas[at]users.sourceforge.net
// Comments: List supported contacts by contract
$permission = 19; /* View Maintenance Contracts */
$title = $strSupportedContactsbySite;
require ('core.php');
require (APPLICATION_LIBPATH . 'functions.inc.php');
// This page requires authentication
require (APPLICATION_LIBPATH . 'auth.inc.php');
$siteid = cleanvar($_REQUEST['siteid']);
if ($_REQUEST['mode'] == 'csv')
{
// --- CSV File HTTP Header
header("Content-type: text/csv\r\n");
header("Content-disposition-type: attachment\r\n");
header("Content-disposition: filename=supported_contacts_by_contract.csv");
}
else
{
include (APPLICATION_INCPATH . 'htmlheader.inc.php');
}
$sql = "SELECT *, s.name AS sitename FROM `{$dbSites}` AS s ";
if (!empty($_REQUEST['siteid'])) $sql .= "WHERE id='{$siteid}'";
else $sql .= "ORDER BY s.name";
$result = mysql_query($sql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
while ($site = mysql_fetch_object($result))
{
$msql = "SELECT m.id AS maintid, m.term AS term, p.name AS product, r.name AS reseller, ";
$msql .= "licence_quantity, l.name AS licence_type, expirydate, admincontact, c.forenames AS admincontactsforenames, ";
$msql .= "c.surname AS admincontactssurname, m.notes AS maintnotes ";
$msql .= "FROM `{$dbMaintenance}` AS m, `{$dbContacts}` AS c, `{$dbProducts}` AS p, `{$dbLicenceTypes}` AS l, `{$dbResellers}` AS r ";
$msql .= "WHERE m.product=p.id ";
$msql .= "AND m.reseller=r.id AND licence_type=l.id AND admincontact=c.id ";
$msql .= "AND m.site = '{$site->id}' ";
// $msql .= "AND p.vendorid=2 "; // novell products only
$msql .= "AND m.term!='yes' ";
$msql .= "AND m.expirydate > '$now' "; $msql .= "ORDER BY expirydate DESC";
echo "\n<!-- $msql -->\n";
$mresult = mysql_query($msql);
if (mysql_num_rows($mresult)>=1)
{
if ($_REQUEST['mode'] == 'csv')
{
echo "{$site->sitename}\n";
echo "{$strProduct},{$strLicense},{$strExpiryDate},{$strEngineer} 1, {$strEngineer} 2, {$strEngineer} 3, {$strEngineer} 4\n";
while ($maint = mysql_fetch_object($mresult))
{
if ($maint->expirydate > $now AND $maint->term != 'yes')
{
echo "{$maint->product},";
echo "{$maint->licence_quantity} {$maint->licence_type},";
echo ldate($CONFIG['dateformat_date'], $maint->expirydate).",";
$csql = "SELECT * FROM `{$dbSupportContacts}` ";
$csql .= "WHERE maintenanceid='{$maint->maintid}' ";
$csql .= "ORDER BY contactid LIMIT 4";
## echo "<!-- ($csql) -->";
$cresult = mysql_query($csql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
while ($contact = mysql_fetch_object($cresult))
{
echo contact_realname($contact->contactid).",";
}
echo "\n";
$a++;
}
}
}
else
{
echo "<h2>{$site->sitename}</h2>";
echo "<table width='100%'>";
echo "<tr><th style='text-align: left;'>{$strProduct}</th>";
echo "<th style='text-align: left;'>{$strLicense}</th>";
echo "<th style='text-align: left;'>{$strExpiryDate}</th>";
echo "<th style='text-align: left;'>{$strEngineer} 1</th>";
echo "<th style='text-align: left;'>{$strEngineer} 2</th>";
echo "<th style='text-align: left;'>{$strEngineer} 3</th>";
echo "<th style='text-align: left;'>{$strEngineer} 4</th></tr>\n";
while ($maint = mysql_fetch_object($mresult))
{
if ($maint->expirydate > $now AND $maint->term != 'no')
{
echo "<tr>";
echo "<td width='20%'>{$maint->product}</td>";
echo "<td>{$maint->licence_quantity} {$maint->licence_type}</td>";
echo "<td>".ldate($CONFIG['dateformat_date'], $maint->expirydate)."</td>";
$csql = "SELECT * FROM `{$dbSupportContacts}` ";
$csql .= "WHERE maintenanceid='{$maint->maintid}' ";
$csql .= "ORDER BY contactid LIMIT 4";
## echo "<!-- ($csql) -->";
$cresult = mysql_query($csql);
if (mysql_error()) trigger_error(mysql_error(), E_USER_WARNING);
while ($contact = mysql_fetch_object($cresult))
{
echo "<td>".contact_realname($contact->contactid)."</td>";
}
echo "</tr>\n";
$a++;
}
}
echo "</table>";
echo "<hr />";
}
}
}
if ($_REQUEST['mode'] != 'csv')
{
echo "<p align='center'><a href='{$_SERVER['PHP_SELF']}?siteid={$siteid}&mode=csv'>{$strSaveAsCSV}</a></p>";
include (APPLICATION_INCPATH . 'htmlfooter.inc.php');
}
?>