Jump to content
  • 0

Admin services tab additional fields. - I can't get it to work. :(


Bets

Question

Hi,

I have ben started make a module for our company yesterday, 

I don't understand how to make the additional fields work.  😞

I've been reading the documentation and checking the sample files for two days now, but it's not really getting into my head... hahaha 
When clicked "Save" on WHMCS no error returned.
But nothing of the additional fields created got being saved. obviously it doesn't return the saved values either.

 

/**
 * Admin services tab additional fields.
 *
 * Define additional rows and fields to be displayed in the admin area service
 * information and management page within the clients profile.
 *
 * Supports an unlimited number of additional field labels and content of any
 * type to output.
 *
 * @param array $params common module parameters
 *
 * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
 * @see urcumodule_AdminServicesTabFieldsSave()
 *
 * @return array
 */
function urcumodule_AdminServicesTabFields(array $params)
{

    $result = select_query(
        "streaming_server",
        "streaming_usuario",
        "streaming_porta",
        "streaming_porta_ssl",
        "streaming_mountpoint",
        array("serviceid" => $params['serviceid'],)
    );
    $data = mysql_fetch_array($result);

    $streaming_server = $params['customfields']['streaming_server'];
    $streaming_usuario = $params['customfields']['streaming_usuario'];
    $streaming_porta = $params['customfields']['streaming_porta'];
    $streaming_porta_ssl = $params['customfields']['streaming_porta_ssl'];
    $streaming_mountpoint = $params['customfields']['streaming_mountpoint'];

    if (  $streaming_usuario == "" ) {
        $streaming_usuario = $params['username'];
    }

    $fieldsForCentova = array(
        'Servidor Streaming' => '<select name="streaming_server" id="streaming_server" class="form-control select-inline">
        <option '. ( $streaming_server == "") { "selected" } .'>Selecione ...</option>
        <option value="cast.mydomain.com.br" '. ( $streaming_server == "cast.mydomain.com.br") { "selected" } .'>Centovacast - CAST #1</option>
        <option value="cast2.mydomain.com.br" '. ( $streaming_server == "cast2.mydomain.com.br") { "selected" } .'>Centovacast - CAST #2</option>
        <option value="cast3.mydomain.com.br" '. ( $streaming_server == "cast3.mydomain.com.br") { "selected" } .'>Centovacast - CAST #3</option>
        <option value="cast3.mydomain.com.br" '. ( $streaming_server == "cast4.mydomain.com.br") { "selected" } .'>Centovacast - CAST #4</option>
        </select>',
        'Usuario Streaming' => '<input type="text" name="streaming_usuario" id="streaming_usuario" class="form-control input-200" value="'. $streaming_usuario.'">',
        'Porta' => '<input type="text" name="streaming_porta" id="streaming_porta" class="form-control input-200" value="'. $streaming_porta.'">',
        'Porta SSL' => '<input type="text" name="streaming_porta_ssl" id="streaming_porta_ssl" class="form-control input-200" value="'. $streaming_porta_ssl.'">',
        'Mountpoint' => '<input type="text" name="streaming_mountpoint" id="streaming_mountpoint" class="form-control input-200" value="'. $streaming_mountpoint.'">',
        'Streaming Commands' => '
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnStartStream"><i class="fas fa-play"></i> Iniciar Streaming</button> 
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnStopStream"><i class="fas fa-stop"></i> Parar Streaming</button> 
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnRefreshStream"><i class="fas fa-sync-alt"></i> Reiniciar streaming</button>
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnProgrametes"><i class="fas fa-music"></i> Instalar Programetes</button> ',
        'SiteAdmin Comands' => '
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnImplantar"><i class="fas fa-sitemap"></i> Implantar</button> 
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnServiceEmail"><i class="fas fa-envelope"></i> Enviar dados de acesso</button>
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnUrlFix"><i class="fas fa-link"></i> Fixar URLs</button> 
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnRefreshSiteFiles"><i class="fas fa-wrench"></i> Atualizar Site</button> ',
    );

    return $fieldsForCentova;

}

/**
 * Execute actions upon save of an instance of a product/service.
 *
 * Use to perform any required actions upon the submission of the admin area
 * product management form.
 *
 * It can also be used in conjunction with the AdminServicesTabFields function
 * to handle values submitted in any custom fields which is demonstrated here.
 *
 * @param array $params common module parameters
 *
 * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
 * @see urcumodule_AdminServicesTabFields()
 */
function urcumodule_AdminServicesTabFieldsSave(array $params)
{
    try {

    update_query("mod_urcumodule",array(
        "streaming_server"=>$_POST['streaming_server'],
        "streaming_usuario"=>$_POST['streaming_usuario'],
        "streaming_porta"=>$_POST['streaming_porta'],
        "streaming_porta_ssl"=>$_POST['streaming_porta_ssl'],
        "streaming_mountpoint"=>$_POST['streaming_mountpoint'],

    ),array("serviceid"=>$params['serviceid']));

 } catch (Exception $e) {
        // Record the error in WHMCS's module log.
        logModuleCall(
            'urcumodule',
            __FUNCTION__,
            $params,
            $e->getMessage(),
            $e->getTraceAsString()
        );

        return array(
            'success' => false,
            'errorMsg' => $e->getMessage(),
        );
    }
}

 

What im making wrong? 

Thank you 🙂

Edited by Bets
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
On 7/25/2021 at 12:17 AM, Bets said:

Hi,

I have ben started make a module for our company yesterday, 

I don't understand how to make the additional fields work.  😞

I've been reading the documentation and checking the sample files for two days now, but it's not really getting into my head... hahaha 
When clicked "Save" on WHMCS no error returned.
But nothing of the additional fields created got being saved. obviously it doesn't return the saved values either.

 


/**
 * Admin services tab additional fields.
 *
 * Define additional rows and fields to be displayed in the admin area service
 * information and management page within the clients profile.
 *
 * Supports an unlimited number of additional field labels and content of any
 * type to output.
 *
 * @param array $params common module parameters
 *
 * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
 * @see urcumodule_AdminServicesTabFieldsSave()
 *
 * @return array
 */
function urcumodule_AdminServicesTabFields(array $params)
{

    $result = select_query(
        "streaming_server",
        "streaming_usuario",
        "streaming_porta",
        "streaming_porta_ssl",
        "streaming_mountpoint",
        array("serviceid" => $params['serviceid'],)
    );
    $data = mysql_fetch_array($result);

    $streaming_server = $params['customfields']['streaming_server'];
    $streaming_usuario = $params['customfields']['streaming_usuario'];
    $streaming_porta = $params['customfields']['streaming_porta'];
    $streaming_porta_ssl = $params['customfields']['streaming_porta_ssl'];
    $streaming_mountpoint = $params['customfields']['streaming_mountpoint'];

    if (  $streaming_usuario == "" ) {
        $streaming_usuario = $params['username'];
    }

    $fieldsForCentova = array(
        'Servidor Streaming' => '<select name="streaming_server" id="streaming_server" class="form-control select-inline">
        <option '. ( $streaming_server == "") { "selected" } .'>Selecione ...</option>
        <option value="cast.mydomain.com.br" '. ( $streaming_server == "cast.mydomain.com.br") { "selected" } .'>Centovacast - CAST #1</option>
        <option value="cast2.mydomain.com.br" '. ( $streaming_server == "cast2.mydomain.com.br") { "selected" } .'>Centovacast - CAST #2</option>
        <option value="cast3.mydomain.com.br" '. ( $streaming_server == "cast3.mydomain.com.br") { "selected" } .'>Centovacast - CAST #3</option>
        <option value="cast3.mydomain.com.br" '. ( $streaming_server == "cast4.mydomain.com.br") { "selected" } .'>Centovacast - CAST #4</option>
        </select>',
        'Usuario Streaming' => '<input type="text" name="streaming_usuario" id="streaming_usuario" class="form-control input-200" value="'. $streaming_usuario.'">',
        'Porta' => '<input type="text" name="streaming_porta" id="streaming_porta" class="form-control input-200" value="'. $streaming_porta.'">',
        'Porta SSL' => '<input type="text" name="streaming_porta_ssl" id="streaming_porta_ssl" class="form-control input-200" value="'. $streaming_porta_ssl.'">',
        'Mountpoint' => '<input type="text" name="streaming_mountpoint" id="streaming_mountpoint" class="form-control input-200" value="'. $streaming_mountpoint.'">',
        'Streaming Commands' => '
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnStartStream"><i class="fas fa-play"></i> Iniciar Streaming</button> 
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnStopStream"><i class="fas fa-stop"></i> Parar Streaming</button> 
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnRefreshStream"><i class="fas fa-sync-alt"></i> Reiniciar streaming</button>
        <button type="button" class="btn btn-primary" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnProgrametes"><i class="fas fa-music"></i> Instalar Programetes</button> ',
        'SiteAdmin Comands' => '
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnImplantar"><i class="fas fa-sitemap"></i> Implantar</button> 
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnServiceEmail"><i class="fas fa-envelope"></i> Enviar dados de acesso</button>
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnUrlFix"><i class="fas fa-link"></i> Fixar URLs</button> 
        <button type="button" class="btn btn-success" onclick="runModuleCommand("custom","buttonTwoFunction")" id="btnRefreshSiteFiles"><i class="fas fa-wrench"></i> Atualizar Site</button> ',
    );

    return $fieldsForCentova;

}

/**
 * Execute actions upon save of an instance of a product/service.
 *
 * Use to perform any required actions upon the submission of the admin area
 * product management form.
 *
 * It can also be used in conjunction with the AdminServicesTabFields function
 * to handle values submitted in any custom fields which is demonstrated here.
 *
 * @param array $params common module parameters
 *
 * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
 * @see urcumodule_AdminServicesTabFields()
 */
function urcumodule_AdminServicesTabFieldsSave(array $params)
{
    try {

    update_query("mod_urcumodule",array(
        "streaming_server"=>$_POST['streaming_server'],
        "streaming_usuario"=>$_POST['streaming_usuario'],
        "streaming_porta"=>$_POST['streaming_porta'],
        "streaming_porta_ssl"=>$_POST['streaming_porta_ssl'],
        "streaming_mountpoint"=>$_POST['streaming_mountpoint'],

    ),array("serviceid"=>$params['serviceid']));

 } catch (Exception $e) {
        // Record the error in WHMCS's module log.
        logModuleCall(
            'urcumodule',
            __FUNCTION__,
            $params,
            $e->getMessage(),
            $e->getTraceAsString()
        );

        return array(
            'success' => false,
            'errorMsg' => $e->getMessage(),
        );
    }
}

 

What im making wrong? 

Thank you 🙂

Hi @Bets

Please read this document

you can not use select_query  if your WHMCS version 8.+,

you should use Capsule in your query 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated