 <div class="content-wrapper">
    <div class="container-fluid">
		
        <div class="row">
        	<div class="col-lg-12">
        		<div class="card">
        			<div class="card-body">
        				<div class="card-title">WhatsApp Messaging Templates for Marketing</div>
       					<?php $pagemsg = $this->session->flashdata('page_message'); 
					if($pagemsg){
						echo $pagemsg;
					}
				?>
        			</div>
        		</div>
        	</div>
        </div><!--End Row-->
        
        <div class="row">
			<div class="col-lg-8 offset-2">
				<div class="row">
				<div class="col-lg-8">
					<form action="#" method="post" method="post" id="sendwhatsapp" enctype="multipart/form-data">
					<div class="row">
						<div class="col-lg-12">
							<div class="card">
								<div class="card-body">
								   
								  <div class="form-group row">
											<label for="input-21" class="col-sm-3 col-form-label">Campaign Name*</label>
											<div class="col-sm-9">
												<input type="text" class="form-control"  name="campaignname" id="input-21" required>
											</div>
									</div>
									
									<div class="form-group row">
											<label for="input-21" class="col-sm-3 col-form-label">Select Templates*</label>
											<div class="col-sm-9">
											  
											  <select name="template" id="merchanttemplates" class="form-control" required>
												<option value="0">Select Template</option>
												<?= $templateesoptions; ?>
											</select>
							
											</div>
									</div>
									<div id="templatesdata">
										
									</div>
									
									<!-- <div class="form-group row">
											<label for="input-21" class="col-sm-3 col-form-label">Upload CSV</label>
											<div class="col-sm-9">
												<input type="file" name="csvfile" id="contactscsv" class="form-control " accept=".csv">											<div id="csverr" class="p-2" style="display:none"></div>
											</div>
									</div> -->
									
									<div class="form-group row">
											<label for="input-21" class="col-sm-3 col-form-label">Contacts* <br/>(One Per Line)</label>
											<div class="col-sm-9">
												<textarea class="form-control"  name="contacts" id="checkdublicate" placeholder="One Per Line"></textarea>
											</div>
											<div style="float: right;width: 100%;text-align: right;padding: 12px;color: #858585;">
												Total <span id="totalno">0</span>
													| Dublicate <span id="duplicateno">0</span>
													| Valid <span id="validno">0</span>
													| Invalid <span id="invalidno">0</span>
												
											</div>	
									</div>
									
								
									<div class="form-group row">
											<label for="input-21" class="col-sm-3 col-form-label">Send Time</label>
											<div class="col-sm-9">
											   <input type="datetime-local" name="scheduledate" required class="form-control" min="<?php echo date('Y-m-d\TH:i:s'); ?>" value="<?php echo date('Y-m-d\TH:i:s'); ?>" />
											</div>
									</div>
									<div id="errmsg"></div>
									<?php if(LEFTCREDITS <=0){ ?>
										<div class="alert alert-danger p-4 text-center">You Have No Credits To Send Whatsapp...</div>
									<?php }
									else{ ?>
									 <div class="form-group row">
										  <div class="col-sm-12">
											<button type="submit" name="submit" class="btn btn-primary px-5 pull-right"><i class="icon-lock"></i> Send Messages</button>
										  </div>
										</div>
								  	<?php } ?>
								</div>
							</div>
						 </div>
					  </div>
					  </form>
					  
					  
				</div>
<style>
.whatsapp-container{background:#ccc;min-height:350px;width:350px;margin-left:auto;margin-right:auto;margin-bottom:20px; }
.topribben{height: 30px;background: #075E54;}
.waheader{min-height: 60px;background: #128C7E;font-size: 18px;
color: #fff;padding:12px}

.waheader i {padding:8px;}
.wabody{min-height: 350px;}

.wafooter .textarea{
width: 290px;height: auto;background: #fff;border-radius: 102px;padding: 12px 17px;color: #989898;font-size: 19px;display: inline-block;
}

.wafooter .textbutton{
width: 44px;
display: inline-block;
background: #075E54;
padding: 12px 16px;
vertical-align: top;
border-radius: 100px;
height: 43px;
}

.wamsg-left{
min-height: 63px;width: 272px;background: #fff;margin: 10px 5px;border-radius: 3px 15px 15px 15px;float: left;
}

.wamsg-right{
min-height: 63px;width: 272px;background:#fff9cb;padding: 12px;
color: #393939;margin: 10px 5px;border-radius: 15px 3px 15px 15px;float: right;
}

.prvhead{font-size: 12px;
color: #6a6a6a; margin-bottom:5px;}
.prvbody{margin-bottom:5px;}
.prvfooter{font-size: 12px;
color: #6a6a6a; margin-bottom:10px;}

.prvmedia img{
border-radius: 5px 5px 0px 0px;
margin-bottom: 10px;
}
</style>            
            <div class="col-lg-4">
            	<div class="whatsapp-container">
                	<div class="topribben"></div>
                    <div class="waheader">
                    	<i class="fa fa-chevron-left pull-left"> <?= @$_SESSION['merchantname']; ?></i>
                        
                        <i class="fa fa-video-camera pull-right"></i>
                        <i class="fa fa-phone pull-right"></i>
                        <i class="fa fa-ellipsis-v pull-right"></i>
                    </div>
                    <div class="wabody">
                    
                    	
                        <div class="wamsg-left">
                        </div>
                        <div class="wamsg-right wamsg-prev">
                        </div>
                    </div>
                    <div class="wafooter">
                    	<div class="textarea">
                        	<i class="fa fa-smile-o pull-left"></i>
                        	<i class="fa fa-paperclip pull-right"></i>
                        	<i class="fa fa-camera pull-right"></i>                            
                        </div>
                        <div class="textbutton">
                        	<i class="fa fa-microphone"></i>
                        </div>
                    </div>                   
                    
                </div>
            </div>
		</div>	
	</div>		
        </div><!--End Row-->
		
		
	<div class="row mt-20">
        <div class="col-lg-12">
          <div class="card">

			<div class="card-body">
              <div class="table-responsive">
              <table id="default-datatable" class="table table-bordered">
                <thead>
                    <tr>
                        <th class="nosort">Sr. No.</th>
                        <th>Contact No</th>
                        <th>Compaign</th>
						<th>Template</th>
                        <th>Created On</th>
                        <th>Send On</th>	
                        <th>Status</th>
                        <th>Action</th>
                    </tr>
                </thead>
               <tbody>
					<?php $srno=1;
					for($i=0;$i<count($response);$i++){
						
						?>
						 <tr>
							<td><?= $srno; ?></td>
							<td><?= $response[$i]->contact; ?></td>
							<td><?= $response[$i]->campaignname; ?></td>
                            <td><?= $response[$i]->name; ?></td>
							<td><?= $response[$i]->createdon; ?></td>
							<td><?= $response[$i]->sendon; ?></td>
							<td><?php if($response[$i]->status == 0){ echo 'Pending';} elseif($response[$i]->status == 1){ echo 'Delivered';} else{ echo 'Error';} ?></td>
							<td align="center">
								<?php if($response[$i]->status != 1){ ?>
								<a href="<?= base_url('merchant/deletemessage/'.$response[$i]->messageId);?>" class="btn btn-sm btn-danger mb-2"> <i class=" fa fa-bin"></i> Delete</a>
								<?php } ?>
								</td>
						</tr>
					<?php $srno++; } ?>
                   
                </tbody>
            </table>
            </div>
            </div>
          </div>
        </div>
      </div><!-- End Row-->
		