<head>
<style type="text/css">
button {
 	margin-left: 2px;
 	margin-right: 2px;
}

.modal-header {
	background-color: #3c8dbc;
	color: white;
}

</style>
</head>
<!-- Add Project Modal HTML -->
<div id="addTaskScheduleView" class="modal fade" style="overflow: auto;overflow-y: scroll;" tabindex="-1" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog" style="width: 60%;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Task Schedule</h4>
            </div>
            <div class="modal-body">
	            <div id="modalAddTaskScheduleHeaderViewContent">
	        	</div>
            </div>
            <div class="modal-footer">
            	<div id="modalAddTaskScheduleHeaderViewButtonContent">
			   </div>
            </div>
        </div>
    </div>
</div>

<!-- message Modal HTML -->
<div id="messageView" class="modal fade" style="overflow: auto;overflow-y: scroll;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" id="modalMessageHeaderContent">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="modalMessageViewTitle" >Message</h4>
            </div>
            
            <div class="modal-body">
	            <div id="modalMessageViewContent">
	        	</div>
            </div>
            
            <div class="modal-footer">
            	<div id="modalMessageButtonContent">
            		<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
			   </div>
            </div>
        </div>
    </div>
</div>

<!-- confirmation message Modal HTML -->
<div id="confirmationMessageView" class="modal fade" style="overflow: auto;overflow-y: scroll;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header" id="modalConfirmationMessageHeaderContent">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="modalConfirmationMessageViewTitle" >Message</h4>
            </div>
            
            <div class="modal-body">
	            <div id="modalConfirmationMessageViewContent">
	        	</div>
            </div>
            <div class="modal-footer">
            	<div id="modalcCnfirmationMessageButtonContent">
            		<button type="button" class="btn btn-default" data-dismiss="modal">Yes</button>
			   </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="activityLoadingModal" tabindex="-1" data-backdrop="static" data-keyboard="false">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="modalLoadingTitle">Processing...</h4>
            </div>
            <div class="modal-body">
                <div class="progress progress-striped active">
                    <div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:100%">
                        <span class="sr-only">70% Complete</span>
                      </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- Submit pop up Modal HTML -->
<div id="deleteTaskScheduleConfirmationView" class="modal fade" style="overflow: auto;overflow-y: scroll;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="modalDeleteTaskScheduleConfirmationTitle">Confirm Task Schedule Deletion</h4>
            </div>
            
            <div class="modal-body">
	            <div id="modalDeleteTaskScheduleConfirmationContent">
	            
	        	</div>
            </div>
            
            <div class="modal-footer">
            	<div id="modalDeleteTaskScheduleConfirmationButton">
			   </div>
            </div>
        </div>
    </div>
</div>

<input type="hidden" id="isManagerFilter" value="<?php echo isset($isManagerFilter) ? ($isManagerFilter ? 'true' : 'false' ) : 'false';?>" >

<div class="col-md-12" <?php echo isset($isManagerFilter) && $isManagerFilter ? "style='display:none'" : ''; ?>>
	
	<div class="filter-unit">
        <div class="filter-unit">
            <input  style="height: 30px;"  type="text" placeholder="From Date" id="fromDateScheduleFilter" size=10>
            <input  style="height: 30px;"  type="hidden" id="txtClaimDayLast" value="<?php echo $this->getClaimDayLastConfig(); ?>">
        </div>
        <div class="filter-unit">
            <input style="height: 30px;" type="text" placeholder="To Date"  id="toDateScheduleFilter" size=10>
        </div>
        <div class="filter-unit">
            <input  style="height: 30px;"  type="text" placeholder="Job Number" id="filterJobNumberSchedule">
        </div>
        <div class="filter-unit">
            <select style="height: 30px;" id="cobCustomerFilter" >
            <?php echo $this->getCustomerFilterOption(); ?>
            </select>
        </div>
        <div class="filter-unit">
            <select style="height: 30px;" id="cobStatusFilter" >
                <?php echo $this->getResultFilterOption(); ?>
            </select>
        </div>
		<a href="#" onclick="return filterTaskSchedule();" class="btn btn-primary btn-sm"><span class="fa fa-plus"></span> Filter</a>
	</div>
	<?php if(!isset($isManagerFilter) || $isManagerFilter == false) { ?>
	<div class="claim-btn">
		<table>
			<tr>
				<td style="text-align:right;display:none">
				</td>
			</tr>
		</table>
	</div>
	<?php } ?>
</div>

<div class="col-md-12" id="errorShow"></div>

<div class="col-md-12" style="margin-top: 20px">
	<div class="box" id="testData">
		<table class="table" style="width: 100%; max-width: 100%; margin-bottom: 20px;" id="task-schedule-table">
		</table>
	</div>
</div>
<script>
$(document).ready(function () {
    var claimDayLast = 30;
    if(!isNaN($('#txtClaimDayLast').val()))
        claimDayLast = parseInt($('#txtClaimDayLast').val());
    var date = new Date();
    var firstDay = new Date();
    var lastDay = new Date();
    var todayDate = new Date();
    var startDate = new Date(new Date().setDate(todayDate.getDate()-claimDayLast));
    
    firstDay.setFullYear(date.getFullYear(), date.getMonth(), 1);
    lastDay.setFullYear(date.getFullYear(), date.getMonth() + 1, 0);

    $('#fromDateScheduleFilter').datepicker({
        format: "dd/mm/yyyy"
    }); 
    $('#fromDateScheduleFilter').on('changeDate', function(ev){
        $(this).datepicker('hide');
    });
    
    $('#toDateScheduleFilter').datepicker({
        format: "dd/mm/yyyy"
    });

    $('#toDateScheduleFilter').on('changeDate', function(ev){
        $(this).datepicker('hide');
    });

    
    // last xx days
    $('#fromDateScheduleFilter').datepicker('setValue', (startDate.getDate() <= 9 ? "0" + startDate.getDate() : startDate.getDate()) + "/" + (startDate.getMonth()+1 <= 9 ? "0" + (startDate.getMonth()+1) : (startDate.getMonth()+1) ) + "/" + startDate.getFullYear());
    $('#toDateScheduleFilter').datepicker('setValue', (todayDate.getDate() <= 9 ? "0" + todayDate.getDate() : todayDate.getDate()) + "/" + (todayDate.getMonth()+1 <= 9 ? "0" + (todayDate.getMonth()+1) : (todayDate.getMonth()+1) ) + "/" + todayDate.getFullYear());

	filterTaskSchedule();
    getTaskScheduleAutoSearch();
});
</script>
