Jump to content

Widget doesn't show language and values


monstertocode

Recommended Posts

Hi so have this problem with the widget that it doesn't show the language that i have set for it nor the values in the tags.

Can someone help me with this?

Thanks.

 

Code:

Hook:

<?php
add_hook('AdminHomeWidgets', 1, function() {
    $clientfiles = new ClientFiles();
    $datas = array(
        'lang'=> $_SESSION["Language"],
    );
    $clientfiles->setData($datas);
    return $clientfiles;
});

 

Class ClientFiles:

<?php 

use WHMCS\Database\Capsule;
use WHMCS\Module\AbstractWidget;

class ClientFiles extends AbstractWidget
{
    protected $title = 'Client Files';
    protected $description = '';
    protected $weight = 100;
    protected $columns = 1;
    protected $cache = false;
    protected $cacheExpiry = 120;
    protected $requiredPermission = '';
    protected $lang = '';
    
    public function setData($data)
    {
        $this->lang = $data["lang"];
    }
    
    public function getData()
    {
        return array(
            'lang' => $this->lang,
        );
    }

    public function generateOutput($data)
    {
        include( $_SERVER[DOCUMENT_ROOT] . '/whmcs/modules/addons/client_document/lang/english.php' );
        include($_SERVER[DOCUMENT_ROOT] . "/whmcs/modules/addons/client_document/templates/adminarea2.tpl");
    }
}

 

html:

        <style>
            ul{list-style-type: none;}
        </style>
        <div class="widget-content-padded">
            <table class="clientssummarystats" cellspacing="0" cellpadding="2">
                {foreach ($files as $file)}
                    <!--tr class="{cycle value=",altrow"}">
                    <tr-->
                    <tr>
                        <td align="center">
                            <a href="../dl.php?type=f&id={$file[id]}">
                                <i class="fa fa-file-o"></i>&nbsp;
                                {$file[title]}
                            </a>
                            {if($file[adminonly])}
                                $_ADDONLANG[clientsummary][fileadminonly];
                            {/if}
                            <img src="images/icons/delete.png" align="absmiddle" border="0" onClick="deleteFile({$file[id]})"/>
                        </td>
                    </tr>
                {foreachelse}
                    <tr><td align="center">{$_ADDONLANG[clientsummary][nofiles]}</td></tr>
                {/foreach}
            </table>
            <ul>
                <li><a href="#" id="addfile2"><img src="images/icons/add.png" border="0" align="absmiddle"/> {$_ADDONLANG[clientsummary][fileadd]}</a></li>
            </ul>
            <div id="addfileform2" style="display:none;" class="top-margin-5">
                <form method="post" action="clientssummary.php?userid={$clientsdetails[userid]}&action=uploadfile" enctype="multipart/form-data">
                    <table class="clientssummarystats" cellspacing="0" cellpadding="2">
                        <tr><td width="40">{$_ADDONLANG[clientsummary][filetitle]}</td><td class="fieldarea"><input type="text" name="title" style="width:90%" /></td></tr>
                        <tr><td>{$_ADDONLANG[clientsummary][filename]}</td><td class="fieldarea"><input type="file" name="uploadfile" style="width:90%" /></td></tr>
                        <tr>
                            <td width="40">
                                <!--Type-->
                                {$_ADDONLANG[clientsummary][type]}
                            </td>
                            <td class="fieldarea">
                                <select type="text" name="typeid" style="width:90%">
                                    <option disabled selected>{$_ADDONLANG['clientsummary']['option']['default']}</option>
                                        {foreach ($filetypes as $type)}
                                            <option value="{$type->id}">{$type->typename}</option>
                                        {/foreach}
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                            </td>
                            <td class="fieldarea"><input type="checkbox" name="adminonly" value="1" />
                                {$_ADDONLANG[clientsummary][fileadminonly]}
                                &nbsp;&nbsp;&nbsp;&nbsp; 
                                <input type="submit" value="{$_ADDONLANG['global'][submit]}" />
                            </td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <script>
            $("#addfile2").click(function () {
                $("#addfileform2").slideToggle();
                return false;
            });
        </script>

 

Untitled15.png

Link to comment
Share on other sites

the most obvious thought being - why 4 files? you got a hook, calling another hook, calling a language file and a template ???

  1. unless i'm missing something, you only need one file - just the widget hook.
  2. forget about the custom language file... just add global $_ADMINLANG to the widget, that gives you access to the current admin language file (and you won't have to mess with declaring a language)... if you need strings that aren't already defined, use admin Language Overrides... and reference the language strings as below in your code...
    AdminLang::trans('clientsummary.fileadminonly')

     

  3. forget about using Smarty in a template - just do the output in PHP in the original hook.

btw - what's the purpose of the widget?? you can already upload files via the client's profile summary page, so it seems a little redundant to reinvent the wheel if that's all this widget does. :?:

https://docs.whmcs.com/Clients:Summary_Tab#Files

Link to comment
Share on other sites

Hi brian thank for the quick reply, i know that there's already the file section in in the adminclientsummarypage but i can't alter it mostly because of my bosses they don't want me to alter the original files of WHMCS.

They wanted me to add the file type so the client would know what they have and search for it by type and because of that i had to change a table and add one to the database and the file section doesn't interact with that so that's why i'm making it.

Link to comment
Share on other sites

5 hours ago, monstertocode said:

i know that there's already the file section in in the adminclientsummarypage but i can't alter it mostly because of my bosses they don't want me to alter the original files of WHMCS.

it's one of the few admin area pages that uses it's own Smarty template too... so easy to edit... i'd just keep a copy of it and edit away - but bosses will be bosses!

5 hours ago, monstertocode said:

They wanted me to add the file type so the client would know what they have and search for it by type and because of that i had to change a table and add one to the database and the file section doesn't interact with that so that's why i'm making it.

ok fair enough... though I might have been tempted to determine filetype from the file extension in the client area and then use that to show what the filetype is.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • 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