<!DOCTYPE html>
<html>
<head>
<!-- FORM CSS CODE -->
<?php include"comman/code_css.php"; ?>
<!-- </copy> -->  
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

 <?php include"sidebar.php"; ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
       <?= $this->lang->line('promotional_sms_history'); ?>
      </h1>
      <ol class="breadcrumb">
        <li><a href="<?php echo $base_url; ?>dashboard"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="<?php echo $base_url; ?>sms_promotional">Promotional SMS</a></li>
        <li class="active"><?= $this->lang->line('promotional_sms_history'); ?></li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">
        <!-- right column -->
        <div class="col-md-12">
          <!-- Horizontal Form -->
          <div class="col-md-12">
         <div class="box box-primary">
           <div class="box-header with-border">
             <h3 class="box-title">SMS History</h3>
             <div class="box-tools">
               <button class="btn btn-danger btn-sm" onclick="clearSMSHistory()">
                 <i class="fa fa-trash"></i> <?= $this->lang->line('clear_history'); ?>
               </button>
             </div>
           </div>
           
            <!-- /.box-header -->
            <div class="box-body">
              <table id="sms_history_table" class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>ID</th>
                    <th>Send Type</th>
                    <th>Message</th>
                    <th>Success Count</th>
                    <th>Failed Count</th>
                    <th>Date</th>
                    <th>Time</th>
                    <th>Sent By</th>
                    <th>Actions</th>
                  </tr>
                </thead>
                <tbody>
                  <!-- Data will be loaded via AJAX -->
                </tbody>
              </table>
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>

        </div>
        <!--/.col (right) -->
      </div>
      <!-- /.row -->

    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->

 <?php include"footer.php"; ?>

  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->
<!-- SOUND CODE -->
<?php include"comman/code_js_sound.php"; ?>
<!-- TABLES CODE -->
<?php include"comman/code_js.php"; ?>

<script src="<?php echo $theme_link; ?>js/sms-promotional.js"></script>

<script>
function clearSMSHistory() {
    if (confirm('Are you sure you want to clear all SMS history? This action cannot be undone.')) {
        $.ajax({
            url: base_url + 'sms_promotional/clear_history',
            type: 'POST',
            dataType: 'json',
            success: function(response) {
                if (response.status) {
                    toastr.success(response.message);
                    // Reload the history table
                    $('#sms_history_table').DataTable().ajax.reload();
                } else {
                    toastr.error(response.message);
                }
            },
            error: function() {
                toastr.error('Error clearing SMS history');
            }
        });
    }
}
</script>

<!-- Make sidebar menu hughlighter/selector -->
<script>$(".<?php echo basename(__FILE__,'.php');?>-active-li").addClass("active");</script>

</body>
</html>
