<?php 

$title = 'Search HFA Rejection';
$thePage = $this->page;
$thePageRecord = $this->pageRecord;?>

<script>
$(document).ready(function(){
    $("#rejectedReason").multiselect();
    $('#refineResults').show();
    $('#requestFrom, #requestTo').datepicker({
        dateFormat: 'yy-mm-dd',
        showOn: 'both',
        buttonImage: '/images/icoCalendar.gif',
        buttonImageOnly: true,
        changeMonth: true,
        changeYear: true
    });
    $('#ui-datepicker-div').hide();
    addCalendar('Cal1', 'Select Date', 'requestFrom', 'search_hfarejection_request');
    addCalendar('Cal2', 'Select Date', 'requestTo', 'search_hfarejection_request');

    $("#search_hfarejection_request").submit(function(){
        var isFormValid = true;
        var startDate = new Date($('#requestFrom').val());
        var endDate = new Date($('#requestTo').val());

        if (startDate !="" && endDate!="") {
            if (startDate > endDate) {
                isFormValid = false;
                alert('From Date should be less than To Date');
            }
        }
        var checkVal = false;
        $("#search_hfarejection_request input:text").each(function(){
            var formVal = $.trim($(this).val());
            $(this).val(formVal);
            if ($.trim($(this).val()).length > 0) {
                checkVal = true;
            }
        });
        if (!checkVal) {
            if ($('#rejectedReason option:selected').length == 0) {
                isFormValid = false;
                alert('You must fill in at least one field to search.');
            }
        }
        return isFormValid;
    });
});
</script>

<div>
    <?php $this->placeholder('breadcrumb')->set('<a href="/relationships.php">Relationships</a> > Search HFA Rejection'); ?>	
    <div class="panelHeader">
        <h3><?=$title?></h3>
    </div>
    <div class="panelContent">
        <div id="refineResults" class="panelSummary notDisplay refineText ">
            <form id= "search_hfarejection_request" name="search_hfarejection_request" action="/hfarejection/viewhfarejection" method="get">
                <input type="hidden" name="page" id="page" value="1" /> 
                <input type="hidden" name="pageRecord" id="pageRecord" value="20" />
                <table class="form" style="width:100%;">
                    <tr>
                        <th>Label ID:</th>
                        <td colspan="2"><input name="vendorId" maxlength="20" id="vendorId" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>Label Name:</th>
                        <td colspan="2"><input name="vendorName" maxlength="100" id="vendorName" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>Subaccount Name:</th>
                        <td colspan="2"><input name="subAccountName" maxlength="100" id="subAccountName" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>Release Name:</th>
                        <td colspan="2"><input name="releaseName" maxlength="100" id="releaseName" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>UPC:</th>
                        <td colspan="2"><input name="upc" maxlength="20" id="upc" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>Track Unique ID:</th>
                        <td colspan="2"><input name="trackId" maxlength="20" id="trackId" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>Track Name:</th>
                        <td colspan="2"><input name="trackName" maxlength="100" id="trackName" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>ISRC:</th>
                        <td colspan="2"><input name="isrc" maxlength="20" id="isrc" class="small" value=""></input></td>
                    </tr>
                    <tr>
                        <th>HFA Request Date Range</th>
                        <td colspan="2">
                           <input name="requestFrom" id="requestFrom" class="textFieldDate small" value="" maxlength="10" onclick="$('#requestFrom').datepicker({dateFormat: 'yy-mm-dd',showOn: 'both',buttonImage: '/images/icoCalendar.gif',buttonImageOnly: true});"></input>&nbsp;<strong>And</strong>
                           <input name="requestTo" id="requestTo" class="textFieldDate small" value="" maxlength="10" onclick="$('#requestTo').datepicker({dateFormat: 'yy-mm-dd',showOn: 'both',buttonImage: '/images/icoCalendar.gif',buttonImageOnly: true});"></input>&nbsp;
                       	</td>
                    </tr>
                    <tr>
                        <th>Rejected Reason:</th>
                        <td colspan="2">
                            <select id="rejectedReason" name="rejectedReason[]" class="small" multiple="multiple" size="10">
                            <?php foreach ($this->hfaStatusResult as $eachHfaStatusResult) { ?>
                                <option value="<?php echo $eachHfaStatusResult->hfaStatusCode;?>"><?php echo $eachHfaStatusResult->definition;?></option>
                            <?php } ?>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <th>Suggested Fix:</th>
                        <td colspan="2"><input name="orchardEstimateFixForReason" maxlength="100" id="orchardEstimateFixForReason" class="small" value=""></input></td>
                    </tr>
                </table>
                <div class="panelButtons">
                    <input class="btn btn-primary btn-sm" type="submit" value="Search" id="search"/>
                    <input type="reset" value="Clear All" class="btn btn-default btn-sm"/>
                </div>
            </form>
        </div>
    </div>
</div>
