*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/boxes/modules_boxes.php
* \ingroup facture
* \brief Fichier contenant la classe mere des boites
*/
/**
* Parent class of boxes
*/
class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" boxes
{
var $db;
var $error='';
var $max=5;
/**
* Constructor
*
* @param DoliDB $db Database hanlder
*/
function ModeleBoxes($db)
{
$this->db=$db;
}
/**
* Return last error message
*
* @return string Error message
*/
function error()
{
return $this->error;
}
/**
* Load a box line from its rowid
*
* @param int $rowid Row id to load
* @return int <0 if KO, >0 if OK
*/
function fetch($rowid)
{
// Recupere liste des boites d'un user si ce dernier a sa propre liste
$sql = "SELECT b.rowid, b.box_id, b.position, b.box_order, b.fk_user";
$sql.= " FROM ".MAIN_DB_PREFIX."boxes as b";
$sql.= " WHERE b.rowid = ".$rowid;
dol_syslog(get_class($this)."::fetch rowid=".$rowid);
$resql = $this->db->query($sql);
if ($resql)
{
$obj = $this->db->fetch_object($resql);
if ($obj)
{
$this->rowid=$obj->rowid;
$this->box_id=$obj->box_id;
$this->position=$obj->position;
$this->box_order=$obj->box_order;
$this->fk_user=$obj->fk_user;
return 1;
}
else
{
return -1;
}
}
else
{
return -1;
}
}
/**
* Standard method to show a box (usage by boxes not mandatory, a box can still use its own function)
*
* @param array $head Array with properties of box title
* @param array $contents Array with properties of box lines
* @return void
*/
function showBox($head, $contents)
{
global $langs,$conf;
$MAXLENGTHBOX=60; // Mettre 0 pour pas de limite
$bcx[0] = 'class="box_pair"';
$bcx[1] = 'class="box_impair"';
$var = false;
dol_syslog(get_Class($this));
// Define nbcol and nblines of the box to show
$nbcol=0;
if (isset($contents[0])) $nbcol=count($contents[0]);
$nblines=count($contents);
print "\n\n\n";
print '
'."\n";
if (! empty($head['text']) || ! empty($head['sublink']) || $nblines)
{
print '
'."\n";
}
// Show box title
if (! empty($head['text']) || ! empty($head['sublink']))
{
//print ''."\n";
//print '
'."\n";
print '';
print ' 0) { print ' colspan="'.$nbcol.'"'; }
print '>';
if ($conf->use_javascript_ajax)
{
print '| ';
}
if (! empty($head['text']))
{
$s=dol_trunc($head['text'],isset($head['limit'])?$head['limit']:$MAXLENGTHBOX);
print $s;
}
if (! empty($head['sublink']))
{
print ' '.img_picto($head['subtext'],$head['subpicto']).'';
}
if ($conf->use_javascript_ajax)
{
print ' | ';
// The image must have the class 'boxhandle' beause it's value used in DOM draggable objects to define the area used to catch the full object
print img_picto($langs->trans("MoveBox",$this->box_id),'grip','class="boxhandle" style="cursor:move;"');
print img_picto($langs->trans("Close",$this->box_id),'close','class="boxclose" style="cursor:pointer;" id="imgclose'.$this->box_id.'"');
print ' | ';
}
print ' | ';
print "
\n";
// print "
\n";
// print "
\n";
}
// Show box lines
if ($nblines)
{
//print '\n";
}
// If invisible box with no contents
if (empty($head['text']) && empty($head['sublink']) && ! $nblines) print "
\n";
print "\n";
print "\n\n";
}
}
?>