<style>
    
body {
	background-color: #ffffff;
	mix-blend-mode: darken;
}

header h1 {
	margin-top: 10%;
	text-align: center;
	color: black;
	font-weight: bold;
	font-family: sans-serif;
}

table {
	margin-top: 2%;
	width: max-content;
	border: 1px solid black;
	height: 300px;
	margin-left: 23%;
}

td {
	text-align: center;
	border: 1px solid black;
}

#blank {
	color: #000;
	background-color: #fff;
}

#s {
	font-weight: 800;
	text-transform: uppercase;
	font-family: sans-serif;
	background-color: #ffffff;
}

#seminar {
	font-weight: 800;
	font-family: sans-serif;
	background-color: #ffffff;
	text-transform: uppercase;
}

#sub {
	color: black;
	font-family: sans-serif;
	font-weight: 400;
	background-color: #ffffff;
}

#sub1 {
	background-color: #fff;
}

#sub2 {
	color: black;
	text-transform: uppercase;
	background-color: #ffffff;
}

#sub3 {
	background-color: #a3c6ff;
	font-family: sans-serif;
	font-weight: 800;
}

#box1 {
	color: cornflowerblue;
	font-family: sans-serif;
	font-weight: 800;
}

#box2 {
	color: darkorange;
	font-weight: 800;
	font-family: sans-serif;
}

#box3 {
	color: darkviolet;
	font-weight: 800;
	font-family: sans-serif;
}

#box4 {
	color: green;
	font-weight: 800;
	font-family: sans-serif;
}

.p{
    	color: red;
	font-weight: 800;
	font-family: sans-serif;
    
}

#box5 {
	color: red;
	font-family: sans-serif;
	font-weight: 800;
}

#box6 {
    	background-color: #bacfcb;
	color: hotpink;
	font-weight: 800;
	font-family: sans-serif;
}

#box7 {
    	background-color: #bccda3;
	color: blue;
	font-family: sans-serif;
	font-weight: 800;
}
</style>
<!-- =============================================== -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">

    <!-- Content Header (Page header) -->
    <section class="content-header">
        <div class="header-icon">
            <i class="pe-7s-world"></i>
        </div>
        <div class="header-title">
            <h1><?php echo display('appointment_list');?></h1>
            <small><?php echo display('appointment_list');?></small>
           
        </div>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
               
            <div class="panel panel-bd">
                
                
                <div class="panel-heading">
                    
                    
                    
                    <div ><a href="<?php echo base_url();?>admin/Appointment_controller" class="btn btn-success pull-right"><?php echo display('create_appointment')?></a></div>
                    <div class="panel-title" >
                        <h4><?php echo display('appointment_list');?> </h4>
                    </div>
                </div>
                <br><br>
                
                 <?php  
                                $a = array('method'=>'post');
                                echo form_open('admin/Appointment_controller/appointment_date/search',$a);
                                ?>
                            <div class="form-inline">
                                <div class="col-md-3">
                                
                              
                                   <select class="form-control" id="doctor_id" name="doctor_id"  required>
                                        <option value="">--Select doctor--</option>
                                        <?php foreach ($doctor as $value) {
                                            echo '<option value="'.$value->doctor_id.'">'.$value->doctor_name.'</option>';
                                        }?>
                                    </select>
                                    <span class="error-msg"><?php echo form_error('doctor_id'); ?> </span>
                                </div>
                                
                                
                                 <div class="col-md-3">
							
                                <div class="form-group row">
                                   
                                    
                                    <div class="col-sm-6">
								 
                                           <input type="date" class="form-control datepicker1" size="50" name="date" id="date" required="" value="" type="text">
                                    </div>
                                </div>

                                <div class="col-md-4">
                                    <input type="submit" value="<?php echo display('search');?>" class="btn btn-primary">
                                </div>
                            </div>
                            <br><br>
                            <?php echo form_close();?>

                <div class="panel-body">
             <table width="100%" class="table table-striped table-bordered table-hover" > 
         <thead>
              
                                <td id="sub3">  الوقت        </td>   
                                <td id="sub3"> <?php echo "اسم المريض"; ?>       </td> 
                                 <td id="sub3"> <?php echo  "رقم الملف" ; ?>       </td> 
                                
                                <td id="sub3"> <?php echo "اسم الدكتور"; ?>          </td>
                                 <td id="sub3">   الإجراء        </td>
               <?php 
               
                                    foreach (@$appointmaent_info as $value) { 
                             ?>    
            <tr>
             
               
                              
                                <td id="box7"> <?php echo $value->sequence; ?>        </td>   
                                <td id="box6"> <?php echo @$value->title.' '. @$value->given_name .' '. @$value->family_name; ?>       </td> 
                                 <td id="box7"> <?php echo @$value->patient_id ; ?>       </td> 
                                
                                <td id="box6">   <?php echo @$value->doctor_name; ?>          </td>
                                 <td id="box7">    
                                 
                                 
                                 
                                               <a href="<?php echo base_url();?>admin/Appointment_controller/edit_appointment/<?php echo $value->appointment_id;?>" class="btn btn-xs btn-primary"><i class="fa fa-edit"></i></a>  
                                               
                                                <a target=”_blank” href="<?php echo "https://wa.me/+966";?><?php echo @$value->mobile_number  ;?>" class="btn btn-xs btn-success"><i class="fa fa-whatsapp">واتس اب</i></a>
                                 <a  class="btn-blue" href="<?php echo base_url();?>admin/Transfer/transfer_insert/<?php echo $value->patient_id ;?>" > <i class="fa fa-exchange"></i> </a>
                                 
                                                <a href="<?php echo base_url();?>admin/Appointment_controller/delet_appointment/<?php echo $value->appointment_id;?>" onclick="return confirm('هل تريد حذف الموعد ? ')" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></a> 
                                                <a  class="btn btn-xs btn-success" href="<?php echo base_url();?>admin/Patient_controller/procedure_skin_list/<?php echo $value->patient_id ;?>" > <i class="fa fa-eye"></i> </a>
                                 
                                 </td>
                                         
                          <?php }?>
               
            </tr>
         </thead>
         <tbody>
            
                
                
         </tbody>
      </table>
                       
                    </div>
                </div>
            </div>

        </div>
            
    </section>
</div>






<script type="text/javascript">

function sms_send(id){

    //Ajax Load data from ajax
    $.ajax({
        url : "<?php echo site_url('admin/Ajax_controller/getInfo/')?>" + id,
        type: "GET",
        dataType: "JSON",
        success: function(data)
        {
             $('[name="to"]').val(data.patient_phone);
             $('[name="name"]').val(data.patient_name);
             $('[name="patient_id"]').val(data.patient_id);
             $('[name="appointment_id"]').val(data.appointment_id);
             $('[name="appointment_date"]').val(data.date);
             $('[name="sequence"]').val(data.sequence);
             $('[name="doctor_name"]').val(data.doctor_name);
             $('[name="per_patient_time"]').val(data.per_patient_time);
             $('[name="start_time"]').val(data.start_time);
            $('#modal_form').modal('show'); // show bootstrap modal when complete loaded
            $('.modal-title').text('<?php echo display('sms');?>'); // Set title to Bootstrap modal title

        },
        error: function (jqXHR, textStatus, errorThrown)
        {
            alert('Error get data from ajax');
        }
    });
}


function reload()
{
    table.ajax.reload(null,false); //reload datatable ajax 
}


//==================
function save(){
    
    $('#btnSave').text('Sending...'); 
    $('#btnSave').attr('disabled',true);

    var url = "<?php echo site_url('admin/Ajax_controller/sendSms')?>";
    // ajax adding data to database
    $.ajax({
        url : url,
        type: "POST",
        data: $('#form').serialize(),
        dataType: "JSON",
        success: function(data){
            if(data.status) //if success close modal and reload ajax table
            {
                
                $('#modal_form').modal('hide');
                 toastr.success('Success! - <?php echo display('sms_message');?>');
                    
                setTimeout(function(){
                    window.location.href = window.location.href;
                }, 2000);
            }

            $('#btnSave').text('Send'); //change button text
            $('#btnSave').attr('disabled',false); //set button enable 
        },

        error: function (jqXHR, textStatus, errorThrown)
        {
            alert('Error!');
            $('#btnSave').text('Send'); 
            $('#btnSave').attr('disabled',false); 
        }
    });
}


// load patient name
function getTeamplate(){          
    var teamplate_id = document.getElementById('tmp').value;
    
        $.ajax({ 
            'url': '<?php echo base_url();?>' + 'admin/Ajax_controller/get_teamplate/'+teamplate_id,
            'type': 'GET', //the way you want to send data to your URL
            'data': {'teamplate_id': teamplate_id },
            'success': function(d) { 
                var container = $(".view_tmp");
                if(d){
                        container.html(d);
                    }else{ 
                        container.val(""); 
                    }
            }
        });  
}

</script>
 

