Guten Tag,
hier einmal clientareproducts.tpl
<link href="templates/{$template}/css/bootstrap-editable.css" rel="stylesheet"/>
<script src="templates/{$template}/js/bootstrap-editable.js"></script>
<script>
$.fn.editable.defaults.mode = 'inline';
$(document).ready(function() {
$('.change_comment').editable({
params: function(params) {
params.token = $(this).attr('data-token');
params.cid = $(this).attr('data-cid');
return params;
}
});
});
</script>
{include file="$template/includes/tablelist.tpl" tableName="ServicesList" filterColumn="3"}
<script type="text/javascript">
jQuery(document).ready( function ()
{
var table = jQuery('#tableServicesList').removeClass('hidden').DataTable();
{if $orderby == 'product'}
table.order([0, '{$sort}'], [3, 'asc']);
{elseif $orderby == 'amount' || $orderby == 'billingcycle'}
table.order(1, '{$sort}');
{elseif $orderby == 'nextduedate'}
table.order(2, '{$sort}');
{elseif $orderby == 'domainstatus'}
table.order(3, '{$sort}');
{/if}
table.draw();
jQuery('#tableLoading').addClass('hidden');
});
</script>
<div class="table-container clearfix">
<table id="tableServicesList" class="table table-list hidden">
<thead>
<tr>
<th>{$LANG.orderproduct}</th>
<th>{$LANG.custom_description}</th>
<th>{$LANG.clientareaaddonpricing}</th>
<th>{$LANG.clientareahostingnextduedate}</th>
<th>{$LANG.clientareastatus}</th>
<th class="responsive-edit-button" style="display: none;"></th>
</tr>
</thead>
<tbody>
{foreach key=num item=service from=$services_new}
{if $service.status|strtolower != 'terminated' && $service.status|strtolower != 'cancelled'}
<tr>
<td><strong>{$service.product}</strong>{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
<td><a class="change_comment" id=update_comment data-type="text" data-pk={$service.id} data-cid={$clientsdetails.userid} data-token={$service.token} data-url="update_comment.php" data-name="update_comment">{$service.comment}</a></td>
<td class="text-center" data-order="{$service.amountnum}">{$service.amount}<br />{$service.billingcycle}</td>
<td class="text-center"><span class="hidden">{$service.normalisedNextDueDate}</span>{$service.nextduedate}</td>
<td class="text-center"><span class="label status status-{$service.status|strtolower}">{$service.statustext}</span></td>
<td class="responsive-edit-button" style="display: none;">
<a href="clientarea.php?action=productdetails&id={$service.id}" class="btn btn-block btn-info">
{$LANG.manageproduct}
</a>
</td>
</tr>
{/if}
{/foreach}
</tbody>
</table>
<div class="text-center" id="tableLoading">
<p><i class="fa fa-spinner fa-spin"></i> {$LANG.loading}</p>
</div>
</div>
Alles anzeigen
product_comment.php (hook)
<?php
use Illuminate\Database\Capsule\Manager as Capsule;
##### Create a new Smarty var which contains all Data of $services and additional vars for the commentfunction
function comment_add_to_var($templateVariables){
global $smarty;
if (strpos($_SERVER['SCRIPT_NAME'], 'clientarea.php') == true){
$i=0;
$lang = $smarty->get_template_vars('LANG');
$comment_var = array();
foreach ($templateVariables as $name => $variable) {
$elements = count($variable);
$elements = $elements-1;
for ($i = 0; $i <= $elements; $i++) {
$product_comment = '';
$product_token = '';
if($name == 'services'){
$check_entry = Capsule::table('mod_product_comment')->where('PID',$variable[$i]['id'])->where('KID',$templateVariables['clientsdetails']['id'])->count();
if($check_entry != '0'){
$get_comment = Capsule::table('mod_product_comment')->where('PID',$variable[$i]['id'])->where('KID',$templateVariables['clientsdetails']['id'])->first();
$product_token = md5($variable[$i]['id'].".".$templateVariables['clientsdetails']['id']. "." .$get_comment->ID); //create a token
if($get_comment->Comment == ''){
$product_comment = $lang['custom_description_na'];
}else{
$product_comment = $get_comment->Comment;
}
}else{
$product_comment = $lang['custom_description_na'];
$product_token = $product_token = md5($variable[$i]['id'].".".$templateVariables['clientsdetails']['id']. "."."0"); //create a token
}
$variable[$i]['comment'] = $product_comment;
$variable[$i]['token'] = $product_token;
$comment_var = $variable;
}
}
}
$description = $smarty->assign(array('services_new' => $comment_var));
}
}
##### Delete database entry if the product has been deleted.
function comment_delete_product($vars){
Capsule::table('mod_product_comment')->where('PID',$vars['pid'])->delete();
}
##### Delete database entries if the customer has been deleted.
function comment_delete_client($vars){
Capsule::table('mod_product_comment')->where('KID',$vars['userid'])->delete();
}
add_hook("ClientAreaPage",1,"comment_add_to_var");
add_hook("ProductDelete",1,"comment_delete_product");
add_hook("ClientDelete",1,"comment_delete_client");
Alles anzeigen
update_comment.php
<?php
require_once("init.php");
use Illuminate\Database\Capsule\Manager as Capsule;
$ref = $_SERVER['HTTP_REFERER'];
$refData = parse_url($ref);
if($refData['host'] == 'fee-hosting.com'){ //only allow post requests from the URL "client.domain.com"
if($_POST['name'] == 'update_comment'){
if($_POST['token'] != '' && $_POST['cid'] != '' && $_POST['pk'] != ''){
$check_entry = Capsule::table('tblhosting')->where('id',$_POST['pk'])->where('userid',$_POST['cid'])->count(); //check if submitted PID and KID match Database
if($check_entry == '1'){
$check_exist_entry = Capsule::table('mod_product_comment')->where('PID',$_POST['pk'])->where('KID',$_POST['cid'])->count();
if($check_exist_entry == '0'){
$product_token = md5($_POST['pk'].".".$_POST['cid']. "."."0"); //create a token
if($product_token == $_POST['token']){ //Check if the submitted token matches the token from the submitted KID and PID.
try {
$insertEntry = Capsule::table('mod_product_comment')
->insert(['ID' => NULL,'KID' => $_POST['cid'],'PID' => $_POST['pk'],'Comment'=> $_POST['value']]);
}catch (\Exception $e) {
logModuleCall('comment', 'error', $e);
}
}
}else{
$get_id = Capsule::table('mod_product_comment')->where('PID',$_POST['pk'])->where('KID',$_POST['cid'])->first();
$product_token = md5($_POST['pk'].".".$_POST['cid']. "." .$get_id->ID); //create a token
if($product_token == $_POST['token']){ //Check if the submitted token matches the token from the submitted KID and PID.
try {
$updatedentry = Capsule::table('mod_product_comment')
->where('PID', $_POST['pk'])
->where('KID', $_POST['cid'])
->update(['Comment' => $_POST['value']]);
}catch (\Exception $e) {
logModuleCall('comment', 'error', $e);
}
}
}
}
}
}
}
Alles anzeigen