Hey there,
I’m working on a projet to display as a widget some informations from the database.
But i’m facing a problem. My module is activated and i can see my widget in the widget pannel. I can activate him but I can’t see him. I’m looking these last days for a topic like this one but I didn’t see any.
I looked the wiki but there is no many explanation.
Thank you for your help
<?php
/**
* \file htdocs/testun/core/boxes/box_ollas.php
* \ingroup testun
* \brief Module pour voir le nombre d'Ollas a faire
*/
include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
/**
* Class to manage the box to show last manual entries
*/
class box_ollas extends ModeleBoxes
{
public $boxcode = "box_ollas";
public $boximg = "object_rss";
public $boxlabel = "BoxOllasEntry";
public $depends = array("testun");
/**
* @var DoliDB Database handler.
*/
public $db;
public $param;
public $info_box_head = array();
public $info_box_contents = array();
/**
* Constructor
* @param DoliDB $db Database handler
* @param string $param More parameters
*/
public function __construct($db, $param)
{
global $user;
$this->db = $db;
$this->hidden = !($user->rights->accounting->mouvements->lire);
}
/**
* Load data for box to show them later
*
* @param int $max Maximum number of records to load
* @return void
*/
public function loadBox($max = 5)
{
global $user, $langs, $conf;
require_once DOL_DOCUMENT_ROOT."/custom/testun/core/modules/modTestUn.class.php";
$this->info_box_head = array('text' => $langs->trans("BoxOllasEntry", $max));
if ($user->rights->accounting->mouvements->lire)
{
$sql = "SELECT c.ref AS reference, COUNT(b) AS nb_apparition";
$sql .= " FROM ".MAIN_DB_PREFIX."llx_commandedet as a, ".MAIN_DB_PREFIX."llx_commande as b, ".MAIN_DB_PREFIX."llx_product as c ";
$sql .= " WHERE a.fk_commande = b.rowid";
$sql .= " AND a.fk_product = c.rowid";
$sql .= " GROUP BY c.ref";
$sql .= $this->db->plimit($max, 0);
$result = $this->db->query($sql);
if ($result) {
$num = $this->db->num_rows($result);
$line = 0;
while ($line < $num) {
$objp = $this->db->fetch_object($result);
$ref = $objp->reference;
$count = $objp->nb_apparition;
$this->info_box_contents[$line][] = array(
'td' => 'class="center"',
'text' => $ref,
'asis' => 1,
);
$this->info_box_contents[$line][] = array(
'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
'text' => $count,
'asis' => 1,
);
$line++;
}
if ($num == 0) $this->info_box_contents[$line][0] = array(
'td' => 'class="center"',
'text'=> '<span class="opacitymedium">'.$langs->trans("NoRecordedManualEntries").'</span>'
);
$this->db->free($result);
} else {
$this->info_box_contents[0][0] = array(
'td' => '',
'maxlength'=>500,
'text' => ($this->db->error().' sql='.$sql),
);
}
} else {
$this->info_box_contents[0][0] = array(
'td' => 'class="nohover left"',
'text' => '<span class="opacitymedium">'.$langs->trans("ReadPermissionNotAllowed").'</span>'
);
}
}
/**
* Method to show box
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @param int $nooutput No print, only return string
* @return string
*/
public function showBox($head = null, $contents = null, $nooutput = 0)
{
return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
}
}
Have a great day