Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/28/2016 in all areas

  1. Hello All . @Licensecart has request me to do a simple plugin to fetch client data and include it in your Html Template. The Plugin Is Available in Github https://github.com/Blesta-Addons/Client_Data Blesta Plugin That Allow Dev/Themers Get Client Data Info As Json Response , then they can use it in their Template or Plugin . This Plugin didn't need install, just upload the folder client_data to plugins and you are ready to go . Not all request should be Done Via Ajax , a direct call will return a blank page . Example of Requests : 1 - For Tickets, the last element is the Tickets status Get CLient's Open Tickets http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_tickets/open Get CLient's Closed Tickets http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_tickets/closed 2 - For Services, the last element is the Service status Get CLient's Active Services http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_services/active Get CLient's Suspended Services http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_services/suspended 3 - For Invoices, the last element is the Invoices status Get CLient's Open Invoices http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_invoices/open Get CLient's Vioded Invoices http://your_domain.com/blesta_dir/plugin/client_data/client_main/count_invoices/vioded To get the info by Ajax request in template us this code <?php $this->Javascript->setInline(' $(document).ready(function() { fetchInvoices("open"); }); function fetchInvoices(status) { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/client_data/client_main/count_invoices/") . '" + status, null, function(data) { if (data) $("#my_div_id_to_replace").html(data); }, null, {dataType:"json"}); } '); ?> To explain the code , you need to change the url and the div to put the requested data .
    1 point
  2. @Naja7Host helped show me how to get this working and this is what he did to achieve it: Folder structure: - plugins --- count_tickets --------- count_tickets_controller.php ------- controllers ----------- client_main.php ------- models ----------- client_tickets_model.php ----------- count_tickets_model.php If you just want to download the files and not do it manually you can grab them from: https://licensecart.com/public/count_tickets.zip
    1 point
  3. If you're asking me, yes. I've been using this since 3.0 came out.
    1 point
  4. I have fixed the Ajax request, re-download the plugin now .
    1 point
  5. ahhh, errors in link, client_main instead main .
    1 point
  6. calling any plugin url that not exist return a error , something like http://xxxxxx.com/blesta/plugins/dsdsd Fatal error: Call to undefined method Plugins::preAction() in /home/xxxxxx/public_html/blesta/vendors/minphp/bridge/src/Lib/Dispatcher.php on line 134 Undefined variable: e
    1 point
  7. Just to note the model is no longer used as we use the support manager model . Is safe to delete the model directory .
    1 point
  8. Next on the /app/views/client/bootstrap/structure.pdt add this: <div id="count_ticket">0</div> <?php $this->Javascript->setInline(' $(document).ready(function() { fetchCountTickets(); }); function fetchCountTickets() { $(this).blestaRequest("GET", "' . $this->Html->safe($this->base_uri . "plugin/count_tickets/client_main") . '", null, function(data) { if (data) $("#count_ticket").html(data); }, null, {dataType:"json"}); } '); ?>
    1 point
  9. Next make the files: /plugins/count_tickets/count_tickets_controller.php <?php /** * News plugin handler */ class CountTicketsController extends AppController { public function preAction() { $this->structure->setDefaultView(APPDIR); parent::preAction(); // Override default view directory $this->view->view = "default"; $this->orig_structure_view = $this->structure->view; $this->structure->view = "default"; } } /plugins/count_tickets/controllers/client_main.php <?php /** */ class CLientMain extends CountTicketsController { /** * Pre-action save and upload */ public function preAction() { parent::preAction(); $this->uses(["SupportManager.SupportManagerTickets"]); $this->client_id = $this->Session->read("blesta_client_id"); } /** * Portal Newe index */ public function index() { if ($this->isAjax()) { $response = $this->SupportManagerTickets->getStatusCount("open", null, $this->client_id); // JSON encode the AJAX response $this->outputAsJson($response); return false; } return false; } } /plugins/count_tickets/models/client_tickets_model.php <?php class CountTicketsModel extends AppModel { /** * Constructor */ public function __construct() { parent::__construct(); // You Can Load Language here } /** * Retrieves ticket count * * @return string */ public function getCountTickets( $client_ticket_id, $status_opened ) { $ticket_numbers = $this->Record->select()-> from("support_tickets")-> where('client_id', "=", $client_ticket_id)-> where('status', "=", $status_opened)-> fetch(); return count($ticket_numbers); } } /plugins/count_tickets/models/count_tickets_model.php <?php class CountTicketsModel extends AppModel { /** * Constructor */ public function __construct() { parent::__construct(); // You Can Load Language here } /** * Retrieves ticket count * * @return string */ public function getCountTickets( $client_ticket_id, $status_opened ) { $ticket_numbers = $this->Record->select()-> from("support_tickets")-> where('client_id', "=", $client_ticket_id)-> where('status', "=", $status_opened)-> fetch(); return count($ticket_numbers); } }
    1 point
  10. Yes. If plugins could register management options to various/multiple modules a plugin may be the best option. This is functionality I want to add. The issue for me is that the best placement of the feature is within managing a service, right now that puts the module in control over it.. so it'd ideally be implemented for each module.
    1 point
  11. Michael

    Is this possible?

    yeah mate so we can show the tickets open on the structure page like client overview and maybe if we can get that sorted maybe be able to pull other content from the database like "How many active services" a client has active etc :).
    1 point
  12. Paul

    Migration Script Whmcs 6.2

    I've met Matt Pugh several times and he's always been nice to me in person. We are competitors, but there's no reason we can't get along. @zmjwong give the import a try, if you run into any trouble let us know.
    1 point
×
×
  • Create New...