<?php
session_start();
include("../../php_crud/my_class.php");
$obj = new my_class();
$user_id = $_SESSION['LOGIN_USERID'];
extract($_GET);
$user_info = $obj->View_column_details_By_Cond("ST_USER_INFO", "USER_GROUP_ID,OFFICE_ID", "USER_ID='$user_id'");
//$user_group_id = $user_info['USER_GROUP_ID'];
$user_office_id = $user_info['OFFICE_ID'];
?>
<table id="sender_list_tbl" class="table table-striped table-bordered table-hover">
    <thead>
        <tr style="font-family: 'Open Sans';">
            <th style="text-align: center;">Sl</th>
			<th style="text-align: center;">Sender's Name</th>
			<th style="text-align: center;">Mobile Number</th>
			<th style="text-align: center;">Office Name</th>
			<th style="text-align: center;">Status</th>
            <th style="text-align: center;">Action</th>
        </tr>
    </thead>
    <tbody>
        <?php
        $table_name =  "MDM_STATION_MASTER_LIST";
        if($office_status!="all"){
			$where_cond = "STATUS='$sender_status'";
		}
		else{
			$where_cond = "STATUS IN ('A','I')";
		}
		if($user_office_id!=""){
			$where_cond .= " AND OFFICE_ID='$user_office_id'";
		}
		
		$where_cond .=" ORDER BY ID ASC";
		//echo $where_cond;
        $row = $obj->View_all_data_row_column_By_Cond($table_name, ' * ', $where_cond);
        $sl = 0;
        foreach ($row as $index => $val) {
            $sl++;
			$id = $val['ID'];
			$sel_office_id = $val['OFFICE_ID'];
			
			$office_info = $obj->Details_By_Cond("MDM_OFFICE_LIST","ID='$sel_office_id'");
			
            $show_status = "";
			if($val['STATUS']=="A"){
				$show_status = '<span class="label label-success" style="padding: 5px;">Active</span>';
			}
			else{
				$show_status = '<span class="label label-warning" style="padding: 5px;">Inactive</span>';
			}
        ?>
			<tr>
            <td style="text-align: center;"><?php echo $sl; ?></td>
            <td style="text-align: left; padding-left: 5px;"><?php echo $val['PERSON_NAME']; ?></td>
            <td style="text-align: center;"><?php echo $val['MOBILE_NUMBER']; ?></td>
            <td style="text-align: left; padding-left: 5px;"><?php echo $office_info['OFFICE_NAME']; ?></td>
            <td style="text-align: center;"><?php echo $show_status; ?></td>
            <td style="justify-content: center; align-items:center; align-content:center; text-align:center;">
                <?Php
                if ($_SESSION['edit']=='Y') {
					echo '<a class="btn btn-mini btn-success" href="#modal_edit_sender_info" data-toggle="modal" style="margin-left: 10px;" onclick="load_edit_form('.$id.')"><i class="icon-edit"></i> Edit </a>';
              
				}
                // if ($_SESSION['delete'] == 'Y') {}
                ?>
            </td>
			</tr>
        <?php
        }
        ?>
    </tbody>
</table>
<script type="text/javascript">
    var oTable2 = $('#sender_list_tbl').dataTable({
        "aoColumns": [{
                "bSortable": true
            },
            null,null, null,null,
            {
                "bSortable": true
            }
        ],
        "iDisplayLength": 50
    });
</script>
