html_redirect('inventory.php', FALSE); exit; } echo "<h2>" . icon('edit', 32) . " {$strEdit}</h2>"; echo "<form action='{$_SERVER['PHP_SELF']}?id={$id}' method='post'>"; echo "<table class='vertical' align='center'>"; echo "<tr><th>{$strName}</th>"; echo "<td><input class='required' name='name' value='{$row->name}' />"; echo "<span class='required'>{$strRequired}</span></td></tr>"; echo "<tr><th>{$strType}</th>"; echo "<td>" . array_drop_down($CONFIG['inventory_types'], 'type', $row->type, '', TRUE) . "</td></tr>"; echo "<tr><th>{$strSite}</th><td>"; echo site_drop_down('site', $row->siteid, TRUE); echo " <span class='required'>{$strRequired}</td>"; echo "<tr><th>{$strOwner}</th><td>"; echo contact_site_drop_down('owner', ''); echo "</td></tr>"; echo "<tr><th>{$strID} " . help_link('InventoryID') . "</th>"; echo "<td><input name='identifier' value='{$row->identifier}' /></td></tr>"; echo "<tr><th>{$strAddress}</th>"; echo "<td><input name='address' value='{$row->address}' /></td></tr>"; if (!is_numeric($id) or ($row->privacy == 'adminonly' and user_permission($sit[2], 22) or $row->privacy == 'private' and $row->createdby == $sit[2] or $row->privacy == 'none')) { echo "<tr><th>{$strUsername}</th>"; echo "<td><input name='username' value='{$row->username}' /></td></tr>"; echo "<tr><th>{$strPassword}</th>"; echo "<td><input name='password' value='{$row->password}' /></td></tr>"; } echo "<tr><th>{$strNotes}</th>"; echo "<td><textarea name='notes'>{$row->notes}</textarea></td></tr>"; if ($row->privacy == 'adminonly' and user_permission($sit[2], 22) or $row->privacy == 'private' and $row->createdby == $sit[2] or $row->privacy == 'none') { echo "<tr><th>{$strPrivacy} " . help_link('InventoryPrivacy') . "</th>";
echo "<tr><th>{$strName}</th>"; echo "<td><input class='required' name='name' value='{$row->name}' />"; echo "<span class='required'>{$strRequired}</span></td></tr>"; echo "<tr><th>{$strType}</th>"; echo "<td>" . array_drop_down($CONFIG['inventory_types'], 'type', $row->type, '', TRUE) . "</td></tr>"; if (!intval($siteid)) { echo "<tr><th>{$strSite}</th><td>"; echo site_drop_down('site', 0, TRUE); echo " <span class='required'>{$strRequired}</td>"; echo "<tr><th>{$strOwner}</th><td>"; echo contact_site_drop_down('owner', ''); echo "</td></tr>"; } else { echo "<input type='hidden' id='site' name='site' value='{$siteid}' />"; echo "<tr><th>{$strOwner}</th><td>"; echo contact_site_drop_down('owner', $row->contactid, $siteid, NULL, FALSE); echo "</td></tr>"; } echo "<tr><th>{$strID} " . help_link('InventoryID') . "</th>"; echo "<td><input name='identifier' value='{$row->identifier}' /></td></tr>"; echo "<tr><th>{$strAddress}</th>"; echo "<td><input name='address' value='{$row->address}' /></td></tr>"; echo "<tr><th>{$strUsername}</th>"; echo "<td><input name='username' value='{$row->username}' /></td></tr>"; echo "<tr><th>{$strPassword}</th>"; echo "<td><input name='password' value='{$row->password}' /></td></tr>"; echo "<tr><th>{$strNotes}</th>"; echo "<td><textarea name='notes'>{$row->notes}</textarea></td></tr>"; echo "<tr><th>{$strPrivacy} " . help_link('InventoryPrivacy') . "</th>"; echo "<td><input type='radio' name='privacy' value='private' "; if ($row->privacy == 'private') {
/** * Return the html of contract detatils * @author Kieran Hogg * @param int $maintid - ID of the contract * @param string $mode. 'internal' or 'external' * @return array of supported contracts, NULL if none * @todo FIXME not quite generic enough for a function ? */ function contract_details($id, $mode = 'internal') { global $CONFIG, $iconset, $dbMaintenance, $dbSites, $dbResellers, $dbLicenceTypes, $now; $sql = "SELECT m.*, m.notes AS maintnotes, s.name AS sitename, "; $sql .= "r.name AS resellername, lt.name AS licensetypename "; $sql .= "FROM `{$dbMaintenance}` AS m, `{$dbSites}` AS s, "; $sql .= "`{$dbResellers}` AS r, `{$dbLicenceTypes}` AS lt "; $sql .= "WHERE s.id = m.site "; $sql .= "AND m.id='{$id}' "; $sql .= "AND m.reseller = r.id "; $sql .= "AND (m.licence_type IS NULL OR m.licence_type = lt.id) "; if ($mode == 'external') { $sql .= "AND m.site = '{$_SESSION['siteid']}'"; } $maintresult = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $maint = mysql_fetch_object($maintresult); $html = "<table align='center' class='vertical'>"; $html .= "<tr><th>{$GLOBALS['strContract']} {$GLOBALS['strID']}:</th>"; $html .= "<td><h3>" . icon('contract', 32) . " "; $html .= "{$maint->id}</h3></td></tr>"; $html .= "<tr><th>{$GLOBALS['strStatus']}:</th><td>"; if ($maint->term == 'yes') { $html .= "<strong>{$GLOBALS['strTerminated']}</strong>"; } else { $html .= $GLOBALS['strActive']; } if ($maint->expirydate < $now and $maint->expirydate != '-1') { $html .= "<span class='expired'>, {$GLOBALS['strExpired']}</span>"; } $html .= "</td></tr>\n"; $html .= "<tr><th>{$GLOBALS['strSite']}:</th>"; if ($mode == 'internal') { $html .= "<td><a href=\"site_details.php?id=" . $maint->site . "\">" . $maint->sitename . "</a></td></tr>"; } else { $html .= "<td><a href=\"sitedetails.php\">" . $maint->sitename . "</a></td></tr>"; } $html .= "<tr><th>{$GLOBALS['strAdminContact']}:</th>"; if ($mode == 'internal') { $html .= "<td><a href=\"contact_details.php?id="; $html .= "{$maint->admincontact}\">"; $html .= contact_realname($maint->admincontact) . "</a></td></tr>"; } else { $html .= "<td><a href='contactdetails.php?id={$maint->admincontact}'>"; $html .= contact_realname($maint->admincontact) . "</a></td></tr>"; } $html .= "<tr><th>{$GLOBALS['strReseller']}:</th><td>"; if (empty($maint->resellername)) { $html .= $GLOBALS['strNoReseller']; } else { $html .= $maint->resellername; } $html .= "</td></tr>"; $html .= "<tr><th>{$GLOBALS['strProduct']}:</th><td>" . product_name($maint->product) . "</td></tr>"; $html .= "<tr><th>{$GLOBALS['strIncidents']}:</th>"; $html .= "<td>"; $incidents_remaining = $maint->incident_quantity - $maint->incidents_used; if ($maint->incident_quantity == 0) { $quantity = $GLOBALS['strUnlimited']; } else { $quantity = $maint->incident_quantity; } $html .= sprintf($GLOBALS['strUsedNofN'], $maint->incidents_used, $quantity); if ($maint->incidents_used >= $maint->incident_quantity and $maint->incident_quantity != 0) { $html .= " ({$GLOBALS['strZeroRemaining']})"; } $html .= "</td></tr>"; if ($maint->licence_quantity != '0') { $html .= "<tr><th>{$GLOBALS['strLicense']}:</th>"; $html .= "<td>{$maint->licence_quantity} {$maint->licensetypename}</td></tr>\n"; } $html .= "<tr><th>{$GLOBALS['strServiceLevel']}:</th><td>" . servicelevel_name($maint->servicelevelid) . "</td></tr>"; $html .= "<tr><th>{$GLOBALS['strExpiryDate']}:</th><td>"; if ($maint->expirydate == '-1') { $html .= "{$GLOBALS['strUnlimited']}"; } else { $html .= ldate($CONFIG['dateformat_date'], $maint->expirydate); } $html .= "</td></tr>"; if ($mode == 'internal') { $timed = db_read_column('timed', $GLOBALS['dbServiceLevels'], $maint->servicelevelid); if ($timed == 'yes') { $timed = TRUE; } else { $timed = FALSE; } $html .= "<tr><th>{$GLOBALS['strService']}</th><td>"; $html .= contract_service_table($id, $timed); $html .= "</td></tr>\n"; if ($timed) { $html .= "<tr><th>{$GLOBALS['strBalance']}</th><td>{$CONFIG['currency_symbol']}" . number_format(get_contract_balance($id, TRUE, TRUE), 2); $multiplier = get_billable_multiplier(strtolower(date('D', $now)), date('G', $now)); $html .= " (≅" . contract_unit_balance($id, TRUE, TRUE) . " units)"; $html .= "</td></tr>"; } } if ($maint->maintnotes != '' and $mode == 'internal') { $html .= "<tr><th>{$GLOBALS['strNotes']}:</th><td>{$maint->maintnotes}</td></tr>"; } $html .= "</table>"; if ($mode == 'internal') { $html .= "<p align='center'>"; $html .= "<a href=\"contract_edit.php?action=edit&maintid={$id}\">{$GLOBALS['strEditContract']}</a> | "; $html .= "<a href='contract_add_service.php?contractid={$id}'>{$GLOBALS['strAddService']}</a></p>"; } $html .= "<h3>{$GLOBALS['strContacts']}</h3>"; if (mysql_num_rows($maintresult) > 0) { if ($maint->allcontactssupported == 'yes') { $html .= "<p class='info'>{$GLOBALS['strAllSiteContactsSupported']}</p>"; } else { $allowedcontacts = $maint->supportedcontacts; $supportedcontacts = supported_contacts($id); $numberofcontacts = 0; $numberofcontacts = sizeof($supportedcontacts); if ($allowedcontacts == 0) { $allowedcontacts = $GLOBALS['strUnlimited']; } $html .= "<table align='center'>"; $supportcount = 1; if ($numberofcontacts > 0) { foreach ($supportedcontacts as $contact) { $html .= "<tr><th>{$GLOBALS['strContact']} #{$supportcount}:</th>"; $html .= "<td>" . icon('contact', 16) . " "; if ($mode == 'internal') { $html .= "<a href=\"contact_details.php?"; } else { $html .= "<a href=\"contactdetails.php?"; } $html .= "id={$contact}\">" . contact_realname($contact) . "</a>, "; $html .= contact_site($contact) . "</td>"; if ($mode == 'internal') { $html .= "<td><a href=\"contract_delete_contact.php?contactid=" . $contact . "&maintid={$id}&context=maintenance\">{$GLOBALS['strRemove']}</a></td></tr>\n"; } else { $html .= "<td><a href=\"{$_SERVER['PHP_SELF']}?id={$id}&contactid=" . $contact . "&action=remove\">{$GLOBALS['strRemove']}</a></td></tr>\n"; } $supportcount++; } $html .= "</table>"; } else { $html .= "<p class='info'>{$GLOBALS['strNoRecords']}<p>"; } } if ($maint->allcontactssupported != 'yes') { $html .= "<p align='center'>"; $html .= sprintf($GLOBALS['strUsedNofN'], "<strong>" . $numberofcontacts . "</strong>", "<strong>" . $allowedcontacts . "</strong>"); $html .= "</p>"; if ($numberofcontacts < $allowedcontacts or $allowedcontacts == 0 and $mode == 'internal') { $html .= "<p align='center'><a href='contract_add_contact.php?maintid={$id}&siteid={$maint->site}&context=maintenance'>"; $html .= "{$GLOBALS['strAddContact']}</a></p>"; } else { $html .= "<h3>{$GLOBALS['strAddContact']}</h3>"; $html .= "<form action='{$_SERVER['PHP_SELF']}?id={$id}&action="; $html .= "add' method='post' >"; $html .= "<p align='center'>{$GLOBLAS['strAddNewSupportedContact']} "; $html .= contact_site_drop_down('contactid', 'contactid', maintenance_siteid($id), supported_contacts($id)); $html .= help_link('NewSupportedContact'); $html .= " <input type='submit' value='{$GLOBALS['strAdd']}' /></p></form>"; } if ($mode == 'external') { $html .= "<p align='center'><a href='addcontact.php'>"; $html .= "{$GLOBALS['strAddNewSiteContact']}</a></p>"; } } $html .= "<br />"; $html .= "<h3>{$GLOBALS['strSkillsSupportedUnderContract']}:</h3>"; // supported software $sql = "SELECT * FROM `{$GLOBALS[dbSoftwareProducts]}` AS sp, `{$GLOBALS[dbSoftware]}` AS s "; $sql .= "WHERE sp.softwareid = s.id AND productid='{$maint->product}' "; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } if (mysql_num_rows($result) > 0) { $html .= "<table align='center'>"; while ($software = mysql_fetch_object($result)) { $software->lifetime_end = mysql2date($software->lifetime_end); $html .= "<tr><td> " . icon('skill', 16) . " "; if ($software->lifetime_end > 0 and $software->lifetime_end < $now) { $html .= "<span class='deleted'>"; } $html .= $software->name; if ($software->lifetime_end > 0 and $software->lifetime_end < $now) { $html .= "</span>"; } $html .= "</td></tr>\n"; } $html .= "</table>\n"; } else { $html .= "<p align='center'>{$GLOBALS['strNone']} / {$GLOBALS['strUnknown']}<p>"; } } else { $html = "<p align='center'>{$GLOBALS['strNothingToDisplay']}</p>"; } return $html; }
require 'core.php'; require APPLICATION_LIBPATH . 'functions.inc.php'; // This page requires authentication require APPLICATION_LIBPATH . 'auth.inc.php'; // External variables $process = $_REQUEST['process']; $id = cleanvar($_REQUEST['id']); $newcontact = mysql_real_escape_string($_REQUEST['newcontact']); $title = $strDeleteContact; include APPLICATION_INCPATH . 'htmlheader.inc.php'; if (empty($process)) { if (empty($id)) { echo "<h2>{$strDeleteContact}</h2>"; echo "<form action=\"{$_SERVER['PHP_SELF']}?action=delete\" method=\"post\">"; echo "<table align='center'>"; echo "<tr><th>{$strContact}:</th><td>" . contact_site_drop_down("id", 0) . "</td></tr>"; echo "</table>"; echo "<p><input name=\"submit1\" type=\"submit\" value=\"{$strDelete}\" /></p>"; echo "</form>"; } else { echo "<h2>{$strDeleteContact}</h2>\n"; $sql = "SELECT * FROM `{$dbContacts}` WHERE id='{$id}' "; $contactresult = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } while ($contactrow = mysql_fetch_array($contactresult)) { echo "<table align='center' class='vertical'>"; echo "<tr><th>{$strName}:</th><td><h3>" . $contactrow['forenames'] . ' ' . $contactrow['surname'] . "</h3></td></tr>"; echo "<tr><th>{$strSite}:</th><td><a href=\"site_details.php?id=" . $contactrow['siteid'] . "\">" . site_name($contactrow['siteid']) . "</a></td></tr>"; echo "<tr><th>{$strDepartment}:</th><td>" . $contactrow['department'] . "</td></tr>";
echo "<input maxlength='255' id='address2' name='address2' size='40' value='{$contactrow['address2']}' {$extraattributes} />"; echo "</td></tr>\n"; echo "<tr><th>{$strCity}:</th><td>"; echo "<input maxlength='255' id='city' name='city' size='40' value='{$contactrow['city']}' {$extraattributes} />"; echo "</td></tr>\n"; echo "<tr><th>{$strCounty}:</th><td>"; echo "<input maxlength='255' id='county' name='county' size='40' value='{$contactrow['county']}' {$extraattributes} />"; echo "</td></tr>\n"; echo "<tr><th>{$strPostcode}:</th><td>"; echo "<input maxlength='255' id='postcode' name='postcode' size='40' value='{$contactrow['postcode']}' {$extraattributes} />"; echo "</td></tr>\n"; echo "<tr><th>{$strCountry}:</th><td>"; echo country_drop_down('country', $contactrow['country'], $extraattributes); echo "</td></tr>\n"; echo "<tr><th>{$strNotifyContact}:</th><td>"; echo contact_site_drop_down('notify_contactid', $contactrow['notify_contactid'], $contactrow['siteid'], $contact, TRUE, TRUE); echo "</td></tr>\n"; echo "<tr><th>{$strNotes}:</th><td>"; echo "<textarea rows='5' cols='60' name='notes'>{$contactrow['notes']}</textarea></td></tr>\n"; plugin_do('edit_contact_form'); echo "</table>"; echo "<input name='contact' type='hidden' value='{$contact}' />"; echo "<p align='center'><input name='submit' type='submit' value='{$strSave}' /></p>"; echo "</form>\n"; } } else { if ($action == "update") { // External variables $contact = cleanvar($_POST['contact']); $courtesytitle = cleanvar($_POST['courtesytitle']); $surname = cleanvar($_POST['surname']);