<?php include_once "header.php" ?>
<?php

$user->log($user_id, 7, "");

function build_table($array){
  // start table
  $html = '<table class="responsive-table bordered striped"><thead>';
  // header row
  $html .= '<tr>';
  foreach($array[0] as $key=>$value){
          $html .= '<th>' . $key . '</th>';
      }
  $html .= '</tr></thead><tbody>';

  // data rows
  foreach( $array as $key=>$value){
      $html .= '<tr>';
      foreach($value as $key2=>$value2){
        $html .= '<td>' . $value2 . '</td>';
      }
      $html .= '</tr>';
  }

  // finish table and return it

  $html .= '</tbody></table>';
  return $html;
}

// Open connection
if (!isset($conn)) $conn = ew_Connect();

$user_id_withrank = trim(ew_RemoveXSS(ew_StripSlashes($_SESSION['ARMYNOWITHRANK'])));

// KIOSK 3 - Withdrawal
$sql = "SELECT  PersonnelName
               ,StatusWithdrawal
               ,Address1
               ,Address2
               ,Address3
               ,Postcode
               ,City
               ,State
               ,ChequeWithdrawalDate
               ,ModeOfPayment
               ,TotalPayment
          FROM [dbo].[LTAT_tbl_withdrawal]
         WHERE PersonnelID='$user_id_withrank'
       ";
$rs  = ew_Execute($sql);
if ($rs->RecordCount() > 0) {
  $rs->MoveFirst();
  $sData = "";
  $myarray = array();
  while ($rs && !$rs->EOF) {
    if ($rs->fields['StatusWithdrawal']=='01'){ // persaraan
      $name1                        = $rs->fields['PersonnelName'              ]; 
      $statuswithdrawal1            = $rs->fields['StatusWithdrawal'           ];
      $address11                    = $rs->fields['Address1'                   ];
      //die($address11);
      $address21                    = $rs->fields['Address2'                   ];
      $address31                    = $rs->fields['Address3'                   ];
      $postcode1                    = $rs->fields['Postcode'                   ];
      $city1                        = $rs->fields['City'                       ];
      $state1                       = $rs->fields['State'                      ];
      $chequewithdrawaldate1        = $rs->fields['ChequeWithdrawalDate'       ];
      $modeofpayment1               = $rs->fields['ModeOfPayment'              ];
      $totalpayment1                = $rs->fields['TotalPayment'               ];
      //$balancedate1     = date("Y-m-d", strtotime($rs->fields['BalanceDate']));

      // $myarray[] = array('Status Pengeluaran'=>$statuswithdrawal, 'Alamat #1'=>$address1, 'Alamat #2'=>$address2);
    } else if ($rs->fields['StatusWithdrawal']=='02'){ // perumahan
      $name2                        = $rs->fields['PersonnelName'              ]; 
      $statuswithdrawal2            = $rs->fields['StatusWithdrawal'           ];
      $address12                    = $rs->fields['Address1'                   ];
      $address22                    = $rs->fields['Address2'                   ];
      $address32                    = $rs->fields['Address3'                   ];
      $postcode2                    = $rs->fields['Postcode'                   ];
      $city2                        = $rs->fields['City'                       ];
      $state2                       = $rs->fields['State'                      ];
      $chequewithdrawaldate2        = $rs->fields['ChequeWithdrawalDate'       ];
      $modeofpayment2               = $rs->fields['ModeOfPayment'              ];
      $totalpayment2                = $rs->fields['TotalPayment'               ];
    } else if ($rs->fields['StatusWithdrawal']=='03'){ // haji
      $name3                        = $rs->fields['PersonnelName'              ]; 
      $statuswithdrawal3            = $rs->fields['StatusWithdrawal'           ];
      $address13                    = $rs->fields['Address1'                   ];
      $address23                    = $rs->fields['Address2'                   ];
      $address33                    = $rs->fields['Address3'                   ];
      $postcode3                    = $rs->fields['Postcode'                   ];
      $city3                        = $rs->fields['City'                       ];
      $state3                       = $rs->fields['State'                      ];
      $chequewithdrawaldate3        = $rs->fields['ChequeWithdrawalDate'       ];
      $modeofpayment3               = $rs->fields['ModeOfPayment'              ];
      $totalpayment3                = $rs->fields['TotalPayment'               ];
    }

    $rs->MoveNext();
  }
  //echo $sData;
  $rs->Close();
} else {
  //$this->setFailureMessage("No records are found.");
}

//print_r($myarray);


?>

<!-- Full Width Column -->
<div class="content-wrapper">
    <div class="container">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            Withdrawal
            <small>Withdrawal Enquiry</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i class="active">Home</a></li>
            <li>Withdrawal</li>
          </ol>
        </section>    
    
        <!-- Main content -->
        <section class="content">
            <!-- Default box -->
            <div class="box box-primary">
                <div class="box-body">
                    <div class="row">

                        <div class="col-md-12">
                          <!-- Custom Tabs (Pulled to the right) -->
                          <div class="nav-tabs-custom">
                            <ul class="nav nav-tabs pull-right">
                              <li><a href="#tab_1-1" data-toggle="tab">Haji</a></li>
                              <li><a href="#tab_2-2" data-toggle="tab">Housing</a></li>
                              <li class="active"><a href="#tab_3-2" data-toggle="tab">Retirement</a></li>
                              <li class="pull-left header"><i class="fa fa-th"></i> Withdrawal Status</li>
                            </ul>
                            <div class="tab-content">
                              <div class="tab-pane" id="tab_1-1">
                                  <table class="table table-striped table-bordered">
                                    <?php if ($name3==""){                                    
                                    
                                    ?>
                                      <tr>
                                        <td>Tiada maklumat pengeluaran haji setakat ini</td>
                                      </tr>
                                    <?php
                                      
                                    } else {
                                    ?>                                   
                                    <tr>
                                      <td><strong>Name:</strong></td><td><?php echo $name3; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Address:</strong></td><td><?php echo $address13."<br>".$address23."<br>".$address33 ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Poscode:</strong></td><td><?php echo $postcode3; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>City:</strong></td><td><?php echo $city3; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>State:</strong></td><td><?php echo $state3; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Withdrawal Date:</strong></td><td><?php echo $chequewithdrawaldate3; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Payment Method:</strong></td><td><?php echo $modeofpayment3; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>No. Rd:</strong></td><td><?php echo $modeofpayment3; ?></td>
                                    </tr>
                                    <?php
                                    }
                                    ?>                                     
                                  </table>
                              </div>
                              <!-- /.tab-pane -->
                              <div class="tab-pane" id="tab_2-2">
                                  <table class="table table-striped table-bordered">
                                    <?php if ($name2==""){                                    
                                    
                                    ?>
                                      <tr>
                                        <td>Tiada maklumat pengeluaran perumahan setakat ini</td>
                                      </tr>
                                    <?php
                                      
                                    } else {
                                    ?>                                    
                                    <tr>
                                      <td><strong>Name:</strong></td><td><?php echo $name2; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Address:</strong></td><td><?php echo $address12."<br>".$address22."<br>".$address32 ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Poscode:</strong></td><td><?php echo $postcode2; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>City:</strong></td><td><?php echo $city2; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>State:</strong></td><td><?php echo $state2; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Withdrawal Date:</strong></td><td><?php echo $chequewithdrawaldate2; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Payment Method:</strong></td><td><?php echo $modeofpayment2; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>No. Rd:</strong></td><td><?php echo $modeofpayment2; ?></td>
                                    </tr>
                                    <?php
                                      }
                                    ?>                                    
                                  </table>

                              </div>
                              <!-- /.tab-pane -->
                              <div class="tab-pane active" id="tab_3-2">
                                  <table class="table table-striped table-bordered">
                                    <?php if ($name1==""){
                                    
                                    
                                    ?>
                                      <tr>
                                        <td>Tiada maklumat pengeluaran persaraan setakat ini</td>
                                      </tr>
                                    <?php
                                      
                                    } else {
                                    ?>                                  
                                    <tr>
                                      <td><strong>Name:</strong></td><td><?php echo $name1; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Address:</strong></td><td><?php echo $address11."<br>".$address21."<br>".$address31 ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Poscode:</strong></td><td><?php echo $postcode1; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>City:</strong></td><td><?php echo $city1; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>State:</strong></td><td><?php echo $state1; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Withdrawal Date:</strong></td><td><?php echo $chequewithdrawaldate1; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>Payment Method:</strong></td><td><?php echo $modeofpayment1; ?></td>
                                    </tr>
                                    <tr>
                                      <td><strong>No. Rd:</strong></td><td><?php echo $modeofpayment1; ?></td>
                                    </tr>
                                    <?php
                                    }
                                    ?>                                    
                                  </table>
                              </div>
                              <!-- /.tab-pane -->
                            </div>
                            <!-- /.tab-content -->
                          </div>
                          <!-- nav-tabs-custom -->
                        </div>
                        <!-- /.col -->
                    

<!--
<h5>Semakan Pengeluaran</h5>

  <div class="row">
    <div class="col s12">
      <ul class="tabs">
        <li class="tab col s3"><a class="active" href="#test1">Persaraan</a></li>
        <li class="tab col s3"><a href="#test2">Perumahan</a></li>
        <li class="tab col s3"><a href="#test3">Haji</a></li>
      </ul>
    </div>
    <div id="test1" class="col s12">
      
      <p>
        <div class="row">
          <div class="col s8 offset-s2">
            <table class="responsive-table bordered striped">
              <tr>
                <td><strong>Nama:</strong></td><td><?php echo $address1; ?></td>
              </td>
              <tr>
                <td><strong>Alamat:</strong></td><td><?php echo $address1."<br>".$address2."<br>".$address3 ?></td>
              </td>
              <tr>
                <td><strong>Poskod:</strong></td><td><?php echo $postcode; ?></td>
              </td>
              <tr>
                <td><strong>Bandar:</strong></td><td><?php echo $city; ?></td>
              </td>
              <tr>
                <td><strong>Negeri:</strong></td><td><?php echo $state; ?></td>
              </td>
              <tr>
                <td><strong>Tarikh Pengeluaran:</strong></td><td><?php echo $chequewithdrawaldate; ?></td>
              </td>
              <tr>
                <td><strong>Cara Pembayaran:</strong></td><td><?php echo $modeofpayment; ?></td>
              </td>
              <tr>
                <td><strong>No. Rd:</strong></td><td><?php echo $modeofpayment; ?></td>
              </td>
            </table>
          </div>
        </div>
      </p>
      
    </div>
    <div id="test2" class="col s12">
      
      <p>
        <div class="row">
          <div class="col s8 offset-s2">
            <table class="responsive-table bordered striped">
              <tr>
                <td><strong>Nama:</strong></td><td><?php echo $address2; ?></td>
              </td>
              <tr>
                <td><strong>Alamat:</strong></td><td><?php echo $address12."<br>".$address22."<br>".$address32 ?></td>
              </td>
              <tr>
                <td><strong>Poskod:</strong></td><td><?php echo $postcode2; ?></td>
              </td>
              <tr>
                <td><strong>Bandar:</strong></td><td><?php echo $city2; ?></td>
              </td>
              <tr>
                <td><strong>Negeri:</strong></td><td><?php echo $state2; ?></td>
              </td>
              <tr>
                <td><strong>Tarikh Pengeluaran:</strong></td><td><?php echo $chequewithdrawaldate2; ?></td>
              </td>
              <tr>
                <td><strong>Cara Pembayaran:</strong></td><td><?php echo $modeofpayment2; ?></td>
              </td>
              <tr>
                <td><strong>No. Rd:</strong></td><td><?php echo $modeofpayment2; ?></td>
              </td>
            </table>
          </div>
        </div>
      </p>
      

    </div>
    <div id="test3" class="col s12">
      
      <p>
        <div class="row">
          <div class="col s8 offset-s2">
            <table class="responsive-table bordered striped">
              <tr>
                <td><strong>Nama:</strong></td><td><?php echo $address3; ?></td>
              </td>
              <tr>
                <td><strong>Alamat:</strong></td><td><?php echo $address13."<br>".$address23."<br>".$address33 ?></td>
              </td>
              <tr>
                <td><strong>Poskod:</strong></td><td><?php echo $postcode3; ?></td>
              </td>
              <tr>
                <td><strong>Bandar:</strong></td><td><?php echo $city3; ?></td>
              </td>
              <tr>
                <td><strong>Negeri:</strong></td><td><?php echo $state3; ?></td>
              </td>
              <tr>
                <td><strong>Tarikh Pengeluaran:</strong></td><td><?php echo $chequewithdrawaldate3; ?></td>
              </td>
              <tr>
                <td><strong>Cara Pembayaran:</strong></td><td><?php echo $modeofpayment3; ?></td>
              </td>
              <tr>
                <td><strong>No. Rd:</strong></td><td><?php echo $modeofpayment3; ?></td>
              </td>
            </table>
          </div>
        </div>
      </p>
      
    </div>
  </div>
  -->

<!--
<div>
<?php //echo build_table($myarray); ?>
</div>
-->


                    </div>
                    <!-- /.row -->
                </div>   
                <!-- /.box-body -->
            </div>
            <!-- /.box -->
        </section>
        <!-- /.content -->
    </div>
    <!-- /.container -->
</div>
<!-- /.content-wrapper -->



<?php include_once "footer.php" ?>