<?php

use WHMCS\View\Menu\Item as MenuItem;

include_once ROOTDIR.'/modules/addons/AxxessManager/lib/LicenseFunctions.php';
include_once ROOTDIR.'/modules/addons/AxxessManager/lib/Axxessfunction.php';

include_once ROOTDIR . '/modules/servers/axxessReseller/lib/AxxessReseller.php';



/**
 * 1.Change password for ADSL(Capped & Uncapped) and Fibre(Capped & Uncapped)
 * 2.Add modal on check line status for Line services
 * 3.Add friendly name on services details table page
 * @param array $vars
 * @return string
 */

/*
function axxess_changePassword($vars) 
{
    $tagSetting_response = axxess_getAxxessConfig("custom_field", "service_tagname");
    
    $return = '
        <script type="text/javascript">
        $(document).ready(function()
        {
            if($("#Primary_Sidebar-Service_Details_Actions-Change_Password"))
            {
                $("#newPassword2,#newPassword1").hide();
            }
            
            $("#Primary_Sidebar-Service_Details_Actions-Change_Password").click(function()
            {
                $("#newPassword2,#newPassword1").hide();
                $(".btn").removeAttr("disabled");
                $(".btn-primary").attr("value", "Change Password");
                $("#inputNewPassword1").val("Engin#eer260");
                $("#inputNewPassword2").val("Engin#eer260");
                $(".form-horizontal").append(\'<input type="hidden" name="clientarea" value="clientarea" />\');
            });
            
            if($("#Primary_Sidebar-Service_Details_Actions-Custom_Module_Button_Check_my_Line").length)
            {
                $("#Primary_Sidebar-Service_Details_Actions-Custom_Module_Button_Check_my_Line").attr("data-toggle","modal").attr("data-target","#myModal").css("cursor","pointer").removeAttr("href");
            }
            
            if($("#Primary_Sidebar-Service_Details_Actions-Custom_Module_Button_Axxess_Account_Login").length)
            {
                $("#Primary_Sidebar-Service_Details_Actions-Custom_Module_Button_Axxess_Account_Login").attr("data-toggle","modal").attr("data-target","#axxessClientLogin").css("cursor","pointer").removeAttr("href");
                //----when modal is shown---
                $("#axxessClientLogin").on("shown.bs.modal", function ()
                {
                    if ($(\'form[name="frmlogin"]\').length)
                    {
                        $(\'form[name="frmlogin"]\').attr("target", "_blank");
                        $(\'form[name="frmlogin"]\').submit();
                        $("#axxessClientLogin").modal("hide");
                    }
                });
            }
            
        });
        </script>';
    if (($vars['action'] == "services" || $vars['action'] == "products") && $tagSetting_response['records'] == 'on') {
        if ($_POST['submitfname'] && $_POST['submitfname'] == "add_friendly_name") {
            $value = htmlspecialchars($_POST['newtagname']);
            $service_id = htmlspecialchars($_POST['serviceid']);
            axxess_insertCustomFieldsValues($service_id, axxess_getAxxessConfig("custom_field", "friendly_name")['records'], $value);
        }
        if ($_POST['submitfnameedit'] && $_POST['submitfnameedit'] == "edit_friendly_name") {
            $value = htmlspecialchars($_POST['newtagname2']);
            $service_id = htmlspecialchars($_POST['serviceid']);
            axxess_updateServiceTag($service_id, axxess_getAxxessConfig("custom_field", "friendly_name")['records'], $value);
        }
        $return .="<script type=\"text/javascript\">
                       $(document).ready(function()
                        {";
        foreach ($vars['services'] as $key) {
            $checkService = axxess_checkService($key['id']);
            if ($checkService) {
                $sid = $key['id'];
                $custom_value = axxess_getServiceTag($sid, axxess_getAxxessConfig("custom_field", "friendly_name")['records']);
                $return.= "
                                    var b = '" . $sid . "';
                                    var a = '" . $custom_value . "';
                                    if(a)
                                    {
                                      $('#tableServicesList').find('tr td.responsive-edit-button a[href$=\"$sid\"]').closest('tr').find('td:first-child strong').after('<span style=\"color:white;background-color:#46A546;padding: 1px 3px 2px;border-radius: 3px;margin-left:10px\">'+ a +'</span>');  
                                      $('#tableServicesList').after('<div class=\"modal fade\"   id=\"editmodal-$sid\"><div class=\"modal-dialog\"><div class=\"modal-content\"><form action=\"\" method=\'post\'>\           <div class=\"modal-header\"><h4 class=\"modal-title\">Update Tag ( Edit a friendly name for this service )</h4></div><div class=\"modal-body\"><div class=\"form-group\"><label for=\"name\">Enter the Friendly Name </label><input type=\"text\" name=\"newtagname2\" required id=\"newtagname2\" value=\"$custom_value\" autocomplete=\"off\" placeholder=\"Enter the Friendly Name \" class=\"form-control\"><input type=\"hidden\" value=\"$sid\" name=\"serviceid\"></div></div><div class=\"modal-footer\"><button type=\"button\" class=\"btn btn-sm btn-default\" data-dismiss=\"modal\">Close</button><button type=\"submit\" id=\"savetag2\" name=\"submitfnameedit\"  value=\"edit_friendly_name\" class=\"btn btn-sm btn-primary\">Edit</button></div></form></div></div></div>');
                                      $('#tableServicesList').find('tr td.responsive-edit-button a[href$=\"$sid\"]').closest('tr').find('td:first-child').append('<a href=\"#editmodal-" . $key['id'] . "\" class=\"link\" data-toggle=\"modal\" style=\"padding-left:15px;display:none\" title=\"Edit a friendly Product Name\"><img src=\"modules/addons/Axxess_Account_Manager/assets/img/tag.png\"> Update tag </a>');
                                    }                        
                                    else 
                                    {
                                        $('#tableServicesList').after('<div class=\"modal fade\" id=\"myModal-$sid\"><div class=\"modal-dialog\"><div class=\"modal-content\"><form action=\"\" method=\'post\'>\           <div class=\"modal-header\"><h4 class=\"modal-title\">Add Tag ( Add a friendly name for this service )</h4></div><div class=\"modal-body\"><div class=\"form-group\"><label for=\"name\">Enter the Friendly Name </label><input type=\"text\" name=\"newtagname\" required id=\"newtagname\" value=\"\" placeholder=\"Enter the Friendly Name \" autocomplete=\"off\" class=\"form-control\"><input type=\"hidden\" value=\"$sid\" name=\"serviceid\"></div></div><div class=\"modal-footer\"><button type=\"button\" class=\"btn btn-sm btn-default\" data-dismiss=\"modal\">Close</button><button type=\"submit\" id=\"savetag\" name=\"submitfname\"  value=\"add_friendly_name\" class=\"btn btn-sm btn-primary\">Save</button></div></form></div></div></div>');
                                        $('#tableServicesList').find('tr td.responsive-edit-button a[href$=\"$sid\"]').closest('tr').find('td:first-child').append('<a href=\"#myModal-" . $key['id'] . "\" class=\"link\" data-toggle=\"modal\" style=\"padding-left:15px;display:none\" title=\"Add a friendly Product Name\"> <img src=\"modules/addons/Axxess_Account_Manager/assets/img/tag.png\"> Add tag</a>');
                                    } ";
            }
        }
        $return.="
                                    $('#tableServicesList tr').hover(function()
                                    {
                                        $(this).find('.link').show();
                                    },
                                    function()
                                    {
                                        $(this).find('.link').hide();
                                    });
                        });
                        </script>
                            
                        <style>
                        .modal-backdrop.in
                        {
                            opacity: 0 !important;
                        }
                        .modal-backdrop
                        {
                            z-index: 0 !important;
                        }
                        .modal-title
                        {
                            color: black;
                        }
                        .modal
                        {
                            top:40px;
                    </style>";
    }
    #Adding Friendly name at services deatls page
    if ($vars['action'] == "productdetails" && !empty($vars['id'])) {
        $custom_value = axxess_getServiceTag($vars['id'], axxess_getAxxessConfig("custom_field", "friendly_name")['records']);
        if (!empty($custom_value)) {
            $return.='
                                <style>
                                .axxess-friendlyname
                                {
                                    color: white;
                                    background-color: #46A546;
                                    padding: 3px 20px;
                                    border-radius: 3px;
                                    margin-left: 10px;
                                    font-size: 20px;
                                }
                                </style>
                    
                                <script>
                                $(document).ready(function()
                                {
                                    $(".product-icon>h4").eq(0).after("<span class=\'axxess-friendlyname\'>' . $custom_value . '</span>");
                                });
                                </script>';
        }
    }
    return $return;
}
*/

/**
 * Hide Change password for @DSL line and @Mobile
 * Add @Voip sidebar menu
 * Add @RAIN and @Cellc sidebar menu
 * @param MenuItem $primarySidebar
 */
/*
function axxess_hideChangePassword(MenuItem $primarySidebar) 
{
    global $CONFIG;
    
    if(!empty($_SESSION['uid']))
    {
        $uid = $_SESSION['uid'];
    }
    
    if (!empty($_GET) && $_GET['action'] == 'productdetails') 
    {
        $serviceid = $_GET['id'];
        $producDetails_response = axxess_getProductDetails('',$serviceid);
        
        if($producDetails_response['status']=='success' && !empty($producDetails_response['data']))
        {
            $option1 = $producDetails_response['data']->configoption1;
            $option2 = $producDetails_response['data']->configoption2;
            $option3 = $producDetails_response['data']->configoption3;
            
            $pid = $producDetails_response['data']->id;
            
            
            if('Data'== $option2 && 'DSL'== $option1 && 'Capped'== $option3 ) 
            {
                
            }
            else
            {
                if ($primarySidebar->getChild('Service Details Actions')) 
                {
                    $primarySidebar->getChild('Service Details Actions')->removeChild('Change Password');
                }
                if ($primarySidebar->getChild('Service Details Actions')) 
                {
                    $primarySidebar->getChild('Service Details Actions')->removeChild('Custom Module Button Re-send Login Details');
                }
            }
            
            if ($option1=='Voice')
            {
                $number_type = axxess_getCustomFieldsValuesByName(axxess_getAxxessConfig("custom_field","voice_numbertype")['records'],$pid, $serviceid);
            
                if($number_type =='Existing Number')
                {
                    #only for existing number
                    
                    if (!is_null($primarySidebar->getChild('Service Details Actions'))) 
                    {
                        $url = empty($CONFIG['SystemSSLURL']) ? $CONFIG['SystemURL'] : $CONFIG['SystemSSLURL'];
                        $last = substr($url, -1);
                        $system_url = ($last == "/") ? $url : $url . "/";
                        $url = $system_url . "modules/servers/axxessReseller/document/";
                        $customPanel = $primarySidebar->addChild('Voice Porting Documents');
                        $customPanel->moveToFront()
                                    ->setIcon('fa-file-text-o');
                        $customPanel->addChild('Landline only',array(
                                                                            'uri' => $url."voip_landline_only.pdf",
                                                                            'icon'  => 'fa-download',
                                                                            'order' => 1,
                                                                            )
                                            );
                        $customPanel->addChild('Landline with DSL',array(
                                                                            'uri' => $url."voip_landline_dsl.pdf",
                                                                            'icon'  => 'fa-download',
                                                                            'order' => 2,
                                                                            )
                                            );
                        $customPanel->addChild('Uplaod Documents',array(
                                                                            'uri' => 'index.php?m=Axxess_Account_Manager&action=upload&uid='.$uid.'&sid='.$serviceid.'&type=voip',
                                                                            'icon'  => 'fa-upload',
                                                                            'order' => 3,
                                                                            )
                                            );
                    }
                }
            }
            
            if ($option2=='rain' || $option2=='cellc')
            {
                #separetly ok
                if (!is_null($primarySidebar->getChild('Service Details Actions'))) 
                {
                    $url = empty($CONFIG['SystemSSLURL']) ? $CONFIG['SystemURL'] : $CONFIG['SystemSSLURL'];
                    $last = substr($url, -1);
                    $system_url = ($last == "/") ? $url : $url . "/";
                    $url = $system_url . "modules/servers/axxessReseller/document/";
                    $customPanel = $primarySidebar->addChild('LTE Services');
                    $customPanel->moveToFront()->setIcon('fa-fa-mobile');
                    $customPanel->addChild('Check Network Coverage',array(
                                                                        'uri' => "index.php?m=Axxess_Account_Manager&action=network",
                                                                        'icon'  => 'fa-signal',
                                                                        'order' => 1,
                                                                        )
                                        );
                    $customPanel->addChild('Uplaod Documents',array(
                                                                        'uri' => 'index.php?m=Axxess_Account_Manager&action=upload&uid='.$uid.'&sid='.$serviceid.'&type=lte',
                                                                        'icon'  => 'fa-upload',
                                                                        'order' => 3,
                                                                        )
                                        );
                }
            }
        }
    }
}
 * 
 */
/*
 * Adding panel for Axxess
 * 1.Network Coverage for Telkom amd MTN Fixed
 * 
 */
function axxess_primaryNavbar($primaryNavbar)
{  
    $newMenu = $primaryNavbar->addChild('Network Coverage',
            array('name' => 'Home','label' => Lang::trans('Network Coverage'),'uri' => '','order' => 10)
    );
    $newMenu->addChild('MTN Fixed LTE',
            array('name' => 'Item Name 1','label' => Lang::trans('MTN Fixed LTE'),'uri' => 'index.php?m=AxxessManager&action=mtnmap')
    );
     $newMenu->addChild('Telkom Fixed LTE',
            array('name' => 'Item Name 2','label' => Lang::trans('Telkom Fixed LTE'),'uri' => 'index.php?m=AxxessManager&action=telkommap')
    );
}


/*
 * Adding Axxess Panel on Secondary Sidebar Menu
 * 1.For MTN Mobile address for new SIM
 * 2.Document upload and download for voice
 */


function axxess_primarySidebar($primarySidebar)
{
    $axxessReseller = new AxxessReseller;
    
    #Checking for services
    
    if (!empty($_GET) && $_GET['action'] == 'productdetails') 
    {
        $serviceid = $_GET['id'];
        
        $serviceDetails = $axxessReseller->getServiceDetails($serviceid);
        
        if($serviceDetails->domainstatus == 'Pending')
        {
            /*
             * only continue for pending services
             */
        }
        else
        {
            return;
        }
        
        $axxessService = $axxessReseller->getAxxessServiceDetails($serviceid);
        
        if(!empty($serviceDetails->packageid))
        {
            $producDetails = $axxessReseller->getProductDetails($serviceDetails->packageid);
            
            #Primary sidebar Menu
            
            if(!is_null($primarySidebar->getChild('Service Details Actions'))) 
            {
                #creating link for MTN mobile
                if($producDetails->configoption2 === 'mobile')
                {
                    #creating Panel
                    $customPanel = $primarySidebar->addChild('New SIM Delivery Address');

                    $customPanel->moveToFront()->setIcon('fa-file-text');
                    #checking for configurable option(new or existing)
                    $serviceConfigOption = $axxessReseller->getServiceConfigOption($serviceid);
                                        
                    if($serviceConfigOption->optionid)
                    {
                        $serviceConfigSubOption = $axxessReseller->getConfigSubOptionDetails($serviceConfigOption->optionid);
                    }
                    
                    if($serviceConfigSubOption->optionname === Axxessfunction::CONFIGURABLE_SUB_OPTION_NAME_2)
                    {
                        $customPanel->addChild(
                                        'Update Address',
                                        array(
                                                'uri' => 'index.php?m=AxxessManager&action=mtnaddress&service='.$serviceid,
                                                'icon'  => 'fa-address-book',
                                                'order' => 1,
                                              )
                                    );
                    }
                }
                else if($producDetails->configoption1 === 'Voice')
                {
                    #creating Panel
                    if(!empty($axxessService->serviceid))
                    {
                        #service exist
                        #send SIP details to email
                        #done with serever module
                    }
                    else
                    {
                        #not exist
                        $field_nameType = $axxessReseller->getAxxessSetting("custom_field", "voice_numbertype");
                    
                        if(!empty($field_nameType)) 
                        {
                           $customFieldIdType = $axxessReseller->getCustomFiledId($field_nameType, $serviceDetails->packageid);

                           if(!empty($customFieldIdType))
                           {
                               $number_type = $axxessReseller->getCustomFieldValue($customFieldIdType, $serviceid);
                           }
                        } 

                        if($number_type =='Existing Number')
                        {
                            $customPanel = $primarySidebar->addChild('Voice Porting Documents');

                            $customPanel->moveToFront()->setIcon('fa-file-pdf-o');
                            #only for existing number

                            $url = empty($CONFIG['SystemSSLURL']) ? $CONFIG['SystemURL'] : $CONFIG['SystemSSLURL'];
                            $last = substr($url, -1);
                            $system_url = ($last == "/") ? $url : $url . "/";
                            $url = $system_url . "modules/servers/axxessReseller/download/";
                           // $customPanel = $primarySidebar->addChild('Voice Porting Documents');
                            //$customPanel->moveToFront()->setIcon('fa-file-text-o');
                            $customPanel->addChild('Landline only',array(
                                                                                'uri' => $url."voip_landline_only.pdf",
                                                                                'icon'  => 'fa-download',
                                                                                'order' => 1,
                                                                                )
                                                );
                            $customPanel->addChild('Landline with DSL',array(
                                                                                'uri' => $url."voip_landline_dsl.pdf",
                                                                                'icon'  => 'fa-download',
                                                                                'order' => 2,
                                                                                )
                                                );
                            $customPanel->addChild('Upload Documents',array(
                                                                                'uri' => 'index.php?m=AxxessManager&action=voice&sid='.$serviceid.'&type=upload',
                                                                                'icon'  => 'fa-upload',
                                                                                'order' => 3,
                                                                                )
                                                );

                        }
                    }
                    
                }
                
            }
            
            
            //$option1 = $producDetails->configoption1;
            //$option2 = $producDetails->configoption2;
            //$option3 = $producDetails->configoption3;
            
//            if('Data'== $option2 && 'DSL'== $option1 && 'Capped'== $option3 ) 
//            {
//                
//            }
//            else
//            {
//                if ($primarySidebar->getChild('Service Details Actions')) 
//                {
//                    $primarySidebar->getChild('Service Details Actions')->removeChild('Change Password');
//                }
//                if ($primarySidebar->getChild('Service Details Actions')) 
//                {
//                    $primarySidebar->getChild('Service Details Actions')->removeChild('Custom Module Button Re-send Login Details');
//                }
//            }
            
            
            
            if ($option2=='rain' || $option2=='cellc')
            {
                #separetly ok
                if (!is_null($primarySidebar->getChild('Service Details Actions'))) 
                {
                    $url = empty($CONFIG['SystemSSLURL']) ? $CONFIG['SystemURL'] : $CONFIG['SystemSSLURL'];
                    $last = substr($url, -1);
                    $system_url = ($last == "/") ? $url : $url . "/";
                    $url = $system_url . "modules/servers/axxessReseller/document/";
                    $customPanel = $primarySidebar->addChild('LTE Services');
                    $customPanel->moveToFront()->setIcon('fa-fa-mobile');
                    $customPanel->addChild('Check Network Coverage',array(
                                                                        'uri' => "index.php?m=Axxess_Account_Manager&action=network",
                                                                        'icon'  => 'fa-signal',
                                                                        'order' => 1,
                                                                        )
                                        );
                    $customPanel->addChild('Uplaod Documents',array(
                                                                        'uri' => 'index.php?m=Axxess_Account_Manager&action=upload&uid='.$uid.'&sid='.$serviceid.'&type=lte',
                                                                        'icon'  => 'fa-upload',
                                                                        'order' => 3,
                                                                        )
                                        );
                }
            }
        }
    }
}




/**
 * 1.Managing custom field for Mobile SIM.
 * 2.LTE fixed (MTN and Telkom) map.
 * fiber combo to check availablity,
 * Managing custom field for VoIP
 * @param array $vars
 * @return string
 */


function axxess_remove_config($vars) 
{
    $axxessReseller = new AxxessReseller;
    
    if ($vars['action'] == 'confproduct' && !empty($vars['productinfo']['pid'])) 
    {
        $pid = $vars['productinfo']['pid'];
        
        $checkProductConfig = $axxessReseller->getProductDetails($pid);
        
        if('Mobile'== $checkProductConfig->configoption1) 
        {
            if("mobile" == $checkProductConfig->configoption2)
            {
                $configoptiongrp_response = $axxessReseller->getConfigOptionGrpId(Axxessfunction::CONFIGURABLE_GROUP_NAME, Axxessfunction::CONFIGURABLE_GROUP_DESCRIPTION);
                
                if ($configoptiongrp_response['status'] == 'success' && !empty($configoptiongrp_response['records'])) 
                {
                    $config_gid = $configoptiongrp_response['records'];
                    
                    $config_option_response = $axxessReseller->getConfigOptionId($config_gid, Axxessfunction::CONFIGURABLE_OPTION_NAME);
                    
                    $config_option_id = $config_option_response['records'];
                    
                    #Suboption1
                    $config_suboption_response1 = $axxessReseller->getConfigSubOptionId($config_option_id, Axxessfunction::CONFIGURABLE_SUB_OPTION_NAME_1);
                    $config_suboption_id1 = $config_suboption_response1['records'];
                    
                    #Suboption2
                    $config_suboption_response = $axxessReseller->getConfigSubOptionId($config_option_id, Axxessfunction::CONFIGURABLE_SUB_OPTION_NAME_2);
                    $config_suboption_id = $config_suboption_response['records'];
                    
                    $field_nameExisting = $axxessReseller->getAxxessSetting("custom_field", "mobile_sim_number");
                    
                    if(empty($field_nameExisting)) 
                    {
                        return 0;
                    } 
                    
                    
                    $customFieldIdExisting = $axxessReseller->getCustomFiledId($field_nameExisting, $pid);
                    
                    if (empty($config_suboption_id) || empty($customFieldIdExisting)) 
                    {
                        return 0;
                    }
                    
                    $footeroutput_axxess = '
                                <script type="text/javascript" src="modules/servers/axxessReseller/assets/js/mobile.js?'.time().'"></script>
                                <script type="text/javascript">
                                    var configOptionId = '.$config_option_id.';
                                    var configSubOptionId = '.$config_suboption_id.';
                                    var configSubOptionId1 = '.$config_suboption_id1.';
                                    var customfiledIdExisting = '.$customFieldIdExisting.';
                                </script>
                                ';
                }
            }
            else if("telkomfixed" == $checkProductConfig->configoption2)
            {
                $googleMapKey = $axxessReseller->getAxxessSetting("googlemap","key");
                
                $footeroutput_axxess = '
                                <script type="text/javascript" src="modules/servers/axxessReseller/assets/js/telkomfixed.js?'.time().'"></script>
                                <link href="modules/servers/axxessReseller/assets/css/axxess.css?'.time().'" rel="stylesheet">
                                <script>
                                    var googleMapKey = "'.$googleMapKey.'";
                                </script>
                                
                                    <!-- Modal -->
                                    
                                    <div id="telkomFixedMap" class="modal fade" role="dialog">
                                    
                                        <div class="modal-dialog modal-lg">
                                            <!-- Modal content-->
                                            <div class="modal-content">
                                            
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h4 class="modal-title">'.$checkProductConfig->name.'</h4>
                                                </div>
                                                
                                                <!---Map div start-->
                                                
                                                <div class="modal-body inner-div" style="background-color: #f4fafd;">
                                                
                                                    <div id="step1">
                                                    
                                                        <div style="color: #307db1; background-color: #D8EDF8; padding: 30px 10px; margin: -14px -7px; text-align: center; font-size: 15px;">
                                                            Telkom Fixed LTE coverage map
                                                        </div>
                                                        
                                                        <div class="fibre-check-steps">
                                                        
                                                            <div class="fibre-bullet-container" style="float:left;width: 25%">
                                                                <div style="display: inline-block;"></div>
                                                            </div>
                                                            
                                                            <div class="fibre-bullet-container" style="float:left;width: 33.3333%;">
                                                                <div class="telkom-bullet">1</div>
                                                                <span class="bold">Type your address</span> or Pin your location
                                                            </div>
                                                            
                                                            <div class="fibre-bullet-container" style="float:left;width: 25%">
                                                                <div class="telkom-bullet">2</div>
                                                                Click the <span class="bold">check</span> button
                                                            </div>
                                                            
                                                            <div class="fibre-bullet-container" style="float:left;width: 16.6667%">
                                                                <div style="display: inline-block;"></div>
                                                            </div>
                                                            
                                                            <div style="clear:left;"></div>
                                                        </div>';
                
                                                        if(!empty($googleMapKey))
                                                        {
                                                            $footeroutput_axxess .=
                                                                    '<form action="modules/servers/axxessReseller/calls/map.php" method="POST" id="TelkomMapForm">
                                                                        <input type="hidden" name="map" value="checkTelkomFixed">
                                                                        
                                                                        <div id="page-loader">
                                                                          <center>
                                                                                <img src="modules/servers/axxessReseller/assets/img/mobile.gif" alt="loader">
                                                                           </center>
                                                                        </div>
                                                                        
                                                                        <div id="telkomscript"></div>
                                                                        
                                                                        <div class="btn-check-wrapper" style="margin:10px 0;">
                                                                            <button type="submit" id="btn-check" class="btn-check-telkom"><span>CHECK</span></button>
                                                                            <p></p>
                                                                            <div id="map-response"></div>
                                                                        </div>
                                                                    </form>';
                                                        }
                                                        else
                                                        {
                                                            $footeroutput_axxess .=
                                                                    '<div id="mapkey-error">
                                                                          <center>
                                                                                <div class="alert alert-danger">
                                                                                    <strong>Error!</strong> Google Map API Key not found.
                                                                                    <p><a href="submitticket.php">Contact Support</p>
                                                                                </div>
                                                                           </center>
                                                                        </div>';
                                                        }
                                                        
                                                        $footeroutput_axxess .='</div>
                                                    <!--Map div ends-->
                                ';
            }
            else if("mtnfixed" == $checkProductConfig->configoption2)
            {
                $googleMapKey = $axxessReseller->getAxxessSetting("googlemap","key");
                
                $footeroutput_axxess = '
                                <script type="text/javascript" src="modules/servers/axxessReseller/assets/js/mtnfixed.js?'.time().'"></script>
                                <link href="modules/servers/axxessReseller/assets/css/axxess.css?'.time().'" rel="stylesheet">
                                <script>
                                    var googleMapKey = "'.$googleMapKey.'";
                                </script>
                                
                                    <!-- Modal -->
                                    
                                    <div id="mtnFixedMap" class="modal fade" role="dialog">
                                    
                                        <div class="modal-dialog modal-lg">
                                            <!-- Modal content-->
                                            <div class="modal-content">
                                            
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h4 class="modal-title">'.$checkProductConfig->name.'</h4>
                                                </div>
                                                
                                                <!---Map div start-->
                                                
                                                <div class="modal-body inner-div" style="background-color: #f4fafd;">
                                                
                                                    <div id="step1">
                                                    
                                                        <div style="color: #307db1; background-color: #D8EDF8; padding: 30px 10px; margin: -14px -7px; text-align: center; font-size: 15px;">
                                                            MTN Fixed LTE coverage map
                                                        </div>
                                                        
                                                        <div class="fibre-check-steps">
                                                        
                                                            <div class="fibre-bullet-container" style="float:left;width: 25%">
                                                                <div style="display: inline-block;"></div>
                                                            </div>
                                                            
                                                            <div class="fibre-bullet-container" style="float:left;width: 33.3333%;">
                                                                <div class="mtn-bullet">1</div>
                                                                <span class="bold">Type your address</span> or Pin your location
                                                            </div>
                                                            
                                                            <div class="fibre-bullet-container" style="float:left;width: 25%">
                                                                <div class="mtn-bullet">2</div>
                                                                Click the <span class="bold">check</span> button
                                                            </div>
                                                            
                                                            <div class="fibre-bullet-container" style="float:left;width: 16.6667%">
                                                                <div style="display: inline-block;"></div>
                                                            </div>
                                                            
                                                            <div style="clear:left;"></div>
                                                        </div>';
                
                                                        if(!empty($googleMapKey))
                                                        {
                                                            $footeroutput_axxess .=
                                                                    '<form action="modules/servers/axxessReseller/calls/map.php" method="POST" id="MTNMapForm">
                                                                        <input type="hidden" name="map" value="checkMTNFixed">
                                                                        
                                                                        <div id="page-loader">
                                                                          <center>
                                                                                <img src="modules/servers/axxessReseller/assets/img/mobile.gif" alt="loader">
                                                                           </center>
                                                                        </div>
                                                                        
                                                                        <div id="mtn-fixed-lte-script"></div>
                                                                        
                                                                        <div class="btn-check-wrapper" style="margin:10px 0;">
                                                                            <button type="submit" id="btn-check" class="btn-check-mtn"><span>CHECK</span></button>
                                                                            <p></p>
                                                                            <div id="map-response"></div>
                                                                        </div>
                                                                    </form>';
                                                            }
                                                        else
                                                        {
                                                            $footeroutput_axxess .=
                                                                    '<div id="mapkey-error">
                                                                          <center>
                                                                                <div class="alert alert-danger">
                                                                                    <strong>Error!</strong> Google Map API Key not found.
                                                                                    <p><a href="submitticket.php">Contact Support</p>
                                                                                </div>
                                                                           </center>
                                                                        </div>';
                                                        }
                                                        
                                                        $footeroutput_axxess .='</div>
                                                    <!--Map div ends-->
                                ';
            }
            
            
        }
        elseif(preg_match('/Fibre/', $checkProductConfig->configoption1))
        {
            /*------Fiber Combo-----*/
            /*
            $googleMapKey = axxess_getAxxessConfig("googlemap","key")['records'];
            $custFieldIds = axxess_getAllFibreCustFieldId($pid);
            
            $latlongCustFieldId = $custFieldIds[axxess_getAxxessConfig("custom_field","fibre_lat_long")['records']];
            $addressCustFieldId = $custFieldIds[axxess_getAxxessConfig("custom_field","fibre_address")['records']];
            $subrubCustFieldId = $custFieldIds[axxess_getAxxessConfig("custom_field","fibre_ownersuburb")['records']];
            $cityCustFieldId = $custFieldIds[axxess_getAxxessConfig("custom_field","fibre_ownercity")['records']];
            $postCustFieldId = $custFieldIds[axxess_getAxxessConfig("custom_field","fibre_ownerpostcode")['records']];
            
            $footeroutput_axxess = '
                                    <style>
                                    .fibre-check-steps 
                                    {
                                        margin: 30px 0 20px;
                                    }
                                    .fibre-bullet-container
                                    {
                                        font-size: 12px;
                                        text-align: center;
                                    }
                                    .fibre-bullet
                                    {
                                        background-color: #930093;
                                        border-radius: 50%;
                                        color: #fff;
                                        cursor: default;
                                        display: inline-block;
                                        font-size: 16px;
                                        height: 20px;
                                        line-height: 20px;
                                        margin-right: 5px;
                                        text-align: center;
                                        width: 20px;
                                    }
                                    .bold
                                    {
                                        font-weight: bold;
                                    }
                                    .btn-check-fibre
                                    {
                                        display: block;
                                        height: 32px;
                                        line-height: 32px;
                                        border: 0;
                                        min-width: 110px;
                                        padding: 0 10px;
                                        text-align: center;
                                        color: #fff;
                                        background-color: #660066;
                                        width: auto;
                                        margin: 0 auto;
                                        cursor: pointer;
                                        font-size: 16px;
                                    }
                                    .btn-check-wrapper .msg
                                    {
                                        font-size: 14px;
                                        text-align: center;
                                    }
                                    .btn-check-wrapper .msg.success
                                    {
                                        color: #147873;
                                    }
                                    .btn-check-wrapper .msg
                                    {
                                        font-size: 14px;
                                        text-align: center;
                                    }
                                    .btn-check-wrapper .msg.error
                                    {
                                        color: #a94442;
                                    }
                                    .pac-container
                                    {
                                        z-index: 1060 !important;
                                    }
                                    #fibrecontainer
                                    {
                                        display:none;
                                    }
                                    </style>
                                    
                                    <!-- Modal -->
                                    <div id="fiberMap" class="modal fade" role="dialog">
                                        <div class="modal-dialog modal-lg">
                                            <!-- Modal content-->
                                            <div class="modal-content">
                                            
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                                    <h4 class="modal-title">'.$checkProductConfig->name.'</h4>
                                                </div>
                                                
                                                <!---Map div start-->
                                                <div class="modal-body inner-div" style="background-color: #f4fafd;">
                                                    <div id="step1">
                                                        <div style="color: #307db1; background-color: #D8EDF8; padding: 30px 10px; margin: -14px -7px; text-align: center; font-size: 15px;">
                                                            Check to see if Fibre is available in your area
                                                        </div>
                                                        <div class="fibre-check-steps">
                                                            <div class="fibre-bullet-container" style="float:left;width: 25%">
                                                                <div style="display: inline-block;"></div>
                                                            </div>
                                                            <div class="fibre-bullet-container" style="float:left;width: 33.3333%;">
                                                                <div class="fibre-bullet">1</div>
                                                                <span class="bold">Type your address</span> or Pin your location
                                                            </div>
                                                            <div class="fibre-bullet-container" style="float:left;width: 25%">
                                                                <div class="fibre-bullet">2</div>
                                                                Click the <span class="bold">check</span> button
                                                            </div>
                                                            <div class="fibre-bullet-container" style="float:left;width: 16.6667%">
                                                                <div style="display: inline-block;"></div>
                                                            </div>
                                                            <div style="clear:left;"></div>
                                                        </div>';
                                                        if(!empty($googleMapKey))
                                                        {
                                                            $footeroutput_axxess .=
                                                                    '<form action="modules/servers/axxessReseller/calls/fibreCheck.php" method="POST" id="fibreMapForm">
                                                                        <input type="hidden" name="map" value="checkFibre">
                                                                        <input type="hidden" name="networkProviderId" value="'.$checkProductConfig->configoption2.'">
                                                                        <div id="page-loader">
                                                                          <center>
                                                                                <img src="modules/servers/axxessReseller/images/loader.gif" alt="loader">
                                                                           </center>
                                                                        </div>
                                                                        <div id="fibrescript"></div>
                                                                        <div class="btn-check-wrapper" style="margin:10px 0;">
                                                                            <button type="submit" id="btn-check" class="btn-check-fibre"><span>CHECK</span></button>
                                                                            <p></p>
                                                                            <div id="map-response"></div>
                                                                        </div>
                                                                    </form>';
                                                        }
                                                        else
                                                        {
                                                            $footeroutput_axxess .=
                                                                    '<div id="mapkey-error">
                                                                          <center>
                                                                                <div class="alert alert-danger">
                                                                                    <strong>Error!</strong> Google Map API Key not found.Make sure you have enter key at <b>Configuaration</b>-><b>General settings</b> in Axxess Account Manager module.
                                                                                </div>
                                                                           </center>
                                                                        </div>';
                                                        }
                                                        $footeroutput_axxess .='</div>
                                                    <!--Map div ends-->
             * 
                                                    <div id="step2" style="background-color: #f4fafd;display:none;">
                                                        <div>
                                                            <div style="color:white;background-color: #bf65e4; padding: 30px 10px; margin: -14px -7px; text-align: center; font-size: 15px;">
                                                                Fibre service available in your area </br>
                                                                <span id="map-address"></span>
                                                            </div>
                                                            <div id="area-fibre-product" class="row" style="margin-top:30px;">
                                                            </div>
                                                        </div>
                                                        <div style="text-align:center;">
                                                            <button type="button" class="btn btn-primary" onclick="showstep(2);">Back</button>
                                                        </div>
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!---End Modal---->
                                    
                                    <script>
                                    
                                    function showstep(step)
                                    {
                                        if(step==1)
                                        {
                                            $("#map-address").html("<b>"+$("#address-input").val()+"</b>");
                                            $("#step1").hide();
                                            $("#step2").show();
                                            
                                        }
                                        else if(step==2)
                                        {
                                            $("#map-address").empty();
                                            $("#step2").hide();
                                            $("#step1").show();
                                        }
                                    }
                                    
                                    $(document).ready(function()
                                    {
                                    ';
                                        if(!empty($googleMapKey))
                                        {
                                            $footeroutput_axxess .=
                                            'var ax = document.createElement("script");
                                            ax.id = "mainscript";
                                            ax.onload = setInterval(checkJSLoaded,5000);
                                            ax.type = "text/javascript";
                                            ax.async = true;
                                            ax.src = "https://rcp.axxess.co.za/public/js/fibremapJs.php?key='.$googleMapKey.'&width=100%&height=500px";
                                            var s = document.getElementsByTagName("script")[0];
                                            s.parentNode.insertBefore(ax, s);';
                                        }
                                        
                                        $footeroutput_axxess .=
                                        '$("#fiberMap").modal({backdrop: "static"});
                                        
                                        function checkJSLoaded()
                                        {
                                            if (typeof(gmaps) != "undefined") 
                                            {
                                                clearInterval();
                                                $("#page-loader").hide();
                                                $("#fibrecontainer").show();   
                                            }   
                                        }
                                        
                                        $("#btnCompleteProductConfig").addClass("disabled").attr("disabled","disabled");
                                        
                                        $("#fibreMapForm").submit(function(e)
                                        {
                                            e.preventDefault();
                                            
                                            $("#btn-check").html("<span>CHECKING...</span>");
                                            
                                            $(".btn-check-fibre").addClass("disabled").attr("disabled","disabled");
                                            
                                            $("#map-response").empty();
                                            
                                            var $form = $(this),
                                            form_url = $form.attr("action");
                                            
                                            $.ajax(
                                            {
                                              url: form_url,
                                              type: "POST",
                                              data: $form.serializeArray(),
                                              cache: false,
                                              
                                              timeout: 150000,
                                              dataType: "json",
                                                                         
                                            })
                                            .done(function(data)
                                            {
                                                $(".inner-div:visible .btn-check-fibre span").html("CHECK");
                                                $(".inner-div:visible .btn-check-fibre").removeClass("disabled").removeAttr("disabled");
                                                
                                                var msg = "";
                                                
                                                if(data.status=="success")
                                                {
                                                    //----Fiber is available---
                                                    msg += data.message;
                                                    
                                                    if(data.service=="available")
                                                    {
                                                        //---selected service is available----
                                                        
                                                        msg += "<br/>Selected Service is available to order.Close the pop up and complete order."; 
                                                        
                                                        $("#btnCompleteProductConfig").removeClass("disabled").removeAttr("disabled","disabled");
                                                        if($("#address-input").val())
                                                        {
                                                              var addressArr = $("#address-input").val().split(",");
                                                              if($("#customfield'.$latlongCustFieldId.'"))
                                                              {
                                                                //--latitude & longitude---
                                                                $("#customfield'.$latlongCustFieldId.'").val($("#latlong-input").val());
                                                                $("#customfield'.$latlongCustFieldId.'").prop("readonly", true);
                                                              }
                                                              
                                                              if($("#customfield'.$addressCustFieldId.'"))
                                                              {
                                                                //---Address---
                                                                $("#customfield'.$addressCustFieldId.'").val(addressArr[0]);
                                                              }
                                                              if($("#customfield'.$subrubCustFieldId.'"))
                                                              {
                                                                //---subrub---
                                                                $("#customfield'.$subrubCustFieldId.'").val(addressArr[1]);
                                                              }
                                                              if($("#customfield'.$cityCustFieldId.'"))
                                                              {
                                                                //---city---
                                                                $("#customfield'.$cityCustFieldId.'").val(addressArr[2]);
                                                              }
                                                              if($("#customfield'.$postCustFieldId.'"))
                                                              {
                                                                //---post code---
                                                                $("#customfield'.$postCustFieldId.'").val(addressArr[3]);
                                                              }
                                                        }
                                                        $("#map-response").html(\'<div class="msg success">\'+msg+\'</div>\');
                                                    }
                                                    else if(data.service=="Fibre not available")
                                                    {
                                                        //---fibre not available----
                                                        errorMsg = "Unfortunately Fibre is not available in your area. Why not check out other connectivity options. <a href=\'javascript://\' onclick=\'showstep(1);\'>click here</a> to list of available other services in your area."; 
                                                        
                                                        $("#map-response").html(\'<div class="msg error">\'+errorMsg+\'</div>\');
                                                        
                                                        //---Adding product suggestions---
                                                        
                                                        $("#area-fibre-product").empty();
                                                        
                                                        var productHTML = "";
                                                            
                                                        if((data.suggestion).length)
                                                        {   
                                                            $.each(data.suggestion, function (key, value)
                                                            {
                                                               
                                                                productHTML += `
                                                                                <div class="col-md-6">
                                                                                    <div onclick="window.location=\'cart.php?gid=`+value.id+`\'" style="margin: 15px 0;padding: 15px;background-color: #fff;border: 1px solid #ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;-o-border-radius: 5px;border-radius: 5px;">
                                                                                        <div class="text-center" style="margin-bottom: 15px;">`+value.name+`</div>
                                                                                        <div class="text-center">
                                                                                            <a href="cart.php?gid=`+value.id+`" class="btn btn-success"><i class="fa fa-shopping-cart"></i> Order Now</a>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                               `;
                                                               
                                                            });
                                                        }
                                                        else
                                                        {
                                                            //---No suggestions---
                                                            productHTML = `
                                                            <div style ="text-align:center;padding-right: 50px;padding-left: 50px;">
                                                                <div class="alert alert-danger">
                                                                    <strong>Error!</strong> No service is avialble for this area.
                                                                    <p>Either <a href="javascript://" onclick="showstep(2);">Go Back</a> and try different address or <a href="/submitticket.php">Create a ticket</a>.</p>
                                                                </div>
                                                            </div>`;
                                                        }
                                                        
                                                        $("#area-fibre-product").append(productHTML);
                                                        
                                                        
                                                    }
                                                    else
                                                    {
                                                        //---service is not available---
                                                        errorMsg = "Currently selected srervice is not available in your area.Either try with different address or <a href=\'javascript://\' onclick=\'showstep(1);\'>click here</a> to list of available services in this area."; 
                                                        
                                                        $("#map-response").html(\'<div class="msg error">\'+errorMsg+\'</div>\');
                                                        
                                                        //---Adding product suggestions---
                                                        
                                                        $("#area-fibre-product").empty();
                                                        var productHTML = "";
                                                            
                                                        if((data.suggestion).length)
                                                        {
                                                            $.each(data.suggestion, function (key, value)
                                                            {
                                                                $.each(value, function (key1, value1)
                                                                {
                                                                    productHTML += `
                                                                                    <div class="col-md-6">
                                                                                        <div onclick="window.location=\'cart.php?a=add&amp;pid=`+value1.id+`\'" style="margin: 15px 0;padding: 15px;background-color: #fff;border: 1px solid #ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;-o-border-radius: 5px;border-radius: 5px;">
                                                                                            <div class="text-center" style="margin-bottom: 15px;">`+value1.name+`</div>
                                                                                            <div class="text-center">
                                                                                                <a href="cart.php?a=add&amp;pid=`+value1.id+`" class="btn btn-success"><i class="fa fa-shopping-cart"></i> Order Now</a>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                   `;
                                                                });
                                                            });
                                                        }
                                                        else
                                                        {
                                                            //---No suggestions---
                                                            productHTML = `
                                                            <div style ="text-align:center;padding-right: 50px;padding-left: 50px;">
                                                                <div class="alert alert-danger">
                                                                    <strong>Error!</strong> No service is avialble for this area.
                                                                    <p>Either <a href="javascript://" onclick="showstep(2);">Go Back</a> and try different address or <a href="/submitticket.php">Create a ticket</a>.</p>
                                                                </div>
                                                            </div>`;
                                                        }
                                                        $("#area-fibre-product").append(productHTML);
                                                        
                                                    }
                                                    
                                                }
                                                else
                                                {
                                                    $(".inner-div:visible .btn-check-fibre span").addClass("blink");
                                                    $("#map-response").html(\'<div class="msg error">\'+data.message+\'.Try Different Address.</div>\');
                                                    $("#btnCompleteProductConfig").addClass("disabled").attr("disabled","disabled");
                                                }
                                            })
                                            .fail(function(jqXHR, textStatus)
                                            {
                                                console.log("error on fibre availability");
                                                
                                                $(".inner-div:visible .btn-check-fibre span").addClass("blink").html("CHECK");
                                                $(".inner-div:visible .btn-check-fibre").removeClass("disabled").removeAttr("disabled");
                                                $("#map-response").html(\'<div class="alert alert-danger"><strong>Error! </strong>\'+ error+\'. Contact support team</div>\');
                                                $("#btnCompleteProductConfig").addClass("disabled").attr("disabled","disabled");
                                                
                                                if (textStatus == "timeout") 
                                                {
                                                    $("#map-response").html(\'<div class="msg error">Results currently not available. Please try again later.</div>\');					
                                                }
                                            });
                                            
                                        });
                                        
                                        
                                    });
                                    </script>
                                    '
                    ;
             * 
             */
        }
        elseif('Voice' === $checkProductConfig->configoption1)
        {
            $field_nameType = $axxessReseller->getAxxessSetting("custom_field", "voice_numbertype");
                    
            if(!empty($field_nameType)) 
            {
                $customFieldIdType = $axxessReseller->getCustomFiledId($field_nameType, $pid);
            }
            
            $field_nameExisting = $axxessReseller->getAxxessSetting("custom_field", "voice_existingno");
                    
            if(!empty($field_nameExisting)) 
            {
                $customFieldIdExisting = $axxessReseller->getCustomFiledId($field_nameExisting, $pid);
            }
                    

            if (empty($customFieldIdType) || empty($customFieldIdExisting)) 
            {
                return 0;
            }
            
            $footeroutput_axxess = '
                                <script type="text/javascript" src="modules/servers/axxessReseller/assets/js/voice.js?'.time().'"></script>
                                <link href="modules/servers/axxessReseller/assets/css/axxess.css?'.time().'" rel="stylesheet">
                                <script>
                                    var voiceExistingId = "'.$customFieldIdExisting.'";
                                    var voiceTypeId = "'.$customFieldIdType.'";
                                </script>
                                <!-- Modal -->
                                <div class="modal fade" id="voiceModal" tabindex="-1" role="dialog" aria-labelledby="voiceModalTitle" aria-hidden="true">
                                  <div class="modal-dialog modal-dialog-centered" role="document">
                                    <div class="modal-content">
                                      <div class="modal-header" style="color: #fff;background-color: #337ab7;border-color: #337ab7;">
                                        <h4 class="modal-title" id="voiceModalLongTitle">Existing Voice Number</h4>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="opacity: inherit;color:#fff">
                                          <span aria-hidden="true">&times;</span>
                                        </button>
                                      </div>
                                      <div class="modal-body">
                                        <p>
                                            This existing voice number needs to be residential only. If you transfer a number that is part of a block of multiple numbers from another provider, the other numbers will be deleted. 
                                        </p>
                                        
                                        <p>
                                            You will have to upload following documents after completing this order:
                                            <ol type="1">
                                                <li>Signed request form</li>
                                                <li>Copy of ID</li>
                                                <li>Latest paid invoice of current Service Provider</li>
                                                <li>Proof of Payment of existing network operators account</li>
                                            </ol> 
                                        </p>
                                        <p>
                                            <small>More information regarding uploading/downloading supporting documents will be available in product/service page once this order is completed.</small>
                                        </p>
                                      </div>
                                      <div class="modal-footer">
                                        <button type="button" class="btn btn-default" data-dismiss="modal" style="border-radius:0px;">Close</button>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                                ';
        }
        
        return $footeroutput_axxess;
    }
}


/**
 * Attach axxess products in drop down menu on product config page on admin area
 * @global type $CONFIG
 * @return string
 */
function axxess_attachProduct() 
{
    $action = htmlspecialchars($_GET['action']);
    
    $pid = htmlspecialchars($_GET['id']);
    
    $script_name = explode("/", $_SERVER['SCRIPT_NAME']); #/admin/configproducts.php
    
    if (end($script_name) == 'configproducts.php' && $action == 'edit') 
    {
        
        $return = '
            <style>
            #tblModuleSettings .select-inline
            {
                max-width: 100%;
            }
            </style>
            <script>
            var axxessPid = "'.$pid.'";
            </script>
            <script src="../modules/servers/axxessReseller/assets/js/axxess.js?'.time().'"></script>';
    }

    return $return;
}
/**
 * adminarea clientservice page
 * Check DSL line status
 * Axxess client login
 */

/*
function axxess_checkLine()
{
    $userid = htmlspecialchars($_GET['userid']);
    $script_name = explode("/", $_SERVER['SCRIPT_NAME']); #/admin/configproducts.php
    if (end($script_name) == 'clientsservices.php')
    {
        $return = '
            <!-- Modal -->
            <div id="myModal" class="modal fade" role="dialog">
              <div class="modal-dialog">
                <!-- Modal content-->
                <div class="modal-content" style="background: #f7f7f7;">
                  <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <img src="../modules/servers/axxessReseller/images/profile_linefix_update.png" style="float:left;" height="46" width="46">
                    <div style="float:left;font-size:28px;margin-left:10px;line-height:18px;" class="bold">Check My Line 
                        <span style="font-size:15px;"></span><br>
                        <span style="font-size:13px;font-weight:normal;">Take control of your DSL Line and get optimal speeds by performing a port recreate.</span>
                    </div>
                    <div style="clear:left;"></div>
                  </div>
                <div class="modal-body">
                    <div style="text-align:center">
                        <input id="button_checkline" value="Check Line Status" class="btn btn-primary" style="width:220px;margin-top:10px;margin-right:30px;height:auto;font-size:22px;" onclick="axxess_checkLineStatus();" type="button"> 
                        <input id="button_fixline" value="Fix My Line" class="btn btn-primary" style="width:220px;margin-top:10px;height:auto;font-size:22px;" onclick="axxess_fixLine();" type="button">
                        <!--<input id="button_linefault" value="Report Line Fault" class="btn btn-primary" style="width:220px;margin-top:10px;height:auto;font-size:22px;" onclick="linefault();" type="button">-->
                        <div id="mainstatus" style="margin-top:30px;"></div>
                        <div id="dyk" style="clear:left;margin-left:108px;margin-top:10px;font-size:13px;"></div>
                    </div>
                    <div id="line_results"></div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
                </div>
              </div>
            </div>
            
            <script>
            if($("#axxess_line").length)
            {
                var line = $("#axxess_line").attr("line-no");
                var guidserviceid = $("#axxess_line").attr("guidserviceid");
                
                function axxess_checkLineStatus() 
                {
                    $("#line_results").html("");
                    $("#mainstatus").html(\'<img src="../modules/servers/axxessReseller/images/loader.gif" border="0" alt="" style="float:left;margin-left:120px;margin-right:10px;width:36px;height:36px;" /><div style="font-size:24px;float:left;width:320px;text-align:left;line-height:22px;">Checking your Line Status<br><span style="font-size:14px;">Please be patient. This could take a few minutes.</span></div>\');
                    buttonDisable("button_checkline");
                    buttonDisable("button_fixline");
                    buttonDisable("button_linefault");
                    var url = "../modules/servers/axxessReseller/calls/portfunc.php";
                    if ( typeof(checkLineAjax) == "object" )
                    { 
                        checkLineAjax.abort();
                    }
                    checkLineAjax = $.ajax({
                                            type: "POST",
                                            url: url,
                                            data: { 
                                                    "query": "checkLineStatus", 
                                                    "token_line_no": line,
                                                    "product_id":"",
                                                    "guidServiceId":guidserviceid
                                                   },
                                            cache: false,
                                            dataType: "json",
                                            timeout: 120000, // 2 minutes
                                            error: function(request,error,errorThrown)
                                            {
                                                buttonEnable("button_checkline");
                                                buttonEnable("button_fixline");
                                                buttonEnable("button_linefault");
                                                $("#mainstatus").html(error);
                                            },
                                            success: function(response) 
                                            {
                                                buttonEnable("button_checkline");
                                                buttonEnable("button_fixline");
                                                buttonEnable("button_linefault");
                                                console.log(response);
                                                $("#mainstatus").html("");
                                                var adviseFix = false;
                                                if (response.data != "")
                                                {
                                                    var down_speed, down_att, down_snr, up_speed, up_att, up_snr;
                                                    var down_speed_advise, down_att_advise, down_snr_advise, up_speed_advise, up_att_advise, up_snr_advise;
                                                    $.each(response.data, function (i, v) 
                                                    {
                                                        //console.log(i+": "+v);
                                                        if (i == "ATUC Current Rate" && v != "")
                                                        {
                                                            down_speed = v;
                                                        }
                                                        else if (i == "ATUC Attenuation" && v != "")
                                                        {
                                                            down_att = v;
                                                        }
                                                        else if (i == "ATUC SNR" && v != "") 
                                                        {
                                                            down_snr = v;
                                                        }
                                                        else if (i == "ATUR Current Rate" && v != "")
                                                        {
                                                            up_speed = v;
                                                        }
                                                        else if (i == "ATUR Attenuation" && v != "")
                                                        {
                                                            up_att = v;
                                                        }
                                                        else if (i == "ATUR SNR" && v != "")
                                                        {
                                                            up_snr = v;
                                                        }
                                                        if (i == "errordiv" && v != "") 
                                                        { // error
                                                            $("#mainstatus").html(\'<div style="text-align:center;font-size:16px;color:#f00;">Your exchange is currently busy. Please try again later.</div>\');
                                                            console.log(v);
                                                            return false;
                                                        }
                                                        if (i == "ATUC Current Rate" && v == null)
                                                        { 
                                                            // error
                                                            //console.log("erreo"+i+": "+v);
                                                            $("#mainstatus").html(\'<div style="text-align:center;font-size:16px;color:#f00;">Error: No Line response or your modem is not connected.</div>\');
                                                            return false;
                                                        }
                                                    });
                                                    if (down_att == undefined)
                                                    {
                                                        return;
                                                    }
                                                    // recommendation	
                                                    if (parseFloat(down_att.split(" ")[0]) <= 50)
                                                    {
                                                        down_att = \'<span style="color:#090;">\'+down_att+\'</span>\';
                                                        down_att_advise = false;
                                                    }
                                                    else if (parseFloat(down_att.split(" ")[0]) > 50 && parseFloat(down_att.split(" ")[0]) <= 55) 
                                                    {
                                                        down_att = \'<span style="color:#f60;">\'+down_att+\'</span>\';
                                                        down_att_advise = true;
                                                    }
                                                    else if (parseFloat(down_att.split(" ")[0]) > 55)
                                                    {
                                                        down_att = \'<span style="color:#f00;">\'+down_att+\'</span>\';
                                                        down_att_advise = true;
                                                    }
                                                    if (parseFloat(down_snr.split(" ")[0]) < 6)
                                                    {
                                                        down_snr = \'<span style="color:#f00;">\'+down_snr+\'</span>\';
                                                        down_snr_advise = true;
                                                    }
                                                    else if (parseFloat(down_snr.split(" ")[0]) >= 6 && parseFloat(down_snr.split(" ")[0]) <= 8)
                                                    {
                                                        down_snr = \'<span style="color:#f60;">\'+down_snr+\'</span>\';
                                                        down_snr_advise = true;
                                                    }
                                                    else if (parseFloat(down_snr.split(" ")[0]) > 8)
                                                    {
                                                        down_snr = \'<span style="color:#090;">\'+down_snr+\'</span>\';
                                                        down_snr_advise = false;
                                                    }
                                                    if (parseFloat(up_att.split(" ")[0]) <= 50)
                                                    {
                                                        up_att = \'<span style="color:#090;">\'+up_att+\'</span>\';
                                                        up_att_advise = false;
                                                    }
                                                    else if (parseFloat(up_att.split(" ")[0]) > 50 && parseFloat(up_att.split(" ")[0]) <= 55)
                                                    {
                                                        up_att = \'<span style="color:#f60;">\'+up_att+\'</span>\';
                                                        up_att_advise = true;
                                                    }
                                                    else if (parseFloat(up_att.split(" ")[0]) > 55) 
                                                    {
                                                        up_att = \'<span style="color:#f00;">\'+up_att+\'</span>\';
                                                        up_att_advise = true;
                                                    }
                                                    if (parseFloat(up_snr.split(" ")[0]) < 6)
                                                    {
                                                        up_snr = \'<span style="color:#f00;">\'+up_snr+\'</span>\';
                                                        up_snr_advise = true;
                                                    }
                                                    else if (parseFloat(up_snr.split(" ")[0]) >= 6 && parseFloat(up_snr.split(" ")[0]) <= 8) 
                                                    {
                                                        up_snr = \'<span style="color:#f60;">\'+up_snr+\'</span>\';
                                                        up_snr_advise = true;
                                                    }
                                                    else if (parseFloat(up_snr.split(" ")[0]) > 8) 
                                                    {
                                                        up_snr = \'<span style="color:#090;">\'+up_snr+\'</span>\';
                                                        up_snr_advise = false;
                                                    }
                                                    // results
                                                  $("#line_results").html(\'<fieldset style="float:left;background-color:#fff;padding:10px;padding-top:0px;color:#555;width:280px;margin-right:10px;border: 1px solid #7fb9ec;"><legend style="font-size: 16px;color:#0C5F8C;border-bottom:none;width: auto;margin-bottom: 4px;">Line Status</legend><div style=""><table style="width:100%;"><tbody><tr><td colspan="2" class="bold" style="text-align: left;"><b>Your Download Quality</b></td></tr><tr><td width="170" style="font-size:14px;text-align: left;">Current Speed:</td><td id="d_speed" align="right" style="font-size:14px;text-align: right;">\'+down_speed+\'</td></tr><tr><td style="font-size:14px;text-align: left;border-bottom:none;width: auto;margin-bottom: 4px;">Signal Interference:</td><td id="d_att" align="right" style="font-size:14px;">\'+down_att+\'</td></tr><tr><td style="font-size:14px;text-align: left;">Signal to Noise Ratio:</td><td id="d_snr" align="right" style="font-size:14px;">\'+down_snr+\'</td></tr></tbody></table><table style="margin-top:10px;width:100%;"><tbody><tr><td colspan="2" class="bold" style="font-weight:bold;text-align: left;">Your Upload Quality</td></tr><tr><td width="170" style="font-size:14px;text-align: left;">Current Speed:</td><td id="u_speed" align="right" style="font-size:14px;">\'+up_speed+\'</td></tr><tr><td style="font-size:14px;text-align: left;">Signal Interference:</td><td id="u_att" align="right" style="font-size:14px;">\'+up_att+\'</td></tr><tr><td style="font-size:14px;text-align: left;">Signal to Noise Ratio:</td><td id="u_snr" align="right" style="font-size:14px;">\'+up_snr+\'</td></tr></tbody></table><div style="clear:both;"></div></div></fieldset><fieldset style="float:left;background-color:#fff;padding:10px;padding-top:0px;color:#555;width:275px;height:214px;border: 1px solid #7fb9ec;"><legend style="font-size: 16px;color:#0C5F8C;border-bottom:none; width:auto;margin-bottom:4px;">Recommendation</legend> <div id="rec_status"></div> </fieldset>\');
                                                    // legend
                                                    $("#line_results").append(\'<div style="clear:left;"></div><fieldset style="margin-top: 5px;background-color: #fff;border: 1px solid #7fb9ec;padding: 5px 10px 10px;"><legend style="color:#0C5F8C;border-bottom: none; margin-bottom: 4px; width: auto; font-size:15px;">What does this mean?</legend><table class="define"><tr><td width="150" class="bold" style="text-align: left;font-size: 15px;font-weight: 700;">Current Speed:</td><td style="font-size: 15px; text-align: left;">The current speed established between the exchange and your modem.</td></tr><tr><td class="bold" style="text-align: left;font-size: 15px;font-weight: 700;">Signal Interference:</td><td style="font-size: 15px; text-align: left;">If this value is high, then the signal quality is low, and vice versa.</td></tr><tr><td class="bold" style="text-align: left;font-size: 15px;font-weight: 700;">Signal to Noise Ratio:</td><td style="font-size: 15px; text-align: left;">The signal level compared to the noise level. The higher the signal value, the better.</td></tr></table></fieldset>\');
                                                    // recommendation
                                                    if (!down_att_advise && !down_snr_advise && !up_att_advise && !up_snr_advise) 
                                                    { 
                                                        //no issues
                                                        $("#rec_status").html(\'<div style="font-size:14px;text-align:center;margin-top:20px;color:#1ABC9C;">There are no defects on your line.<br>No need to Fix your Line.</div><div style="width:90px;height:90px;overflow:hidden;background:url("../modules/servers/axxessReseller/images/success.png") no-repeat;margin: 0 auto;margin-top:20px;"></div>\');
                                                    }
                                                    else
                                                    {
                                                        $("#rec_status").html(\'<div style="font-size:14px;text-align:center;margin-top:20px;color:#E74C3C">There are defects on your line.<br>Click on Fix my Line.</div>  <div style="width:90px;height:90px;overflow:hidden;background:url("../modules/servers/axxessReseller/images/error.png") no-repeat;margin: 0 auto;margin-top:20px;"></div>\');
                                                    }
                                                }
                                            }
                                        });
                }
                
                function axxess_fixLine() 
                {
                    $("#line_results").html("");
                    $("#mainstatus").html(\'<img src="../modules/servers/axxessReseller/images/loader.gif" border="0" alt="" style="float:left;margin-left:120px;margin-right:10px;width:36px;height:36px;" /><div style="font-size:24px;float:left;width:320px;text-align:left;line-height:22px;">Fixing your Line<br><span style="font-size:14px;">Please be patient. This could take a few minutes.</span></div>\');
                    buttonDisable("button_checkline");
                    buttonDisable("button_fixline");
                    buttonDisable("button_linefault");
                    var url = "../modules/servers/axxessReseller/calls/portfunc.php";
                    if (typeof(checkLineAjax) == "object")
                    { 
                        checkLineAjax.abort();
                    }
                    checkLineAjax = $.ajax({
                                            type: "POST",
                                            url: url,
                                            data: { 
                                                    "query": "fixLine",
                                                    "token_line_no": line,
                                                    "product_id":"",
                                                    "guidServiceId":guidserviceid
                                                   },
                                            cache: false,
                                            dataType: "json",
                                            timeout: 300000, // 5 minutes
                                            error: function(request,error,errorThrown)
                                            {
                                                buttonEnable("button_checkline");
                                                buttonEnable("button_fixline");
                                                buttonEnable("button_linefault");
                                                $("#mainstatus").html("");
                                            },
                                            success: function(response)
                                            {
                                                buttonEnable("button_checkline");
                                                buttonEnable("button_fixline");
                                                buttonEnable("button_linefault");
                                                $("#mainstatus").html("");
                                                if (response.data != "")
                                                {
                                                    var before_down_speed, before_down_att, before_down_snr, before_up_speed, before_up_att, before_up_snr, after_down_speed, after_down_att, after_down_snr, after_up_speed, after_up_att, after_up_snr;
                                                    var message;
                                                    $.each(response.data, function (i, v)
                                                    {
                                                        if (i == "message" && v != "")
                                                        {
                                                            message = v;
                                                        }
                                                        if (i == "error" && v != "")
                                                        {
                                                            $("#mainstatus").html(\'<div style="text-align:center;font-size:16px;color:#f00;">Error:<br>No Line response or your modem is not connected.</div>\');
                                                            console.log(v);
                                                            return false;
                                                        }
                                                        if (i == "success" && v != "")
                                                        {
                                                            $("#mainstatus").html(\'<div style="text-align:center;font-size:16px;color:#1ABC9C;">Success:<br>\'+v+\'</div>\');
                                                            console.log(v);
                                                            return false;
                                                        }
                                                    });
                                                    if (data["before.interrogation"] == undefined)
                                                    {
                                                            return;
                                                    }
                                                    if (message == undefined) 
                                                    { 
                                                            return;
                                                    }
                                        $("#mainstatus").html(\'<span class="bold" style="font-size:15px;">\'+message+\'</span>\');
                                        $.each(data["before.interrogation"], function (i, v) {	
                                                if (i == "ATUC Current Rate" && v != "") {
                                                        before_down_speed = v;
                                                } else if (i == "ATUC Attenuation" && v != "") {
                                                        before_down_att = v;
                                                } else if (i == "ATUC SNR" && v != "") {
                                                        before_down_snr = v;
                                                } else if (i == "ATUR Current Rate" && v != "") {
                                                        before_up_speed = v;
                                                } else if (i == "ATUR Attenuation" && v != "") {
                                                        before_up_att = v;
                                                } else if (i == "ATUR SNR" && v != "") {
                                                        before_up_snr = v;
                                                }	
                                        });
                                        $.each(data["after.interrogation"], function (i, v) {
                                                if (i == "ATUC Current Rate" && v != "") {
                                                        after_down_speed = v;
                                                } else if (i == "ATUC Attenuation" && v != "") {
                                                        after_down_att = v;
                                                } else if (i == "ATUC SNR" && v != "") {
                                                        after_down_snr = v;
                                                } else if (i == "ATUR Current Rate" && v != "") {
                                                        after_up_speed = v;
                                                } else if (i == "ATUR Attenuation" && v != "") {
                                                        after_up_att = v;
                                                } else if (i == "ATUR SNR" && v != "") {
                                                        after_up_snr = v;
                                                }
                                        });	
                                        // recommendation
                                        if (parseFloat(before_down_att.split(" ")[0]) <= 50) {
                                                before_down_att = \'<span style="color:#090;">\'+before_down_att+\'</span>\';
                                        } else if (parseFloat(before_down_att.split(" ")[0]) > 50 && parseFloat(before_down_att.split(" ")[0]) <= 55) {
                                                before_down_att = \'<span style="color:#f60;">\'+before_down_att+\'</span>\';
                                        }  else if (parseFloat(before_down_att.split(" ")[0]) > 55) {
                                                before_down_att = \'<span style="color:#f00;">\'+before_down_att+\'</span>\';
                                        }
                                        if (parseFloat(before_down_snr.split(" ")[0]) < 6) {
                                                before_down_snr = \'<span style="color:#f00;">\'+before_down_snr+\'</span>\';
                                        } else if (parseFloat(before_down_snr.split(" ")[0]) >= 6 && parseFloat(before_down_snr.split(" ")[0]) <= 8) {
                                                before_down_snr = \'<span style="color:#f60;">\'+before_down_snr+\'</span>\';
                                        }  else if (parseFloat(before_down_snr.split(" ")[0]) > 8) {
                                                before_down_snr = \'<span style="color:#090;">\'+before_down_snr+\'</span>\';
                                        }
                                        if (parseFloat(before_up_att.split(" ")[0]) <= 50) {
                                                before_up_att = \'<span style="color:#090;">\'+before_up_att+\'</span>\';
                                        } else if (parseFloat(before_up_att.split(" ")[0]) > 50 && parseFloat(before_up_att.split(" ")[0]) <= 55) {
                                                before_up_att = \'<span style="color:#f60;">\'+before_up_att+\'</span>\';
                                        }  else if (parseFloat(before_up_att.split(" ")[0]) > 55) {
                                                before_up_att = \'<span style="color:#f00;">\'+before_up_att+\'</span>\';
                                        }
                                        if (parseFloat(before_up_snr.split(" ")[0]) < 6) {
                                                before_up_snr = \'<span style="color:#f00;">\'+before_up_snr+\'</span>\';
                                        } else if (parseFloat(before_up_snr.split(" ")[0]) >= 6  && parseFloat(before_up_snr.split(" ")[0]) <= 8) {
                                                before_up_snr = \'<span style="color:#f60;">\'+before_up_snr+\'</span>\';
                                        }  else if (parseFloat(before_up_snr.split(" ")[0]) > 8) {
                                                before_up_snr = \'<span style="color:#090;">\'+before_up_snr+\'</span>\';
                                        }
                                        if (parseFloat(after_down_att.split(" ")[0]) <= 50) {
                                                after_down_att = \'<span style="color:#090;">\'+after_down_att+\'</span>\';
                                        } else if (parseFloat(after_down_att.split(" ")[0]) > 50 && parseFloat(after_down_att.split(" ")[0]) <= 55) {
                                                after_down_att = \'<span style="color:#f60;">\'+after_down_att+\'</span>\';
                                        }  else if (parseFloat(after_down_att.split(" ")[0]) > 55) {
                                                after_down_att = \'<span style="color:#f00;">\'+after_down_att+\'</span>\';
                                        }
                                        if (parseFloat(after_down_snr.split(" ")[0]) < 6) {
                                                after_down_snr = \'<span style="color:#f00;">\'+after_down_snr+\'</span>\';
                                        } else if (parseFloat(after_down_snr.split(" ")[0]) >= 6 && parseFloat(after_down_snr.split(" ")[0]) <= 8) {
                                                after_down_snr = \'<span style="color:#f60;">\'+after_down_snr+\'</span>\';
                                        }  else if (parseFloat(after_down_snr.split(" ")[0]) > 8) {
                                                after_down_snr = \'<span style="color:#090;">\'+after_down_snr+\'</span>\';
                                        }
                                        if (parseFloat(after_up_att.split(" ")[0]) <= 50) {
                                                after_up_att = \'<span style="color:#090;">\'+after_up_att+\'</span>\';
                                        } else if (parseFloat(after_up_att.split(" ")[0]) > 50 && parseFloat(after_up_att.split(" ")[0]) <= 55) {
                                                after_up_att = \'<span style="color:#f60;">\'+after_up_att+\'</span>\';
                                        }  else if (parseFloat(after_up_att.split(" ")[0]) > 55) {
                                                after_up_att = \'<span style="color:#f00;">\'+after_up_att+\'</span>\';
                                        }
                                        if (parseFloat(after_up_snr.split(" ")[0]) < 6) {
                                                after_up_snr = \'<span style="color:#f00;">\'+after_up_snr+\'</span>\';
                                        } else if (parseFloat(after_up_snr.split(" ")[0]) >= 6 && parseFloat(after_up_snr.split(" ")[0]) <= 8) {
                                                after_up_snr = \'<span style="color:#f60;">\'+after_up_snr+\'</span>\';
                                        }  else if (parseFloat(after_up_snr.split(" ")[0]) > 8) {
                                                after_up_snr = \'<span style="color:#090;">\'+after_up_snr+\'</span>\';
                                        }
                                        // results
                                        $("#line_results").html(\'<fieldset style="float:left;background-color:#fff;padding:10px;padding-top:0px;color:#555;width:260px;margin-right:10px;"><legend style="color:#0C5F8C;">Before Fix my Line</legend><div style=""><table style="width:100%;"><tbody><tr><td colspan="2" class="bold">Your Download Quality</td></tr><tr><td width="180">Current Speed:</td><td align="right">\'+before_down_speed+\'</td></tr><tr><td>Signal Interference:</td><td align="right">\'+before_down_att+\'</td></tr><tr><td>Signal to Noise Ratio:</td><td align="right">\'+before_down_snr+\'</td></tr></tbody></table><table style="margin-top:10px;width:100%;"><tbody><tr><td colspan="2" class="bold">Your Upload Quality</td></tr><tr><td width="180">Current Speed:</td><td align="right">\'+before_up_speed+\'</td></tr><tr><td>Signal Interference:</td><td align="right">\'+before_up_att+\'</td></tr><tr><td>Signal to Noise Ratio:</td><td align="right">\'+before_up_snr+\'</td></tr></tbody></table><div style="clear:both;"></div></div></fieldset><fieldset style="float:left;background-color:#fff;padding:10px;padding-top:0px;color:#555;width:260px;"><legend style="color:#0C5F8C;">After Fix my Line</legend><div style=""><table style="width:100%;"><tbody><tr><td colspan="2" class="bold">Your Download Quality</td></tr><tr><td width="180">Current Speed:</td><td align="right">\'+after_down_speed+\'</td></tr><tr><td>Signal Interference:</td><td align="right">\'+after_down_att+\'</td></tr><tr><td>Signal to Noise Ratio:</td><td align="right">\'+after_down_snr+\'</td></tr></tbody></table><table style="margin-top:10px;width:100%;"><tbody><tr><td colspan="2" class="bold">Your Upload Quality</td></tr><tr><td width="180">Current Speed:</td><td align="right">\'+after_up_speed+\'</td></tr><tr><td>Signal Interference:</td><td align="right">\'+after_up_att+\'</td></tr><tr><td>Signal to Noise Ratio:</td><td align="right">\'+after_up_snr+\'</td></tr></tbody></table><div style="clear:both;"></div></div></fieldset>\');
                                        // legend					
                                        $("#line_results").append(\'<div style="clear:left;"></div><fieldset style="margin-top:5px;background-color:#fff;"><legend style="color:#0C5F8C;">What does this mean?</legend><table class="define"><tr><td width="150" class="bold" style="text-align: left;font-size: 15px;font-weight: 700;">Current Speed:</td><td style="font-size: 15px; text-align: left;">The current speed established between the exchange and your modem.</td></tr><tr><td class="bold" style="text-align: left;font-size: 15px;font-weight: 700;">Signal Interference:</td><td style="font-size: 15px; text-align: left;">If this value is high, then the signal quality is low, and vice versa.</td></tr><tr><td class="bold" style="text-align: left;font-size: 15px;font-weight: 700;">Signal to Noise Ratio:</td><td style="font-size: 15px; text-align: left;">The signal level compared to the noise level. The higher the signal value, the better.</td></tr></table></fieldset>\');
                                }
                                }
                        });
                }
                function linefault() 
                {
                    $("#line_results").html("");
                    $("#mainstatus").html(\'<img src="../modules/servers/axxessReseller/images/loader.gif" border="0" alt="" style="float:left;margin-left:120px;margin-right:10px;width:36px;height:36px;" /><div style="font-size:24px;float:left;width:320px;text-align:left;line-height:22px;">Fixing your Line<br><span style="font-size:14px;">Please be patient. This could take a few minutes.</span></div>\');
                    buttonDisable(\'button_checkline\');
                    buttonDisable(\'button_fixline\');
                    buttonDisable(\'button_linefault\');
                    var url = "modules/servers/axxessReseller/calls/portfunc.php";
                    if (typeof(checkLineAjax) === "object")
                    { 
                        checkLineAjax.abort();
                    }
                    checkLineAjax = $.ajax({
                                            type: "POST",
                                            url: url,
                                            data: {
                                                    "query":"openTicket",
                                                    "client_id": "' . $userid . '",
                                                   },
                                            cache: false,
                                            dataType: "json",
                                            timeout: 300000, // 5 minutes
                                            error: function(request,error,errorThrown)
                                            {
                                                buttonEnable(\'button_checkline\');
                                                buttonEnable(\'button_fixline\');
                                                buttonEnable(\'button_linefault\');
                                                $("#mainstatus").html(\'error\');
                                            },
                                            success: function(data)
                                            {
                                                buttonEnable(\'button_checkline\');
                                                buttonEnable(\'button_fixline\');
                                                buttonEnable(\'button_linefault\');
                                                $("#mainstatus").html("");
                                                console.log(data);
                                                if (data != "")
                                                {
                                                    if (data.status=="success")
                                                    {
                                                        $("#mainstatus").html(\'<div style="text-align:center;font-size:16px;color:#3C763D;">Success:<br>Ticket has been Opened.</div>\');
                                                    }
                                                    if (data.status=="error")
                                                    {
                                                        $("#mainstatus").html(\'<div style="text-align:center;font-size:16px;color:#f00;">Error:<br>\'+ data.msg +\'</div>\');
                                                        return false;
                                                    }		
                                                }
                                            }
                        });
                }
                function buttonDisable(id) 
                {
                        $("#"+id).attr("disabled","disabled");
                        $("#"+id).removeClass("btn-primary").addClass("btn-primary-disabled");
                        $("#"+id).css("color","#999");
                }
                function buttonEnable(id) 
                {
                        $("#"+id).removeAttr("disabled");
                        $("#"+id).removeClass("btn-primary-disabled").addClass("btn-primary");
                        $("#"+id).css("color","#fff");
                }
            }
            </script>
                ';
        #login to axxess account
        if($userid)
        {
            $clientRCPDetails_response = axxess_getClientRCP($userid);
            if($clientRCPDetails_response['status']=='success' && !empty($clientRCPDetails_response['data']))
            {
                #user exist on axxess
                $username = $clientRCPDetails_response['data']->username;
                $password = $clientRCPDetails_response['data']->password;
                
                $login_modal ='
                    <!-- axxess client login modal -->
                    <div class="modal fade" id="axxessClientLogin"  role="dialog">
                        <div class="modal-dialog">
                            <!-- Modal content-->
                            <div class="modal-content">
                                <div class="modal-header" style="background-color: #1a4d80;color: white;">
                                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                                    <h4 class="modal-title">Login into Axxess Control Panel</h4>
                                </div>
                                <div class="modal-body">
                                ';
                
                if(!empty($username) && !empty($password))
                {
                    $login_modal .='
                                    <center>
                                        <p>Authenticating...</p>
                                        <img src="../modules/servers/axxessReseller/images/loader.gif" alt="loader">
                                    </center>
                                    <div id="axxessScript" style="display:none;">
                                        <script type="text/javascript">
                                        //<![CDATA[
                                        (function ()
                                        {
                                            document.write(\'<script type="text/javascript" src="\' + \'https://www.youradsl.co.za/loginbox.php?\' + (new Date().getTime()) + \'"></\' + \'script>\');
                                        })
                                        ();
                                        //]]>
                                        </script>
                                    </div>
                                    <script>
                                    $(document).ready(function ()
                                    {
                                        if ($("#Usernamefield").length)
                                        {
                                            $("#Usernamefield").val("'.$username.'");
                                        }
                                        if ($("#Password").length)
                                        {
                                            $("#Password").val("'.$password.'");
                                        }
                                        
                                        $("#axxessClientLogin").on("shown.bs.modal", function ()
                                        {
                                            if ($(\'form[name="frmlogin"]\').length)
                                            {
                                                $(\'form[name="frmlogin"]\').attr("target", "_blank");
                                                $(\'form[name="frmlogin"]\').submit();
                                                $("#axxessClientLogin").modal("hide");
                                            }
                                        });
                                        
                                    });
                                    </script>
                             ';
                }
                else
                {
                    #username or password missing
                    $login_modal .='
                                    <form autocomplete="off" name="axxessClientLogin" action="https://www.youradsl.co.za/login.php" method="post" id="axxe_form" target="_blank">
                                        <center>
                                            <h3 style="color:red">Username or password is missing.</h3>
                                            <div class="form-group">
                                                <label for="Usernamefield" style="float:left">Enter Username </label>
                                                <input type="text" id="Usernamefield" name="loginName" value="'.$username.'" autocomplete="off" placeholder="Enter Username" class="form-control" required>
                                            </div>
                                            <div class="form-group">
                                                <label for="password" style="float:left">Enter Password </label>
                                                <input type="password" id="Password" name="password" value="'.$password.'" autocomplete="off" placeholder="Enter Password" class="form-control" required>
                                                <input type="hidden" name="clientid" value="'.$userid.'">
                                            </div>
                                            <button type="reset" class="btn btn-sm btn-default" value="reset">Reset</button>
                                            <button type="submit" name="submitdetail" id="axxessdetail" value="Login" class="btn btn-sm btn-primary">Login</button>
                                        </center>
                                    </form>
                                    
                                    <script type="text/javascript" src="../modules/addons/Axxess_Account_Manager/assets/js/validator.js"></script>
                                    <script type="text/javascript">
                                    $(document).ready(function()
                                    {
                                        $("#axxe_form").validator().on("submit", function (e)
                                        {
                                            if(e.isDefaultPrevented())
                                            {
                                            }
                                            else
                                            {
                                                $("#axxessdetail").attr("disabled","true");
                                                $("#axxessdetail").text("Authenticating...");
                                                
                                                $.ajax(
                                                    {
                                                        type: "POST",
                                                        url: "../modules/servers/axxessReseller/calls/updateaxxessdetail.php",
                                                        data: $("#axxe_form").serialize(),
                                                        success: function(data)
                                                        {
                                                            $("#axxessClientLogin").modal("hide");
                                                            location.reload();
                                                        }
                                                    });
                                                $("#axxessdetail").attr("disabled","false");
                                            }
                                        });
                                    });
                                    </script>
                                    ';
                }
                #footer
                $login_modal .='
                                </div>
                            <div class="modal-footer"></div>
                        </div>
                    </div>
                </div>
            <!----end modal---->
                    ';
            }
        }
    }
    return $return."<br>".$login_modal;
}
*/

/* ----Hook Points----- */

add_hook('ClientAreaPrimarySidebar', 1, 'axxess_primarySidebar');

add_hook('ClientAreaPrimaryNavbar', 2,'axxess_primaryNavbar');
//add_hook('AddonActivation', 1, 'axxess_topUp');
//add_hook('ClientAreaHeadOutput', 1, 'axxess_changePassword');

add_hook('ClientAreaFooterOutput', 2, 'axxess_remove_config');

//add_hook('DailyCronJob', 1, 'axxess_terminateAddon');

add_hook('AdminAreaHeaderOutput', 1, 'axxess_attachProduct');

//add_hook('AdminAreaFooterOutput', 2, 'axxess_checkLine');