|
From: <an...@us...> - 2006-03-06 20:45:49
|
Revision: 193 Author: anarcat Date: 2006-03-06 12:45:40 -0800 (Mon, 06 Mar 2006) ViewCVS: http://svn.sourceforge.net/phptimetracker/?rev=193&view=rev Log Message: ----------- merge rapport.php into facture.php. the summary on top of facture.php was broken anyways and looks much better now. this commit inaugurates the migration to Subversion. Modified Paths: -------------- trunk/phptimetracker/facture.php trunk/phptimetracker/includes/menu_utils.php Removed Paths: ------------- trunk/phptimetracker/rapport.php Modified: trunk/phptimetracker/facture.php =================================================================== --- trunk/phptimetracker/facture.php 2006-01-28 00:39:56 UTC (rev 192) +++ trunk/phptimetracker/facture.php 2006-03-06 20:45:40 UTC (rev 193) @@ -106,11 +106,64 @@ if (!$user) { unset($user); } - $project = Project::top_level($customer->get('name')); -$total = 0; -while ($project->next()) { - print ecdStd::project_facture($project, 0, $bounds); + +// avoid sql injection +$where = ""; + +/* XXX: copy paste from Projec::listTimeEntries() */ +if (!is_null($bounds)) { + $st = new ecdDate($bounds[0], 'unixtimestamp'); + $end = new ecdDate($bounds[1], 'unixtimestamp'); + $where .= + "`start` >= '" .$st->datetime()."' AND ". + "`start` <= '".$end->datetime()."' AND "; } + +$p = new Project(array('id' => $_GET['project'])); $p->next(); +$project = $p->get('path'); +$join = " INNER JOIN `project` AS p ON p.id = timeentry.project "; + +$where .= "p.path LIKE '" . $project . "%' AND "; + +if ($_GET['user']) { + $where .= "timeentry.user = '" . addslashes($_GET['user']) . "' AND "; +} + +$where .= "1 GROUP BY user, project"; + +/* original query, reconstructed in TimeEntry below */ +/* $query = "SELECT SUM(end-start),user,project,path,name +FROM `timeentry` JOIN `project` $where +GROUP BY user, project ORDER BY user,path"; */ + +$track = new TimeEntry($where, null, null, + "user,path", /* order by */ + "SUM(UNIX_TIMESTAMP(end)-UNIX_TIMESTAMP(start)) AS time,user,project,path,name", /* select */ + $join); + +$current_user = null; +while ($track->next()) { + $style = ( $style != 'odd' ? 'odd' : 'even'); + + if ($current_user != $track->get('user')) { + + if (!is_null($current_user)) { + print "<tr class=\"$style\"><td><strong>".__('Total').":</strong></td>"; + print "<td style=\"text-align: right\">".ecdDate::how_much_time_str($total, HOURS, 30*MINUTES) . "</td>"; + print '</tr><tr><td colspan="2"></td></tr>'; + $total = 0; +} + print "<tr>"; + $current_user = $track->get('user'); + print '<td class="dateline" colspan="2">'.User::id_to_mail($current_user).'</td>'; + print "</tr>"; + } + print "<tr class=\"$style\">"; + print "<td>".$track->get('name')."</td>"; + $total += $time = $track->get('time'); + print "<td align=\"right\">".ecdDate::how_much_time_str($time, HOURS, 30 * MINUTES)."</td>"; + print "</tr>"; +} ?> <tr><td></td><td></td></tr> <tr class="even"><td><strong><?=__('Total')?>:</strong></td> Modified: trunk/phptimetracker/includes/menu_utils.php =================================================================== --- trunk/phptimetracker/includes/menu_utils.php 2006-01-28 00:39:56 UTC (rev 192) +++ trunk/phptimetracker/includes/menu_utils.php 2006-03-06 20:45:40 UTC (rev 193) @@ -17,7 +17,6 @@ <li<?=@$menu['profil.php']?>><a href="<?=add_get_array('profil.php', $_GET)?>"><?=__('Mon profil')?></a></li> <li<?=@$menu['liste_projets.php']?>><a href="<?=add_get_array('liste_projets.php', $_GET)?>"><?=__('Liste des projets')?></a></li> <li<?=@$menu['facture.php']?>><a href="<?=add_get_array('facture.php', $_GET)?>"><?=__('Factures')?></a></li> - <li<?=@$menu['rapport.php']?>><a href="<?=add_get_array('rapport.php', $_GET)?>"><?=__('Rapports')?></a></li> <li><a href="http://wiki/wiki/index.php/Accueil"><?=__('Wiki')?></a></li> <li><a href="<?=add_get_array('php/bin/logout.php', $_GET)?>"><?=__('Logout')?></a></li> Deleted: trunk/phptimetracker/rapport.php =================================================================== --- trunk/phptimetracker/rapport.php 2006-01-28 00:39:56 UTC (rev 192) +++ trunk/phptimetracker/rapport.php 2006-03-06 20:45:40 UTC (rev 193) @@ -1,178 +0,0 @@ -<?php - -/** - * Affichage de la facture - * - * $Id$ - */ - -/** - * page protected - */ -require_once('php/bin/login.php'); -require_once('php/Customer.php'); -require_once('php/ecdErrorBuffer.inc.php'); -require_once('php/ecdProfiler.inc.php'); -require_once('php/language.php'); -require_once('php/ecdStd.inc.php'); -require_once('php/ecdForms.inc.php'); -require_once('php/bin/project_edit.php'); -require_once('php/bin/profile_edit.php'); - -$auth = TimeAuth::instance(); - -?> -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> - -<html> - - <head> - <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> - <title><?=__('Rapports')?></title> - <link href="css/espresso_timesheet.css" rel="stylesheet" type="text/css" media="screen" /> - <link href="css/plain.css" rel="alternate stylesheet" type="text/css" media="screen" title="plain" /> - <link href="css/facture_print.css" rel="stylesheet" type="text/css" media="print" /> - <style type="text/css" media="screen"></style> - <script type="text/javascript" src="js/datepick/ts_picker.js"></script> - <link rel="Shortcut Icon" href="http://www.espresso-com.com/favicon.ico" type="image/x-icon" /> - <script type="text/javascript" src="js/reload.js" language="javascript"></script> - </head> - - <body> - <div id="entete"> - <?php include ("includes/menu_utils.php"); ?> - <div id="titre"> - <h2><?=__('Rapports')?></h2> - </div> - </div> - <div id="container"> - <div id="side"> - <div id="calendar_container"> -<div id="calendar_a"> - <?php - print __("From").":"; - $from = new ecdDate($_GET['from'], 'datetime'); - $to = new ecdDate($_GET['to'], 'datetime'); - -print ecdDate::calendar_str(new Date($from->unixtimestamp()), 0, null, 'from'); -?> -</div> -<div id="calendar_b"> -<?php -print __("To").":"; -print ecdDate::calendar_str(new Date($to->unixtimestamp()), 0, null, 'to'); -?> -</div> -</div> - <div id="editor"> - - <!-- ceci sert \xE0 choisir le client duquel on liste les projets --> - <!-- si l'usager a acc\xE8s \xE0 plus d'un client, un listbox appara\xEEtra --> -<?php -$customer = new Customer(array('name' => ecdStd::current_customer())); -$customer->next(); - -print ecdStd::customer_listbox(); - -print ecdStd::user_listbox(null, 'user', $_GET, __('montrer tous'), array("onChange" => "change(this)")); - -print ecdStd::project_listbox(null, $_GET, 'project', false, true, true); -?> - </div> - </div> - <div id="result"> -<?php - $bounds = array($from->unixtimestamp(), $to->unixtimestamp()); - -?> - <h3><?=__('Temps du %s au %s', $from->getShortDate(sane_lang()), $to->getShortDate(sane_lang()))?></h3> - - <table width="100%"> - <tr class="header"> - <td><?=__('Projet')?></td> - <td style="text-align: right"><?=__('Time')?></td> - </tr> -<?php - -# XXX: this is evil. for some reason, project_facture() uses a global $user and -# defaults it only if it's not isset() (in opposition with is_null()). -$user = $_GET['id']; -if (!$user) { - unset($user); -} - -// avoid sql injection -$where = ""; - -/* XXX: copy paste from Projec::listTimeEntries() */ -if (!is_null($bounds)) { - $st = new ecdDate($bounds[0], 'unixtimestamp'); - $end = new ecdDate($bounds[1], 'unixtimestamp'); - $where .= - "`start` >= '" .$st->datetime()."' AND ". - "`start` <= '".$end->datetime()."' AND "; -} - -$p = new Project(array('id' => $_GET['project'])); $p->next(); -$project = $p->get('path'); -$join = " INNER JOIN `project` AS p ON p.id = timeentry.project "; - -$where .= "p.path LIKE '" . $project . "%' AND "; - -if ($_GET['user']) { - $where .= "timeentry.user = '" . addslashes($_GET['user']) . "' AND "; -} - -$where .= "1 GROUP BY user, project"; - -/* original query, reconstructed in TimeEntry below */ -/* $query = "SELECT SUM(end-start),user,project,path,name -FROM `timeentry` JOIN `project` $where -GROUP BY user, project ORDER BY user,path"; */ - -$track = new TimeEntry($where, null, null, - "user,path", /* order by */ - "SUM(UNIX_TIMESTAMP(end)-UNIX_TIMESTAMP(start)) AS time,user,project,path,name", /* select */ - $join); - -$current_user = null; -while ($track->next()) { - $style = ( $style != 'odd' ? 'odd' : 'even'); - - if ($current_user != $track->get('user')) { - - if (!is_null($current_user)) { - print "<tr class=\"$style\"><td><strong>".__('Total').":</strong></td>"; - print "<td style=\"text-align: right\">".ecdDate::how_much_time_str($total, HOURS, 30*MINUTES) . "</td>"; - print '</tr><tr><td colspan="2"></td></tr>'; - $total = 0; -} - print "<tr>"; - $current_user = $track->get('user'); - print '<td class="dateline" colspan="2">'.User::id_to_mail($current_user).'</td>'; - print "</tr>"; - } - print "<tr class=\"$style\">"; - print "<td>".$track->get('name')."</td>"; - $total += $time = $track->get('time'); - print "<td align=\"right\">".ecdDate::how_much_time_str($time, HOURS, 30 * MINUTES)."</td>"; - print "</tr>"; -} - $style = ( $style != 'odd' ? 'odd' : 'even'); - print "<tr class=\"$style\"><td><strong>".__('Total').":</strong></td>"; - print "<td style=\"text-align: right\">".ecdDate::how_much_time_str($total, HOURS, 30*MINUTES) . "</td>"; - print "</tr>"; - -?> - - - </table> - - - </div> - </div> -</form> - - </body> - -</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |