Michael Posted September 27, 2016 Report Share Posted September 27, 2016 @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 Paul 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Author Report Share Posted September 27, 2016 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); } } Paul 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Author Report Share Posted September 27, 2016 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"}); } '); ?> Paul 1 Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 27, 2016 Report Share Posted September 27, 2016 Just to note the model is no longer used as we use the support manager model . Is safe to delete the model directory . Paul and Michael 2 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Author Report Share Posted September 27, 2016 6 minutes ago, naja7host said: Just to note the model is no longer used as we use the support manager model . Is safe to delete the model directory . Magic haha Just to let people know donated to you mate for your help and time Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 27, 2016 Report Share Posted September 27, 2016 Thanks mate .... You got the small plugin ever created for blesta , just 2 files !!!! Michael and Joseph H 2 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Author Report Share Posted September 27, 2016 27 minutes ago, naja7host said: Thanks mate .... You got the small plugin ever created for blesta , just 2 files !!!! Lol mate I still can't even edit that to grab services and there's not much to edit lol. Need more time I think Joseph H 1 Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 27, 2016 Report Share Posted September 27, 2016 Maybe we will make a plugin that return some usefull info for the client like Tickets open closed Services active suspend Invoices closed open Pending orders Michael 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Author Report Share Posted September 27, 2016 14 minutes ago, naja7host said: Maybe we will make a plugin that return some usefull info for the client like Tickets open closed Services active suspend Invoices closed open Pending orders That would be awesome mate so you can expand by seeing how you did what for each one and then hopefully more can expand as needed? Quote Link to comment Share on other sites More sharing options...
Blesta Addons Posted September 27, 2016 Report Share Posted September 27, 2016 7 hours ago, Licensecart said: That would be awesome mate so you can expand by seeing how you did what for each one and then hopefully more can expand as needed? Ok i will do it . Michael 1 Quote Link to comment Share on other sites More sharing options...
Michael Posted September 27, 2016 Author Report Share Posted September 27, 2016 5 minutes ago, naja7host said: Ok i will do it . Yey merci mate Quote Link to comment Share on other sites More sharing options...
turner2f Posted November 28, 2016 Report Share Posted November 28, 2016 @Licensecart and @Blesta Addons I uploaded the files for "Count tickets" to /plugins/count_tickets And then went to /admin/settings/company/plugins/available/ I did not see anything. I even deleted the "model" directory folder. ========== Why am I not able to see the plugin to activate it ? OR... Is it automatically activated when uploaded ? Quote Link to comment Share on other sites More sharing options...
Michael Posted November 28, 2016 Author Report Share Posted November 28, 2016 7 hours ago, turner2f said: @Licensecart and @Blesta Addons I uploaded the files for "Count tickets" to /plugins/count_tickets And then went to /admin/settings/company/plugins/available/ I did not see anything. I even deleted the "model" directory folder. ========== Why am I not able to see the plugin to activate it ? OR... Is it automatically activated when uploaded ? Ignore this thread go to the contribute thread with the proper script / plugin by Naja7Host. 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.