<!-- Main content -->
<div class="content-wrapper">
    <!-- Dashboard content -->
    <div class="row">
        <div class="col-lg-6">
            <!-- Daily sales -->
            <div class="panel panel-flat">
                <div class="panel-heading">
                    <div class="text-right">
                        <button type="button" class="btn btn-info btn-xs" onclick="addNewLocation(0,<?= $_SESSION['agent_id'] ?>);" >Add New Location</button>          
                    </div>
                </div>
                <div class="table-responsive">
                    <table class="table text-nowrap">
                        <thead>
                            <tr>
                                <th>My Transport Locations</th>  
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>

                            <?
                            foreach ($result_list as $rect) {
                                ?>
                                <tr>
                                    <td>
                                        <div class="media-body">
                                            <div class="heading">
                                                <b><?= $rect['loc_name'] ?></b>,<br> <?= $rect['street'] ?>,<br><?= $rect['city'] ?>,<?= $rect['state'] ?> <?= $rect['zipcode'] ?>
                                            </div>


                                        </div>
                                    </td>
                                    <td style="width: 210px;">

                                        <div class="btn-group btn-group-xs" role="group">
                                            <button type="button" class="btn btn-info" onclick="editLocation(<?= $rect['id'] ?>,<?= $rect['agent_id'] ?>);" >Edit</button>
                                            <button type="button" class="btn btn-primary" id="accs<?= $rect['id'] ?>" onclick="configureLocation(<?= $rect['id'] ?>,<?= $rect['agent_id'] ?>);" >Configure</button>                                                  
                                        </div>

                                    </td>
                                </tr>  
                                <?
                            }
                            ?>
                        </tbody>
                    </table>
                </div>

            </div>
            <!-- /daily sales -->

        </div>

        <div class="col-lg-6">
            <!-- Daily sales -->
            <div class="panel panel-flat">
                <div class="panel-heading">
                    <h6 class="panel-title">Manage Transport Location</h6>
                    <div class="heading-elements">

                    </div>
                </div>

                <div class="panel-body">
                    <div id="action_panel">
                        <form class="form-horizontal form-validate-jquery" method="post" action="?">
                            <? include 'extra/locations_form.php'; ?> 
                        </form>
                    </div>
                </div>
            </div>
            <!-- /daily sales -->

        </div>
    </div>
    <!-- /dashboard content -->
</div>
<!-- /main content -->






<script type="text/javascript">
<!--
    function addNewLocation() {
        $('#location_name').html('Add New Location');
        $('#loc_name').val('');
        $('#location_id').val('0');
        $('#phone').val('');
        $('#street').val('');
        $('#city').val('');
        $('#state').val('GA');
        $('#zipcode').val('');
        return false;
    }

    function editLocation(location_id, agent) {
        if (confirm("Continue editing the selected location?")) {
// do something
            $.ajax({
                url: "/transp/mylocation_load?location_id=" + location_id + "&agent_id=" + agent
            }).done(function (data) {
                loc = JSON.parse(data)
                if (loc.status == 1) {
                    $('#location_name').html('EDIT: ' + loc.loc_name + ' = ' + loc.transporter_id);
                    $('#location_id').val(loc.transporter_id);
                    $('#loc_name').val(loc.loc_name);
                    $('#phone').val(loc.phone);
                    $('#street').val(loc.street);
                    $('#city').val(loc.city);
                    $('#state').val(loc.state);
                    $('#zipcode').val(loc.zipcode);
                } else {
                    alert('Failed to load location!');
                    addloc();
                }
            });
        }
        return false;
    }
    function configureLocation(line_id, agent) {
        if (confirm("Are you sure you want continue configure ?")) {
// do something
        } else {
            return false;
        }

        $('#accs' + line_id).prop('disabled', true);
        $.ajax({
            url: "/transp/cfglocation?proc=DETAIL&tranlator_id=" + line_id + "&agent_id" + agent
        }).done(function (data) {
            $('#action_panel').html(data);
            $('#accs' + line_id).prop('disabled', false);
        });



        return false;
    }

// -->
</script>
