<?php
$translation = \DynCom\mysyde\common\classes\Registry::get("translation");
$formname    = "form_contact_list";
$inputname   = "input_id";
?>
    <ul class="toolbar_menu">
        <?= button("new", $translation->get("new"), $formname, "loadCard('new', true)"); ?>
        <!-- <?= button("updateFromJSON", $translation->get("updateFromJSON"), $formname, "loadCard('updateFromJSON', true)"); ?> -->
    </ul>

<div id="mainContent">

    <?php echo current_website_language($site, $language); ?>
    <h1><?php echo get_translation('intranet_top_contact'); ?></h1>

    <form id="<?= $formname ?>" name="<?= $formname ?>" method="post">
        <input type="hidden" class="selected_linklist_row" name="input_id" value="" />

        <div class="requestLoader"></div>
        <?php
$query  = "SELECT DISTINCT main_contact.id, 
main_contact.name AS '" . $translation->get("name") . "',
main_contact.email AS '" . $translation->get("email") . "',
main_department.description AS '" . $translation->get("top_department") . "'
FROM main_contact 
LEFT JOIN main_contact_department ON main_contact.id = main_contact_department.main_contact_id
LEFT JOIN main_department ON main_department.id = main_contact_department.main_department_id
GROUP BY main_contact.id, main_contact.name, main_contact.email
ORDER BY main_contact.name ASC";
// var_dump($query);
$format = array("option", "text", "text", "text");
if ($result = mysqli_query($GLOBALS['mysql_con'], $query)) {
    linklist($result, "form_contact_list", $format);
}
?>


    </form>
</div>

<?php
// require_once("api.php");