<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/imgpro.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
$_SESSION['cuPages']='axe_company.php';   
$cuPage='axe_company.php';    
$aid=$_SESSION['uid'];
$brid=$_SESSION['abrid'];    
}else{
header('Location:../index.php');
exit;    
}
$mhead='sms';
$menuh='Company';
$phead='setcom';
$page='SMS Setup';
$dtnow = date("Y-m-d h:i:s", time());
?>
<?php
include('../layout/head.php');
include('../layout/header.php');
include('../layout/side_nav.php');
?>
<?php
$sql="SELECT * FROM tbl_sms WHERE id=1 LIMIT 1";
$smsde = mysqli_query($con,$sql);
$com=mysqli_fetch_array($smsde);

if(isset($_POST['upd_sms'])){
$status = remove_junk(escape($_POST['status']));
$appkey = remove_junk(escape($_POST['appkey']));    
$senderid = remove_junk(escape($_POST['senderid']));
$type = remove_junk(escape($_POST['type'])); 
$url = remove_junk(escape($_POST['url']));
$htext = remove_junk(escape($_POST['htext']));
$ftext = remove_junk(escape($_POST['ftext']));   
$language = remove_junk(escape($_POST['language'])); 

$hbtext = remove_junk(escape($_POST['hbtext']));
$fbtext = remove_junk(escape($_POST['fbtext'])); 

$sql="UPDATE tbl_sms SET status=$status,language=$language, appkey='$appkey', senderid='$senderid', type='$type',url='$url',htext='$htext',ftext='$ftext',hbtext='$hbtext',fbtext='$fbtext' WHERE id='1'";
$result = mysqli_query($con,$sql) or die(mysqli_error($con));   
if($result){   
$act =remove_junk(escape('SMS Setting Update: '.$name));    
write_activity($aid,'SMS','SMS Setting has been Updated',$act); 
    
save_msg('s','SMS Update Successfully!!!');
echo "<script>window.location='axe_smssetting.php'</script>";	
}else{
save_msg('e','SMS update fail!!!!');
echo "<script>window.location='axe_smssetting.php'</script>";		
}    
}
?>
<div class="content-wrapper">
<?php include('../layout/page_head.php'); ?>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-8">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Update SMS Setting</h3>
</div>
<div class="box-body">
<?php echo display_msg();?>    
<form action="axe_smssetting.php" onsubmit="return validate()" enctype="multipart/form-data" method="post" accept-charset="utf-8">    
<div class="col-md-12 popup_details_div">
<div class="row">
<div class="col-md-1"></div>
<div class="col-md-10">
<div class="row">
<div class="col-md-6">
<div class="form-group" >
<label>SMS Active Status</label>
<div class="input-group">
<span class="input-group-addon">S</span>
<select class="form-control select2" name="status" id="status">
<option <?php if($com['status']==1){echo 'selected';}?> value="1">Active</option>
<option <?php if($com['status']==0){echo 'selected';}?> value="0">De-Active</option>    
</select>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" >
    <label>Language</label>
        <div class="input-group">
            <span class="input-group-addon">LN</span>
            <select class="form-control select2" name="language" id="language">
            <option <?php if($com['language']==1){echo 'selected';}?> value="1">EN</option>
            <option <?php if($com['language']==0){echo 'selected';}?> value="0">BN</option>    
            </select>
        </div>
</div>
      
</div>
</div>    
<div class="row">
<div class="col-md-6">
<div class="form-group" >
<label>App Key</label>
<div class="input-group">
<span class="input-group-addon">AK</span>
<input type="text" maxlength="100" class="form-control" name="appkey" id="appkey" value="<?php echo $com['appkey'];?>"   autocomplete="off">
</div>
</div>
<div class="form-group" >
<label>Sender ID</label>
<div class="input-group">
<span class="input-group-addon">SI</span>
<input type="text" maxlength="50" class="form-control" name="senderid" id="senderid" Value="<?php echo $com['senderid'];?>" autocomplete="off">
</div>
</div>        
</div>
<div class="col-md-6">
<div class="form-group" >
<label>Type</label>
<div class="input-group">
<span class="input-group-addon">T</span>
<select class="form-control select2" name="type" id="type">
<option <?php if($com['type']=='text'){echo 'selected';}?> value="text">Text</option>
<option <?php if($com['type']=='unicode'){echo 'selected';}?> value="unicode">Unicode</option>    
</select>
</div>
</div>
<div class="form-group" >
<label>Url</label>
<div class="input-group">
<span class="input-group-addon">U</span>
<input type="web" maxlength="35" class="form-control" name="url" id="url" value="<?php echo $com['url'];?>"  placeholder="e.g.  https://msg.elitbuzz-bd.com/smsapi?" autocomplete="off">
</div>
</div>    
</div>    
</div>
<div class="row">
    <div class="col-md-6">                                
        <div class="form-group">
            <label>Header Text(EN)</label>
            <div class="input-group">
                <span class="input-group-addon">HT</span>
                <textarea class="form-control" name="htext" id="htext" maxlength="250" rows="5" placeholder="Header Text" required><?php echo $com['htext'];?></textarea>
            </div>    
        </div>
    </div>
    <div class="col-md-6">  
        <div class="form-group">
            <label>Footer Text(EN)</label>
            <div class="input-group">
                <span class="input-group-addon">FT</span>
                <textarea class="form-control" name="ftext" id="ftext" maxlength="350" rows="5" placeholder="Footer Text" required><?php echo $com['ftext'];?></textarea>
            </div>    
        </div>    
    </div>    
</div> 

<div class="row">
    <div class="col-md-6">                                
        <div class="form-group">
            <label>Header Text(BN)</label>
            <div class="input-group">
                <span class="input-group-addon">HT</span>
                <textarea class="form-control" name="hbtext" id="hbtext" maxlength="250" rows="5" placeholder="Header Text" required><?php echo $com['hbtext'];?></textarea>
            </div>    
        </div>
    </div>
    <div class="col-md-6">  
        <div class="form-group">
            <label>Footer Text(BN)</label>
            <div class="input-group">
                <span class="input-group-addon">FT</span>
                <textarea class="form-control" name="fbtext" id="fbtext" maxlength="350" rows="5" placeholder="Footer Text" required><?php echo $com['fbtext'];?></textarea>
            </div>    
        </div>    
    </div>    
</div> 
</div>    
<div class="col-md-1"></div>
</div>
    
</div>
<div class="clearfix" ></div>
<div class="col-md-12 nopadding widgets_area"></div>    
<div class="row"style="margin-top: 15px" >
<div class="col-md-8 ">
</div>
<div class="col-md-4 text-right" >
<input type="submit" name="upd_sms" id="submit" class="btn btn-flat bg-purple btn-sm" value="Update"/>
</div> 
</div>     
</form>    
</div>
</div>
</div>
<div class="col-md-4">
<div class="row">
<div class="col-md-12">
<div class="box box-solid">
<div class="box-header">
<h3 class="box-title">History </h3>
</div>
<!-- /.box-header -->
<div class="box-body" >
<?php if($_SESSION['access']=='1'){echo read_activity($aid,'SMS','A');}else{echo read_activity($aid,'SMS','U');}?>
</div>
</div>
</div>
</div>
</div>
</div>
    
<?php include('../layout/quick.php');?>    
</section>
<!-- /.main content -->    
</div>

<?php 
include('../layout/footer.php');
?>
<!-- page script -->
<script type="text/javascript">
$(document).ready(function () {  
var name = new LiveValidation('name');
name.add(Validate.Presence);
var address = new LiveValidation('address');
address.add(Validate.Presence);    
var mobile = new LiveValidation('mobile');
mobile.add(Validate.Presence);
mobile.add(Validate.Length, {minimum: 11, maximum: 14});
var email = new LiveValidation('email');
email.add(Validate.Email);
var web = new LiveValidation('web');
web.add(Validate.Web);    
});    
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
            
reader.onload = function (e) {
$('#profile-img-tag').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$("#profile-img").change(function(){
readURL(this);
});
$("#profile-img-tag").click(function() {
$("#profile-img").click();
}); 
</script>    
<!-- /page script -->
</html>    