<?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/job_order_entry_ui.inc"); 
include_once($path_to_root . "/services/includes/db/job_orders_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 = "Job Card List View"), false, false, "", $js);

start_form();

    global $Ajax;

    start_table(TABLESTYLE_NOBORDER);
        start_row();
            date_cells(_("Date From:"), 'from_date', null, null, 0, -1);
            date_cells(_("Date To:"), 'to_date');
            label_cells(_("Vehicle:"), asset_list('vehicle_id'));
            custom_values_list_cells('Req. Department:', 'req_department_id', create_request_departmens_array(), null, '', true);
            value_list_cells('Department:', 'department_id', 'DEPARTMENTS', null, '', true);
            $dep_row = get_listvalue_by_id($_POST['department_id']);
                if (is_array($dep_row)) {
                    $section_list_code = $dep_row['value_code'];
                    value_list_cells('Section:', 'section_id', "VMS_$section_list_code", null, '', true);
                } else {
                    $_POST['section_id'] = 0;    
                }
        end_row();            
        start_row();
            employees_simple_list_cells_2(_("Sectional Engineer:"), 'engineer_code', null, _(''), false, array("'ENGINEER'"));
            employees_simple_list_cells_2(_("Technical Officer:"), 'tech_officer_code', null, _(''), false, array("'TECHNICAL_OFFICER'", "'WORK_FIELD_SUPERVISO'"));
            employees_simple_list_cells(_("Current Job Owner:"), 'next_job_owner_id', null, _(''), true);
            three_value_list_cells(_("Work Completed:"), 'job_completed', null, '', '', 'Yes', 1, 'No', 0, true);
            custom_values_list_cells("Approval Status:", "approval_status", job_order_approval_status_array(true), null, false, true);
            
            submit_cells('SearchOrders', _("Search"), '', _('Select documents'), false, ICON_SUBMIT);
        end_row();

    end_table(1);
    
    $Ajax->activate('job_orders_view');
    div_start('job_orders_view');
    
        display_job_orders_view($_POST['from_date'], $_POST['to_date'], $_POST['vehicle_id'], $_POST['req_department_id'], $_POST['department_id'], $_POST['section_id'], 
                                $_POST['engineer_code'], $_POST['tech_officer_code'], $_POST['next_job_owner_id'], $_POST['job_completed'], $_POST['approval_status']);
    
    div_end();


end_form(2);
end_page(true);

?>