<? global $vis_language; ?><form method="post" name="vis_report_form" id="vis_report_form">
<div class="vis_main_window vis_shadow vis_round_corner">
    <div class="vis_main_header"><? echo $vis_language['TXTADDREPORT']; ?></div>
    <div class="vis_main_window_content vis_round_corner">

    <div id="vis_add_report"><input type="hidden" name="vis_report_type" value="0" />
    <table cellpadding="3" cellspacing="3" width="100%">
        <tr><td width="80"><? echo $vis_language['TXTTITLE']; ?></td><td><input type="text" name="vis_report_title" id="vis_report_title" class="vis_input" value="" /></td></tr>
        <!--<tr><td><span class="vis_sub_title"><? echo $vis_language['TXTTYPE']; ?></span></td><td><select name="vis_report_type" id="vis_report_type" class="vis_input"><option value="0"><? echo $vis_language['TXTTABULAR']; ?></option><option value="1"><? echo $vis_language['TXTSUMMARY']; ?></option></td></tr>-->
        <tr><td><? echo $vis_language['TXTMODULE']; ?></td><td><select name="vis_report_module" id="vis_report_module" class="vis_input"><option value="0"><? echo $vis_language['TXTTICKET']; ?></option><option value="2"><? echo $vis_language['TXTCLIENT']; ?></option><option value="1"><? echo $vis_language['TXTSTAFF']; ?></option></td></tr>
        <tr><td colspan="2"><div class="vis_seperator_horizontal"></div></td></tr>
        <tr><td colspan="2"><span class="vis_button" onclick="load_next_step(1)"><? echo $vis_language['TXTNEXT']; ?></span></td></tr>
    </table></div>

    <div id="vis_select_report_fields" style="display:none"><div id="vis_ticket_field_group"><table cellpadding="0" cellspacing="0" width="100%" class="vis_list_table">
        <tr><th colspan="2"><? echo $vis_language['TXTTICKET']; ?></th></tr>
        <tr>
            <td width="50%"><input type="checkbox" name="vis_ticket_hash" id="vis_ticket_hash" value="1" /> <label for="vis_ticket_hash"><? echo $vis_language['TXTTICKETHASH']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_id" id="vis_ticket_id" value="1" /> <label for="vis_ticket_id"><? echo $vis_language['TXTTICKETID']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_subject" id="vis_ticket_subject" value="1" /> <label for="vis_ticket_subject"><? echo $vis_language['TXTSUBJECT']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_type" id="vis_ticket_type" value="1" /> <label for="vis_ticket_type"><? echo $vis_language['TXTTICKETTYPE']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_domain" id="vis_ticket_domain" value="1" /> <label for="vis_ticket_domain"><? echo $vis_language['TXTDOMAIN']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_department" id="vis_ticket_department" value="1" /> <label for="vis_ticket_department"><? echo $vis_language['TXTDEPARTMENT']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_status" id="vis_ticket_status" value="1" /> <label for="vis_ticket_status"><? echo $vis_language['TXTTICKETSTATUS']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_priority" id="vis_ticket_priority" value="1" /> <label for="vis_ticket_priority"><? echo $vis_language['TXTTICKETPRIORITY']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_createdon" id="vis_ticket_createdon" value="1" /> <label for="vis_ticket_createdon"><? echo $vis_language['TXTTICKETCREATEDON']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_modifiedon" id="vis_ticket_modifiedon" value="1" /> <label for="vis_ticket_modifiedon"><? echo $vis_language['TXTTICKETMODIFIEDON']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_duetime" id="vis_ticket_duetime" value="1" /> <label for="vis_ticket_duetime"><? echo $vis_language['TXTDUETIME']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_reslove_time" id="vis_ticket_reslove_time" value="1" /> <label for="vis_ticket_reslove_time"><? echo $vis_language['TXTRESOLVETIME']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_slaplan" id="vis_ticket_slaplan" value="1" /> <label for="vis_ticket_slaplan"><? echo $vis_language['TXTSLAPLAN']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_sla_id" id="vis_ticket_sla_id" value="1" /> <label for="vis_ticket_sla_id"><? echo $vis_language['TXTSLAID']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_ticket_reply_count" id="vis_ticket_reply_count" value="1" /> <label for="vis_ticket_reply_count"><? echo $vis_language['TXTTICKETPOSTCOUNT']; ?></label></td>
            <td><input type="checkbox" name="vis_ticket_count" id="vis_ticket_count" value="1" /> <label for="vis_ticket_count"><? echo $vis_language['TXTTICKETCOUNT']; ?></label></td>
        </tr>
        </table>
        </div><div id="vis_client_field_group">
        <table cellpadding="0" cellspacing="0" width="100%" class="vis_list_table">
        <tr><th colspan="2"><? echo $vis_language['TXTCLIENT']; ?></th></tr>
        <tr>
            <td width="50%"><input type="checkbox" name="vis_client_first_name" id="vis_client_first_name" value="1" /> <label for="vis_client_first_name"><? echo $vis_language['TXTCLIENTFIRSTNAME']; ?></label></td>
            <td><input type="checkbox" name="vis_client_last_name" id="vis_client_last_name" value="1" /> <label for="vis_client_last_name"><? echo $vis_language['TXTCLIENTLASTNAME']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_client_email" id="vis_client_email" value="1" /> <label for="vis_client_email"><? echo $vis_language['TXTCLIENTEMAIL']; ?></label></td>
            <td><input type="checkbox" name="vis_client_contact" id="vis_client_contact" value="1" /> <label for="vis_client_contact"><? echo $vis_language['TXTCLIENTCONTACT']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_client_jobtitle" id="vis_client_jobtitle" value="1" /> <label for="vis_client_jobtitle"><? echo $vis_language['TXTCLIENTJOBTITLE']; ?></label></td>
            <td><input type="checkbox" name="vis_client_company" id="vis_client_company" value="1" /> <label for="vis_client_company"><? echo $vis_language['TXTCLIENTCOMPANY']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_client_city" id="vis_client_city" value="1" /> <label for="vis_client_city"><? echo $vis_language['TXTCLIENTCITY']; ?></label></td>
            <td><input type="checkbox" name="vis_client_state" id="vis_client_state" value="1" /> <label for="vis_client_state"><? echo $vis_language['TXTCLIENTSTATE']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_client_country" id="vis_client_country" value="1" /> <label for="vis_client_country"><? echo $vis_language['TXTCLIENTCOUNTRY']; ?></label></td>
            <td><input type="checkbox" name="vis_client_zipcode" id="vis_client_zipcode" value="1" /> <label for="vis_client_zipcode"><? echo $vis_language['TXTCLIENTZIPCODE']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_client_group" id="vis_client_group" value="1" /> <label for="vis_client_group"><? echo $vis_language['TXTORGANIZATION']; ?></label></td>
            <td><input type="checkbox" name="vis_client_domain" id="vis_client_domain" value="1" /> <label for="vis_client_domain"><? echo $vis_language['TXTDOMAIN']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_client_isspam" id="vis_client_isspam" value="1" /> <label for="vis_client_isspam"><? echo $vis_language['TXTISSPAMCLIENT']; ?></label></td>
            <td><input type="checkbox" name="vis_client_isban" id="vis_client_isban" value="1" /> <label for="vis_client_isban"><? echo $vis_language['TXTISBANNEDCLIENT']; ?></label></td>
        </tr>
        </table>
        </div><div id="vis_billing_field_group">
        <table cellpadding="0" cellspacing="0" width="100%" class="vis_list_table">
        <tr><th colspan="2"><? echo $vis_language['TXTBILLING']; ?></th></tr>
        <tr>
            <td width="50%"><input type="checkbox" name="vis_client_credit" id="vis_client_credit" value="1" /> <label for="vis_client_credit"><? echo $vis_language['TXTCREDIT']; ?></label></td>
            <td width="50%"><!--<input type="checkbox" name="vis_client_group_credit" id="vis_client_group_credit" value="1" /> <label for="vis_client_group_credit"><? echo $vis_language['TXTCLIENTGROUPCREDIT']; ?></label>--></td>
        </tr>
        <tr>
            <td width="50%"><input type="checkbox" name="vis_client_paid_invocie" id="vis_client_paid_invocie" value="1" /> <label for="vis_client_paid_invocie"><? echo $vis_language['TXTCLIENTPAIDINVOICECOUNT']; ?></label></td>
            <td><input type="checkbox" name="vis_client_unpaid_invocie" id="vis_client_unpaid_invocie" value="1" /> <label for="vis_client_unpaid_invocie"><? echo $vis_language['TXTCLIENTUNPAIDINVOICECOUNT']; ?></label></td>
        </tr>
        </table>
        </div><div id="vis_staff_field_group">
        <table cellpadding="0" cellspacing="0" width="100%" class="vis_list_table">
        <tr><th colspan="2"><? echo $vis_language['TXTSTAFF']; ?></th></tr>
        <tr>
            <td width="50%"><input type="checkbox" name="vis_staff_first_name" id="vis_staff_first_name" value="1" /> <label for="vis_staff_first_name"><? echo $vis_language['TXTSTAFFFIRSTNAME']; ?></label></td>
            <td><input type="checkbox" name="vis_staff_last_name" id="vis_staff_last_name" value="1" /> <label for="vis_staff_last_name"><? echo $vis_language['TXTSTAFFLASTNAME']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_staff_email" id="vis_staff_email" value="1" /> <label for="vis_staff_email"><? echo $vis_language['TXTSTAFFEMAIL']; ?></label></td>
            <td><input type="checkbox" name="vis_staff_job_title" id="vis_staff_job_title" value="1" /> <label for="vis_staff_job_title"><? echo $vis_language['TXTSTAFFJOBTITLE']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_staff_contact" id="vis_staff_contact" value="1" /> <label for="vis_staff_contact"><? echo $vis_language['TXTCONTACTNUMBER']; ?></label></td>
            <td><input type="checkbox" name="vis_staff_mobile" id="vis_staff_mobile" value="1" /> <label for="vis_staff_mobile"><? echo $vis_language['TXTMOBILENUMBER']; ?></label></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="vis_staff_avg_response" id="vis_staff_avg_response" value="1" /> <label for="vis_staff_avg_response"><? echo $vis_language['TXTAVGRESPONSE']; ?></label></td>
            <td><input type="checkbox" name="vis_staff_num_response" id="vis_staff_num_response" value="1" /> <label for="vis_staff_num_response"><? echo $vis_language['TXTTOTALRESPONSES']; ?></label></td>
        </tr>
        </table></div><table cellpadding="0" cellspacing="0" width="100%">
        <tr><td><div class="vis_seperator_horizontal"></div></td></tr>
        <tr><td><span class="vis_button" onclick="load_next_step(2)"><? echo $vis_language['TXTNEXT']; ?></span> <span class="vis_button" onclick="load_next_step(0)"><? echo $vis_language['TXTBACK']; ?></span></td></tr>
    </table></div>

    <div id="vis_add_report_condition" style="display:none"><table cellpadding="3" cellspacing="3" width="100%"><tr><td><div id="vis_report_options"></div></td></tr><tr><td>
            <input id="or_option" name="vis_concate_option" value="or" checked="checked" type="radio"> <label for="or_option"><? echo $vis_language['TXTMATCHANYCRITERIA']; ?></label> <input id="and_option" name="vis_concate_option" value="and" type="radio"> <label for="and_option"><? echo $vis_language['TXTMATCHALLCRITERIA']; ?></label> <span class="vis_button" onclick="add_condition()"><? echo $vis_language['TXTADDCRITERIA']; ?></span>
        <div class="vis_seperator_horizontal"></div></td></tr>
    </table><input type="hidden" name="total_conditions" id="total_conditions" value="0" />

    <div id="vis_type_sortby"><table cellpadding="3" cellspacing="3" width="100%"><tr><td width="80"><span class="vis_sub_title"><? echo $vis_language['TXTSORTBY']; ?></span></td><td>
    <table cellspacing="0" cellpadding="2"><tr>
        <td width="100"><select name="vis_sort_by_1" id="vis_sort_by_1"><option value="-1">-- <? echo $vis_language['TXTSELECT']; ?>--</option><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTORGANIZATION']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option></select></td>
        <td width="100"><select name="vis_sort_by_2" id="vis_sort_by_2"><option value="-1">-- <? echo $vis_language['TXTSELECT']; ?>--</option><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTORGANIZATION']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option></select></td>
        <td width="100"><select name="vis_sort_by_3" id="vis_sort_by_3"><option value="-1">-- <? echo $vis_language['TXTSELECT']; ?>--</option><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTORGANIZATION']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option></select></td></tr></table>
    </td></tr><tr><td colspan="2"><div class="vis_seperator_horizontal"></div></td></tr></table></div>

    <div id="vis_type_groupby" style="display:none"><table cellpadding="3" cellspacing="3" width="100%"><tr><td width="80"><span class="vis_sub_title"><? echo $vis_language['TXTGROUPBY']; ?></span></td><td>
    <table cellspacing="0" cellpadding="2"><tr>
        <td width="100"><select name="vis_group_by_1" id="vis_group_by_1"><option value="-1">-- <? echo $vis_language['TXTSELECT']; ?>--</option><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="1"><? echo $vis_language['TXTMESSAGE']; ?></option><option value="2"><? echo $vis_language['TXTTICKETNOTE']; ?></option><option value="3"><? echo $vis_language['TXTTICKETCOMMENT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTORGANIZATION']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="10"><? echo $vis_language['TXTOWNER']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="20"><? echo $vis_language['TXTBILLINGNOTE']; ?></option></select></td>
        <td width="100"><select name="vis_group_by_2" id="vis_group_by_2"><option value="-1">-- <? echo $vis_language['TXTSELECT']; ?>--</option><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="1"><? echo $vis_language['TXTMESSAGE']; ?></option><option value="2"><? echo $vis_language['TXTTICKETNOTE']; ?></option><option value="3"><? echo $vis_language['TXTTICKETCOMMENT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTCLIENTGROUP']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="10"><? echo $vis_language['TXTOWNER']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="20"><? echo $vis_language['TXTBILLINGNOTE']; ?></option></select></td>
        <td width="100"><select name="vis_group_by_3" id="vis_group_by_3"><option value="-1">-- <? echo $vis_language['TXTSELECT']; ?>--</option><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="1"><? echo $vis_language['TXTMESSAGE']; ?></option><option value="2"><? echo $vis_language['TXTTICKETNOTE']; ?></option><option value="3"><? echo $vis_language['TXTTICKETCOMMENT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTORGANIZATION']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="10"><? echo $vis_language['TXTOWNER']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="20"><? echo $vis_language['TXTBILLINGNOTE']; ?></option></select></td></tr></table>
    </td></tr><tr><td colspan="2"><div class="vis_seperator_horizontal"></div></td></tr></table></div>
    <br /><span class="vis_button" onclick="$('#vis_global_msg_div').visExecution('submit_form', {'vis_module':'report', 'vis_operation':'save_report', 'vis_form':'vis_report_form'})"><? echo $vis_language['TXTFINISH']; ?></span> <span class="vis_button" onclick="load_next_step(1)"><? echo $vis_language['TXTBACK']; ?></span>
    </div>
</div></div></form>

<script>
    function load_next_step(level) {
        if(level==0) {
            $("#vis_add_report").show("slow");
            $("#vis_select_report_fields").hide();
            $("#vis_add_report_condition").hide();
        }
        else if(level==1) {
            $("#vis_add_report").hide();
            $("#vis_select_report_fields").show("slow");
            $("#vis_add_report_condition").hide();
            if($("#vis_report_module").val()==0) {
                $("#vis_staff_field_group").hide();
                $("#vis_ticket_field_group").show();
                $("#vis_client_field_group").show();
                $("#vis_billing_field_group").show();
            }
            else if($("#vis_report_module").val()==1) {
                $("#vis_staff_field_group").show();
                $("#vis_ticket_field_group").hide();
                $("#vis_client_field_group").hide();
                $("#vis_billing_field_group").hide();
            }
            else if($("#vis_report_module").val()==2) {
                $("#vis_staff_field_group").hide();
                $("#vis_ticket_field_group").hide();
                $("#vis_client_field_group").show();
                $("#vis_billing_field_group").show();
            }
        }
        else if(level==2) {
            $("#vis_add_report").hide();
            $("#vis_select_report_fields").hide();
            $("#vis_add_report_condition").show("slow");
            if($("#vis_report_type").val()==0) {
                $("#vis_type_groupby").hide();
            }
            else if($("#vis_report_type").val()==1) {
                $("#vis_type_groupby").show();
            }
        }
    }
    function add_condition() {
        var total=document.getElementById("total_conditions");
        var num=parseInt(total.value)+1;
        total.value=num;
        var newDiv=document.createElement("DIV");
        var newCritera='<table cellspacing="1" cellpadding="2" width="100%"><tr><td width="18" align="center"><span class="vis-icon vis-icon-close" onclick="close_condition('+num+')"></span></td><td width="100"><select name="vis_main_report'+num+'" id="vis_main_report'+num+'" onchange="changeReportOption('+num+')"><option value="0"><? echo $vis_language['TXTSUBJECT']; ?></option><option value="1"><? echo $vis_language['TXTMESSAGE']; ?></option><option value="2"><? echo $vis_language['TXTTICKETNOTE']; ?></option><option value="3"><? echo $vis_language['TXTTICKETCOMMENT']; ?></option><option value="4"><? echo $vis_language['TXTCLIENTNAME']; ?></option><option value="5"><? echo $vis_language['TXTCLIENTEMAIL']; ?></option><option value="6"><? echo $vis_language['TXTORGANIZATION']; ?></option><option value="7"><? echo $vis_language['TXTDEPARTMENT']; ?></option><option value="8"><? echo $vis_language['TXTSTATUS']; ?></option><option value="9"><? echo $vis_language['TXTPRIORITY']; ?></option><option value="21"><? echo $vis_language['TXTTICKETTYPE']; ?></option><option value="10"><? echo $vis_language['TXTOWNER']; ?></option><option value="11"><? echo $vis_language['TXTFLAG']; ?></option><option value="12"><? echo $vis_language['TXTLASTACTIVITY']; ?></option><option value="16"><? echo $vis_language['TXTCREATIONDATE']; ?></option><option value="15"><? echo $vis_language['TXTSLAPLAN']; ?></option><option value="17"><? echo $vis_language['TXTDUETIME']; ?></option><option value="19"><? echo $vis_language['TXTHASATTACHMENT']; ?></option><option value="20"><? echo $vis_language['TXTBILLINGNOTE']; ?></option></select></td><td width="50" id="vis_condition_option'+num+'"><select name="vis_sub_report'+num+'" id="vis_sub_report'+num+'"><option value="0"><? echo $vis_language['TXTCONTAIN']; ?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN']; ?></option><option value="2"><? echo $vis_language['TXTEQUAL']; ?></option><option value="3"><? echo $vis_language['TXTNOTEQUAL']; ?></option></select></td><td id="vis_condition_text'+num+'"><input name="vis_report_text'+num+'" id="vis_report_text'+num+'" type="text" class="vis_input" /></td></tr></table>';
        newDiv.id="vis_report_sub_condition"+num;
        newDiv.innerHTML=newCritera;
        document.getElementById("vis_report_options").appendChild(newDiv);
    }
    function changeReportOption(num) {
        var mainOpt=document.getElementById("vis_main_report"+num).value;
        var subOpt=document.getElementById("vis_condition_option"+num);
        var subTxt=document.getElementById("vis_condition_text"+num);
        if(mainOpt==0 || mainOpt==4 || mainOpt==5 || mainOpt==26) {
            subOpt.innerHTML='<select name="vis_sub_report'+num+'" id="vis_sub_report'+num+'"><option value="0"><? echo $vis_language['TXTCONTAIN']; ?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN']; ?></option><option value="2"><? echo $vis_language['TXTEQUAL']; ?></option><option value="3"><? echo $vis_language['TXTNOTEQUAL']; ?></option></select>';
        }
        else if(mainOpt==1 || mainOpt==2 || mainOpt==3 || mainOpt==20) {
            subOpt.innerHTML='<select name="vis_sub_report'+num+'" id="vis_sub_report'+num+'"><option value="0"><? echo $vis_language['TXTCONTAIN']; ?></option><option value="1"><? echo $vis_language['TXTDOESNOTCONTAIN']; ?></option></select>';
        }
        else if(mainOpt==6 || mainOpt==7 || mainOpt==8 || mainOpt==9 || mainOpt==10 || mainOpt==11 || mainOpt==21 || mainOpt==15 || mainOpt==18 || mainOpt==19 || mainOpt==27 || mainOpt==28 || mainOpt==29) {
            subOpt.innerHTML='<select name="vis_sub_report'+num+'" id="vis_sub_report'+num+'"><option value="0"><? echo $vis_language['TXTEQUAL']; ?></option><option value="1"><? echo $vis_language['TXTNOTEQUAL']; ?></option></select>';
        }
        else if(mainOpt==12 || mainOpt==13 || mainOpt==14 || mainOpt==16 || mainOpt==17 || mainOpt==22 || mainOpt==23 || mainOpt==24 || mainOpt==25 || mainOpt==30 || mainOpt==31 || mainOpt==32 || mainOpt==33 || mainOpt==34) {
            subOpt.innerHTML='<select name="vis_sub_report'+num+'" id="vis_sub_report'+num+'"><option value="0"><? echo $vis_language['TXTLESSTHAN']; ?></option><option value="1"><? echo $vis_language['TXTGREATEREQLTHAN']; ?></option></select>';
        }
        if(mainOpt==0 || mainOpt==1 || mainOpt==2 || mainOpt==3 || mainOpt==4 || mainOpt==5 || mainOpt==20 || mainOpt==22 || mainOpt==24 || mainOpt==25 || mainOpt==26 || mainOpt==29 || mainOpt==30 || mainOpt==31 || mainOpt==32 || mainOpt==33 || mainOpt==35) {
            subTxt.innerHTML='<input name="vis_report_text'+num+'" id="vis_report_text'+num+'" type="text" value="" class="vis_input" />';
        }
        else if(mainOpt==6) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($user_groups);$i++) $temp.='<option value="'.$user_groups[$i]['group_id'].'">'.$user_groups[$i]['group_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==7) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($departments);$i++) $temp.='<option value="'.$departments[$i]['department_id'].'">'.$departments[$i]['domain_name'].' :: '.$departments[$i]['department_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==8) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($status);$i++) $temp.='<option value="'.$status[$i]['status_id'].'">'.$status[$i]['status_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==9) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($priorities);$i++) $temp.='<option value="'.$priorities[$i]['priority_id'].'">'.$priorities[$i]['priority_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==10) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'"><option value="0">'.$vis_language['TXTUNASSIGNED'].'</option>';
            for($i=0;$i<count($owner);$i++) $temp.='<option value="'.$owner[$i]['staff_id'].'">'.$owner[$i]['first_name'].' '.$owner[$i]['last_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==11) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($flags);$i++) $temp.='<option value="'.$flags[$i]['flag_id'].'" style="background-color:#'.$flags[$i]['flag_color'].'">'.$flags[$i]['flag_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==12 || mainOpt==13 || mainOpt==14 || mainOpt==16 || mainOpt==17 || mainOpt==23) {
            subTxt.innerHTML='<input name="vis_report_text'+num+'" id="vis_report_text'+num+'" type="text" value="" />';
            $( "#vis_report_text"+num ).datetimepicker({showButtonPanel: true, dateFormat: 'yy-mm-dd'});
        }
        else if(mainOpt==15) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($sla);$i++) $temp.='<option value="'.$sla[$i]['sla_id'].'">'.$sla[$i]['sla_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."';"; ?>
        }
        else if(mainOpt==18 || mainOpt==19 || mainOpt==27 || mainOpt==28) {
            subTxt.innerHTML='<select name="vis_report_text'+num+'" id="vis_report_text'+num+'"><option value="0">True</option></select>';
        }
        else if(mainOpt==21) { <?
            $temp='<select name="vis_report_text\'+num+\'" id="vis_report_text\'+num+\'">';
            for($i=0;$i<count($ticket_types);$i++) $temp.='<option value="'.$ticket_types[$i]['type_id'].'">'.$ticket_types[$i]['type_name'].'</option>';
            $temp.='</select>';
            echo "subTxt.innerHTML='".$temp."'"; ?>
        }
    }
    function close_condition(num) {
        document.getElementById("vis_report_sub_condition"+num).innerHTML="";
    }
    function reset_filter() {
        document.getElementById("vis_report_options").innerHTML="";
        document.getElementById("total_conditions").value=0;
        add_condition();
    }
    add_condition();
</script>