<!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"; ?>
         <?php 
            $store_rec = get_store_details();
            ?>
         <!-- Content Wrapper. Contains page content -->
         <div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
               <h1>
                  <?= $this->lang->line('sms_api'); ?>
                  <small>Add/Update SMS API</small>
               </h1>
               <ol class="breadcrumb">
                  <li><a href="<?php echo $base_url; ?>dashboard"><i class="fa fa-dashboard"></i>Home</a></li>
                  <li class="active"> <?= $this->lang->line('sms_api'); ?></li>
               </ol>
            </section>
            <!-- Main content -->
            <section class="content">
               <div class="row">
                  <!-- right column -->
                  <!-- ********** ALERT MESSAGE START******* -->
                  <?php include"comman/code_flashdata.php"; ?>
                  <!-- ********** ALERT MESSAGE END******* -->
                  <div class="col-md-12">
                     <!-- Horizontal Form -->
                     
                        <?= form_open('#', array('class' => 'form-horizontal', 'id' => 'api-form', 'enctype'=>'multipart/form-data', 'method'=>'POST'));?>


                     <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                           <li class="active"><a href="#tab_1" data-toggle="tab">HTTP/URL SMS API</a></li>
                           <li><a href="#tab_2" data-toggle="tab">Twilio SMS API</a></li>
                           <li><a href="#tab_4" data-toggle="tab">FiveMojo WhatsApp API</a></li>
                           <li><a href="#tab_3" data-toggle="tab">Action</a></li>
                          
                        </ul>
                        <div class="tab-content">
                           <div class="tab-pane active" id="tab_1">
                              
                           <input type="hidden" name="hidden_rowcount" id="hidden_rowcount" value="">
                          
                           <input type="hidden" id="base_url" value="<?php echo $base_url;; ?>">
                           <!-- <div class="box-body"> -->
                              <div class="form-group " >

                                 <div class="col-sm-12">
                                  <div class="callout callout-info">
                                    <h4><i class="fa fa-info-circle"></i> SMS API Configuration Guide</h4>
                                    
                                    <div class="row">
                                      <div class="col-md-6">
                                        <h5><i class="fa fa-list-ol"></i> Step-by-Step Setup:</h5>
                                        <ol>
                                          <li><strong>Get your SMS provider's API details</strong></li>
                                          <li><strong>Configure the base URL</strong> (without parameters)</li>
                                          <li><strong>Set Mobile Key</strong> (parameter name for phone numbers)</li>
                                          <li><strong>Set Message Key</strong> (parameter name for message content)</li>
                                          <li><strong>Add your credentials</strong> (API keys, usernames, etc.)</li>
                                          <li><strong>Test the configuration</strong></li>
                                        </ol>
                                      </div>
                                      <div class="col-md-6">
                                        <h5><i class="fa fa-exclamation-triangle"></i> Important Notes:</h5>
                                        <ul>
                                          <li>Mobile & Message Key <strong>values should be empty</strong></li>
                                          <li>Don't include <code>?</code> in the URL field</li>
                                          <li>Use exact parameter names from your provider</li>
                                          <li>Test with a real number before going live</li>
                                        </ul>
                                      </div>
                                    </div>
                                    
                                    <div class="row">
                                      <div class="col-md-12">
                                        <h5><i class="fa fa-globe"></i> Popular SMS Provider Examples:</h5>
                                        
                                        <div class="panel-group" id="accordion" role="tablist">
                                          <!-- Africa's Talking -->
                                          <div class="panel panel-default">
                                            <div class="panel-heading" role="tab" id="heading1" style="background-color: #337ab7; color: white;">
                                              <h4 class="panel-title">
                                                <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse1" aria-expanded="true" aria-controls="collapse1" style="color: white; text-decoration: none;">
                                                  <i class="fa fa-chevron-down"></i> Africa's Talking
                                                </a>
                                              </h4>
                                            </div>
                                            <div id="collapse1" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="heading1">
                                              <div class="panel-body" style="background-color: #f9f9f9; color: #333;">
                                                <p><strong>URL:</strong> <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">https://api.africastalking.com/restless/send</code></p>
                                                <p><strong>Mobile Key:</strong> <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">to</code></p>
                                                <p><strong>Message Key:</strong> <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">message</code></p>
                                                <p><strong>Required Parameters:</strong></p>
                                                <ul>
                                                  <li><code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">username</code> - Your Africa's Talking username</li>
                                                  <li><code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">Apikey</code> - Your API key</li>
                                                </ul>
                                                <div class="alert alert-success">
                                                  <strong>Example URL:</strong><br>
                                                  <code style="background: #d4edda; color: #155724; padding: 2px 6px; border-radius: 3px;">https://api.africastalking.com/restless/send?username=YOUR_USERNAME&Apikey=YOUR_API_KEY&to=+256754084013&message=Test Message</code>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          <!-- Twilio -->
                                          <div class="panel panel-default">
                                            <div class="panel-heading" role="tab" id="heading2" style="background-color: #5cb85c; color: white;">
                                              <h4 class="panel-title">
                                                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse2" aria-expanded="false" aria-controls="collapse2" style="color: white; text-decoration: none;">
                                                  <i class="fa fa-chevron-right"></i> Twilio
                                                </a>
                                              </h4>
                                            </div>
                                            <div id="collapse2" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading2">
                                              <div class="panel-body" style="background-color: #f9f9f9; color: #333;">
                                                <p><strong>Note:</strong> Use the Twilio tab instead of HTTP/URL for Twilio configuration</p>
                                                <p>Twilio has its own dedicated configuration section with Account SID, Auth Token, and Phone Number fields.</p>
                                              </div>
                                            </div>
                                          </div>
                                          
                                          <!-- Generic HTTP API -->
                                          <div class="panel panel-default">
                                            <div class="panel-heading" role="tab" id="heading3" style="background-color: #f0ad4e; color: white;">
                                              <h4 class="panel-title">
                                                <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse3" aria-expanded="false" aria-controls="collapse3" style="color: white; text-decoration: none;">
                                                  <i class="fa fa-chevron-right"></i> Generic HTTP API
                                                </a>
                                              </h4>
                                            </div>
                                            <div id="collapse3" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading3">
                                              <div class="panel-body" style="background-color: #f9f9f9; color: #333;">
                                                <p><strong>URL:</strong> <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">https://your-provider.com/api/send</code></p>
                                                <p><strong>Mobile Key:</strong> <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">mobiles</code> (or <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">phone</code>, <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">number</code>)</p>
                                                <p><strong>Message Key:</strong> <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">message</code> (or <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">text</code>, <code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">msg</code>)</p>
                                                <p><strong>Common Parameters:</strong></p>
                                                <ul>
                                                  <li><code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">APIKey</code> - Your API key</li>
                                                  <li><code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">senderid</code> - Your sender ID</li>
                                                  <li><code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">username</code> - Your username</li>
                                                  <li><code style="background: #e8f4fd; color: #2c5aa0; padding: 2px 6px; border-radius: 3px;">password</code> - Your password</li>
                                                </ul>
                                                <div class="alert alert-info">
                                                  <strong>Example URL:</strong><br>
                                                  <code style="background: #d1ecf1; color: #0c5460; padding: 2px 6px; border-radius: 3px;">https://your-provider.com/api/send?APIKey=YOUR_KEY&senderid=SENDER&mobiles=91989xxxxxxx&message=Test Message</code>
                                                </div>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                 </div>
                                 <div class="col-sm-12  table-responsive">
                                  
                                    <div class="row" style="margin-bottom: 15px;">
                                      <div class="col-md-6">
                                        <h5><i class="fa fa-cog"></i> API Configuration</h5>
                                      </div>
                                      <div class="col-md-6 text-right">
                                        <div class="btn-group" role="group">
                                          <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            <i class="fa fa-magic"></i> Load Gateway Template <span class="caret"></span>
                                          </button>
                                          <ul class="dropdown-menu">
                                            <li><a href="#" onclick="populateAfricasTalkingExample()"><i class="fa fa-star"></i> Africa's Talking (Recommended)</a></li>
                                            <li><a href="#" onclick="populateTwilioExample()"><i class="fa fa-phone"></i> Twilio</a></li>
                                            <li><a href="#" onclick="populateGenericExample()"><i class="fa fa-globe"></i> Generic SMS API</a></li>
                                            <li><a href="#" onclick="populateTextLocalExample()"><i class="fa fa-envelope"></i> TextLocal</a></li>
                                            <li><a href="#" onclick="populateMsg91Example()"><i class="fa fa-send"></i> MSG91</a></li>
                                          </ul>
                                        </div>
                                        <input type="button" class="btn btn-success btn-sm" name="new_row" onclick="addrow();" value="+ Add Parameter" title="Add New Parameter">
                                      </div>
                                    </div>
                                  
                                    <table class="table" id='api_table'>
                                       <thead>
                                          <th width="15%">Parameter Type</th>
                                          <th width="20%" class="text-center">Key</th>
                                          <th width="40%" class="text-center">Key Value</th>
                                          <th width="10%">Action</th>
                                       </thead>
                                       <tbody>
                                          <?php 
                                             $q2=$this->db->select("*")->where("store_id",get_current_store_id())->get("db_smsapi");
                                             $i=0; 
                                             foreach($q2->result() as $res2){
                                               $i++;
                                               if($res2->info == 'url'){
                                             ?>
                                          <tr id="row_<?= $i; ?>" data-row='<?= $i; ?>'>
                                             <td  class="text-right"><label class="control-label">URL<label class="text-danger">*</label></label>
                                                <input type="hidden" id="info_<?= $i; ?>" name="info_<?= $i; ?>" value="<?php echo  $res2->info; ?>">
                                             </td>
                                             <td >
                                                <input id="key_<?= $i; ?>" name="key_<?= $i; ?>"  type="text" class="form-control " placeholder="" value='<?= $res2->key; ?>' readonly="true" />
                                             </td>
                                             <td><input id="key_val_<?= $i; ?>" name="key_val_<?= $i; ?>"  type="text" class="form-control " placeholder=""  value='<?= $res2->key_value; ?>' /></td>
                                             <td><input type="button" class="btn btn-danger" name="btn_<?= $i; ?>" id="btn_<?= $i; ?>" value="-" title="Cant' Remove" disabled='true' ></td">
                                          </tr>
                                          <?php 
                                             }//url end
                                             else if($res2->info == 'mobile'){
                                               ?>
                                          <tr id="row_<?= $i; ?>" data-row='<?= $i; ?>'>
                                             <td  class="text-right">
                                                <label class="control-label">Mobile Key<label class="text-danger">*</label></label>
                                                <br><small class="text-dark" style="font-weight: 500;">Parameter name for phone numbers</small>
                                                <input type="hidden" id="info_<?= $i; ?>" name="info_<?= $i; ?>" value="<?php echo  $res2->info; ?>">
                                             </td>
                                             <td >
                                                <input id="key_<?= $i; ?>" name="key_<?= $i; ?>"  type="text" class="form-control " placeholder="e.g., to, mobiles, phone" value='<?= $res2->key; ?>' />
                                                <small class="text-primary" style="font-weight: bold;">Common values: <code style="background: #f0f0f0; padding: 2px 4px; border-radius: 3px;">to</code>, <code style="background: #f0f0f0; padding: 2px 4px; border-radius: 3px;">mobiles</code>, <code style="background: #f0f0f0; padding: 2px 4px; border-radius: 3px;">phone</code></small>
                                             </td>
                                             <td>
                                                <input id="key_val_<?= $i; ?>" name="key_val_<?= $i; ?>"  type="text" class="form-control " placeholder="Leave empty - auto-filled" readonly="true" value='<?= $res2->key_value; ?>' />
                                                <small class="text-dark" style="font-weight: 500;">Auto-populated with actual phone number</small>
                                             </td>
                                             <td><input type="button" class="btn btn-danger" name="btn_<?= $i; ?>" id="btn_<?= $i; ?>" value="-" title="Cant' Remove" disabled='true' ></td">
                                          </tr>
                                          <?php 
                                             }//mobile end
                                             else if($res2->info == 'message'){
                                               ?>
                                          <tr id="row_<?= $i; ?>" data-row='<?= $i; ?>'>
                                             <td  class="text-right">
                                                <label class="control-label">Message Key<label class="text-danger">*</label></label>
                                                <br><small class="text-dark" style="font-weight: 500;">Parameter name for message content</small>
                                                <input type="hidden" id="info_<?= $i; ?>" name="info_<?= $i; ?>" value="<?php echo  $res2->info; ?>">
                                             </td>
                                             <td >
                                                <input id="key_<?= $i; ?>" name="key_<?= $i; ?>"  type="text" class="form-control " placeholder="e.g., message, text, msg" value='<?= $res2->key; ?>' />
                                                <small class="text-primary" style="font-weight: bold;">Common values: <code style="background: #f0f0f0; padding: 2px 4px; border-radius: 3px;">message</code>, <code style="background: #f0f0f0; padding: 2px 4px; border-radius: 3px;">text</code>, <code style="background: #f0f0f0; padding: 2px 4px; border-radius: 3px;">msg</code></small>
                                             </td>
                                             <td>
                                                <input id="key_val_<?= $i; ?>" name="key_val_<?= $i; ?>"  type="text" class="form-control " placeholder="Leave empty - auto-filled" readonly="true" value='<?= $res2->key_value; ?>' />
                                                <small class="text-dark" style="font-weight: 500;">Auto-populated with actual message content</small>
                                             </td>
                                             <td><input type="button" class="btn btn-danger" name="btn_<?= $i; ?>" id="btn_<?= $i; ?>" value="-" title="Cant' Remove" disabled='true' ></td">
                                          </tr>
                                          <?php 
                                             }//mobile end
                                             else{
                                               ?>
                                          <tr id="row_<?= $i; ?>" data-row='<?= $i; ?>'>
                                             <td>
                                                <input type="hidden" id="info_<?= $i; ?>" name="info_<?= $i; ?>" value="<?php echo  $res2->info; ?>">
                                             </td>
                                             <td >
                                                <input id="key_<?= $i; ?>" name="key_<?= $i; ?>"  type="text" class="form-control " placeholder="" value='<?= $res2->key; ?>' />
                                             </td>
                                             <td><input id="key_val_<?= $i; ?>" name="key_val_<?= $i; ?>"  type="text" class="form-control " placeholder="" value='<?= $res2->key_value; ?>' /></td>
                                             <td><input type="button" class="btn btn-danger" name="btn_<?= $i; ?>" id="btn_<?= $i; ?>" value="-" title="Remove ?" onclick="removerow('<?= $i; ?>')"  ></td">
                                          </tr>
                                          <?php 
                                             }//mobile end
                                             }//foreach end
                                             ?>
                                       </tbody>
                                    </table>
                                 </div>
                                 

                                 <?php
                              $btn_name="Update";
                                  $btn_id="update";
                              ?>
                        

                              </div>
                              <!-- server code -->
                           <!-- </div> -->
                           <!-- /.box-body -->
                           
                           <!-- /.box-footer -->
                        
                           </div>
                           <!-- /.tab-pane -->
                           <div class="tab-pane" id="tab_2">
                            <?php
                            $account_sid = $auth_token = $twilio_phone =''; 
                            $q1=$this->db->select("*")->where("store_id",get_current_store_id())->get("db_twilio");
                            if($q1->num_rows()>0){
                              $account_sid = $q1->row()->account_sid;
                              $auth_token = $q1->row()->auth_token;
                              $twilio_phone = $q1->row()->twilio_phone;
                            } 
                            ?>
                              <div class="row">
                                 <!-- right column -->
                                 <div class="col-md-12">
                                       <div class="box-body">
                                          <div class="row">
                                            <div class="callout callout-info">
                                    <h4>Twilio SMS API</h4>
                                      Website Link: <a href='https://www.twilio.com/' target="_blank">https://www.twilio.com/</a>

                                    <p>Where <b>Account SID, Auth Token</b> and <b>Twilio Phone</b> number are neccessary for SMS Sending Feature.</p>
                                    <p><b>Note: Twilio requires the complete number to send SMS. Ex: +919876543210, +188888888888.</b></p>
                                  </div>
                                             <div class="col-md-8">
                                                <div class="form-group">
                                                   <label for="account_sid" class="col-sm-4 control-label">Account SID</label>
                                                   <div class="col-sm-4">
                                                      <input type="text" class="form-control" id="account_sid" name="account_sid" placeholder="" value="<?php print $account_sid; ?>" >
                                                      <span id="account_sid_msg" style="display:none" class="text-danger"></span>
                                                   </div>
                                                </div>
                                             </div>
                                             <div class="col-md-8">
                                                <div class="form-group">
                                                   <label for="auth_token" class="col-sm-4 control-label">Auth Token</label>
                                                   <div class="col-sm-4">
                                                      <input type="text" class="form-control" id="auth_token" name="auth_token" placeholder="" value="<?php print $auth_token; ?>" >
                                                      <span id="auth_token_msg" style="display:none" class="text-danger"></span>
                                                   </div>
                                                </div>
                                             </div>
                                             <div class="col-md-8">
                                                <div class="form-group">
                                                   <label for="twilio_phone" class="col-sm-4 control-label">Twilio Phone Number</label>
                                                   <div class="col-sm-4">
                                                      <input type="text" class="form-control" id="twilio_phone" name="twilio_phone" placeholder="" value="<?php print $twilio_phone; ?>" >
                                                      <span id="twilio_phone_msg" style="display:none" class="text-danger"></span>
                                                   </div>
                                                </div>
                                             </div>
                                             


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

                           <div class="tab-pane" id="tab_4">
                            <?php
                            $whatsAppUrl  = 'https://app.fivemojo.com/api/send.php';
                            $whatsAppInstanceId = $whatsAppToken =''; 
                            $q1=$this->db->select("*")->where("store_id",get_current_store_id())->get("db_fivemojo");
                            if($q1->num_rows()>0){
                              $account_sid = $q1->row()->url;
                              $whatsAppInstanceId = $q1->row()->instance_id;
                              $whatsAppToken = $q1->row()->token;
                              $whatsAppUrl = $q1->row()->url;
                            } 
                            ?>
                              <div class="row">
                                 <!-- right column -->
                                 <div class="col-md-12">
                                       <div class="box-body">
                                          <div class="row">
                                            <div class="callout callout-info">
                                    <h4>FiveMojo WhatsApp API</h4>
                                      Website Link: <a href='https://app.fivemojo.com/' target="_blank">https://app.fivemojo.com/</a>

                                    <p>Where <b>URL, Instance ID</b> and <b>Token</b> number are neccessary for message Sending Feature.</p>
                                    <b>Note: </b> Number should be full, example: 91989xxxxxxx (Don't use + symbol).
                                    
                                  </div>
                                             <div class="col-md-8 hide">
                                                <div class="form-group">
                                                   <label for="whatsAppUrl" class="col-sm-4 control-label">URL</label>
                                                   <div class="col-sm-4">
                                                      <input type="text" class="form-control" id="whatsAppUrl" name="whatsAppUrl" placeholder="" value="<?php print $whatsAppUrl; ?>" readonly >
                                                      <span id="whatsAppUrl_msg" style="display:none" class="text-danger"></span>
                                                   </div>
                                                </div>
                                             </div>
                                             <div class="col-md-8">
                                                <div class="form-group">
                                                   <label for="whatsAppInstanceId" class="col-sm-4 control-label">Instance ID</label>
                                                   <div class="col-sm-4">
                                                      <input type="text" class="form-control" id="whatsAppInstanceId" name="whatsAppInstanceId" placeholder="" value="<?php print $whatsAppInstanceId; ?>" >
                                                      <span id="whatsAppInstanceId_msg" style="display:none" class="text-danger"></span>
                                                   </div>
                                                </div>
                                             </div>
                                             <div class="col-md-8">
                                                <div class="form-group">
                                                   <label for="whatsAppToken" class="col-sm-4 control-label">Token</label>
                                                   <div class="col-sm-4">
                                                      <input type="text" class="form-control" id="whatsAppToken" name="whatsAppToken" placeholder="" value="<?php print $whatsAppToken; ?>" >
                                                      <span id="whatsAppToken_msg" style="display:none" class="text-danger"></span>
                                                   </div>
                                                </div>
                                             </div>
                                             
                                             


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

                           <!-- /.tab-pane -->
                           <div class="tab-pane" id="tab_3">
                           
                              <div class="row">
                                 <!-- right column -->
                                 <div class="col-md-12">
                                       <div class="box-body">
                                          <div class="row">
                                            <div class="callout callout-info">
                                    <h4>Enable or Disable the SMS Sending Feature.</h4>
                                    <p>
                                      <ul>
                                        <li>Disable: If you don't want to send SMS</li>
                                        <li>HTTP/URL API : Which will allow to send SMS by using HTTP/URL Based SMS API.</li>
                                        <li>Twilio API : Which will allow to send SMS by using Twilio SMS API.</li>
                                      </ul>
                                    </p>
                                  </div>
                                             <div class="col-md-8">
                                                <div class="form-group">
                                                   <label for="sms_status" class="col-sm-4 control-label">SMS Status</label>
                                                   <div class="col-sm-4">
                                                      <select class="form-control select2" id="sms_status" name="sms_status"  style="width: 100%;" >
                                                      <option value="0">Disable</option>
                                                      <option value="1">HTTP/URL API</option>
                                                      <option value="2">Twilio API</option>
                                                      <option value="3">Fivemojo WhatsApp API</option>
                                                   </select>
                                                   </div>
                                                </div>
                                             </div>
                                          </div>
                                       </div>
                                 </div>
                                 <!--/.col (right) -->
                              </div>
                           </div>
                           <!-- /.tab-pane -->
                        </div>
                        <!-- /.tab-content -->

                     </div>
                    <div class="col-sm-8 col-sm-offset-2 text-center">
                           <center>
                            <?php
                              $btn_name="Update";
                                  $btn_id="update";
                              ?>
                             <div class="col-md-2">
                              <button type="button" id="test_sms" class="btn btn-block btn-info" title="Test SMS Configuration">
                                <i class="fa fa-paper-plane"></i> Test SMS
                              </button>
                           </div>
                             <div class="col-md-3">
                              <button type="button" id="<?php echo $btn_id;?>" class=" btn btn-block btn-success" title="Save Data"><?php echo $btn_name;?></button>
                           </div>
                            <div class="col-sm-2">
                              <a href="<?=base_url('dashboard');?>">
                                <button type="button" class="col-sm-12 btn btn-block btn-warning close_btn" title="Go Dashboard">Close</button>
                              </a>
                             </div>
                           </center>
                        </div>
                     <!-- /.box -->
                   <?= form_close(); ?>
                  </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>
      <!-- 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.js"></script>
      
      <!-- Make sidebar menu hughlighter/selector -->
      <script>$(".<?php echo basename(__FILE__,'.php');?>-active-li").addClass("active");</script>
      <script>
         //UPDATE ROW COUNT
         $("#hidden_rowcount").val("<?= $i;?>");
         
         //UPDATE current sms_status
           $("#sms_status").val(<?= $store_rec->sms_status;?>).select2();  
        
      </script>
      <script type="text/javascript">
         function removerow(id){//id=Rowid
         
             $("#row_"+id).remove();
            // final_total();
             }
           function addrow(id){
             
               var rowcount=$("#hidden_rowcount").val();
               rowcount=parseInt(rowcount)+1;
                 $("#hidden_rowcount").val(rowcount);
         
                 var str='<tr id="row_'+rowcount+'" data-row="'+rowcount+'">';
                 
                 
                 str+='<td><input type="hidden" id="info_'+rowcount+'" name="info_'+rowcount+'" value=""></td>';
               str+='<td><input id="key_'+rowcount+'" name="key_'+rowcount+'"  type="text" class="form-control" /></td>';
               str+='<td><input id="key_val_'+rowcount+'" name="key_val_'+rowcount+'"  type="text" class="form-control" /></td>';
               str+='<td><input type="button" class="btn btn-danger" name="btn_'+rowcount+'" id="btn_'+rowcount+'" value="-" title="Remove Record" onclick="removerow('+rowcount+')"></td>';
                 str+='</tr>';
                  //console.log(str);
                       $('#api_table tbody').append(str);
            
             //return;
           }
         
         
      </script>
   </body>
</html>
