 <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</div>
       					<?php echo ($this->session->flashdata('form_error'));?>
				   <?php echo ($this->session->flashdata('file_error'));?>
                   
        			</div>
        		</div>
        	</div>
        </div><!--End Row-->
        
        <div class="row">
        	<div class="col-lg-12">
        		<form action="#" method="post" method="post" enctype="multipart/form-data">
			   <input type="hidden" name="id" value="<?= @$id; ?>">
                <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">Merchant Name</label>
                                        <div class="col-sm-9">
                                          <select name="merchants[]" class="multi-select" multiple="multiple" id="my_multi_select3">
													<option value="0">For All Merchants</option>
													<?php foreach($merchantoptions as $val){ 
													
													if(is_array($templates_merchant)){
													$key = array_search($val->merchantId, array_column(@$templates_merchant, 'merchantId'));
													$key = preg_replace('/\s+/', '', $key);
												}else{
													$key='';
												}
												
												if($key!=''){ $optionstatus='selected';}else{$optionstatus='';}
										
													echo "<option value='".$val->merchantId."' ".$optionstatus.">".$val->storename."</option>";
													}?>
                                                </select>
                        
                                        </div>
                                </div>
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Template Name</label>
                                        <div class="col-sm-9">
                                            <input type="text" name="name" class="form-control" placeholder="Enter Template Name" <?php if(@$templates['templatename'] !=''){echo "value='".@$templates['templatename']."'";}?>>
                                        </div>
                                </div>
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Operator</label>
                                        <div class="col-sm-9">
                                           	<select class="form-control" name="operator">
                                            	<option value=''>Select Operator</option>
												<?php foreach($operatorsoptions as $val){ 
													if($val->title == @$templates['operator']){
													echo "<option value='".$val->title."' selected>".$val->title."</option>";
													}else{
													echo "<option value='".$val->title."'>".$val->title."</option>";
													}
												}?>
                                            </select>
                                        </div>
                                </div>
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Language</label>
                                        <div class="col-sm-9">
                                           	<select class="form-control" name="language">
                                            	<option value=''>Select Language</option>
												<?php foreach($languageoptions as $val){ 
												if($val->symbol == @$templates['language']){
													echo "<option value='".$val->symbol."' selected>".$val->language." (".$val->symbol.")</option>";
												}else{
													echo "<option value='".$val->symbol."'>".$val->language." (".$val->symbol.")</option>";
													}
												}?>
                                            </select>
                                        </div>
                                </div>
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Category</label>
                                        <div class="col-sm-9">
                                         	<select class="form-control" name="category">
										 	<option value=''>Select Category</option>
										 	<?php foreach($categoryoptions as $val){ 
													if($val->type == @$templates['category']){
														echo "<option value='".$val->type."' selected>".$val->type."</option>";
													}else{
														echo "<option value='".$val->type."'>".$val->type."</option>";
													}
												}?> 
                                            </select>     
                                        </div>
                                </div>
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Type</label>
                                        <div class="col-sm-9">
                                          <select class="form-control" name="type"> <!-- id="watype"  -->
                                           <option value=''>Select Template Type</option>
										   <?php foreach($typeoptions as $val){ 
													if($val == @$templates['header_type']){
													echo "<option value='".$val."' selected>".$val."</option>";
													}else{
													echo "<option value='".$val."'>".$val."</option>";
													}
												}?>
                                            </select>  
                                        </div>
                                </div>
                                
                                <div class="form-group row" id="mediashow" style="display:none">
                                        <label for="input-21" class="col-sm-3 col-form-label">Image/Video/Document</label>
                                        <div class="col-sm-9">
                                            <input type="file" name="headerfile" id="headerfile" class="form-control  prevfield">
                                            <input type="hidden" id="prvlink" value=''>
                                            <input type="hidden" name="headerfileold" value=''>
                                        </div>
                                </div>
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Header Text</label>
                                        <div class="col-sm-9">
                                            <input type="text" name="headertext" class="form-control prevfield" id="headertext" placeholder="Enter Header Text" <?php if(@$templates['header_value'] !=''){echo "value='".@$templates['header_value']."'";}?>>
                                        </div>
                                </div>
                               
                               
                                
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Body Text </label>
                                        <div class="col-sm-9">
                                            <textarea class="form-control prevfield" name="body"  id="bodytxt"><?php if(@$templates['body'] !=''){echo @$templates['body'];}?></textarea>
										<p style="color:#000;">* Use <b>{{var}}</b> for Variable</p>
										</div>
                                </div>
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Footer Text</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control prevfield" name="footertext" id="footertxt" placeholder="Enter Footer Text" <?php if(@$templates['footer'] !=''){echo "value='".@$templates['footer']."'";}?>>
                                        </div>
                                </div>
                                
                                 <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Button One (Text/Link)</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control prevfield" name="btn1text" id="btn1text" placeholder="Enter Text" <?php if(@$templates['btn_1_text'] !=''){echo "value='".@$templates['btn_1_text']."'";}?>>
                                        </div>
                                         <div class="col-sm-5">
                                            <input type="text" class="form-control prevfield" name="btn1url" id="btn1url" placeholder="Enter URL" <?php if(@$templates['btn_1_url'] !=''){echo "value='".@$templates['btn_1_url']."'";}?>>
                                        </div>
                                </div>
                                
                                 <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Button Two (Text/Link)</label>
                                        <div class="col-sm-4">
                                            <input type="text" class="form-control prevfield" name="btn2text" id="btn2text" placeholder="Enter Text"  <?php if(@$templates['btn_2_text'] !=''){echo "value='".@$templates['btn_2_text']."'";}?>>
                                        </div>
                                         <div class="col-sm-5">
                                            <input type="text" class="form-control prevfield" name="btn2url" id="btn2url" placeholder="Enter URL"  <?php if(@$templates['btn_2_url'] !=''){echo "value='".@$templates['btn_2_url']."'";}?>>
                                        </div>
                                </div>
                                <div class="form-group row">
                                        <label for="input-21" class="col-sm-3 col-form-label">Status</label>
                                        <div class="col-sm-9">
                                         	<select class="form-control" name="status">
										 	<option value='1' <?php if(@$templates['status']){echo "selected";}?>>Approved</option>
										 	<option value='0' <?php if(!@$templates['status']){echo "selected";}?>>Disapproved</option>
                                            </select>     
                                        </div>
                                </div>
                                 <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> Update</button>
                                      </div>
                                    </div>
                                
                            </div>
                        </div>
                     </div>
                  </div>
                  
                  
        	</div>
           </form>
        </div><!--End Row-->      
	
	