<?php
/*************************************************************
* The MyDB librairy and applications are product of SQLFusion
* It may be used and/or distributed under the terms of the Q Public
* License (QPL) version 1.0, enclosed in the file licence.txt.
****************************************************************/
/** MyDataLib Version 0.7 **/
/** Author Philippe Lewicki **/
class currency {
var $tbl_currency = "currency" ;
var $name ;
var $coef ;
var $nbrdec ;
var $decpoint ;
var $thousandsep ;
var $mask ;
function getcurrency($dbc) {
$dbc->sql_query = "select * from $this->tbl_currency where name='$this->name'" ;
$dbc->sql_order ="" ;
$dbc->pos ="";
$dbc->query() ;
if($cur = $dbc->fetch()) {
$this->name = $cur->name ;
$this->coef = $cur->coef ;
$this->nbrdec = $cur->nbrdec ;
$this->decpoint = $cur->decpoint ;
if ($cur->thousandsep == "_") { $cur->thousandsep = " "; }
$this->thousandsep = $cur->thousandsep ;
$this->mask = $cur->mask ;
}
}
function printcurrency($dbc, $value) {
$newcur = $value*$this->coef ;
$printcur = sprintf($this->mask, number_format($newcur, $this->nbrdec, "$this->decpoint", "$this->thousandsep") );
return $printcur ;
}
/* convert the current currency $value to $destcurrency */
function convert($value,$destcurrency)
{
$newval=doubleval($value)/doubleval($this->coef);
$newval=doubleval($newval)*doubleval($destcurrency->coef);
return doubleval($newval);
}
}
class Caract {
var $tbl_caracteristic = "caracteristic";
var $tbl_caractvalue = "caractvalue";
var $caract ;
function getcaract($caractreg, $dbc) {
$returnvalue = "";
if ($caractreg>0) {
$query = "select * from ".$this->tbl_caracteristic." where id".$this->tbl_caracteristic."='".$caractreg."'" ;
$dbc->sql_query = $query;
$dbc->sql_order = "";
$dbc->sql_pos = "";
$rcarac = $dbc->query();
if($caract = $dbc->fetch($rcarac) ) {
$query = "select * from ".$this->tbl_caractvalue." where id".$this->tbl_caracteristic."='$caractreg'" ;
$dbc->sql_query = $query ;
$rvalue = $dbc->query();
while ($values = $dbc->fetch($rvalue)) {
$returnvalue .= "<option value=\"".$caract->prefix.$values->value."\">".$values->value."</option>\n" ;
}
if(strlen($caract->prefix)>0) $ctete="";
else $ctete="$caract->name ";
if($returnvalue!="") $returnvalue = "$ctete<select name=\"$caract->varname\">$returnvalue</select>";
else $returnvalue= "<input type=hidden name=\"$caract->varname\" value=\"".$caract->prefix.$caract->name."\">".$caract->name ;
}
}
return $returnvalue ;
}
} // fin classe Caract
class MenuHTML {
var $Table = "categorie" ; /* Table with the categorie content */
var $DisplayField = "name" ; /* Field name with the value to display */
var $SendField = "idcategorie"; /* Field name with the value to send in get to the url page */
var $SendVariable = "cat" ; /* Name of the var send in get with the SendField value */
var $Url ; /* Url of the page where the SendField and SendVariable while be send */
var $Target = ""; /* Target for the link */
var $Separator = "<br>"; /* HTML separator betewen the link */
function display($dbc) {
if (strlen($this->Table)>0) { $tablename = $this->Table; } else { $tablename = $dbc->table; }
if (strlen($this->SendVariable)<1) { $this->SendVariable = $this->SendField; }
$rm = mysql_db_query($dbc->db, "select $this->DisplayField, $this->SendField from $tablename");
while (list ($DispValue, $SendValue) = mysql_fetch_row($rm)) {
if (eregi("\?",$this->Url)) {
$sep = "&" ;
} else {
$sep = "?";
}
echo "<a href=\"".$this->Url.$sep.$this->SendVariable."=".$SendValue."\"";
if (strlen($this->Target)>0)
echo " target=\"".$this->Target."\"" ;
echo">$DispValue</a>$this->Separator";
}
}
}
Class MenuListBox {
var $DB ;
var $Table ;
var $DisplayField ;
var $ValueField ;
var $Name ;
var $QueryWhere;
function display($dbc) {
if (strlen($this->Name)<1) { $this->Name = $this->ValueField; }
$rm = mysql_db_query($dbc->db, "select $this->DisplayField, $this->ValueField from $this->Table ".$this->QueryWhere);
echo "$this->querywhere";
echo "<select name=$this->Name>\n" ;
while (list ($DispValue, $SendValue) = mysql_fetch_row($rm)) {
echo "<option value=\"$SendValue\">$DispValue</option>\n";
}
echo "</select>";
}
}
?>