您好,堆栈我有一个问题不知道如何解决。我想显示客户订单中的专用 IP,如下所示:
我做了一个简短的检查,发现需要完成查看发票.tpl and 发票pdf.tpl文件。我发现专用IP被存储到tbl主机数据库中的表。
我找到了这段代码:
{php}
$clienthosting = $this->get_template_vars(service);
$dbid = $clienthosting['id'];
$query = mysql_query("SELECT dedicatedip FROM tblhosting WHERE id = $dbid");
$result = mysql_fetch_array($query);
$dedicatedip = $result["dedicatedip"];
$this->assign("dedicatedip", $dedicatedip);
{/php}
最后打印:
<td>{if $dedicatedip gt 0} - {$dedicatedip}{/if}{/if}</td>
这是代码发票.tpl客户购买的打印数据在哪里:
<tbody>
{foreach from=$invoiceitems item=item}
<tr>
<td>{$item.description}{if $item.taxed eq "true"} *{/if}</td>
<td class="text-center">{$item.amount}</td>
</tr>
{/foreach}
<tr>
<td class="total-row text-right"><strong>{$LANG.invoicessubtotal}</strong></td>
<td class="total-row text-center">{$subtotal}</td>
</tr>
{if $taxrate}
<tr>
<td class="total-row text-right"><strong>{$taxrate}% {$taxname}</strong></td>
<td class="total-row text-center">{$tax}</td>
</tr>
{/if}
{if $taxrate2}
<tr>
<td class="total-row text-right"><strong>{$taxrate2}% {$taxname2}</strong></td>
<td class="total-row text-center">{$tax2}</td>
</tr>
{/if}
<tr>
<td class="total-row text-right"><strong>{$LANG.invoicescredit}</strong></td>
<td class="total-row text-center">{$credit}</td>
</tr>
<tr>
<td class="total-row text-right"><strong>{$LANG.invoicestotal}</strong></td>
<td class="total-row text-center">{$total}</td>
</tr>
</tbody>
但这似乎仅在尝试执行时才会生成白屏。这里有什么帮助吗?
在中创建 php 文件whmcs_dir/includes/hooks/
(例如:dedicated_ip.php)并添加以下代码:
<?php
use WHMCS\Database\Capsule as DB;
add_hook('ClientAreaPageViewInvoice', 1, function($vars) {
$dedicatedIps = [];
foreach ($vars['invoiceitems'] as $k => $item) {
$ip = '';
if ($item['type'] == 'Hosting') {
$hosting = DB::table('tblhosting')->select('dedicatedip')->where('id', $item['relid'])->first();
if (!is_null($hosting)) {
$ip = $hosting->dedicatedip;
}
}
$dedicatedIps[$k] = $ip;
}
return ['dedicatedIps' => $dedicatedIps];
});
此代码将仅在发票查看页面中运行,并为每个发票项目添加一组专用 IP。例如,域名的 IP 为空。
然后在 viewinvoice.tpl 中更新发票项目循环,如下所示:
{foreach from=$invoiceitems item=item key=key}
<tr>
<td>
{$item.description}{if $item.taxed eq "true"} *{/if}
{if $key|in_array:$dedicatedIps}
<br>IP: {$dedicatedIps[$key]}
{/if}
</td>
<td class="text-center">{$item.amount}</td>
</tr>
{/foreach}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)