Exemplo n.º 1
0
 function InvoicePaid($args)
 {
     $class = new AktuelSms();
     $template = $class->getTemplateDetails(__FUNCTION__);
     if ($template['active'] == 0) {
         return null;
     }
     $settings = $class->getSettings();
     if (!$settings['api'] || !$settings['apiparams'] || !$settings['gsmnumberfield'] || !$settings['wantsmsfield']) {
         return null;
     }
     $userSql = "\n        SELECT a.duedate,b.id as userid,b.firstname,b.lastname,`c`.`value` as `gsmnumber` FROM `tblinvoices` as `a`\n        JOIN tblclients as b ON b.id = a.userid\n        JOIN `tblcustomfieldsvalues` as `c` ON `c`.`relid` = `a`.`userid`\n        JOIN `tblcustomfieldsvalues` as `d` ON `d`.`relid` = `a`.`userid`\n        WHERE a.id = '" . $args['invoiceid'] . "'\n        AND `c`.`fieldid` = '" . $settings['gsmnumberfield'] . "'\n        AND `d`.`fieldid` = '" . $settings['wantsmsfield'] . "'\n        AND `d`.`value` = 'on'\n        LIMIT 1\n    ";
     $result = mysql_query($userSql);
     $num_rows = mysql_num_rows($result);
     if ($num_rows == 1) {
         $UserInformation = mysql_fetch_assoc($result);
         $template['variables'] = str_replace(" ", "", $template['variables']);
         $replacefrom = explode(",", $template['variables']);
         $replaceto = array($UserInformation['firstname'], $UserInformation['lastname'], $class->changeDateFormat($UserInformation['duedate']));
         $message = str_replace($replacefrom, $replaceto, $template['template']);
         $class->setGsmnumber($UserInformation['gsmnumber']);
         $class->setMessage($message);
         $class->setUserid($UserInformation['userid']);
         $class->send();
     }
 }
Exemplo n.º 2
0
 function AcceptOrder_SMS($args)
 {
     $class = new AktuelSms();
     $template = $class->getTemplateDetails(__FUNCTION__);
     if ($template['active'] == 0) {
         return null;
     }
     $settings = $class->getSettings();
     if (!$settings['api'] || !$settings['apiparams'] || !$settings['gsmnumberfield'] || !$settings['wantsmsfield']) {
         return null;
     }
     $userSql = "SELECT `a`.`id`,`a`.`firstname`, `a`.`lastname`, `b`.`value` as `gsmnumber`\n        FROM `tblclients` as `a`\n        JOIN `tblcustomfieldsvalues` as `b` ON `b`.`relid` = `a`.`id`\n        JOIN `tblcustomfieldsvalues` as `c` ON `c`.`relid` = `a`.`id`\n        WHERE `a`.`id` IN (SELECT userid FROM tblorders WHERE id = '" . $args['orderid'] . "')\n        AND `b`.`fieldid` = '" . $settings['gsmnumberfield'] . "'\n        AND `c`.`fieldid` = '" . $settings['wantsmsfield'] . "'\n        AND `c`.`value` = 'on'\n        LIMIT 1";
     $result = mysql_query($userSql);
     $num_rows = mysql_num_rows($result);
     if ($num_rows == 1) {
         $UserInformation = mysql_fetch_assoc($result);
         $template['variables'] = str_replace(" ", "", $template['variables']);
         $replacefrom = explode(",", $template['variables']);
         $replaceto = array($UserInformation['firstname'], $UserInformation['lastname'], $args['orderid']);
         $message = str_replace($replacefrom, $replaceto, $template['template']);
         $class->setGsmnumber($UserInformation['gsmnumber']);
         $class->setUserid($UserInformation['id']);
         $class->setMessage($message);
         $class->send();
     }
 }
 function AfterRegistrarRenewalFailed_admin($args)
 {
     $class = new AktuelSms();
     $template = $class->getTemplateDetails(__FUNCTION__);
     if ($template['active'] == 0) {
         return null;
     }
     $settings = $class->getSettings();
     if (!$settings['api'] || !$settings['apiparams'] || !$settings['gsmnumberfield'] || !$settings['wantsmsfield']) {
         return null;
     }
     $admingsm = explode(",", $template['admingsm']);
     $template['variables'] = str_replace(" ", "", $template['variables']);
     $replacefrom = explode(",", $template['variables']);
     $replaceto = array($args['params']['sld'] . "." . $args['params']['tld']);
     $message = str_replace($replacefrom, $replaceto, $template['template']);
     foreach ($admingsm as $gsm) {
         if (!empty($gsm)) {
             $class->setGsmnumber(trim($gsm));
             $class->setUserid(0);
             $class->setMessage($message);
             $class->send();
         }
     }
 }
 function AfterModuleChangePassword($args)
 {
     $type = $args['params']['producttype'];
     if ($type == "hostingaccount") {
         $class = new AktuelSms();
         $template = $class->getTemplateDetails(__FUNCTION__);
         if ($template['active'] == 0) {
             return null;
         }
         $settings = $class->getSettings();
         if (!$settings['api'] || !$settings['apiparams'] || !$settings['gsmnumberfield'] || !$settings['wantsmsfield']) {
             return null;
         }
     } else {
         return null;
     }
     $userSql = "SELECT `a`.`id`,`a`.`firstname`, `a`.`lastname`, `b`.`value` as `gsmnumber`\n    FROM `tblclients` as `a`\n    JOIN `tblcustomfieldsvalues` as `b` ON `b`.`relid` = `a`.`id`\n    JOIN `tblcustomfieldsvalues` as `c` ON `c`.`relid` = `a`.`id`\n    WHERE `a`.`id`  = '" . $args['params']['clientsdetails']['userid'] . "'\n    AND `b`.`fieldid` = '" . $settings['gsmnumberfield'] . "'\n    AND `c`.`fieldid` = '" . $settings['wantsmsfield'] . "'\n    AND `c`.`value` = 'on'\n    LIMIT 1";
     $result = mysql_query($userSql);
     $num_rows = mysql_num_rows($result);
     if ($num_rows == 1) {
         $UserInformation = mysql_fetch_assoc($result);
         $template['variables'] = str_replace(" ", "", $template['variables']);
         $replacefrom = explode(",", $template['variables']);
         $replaceto = array($UserInformation['firstname'], $UserInformation['lastname'], $args['params']['domain'], $args['params']['username'], $args['params']['password']);
         $message = str_replace($replacefrom, $replaceto, $template['template']);
         $class->setGsmnumber($UserInformation['gsmnumber']);
         $class->setUserid($args['params']['clientsdetails']['userid']);
         $class->setMessage($message);
         $class->send();
     }
 }
Exemplo n.º 5
0
 function ClientAdd_admin($args)
 {
     $class = new AktuelSms();
     $template = $class->getTemplateDetails(__FUNCTION__);
     if ($template['active'] == 0) {
         return null;
     }
     $settings = $class->getSettings();
     if (!$settings['api'] || !$settings['apiparams'] || !$settings['gsmnumberfield'] || !$settings['wantsmsfield']) {
         return null;
     }
     $admingsm = explode(",", $template['admingsm']);
     foreach ($admingsm as $gsm) {
         if (!empty($gsm)) {
             $class->setGsmnumber(trim($gsm));
             $class->setUserid(0);
             $class->setMessage($template['template']);
             $class->send();
         }
     }
 }
 function DomainRenewalNotice($args)
 {
     $class = new AktuelSms();
     $template = $class->getTemplateDetails(__FUNCTION__);
     if ($template['active'] == 0) {
         return null;
     }
     $settings = $class->getSettings();
     if (!$settings['api'] || !$settings['apiparams'] || !$settings['gsmnumberfield'] || !$settings['wantsmsfield']) {
         return null;
     }
     $extra = $template['extra'];
     $sqlDomain = "SELECT  `userid` ,  `domain` ,  `expirydate`\n           FROM  `tbldomains`\n           WHERE  `status` =  'Active'";
     $resultDomain = mysql_query($sqlDomain);
     while ($data = mysql_fetch_array($resultDomain)) {
         $tarih = explode("-", $data['expirydate']);
         $yesterday = mktime(0, 0, 0, $tarih[1], $tarih[2] - $extra, $tarih[0]);
         $today = date("Y-m-d");
         if (date('Y-m-d', $yesterday) == $today) {
             $userSql = "SELECT `a`.`id` as userid,`a`.`firstname`, `a`.`lastname`, `b`.`value` as `gsmnumber`\n            FROM `tblclients` as `a`\n            JOIN `tblcustomfieldsvalues` as `b` ON `b`.`relid` = `a`.`id`\n            JOIN `tblcustomfieldsvalues` as `c` ON `c`.`relid` = `a`.`id`\n            WHERE `a`.`id` = '" . $data['userid'] . "'\n            AND `b`.`fieldid` = '" . $settings['gsmnumberfield'] . "'\n            AND `c`.`fieldid` = '" . $settings['wantsmsfield'] . "'\n            AND `c`.`value` = 'on'\n            LIMIT 1";
             $result = mysql_query($userSql);
             $num_rows = mysql_num_rows($result);
             if ($num_rows == 1) {
                 $UserInformation = mysql_fetch_assoc($result);
                 $template['variables'] = str_replace(" ", "", $template['variables']);
                 $replacefrom = explode(",", $template['variables']);
                 $replaceto = array($UserInformation['firstname'], $UserInformation['lastname'], $data['domain'], $data['expirydate'], $extra);
                 $message = str_replace($replacefrom, $replaceto, $template['template']);
                 $class->setGsmnumber($UserInformation['gsmnumber']);
                 $class->setMessage($message);
                 $class->setUserid($UserInformation['userid']);
                 $class->send();
             }
         }
     }
 }
Exemplo n.º 7
0
<?php

/* WHMCS SMS Addon with GNU/GPL Licence
 * AktuelHost - http://www.aktuelhost.com
 *
 * https://github.com/AktuelSistem/WHMCS-SmsModule
 *
 * Developed at Aktuel Sistem ve Bilgi Teknolojileri (www.aktuelsistem.com)
 * Licence: GPLv3 (http://www.gnu.org/licenses/gpl-3.0.txt)
 * */
if (!defined("WHMCS")) {
    die("This file cannot be accessed directly");
}
require_once "smsclass.php";
$class = new AktuelSms();
$hooks = $class->getHooks();
foreach ($hooks as $hook) {
    add_hook($hook['hook'], 1, $hook['function'], "");
}
Exemplo n.º 8
0
function aktuel_sms_output($vars)
{
    $modulelink = $vars['modulelink'];
    $version = $vars['version'];
    $LANG = $vars['_lang'];
    putenv("TZ=Europe/Istanbul");
    $class = new AktuelSms();
    $tab = $_GET['tab'];
    echo '
    <div id="clienttabs">
        <ul>
            <li class="' . ($tab == "settings" ? "tabselected" : "tab") . '"><a href="addonmodules.php?module=aktuel_sms&tab=settings">' . $LANG['settings'] . '</a></li>
            <li class="' . (@$_GET['type'] == "client" ? "tabselected" : "tab") . '"><a href="addonmodules.php?module=aktuel_sms&tab=templates&type=client">' . $LANG['clientsmstemplates'] . '</a></li>
            <li class="' . (@$_GET['type'] == "admin" ? "tabselected" : "tab") . '"><a href="addonmodules.php?module=aktuel_sms&tab=templates&type=admin">' . $LANG['adminsmstemplates'] . '</a></li>
            <li class="' . ($tab == "sendbulk" ? "tabselected" : "tab") . '"><a href="addonmodules.php?module=aktuel_sms&tab=sendbulk">' . $LANG['sendsms'] . '</a></li>
            <li class="' . ($tab == "messages" ? "tabselected" : "tab") . '"><a href="addonmodules.php?module=aktuel_sms&amp;tab=messages">' . $LANG['messages'] . '</a></li>
            <li class="' . ($tab == "update" ? "tabselected" : "tab") . '"><a href="addonmodules.php?module=aktuel_sms&amp;tab=update">' . $LANG['update'] . '</a></li>
        </ul>
    </div>
    ';
    if (!isset($tab) || $tab == "settings") {
        /* UPDATE SETTINGS */
        if ($_POST['params']) {
            $update = array("api" => $_POST['api'], "apiparams" => json_encode($_POST['params']), 'wantsmsfield' => $_POST['wantsmsfield'], 'gsmnumberfield' => $_POST['gsmnumberfield'], 'dateformat' => $_POST['dateformat']);
            update_query("mod_aktuelsms_settings", $update, "");
        }
        /* UPDATE SETTINGS */
        $settings = $class->getSettings();
        $apiparams = json_decode($settings['apiparams']);
        /* CUSTOM FIELDS START */
        $where = array("fieldtype" => array("sqltype" => "LIKE", "value" => "tickbox"), "showorder" => array("sqltype" => "LIKE", "value" => "on"));
        $result = select_query("tblcustomfields", "id,fieldname", $where);
        $wantsms = '';
        while ($data = mysql_fetch_array($result)) {
            if ($data['id'] == $settings['wantsmsfield']) {
                $selected = 'selected="selected"';
            } else {
                $selected = "";
            }
            $wantsms .= '<option value="' . $data['id'] . '" ' . $selected . '>' . $data['fieldname'] . '</option>';
        }
        $where = array("fieldtype" => array("sqltype" => "LIKE", "value" => "text"), "showorder" => array("sqltype" => "LIKE", "value" => "on"));
        $result = select_query("tblcustomfields", "id,fieldname", $where);
        $gsmnumber = '';
        while ($data = mysql_fetch_array($result)) {
            if ($data['id'] == $settings['gsmnumberfield']) {
                $selected = 'selected="selected"';
            } else {
                $selected = "";
            }
            $gsmnumber .= '<option value="' . $data['id'] . '" ' . $selected . '>' . $data['fieldname'] . '</option>';
        }
        /* CUSTOM FIELDS FINISH HIM */
        $classers = $class->getSenders();
        $classersoption = '';
        $classersfields = '';
        foreach ($classers as $classer) {
            $classersoption .= '<option value="' . $classer['value'] . '" ' . ($settings['api'] == $classer['value'] ? "selected=\"selected\"" : "") . '>' . $classer['label'] . '</option>';
            if ($settings['api'] == $classer['value']) {
                foreach ($classer['fields'] as $field) {
                    $classersfields .= '<tr>
                            <td class="fieldlabel" width="30%">' . $LANG[$field] . '</td>
                            <td class="fieldarea"><input type="text" name="params[' . $field . ']" size="40" value="' . $apiparams->{$field} . '"></td>
                        </tr>';
                }
            }
        }
        echo '
        <script type="text/javascript">
            $(document).ready(function(){
                $("#api").change(function(){
                    $("#form").submit();
                });
            });
        </script>
        <form action="" method="post" id="form">
        <input type="hidden" name="action" value="save" />
            <div style="text-align: left;background-color: whiteSmoke;margin: 0px;padding: 10px;">
                <table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
                    <tbody>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['sender'] . '</td>
                            <td class="fieldarea">
                                <select name="api" id="api">
                                    ' . $classersoption . '
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['senderid'] . '</td>
                            <td class="fieldarea"><input type="text" name="params[senderid]" size="40" value="' . $apiparams->senderid . '"> e.g:  AktuelHost</td>
                        </tr>
                        ' . $classersfields . '
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['signature'] . '</td>
                            <td class="fieldarea"><input type="text" name="params[signature]" size="40" value="' . $apiparams->signature . '"> e.g:  www.aktuelsistem.com</td>
                        </tr>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['wantsmsfield'] . '</td>
                            <td class="fieldarea">
                                <select name="wantsmsfield">
                                    ' . $wantsms . '
                                </select>
                            </td>
                        </tr>

                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['gsmnumberfield'] . '</td>
                            <td class="fieldarea">
                                <select name="gsmnumberfield">
                                    ' . $gsmnumber . '
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['dateformat'] . '</td>
                            <td class="fieldarea"><input type="text" name="dateformat" size="40" value="' . $settings['dateformat'] . '"> e.g:  %d.%m.%y (27.01.2014)</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <p align="center"><input type="submit" value="' . $LANG['save'] . '" class="button" /></p>
        </form>
        ';
    } elseif ($tab == "templates") {
        if ($_POST['submit']) {
            $where = array("type" => array("sqltype" => "LIKE", "value" => $_GET['type']));
            $result = select_query("mod_aktuelsms_templates", "*", $where);
            while ($data = mysql_fetch_array($result)) {
                if ($_POST[$data['id'] . '_active'] == "on") {
                    $tmp_active = 1;
                } else {
                    $tmp_active = 0;
                }
                $update = array("template" => $_POST[$data['id'] . '_template'], "active" => $tmp_active);
                if (isset($_POST[$data['id'] . '_extra'])) {
                    $update['extra'] = trim($_POST[$data['id'] . '_extra']);
                }
                if (isset($_POST[$data['id'] . '_admingsm'])) {
                    $update['admingsm'] = $_POST[$data['id'] . '_admingsm'];
                    $update['admingsm'] = str_replace(" ", "", $update['admingsm']);
                }
                update_query("mod_aktuelsms_templates", $update, "id = " . $data['id']);
            }
        }
        echo '<form action="" method="post">
        <input type="hidden" name="action" value="save" />
            <div style="text-align: left;background-color: whiteSmoke;margin: 0px;padding: 10px;">
                <table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
                    <tbody>';
        $where = array("type" => array("sqltype" => "LIKE", "value" => $_GET['type']));
        $result = select_query("mod_aktuelsms_templates", "*", $where);
        while ($data = mysql_fetch_array($result)) {
            if ($data['active'] == 1) {
                $active = 'checked = "checked"';
            } else {
                $active = '';
            }
            $desc = json_decode($data['description']);
            if (isset($desc->{$LANG}['lang'])) {
                $name = $desc->{$LANG}['lang'];
            } else {
                $name = $data['name'];
            }
            echo '
                <tr>
                    <td class="fieldlabel" width="30%">' . $name . '</td>
                    <td class="fieldarea">
                        <textarea cols="50" name="' . $data['id'] . '_template">' . $data['template'] . '</textarea>
                    </td>
                </tr>';
            echo '
            <tr>
                <td class="fieldlabel" width="30%" style="float:right;">' . $LANG['active'] . '</td>
                <td><input type="checkbox" value="on" name="' . $data['id'] . '_active" ' . $active . '></td>
            </tr>
            ';
            echo '
            <tr>
                <td class="fieldlabel" width="30%" style="float:right;">' . $LANG['parameter'] . '</td>
                <td>' . $data['variables'] . '</td>
            </tr>
            ';
            if (!empty($data['extra'])) {
                echo '
                <tr>
                    <td class="fieldlabel" width="30%">' . $LANG['ekstra'] . '</td>
                    <td class="fieldarea">
                        <input type="text" name="' . $data['id'] . '_extra" value="' . $data['extra'] . '">
                    </td>
                </tr>
                ';
            }
            if ($_GET['type'] == "admin") {
                echo '
                <tr>
                    <td class="fieldlabel" width="30%">' . $LANG['admingsm'] . '</td>
                    <td class="fieldarea">
                        <input type="text" name="' . $data['id'] . '_admingsm" value="' . $data['admingsm'] . '">
                        ' . $LANG['admingsmornek'] . '
                    </td>
                </tr>
                ';
            }
            echo '<tr>
                <td colspan="2"><hr></td>
            </tr>';
        }
        echo '
        </tbody>
                </table>
            </div>
            <p align="center"><input type="submit" name="submit" value="Save Changes" class="button" /></p>
        </form>';
    } elseif ($tab == "messages") {
        if (!empty($_GET['deletesms'])) {
            $smsid = (int) $_GET['deletesms'];
            $sql = "DELETE FROM mod_aktuelsms_messages WHERE id = '{$smsid}'";
            mysql_query($sql);
        }
        echo '
        <!--<script src="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/jquery.dataTables.min.js"></script>
        <link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css" type="text/css">
        <link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables_themeroller.css" type="text/css">
        <script type="text/javascript">
            $(document).ready(function(){
                $(".datatable").dataTable();
            });
        </script>-->

        <div style="text-align: left;background-color: whiteSmoke;margin: 0px;padding: 10px;">
        <table class="datatable" border="0" cellspacing="1" cellpadding="3">
        <thead>
            <tr>
                <th>#</th>
                <th>' . $LANG['client'] . '</th>
                <th>' . $LANG['gsmnumber'] . '</th>
                <th>' . $LANG['message'] . '</th>
                <th>' . $LANG['datetime'] . '</th>
                <th>' . $LANG['status'] . '</th>
                <th width="20"></th>
            </tr>
        </thead>
        <tbody>
        ';
        // Getting pagination values.
        $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
        $limit = isset($_GET['limit']) && $_GET['limit'] <= 50 ? (int) $_GET['limit'] : 10;
        $start = $page > 1 ? $page * $limit - $limit : 0;
        $order = isset($_GET['order']) ? $_GET['order'] : 'DESC';
        /* Getting messages order by date desc */
        $sql = "SELECT `m`.*,`user`.`firstname`,`user`.`lastname`\n        FROM `mod_aktuelsms_messages` as `m`\n        JOIN `tblclients` as `user` ON `m`.`user` = `user`.`id`\n        ORDER BY `m`.`datetime` {$order} limit {$start},{$limit}";
        $result = mysql_query($sql);
        $i = 0;
        //Getting total records
        $total = "SELECT count(id) as toplam FROM `mod_aktuelsms_messages`";
        $sonuc = mysql_query($total);
        $sonuc = mysql_fetch_array($sonuc);
        $toplam = $sonuc['toplam'];
        //Page calculation
        $sayfa = ceil($toplam / $limit);
        while ($data = mysql_fetch_array($result)) {
            if ($data['msgid'] && $data['status'] == "") {
                $status = $class->getReport($data['msgid']);
                mysql_query("UPDATE mod_aktuelsms_messages SET status = '{$status}' WHERE id = " . $data['id'] . "");
            } else {
                $status = $data['status'];
            }
            $i++;
            echo '<tr>
            <td>' . $data['id'] . '</td>
            <td><a href="clientssummary.php?userid=' . $data['user'] . '">' . $data['firstname'] . ' ' . $data['lastname'] . '</a></td>
            <td>' . $data['to'] . '</td>
            <td>' . $data['text'] . '</td>
            <td>' . $data['datetime'] . '</td>
            <td>' . $LANG[$status] . '</td>
            <td><a href="addonmodules.php?module=aktuel_sms&tab=messages&deletesms=' . $data['id'] . '" title="' . $LANG['delete'] . '"><img src="images/delete.gif" width="16" height="16" border="0" alt="Delete"></a></td></tr>';
        }
        /* Getting messages order by date desc */
        echo '
        </tbody>
        </table>

        ';
        $list = "";
        for ($a = 1; $a <= $sayfa; $a++) {
            $selected = $page == $a ? 'selected="selected"' : '';
            $list .= "<option value='addonmodules.php?module=aktuel_sms&tab=messages&page={$a}&limit={$limit}&order={$order}' {$selected}>{$a}</option>";
        }
        echo "<select  onchange=\"this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);\">{$list}</select></div>";
    } elseif ($tab == "sendbulk") {
        $settings = $class->getSettings();
        if (!empty($_POST['client'])) {
            $userinf = explode("_", $_POST['client']);
            $userid = $userinf[0];
            $gsmnumber = $userinf[1];
            $class->setGsmnumber($gsmnumber);
            $class->setMessage($_POST['message']);
            $class->setUserid($userid);
            $result = $class->send();
            if ($result == false) {
                echo $class->getErrors();
            } else {
                echo $LANG['smssent'] . ' ' . $gsmnumber;
            }
            if ($_POST["debug"] == "ON") {
                $debug = 1;
            }
        }
        $userSql = "SELECT `a`.`id`,`a`.`firstname`, `a`.`lastname`, `b`.`value` as `gsmnumber`\n        FROM `tblclients` as `a`\n        JOIN `tblcustomfieldsvalues` as `b` ON `b`.`relid` = `a`.`id`\n        JOIN `tblcustomfieldsvalues` as `c` ON `c`.`relid` = `a`.`id`\n        WHERE `b`.`fieldid` = '" . $settings['gsmnumberfield'] . "'\n        AND `c`.`fieldid` = '" . $settings['wantsmsfield'] . "'\n        AND `c`.`value` = 'on' order by `a`.`firstname`";
        $clients = '';
        $result = mysql_query($userSql);
        while ($data = mysql_fetch_array($result)) {
            $clients .= '<option value="' . $data['id'] . '_' . $data['gsmnumber'] . '">' . $data['firstname'] . ' ' . $data['lastname'] . ' (#' . $data['id'] . ')</option>';
        }
        echo '
        <script>
        jQuery.fn.filterByText = function(textbox, selectSingleMatch) {
          return this.each(function() {
            var select = this;
            var options = [];
            $(select).find("option").each(function() {
              options.push({value: $(this).val(), text: $(this).text()});
            });
            $(select).data("options", options);
            $(textbox).bind("change keyup", function() {
              var options = $(select).empty().scrollTop(0).data("options");
              var search = $.trim($(this).val());
              var regex = new RegExp(search,"gi");

              $.each(options, function(i) {
                var option = options[i];
                if(option.text.match(regex) !== null) {
                  $(select).append(
                     $("<option>").text(option.text).val(option.value)
                  );
                }
              });
              if (selectSingleMatch === true && 
                  $(select).children().length === 1) {
                $(select).children().get(0).selected = true;
              }
            });
          });
        };
        $(function() {
          $("#clientdrop").filterByText($("#textbox"), true);
        });  
        </script>';
        echo '<form action="" method="post">
        <input type="hidden" name="action" value="save" />
            <div style="text-align: left;background-color: whiteSmoke;margin: 0px;padding: 10px;">
                <table class="form" width="100%" border="0" cellspacing="2" cellpadding="3">
                    <tbody>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['client'] . '</td>
                            <td class="fieldarea">
                                <input id="textbox" type="text" placeholder="Filtrelemek İçin İsim Yazınız" style="width:498px;padding:5px"><br>
                                <select name="client" multiple id="clientdrop" style="width:512px;padding:5px">
                                    <option value="">' . $LANG['selectclient'] . '</option>
                                    ' . $clients . '
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['mesaj'] . '</td>
                            <td class="fieldarea">
                               <textarea cols="70" rows="20" name="message" style="width:498px;padding:5px"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <td class="fieldlabel" width="30%">' . $LANG['debug'] . '</td>
                            <td class="fieldlabel"><input type="checkbox" name="debug" value="ON"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <p align="center"><input type="submit" value="' . $LANG['send'] . '" class="button" /></p>
        </form>';
        if (isset($debug)) {
            echo $class->getLogs();
        }
    } elseif ($tab == "update") {
        $currentversion = file_get_contents("https://raw.github.com/AktuelSistem/WHMCS-SmsModule/master/version.txt");
        echo '<div style="text-align: left;background-color: whiteSmoke;margin: 0px;padding: 10px;">';
        if ($version != $currentversion) {
            echo $LANG['newversion'];
        } else {
            echo $LANG['uptodate'] . '<br><br>';
        }
        echo '</div>';
    }
    $credit = $class->getBalance();
    if ($credit) {
        echo '
            <div style="text-align: left;background-color: whiteSmoke;margin: 0px;padding: 10px;">
            <b>' . $LANG['credit'] . ':</b> ' . $credit . '
            </div>';
    }
    echo $LANG['lisans'];
}