<!-- 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="addtranslator()">Add New Translator</button>          
                    </div>
                </div>

                <div class="table-responsive">
                    <table class="table text-nowrap">
                        <thead>
                            <tr>
                                <th>Language</th>  
                                <th>Name</th>  
                                <th>Phone</th>   
                                <th>Address</th>    
                                <th></th>
                            </tr>
                        </thead>
                        <tbody>

                            <?
                            foreach ($result_list as $rect) {
                                ?>
                                <tr>
                                    <td>
                                        <div class="media-body"> </div>
                                        <div class="heading">
                                            <b><?= $rect['language'] ?> 
                                        </div>
                                    </td>  

                                    <td>
                                        <div class="media-body"> </div>
                                        <div class="heading">
                                            <b><?= $rect['firstname'] ?> <?= $rect['lastname'] ?></b>
                                        </div>
                                    </td>   
                                    <td>
                                        <div class="media-body"> </div>
                                        <div class="heading">
                                            <b><?= $rect['phone'] ?> 
                                        </div>
                                    </td>   

                                    <td>
                                        <div class="media-body"> </div>
                                        <div class="heading">
                                            <?= $rect['street'] ?>,<br><?= $rect['city'] ?>,<?= $rect['state'] ?> <?= $rect['zipcode'] ?>
                                        </div>
                                    </td>   
                                    <td style="width:190px;">   
                                        <div class="btn-group btn-group-xs" role="group">
                                            <button type="button" class="btn btn-info" onclick="edittranslator(<?= $rect['interpreter_id'] ?>,<?= $rect['agent_id'] ?>);">Edit</button>
                                            <button type="button" class="btn btn-primary" id="accs<?= $rect['interpreter_id'] ?>" onclick="manageLanguage(<?= $rect['interpreter_id'] ?>,<?= $rect['agent_id'] ?>);">languages</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 Translators</h6>
                    <div class="heading-elements">

                    </div>
                </div>

                <div class="panel-body">
                    <div id="action_panel_translator" style="display:none;"></div>
                    <div id="action_panel">
                        <?= $message ?>
                        <form class="form-horizontal form-validate-jquery" method="post" action="?">
                            <? include 'extra/translators_form.php'; ?> 
                        </form>
                    </div>

                </div>

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

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



<script type="text/javascript">
<!--
    var translator_saved = false;
    function addtranslator() {
        if (translator_saved) {
            $('#action_panel').html($('#action_panel_translator').html());
            translator_saved = false;
            $('#action_panel_translator').html('Error');
        }
        $('#translator_name').html('Add New Translator');
        $('#interpreter_id').val('0');
        $('#email').val('');
        $('#firstname').val('');
        $('#lastname').val('');
        $('#phone').val('');
        $('#street').val('');
        $('#city').val('');
        $('#state').val('GA');
        $('#zipcode').val('');
        return false;
    }

    function edittranslator(translator_id, agent) {
        if (confirm("Are you sure you want continue ?")) {
// do something
            if (translator_saved) {
                $('#action_panel').html($('#action_panel_translator').html());
                translator_saved = false;
                $('#action_panel_translator').html('Error');
            }
            $.ajax({
                url: "/transp/translators_load?translator_id=" + translator_id + "&agent_id=" + agent
            }).done(function (data) {
                translator = JSON.parse(data)
                if (translator.status == 1) {
                    $('#translator_name').html('EDIT: ' + translator.firstname + ' ' + translator.lastname + ' = ' + translator.interpreter_id);
                    $('#interpreter_id').val(translator.interpreter_id);
                    $('#email').val(translator.email);
                    $('#firstname').val(translator.firstname);
                    $('#lastname').val(translator.lastname);
                    $('#phone').val(translator.phone);
                    $('#street').val(translator.street);
                    $('#city').val(translator.city);
                    $('#state').val(translator.state);
                    $('#zipcode').val(translator.zipcode);
// {"ADDED":"2017-10-13 16:10:39.226379","AGENT_ID":"4","CITY":"MARIETTA","COUNTRY":"US","EMAIL":"SES66181+INTERPRETER76@GMAIL.COM","FIRSTNAME":"ANATOLII","ID":"15","INTERPRETER_ID":"15","LASTNAME":"OKHOTNIKOV","LOC":"104.238.127.115","PHONE":"664651123","PID":"100","STATE":"GA","STATUS":"1","STREET":"2600 BENTLEY RD SE","ZIPCODE":"30067","INTERNAL_RETURN":"0"}			
                } else {
                    alert('Failed to load translator!');
                    addtranslator();
                }
            });
        }
        return false;
    }

    function manageTranslator(line_id, agent) {
        if (confirm("Are you sure you want continue ?")) {
// do something
        } else {
            return false;
        }
        return false;
    }

    function manageLanguage(line_id, agent) {
        if (confirm("Are you sure you want configure translators languages ?")) {
// do something
            if (translator_saved) {
                // We have saved the translator form, so nothing to do here
            } else {
                $('#action_panel_translator').html($('#action_panel').html());
                translator_saved = true;
            }
        } else {
            return false;
        }


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


        return false;
    }



// -->
</script>



<!--
vi:ts=2
-->
