<?php include('accesscheck2.php'); 
require_once('Connections/courier.php');
require_once('functions/functions.php');

mysql_select_db($database_courier, $courier);
$query_rsodest_patient = "SELECT * FROM branches where id='$id'";
$rsodest_patient = mysql_query($query_rsodest_patient, $courier) or die(mysql_error());
$row_rsodest_client = mysql_fetch_assoc($rsodest_patient); ?>

<div class="page-bar">
    <ul class="page-breadcrumb">
        <li>
            <i class="icon-home"></i>
            <a href="index.html">Home</a>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span>Admin Utilities</span>
            <i class="fa fa-angle-right"></i>
        </li>
        <li>
            <span>Edit Branch Details</span>
        </li>
    </ul>
    <div class="page-toolbar">
        <div class="btn-group pull-right">
            <button type="button" class="btn btn-fit-height grey-salt dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> Actions
                <i class="fa fa-angle-down"></i>
            </button>
            <ul class="dropdown-menu pull-right" role="menu">
                <li onclick="getstep('edit_branch_details','<?php echo $id; ?>');">
                    <a href="#">
                        <i class="icon-refresh"></i> Refresh 
                    </a>
                </li>
                <li onclick="getstep('add_new_branch');">
                    <a href="#">
                        <i class="icon-plus"></i> Add New Branch 
                    </a>
                </li>
                <li onclick="getstep('list_branches');">
                    <a href="#">
                        <i class="fa fa-list"></i> List of Branches 
                    </a>
                </li>
            </ul>
        </div>
    </div>
</div>
                    <!-- END PAGE HEADER-->
                    <div class="row">
                        <div class="col-md-12">
                            <div class="profile-content">
                                <div class="row">
                                    <div class="col-md-12">
                                        <div class="portlet light " id="patient_page_wrapper" style="min-height:800px;">
                                            <div class="portlet-title">
                                                <div class="caption caption-md">
                                                    <i class="icon-globe theme-font hide"></i>
                                                    <span class="caption-subject bold uppercase font-dark"> BRANCH DETAILS </span>
                                                </div>
                                            </div>
                                            <div class="portlet-body form">
                                                <div id="success_error_info_display"></div>
                                                <form role="form" action="#" class="form-horizontal" id="save_new_branch">
                                                    <div class="row"> 
                                                        <div class="form-body">
                                                            
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> Branch Name </label>
                                                                <div class="col-md-7">
                                                                    <input type="text" name="branch_name" id="branch_name" class="form-control" value="<?php echo $row_rsodest_client['branch_name'] ?>"> 
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> Branch Code </label>
                                                                <div class="col-md-5">
                                                                    <input type="text" name="branch_code" id="branch_code" class="form-control" value="<?php echo $row_rsodest_client['branch_code'] ?>"> </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> Postal Address </label>
                                                                <div class="col-md-5">
                                                                    <input type="text" name="postal_address" id="postal_address" class="form-control" value="<?php echo $row_rsodest_client['postal_address'] ?>"> </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> Branch Location </label>
                                                                <div class="col-md-5">
                                                                    <input type="text" name="branch_location" id="branch_location" class="form-control" value="<?php echo $row_rsodest_client['location'] ?>"> </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> City/Town </label>
                                                                <div class="col-md-5">
                                                                    <input type="text" name="branch_city" id="branch_city" class="form-control" value="<?php echo $row_rsodest_client['city'] ?>"> </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> Region </label>
                                                                <div class="col-md-5">
                                                                    <select name="region"  id="region" class="form-control">
                                                                            <option value="">-- SELECT --</option>
                                                                            <?php
                                                                            $query_rsodestship_country = "SELECT * FROM regions order by region";
                                                                            $rsodestship_country = mysql_query($query_rsodestship_country, $courier) or die(mysql_error());
                                                                            $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                                                            $totalRows_rsodestship_country = mysql_num_rows($rsodestship_country);
                                                                            do {
                                                                                ?>
                                                                                <option value="<?php echo $row_rsodestship_country['region']; ?>" <?php if ($row_rsodest_client['region'] == $row_rsodestship_country['region']) { ?>selected="selected"<?php } ?>><?php echo $row_rsodestship_country['region'] ?></option>
                                                                                <?php
                                                                            } while ($row_rsodestship_country = mysql_fetch_assoc($rsodestship_country));
                                                                            $rows = mysql_num_rows($rsodestship_country);
                                                                            if ($rows > 0) {
                                                                                mysql_data_seek($rsodestship_country, 0);
                                                                                $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                                                            }
                                                                            ?>
                                                                        </select>
                                                                </div>
                                                            </div>
                                                            <div class="form-group">
                                                                <label class="col-md-3 control-label"> Country </label>
                                                                <div class="col-md-5">
                                                                    <select name="country"  id="country" class="form-control">
                                                                            <option value="">-- SELECT --</option>
                                                                            <?php
                                                                            $query_rsodestship_country = "SELECT * FROM countrylist order by country";
                                                                            $rsodestship_country = mysql_query($query_rsodestship_country, $courier) or die(mysql_error());
                                                                            $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                                                            $totalRows_rsodestship_country = mysql_num_rows($rsodestship_country);
                                                                            do {
                                                                                ?>
                                                                                <option value="<?php echo $row_rsodestship_country['country']; ?>" <?php if ($row_rsodest_client['country'] == $row_rsodestship_country['country']) { ?>selected="selected"<?php } ?>><?php echo $row_rsodestship_country['country'] ?></option>
                                                                                <?php
                                                                            } while ($row_rsodestship_country = mysql_fetch_assoc($rsodestship_country));
                                                                            $rows = mysql_num_rows($rsodestship_country);
                                                                            if ($rows > 0) {
                                                                                mysql_data_seek($rsodestship_country, 0);
                                                                                $row_rsodestship_country = mysql_fetch_assoc($rsodestship_country);
                                                                            }
                                                                            ?>
                                                                        </select>
                                                            </div>
                                                    </div>
                                                    <div class="form-actions right">
                                                        <button type="reset" class="btn default"> Reset </button>
                                                        <a class="btn green" onclick="saveInformation2('update_branch_details','<?php echo $id; ?>','form#save_new_branch','#currentarea');return false;"> Update Branch </a>
                                                    </div>
                                            </div>
                                        </div>
                                                </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>