Michael Posted September 27, 2016 Report 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
Michael Posted September 27, 2016 Author Report 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
Michael Posted September 27, 2016 Author Report 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
Blesta Addons Posted September 27, 2016 Report 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 . Michael and Paul 2
Michael Posted September 27, 2016 Author Report Posted September 27, 2016 On 9/27/2016 at 12:49 AM, 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 . Expand Magic haha Just to let people know donated to you mate for your help and time
Blesta Addons Posted September 27, 2016 Report Posted September 27, 2016 Thanks mate .... You got the small plugin ever created for blesta , just 2 files !!!! Joseph H and Michael 2
Michael Posted September 27, 2016 Author Report Posted September 27, 2016 On 9/27/2016 at 12:55 AM, naja7host said: Thanks mate .... You got the small plugin ever created for blesta , just 2 files !!!! Expand 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
Blesta Addons Posted September 27, 2016 Report 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
Michael Posted September 27, 2016 Author Report Posted September 27, 2016 On 9/27/2016 at 1:57 PM, 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 Expand 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?
Blesta Addons Posted September 27, 2016 Report Posted September 27, 2016 On 9/27/2016 at 2:07 PM, 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? Expand Ok i will do it . Michael 1
Michael Posted September 27, 2016 Author Report Posted September 27, 2016 On 9/27/2016 at 9:13 PM, naja7host said: Ok i will do it . Expand Yey merci mate
turner2f Posted November 28, 2016 Report 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 ?
Michael Posted November 28, 2016 Author Report Posted November 28, 2016 On 11/28/2016 at 3:52 AM, 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 ? Expand Ignore this thread go to the contribute thread with the proper script / plugin by Naja7Host.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now