<?php 
include('accesscheck2.php');
require_once('Connections/courier.php'); 
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_courier, $courier);
$qry = mysql_query("SELECT * FROM users where (security='MEDICAL OFFICER' or security='OPTICIAN' or security='DENTIST') order by title, surname, firstnames", $courier);


?>

<div style="border: none" class="portlet box green">
    <div style="background:#108dbf" class="portlet-title">
        <div   class="caption"><i class="icon-globe"></i>Doctor Schedule</div>
        <div class="actions">
                <div class="btn-group">
                    <a class="btn btn-sm green dropdown-toggle" href="javascript:;" data-toggle="dropdown" aria-expanded="false"> Actions <i class="icon-angle-down"></i></a>
                    <ul class="dropdown-menu pull-right">
                        <li><a onclick="getstep('gp_schedule_view');" href="javascript:;"><i class="icon-refresh"></i> Refresh </a> </li>
                        <li><a onclick="view_calendar('<?php echo $_SESSION['myMM_Userid']; ?>');" href="#"><i class="icon-user-md"></i> Go to Calendar </a> </li>
                    </ul>
                </div>
            </div>
    </div>
    <div class="portlet-body">
        <div class="portlet white box">
            <div class="portlet-title">
                <div style="color:#000" class="caption"><i class="icon-user-md"></i>SELECT A DOCTOR</div>
            </div>
            <div class="portlet-body">
                <form name="form" class="form" role="form">
                    <div class="form-body">
                        <div class="row"> 
                            <!--<div class="col-md-6">-->
                                <div class="form-group">
                                    <!--<label class="col-md-4 control-label">Doctors</label>-->
                                    <div class="col-md-5">
                                        <select class="form-control" name="doctors_name" id="doctors_name">
                                            <option value="">Select Doctor</option>
                                            <?php while ($row = mysql_fetch_assoc($qry)) { ?>
                                                <option value="<?php echo $row['id']; ?>"><?php echo $row['title'] . " " . $row['surname'] . " " . $row['firstnames'] . " (" . $row['area_specialisation'] . ")"; ?></option>   
                                            <?php } ?>
                                        </select>
                                    </div>
                                </div>
                            <!--</div>-->
                        </div>
                    </div>
                </form>
            </div>
        </div>
        
           <div class="portlet white box">
            <div class="portlet-title">
                <div style="color:#000" class="caption"><i class="icon-time"></i>SET  SCHEDULE FOR ABOVE DOCTOR</div>
            </div>
            <div class="portlet-body">
                <form name="form" class="form-horizontal" role="form">
                    <div class="row">
                        <div class="col-md-5">
                            <div class="form-body">
                                <div class="row">
                                    <div class="col-md-12">
                                        <input type="text" name="event_title" id="event_title" class="form-control" placeholder="Enter Title">
                                    </div>
                                </div>
                            </div>
                             <div class="form-body">
                                <div class="row">
                                    <div class="col-md-6">
                                        <input onchange="$('#start_on_date').val(this.value);CheckCurrentDay();" type="text" name="schedule_start_date" id="schedule_start_date" class="form-control date_time_picker" placeholder="Start Date">
                                    </div>
                                    <div class="col-md-6">
                                        <input type="text" name="start_time_picker" id="start_time_picker" class="form-control time_picker" placeholder="Start Time">
                                    </div>
                                </div>
                            </div>   
                            <div class="form-body">
                                <div class="row">
                                    <div class="col-md-6">
                                        <input onchange="$('#date_time_picker').val(this.value);" type="text" name="schedule_end_date" id="schedule_end_date" class="form-control date_time_picker" placeholder="End Date">
                                    </div>
                                    <div class="col-md-6">
                                        <input type="text" name="end_time_picker" id="end_time_picker" class="form-control time_picker" placeholder="End Time">
                                    </div>
                                </div>
                            </div>    
                        </div>
                        <div class="col-md-7">
                            <table class="table">
                                <thead>
                                    <tr>
                                        <th>Repeat Mode</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <th>Repeats:</th>
                                        <td>
                                            <select onchange="Summary();" name="repeat_frequency" id="repeat_frequency">
                                                <?php for ($i = 1; $i <= 30; $i++) { ?>
                                                    <option value="<?php echo $i; ?>"><?php echo $i; ?></option>
                                                <?php } ?>
                                            </select>
                                            <select onchange="Repeat_Interval(this.value);Summary();" name="repeat_interval" id="repeat_interval" title="Repeats">
                                                <option value="0" title="Days">Days</option>
                                                <option value="2" title="Weeks">Weeks</option>
                                                <option value="3" title="Months">Months</option>
                                                <option value="4" title="Years">Years</option>
                                            </select>
                                            <input type="hidden" name="repeat_frequency_text" id="repeat_frequency_text" value="Days">
                                        </td>
                                    </tr>
                                    <tr id="repeat_on_weekly" style="display: none;">
                                        <th>Repeat On:</th>
                                        <td>
                                            <input class="repeat_on" onchange="Summary();" value="Sunday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Sunday"> S 
                                            <input class="repeat_on" onchange="Summary();" value="Monday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Monday"> M
                                            <input class="repeat_on" onchange="Summary();" value="Tuesday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Tuesday"> T
                                            <input class="repeat_on" onchange="Summary();" value="Wednesday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Wednesday"> W
                                            <input class="repeat_on" onchange="Summary();" value="Thursday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Thursday"> T
                                            <input class="repeat_on" onchange="Summary();" value="Friday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Friday"> F
                                            <input class="repeat_on" onchange="Summary();" value="Saturday" multiple="" type="checkbox" style="" name="repeat_on[]" title="Saturday"> S
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>Start On:</th>
                                        <td>
                                            <input type="text" readonly="" style="box-shadow:none;border: 1px solid #e5e5e5;" name="start_on_date" id="start_on_date">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>Ends:</th>
                                        <td>
                                            <input type="radio" name="ends_on_text" id="" value="Never"> Never <br>
                                            <!--<input type="radio" name="ends_on_text" id=""> After  &nbsp;&nbsp; <input type="text" name="occurences"> Occurrences <br>-->
                                            <input checked="" type="radio" name="ends_on_text" id="" value="On"> On &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input readonly="" style="box-shadow:none;border: 1px solid #e5e5e5;" type="text" name="ends_on_date" id="date_time_picker" class="date_time_picker" placeholder="Ends On">
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>Summary:</th>
                                        <td style="font-weight:bold;color:blue;" id="summary_wrapper">
                                           Daily 
                                        </td>
                                    </tr>
                                </tbody>
                            </table>            
                        </div>
                    </div>
                    <div class="form-actions right" style="background-color: white;border: none;">
									<button type="button" class="btn default">Reset</button>
                                                                        <button onclick="process_information('getstep.php', 'save_new_schedule');return false;" type="submit" class="btn green">Save</button>
								</div>
                </form>
            </div>
        </div>

    </div>
</div>