Jump to content

Hook DashboardData never executed


Recommended Posts

Hi everyone,

 

Please excuse me in advance if I made some mistakes, I'm french :) .

 

I'm currently developping my first dashboard module taking the dashproducts module for exemple. My problem is that in my .tpl file, the thead and tbody tags are always empty.

 

Here is a part of my code :

 

 

my_module.php

<?php

public function hookDashboardData($params)
    {

      $table_best_sale = $this->getBestandBadsale($params['date_from'], $params['date_to']);

      print_r($table_best_sale);
      die();

      return array(
        'data_table' => array(
          'table_best_sale' => $table_best_sale,
        )
      );
    }

  	public function hookDashboardZoneTwo($params)
  	{
  		$this->context->smarty->assign(
        array(
        	'date_from' => Tools::displayDate($params['date_from']),
        	'date_to' => Tools::displayDate($params['date_to']),
        )
      );

    	return $this->display(__FILE__, 'dashboard_zone_two.tpl');
  	}

  	public function getBestandBadsale($date_from, $date_to)
  	{

  		$header = array(
  			array(
  				'id' => 'product',
  				'title' => $this->l('produit'),
  				'class' => 'text-center',
  			),
  			array(
  				'id' => 'option',
  				'title' => $this->l('option'),
  				'class' => 'text-center',
  			),
  			array(
  				'id' => 'nb_sales',
  				'title' => $this->l('vendus'),
  				'class' => 'text-center',
  			)
  		);
  	
  		$body = array();

  		$best_product_name = "db query";

  		$best_product_option = "db query";

  		$best_product_nb_sales = "db query";
  	

  		$body[] = array(
  			array(
  				'id' => 'product',
  				'value' => $best_product_name,
  				'class' => 'text-center'
  			),
  			array(
  				'id' => 'option',
  				'value' => $best_product_option,
  				'class' => 'text-center'
  			),
  			array(
  				'id' => 'nb_sales',
  				'value' => $best_product_nb_sales,
  				'class' => 'text-center'
  			)
  		);

  		return array('header' => $header, 'body' => $body);
  	} ?>

my_module.tpl

<section id="statssales" class="panel widget {if $allow_push} allow_push{/if}">
	<header class="panel-heading">
		<i class="icon-bar-chart"></i> Statistiques détaillées des ventes
		<span class="panel-heading-action">
			<a class="list-toolbar-btn" href="#"  onclick="refreshDashboard('statssales'); return false;"  title="rafraichir">
				<i class="process-icon-refresh"></i>
			</a>
		</span>
	</header>

	<section>
		<nav>
			<ul class="nav nav-pills">
				<li class="active">
					<a href="#dash_best_sellers" data-toggle="tab">
						<i class="icon-fire"></i>
						<span class="hidden-inline-xs">Meilleure vente</span>
					</a>
				</li>
			</ul>
		</nav>
		<br>
		<div class="tab-content panel">
			<div class="tab-pane" id="dash_best_sellers">
				<h3>
					Meilleur vente
					<span>Du {$date_from} au {$date_to}</span>
				</h3>
				<div class="table-responsive">
					<table class="table data_table" id="table_best_sale">
						<thead></thead>
						<tbody></tbody>
					</table>
				</div>
			</div>
		</div>
	</section>
</section>

Could you please help me to solve this problem ?

 

Thanks in advance !

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...