<?php
/**********************************************************************
    Copyright (C) FrontAccounting, LLC.
	Released under the terms of the GNU General Public License, GPL, 
	as published by the Free Software Foundation, either version 3 
	of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
***********************************************************************/
$page_security = 'SA_JOB_CARDS_VIEW';
$path_to_root = "..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui/ui_input.inc"); 
include_once($path_to_root . "/services/includes/ui/service_complains_ui.inc"); 
include_once($path_to_root . "/services/includes/db/service_complains_db.inc");
include_once($path_to_root . "/includes/ui/ui_lists_custom.inc"); 
include_once($path_to_root . "/admin/db/list_values_db.inc"); 
include_once($path_to_root . "/payroll/includes/db/employees_db.inc"); 
include_once($path_to_root . "/assets/includes/db/assets_db.inc"); 
include_once($path_to_root . "/includes/ui/ui_view_custom.inc"); 
include_once($path_to_root . "/includes/ui/ui_controls_custom.inc"); 

$js = "";
$js .= get_js_open_window(900, 500);
$js .= get_js_date_picker();

page(_($help_context = "Service Complain/ Request List View"), false, false, "", $js);

start_form();

    global $Ajax;

    start_table(TABLESTYLE_NOBORDER);
        start_row();
            ref_cells(text_bold(_("Id:")), 'id', '',null, '', true);
            ref_cells(text_bold(_("Job Card:")), 'jo_id', '',null, '', true);
            ref_cells(_("Reference:"), 'reference', '', null, '', true);
            three_value_list_cells(_("Has Job:"), 'has_job', null, '', '', 'Yes', 'Yes', 'No', 'No', true);
            date_cells(_("Date From:"), 'from_date', null, null, 0, -1);
            date_cells(_("Date To:"), 'to_date');
            label_cells(_("Vehicle/ Tool/ Location:"), asset_list('vehicle_id'));
        end_row();
        start_row();
            custom_values_list_cells('Req. Department:', 'req_department_id', create_request_departmens_array(), null, '', true);
            system_users_list_cells("Issuing Officer:", 'issuing_officer', null, '', true);
            text_cells('Name:', 'customer_name', null, 20, 300, 'Customer Name');
            text_cells('Address:', 'customer_address', null, 20, 300, 'Customer Address');
            text_cells('Complain:', 'complain', null, 20, 300, 'Complain/ Request Details');
            three_value_list_cells(_("Closed:"), 'closed', null, '', '', 'Yes', 'Yes', 'No', 'No', true);
            three_value_list_cells(_("Booking:"), 'booking', null, '', '', 'Yes', 'Yes', 'No', 'No', true);
            
            submit_cells('SearchOrders', _("Search"), '', _('Search'), false, ICON_SUBMIT);
        end_row();
    end_table(1);
    
    $customer_name = $customer_address = $complain = '';
    $closed = $booking = null;
    if (isset($_POST['customer_name'])) {
        $customer_name = $_POST['customer_name'];
    }
    if (isset($_POST['customer_address'])) {
        $customer_address = $_POST['customer_address'];
    }
    if (isset($_POST['complain'])) {
        $complain = $_POST['complain'];
    }
    
    if ($_POST['closed'] == 'Yes') {
        $closed = 1;
    } elseif ($_POST['closed'] == 'No') {
        $closed = 0;
    } 
    
    if ($_POST['booking'] == 'Yes') {
        $booking = 1;
    } elseif ($_POST['booking'] == 'No') {
        $booking = 0;
    } 
    
    $Ajax->activate('service_complain_list_view');
    div_start('service_complain_list_view');
    
    display_service_complains_view($_POST['from_date'], $_POST['to_date'], $_POST['vehicle_id'], $_POST['req_department_id'], $closed, $_POST['has_job'], 
                                   $_POST['issuing_officer'], $_POST['id'], $_POST['jo_id'], $_POST['reference'], $customer_name, $customer_address, $complain, 
                                   $booking);
                
    div_end();

end_form(2);
end_page(true);

?>