home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / calendar / index.php < prev    next >
Encoding:
PHP Script  |  2003-12-13  |  3.2 KB  |  94 lines

  1. <?php /* CALENDAR $Id: index.php,v 1.26 2003/12/12 20:15:06 gregorerhardt Exp $ */
  2. $AppUI->savePlace();
  3.  
  4. dPsetMicroTime();
  5.  
  6. require_once( $AppUI->getModuleClass( 'companies' ) );
  7. require_once( $AppUI->getModuleClass( 'tasks' ) );
  8.  
  9. // retrieve any state parameters
  10. if (isset( $_REQUEST['company_id'] )) {
  11.     $AppUI->setState( 'CalIdxCompany', intval( $_REQUEST['company_id'] ) );
  12. }
  13. $company_id = $AppUI->getState( 'CalIdxCompany' ) !== NULL ? $AppUI->getState( 'CalIdxCompany' ) : $AppUI->user_company;
  14.  
  15. // get the passed timestamp (today if none)
  16. $date = dPgetParam( $_GET, 'date', null );
  17.  
  18. // get the list of visible companies
  19. $company = new CCompany();
  20. $companies = $company->getAllowedRecords( $AppUI->user_id, 'company_id,company_name', 'company_name' );
  21. $companies = arrayMerge( array( '0'=>$AppUI->_('All') ), $companies );
  22.  
  23. #echo '<pre>';print_r($events);echo '</pre>';
  24. // setup the title block
  25. $titleBlock = new CTitleBlock( 'Monthly Calendar', 'myevo-appointments.png', $m, "$m.$a" );
  26. $titleBlock->addCell( $AppUI->_('Company').':' );
  27. $titleBlock->addCell(
  28.     arraySelect( $companies, 'company_id', 'onChange="document.pickCompany.submit()" class="text"', $company_id ), '',
  29.     '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="pickCompany">', '</form>'
  30. );
  31. $titleBlock->show();
  32. ?>
  33.  
  34. <script language="javascript">
  35. function clickDay( uts, fdate ) {
  36.     window.location = './index.php?m=calendar&a=day_view&date='+uts;
  37. }
  38. function clickWeek( uts, fdate ) {
  39.     window.location = './index.php?m=calendar&a=week_view&date='+uts;
  40. }
  41. </script>
  42.  
  43. <table cellspacing="0" cellpadding="0" border="0" width="100%"><tr><td>
  44. <?php
  45. // establish the focus 'date'
  46. $date = new CDate( $date );
  47.  
  48. // prepare time period for 'events'
  49. $first_time = new CDate( $date );
  50. $first_time->setDay( 1 );
  51. $first_time->setTime( 0, 0, 0 );
  52. $first_time->subtractSeconds( 1 );
  53. $last_time = new CDate( $date );
  54. $last_time->setDay( $date->getDaysInMonth() );
  55. $last_time->setTime( 23, 59, 59 );
  56.  
  57. $links = array();
  58.  
  59. // assemble the links for the tasks
  60. require_once( $AppUI->getConfig( 'root_dir' )."/modules/calendar/links_tasks.php" );
  61. getTaskLinks( $first_time, $last_time, $links, 20, $company_id );
  62.  
  63. // assemble the links for the events
  64. require_once( $AppUI->getConfig( 'root_dir' )."/modules/calendar/links_events.php" );
  65. getEventLinks( $first_time, $last_time, $links, 20 );
  66.  
  67. // create the main calendar
  68. $cal = new CMonthCalendar( $date  );
  69. $cal->setStyles( 'motitle', 'mocal' );
  70. $cal->setLinkFunctions( 'clickDay', 'clickWeek' );
  71. $cal->setEvents( $links );
  72.  
  73. echo $cal->show();
  74. //echo '<pre>';print_r($cal);echo '</pre>';
  75.  
  76. // create the mini previous and next month calendars under
  77. $minical = new CMonthCalendar( $cal->prev_month );
  78. $minical->setStyles( 'minititle', 'minical' );
  79. $minical->showArrows = false;
  80. $minical->showWeek = false;
  81. $minical->clickMonth = true;
  82. $minical->setLinkFunctions( 'clickDay' );
  83.  
  84. echo '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>';
  85. echo '<td valign="top" align="center" width="200">'.$minical->show().'</td>';
  86. echo '<td valign="top" align="center" width="100%"> </td>';
  87.  
  88. $minical->setDate( $cal->next_month );
  89.  
  90. echo '<td valign="top" align="center" width="200">'.$minical->show().'</td>';
  91. echo '</tr></table>';
  92. ?>
  93. </td></tr></table>
  94.