Example #1
0
?>
/"  onsubmit="return startCompetitionValidate('<?php 
echo $this->uri->segment(4);
?>
');" > 
<table width="90%" border="0" cellpadding="0" cellspacing="2" align="center">
<tr>
    <td width="26%" height="31" align="right">&nbsp;</td>
    <td width="3%">&nbsp;</td>
    <td colspan="2">&nbsp;</td>
</tr>
<tr>
  <td height="38" align="left"><span class="box_title">Competition Date </span></td>
  <td align="left">:</td>
  <td align="left"><input type="text" value="<?php 
echo getDateDisplay($CompetitionDetails['CompetitionDate']);
?>
" class="tb3" style="width:280px;" tabindex="1" name="StartCompetitionDate" id="StartCompetitionDate" maxlength="20"  onkeyup="trimFirstSpace('StartCompetitionDate');" onkeypress="enterPage('addnewcompetitionbutton', event);" readonly="readonly" /></td>
  <td align="left">&nbsp;</td>
</tr>
<tr>
    <td height="42" align="left"><span class="box_title">Start Time</span></td>
    <td align="left">:</td>
    <td width="63%" align="left">
      <select name="StartCompetitionHour" id="StartCompetitionHour" class="tb_drop" style="width:86px; height:32px; padding-left:8px; margin-top:8px;" tabindex="2" >
        <option value="" class="box_drop">Hour</option>
        <?php 
for ($i = 1; $i <= 12; $i++) {
    ?>
        <option class="box_drop" value="<?php 
    echo $i;
	<tbody>
		<?php 
if (count($CompetitionDetails) > 0) {
    foreach ($CompetitionDetails as $row) {
        ?>
		<tr class="gradeC">
			<td class="left"><?php 
        echo getMaxFieldLength(ucwords($row['CompetitionName']), 25);
        ?>
</td>
              <td class="left"><?php 
        echo getDateDisplay($row['CompetitionDate']);
        ?>
</td>
              <td class="left"><?php 
        echo getDateDisplay($row['CreatedDate']);
        ?>
</td>
			  <td class="center" id="ActionICon<?php 
        echo $row['CompetitionICode'];
        ?>
">
              <?php 
        if ($row['IsCompleted'] == 0) {
            ?>
			   <img src="<?php 
            echo base_url();
            ?>
images/start.png" border="0" width="24" height="24" alt="Started Competition" title="Started Competition" style="cursor:pointer;" onclick="return endcompetition('<?php 
            echo $row['CompetitionICode'];
            ?>
 function setLiteralDate()
 {
     switch ($this->periodType) {
         case DB_ARCHIVES_PERIOD_DAY:
             $typeDateDisplay = 1;
             break;
         case DB_ARCHIVES_PERIOD_WEEK:
             $typeDateDisplay = 6;
             break;
         case DB_ARCHIVES_PERIOD_MONTH:
             $typeDateDisplay = 4;
             break;
         case DB_ARCHIVES_PERIOD_YEAR:
             $typeDateDisplay = 11;
             break;
     }
     $this->literalDate = getDateDisplay($typeDateDisplay, $this->date);
 }
			<th width="41%" align="left">Competition Date			  </th>
			<td width="15%" align="center" class="th_css">Action</td>
		</tr>
	</thead>
	<tbody>
		<?php 
if (!empty($CompetitionDetails)) {
    foreach ($CompetitionDetails as $row) {
        ?>
		<tr class="gradeC">
			<td class="left"><?php 
        echo getMaxFieldLength(ucwords($row['CompetitionName']), 25);
        ?>
</td>
            <td class="left"><?php 
        echo getDateDisplay($row['CompetitionDate']);
        ?>
</td>
            <td class="center" id="ActionICon<?php 
        echo $row['CompetitionICode'];
        ?>
" align="center"><a href="<?php 
        echo base_url();
        ?>
competition/competitionresultpost/<?php 
        echo $row['CompetitionICode'];
        ?>
/" class="tlink">View</a></td>
		</tr>
		<?php 
    }
/**
 * returns the literal date 
 * Ex : if period = DB_ARCHIVES_PERIOD_WEEK and $s_date = "2006-08-14"
 * Returned string will be "Week August 14 To August 20 2006"
 * 
 * @param int period 
 * @param string s_date 
 */
function getLiteralDate($period, $s_date)
{
    switch ($period) {
        case DB_ARCHIVES_PERIOD_DAY:
            return getDateDisplay(1, new Date($s_date));
            break;
        case DB_ARCHIVES_PERIOD_WEEK:
        case DB_ARCHIVES_PERIOD_WEEK:
            $date = new Date($s_date);
            $mon = getFirstDayOfWeek($date);
            $sun = getDateFromTimestamp(mktime(0, 0, 0, $date->getMonth(), $date->getDay() - ($date->getWeekDayNumber() + 6) % 7 + 6, $date->getYear()));
            return getDateDisplay(3, new Date($mon), new Date($sun));
            break;
        case DB_ARCHIVES_PERIOD_MONTH:
            return getDateDisplay(4, new Date($s_date));
            break;
        case DB_ARCHIVES_PERIOD_YEAR:
            return getDateDisplay(11, new Date($s_date));
            break;
        default:
            trigger_error("Period unknown !", E_USER_ERROR);
            break;
    }
    return;
}
 function getLastArchives($n, $boolOnlyGetPeriodNMinus = 0, $dateTextType = DATE_NORMAL, $o_site = false)
 {
     //var_dump($this->archive->date->get());
     $date = new Date($this->archive->date->get());
     //var_dump($date->get());
     if ($o_site) {
         $o_siteToUse = $o_site;
     } else {
         $o_siteToUse = $this->archive->site;
     }
     $toArchive = array();
     switch ($this->archive->periodType) {
         case DB_ARCHIVES_PERIOD_DAY:
             $ts = $date->getTimestamp() + 86400;
             while (sizeof($toArchive) < $n) {
                 $toArchive[] = getDateFromTimestamp($ts -= 86400);
             }
             $typeDateDisplay = 2;
             $typeDateDisplayGraph = 8;
             $typeDateDisplayGraphLongAxis = 13;
             // only take N - x, only for page views comparisons
             if ($boolOnlyGetPeriodNMinus === 1) {
                 $date0 = $toArchive[0];
                 $date1 = $toArchive[7];
                 $date2 = $toArchive[14];
                 unset($toArchive);
                 $toArchive[] = $date0;
                 $toArchive[] = $date1;
                 $toArchive[] = $date2;
                 $typeDateDisplay = 7;
                 //print("date1 $date1 date2 $date2 ");
             }
             break;
         case DB_ARCHIVES_PERIOD_WEEK:
             $ts = $date->getTimestamp();
             $ts += 86400 * 7;
             while (sizeof($toArchive) < $n) {
                 $toArchive[] = getDateFromTimestamp($ts -= 86400 * 7);
             }
             $typeDateDisplay = 6;
             $typeDateDisplayGraph = 6;
             $typeDateDisplayGraphLongAxis = 13;
             break;
         case DB_ARCHIVES_PERIOD_MONTH:
             $s_date1 = getDateFromTimestamp(mktime(23, 59, 59, $date->getMonth() - $n % 12, 15, $date->getYear() - floor($n / 12)));
             $s_date2 = $date->get();
             $toArchive = array_reverse(getDayOfMonthBetween($s_date1, $s_date2));
             $typeDateDisplay = 5;
             $typeDateDisplayGraph = 10;
             $typeDateDisplayGraphLongAxis = 10;
             break;
         case DB_ARCHIVES_PERIOD_YEAR:
             for ($i = 0; $i < $n; $i++) {
                 $a = $date->getYear() - $i;
                 $toArchive[] = $a . "-01-01";
             }
             $typeDateDisplay = 11;
             $typeDateDisplayGraph = 12;
             break;
     }
     //var_dump($this->archive->date->get());
     $return = array();
     foreach ($toArchive as $dateToArchive) {
         //print("boucle :");
         // if day, and IF current date asked is today, then take current archive
         if ($dateToArchive == $this->archive->date->get() && $this->archive->periodType === DB_ARCHIVES_PERIOD_DAY && $o_siteToUse->getId() === $this->archive->site->getId()) {
             $a = $this->archive;
             // erreur possible ici ?
         } else {
             $a = $this->getArchive($o_siteToUse, $dateToArchive, $this->archive->periodType);
         }
         if ($dateTextType == DATE_GRAPH) {
             $dateToDisplay = getDateDisplay($typeDateDisplayGraph, new Date($dateToArchive));
             $dateComputed = getDateDisplay($typeDateDisplayGraph, $a->date);
         } else {
             if ($dateTextType == DATE_NORMAL) {
                 $dateToDisplay = getDateDisplay($typeDateDisplay, new Date($dateToArchive));
                 $dateComputed = getDateDisplay($typeDateDisplay, $a->date);
             } else {
                 if ($dateTextType == DATE_GRAPH_LONG_AXIS) {
                     $dateToDisplay = getDateDisplay($typeDateDisplayGraphLongAxis, new Date($dateToArchive));
                     $dateComputed = getDateDisplay($typeDateDisplayGraphLongAxis, $a->date);
                 }
             }
         }
         if ($this->archive->periodType === DB_ARCHIVES_PERIOD_WEEK) {
             $firstDayOfWeek = new Date(getFirstDayOfWeek(new Date($dateToArchive)));
             $minDay = $o_siteToUse->getMinDay();
             if ($firstDayOfWeek->getTimestamp() >= $minDay->getTimestamp()) {
                 $dateToDisplay = getDateDisplay($typeDateDisplay, $firstDayOfWeek);
             }
         }
         if ($dateComputed == $dateToDisplay) {
             //				print("$dateToDisplay is correctly computed ($dateComputed)<br>");
             $return[$dateComputed] = $a;
         } else {
             //				print("$dateToDisplay is not correctly computed ($dateComputed) ==> empty archive<br>");
             $return[$dateToDisplay] = $this->getEmptyArchive($o_siteToUse, $dateToArchive, $this->archive->periodType);
         }
     }
     //print("\n\n");exit;
     return $return;
 }