home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / projects / view.php < prev    next >
Encoding:
PHP Script  |  2004-01-31  |  8.2 KB  |  214 lines

  1. <?php /* PROJECTS $Id: view.php,v 1.56 2004/01/31 09:24:52 ajdonnison Exp $ */
  2.  
  3. $project_id = intval( dPgetParam( $_GET, "project_id", 0 ) );
  4.  
  5. // check permissions for this record
  6. $canRead = !getDenyRead( $m, $project_id );
  7. $canEdit = !getDenyEdit( $m, $project_id );
  8.  
  9. if (!$canRead) {
  10.     $AppUI->redirect( "m=public&a=access_denied" );
  11. }
  12.  
  13. // retrieve any state parameters
  14. if (isset( $_GET['tab'] )) {
  15.     $AppUI->setState( 'ProjVwTab', $_GET['tab'] );
  16. }
  17. $tab = $AppUI->getState( 'ProjVwTab' ) !== NULL ? $AppUI->getState( 'ProjVwTab' ) : 0;
  18.  
  19. // check if this record has dependancies to prevent deletion
  20. $msg = '';
  21. $obj = new CProject();
  22. $canDelete = $obj->canDelete( $msg, $project_id );
  23.  
  24. // load the record data
  25. $sql = "
  26. SELECT
  27.     company_name,
  28.     CONCAT_WS(' ',user_first_name,user_last_name) user_name,
  29.     projects.*,
  30.     SUM(t1.task_duration*t1.task_duration_type*t1.task_percent_complete)/SUM(t1.task_duration*t1.task_duration_type) AS project_percent_complete
  31. FROM projects
  32. LEFT JOIN companies ON company_id = project_company
  33. LEFT JOIN users ON user_id = project_owner
  34. LEFT JOIN tasks t1 ON projects.project_id = t1.task_project
  35. WHERE project_id = $project_id
  36. GROUP BY project_id
  37. ";
  38.  
  39. $obj = null;
  40. if (!db_loadObject( $sql, $obj )) {
  41.     $AppUI->setMsg( 'Project' );
  42.     $AppUI->setMsg( "invalidID", UI_MSG_ERROR, true );
  43.     $AppUI->redirect();
  44. } else {
  45.     $AppUI->savePlace();
  46. }
  47.  
  48. // worked hours
  49. // by definition milestones don't have duration so even if they specified, they shouldn't add up
  50. // the sums have to be rounded to prevent the sum form having many (unwanted) decimals because of the mysql floating point issue
  51. // more info on http://www.mysql.com/doc/en/Problems_with_float.html
  52. $sql = "SELECT ROUND(SUM(task_log_hours),2) FROM task_log, tasks WHERE task_log_task = task_id AND task_project = $project_id AND task_milestone ='0'";
  53. $worked_hours = db_loadResult($sql);
  54. $worked_hours = rtrim($worked_hours, "0");
  55.  
  56. // total hours
  57. // same milestone comment as above, also applies to dynamic tasks
  58. $sql = "SELECT ROUND(SUM(task_duration),2) FROM tasks WHERE task_project = $project_id AND task_duration_type = 24 AND task_milestone ='0' AND task_dynamic = 0";
  59. $days = db_loadResult($sql);
  60. $sql = "SELECT ROUND(SUM(task_duration),2) FROM tasks WHERE task_project = $project_id AND task_duration_type = 1 AND task_milestone  ='0' AND task_dynamic = 0";
  61. $hours = db_loadResult($sql);
  62. $total_hours = $days * $dPconfig['daily_working_hours'] + $hours;
  63. //due to the round above, we don't want to print decimals unless they really exist
  64. $total_hours = rtrim($total_hours, "0");
  65.  
  66. // get the prefered date format
  67. $df = $AppUI->getPref('SHDATEFORMAT');
  68.  
  69. // create Date objects from the datetime fields
  70. $start_date = intval( $obj->project_start_date ) ? new CDate( $obj->project_start_date ) : null;
  71. $end_date = intval( $obj->project_end_date ) ? new CDate( $obj->project_end_date ) : null;
  72. $actual_end_date = intval( $obj->project_actual_end_date ) ? new CDate( $obj->project_actual_end_date ) : null;
  73.  
  74. // setup the title block
  75. $titleBlock = new CTitleBlock( 'View Project', 'applet3-48.png', $m, "$m.$a" );
  76. if ($canEdit) {
  77.     $titleBlock->addCell();
  78.     $titleBlock->addCell(
  79.         '<input type="submit" class="button" value="'.$AppUI->_('new task').'">', '',
  80.         '<form action="?m=tasks&a=addedit&task_project=' . $project_id . '" method="post">', '</form>'
  81.     );
  82. }
  83. $titleBlock->addCrumb( "?m=projects", "projects list" );
  84. if ($canEdit) {
  85.     $titleBlock->addCrumb( "?m=projects&a=addedit&project_id=$project_id", "edit this project" );
  86.     if ($canEdit) {
  87.         $titleBlock->addCrumbDelete( 'delete project', $canDelete, $msg );
  88.     }
  89. }
  90. $titleBlock->addCrumb( "?m=projects&a=reports&project_id=$project_id", "reports" );
  91. $titleBlock->show();
  92. ?>
  93. <script language="javascript">
  94. function delIt() {
  95.     if (confirm( "<?php echo $AppUI->_('doDelete').' '.$AppUI->_('Project').'?';?>" )) {
  96.         document.frmDelete.submit();
  97.     }
  98. }
  99. </script>
  100.  
  101. <table border="0" cellpadding="4" cellspacing="0" width="100%" class="std">
  102.  
  103. <form name="frmDelete" action="./index.php?m=projects" method="post">
  104.     <input type="hidden" name="dosql" value="do_project_aed" />
  105.     <input type="hidden" name="del" value="1" />
  106.     <input type="hidden" name="project_id" value="<?php echo $project_id;?>" />
  107. </form>
  108.  
  109. <tr>
  110.     <td style="border: outset #d1d1cd 1px;background-color:#<?php echo $obj->project_color_identifier;?>" colspan="2">
  111.     <?php
  112.         echo '<font color="' . bestColor( $obj->project_color_identifier ) . '"><strong>'
  113.             . $obj->project_name .'<strong></font>';
  114.     ?>
  115.     </td>
  116. </tr>
  117.  
  118. <tr>
  119.     <td width="50%" valign="top">
  120.         <strong><?php echo $AppUI->_('Details');?></strong>
  121.         <table cellspacing="1" cellpadding="2" border="0" width="100%">
  122.         <tr>
  123.             <td align="right" nowrap><?php echo $AppUI->_('Company');?>:</td>
  124.             <td class="hilite" width="100%"><?php echo htmlspecialchars( $obj->company_name, ENT_QUOTES) ;?></td>
  125.         </tr>
  126.         <tr>
  127.             <td align="right" nowrap><?php echo $AppUI->_('Short Name');?>:</td>
  128.             <td class="hilite"><?php echo htmlspecialchars( @$obj->project_short_name, ENT_QUOTES) ;?></td>
  129.         </tr>
  130.         <tr>
  131.             <td align="right" nowrap><?php echo $AppUI->_('Start Date');?>:</td>
  132.             <td class="hilite"><?php echo $start_date ? $start_date->format( $df ) : '-';?></td>
  133.         </tr>
  134.         <tr>
  135.             <td align="right" nowrap><?php echo $AppUI->_('Target End Date');?>:</td>
  136.             <td class="hilite"><?php echo $end_date ? $end_date->format( $df ) : '-';?></td>
  137.         </tr>
  138.         <tr>
  139.             <td align="right" nowrap><?php echo $AppUI->_('Actual End Date');?>:</td>
  140.             <td class="hilite"><?php echo $actual_end_date ? $actual_end_date->format( $df ) : '-';?></td>
  141.         </tr>
  142.         <tr>
  143.             <td align="right" nowrap><?php echo $AppUI->_('Target Budget');?>:</td>
  144.             <td class="hilite"><?php echo $dPconfig['currency_symbol'] ?><?php echo @$obj->project_target_budget;?></td>
  145.         </tr>
  146.         <tr>
  147.             <td align="right" nowrap><?php echo $AppUI->_('Project Owner');?>:</td>
  148.             <td class="hilite"><?php echo htmlspecialchars( $obj->user_name, ENT_QUOTES) ; ?></td>
  149.         </tr>
  150.         <tr>
  151.             <td align="right" nowrap><?php echo $AppUI->_('URL');?>:</td>
  152.             <td class="hilite"><a href="<?php echo @$obj->project_url;?>" target="_new"><?php echo @$obj->project_url;?></A></td>
  153.         </tr>
  154.         <tr>
  155.             <td align="right" nowrap><?php echo $AppUI->_('Staging URL');?>:</td>
  156.             <td class="hilite"><a href="<?php echo @$obj->project_demo_url;?>" target="_new"><?php echo @$obj->project_demo_url;?></a></td>
  157.         </tr>
  158.         </table>
  159.     </td>
  160.     <td width="50%" rowspan="9" valign="top">
  161.         <strong><?php echo $AppUI->_('Summary');?></strong><br />
  162.         <table cellspacing="1" cellpadding="2" border="0" width="100%">
  163.         <tr>
  164.             <td align="right" nowrap><?php echo $AppUI->_('Status');?>:</td>
  165.             <td class="hilite" width="100%"><?php echo $AppUI->_($pstatus[$obj->project_status]);?></td>
  166.         </tr>
  167.         <tr>
  168.             <td align="right" nowrap><?php echo $AppUI->_('Progress');?>:</td>
  169.             <td class="hilite" width="100%"><?php printf( "%.1f%%", $obj->project_percent_complete );?></td>
  170.         </tr>
  171.         <tr>
  172.             <td align="right" nowrap><?php echo $AppUI->_('Active');?>:</td>
  173.             <td class="hilite" width="100%"><?php echo $obj->project_active ? $AppUI->_('Yes') : $AppUI->_('No');?></td>
  174.         </tr>
  175.         <tr>
  176.             <td align="right" nowrap><?php echo $AppUI->_('Worked Hours');?>:</td>
  177.             <td class="hilite" width="100%"><?php echo $worked_hours ?></td>
  178.         </tr>    
  179.         <tr>
  180.             <td align="right" nowrap><?php echo $AppUI->_('Total Hours');?>:</td>
  181.             <td class="hilite" width="100%"><?php echo $total_hours ?></td>
  182.         </tr>        
  183.         </table>
  184.         <strong><?php echo $AppUI->_('Description');?></strong><br />
  185.         <table cellspacing="0" cellpadding="2" border="0" width="100%">
  186.         <tr>
  187.             <td class="hilite">
  188.                 <?php echo str_replace( chr(10), "<br>", $obj->project_description) ; ?> 
  189.             </td>
  190.         </tr>
  191.         </table>
  192.     </td>
  193. </table>
  194.  
  195. <?php
  196. if ($tab == 1) {
  197.     $_GET['task_status'] = -1;
  198. }
  199. $query_string = "?m=projects&a=view&project_id=$project_id";
  200. // tabbed information boxes
  201. $tabBox = new CTabBox( "?m=projects&a=view&project_id=$project_id", "", $tab );
  202. $tabBox->add( "{$AppUI->cfg['root_dir']}/modules/tasks/tasks", 'Tasks' );
  203. $tabBox->add( "{$AppUI->cfg['root_dir']}/modules/tasks/tasks", 'Tasks (Inactive)' );
  204. $tabBox->add( "{$AppUI->cfg['root_dir']}/modules/projects/vw_forums", 'Forums' );
  205. $tabBox->add( "{$AppUI->cfg['root_dir']}/modules/projects/vw_files", 'Files' );
  206. $tabBox->add( "{$AppUI->cfg['root_dir']}/modules/tasks/viewgantt", 'Gantt Chart' );
  207.  
  208. // settings for tasks
  209. $f = 'all';
  210. $min_view = true;
  211.  
  212. $tabBox->show();
  213. ?>
  214.