<? global $vis_language; $class='';$remark_flag=0;?>
<div  class="wrapper-sm m-b-none m-t">
	<?php if($total_aprovals>0){
			for($i=0;$i<$total_aprovals;$i++){
				$aprove_status = $aprovals_details[$i]['aprovals_status'];
				$dates = format_datetime($aprovals_details[$i]['status_date']);
				
				if($aprove_status==0){ 
					$date_label = $vis_language['TXTSENTON'];
					$status = $vis_language['TXTREQUESTED'];$lbl='vh-blue-bg';
					$dates = format_datetime($aprovals_details[$i]['send_date']);
				} 
				else if($aprove_status==1){ 
					$date_label = $vis_language['TXTAPPROVEDON'];
					$status =$vis_language['TXTAPPROVED'];$lbl='vh-green-bg';
				}
				else if($aprove_status==2){
					$date_label = $vis_language['TXTCANCELEDON'];
					$status =$vis_language['TXTCANCELED']; $lbl='label-default';
				}
				else if($aprove_status==3){
					$date_label = $vis_language['TXTREJECTEDON'];
					$status =$vis_language['TXTITILREJECTED']; $lbl='vh-red-bg';
				} 
			?>
				<div class="row">
					<div class="col-sm-3 m-t-xs">
						<label><a href="#/home/profile_view/Profile/<?=$aprovals_details[$i]['staff_id']?>"><i class="vh vh-staff"></i></a></label>
						<span class="m-l-sm"><? echo $aprovals_details[$i]['first_name'].' '.$aprovals_details[$i]['last_name'];?></span>
					</div> 
					
					<div class="col-sm-3 m-t-xs">
						<label><? echo $date_label; ?></label>
						<span class="m-l-sm"><? echo $dates;?></span>
					</div>
					<div class="col-sm-3 m-t-xs">
						<span class="m-l-sm"><?php if($aprove_status==0){ 
								if($aprovals_details[$i]['staff_id']==VIS_STAFF_ID){?>
									<!--<a class="link"  href="javascript:void(0);" onclick="change_status(<? echo $aprovals_details[$i]['aprovals_id'].', 1, '.$aprovals_details[$i]['staff_id'];?>);" title="<? echo $vis_language['TXTAPPROVE']; ?>"><?= $vis_language['TXTAPPROVE'];?></a> / 
									
									<a class="link"  href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=reject_aprovals&from=changes&vis_changes_id=<? echo $changes_details['changes_id'];?>&vis_aprovals_id=<? echo $aprovals_details[$i]['aprovals_id'];?>" title="<? echo $vis_language['TXTITILREJECT']; ?>"><?= $vis_language['TXTITILREJECT'];?></a>-->
							<?php }else {?>
									<a class="link"  href="javascript:void(0);" onclick="send_aprovals(<? echo $aprovals_details[$i]['aprovals_id'].', '.$aprovals_details[$i]['staff_id'];?>);" title="<? echo $vis_language['TXTSENDREMINDER']; ?>"><?= $vis_language['TXTSENDREMINDER'];?></a> / 
									
									<a class="link"  href="javascript:void(0);" onclick="change_status(<? echo $aprovals_details[$i]['aprovals_id'].', 2, '.$aprovals_details[$i]['staff_id'];?>);" title="<? echo $vis_language['TXTCANCEL']; ?>"><?= $vis_language['TXTCANCEL'];?></a>
							<?php }
						}?></span>
					</div>
					<div class="col-sm-2 m-t-xs ">
						<span class=" pull-right"><label class="label <?php echo $lbl;?>"><?php $status;?><? echo $status; ?></label></span>
					</div>
					<div class="col-sm-1 m-t-xs">
						<?php $remarks_flag=0;
						for($j=0;$j<$total_remark;$j++){
							if($aprovals_details[$i]['staff_id'] == $remark_details[$j]['staff_id']){$remarks_flag=1;}}?>
						<span class="link pull-left"><a href="javascript:void(0);" onclick="$('#remarks_<?php echo $aprovals_details[$i]['staff_id'];?>').toggle();"> <? if($remarks_flag==1) echo $vis_language['TXTREMARKS'];?></a></span>
					</div>
				</div>
				<div id="remarks_<?php echo $aprovals_details[$i]['staff_id'];?>" style="display:none;">
					<?php for($j=0;$j<$total_remark;$j++){
						if($aprovals_details[$i]['staff_id'] == $remark_details[$j]['staff_id']){
							if($remark_flag==0){?>
								<div class="row">
									<div class="col-sm-3">
										<label class='font-bold'><? echo $vis_language['TXTREMARKS'];?></label>
									</div> 
								</div>
							<?php $remark_flag=1; }	?>
							<div class="row">
								<div class="col-sm-12">
									<span class="m-l-lg"><? echo format_datetime($remark_details[$j]['send_date']);?> - <?php echo $remark_details[$j]['remark'];?></span>
								</div> 
							</div>
						<?php }
					} ?>
				</div>	
			<?php
			}
		}?>
		<div class="row">
			<div class="col-sm-12 m-t-xs">
				<?php if($total_aprovals==0){ $class="m-l-sm";?><label><? echo  $vis_language['TXTNOAPROVALS'];?></label><?php }?>
				<span class="<?php echo $class;?>"><a class="link"  href="javascript:void(0);" data-toggle="ajaxModal" data-modal-arguments="vis_module=changes&vis_operation=send_aprovals&from=changes&vis_changes_id=<? echo $changes_details['changes_id'];?>&vis_dept_id=<? echo $changes_details['department_id'];?>" title="<? echo $vis_language['TXTREQUESTAPROVALS']; ?>"><?= $vis_language['TXTREQUESTAPROVALS'];?></a></span>
			</div>	
		</div>
</div>
<script>
		
	function send_aprovals(id, staff_id) {
		var data = { vis_changes_id:"<?=$changes_details['changes_id'];?>", aprove_id:id, staff_id:staff_id};
		$.ajax({
			url: 'index.php?vis_module=<?=$operation['vis_module'];?>&vis_operation=send_aprove_reminder',
			data: data,
			type: "POST",
			success: function(data) {
				$('#vis_global_msg_div').visInterface('load_global_message', '<?php echo $vis_language['MSGSUCCOPRT'];?>');
			},
			error: function(xhr, ajaxOptions, thrownError) {$("#vis_global_msg_div").visInterface("load_global_message", "Error: "+xhr.status+" - "+thrownError);}
		});
		
	}
</script>