gsouza Posted August 21, 2018 Share Posted August 21, 2018 Olá Pessoal, boa noite. Queria tirar uma dúvida. Encontrei este tópico Me ajudou muito, porem eu queria inserir em mais um local e não consegui =/ Podem me ajudar ? Quero inserir esta Hook que o amigo criou tanto na área inicial, quanto na aba minhas faturas. E gostaria de dois pequenos ajustes. O primeiro é que se o credito for maior que zero , mude a frase e informe por exemplo: Você não possui créditos em sua conta. clique no botão abaixo e adicione um saldo em sua conta!. Algo do tipo. O segundo é inserir um botão verde para (Adicionar fundos) no fim da guia. E se possivel deixar o valor atual na área toda assim como este http://prntscr.com/kl0icc Meu código esta assim atualmente. Agradeço a ajuda. <?php use WHMCS\Session; use WHMCS\Database\Capsule; use WHMCS\View\Menu\Item as MenuItem; if (!defined("WHMCS")){ die("Acesso restrito!"); } add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { $idusuario = $_SESSION["uid"]; foreach (Capsule::table('tblclients')->where([['id','=',$idusuario],])->get() as $clientes) { $credito = $clientes->credit; } if ($clientes->credit > 0){ if (!is_null($primarySidebar->getChild('Client Details'))) { $saldoConta = $primarySidebar->addChild('Saldo da Conta'); $saldoConta = $primarySidebar->addChild('Saldo da Conta', array( 'icon' => 'fal fa-donate', 'order' => 1, ) ); // Add hours to the panel. $saldoConta->addChild('Saldo da Conta') ->setLabel('<p style="float: left; padding: 3px 0px 0px; margin-top: 6px;"><strong> Saldo disponível:</strong></p> <strong style="margin-top: 6px; background-color: #5bc0de; padding: 4px 10px; color: #FFF; float: right; border-radius: 5px;">R$ '.$credito.'</strong>') ->setClass('panel-body clearfix') ->setOrder(101); } } }); Resultado atual http://prntscr.com/kl0hy5 o que desejo http://prntscr.com/kl0i2h 0 Quote Link to comment Share on other sites More sharing options...
AJ Meireles Posted August 21, 2018 Share Posted August 21, 2018 Olá, Há uma outra forma de obter o saldo do cliente afim de evitar o uso da consulta: GLOBAL $smarty; $VariavelQualquer = $smarty->getVariable('clientsstats')->value['creditbalance']; 0 Quote Link to comment Share on other sites More sharing options...
gsouza Posted August 21, 2018 Author Share Posted August 21, 2018 9 horas atrás, AJ Meireles disse: Olá, Há uma outra forma de obter o saldo do cliente afim de evitar o uso da consulta: GLOBAL $smarty; $VariavelQualquer = $smarty->getVariable('clientsstats')->value['creditbalance']; @AJ Meireles bom dia. Agradeço a informação, vou utilizar neste hook 0 Quote Link to comment Share on other sites More sharing options...
jerenc Posted August 25, 2018 Share Posted August 25, 2018 Segue o Hook que usamos aqui. o que ele faz: - Mostra na página inicial e páginas de faturamento - Caso o cliente não possua crédito o mesmo é ocultado Espero ter ajudado! <?php /** * Display Client's Credit Balance in Client Area * * @author WHMCMS * @link www.whmcms.com * @since WHMCS v6.0.0+ */ use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # Add Balance To Sidebar add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $primarySidebar){ $filename = APP::getCurrentFileName(); $client = Menu::context("client"); $clientid = (int) $client->id; $action = $_GET['action']; $allowed = array('invoices', 'quotes', 'masspay', 'addfunds',''); if ($filename!=='clientarea' || $clientid===0 || !in_array($action,$allowed)){ return; } if ($client->credit <= 0.00) { return; } $primarySidebar->addChild('Client-Balance', array( 'label' => "Crédito disponível", 'uri' => '#', 'order' => '1', 'icon' => 'fa-money' )); # Get Currency $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get(); # Retrieve the panel we just created. $balancePanel = $primarySidebar->getChild('Client-Balance'); // Move the panel to the end of the sorting order so it's always displayed // as the last panel in the sidebar. $balancePanel->moveToBack(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( 'uri' => 'clientarea.php?action=addfunds', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); $balancePanel->setFooterHtml( '<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block"> <i class="fa fa-plus"></i> Adicionar fundos </a>' ); }); 3 minutos atrás, jerenc disse: Segue o Hook que usamos aqui. o que ele faz: - Mostra na página inicial e páginas de faturamento - Caso o cliente não possua crédito o mesmo é ocultado Espero ter ajudado! <?php /** * Display Client's Credit Balance in Client Area * * @author WHMCMS * @link www.whmcms.com * @since WHMCS v6.0.0+ */ use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # Add Balance To Sidebar add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $primarySidebar){ $filename = APP::getCurrentFileName(); $client = Menu::context("client"); $clientid = (int) $client->id; $action = $_GET['action']; $allowed = array('invoices', 'quotes', 'masspay', 'addfunds',''); if ($filename!=='clientarea' || $clientid===0 || !in_array($action,$allowed)){ return; } if ($client->credit <= 0.00) { return; } $primarySidebar->addChild('Client-Balance', array( 'label' => "Crédito disponível", 'uri' => '#', 'order' => '1', 'icon' => 'fa-money' )); # Get Currency $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get(); # Retrieve the panel we just created. $balancePanel = $primarySidebar->getChild('Client-Balance'); // Move the panel to the end of the sorting order so it's always displayed // as the last panel in the sidebar. $balancePanel->moveToBack(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( 'uri' => 'clientarea.php?action=addfunds', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); $balancePanel->setFooterHtml( '<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block"> <i class="fa fa-plus"></i> Adicionar fundos </a>' ); }); Resultado do hook compartilhado acima. 1 Quote Link to comment Share on other sites More sharing options...
gsouza Posted August 27, 2018 Author Share Posted August 27, 2018 Em 24/08/2018 em 10:06 PM, jerenc disse: Segue o Hook que usamos aqui. o que ele faz: - Mostra na página inicial e páginas de faturamento - Caso o cliente não possua crédito o mesmo é ocultado Espero ter ajudado! <?php /** * Display Client's Credit Balance in Client Area * * @author WHMCMS * @link www.whmcms.com * @since WHMCS v6.0.0+ */ use WHMCS\View\Menu\Item as MenuItem; use Illuminate\Database\Capsule\Manager as Capsule; # Add Balance To Sidebar add_hook('ClientAreaSecondarySidebar', 1, function(MenuItem $primarySidebar){ $filename = APP::getCurrentFileName(); $client = Menu::context("client"); $clientid = (int) $client->id; $action = $_GET['action']; $allowed = array('invoices', 'quotes', 'masspay', 'addfunds',''); if ($filename!=='clientarea' || $clientid===0 || !in_array($action,$allowed)){ return; } if ($client->credit <= 0.00) { return; } $primarySidebar->addChild('Client-Balance', array( 'label' => "Crédito disponível", 'uri' => '#', 'order' => '1', 'icon' => 'fa-money' )); # Get Currency $getCurrency = Capsule::table('tblcurrencies')->where('id', $client->currency)->get(); # Retrieve the panel we just created. $balancePanel = $primarySidebar->getChild('Client-Balance'); // Move the panel to the end of the sorting order so it's always displayed // as the last panel in the sidebar. $balancePanel->moveToBack(); $balancePanel->setOrder(0); # Add Balance. $balancePanel->addChild('balance-amount', array( 'uri' => 'clientarea.php?action=addfunds', 'label' => '<h4 style="text-align:center;">'.$getCurrency['0']->prefix.$client->credit.' '. $getCurrency['0']->suffix.'</h4>', 'order' => 1 )); $balancePanel->setFooterHtml( '<a href="clientarea.php?action=addfunds" class="btn btn-success btn-sm btn-block"> <i class="fa fa-plus"></i> Adicionar fundos </a>' ); }); Resultado do hook compartilhado acima. Opa como vai mestre. Funcionou sim. Estou tentando ajustar para que não seja necessário efetuar consultas em banco Consegui isso até agora <?php use WHMCS\Session; use WHMCS\View\Menu\Item as MenuItem; if (!defined("WHMCS")){ die("Acesso restrito!"); } add_hook('ClientAreaPrimarySidebar', 1, function (MenuItem $primarySidebar) { GLOBAL $smarty; $saldo = $smarty->getVariable('clientsstats')->value['creditbalance']; $tesald = preg_replace('/[^\d.]/i', '', $saldo); if ($tesald > 0){ if (!is_null($primarySidebar->getChild('Client Details'))) { $saldoConta = $primarySidebar->addChild('Saldo da Conta'); $saldoConta = $primarySidebar->addChild('Saldo da Conta', array( 'icon' => 'fal fa-donate', 'order' => 1, ) ); // Add hours to the panel. $saldoConta->addChild('Saldo da Conta') ->setLabel('<p style="float: left; padding: 3px 0px 0px; margin-top: 6px;"><strong> Saldo disponível:</strong></p> <strong style="margin-top: 6px; background-color: #5bc0de; padding: 4px 10px; color: #FFF; float: right; border-radius: 5px;">'.$saldo.'</strong>') ->setClass('panel-body clearfix') ->setOrder(101); } } }); Este foi o resultado. Me agradou bastante, porem ainda preciso ajustar o botão de add fundos e que exiba nas abas que o seu esta exibindo. invoices', 'quotes', 'masspay', 'addfunds Alguma dica ? Estou querendo manter a utilização da função Smarty 0 Quote Link to comment Share on other sites More sharing options...
Divin0 Silva Posted October 24, 2018 Share Posted October 24, 2018 show deu certo 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.