src.dualinventive.com/mtinfo/dist/webroot/rc-4.05/scripts/page/menu_service_limits.php

115 lines
3.8 KiB
PHP

<?php
/** \file scripts\page\menu_service_limits.php
* \brief DI webinterface service limits script.
* \author Rob Schalken, Core|Vision
* \version $Revision: 26247 $
* \date $Date: 2016-02-29 10:40:22 +0100 (Mon, 29 Feb 2016) $
*
* This file contains the service limits script.
*/
//== Menu structure =========================
// Check that this page is called with the correct action (to prevent illegal access)
if(
!is_valid_action(
"service_limits"
)
) {
// Possible abuse: redirect page back to login page
force_logout(_("No valid rights"), "Invalid action: " . current_action(TRUE));
}
$page = new MTinfoPage();
//===========================================
// Verify project/rights and log
if( $page->user_has_rights() ) {
// Check if this is a recall action
if (!$_SESSION[$_PAGE_INFO['id']]['recall_counter']) {
if( isset($_GET['cust_id']) ) {
// customer is set the URL
$wo_id = decrypt($_GET['cust_id'], "cust_id_" . $_SESSION[$_PAGE_INFO['id']]['login']['user']['id']);
}
else {
$cust_id = $_SESSION[$_PAGE_INFO['id']]['search']['customer']['id'];
}
$row_customer = db_fetch_customer($cust_id, TRUE);
$_SESSION[$_PAGE_INFO['id']]['service_info'] = array(
'klant' => $cust_id,
'bedrijfsnaam' => $row_customer['bedrijfsnaam'],
'valuta' => $row_customer['valuta'],
// container for the data entry
'type' => array()
);
// Get the system currencies
$currencies = db_fetch_system_currencies();
// Retrieve all device types
$types = db_fetch_system_devices($_SESSION[$_PAGE_INFO['id']]['i18n']);
if( $types ) foreach( $types as $type ) {
// Fetch the repair items linked to this device type
$woitems = db_search_workorder_items($_SESSION[$_PAGE_INFO['id']]['i18n'], $type['id']);
// Initialize the data array
$type_data = $type;
$type_data['max_bedrag'] = array();
$type_data['insurance'] = array();
foreach( $currencies as $currency => $currency_data ) {
$type_data['max_bedrag'][$currency] = FALSE;
}
if( $woitems ) foreach( $woitems as $woitem ) {
$type_data['insurance'][$woitem['id']] = $woitem;
$type_data['insurance'][$woitem['id']]['enabled'] = FALSE; // will be set to 'TRUE' below, when part of the fleet service
}
$limits = db_fetch_device_max_amount($type['id'], $row_customer['id']);
$type_data['limiet'] = 'never'; // default if not set
if( $limits ) foreach( $limits as $limit ) {
$type_data['max_bedrag'][$limit['valuta']] = $limit['bedrag'];
if(
$limit['valuta'] == $row_customer['valuta'] &&
is_numeric($limit['bedrag'])
) {
if( $limit['bedrag'] == 0 ) {
$type_data['limiet'] = 'unlimited';
// don't show zero amouts
$type_data['max_bedrag'][$limit['valuta']] = "";
}
else {
$type_data['limiet'] = '';
}
}
}
$insured_items = db_fetch_device_insurance($type['id'], $cust_id);
if( $insured_items ) foreach( $insured_items as $insured_item ) {
$type_data['insurance'][$insured_item['werkopdracht']]['enabled'] = TRUE;
}
// Store in the session
$_SESSION[$_PAGE_INFO['id']]['service_info']['type'][$type['id']] = $type_data;
}
}
$page_options = array();
$page_options['y_position'] = $_SESSION[$_PAGE_INFO['id']]['service_info']['y_position'];
// Show page header
print_xml_header($page_options, $extra_header_HTML);
// Include lance info content
include("menu_service_limits_content.php");
// Show page footer
print_page_footer();
}
else {
// Redirect page back to login page
force_logout(_("No valid rights"), "No rights for menu " . $page->menu . ": " . $page->rights);
}
?>