Jump to content

Recommended Posts

Posted

Is there a way to grab things from the database for use on the structure using something like:

$client_ticket_id = $client->id;
$status_opened =  "open";
$ticket_numbers = $this->Record->select()->from("support_tickets")->where('client_id', $client_ticket_id)->where('status', $status_opened)->fetch();
$ticket_open = count($ticket_numbers);

 

Posted
25 minutes ago, naja7host said:

The simple way is to create a simple plugin that fetch the request and show the result as json, then in your template just add a blestarequest ajax to fetch the data and show it in DIV . something like the balance credit of client in his profile .

 

Merci mate :)

Posted
5 minutes ago, naja7host said:

If you want help in coding it i'm ready ....

I would need to learn how to do a basic plugin :P but if it's simple and you're up for it it would help the community and maybe expand what can be done and I'll donate a bit towards it mate.

Posted

What are you trying to do exactly Mike? Show like ticket stats on the portal or someplace for public view?

I'd like to update the ticket system to show stats in the admin UI, and also have an optional javascript feed to embed on your website.

Posted
13 minutes ago, Paul said:

What are you trying to do exactly Mike? Show like ticket stats on the portal or someplace for public view?

I'd like to update the ticket system to show stats in the admin UI, and also have an optional javascript feed to embed on your website.

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 :).

Posted

@Licensecart relax, take a pen and paper . cup of coffee ... i will teach you in 5 min !!!!!.

create the fallowing directory files structure .

count_tickets
Lــــــــــ count_tickets_controller.php
Lــــــــــ count_tickets_model.php
Lــــــــــ controllers
      Lــــــــــ main.php
Lــــــــــ models
      Lــــــــــ count_tickets.php

next step is the content of each file .

 

Posted
11 minutes ago, naja7host said:

@Licensecart relax, take a pen and paper . cup of coffee ... i will teach you in 5 min !!!!!.

create the fallowing directory files structure .


count_tickets
Lــــــــــ count_tickets_controller.php
Lــــــــــ count_tickets_model.php
Lــــــــــ controllers
      Lــــــــــ main.php
Lــــــــــ models
      Lــــــــــ count_tickets.php

next step is the content of each file .

 

Done merci mate :)

Posted

count_tickets_controller.php

<?php
class MyTestController 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";
	}	
}

count_tickets_model.php

<?php
class CountTicketsModel extends AppModel 
{
}

Next is coming

Posted

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);
    }
 } 

 

Posted

controllers/main.php

<?php
/**
 */
class Main extends CountTicketsController 
{
	
	/**
	 * Pre-action
	 */
	public function preAction() 
	{
		parent::preAction();
		
		$this->uses(["CountTickets.CountTicketsModel"));
		$this->client_id = $this->Session->read("blesta_client_id");
	}
	
	/**
	 * Portal Newe index
	 */
	public function index() 
	{
		if ($this->isAjax()) {
			$response = $this->CountTicketsModel
				->getCountTickets($this->client_id, "open");
			
			// JSON encode the AJAX response
			$this->outputAsJson($response);
			return false;		
		}
		
		return false;
	}
}

 

Posted

now the template side, add a jquery request to fetch the numbers and add the response to a div class that has the id count_ticket .

<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/main") . '", null, function(data) {
					if (data)
						$("#count_ticket").html(data);
				},
				null,
				{dataType:"json"});
			}
		');
		?>

 

Posted
13 minutes ago, Licensecart said:

Lol mate trust me to duck up as you told me what to do, got a white page. Do you have Skype mate?

error reporting is enabled ? i suspect it the model name maybe . can you PM the url ?

 

Posted

Uff how stupid 'im , is normal to see a blank page , because it will show response only in ajax request ; in controller main change this

if ($this->isAjax()) {

by

if (!$this->isAjax()) {

and revert back when you call it from Jquery request .

 

Posted
6 minutes ago, naja7host said:

Uff how stupid 'im , is normal to see a blank page , because it will show response only in ajax request ; in controller main change this


if ($this->isAjax()) {

by


if (!$this->isAjax()) {

and revert back when you call it from Jquery request .

 

Still the same mate: https://licensecart.com/plugin/count_tickets/main Maybe I'm being stupid too lol.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...