<html>
    <head>
        <TITLE><?php
print($config[0][1]);
if (substr_count($_SERVER['SCRIPT_NAME'], 'index.php') > 0 AND $_SERVER['QUERY_STRING']) {
    print (" | " . $_SERVER['QUERY_STRING'] . " ");
}
print(" | " . $config[2][1]);
checklevel(1, $_REQUEST['clientid']);
?></TITLE>

        <meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, maximum-scale=1">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

        <meta charset="utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

        <meta name="description" content="<?php echo $config[81][1] ?>" />
        <meta name="keywords" content="<?php echo $config[83][1] ?>" />
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
        <link rel="stylesheet" type="text/css" media="screen" href="css/style.css" />

        <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700' rel='stylesheet' type='text/css'>

        <link rel="stylesheet" type="text/css" href="content/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="content/css/bootstrap-responsive.css">
        <link rel="stylesheet" type="text/css" href="content/css/bootmetro.css">
        <link rel="stylesheet" type="text/css" href="content/css/bootmetro-tiles.css">
        <link rel="stylesheet" type="text/css" href="content/css/bootmetro-charms.css">
        <?php if ($theme == 'light') { ?>
            <link rel="stylesheet" type="text/css" href="content/css/metro-ui-light.css">
        <?php } else { ?>
            <link rel="stylesheet" type="text/css" href="content/css/metro-ui-semilight.css">
        <?php } ?>
        <link rel="stylesheet" type="text/css" href="content/css/icomoon.css">

        <link rel="shortcut icon" href="favicon.ico">
        <link rel="apple-touch-icon-precomposed" sizes="144x144" href="content/ico/apple-touch-icon-144-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="114x114" href="content/ico/apple-touch-icon-114-precomposed.png">
        <link rel="apple-touch-icon-precomposed" sizes="72x72" href="content/ico/apple-touch-icon-72-precomposed.png">
        <link rel="apple-touch-icon-precomposed" href="content/ico/apple-touch-icon-57-precomposed.png">

        <script src="scripts/modernizr.min.js"></script>

        <script type="text/javascript" src="js/bootstrap.js"></script>

        <script type="text/javascript" src="js/jquery.js"></script>
<!--        <script type="text/javascript" src="js/jquery.tablednd.js"></script>-->
        <script type="text/javascript" src="js/color_picker.js"></script>
        <script type="text/javascript" src="js/calendar.js"></script>
        <script type="text/javascript" src="js/btip.js"></script>

        <script type="text/javascript" src="js/jquery-ui.custom.min.js"></script>

        <?php
        include_once("postget.php");
        include_once("common.php");
        ?>



        <script>

            OCULTO="none";
            VISIBLE="block";

            function mostrar(blo,bloqueon,bloqueoff) {
                document.getElementById(blo).style.display=VISIBLE;
                document.getElementById(bloqueoff).style.display=VISIBLE;
                document.getElementById(bloqueon).style.display=OCULTO;
            }

            function ocultar(blo,bloqueon,bloqueoff) {
                document.getElementById(blo).style.display=OCULTO;
                document.getElementById(bloqueoff).style.display=OCULTO;
                document.getElementById(bloqueon).style.display=VISIBLE;
            }


            function MostrarFilas(Fila) {
                var elementos = document.getElementsByName(Fila);
                for (i = 0; i < elementos.length; i++)
                    elementos[i].style.display ="";
            }

            function OcultarFilas(Fila) {
                var elementos = document.getElementsByName(Fila);
                for (k = 0; k < elementos.length; k++)
                    elementos[k].style.display = "none";
            }

            function Activar(blo) {
                var oldcurrent = document.getElementById('current').getAttribute('name');
                document.getElementById('current').id = oldcurrent;
                document.getElementById(blo).id = 'current';
            }

        </script>

        <script type="text/javascript">
            $(document).ready(function() {
                $('#table-1').tableDnD(
                {
                    onDrop: function(table, row) {
                        //alert("Result of $.tableDnD.serialise() is "+$.tableDnD.serialize());
                        //$('#AjaxResult').load("setorder.php?"+$.tableDnD.serialize());
                        //$.post("setorder.php",$.tableDnD.serialize());

                        //$.tableDnD.serialize();
                        $.ajax({
                            type: "POST",
                            url: "setorder.php",
                            data: $.tableDnD.serialize()
                        });
                    },
                    dragHandle: "dragHandle",
                    onDragClass: "currentrow"
                }
            );
                $("#table-1 tr").hover(function() {
                    $(this.cells[0]).addClass('showDragHandle');
                }, function() {
                    $(this.cells[0]).removeClass('showDragHandle');
                });

            });
        </script>


        <?php
        if ($config[122][1] <> 'UA-' AND $config[122][1] <> '') {
            ?>
            <script type="text/javascript">

                var _gaq = _gaq || [];
                _gaq.push(['_setAccount', '<?php echo $config[122][1]; ?>']);
                _gaq.push(['_trackPageview']);

                (function() {
                    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                })();

            </script>
            <?php
        }
        ?>


    </head>

    <body data-accent="blue">

        <!-- Header
        ================================================== -->
        <header id="nav-bar" class="container-fluid">
            <div class="row-fluid">
                <div class="span8">
                    <div id="header-container">
                        <?php if (!stristr($_SERVER['SCRIPT_FILENAME'], 'index.php') AND !stristr($_SERVER['SCRIPT_FILENAME'], 'main.php')) { ?>
                            <a id="backbutton" class="win-backbutton" href="./index.php"></a>
                        <?php } ?>
                        <h5>Help Desk</h5>
                        <div class="dropdown">
                            <a class="header-dropdown dropdown-toggle accent-color" data-toggle="dropdown" href="#">
                                <?php
                                if (isset($pagetitle)) {
                                    echo ucfirst($pagetitle);
                                } else {
                                    echo ucfirst(_HOME);
                                }
                                ?>
                                <b class="caret"></b>
                            </a>
                            <ul class="dropdown-menu">

                                <?php
                                if ($_SESSION['hd_accesslvl'] == 1) {
                                    if (substr($config[68][1], 2, 1) == '1') {
                                        echo '<li><a href="./announcements.php">' . ucfirst(_menu_ANNOUNCEMENTS) . '</a></li>';
                                    }
                                    if (substr($config[64][1], 2, 1) == '1') {
                                        echo '<li><a href="./tickets.php">' . ucfirst(_menu_TICKETS) . '</a></li>';
                                    }
                                    if (substr($config[67][1], 2, 1) == '1') {
                                        echo '<li><a href="./faq.php">' . ucfirst(_menu_FAQ) . '</a></li>';
                                    }
                                    if (substr($config[71][1], 2, 1) == '1') {
                                        echo '<li><a href="./manuals.php">' . ucfirst(_menu_MANUALS) . '</a></li>';
                                    }
                                    if (substr($config[69][1], 2, 1) == '1') {
                                        echo '<li><a href="./downloads.php">' . ucfirst(_menu_DOWNLOADS) . '</a></li>';
                                    }
                                    if (substr($config[65][1], 2, 1) == '1') {
                                        echo '<li><a href="./contactus.php">' . ucfirst(_menu_CONTACT) . '</a></li>';
                                    }
                                } elseif ($_SESSION['hd_accesslvl'] > 1) {
                                    echo '<li><a href="./addclient.php">' . ucfirst(_ADD_NEW_CLIENT) . '</a></li>';
                                    echo '<li><a href="./clientslist.php?active=9">' . ucfirst(_ALL_CLIENTS) . '</a></li>';
                                    echo '<li><a href="./clientslist.php?active=-2">' . ucfirst(_SUSPENDED_CLIENTS) . '</a></li>';
                                    echo '<li><a href="./clientslist.php?active=-1">' . ucfirst(_ELIMINATED_CLIENTS) . '</a></li>';
                                    echo '<li><a href="./clientslist.php?active=-9">' . ucfirst(_CLIENTS_NOT_SUBSCRIBED) . '</a></li>';
                                }
                                ?>

                                <li class="divider"></li>
                                <li><a href="./index.php"><?php echo ucfirst(_HOME); ?></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div id="top-info" class="pull-right">
                    <a href="#" class="pull-left">
                        <div class="top-info-block">
                            <?php
                            if ($_SESSION['hd_accesslvl'] == 1) {
                                $cldata = query("SELECT first, last FROM hd_clients WHERE clientid='" . $_SESSION['hd_clientid'] . "'", 1);
                                if ($cldata['last'] == '') {
                                    echo '<h3><a href="./editclient.php">' . lang('_CLICK_HERE') . '</a></h3>';
                                } else {
                                    echo '<h3><a href="./clientdata2.php">' . $cldata['first'] . ' ' . $cldata['last'] . '</a></h3>';
                                }
                            } else {
                                echo '<h3><a href="#">' . $_SESSION['hd_idc'] . '</a></h3>';
                            }
                            ?>
                            <h4><a href="./logout.php"><?php echo lang('_LOGOUT') ?></a></h4>
                        </div>
                        <div class="top-info-block">
                            <b class="icon-user"></b>
                        </div>
                    </a>
                    <hr class="separator pull-left"/>
                    <a id="settings" class="pull-left" href="#">
                        <b class="icon-settings"></b>
                    </a>
                </div>
            </div>
        </header>




        <div id="charms" class="win-ui-dark">

            <div id="theme-charms-section" class="charms-section">
                <div class="charms-header">
                    <a href="#" class="close-charms win-command">
                        <span class="win-commandimage win-commandring">&#xe05d;</span>
                    </a>
                    <h2><?php echo lang('_SETTINGS') ?></h2>
                </div>

                <div class="row-fluid">
                    <?php
                    ////////////////////// change lang   ////////////////////////////////////////
                    if ($config[104][1] == 1) {
                        selectlanguagecookie($language);
                        echo $content;
                    }

                    function selectlanguagecookie() {
                        $pagefrom = $_SERVER['REQUEST_URI'];

                        global $currentlang, $content;
                        $content = "<form method='post'>" . _LANGUAGE . ":
                            <select name='newlanguage' onChange='top.location.href=this.options[this.selectedIndex].value'>";
                        $result = mysql_query("SHOW COLUMNS FROM hd_languages");
                        if (mysql_num_rows($result) > 0) {
                            while ($row = mysql_fetch_assoc($result)) {
                                if ($row[Field] <> 'original') {
                                    $content .= "<option value='cookielang.php?currentlang=$row[Field]&file=$pagefrom' ";
                                    if ($row[Field] == $currentlang)
                                        $content .= " selected";
                                    $content .= ">" . langname($row[Field]) . "</option>";
                                }
                            }
                        }
                        $content .= "</select></form>";
                        return $content;
                    }

                    //////////////////////////////////////////////////////////// change lang (end)
                    /////////////editar datos del cliente
                    checklevel(1, $_REQUEST['clientid']);

                    if (($_SESSION['hd_accesslvl'] == 1 OR $thisclient == 1) AND $_SESSION['hd_clientid']) {

                        if ($_SESSION['hd_accesslvl'] == 1) {
                            $qClientActive = "UPDATE hd_clients SET preflang='" . $currentlang . "' WHERE clientid=" . $_SESSION['hd_clientid'] . "";
                        }
                        mysql_query($qClientActive, $db_link);


                        print("<div>");

                        $clienteactual = query('SELECT first,last,company,start,active,preflang FROM hd_clients WHERE clientid=' . $_SESSION['hd_clientid'], 1);

                        if ($clienteactual[preflang] <> '') {
                            $_SESSION['preflang'] = $clienteactual[preflang];
                        } else {
                            $_SESSION['preflang'] = $currentlang;
                        }

                        print("<span>
                            " . _CLIENT . ": " . $_SESSION['hd_clientid'] . "
                            <br>" . _LANGUAGE . ": " . $clienteactual['preflang'] . "
                            <br>" . _COUNTRY . ": ");
                        banderacliente($_SESSION['hd_clientid']);
                        print("</span>");


                        if ($clienteactual[company]) {
                            print ("<br><span>" . $clienteactual[company] . "</span>");
                        }
                        print("<br><span>" . $clienteactual[first] . " " . $clienteactual[last] . "</span>");

                        print("<br><span> " . _CLIENT_SINCE . ": " . date($df, $clienteactual[start]) . "
                            <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            (" . TimeAgo($clienteactual[start], time()) . ")</span>");
                        print("</div>");
                    }

                    /////////////////////////////////////
                    ?>

                </div>
            </div>
        </div>



    <?php
    checklevel(1, $_REQUEST['clientid']);



    if ($_SESSION['hd_accesslvl'] > 1) {

        // imprimir el bot_bg.gif
        //if ($thisclient == '1') {
        print("<table border='0' width='100%' cellpadding='0' cellspacing='0'>");
        print('</tr>
		<tr>
		<td class="menubar_bot" align="center" valign="top" width="99%" height="' . $bg_altura[1] . '"></td>
		</tr>'
        );
        print("</table>");
        //}

        print('<br>');

    }

/////////////////////////////////// imprimir los mensajes
    if (isset($_SESSION['msgbox']) AND $_SESSION['msgbox'] <> '') {
        print ($_SESSION['msgbox']);
    }
    $_SESSION['msgbox'] = '';
///////////////////////////////////

    if ($_SESSION['hd_accesslvl'] > 1 AND $currentlang <> $_SESSION['preflang'] AND $thisclient == 1) {
        print(messagetopinthispage(lang('_THIS_CLIENT_SPEAKS') . ' <i>"' . langname($_SESSION['preflang']) . '"</i>', '', 2));
    }

    if ($_SESSION['hd_accesslvl'] > 1 AND $_SESSION['hd_clientid']) {
        // imprimir un mensaje si el cliente está suspendido o eliminado.
        $suspendido = query("SELECT suspended, active FROM hd_clients WHERE clientid='" . $_SESSION['hd_clientid'] . "'", 1);
        if ($suspendido['suspended'] == 1) {
            print(
                    messagetopinthispage(lang('_THIS_ACCOUNT_IS_SUSPENDED'), "<a href='" . $serverurl . "/tickets.php?reverse=suspension&clientid=" . $_SESSION['hd_clientid'] . "'>" . lang('_REMOVE_SUSPENSION') . "</a>", 2)
            );
        }
        if ($suspendido['active'] == -1) {
            print(
                    messagetopinthispage(lang('_THIS_ACCOUNT_IS_DELETED'), "<a href='" . $serverurl . "/tickets.php?reverse=elimination&clientid=" . $_SESSION['hd_clientid'] . "'>" . lang('_REVERSE_ELIMINATION') . "</a>", 0)
            );
        }
    }


    print("<a name='templatetop'></a>");
    ?>

    <!-- Grab Google CDN's jQuery. fall back to local if necessary -->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script>window.jQuery || document.write("<script src='scripts/jquery-1.7.2.min.js'>\x3C/script>")</script>

    <script type="text/javascript" src="scripts/google-code-prettify/prettify.js"></script>
    <script type="text/javascript" src="scripts/jquery.mousewheel.js"></script>
    <script type="text/javascript" src="scripts/jquery.scrollTo.js"></script>
    <script type="text/javascript" src="scripts/bootstrap.min.js"></script>
    <script type="text/javascript" src="scripts/bootmetro.js"></script>
    <script type="text/javascript" src="scripts/bootmetro-charms.js"></script>
    <script type="text/javascript" src="scripts/demo.js"></script>

    <script type="text/javascript">
        $(".metro").metro();
    </script>


    <?php
    if ($_SESSION['hd_accesslvl'] > 1) {
        include("menu_admin.php");
    }
    ?>