Add category color/font support for web view

This commit is contained in:
root 2010-09-10 21:58:34 +02:00
parent 2c7a1ca252
commit 41ace4621e
4 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,4 @@
<?php
/* /*
Copyright 2010 Grégory Soutadé Copyright 2010 Grégory Soutadé
@ -17,8 +18,6 @@
along with KissCount. If not, see <http://www.gnu.org/licenses/>. along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/ */
<?php
class User class User
{ {
public $id; public $id;

View File

@ -1,3 +1,4 @@
<?php
/* /*
Copyright 2010 Grégory Soutadé Copyright 2010 Grégory Soutadé
@ -17,8 +18,6 @@
along with KissCount. If not, see <http://www.gnu.org/licenses/>. along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/ */
<?php
$BDD_FILE = '/var/nfs/kc.bdd'; $BDD_FILE = '/var/nfs/kc.bdd';
try { try {
@ -52,6 +51,28 @@ function IsUserValid($user, $password)
return $result->fetchArray(); return $result->fetchArray();
} }
function ExtractStyle(&$category)
{
$s = "background-color:" . $category["backcolor"] . ";";
$s .= "color:" . $category["forecolor"] . ";";
if ($category["font"] != "")
{
$params = explode(";", $category["font"]);
// size ; xx ; 93 italic ; 92 bold ; face name
$s .= "font-size:" . $params[0] . "px;";
if ($params[2] == "93")
$s .= "font-style:italic;";
if ($params[3] == "92")
$s .= "font-weight:bold;";
$s .= "font-family:" . $params[4] . ";";
}
$category["style"] = $s;
}
function LoadUser($name) function LoadUser($name)
{ {
global $db; global $db;
@ -79,7 +100,10 @@ function LoadUser($name)
$user->categories = array(); $user->categories = array();
while ($row = $result->fetchArray()) while ($row = $result->fetchArray())
{
ExtractStyle($row);
array_push($user->categories, $row); array_push($user->categories, $row);
}
$result = $db->query("SELECT * FROM preference WHERE user='$user->id' ORDER by name"); $result = $db->query("SELECT * FROM preference WHERE user='$user->id' ORDER by name");

View File

@ -1,3 +1,4 @@
<?php
/* /*
Copyright 2010 Grégory Soutadé Copyright 2010 Grégory Soutadé
@ -17,7 +18,6 @@
along with KissCount. If not, see <http://www.gnu.org/licenses/>. along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/ */
<?php
include "kisscount.php" ; include "kisscount.php" ;
session_start(); session_start();
@ -209,7 +209,7 @@ while($operation = $operations->fetchArray())
else else
$tr_class = ""; $tr_class = "";
} }
echo "<tr $tr_class bgcolor='" . $category["color"] ."'><td>" . $operation["description"] . "</td>"; echo "<tr $tr_class style='" . $category["style"] . "'><td>" . $operation["description"] . "</td>";
echo "<td>" . date("d/m/Y", mktime(0, 0, 0, $operation["month"]+1, $operation["day"]+1, $operation["year"])) . "</td>"; echo "<td>" . date("d/m/Y", mktime(0, 0, 0, $operation["month"]+1, $operation["day"]+1, $operation["year"])) . "</td>";
if ($operation["amount"] < 0) if ($operation["amount"] < 0)
echo "<td align='right'>" . number_format(-$operation["amount"], 2) . "</td><td />"; echo "<td align='right'>" . number_format(-$operation["amount"], 2) . "</td><td />";

View File

@ -1,3 +1,4 @@
<?php
/* /*
Copyright 2010 Grégory Soutadé Copyright 2010 Grégory Soutadé
@ -17,7 +18,6 @@
along with KissCount. If not, see <http://www.gnu.org/licenses/>. along with KissCount. If not, see <http://www.gnu.org/licenses/>.
*/ */
<?php
include "User.php"; include "User.php";
include "database.php"; include "database.php";