Permalink
Browse files

working on logtimes views and sidebars for messages, logtime and project

  • Loading branch information...
1 parent cb0c931 commit b0423ef047c3d0f95078f016a041cd8a99d3bf11 Filippo committed Jul 11, 2010
Showing with 363 additions and 115 deletions.
  1. +11 −0 apps/fe/lib/myUser.class.php
  2. BIN data/phpcollab_unit_test.db
  3. +40 −0 plugins/idProjectManagementPlugin/lib/components/phpCollabComponents.php
  4. +2 −0 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginIssue.class.php
  5. +30 −5 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginLogTimeTable.class.php
  6. +5 −0 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginProfile.class.php
  7. +16 −0 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginProjectTable.class.php
  8. +10 −2 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginProjectUser.class.php
  9. +1 −2 plugins/idProjectManagementPlugin/lib/model/doctrine/PluginProjectUserTable.class.php
  10. +13 −5 plugins/idProjectManagementPlugin/modules/idIssue/actions/components.class.php
  11. +41 −5 plugins/idProjectManagementPlugin/modules/idLogtime/actions/actions.class.php
  12. +35 −0 plugins/idProjectManagementPlugin/modules/idLogtime/actions/components.class.php
  13. +17 −1 plugins/idProjectManagementPlugin/modules/idLogtime/config/view.yml
  14. +11 −7 plugins/idProjectManagementPlugin/modules/idLogtime/templates/_form.php
  15. 0 ...anagementPlugin/modules/{idProject/templates/_showSidebar.php → idLogtime/templates/_sidebar.php}
  16. +11 −8 plugins/idProjectManagementPlugin/modules/idLogtime/templates/editSuccess.php
  17. +9 −6 plugins/idProjectManagementPlugin/modules/idLogtime/templates/indexSuccess.php
  18. +73 −0 plugins/idProjectManagementPlugin/modules/idLogtime/templates/reportSuccess.php
  19. +5 −7 plugins/idProjectManagementPlugin/modules/idMessage/actions/components.class.php
  20. +0 −1 plugins/idProjectManagementPlugin/modules/idMessage/config/view.yml
  21. +6 −14 plugins/idProjectManagementPlugin/modules/idProject/actions/components.class.php
  22. +1 −1 plugins/idProjectManagementPlugin/modules/idProject/config/view.yml
  23. +3 −17 plugins/idProjectManagementPlugin/modules/idProject/templates/_sidebar.php
  24. +1 −1 plugins/idProjectManagementPlugin/modules/idProject/templates/staffListSuccess.php
  25. +16 −27 test/functional/fe/idProjectIssueLogTimeReportTest.php
  26. +1 −1 test/functional/fe/idProjectLogtimeEditTest.php
  27. +2 −2 test/functional/fe/idProjectLogtimeViewByUserTest.php
  28. +3 −3 test/unit/pluginProjectUserTest.php
@@ -247,4 +247,15 @@ public function countMyIssuesForProject($project_id)
return Doctrine::getTable('Issue')->countIssuesAssignedToUserByProject($this->getGuardUser()->Profile->id, $project_id);
}
+ public function getRoleByProject($project_id)
+ {
+ $this->getProfile()->getRoleByProject($project_id);
+ }
+
+ public function getMyTotalLogtimeForIssue($issue_id)
+ {
+ $logtime = Doctrine::getTable('LogTime')->getLogTimeForIssueByUser($issue_id, $this->getGuardUser()->getProfile()->getId());
+ return $logtime[0]['logtimes'];
+ }
+
}
View
Binary file not shown.
@@ -0,0 +1,40 @@
+<?php
+
+abstract class phpCollabComponents extends sfComponents
+{
+ /**
+ * Retrieve parameter £parameter_name from request
+ * and returns the result of apply php function empty()
+ *
+ * @param string $parameter_name
+ */
+ protected function isRequestFieldEmpty($parameter_name)
+ {
+ $value = $this->getRequest()->getParameter($parameter_name);
+ return empty($value);
+ }
+
+
+ protected function retrieveProject($project_identifier = 'project_id')
+ {
+ if(!$this->isRequestFieldEmpty($project_identifier))
+ {
+ return Doctrine::getTable('Project')->findOneBy('id', $this->getRequestParameter($project_identifier));
+ }
+ }
+
+ protected function retrieveProjectReport(Project $project)
+ {
+ $reports = Doctrine::getTable('Project')->getReportsOnProjectsWithEffortChart(array($project));
+ return (count($reports) > 0) ? $reports[$this->project->id] : null;
+ }
+
+ protected function retrieveProjectByIssue()
+ {
+ if(!$this->isRequestFieldEmpty('issue_id'))
+ {
+ return Doctrine::getTable('Project')->getProjectFromIssueId($this->getRequest()->getParameter('issue_id'));
+ }
+ }
+}
+
@@ -49,6 +49,8 @@ public function hasComments()
public function getTotalLogTime()
{
+ $this->refreshRelated('logtimes');
+
$total_log_time = 0;
foreach ($this->logtimes as $logtime_entry)
{
@@ -4,15 +4,27 @@
*/
class PluginLogTimeTable extends Doctrine_Table
{
- public function getLogTimeByIssueAndProfile($issue_id, $profile_id)
+ public function getLogTimeForIssueByUser($issue_id, $profile_id)
+ {
+ return $this->getQueryForLogtimesForIssueByUser($issue_id, $profile_id)->
+ select('SUM(lt.log_time) as logtimes')->
+ execute(array(), Doctrine::HYDRATE_ARRAY);
+ }
+
+ protected function getQueryForLogtimesForIssueByUser($issue_id, $profile_id)
{
return Doctrine_Query::create()
->from('LogTime lt')
->leftJoin('lt.issue i')
->leftJoin('lt.profile p')
->addWhere('lt.profile_id = ? ',$profile_id)
- ->addWhere('lt.issue_id = ? ',$issue_id)
- ->execute();
+ ->addWhere('lt.issue_id = ? ',$issue_id);
+ }
+
+ public function getLogTimeByIssueAndProfile($issue_id, $profile_id)
+ {
+ return $this->getQueryForLogtimesForIssueByUser($issue_id, $profile_id)
+ ->execute();
}
public function getQueryForAllLogTimes()
@@ -24,15 +36,28 @@ public function getQueryForAllLogTimes()
->orderBy('lt.created_at DESC');
}
- public function getQueryForAllLogTimeFronProject($project_id)
+ public function getQueryForAllLogTimeFromProject($project_id)
{
return $this->getQueryForAllLogTimes()
->where('i.project_id = ? ', $project_id);
}
+ public function getQueryForAllLogTimeFromProjectAndIssue($project_id, $issue_id)
+ {
+ return $this->getQueryForAllLogTimes()
+ ->where('i.project_id = ? ', $project_id)
+ ->andWhere('i.id = ? ', $issue_id);
+ }
+
+ public function getQueryForUserLogTimeFromProjectAndIssue($profile_id, $project_id, $issue_id)
+ {
+ return $this->getQueryForAllLogTimeFromProjectAndIssue($project_id, $issue_id)
+ ->andWhere('p.id = ? ', $profile_id);
+ }
+
public function getLogtimeForProjectByUser($project_id)
{
- return $this->getQueryForAllLogTimeFronProject($project_id)
+ return $this->getQueryForAllLogTimeFromProject($project_id)
->execute();
}
}
@@ -38,4 +38,9 @@ public function getShortName()
$user = $this->getUser();
return ucfirst($this->getFirstName()).' '. ucfirst(substr($this->getLastName(),0,1)).'.';
}
+
+ public function getRoleByProject($project_id)
+ {
+ return ProjectUser::getRoleByProfileIdAndProjectId($this->getId(), $project_id);
+ }
}
@@ -206,4 +206,20 @@ public function getReportsOnProjectsWithEffortChart($projects, $limit = 3)
return $reports;
}
+ public function getProjectFromIssueId($issue_id)
+ {
+ if(!is_null($issue_id))
+ {
+ return $this->createQuery()->
+ from('Project as p')->
+ leftJoin('p.Issues i')->
+ leftJoin('p.users u')->
+ leftJoin('p.trackers t')->
+ leftJoin('p.Milestones mil')->
+ leftJoin('p.Messages mes')->
+ where('i.id = ?', $issue_id)->
+ fetchOne();
+ }
+ }
+
}
@@ -21,10 +21,18 @@
*/
abstract class PluginProjectUser extends BaseProjectUser
{
- public static $roles = array('admin' => 1, 'developer' => 2, 'project manager' => 3, 'customer' => 4);
+ public static $roles = array('admin' => 1,
+ 'developer' => 2,
+ 'project manager' => 3,
+ 'customer' => 4);
public static function getRoleByProfileIdAndProjectId($profile_id, $project_id)
{
- return Doctrine::getTable('ProjectUser')->getRoleByProfileIdAndRojectId($profile_id, $project_id);
+ $code = Doctrine::getTable('ProjectUser')->getRoleByProfileIdAndProjectId($profile_id, $project_id);
+ if($code)
+ {
+ $roles = array_flip(self::$roles);
+ return $roles[$code];
+ }
}
}
@@ -21,8 +21,7 @@
*/
class PluginProjectUserTable extends Doctrine_Table
{
-
- public function getRoleByProfileIdAndRojectId($profile_id, $project_id)
+ public function getRoleByProfileIdAndProjectId($profile_id, $project_id)
{
$result = $this->createQuery()->where('project_id = '. $project_id)->addWhere('profile_id = '. $profile_id)->fetchOne(array(), Doctrine::HYDRATE_ARRAY);
if (is_array($result))
@@ -14,18 +14,26 @@
/**
* idDashboardComponents components
*/
-class idIssueComponents extends sfComponents
+class idIssueComponents extends phpCollabComponents
{
public function executeSidebar()
{
- $this->project = Doctrine::getTable('Project')->findOneBy('id', $this->getRequestParameter('project_id'));
- $reports = Doctrine::getTable('Project')->getReportsOnProjectsWithEffortChart(array($this->project));
-
- $this->project_report = (count($reports) > 0) ? $reports[$this->project->id] : null;
+ if($this->isRequestFieldEmpty('project_id'))
+ {
+ return sfView::NONE;
+ }
+
+ $this->project = $this->retrieveProject();
+ $this->project_report = $this->retrieveProjectReport($this->project);
}
public function executeShowSidebar()
{
+ if($this->isRequestFieldEmpty('issue_id'))
+ {
+ return sfView::NONE;
+ }
+
$this->issue = Doctrine::getTable('Issue')->getIssueById($this->getRequest()->getParameter('issue_id'));
}
}
@@ -26,6 +26,8 @@ public function executeIndex(sfWebRequest $request)
$this->form = new LogTimeForm();
$this->form->setDefault('created_at', date('Y-m-d H:i:s', time()));
+
+ $this->setTemplate('report');
}
public function executeAddToIssue(sfWebRequest $request)
@@ -67,21 +69,53 @@ private function checkUserAgainstIssueAndProject(sfWebRequest $request)
return $issue;
}
+ /**
+ * report for single issue and sigle user
+ *
+ * @param sfWebRequest $request
+ */
public function executeReportForActualUser(sfWebRequest $request)
{
$this->forwardUnless($this->getUser()->hasCredential('idLogotime-ReadReport'), sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
$this->issue = $this->checkUserAgainstIssueAndProject($request);
-
- $this->logtime_report = Doctrine::getTable('LogTime')->getLogTimeByIssueAndProfile($this->issue->id, $this->getUser()->getGuardUser()->Profile->id);
+
+ $this->pager = new sfDoctrinePager('LogTime',10);
+ $this->pager->setQuery(Doctrine::getTable('LogTime')->getQueryForUserLogTimeFromProjectAndIssue($this->getUser()->getGuardUser()->getProfile()->getId(), $this->issue->project_id, $this->issue->id));
+ $this->pager->setMaxPerPage(sfConfig::get('mod_maxperpage_logtime', 10));
+ $this->pager->setPage($this->getRequestParameter('page',1));
+ $this->pager->init();
+
+ $this->total_time = $this->getUser()->getMyTotalLogtimeForIssue($this->issue->id);
+
+ $this->setTemplate('report');
}
+ /**
+ * report for single issue and multiple users
+ *
+ * @param sfWebRequest $request
+ */
public function executeReportForAllUsers(sfWebRequest $request)
{
$this->forwardUnless($this->getUser()->hasCredential('idLogotime-ReadReportForAllUsers'), sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
$this->issue = $this->checkUserAgainstIssueAndProject($request);
- $this->logtime_report = $this->issue->logtimes;
+
+ $this->pager = new sfDoctrinePager('LogTime',10);
+ $this->pager->setQuery(Doctrine::getTable('LogTime')->getQueryForAllLogTimeFromProjectAndIssue($this->issue->project_id, $this->issue->id));
+ $this->pager->setMaxPerPage(sfConfig::get('mod_maxperpage_logtime', 10));
+ $this->pager->setPage($this->getRequestParameter('page',1));
+ $this->pager->init();
+
+ $this->total_time = $this->issue->getTotalLogTime();
+
+ $this->setTemplate('report');
}
-
+
+ /**
+ * list of all the logtimes of a project
+ *
+ * @param sfWebRequest $request
+ */
public function executeReportAllUsersForProject(sfWebRequest $request)
{
$this->forwardUnless($this->getUser()->hasCredential('idLogotime-ReadReportForAllUsers'), sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
@@ -92,7 +126,7 @@ public function executeReportAllUsersForProject(sfWebRequest $request)
$this->form->setDefault('created_at', date('Y-m-d H:i:s', time()));
$this->pager = new sfDoctrinePager('LogTime',10);
- $this->pager->setQuery(Doctrine::getTable('LogTime')->getQueryForAllLogTimeFronProject($this->project->id));
+ $this->pager->setQuery(Doctrine::getTable('LogTime')->getQueryForAllLogTimeFromProject($this->project->id));
$this->pager->setMaxPerPage(sfConfig::get('mod_maxperpage_logtime', 10));
$this->pager->setPage($this->getRequestParameter('page',1));
$this->pager->init();
@@ -128,6 +162,8 @@ public function executeEdit(sfWebRequest $request)
$this->forward404Unless($log_time = Doctrine::getTable('LogTime')->
findOneBy('id', $request->getParameter('id')),
sprintf('Object log_time does not exist (%s).', array($request->getParameter('id'))));
+
+ $this->project = $log_time->getIssue()->getProject();
$this->form = new LogTimeForm($log_time);
}
@@ -0,0 +1,35 @@
+<?php
+/**
+ * This file is part of the phpCollab3 package.
+ * (c) 2009 Ideato s.r.l. <phpcollab@ideato.it>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ *
+ * idLogtimeComponents
+ *
+ * @package phpCollab3
+ * @subpackage idProjectManagementPlugin Modules
+ */
+
+/**
+ * idLogtimeComponents class for components in idLogtime modules templates
+ *
+ * @package phpCollab3
+ * @subpackage idProjectManagementPlugin Modules
+ * @author Filippo (p16) De Santis <fd@ideato.it>
+ */
+class idLogtimeComponents extends phpCollabComponents
+{
+ public function executeSidebar()
+ {
+ if($this->isRequestFieldEmpty('issue_id'))
+ {
+ return sfView::NONE;
+ }
+
+ $this->project = $this->retrieveProjectByIssue();
+ $this->project_report = $this->retrieveProjectReport($this->project);
+ }
+}
+?>
@@ -1,5 +1,21 @@
-default:
+reportSuccess:
+ components:
+ sidebar: [idLogtime, sidebar]
+
+newSuccess:
+ components:
+ sidebar: []
+
+editSuccess:
components:
sidebar: []
+indexSuccess:
+ components:
+ sidebar: []
+
+default:
+ components:
+ sidebar: [idMessage, sidebar]
+
javascripts: [jquery-1.4.2.min.js, log_time_form_show.js]
@@ -26,12 +26,16 @@
</li>
</ul>
<div class="clear"></div>
- <div class="span-7 prepend-1 confirm-box">
- <?php if (!$form->getObject()->isNew()): ?>
- &nbsp;<?php echo link_to('Delete', 'idLogtime/delete?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
- <?php endif; ?>
- <?php echo link_to('Cancel', '@index_logtime'); ?>
- <input type="submit" value="Save" />
+ <div class="confirm-box">
+ <div class="span-7 prepend-1">
+ <input type="submit" value="Save" class="button block-green medium-round"/>
+ </div>
+ <div class="span-8">&nbsp;
+ <?php echo $form->renderHiddenFields() ?>
+ </div>
+ <div class="span-6 right last append-1">
+ <?php echo link_to('Cancel', (isset($referer) && !empty($referer)) ? $referer : '@index_logtime', array('class' => 'button block-red medium-round')); ?>
+ </div>
+ <div class="clear"></div>
</div>
- <?php echo $form->renderHiddenFields() ?>
</form>
Oops, something went wrong.

0 comments on commit b0423ef

Please sign in to comment.