<?php
require_once("../layouts/members/head.php");
if ($user_data['voter_Mobile_Link_Service'] == "YES") {
if (in_array($user_data['usertype'], ['Master Distributor', 'Distributor', 'Retailer'])) {
?>
<div class="row">
    <div class="col-md-4 mb-2">
      <div class="card text-danger">
        <div class="card-header bg-primary text-white py-2">
          <div class="d-flex align-items-center">
            <span class="mr-auto"><?= file_name() ?></span>
             <button class="btn btn-dark btn-sm ml-auto" onclick="history.back()" > <i class="fas fa-arrow-left"></i> Back</button>
          </div>
        </div>
        <div class="p-3 text-dark">
          <?php
          $apiResponseData = null;

          if (isset($_POST['submit'])) {
              $voterNumber = strtoupper($_POST['voterNumber']);
              $mobileNumber = $_POST['mobileNumber'];
               
              if (!empty($voterNumber) && !empty($mobileNumber)) {
                  $amount = $user_data['voter_mobile_link_fee'];
                  $old_balance = $user_data['balance'];
                  $new_balance = $old_balance - $amount;

                  if ($user_data['balance'] >= $amount) {
                      $order_id = order_txn_id();
                      $request = [
                          'voterNumber'  => $voterNumber,
                          'mobileNumber' => $mobileNumber,
                          'order_id'     => $order_id,
                      ];

                      $responseApi = VoterMobileLink_DataUpload_run($request);
                      $response = json_decode($responseApi, true) ?? '';

                      if (isset($response['status']) && $response['status'] == '100') {
                          $updateSuccess = db_update("members", ["balance" => $new_balance], " user_id='" . $user_data['user_id'] . "' ");

                          if ($updateSuccess) {
                              $insData = [
                                  'site_id'       => $site_data['site_id'],
                                  'user_id'       => $user_data['user_id'],
                                  'username'      => $user_data['username'],
                                  'name'          => $user_data['name'],
                                  'operator'      => $user_data['usertype'],
                                  'parent_id'     => $user_data['parent_id'],
                                  'order_id'      => $order_id,
                                  'service'       => "VCM_Request",
                                  'type'          => "Debit",
                                  'account_number'=> $response['epicNumber'],
                                  'app_type'      => "VCM_Request",
                                  'amount'        => $amount,
                                  'main_amount'   => $amount,
                                  'old_balance'   => $old_balance,
                                  'new_balance'   => $new_balance,
                                  'txn_id'        => $order_id,
                                  'ref_id'        => $response['epicNumber'],
                                  'description'   => "Rs.{$amount} Has Been Debit From Wallet for VCM_Request By Epic Number ",
                                  'date_time'     => current_timestamp(),
                                  'status'        => "Process"
                              ];

                              $insertId = db_insert("reports", $insData);
                              if ($insertId) {
                                      $printDataprint = array(
                                        'voterNumber'  => $voterNumber,
                                        'mobileNumber' => $mobileNumber,
                                        'status'       => '',
                                        'name'         => '',
                                        'order_id'     => $order_id,
                                        'amount'       => $amount,
                                        'username'     => $user_data['username'],
                                    );

                                    $insDataprint = [
                                        'order_id'      => $order_id,
                                        'username'      => $user_data['username'],
                                        'name'          => $voterNumber,
                                        'idNumber'      => $voterNumber,
                                        'service'       => "VCM_Request",
                                        'date_time'     => current_timestamp(),
                                        'printData'     => base64_encode(str_replace("\\", "", json_encode($printDataprint, JSON_UNESCAPED_UNICODE))),
                                        'photo'         => "",
                                        'status'        => "Process",
                                    ];

                                    $insertPrintId = db_insert("printRecords", $insDataprint);
                                 if ($insertPrintId) {
                                 $fields = [
                                     'voterNumber' => 'Epic No',
                                     'name'        => 'Name',
                                     'mobileNumber'=> 'Mobile No',
                                     'message'     => 'Message',
                                 ];

                                 $whamessage = "Dear {$user_data['name']},\nYour Request for Epic Number *{$voterNumber}* Mobile Link has been Complete.\n\n";

                                 foreach ($fields as $key => $label) {
                                     if (!empty($response[$key])) {
                                         $whamessage .= "*$label*: {$response[$key]}\n";
                                     }
                                 }
                                 $whamessage .= "\nBest Regards,\n_*{$site_data['brand']}.*_";
                                 send_sms($user_data['mobile'],$whamessage);
                                   
                                   awal_alert_msg($response['message'] ?? 'Applied Successful Submitted.', 'success');
                                   redirect('vcmRequest', 3000);
                                 } else {
                                      awal_alert_msg("Saving Data Error!", 'error');
                                 }
                              } else {
                                  awal_alert_msg("Insert Server Error!", 'error');
                              }
                          } else {
                              awal_alert_msg("Balance debited from wallet but not updated in the database. Please contact support!", 'error');
                          }
                      } else {
                          awal_alert_msg($response['error'] ?? $response['message'] ?? 'Server Down', 'error');
                      }
                  } else {
                      awal_alert_msg("Insufficient Wallet Balance!", 'error');
                  }
              } else {
                  awal_alert_msg("Please Fill All Valid Details!", 'error');
              }
          }
          ?>
          <form action="" method="POST" class="row">
            <div class="col-md-12 mb-3">
              <label>Voter Number</label>
              <input type="text" name="voterNumber" placeholder="Enter Voter Number" maxlength="25" oninput="this.value = this.value.toUpperCase().replace(/\s+/g, '');" class="form-control" onkeypress="if(this.value.length==25) return false;" required>
            </div>
            <div class="col-md-12 mb-3">
              <label>Mobile Number</label>
              <input type="number" name="mobileNumber" placeholder="954785****" maxlength="10" oninput="this.value = this.value.toUpperCase().replace(/\s+/g, '');" class="form-control" onkeypress="if(this.value.length==10) return false;" required>
            </div>
            <div class="col-md-12 mb-3 d-flex justify-content-between">
              <button type="button" class="btn btn-secondary" ><i class="fas fa-inr"></i> <?php echo $user_data['voter_mobile_link_fee'];?></button>
              <button type="submit" name="submit" class="btn btn-primary" onclick="return confirm('Are you sure?');">Submit</button>
              <button type="button" class="btn btn-warning" data-toggle="modal" data-target="#showDetailsModal">Show</button>
            </div>
          </form>
        </div>
      </div>
    </div>

<div class="col-md-8 mb-2">
      <div class="card text-danger">
        <div class="card-header bg-info text-white py-2">
          <span><i class="fa-solid fa-gear"></i> Service Information &amp; Instructions</span>
        </div>
        <div class="p-3 text-dark">
          <div class="alert alert-dark">
            <h5><i class="fas fa-info-circle"></i> Service Details</h5>
            <ul class="mb-0">
              <li><b>Service:</b> Voter Mobile Number Linking (Instant)</li>
              <li><b>Amount:</b> <i class="fas fa-inr"></i> <?php echo $user_data['voter_mobile_link_fee'];?>.00</li>
              <li><b>Processing Time:</b> 10 minutes to 12 hour</li>
            </ul>
          </div>
          
          <div class="alert alert-info">
            <h5><i class="fas fa-headset"></i> Support</h5>
            <p class="mb-0">
              <h6 class="btn btn-sm" style="background:#992b23;color:white;">
                Refund Not Possible within between 24 hour.
              </h6>
            </p>
          </div>
        </div>
      </div>
    </div>

<!-- ===================== VCM REQUEST HISTORY ===================== -->
<div class="col-md-12 mb-3">
  <div class="card">
    <div class="card-header bg-primary text-white py-2">
      <div class="d-flex align-items-center">
        <span class="mr-auto">
          <i class="fas fa-history"></i> VCM Request History
        </span>
      </div>
    </div>

    <div class="card-body p-0">
      <?php
      $historyPerPage = 10;
      $historyPage = isset($_GET['vcm_page']) ? (int)$_GET['vcm_page'] : 1;

      if ($historyPage < 1) {
          $historyPage = 1;
      }

      // Safe username without depending on an undefined $conn variable.
      $historyUsername = str_replace(
          ["\\", "'"],
          ["\\\\", "\\'"],
          (string)($user_data['username'] ?? '')
      );

      $historyCondition = "service = 'VCM_Request' AND username = '{$historyUsername}'";
      $allVcmHistory = db_fetch_all(
          "printRecords",
          $historyCondition . " ORDER BY id DESC"
      );

      if (!is_array($allVcmHistory)) {
          $allVcmHistory = [];
      }

      $totalHistoryRecords = count($allVcmHistory);
      $totalHistoryPages = (int)ceil(
          $totalHistoryRecords / $historyPerPage
      );

      if (
          $totalHistoryPages > 0
          && $historyPage > $totalHistoryPages
      ) {
          $historyPage = $totalHistoryPages;
      }

      $historyOffset = ($historyPage - 1) * $historyPerPage;
      $vcmHistoryRecords = array_slice(
          $allVcmHistory,
          $historyOffset,
          $historyPerPage
      );
      ?>

      <div class="table-responsive">
        <table class="table table-bordered table-striped table-hover mb-0">
          <thead class="bg-light text-dark">
            <tr class="text-center">
              <th>SL No.</th>
              <th>Order ID</th>
              <th>Date</th>
              <th>Voter Number</th>
              <th>Mobile Number</th>
              <th>Status</th>
              <th>Action</th>
            </tr>
          </thead>

          <tbody>
          <?php if (!empty($vcmHistoryRecords)) { ?>
            <?php
            $historySl = $historyOffset + 1;

            foreach ($vcmHistoryRecords as $historyRecord) {
                $historyPrintData = [];
                $historyApiData = [];

                $decodedHistoryData = base64_decode(
                    $historyRecord['printData'] ?? '',
                    true
                );

                if ($decodedHistoryData !== false) {
                    $decodedHistoryJson = json_decode(
                        $decodedHistoryData,
                        true
                    );

                    if (is_array($decodedHistoryJson)) {
                        $historyPrintData = $decodedHistoryJson;
                    }
                }

                if (!empty($historyRecord['api_response'])) {
                    $decodedApiData = base64_decode(
                        $historyRecord['api_response'],
                        true
                    );

                    if ($decodedApiData === false) {
                        $decodedApiData = $historyRecord['api_response'];
                    }

                    $decodedApiJson = json_decode(
                        $decodedApiData,
                        true
                    );

                    if (is_array($decodedApiJson)) {
                        $historyApiData = $decodedApiJson;
                    }
                }

                $historyData = array_merge(
                    $historyPrintData,
                    $historyApiData
                );

                $historyOrderId = $historyRecord['order_id']
                    ?? $historyData['order_id']
                    ?? '';

                $historyVoterNumber = $historyData['voterNumber']
                    ?? $historyData['epicNumber']
                    ?? $historyData['voter_number']
                    ?? $historyRecord['idNumber']
                    ?? '';

                $historyMobileNumber = $historyData['mobileNumber']
                    ?? $historyData['MobileNumber']
                    ?? $historyData['mobile_number']
                    ?? $historyData['mobile']
                    ?? '';

                $historyName = $historyData['name']
                    ?? $historyData['fullName']
                    ?? $historyRecord['name']
                    ?? '';

                $historyReferenceNo = $historyData['refrenceNo']
                    ?? $historyData['referenceNo']
                    ?? $historyData['reference_number']
                    ?? '';

                $historyState = $historyData['state']
                    ?? $historyData['stateName']
                    ?? '';

                $historyMessage = $historyData['message']
                    ?? $historyData['statusMessage']
                    ?? $historyData['error']
                    ?? $historyRecord['admin_remark']
                    ?? '';

                $historyUsernameValue = $historyData['username']
                    ?? $historyRecord['username']
                    ?? '';

                $historyStatus = $historyRecord['status'] ?? '';
                $historyStatusLower = strtolower(
                    trim((string)$historyStatus)
                );

                $historyFinalStatus = $historyData['statusMessage']
                    ?? $historyData['status']
                    ?? $historyStatus;

                $historyModalId = 'vcm_history_status_'
                    . (int)$historyRecord['id'];

                if ($historyStatusLower === 'success') {
                    $historyStatusBadge =
                        '<span class="badge badge-success">Success</span>';
                } elseif (
                    in_array(
                        $historyStatusLower,
                        ['pending', 'process'],
                        true
                    )
                ) {
                    $historyStatusBadge =
                        '<span class="badge badge-warning">'
                        . htmlspecialchars(
                            ucfirst($historyStatusLower),
                            ENT_QUOTES,
                            'UTF-8'
                        )
                        . '</span>';
                } elseif (
                    in_array(
                        $historyStatusLower,
                        ['refund', 'refunded'],
                        true
                    )
                ) {
                    $historyStatusBadge =
                        '<span class="badge badge-danger">'
                        . htmlspecialchars(
                            ucfirst($historyStatusLower),
                            ENT_QUOTES,
                            'UTF-8'
                        )
                        . '</span>';
                } elseif ($historyStatusLower === 'failed') {
                    $historyStatusBadge =
                        '<span class="badge badge-danger">Failed</span>';
                } else {
                    $historyStatusBadge =
                        '<span class="badge badge-secondary">'
                        . htmlspecialchars(
                            $historyStatus ?: 'Unknown',
                            ENT_QUOTES,
                            'UTF-8'
                        )
                        . '</span>';
                }

                $historyViewButtonClass =
                    in_array(
                        $historyStatusLower,
                        ['refund', 'refunded', 'failed'],
                        true
                    )
                    ? 'btn-danger'
                    : (
                        $historyStatusLower === 'success'
                        ? 'btn-success'
                        : 'btn-info'
                    );

                $historyModalHeaderClass =
                    in_array(
                        $historyStatusLower,
                        ['refund', 'refunded', 'failed'],
                        true
                    )
                    ? 'bg-danger'
                    : 'bg-primary';
            ?>
              <tr class="text-center">
                <td><?= $historySl ?></td>

                <td>
                  <?= htmlspecialchars(
                      $historyOrderId,
                      ENT_QUOTES,
                      'UTF-8'
                  ) ?>
                </td>

                <td>
                  <?= !empty($historyRecord['date_time'])
                      ? date(
                          "d-M-Y h:i:s A",
                          strtotime($historyRecord['date_time'])
                      )
                      : '' ?>
                </td>

                <td>
                  <?= htmlspecialchars(
                      $historyVoterNumber,
                      ENT_QUOTES,
                      'UTF-8'
                  ) ?>
                </td>

                <td>
                  <?= htmlspecialchars(
                      $historyMobileNumber,
                      ENT_QUOTES,
                      'UTF-8'
                  ) ?>
                </td>

                <td><?= $historyStatusBadge ?></td>

                <td>
                  <div class="d-flex flex-column">

                    <?php if (
                        in_array(
                            $historyStatusLower,
                            ['pending', 'process'],
                            true
                        )
                        && !empty($historyOrderId)
                        && !empty($historyVoterNumber)
                        && !empty($historyMobileNumber)
                    ) { ?>
                      <form
                        method="POST"
                        action="/members/vcmStatusCheck"
                        class="mb-1"
                      >
                        <input
                          type="hidden"
                          name="order_id"
                          value="<?= htmlspecialchars(
                              $historyOrderId,
                              ENT_QUOTES,
                              'UTF-8'
                          ) ?>"
                        >

                        <input
                          type="hidden"
                          name="voterNumber"
                          value="<?= htmlspecialchars(
                              $historyVoterNumber,
                              ENT_QUOTES,
                              'UTF-8'
                          ) ?>"
                        >

                        <input
                          type="hidden"
                          name="mobileNumber"
                          value="<?= htmlspecialchars(
                              $historyMobileNumber,
                              ENT_QUOTES,
                              'UTF-8'
                          ) ?>"
                        >

                        <button
                          type="submit"
                          class="btn btn-warning btn-sm btn-block"
                        >
                          <i class="fas fa-sync-alt"></i>
                          Check Status
                        </button>
                      </form>

                    <?php } elseif (
                        in_array(
                            $historyStatusLower,
                            ['pending', 'process'],
                            true
                        )
                    ) { ?>
                      <button
                        type="button"
                        class="btn btn-danger btn-sm btn-block mb-1"
                        disabled
                      >
                        Status Data Missing
                      </button>
                    <?php } ?>

                    <button
                      type="button"
                      class="btn <?= $historyViewButtonClass ?> btn-sm btn-block"
                      data-toggle="modal"
                      data-target="#<?= htmlspecialchars(
                          $historyModalId,
                          ENT_QUOTES,
                          'UTF-8'
                      ) ?>"
                    >
                      <i class="fas fa-eye"></i>
                      View VCM Status
                    </button>
                  </div>

                  <div
                    class="modal fade"
                    id="<?= htmlspecialchars(
                        $historyModalId,
                        ENT_QUOTES,
                        'UTF-8'
                    ) ?>"
                    tabindex="-1"
                    role="dialog"
                    aria-hidden="true"
                  >
                    <div class="modal-dialog" role="document">
                      <div class="modal-content">

                        <div class="modal-header <?= $historyModalHeaderClass ?> text-white">
                          <h5 class="modal-title">
                            <i class="fas fa-info-circle"></i>
                            VCM Status Details
                          </h5>

                          <button
                            type="button"
                            class="close text-white"
                            data-dismiss="modal"
                          >
                            <span>&times;</span>
                          </button>
                        </div>

                        <div class="modal-body text-left">
                          <div class="table-responsive">
                            <table class="table table-bordered table-sm mb-0">
                              <tbody>
                                <tr>
                                  <th style="width:40%;">Order ID</th>
                                  <td>
                                    <?= htmlspecialchars(
                                        $historyOrderId ?: 'N/A',
                                        ENT_QUOTES,
                                        'UTF-8'
                                    ) ?>
                                  </td>
                                </tr>

                                <tr>
                                  <th>Voter Number</th>
                                  <td>
                                    <?= htmlspecialchars(
                                        $historyVoterNumber ?: 'N/A',
                                        ENT_QUOTES,
                                        'UTF-8'
                                    ) ?>
                                  </td>
                                </tr>

                                <tr>
                                  <th>Name</th>
                                  <td>
                                    <?= htmlspecialchars(
                                        $historyName ?: 'N/A',
                                        ENT_QUOTES,
                                        'UTF-8'
                                    ) ?>
                                  </td>
                                </tr>

                                <tr>
                                  <th>Mobile Number</th>
                                  <td>
                                    <?= htmlspecialchars(
                                        $historyMobileNumber ?: 'N/A',
                                        ENT_QUOTES,
                                        'UTF-8'
                                    ) ?>
                                  </td>
                                </tr>

                                <?php if (!empty($historyReferenceNo)) { ?>
                                  <tr>
                                    <th>Reference Number</th>
                                    <td>
                                      <?= htmlspecialchars(
                                          $historyReferenceNo,
                                          ENT_QUOTES,
                                          'UTF-8'
                                      ) ?>
                                    </td>
                                  </tr>
                                <?php } ?>

                                <?php if (!empty($historyState)) { ?>
                                  <tr>
                                    <th>State</th>
                                    <td>
                                      <?= htmlspecialchars(
                                          $historyState,
                                          ENT_QUOTES,
                                          'UTF-8'
                                      ) ?>
                                    </td>
                                  </tr>
                                <?php } ?>

                                <tr>
                                  <th>Status</th>
                                  <td>
                                    <strong>
                                      <?= htmlspecialchars(
                                          ucwords(
                                              (string)(
                                                  $historyFinalStatus
                                                  ?: $historyStatus
                                              )
                                          ),
                                          ENT_QUOTES,
                                          'UTF-8'
                                      ) ?>
                                    </strong>
                                  </td>
                                </tr>

                                <?php if (!empty($historyMessage)) { ?>
                                  <tr>
                                    <th>Message</th>
                                    <td>
                                      <?= htmlspecialchars(
                                          $historyMessage,
                                          ENT_QUOTES,
                                          'UTF-8'
                                      ) ?>
                                    </td>
                                  </tr>
                                <?php } ?>

                                <tr>
                                  <th>Username</th>
                                  <td>
                                    <?= htmlspecialchars(
                                        $historyUsernameValue ?: 'N/A',
                                        ENT_QUOTES,
                                        'UTF-8'
                                    ) ?>
                                  </td>
                                </tr>

                                <tr>
                                  <th>Date</th>
                                  <td>
                                    <?= !empty($historyRecord['date_time'])
                                        ? date(
                                            "d-M-Y h:i:s A",
                                            strtotime(
                                                $historyRecord['date_time']
                                            )
                                        )
                                        : 'N/A' ?>
                                  </td>
                                </tr>
                              </tbody>
                            </table>
                          </div>
                        </div>

                        <div class="modal-footer">
                          <button
                            type="button"
                            class="btn btn-secondary btn-sm"
                            data-dismiss="modal"
                          >
                            Close
                          </button>
                        </div>

                      </div>
                    </div>
                  </div>
                </td>
              </tr>
            <?php
                $historySl++;
            }
            ?>

          <?php } else { ?>
            <tr>
              <td
                colspan="7"
                class="text-center text-muted py-4"
              >
                No VCM request history found.
              </td>
            </tr>
          <?php } ?>
          </tbody>
        </table>
      </div>

      <?php if ($totalHistoryPages > 1) { ?>
        <div class="p-3">
          <nav aria-label="VCM History Pagination">
            <ul class="pagination pagination-sm justify-content-center mb-0">

              <li class="page-item <?= $historyPage <= 1
                  ? 'disabled'
                  : '' ?>">
                <a
                  class="page-link"
                  href="?vcm_page=<?= max(
                      1,
                      $historyPage - 1
                  ) ?>"
                >
                  Previous
                </a>
              </li>

              <?php
              for (
                  $pageNo = 1;
                  $pageNo <= $totalHistoryPages;
                  $pageNo++
              ) {
              ?>
                <li class="page-item <?= $pageNo === $historyPage
                    ? 'active'
                    : '' ?>">
                  <a
                    class="page-link"
                    href="?vcm_page=<?= $pageNo ?>"
                  >
                    <?= $pageNo ?>
                  </a>
                </li>
              <?php } ?>

              <li class="page-item <?= $historyPage >= $totalHistoryPages
                  ? 'disabled'
                  : '' ?>">
                <a
                  class="page-link"
                  href="?vcm_page=<?= min(
                      $totalHistoryPages,
                      $historyPage + 1
                  ) ?>"
                >
                  Next
                </a>
              </li>

            </ul>
          </nav>
        </div>
      <?php } ?>
    </div>
  </div>
</div>
<!-- =================== END VCM REQUEST HISTORY =================== -->

<!-- Modal to show fetched details -->
<div class="modal fade" id="showDetailsModal" tabindex="-1" role="dialog" aria-labelledby="showDetailsModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="showDetailsModalLabel">Fetched Details</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
    <?php if (isset($response['voterNumber']) && !empty($response['voterNumber'])) { ?>
          <form class="row">
            <div class="col-md-6 mb-3">
              <label>Voter Number</label>
              <input type="text" value="<?= htmlspecialchars($response['voterNumber']) ?>" class="form-control" readonly>
            </div>
            <?php if (isset($response['name']) && !empty($response['name'])) { ?>
            <div class="col-md-6 mb-3">
              <label>Full Name</label>
              <input type="text" value="<?= htmlspecialchars($response['name']) ?>" class="form-control" readonly>
            </div>
             <?php } ?>
             <?php if (isset($response['refrenceNo']) && !empty($response['refrenceNo'])) { ?>
            <div class="col-md-6 mb-3">
              <label>Refrence No</label>
              <input type="text" value="<?= htmlspecialchars($response['refrenceNo']) ?>" class="form-control" readonly>
            </div>
             <?php } ?>
             <?php if (isset($response['state']) && !empty($response['state'])) { ?>
            <div class="col-md-6 mb-3">
              <label>State</label>
              <input type="text" value="<?= htmlspecialchars($response['state']) ?>" class="form-control" readonly>
              </div>
             <?php } ?>
             <?php if (isset($response['mobileNumber']) && !empty($response['mobileNumber'])) { ?>
            <div class="col-md-6 mb-3">
              <label>Mobile Number</label>
              <input type="text" value="<?= htmlspecialchars($response['mobileNumber']) ?>" class="form-control" readonly>
              </div>
             <?php } ?>
             <?php if (isset($response['message']) && !empty($response['message'])) { ?>
            <div class="col-md-6 mb-3">
              <label>Message</label>
              <input type="text" value="<?= htmlspecialchars($response['message']) ?>" class="form-control" readonly>
              </div>
             <?php } ?>
          </form>
        <?php } else { ?>
          <p>No details fetched yet. Submit Voter Number to Link Your Mobile Number.</p>
        <?php } ?>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div>

<script>
  <?php if (isset($response['voterNumber']) && !empty($response['voterNumber'])) { ?>
    $(document).ready(function() {
      $('#showDetailsModal').modal('show');
    });
  <?php } ?>
</script>

</div>

<?php
} else {
    require_once("404.php");
}
} else {
    awal_alert_msg('You Do Not Have Voter Service Active!', 'info', 'dashboard');
}
require_once("../layouts/members/foot.php");
?>