<?php $__env->startSection('header'); ?>
    <div class="col-lg-8 col-md-6 col-sm-6 col-6">            
        <div class="header-text"><?php echo $company_name; ?></div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <section>
      <div class="section-foreground">
        <div class="centered-element">
            <?php if($errors->any()): ?>
            <div class="alert alert-info">
                <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
                <strong><?php echo $errors->first(); ?></strong>
            </div>
            <?php endif; ?>
            <?php if(file_exists($company_logo)): ?>
            <div class="logo">
                <img src="<?php echo asset("$company_logo"); ?>" alt="logo">
            </div>
            <?php else: ?>
            <div class="logo">
                <img src="<?php echo asset('assets/images/c_u_1.png'); ?>" alt="logo">
            </div>
            <?php endif; ?>
            <form action="<?php echo url('user_dashboard_login'); ?>" method="POST" onsubmit="return checkInp()">
                <div class="login">
                    <input type="text" class="login-field" placeholder="Enter Mobile Number" name="mobile_no" onkeypress="return isNumberKey(event)">
                    <button class="go-button">GO</button>
                </div>
            </form>
            <div class="error-message" style="color:red; margin-top:20px;"><?php echo Session::get('message'); ?></div>
            <div class="error-message initial-dashboard" style="color:red; margin-top:20px;"></div>
        </div>
        <?php if(!Session::has('employeeuser')): ?>
        <div>
            <button class="btn" data-toggle="modal" data-target="#BulkSMS" style="display: block;font-size: 10px; position: fixed; bottom: 16px; right: 150px; z-index: 99; cursor: pointer;">Bulk SMS</button>
            <a class="btn" href="<?php echo url('report-module'); ?>" style="display: block;font-size: 10px; position: fixed; bottom: 16px; right: 245px; z-index: 99; cursor: pointer;">Reports</a>
            <button class="btn" data-toggle="modal" data-target="#advanced_dashboard_login" style="display: block;font-size: 10px; position: fixed; bottom: 16px; right: 15px; z-index: 99; cursor: pointer;">admin dashboard</button>
        </div>
        <?php else: ?>
        <div>
            <a class="btn" href="<?php echo url('report-module'); ?>" style="display: block;font-size: 10px; position: fixed; bottom: 16px; right: 150px; z-index: 99; cursor: pointer;">Reports</a>
            <button class="btn" data-toggle="modal" data-target="#BulkSMS" style="display: block;font-size: 10px; position: fixed; bottom: 16px; right: 15px; z-index: 99; cursor: pointer;">Bulk SMS</button>
        </div>
        <?php endif; ?>
      </div>
    </section>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('modals'); ?>
     <!-- Advanced Dashboard Login Modal -->
     <div class="modal fade" id="advanced_dashboard_login" role="dialog" aria-hidden="true">
            <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                <h5 class="modal-title">admin dashboard</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                </div>
                <div class="modal-body">
                <!--<form action="<?php echo url('admin_dashboard_login'); ?>" method="POST">-->
                    <div><input type="password" name="password" class="modal-field advance-password" placeholder="Enter your password"></div>
                    <div>
                        <button class="btn account-login" id="test1">go</button>
                    </div>
                    <div class="form-error"></div>
                    <a class="forgot-password" href="<?php echo url('merchant/forgotadvancepasswordnew'); ?>">Forgot Password?</a>
                <!--</form>-->
                </div>
            </div>
            </div>
    </div>
    <!-- Advanced Dashboard Login Modal -->
     <div class="modal fade" id="BulkSMS" role="dialog" aria-hidden="true">
            <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                <h5 class="modal-title">Send SMS</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                </div>
                <?php 
                            if(Session::has('employeeuser'))
                            {
                                    $employee = Session::get('employeeuser');
                                    $subid = $employee->id;
                                    $merchant_id = $employee->merchant_id;
                                    $type = 'employee';
                                    //$allow = $employee->Call_otp_permission;
                            }
                            else
                            {
                                    //$email = $this->authUser['email'];
                                    $email = 'email';
                                    $subid = Auth::user()->id;
                                    $merchant_id = Auth::user()->id;
                                    $type = 'merchant';
                                    //$allow = $merchant_details->Call_otp_permission;
                            }
                ?>
                <div class="modal-body">
                    <div style="color:#000;margin-bottom: 30px;"><span style="float: left;font-weight: 800;">Promo Balance : <?php echo $sms; ?></span><span style="float: right;font-weight: 800;">Target Audience : <?php echo $total_members; ?></span></div>
                    <input type="hidden" name="bulk-merchant-id" class="bulk-merchant-id" id="bulk-merchant-id" value="<?php echo $merchant_id; ?>">
                    <input type="hidden" name="bulk-merchant-type" class="bulk-merchant-type" id="bulk-merchant-type" value="<?php echo $type; ?>">
                    <input type="hidden" name="bulk-merchant-email" class="bulk-merchant-email" id="bulk-merchant-email" value="<?php echo $subid; ?>">
                    <div><textarea rows="5" id="comment" name="bulk-merchant-txt" class="modal-field-textarea bulk-merchant-txt" id="bulk-merchant-txt" placeholder="Type your text here limited to 160 characters only" style="font-size: 15px;height:120px;" maxlength="160"></textarea></div>
                    <div>
                        <?php if($sms < $total_members): ?>
                        <button class="btn send-bulk-sms" id="test1">Send</button>
                        <?php else: ?>
                        <span style="color:red;">Your promo SMS balance is lower than your target audience. Please contact your RM for a recharge.</span>
                        <?php endif; ?>
                    </div>
                    <div class="form-error"></div>
                </div>
            </div>
            </div>
    </div>

    <!-- Message Modal -->
    <div class="modal fade" id="message" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Message</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="message-content"></div>
                </div>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('customscripts'); ?>
<script>
        $(document).ready(function() 
        {
        	
            $(".account-login").click(function()
            {
                //alert("hello");
                    //e.preventDefault();
                    var password = $(".advance-password").val();
                    //alert(password);
                    if(password=="")
                    {
                        //alert("error");
                        $(this).parent().parent().find(".form-error").html("Please provide password");
                    }
                    else
                    {
                        $.ajax(
                        {
                            type: 'POST',
                            url: '<?php echo url('admin_dashboard_login'); ?>',
                            data: {password:password},
                            success: function(response)
                            {
                                var reponse = JSON.stringify(response);

                                if(response=="successfully")
                                {
                                    //alert("done");
                                    window.location.replace("merchant/main-dashboard");
                                }
                                else
                                {
                                    $(".account-login").parent().parent().find(".form-error").html(response);
                                }
                                
                            }

                        });
                    }
            });
            $(".send-bulk-sms").click(function()
            {
                //alert("hello");
                    //e.preventDefault();
                    var msg = $(".bulk-merchant-txt").val();
                    var type = $(".bulk-merchant-type").val();
                    var subid = $(".bulk-merchant-email").val();
                    var merchant_id = $(".bulk-merchant-id").val();
                    //alert(password);
                    if(msg=="")
                    {
                        //alert("error");
                        $(this).parent().parent().find(".form-error").html("Please provide msg");
                    }
                    else
                    {
                        $('#BulkSMS').modal('hide');
                        $('#message').modal('show');
                        $(".bulk-merchant-txt").val("");
                        $(".message-content").html('Your SMS has been triggered successfully');
                        $.ajax(
                        {
                            type: 'POST',
                            url: '<?php echo url('sendBulkSMS'); ?>',
                            data: {msg:msg,type:type,subid:subid,merchant_id:merchant_id},
                            //$(".add-credit-comment").val("");
                            
                            success: function(response)
                            {
                                
                            }

                        });
                    }
            });
            $(".advance-password").keyup(function(event) {
                if (event.keyCode === 13) {
                    $(".account-login").click();
                }
            });
            $('#message').on('hidden.bs.modal', function () {
             location.reload();
            });
            
        });
            
        function checkInp()
        {
          var x=$(".login-field").val();
          if (isNaN(x)) 
          {
            alert("Please enter valid mobile number");
            //$(".innitial-dashboard").html(response);
            return false;
          }
        }
            
</script>
    
<?php $__env->stopSection(); ?>
    
<?php echo $__env->make('layouts.MasterLayout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>