Exemple #1
0
  function getProjectSteps($json, $htt='editor_projects.htt') {
   $loop = "";
   
   $usergroup = $this->userdetails->usergroup;
//   ajax_echo_r ($usergroup);
   $json->IsFull = $this->getIsFull();
//   ajax_echo_r ($json);
   
   if ($json->ID) $json->ProjectID = $json->ID;
   if ((!$json->DateMeasure) || (!$json->DateInstall)) {
    $project = $this->model->getProject($json->ProjectID);
    $json->DateMeasure = $project->DateMeasure;
    $json->DateInstall = $project->DateInstall;
    $json->HasDoors    = $project->HasDoors;
   }
//   ajax_echo_r ($json);
//   ajax_echo_r ($project);
   
   if ($json->ProjectID) {
    $loop_par = new Template($this->viewroot, $htt);                                        // load common parent template
    $loop_par = $this->fillStricts($loop_par);
    
    $loop_par->fill(  '%ProjectID%', $json->ProjectID          );
    $loop_par->fill(  '%imgfolder%', $this->imgfolder          );
    $loop_par->fill(   '%viewroot%', $this->viewroot           );
    
    $loop_step  = new Template($this->viewroot, $loop_par->returnloop('loop_step' ));
    $loop_stepa = new Template($this->viewroot, $loop_par->returnloop('loop_stepa'));
    
    $loop_files  = new Template($this->viewroot, $loop_step->returnloop('loop_files' ));
    $loop_filesa = new Template($this->viewroot, $loop_stepa->returnloop('loop_filesa'));
    
    $list = $this->model->getProjectSteps($json);
    $list = $this->model->getProjectStepsPictures($json, $list);
//    ajax_echo_r ($list);
    
    $prevMode = 'active';
    
    $daynames = getDayNames();
    
    $n = 1;
    $vars  = $loop_step->getVariables();
    $varsa = $loop_stepa->getVariables();
    if (sizeof($list)) {
     foreach ($list as $data) {
//      ajax_echo_r ($data);
      $k = 'Step'.$data->ID;
      if (((($data->ID==12) && ($json->HasDoors)) || ($data->ID!=12)) && ($usergroup->$k>0)) {
//      ajax_echo_r ($data);
       $Auxinfo = "";
       if (($data->NeedDate)) {
        switch ($data->ID) {
         case (2):
          if ($data->Mode=='active') {
           $data->Auxinfo = dateTimeAdaptRead($json->DateMeasure).", ".$daynames[dayWeekAdaptRead($json->DateMeasure)];
          } else {
 //          $data->Auxinfo = "...";
          }
         break;
         case (13):
          if ($data->Mode=='active') {
           $data->Auxinfo = dateTimeAdaptRead($json->DateInstall).", ".$daynames[dayWeekAdaptRead($json->DateInstall)];
          } else {
 //          $data->Auxinfo = "...";
          }
         break;
        }
       }
       
       if (($prevMode!=$data->Mode) && ($usergroup->$k==2)) {
        $prevMode=$data->Mode;
        $loop_stepa->reload();
        
        $loop_stepa->fill('%last%', ($n==sizeof($list)?"hidden":""));
        
        $files_str = "";
        if ($data->Files) {
         foreach ($data->Files as $File) {
          $loop_filesa->reload();
          $filename = $File;
          $loop_filesa->fill(      '%filename%', $filename);
          $loop_filesa->fill( '%filename_full%', str_replace("thb_", "full_", $filename));
          $files_str .= $loop_filesa->output();
         }
        }
        $loop_stepa->fillloop('loop_filesa', $files_str);
        
        foreach ($varsa as $var) {
         if ($var) {
          $loop_stepa->fill(       "%".$var."%" , $data->$var);
         }
        }
        $loop.=$loop_stepa->output();
       } else {
        $loop_step->reload();
        
        $loop_step->fill('%last%', ($n==sizeof($list)?"hidden":""));
        
        
        $files_str = "";
        if ($data->Files) {
         foreach ($data->Files as $File) {
          $loop_files->reload();
          $filename = $File;
          $loop_files->fill(      '%filename%', $filename);
          $loop_files->fill( '%filename_full%', str_replace("thb_", "full_", $filename));
          $files_str .= $loop_files->output();
         }
        }
        $loop_step->fillloop('loop_files', $files_str);
        
        foreach ($vars as $var) {
         if ($var) {
          $loop_step->fill(       "%".$var."%" , $data->$var);
         }
        }
        $loop.=$loop_step->output();
       }
      }
      $n++;
     }
    }
   }
   
   return localize($loop);                                               // show it
  }
Exemple #2
0
 /**
  * displayCalendarMonth 
  * 
  * Displays a month view of the calendar based on the month, day and year.
  *
  * NOTE: Dates are assumed already fixed for timezone and dst.
  * 
  * @param int $month 
  * @param int $year 
  * @param int $day 
  * 
  * @return  void
  */
 function displayCalendarMonth($month = 0, $year = 0, $day = 0)
 {
     if ($month == 0) {
         $year = fixDate('Y', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
         $month = fixDate('m', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
         $day = fixDate('d', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
     }
     $year = (int) $year;
     $month = (int) $month;
     $month = str_pad($month, 2, 0, STR_PAD_LEFT);
     $day = (int) $day;
     $day = str_pad($day, 2, 0, STR_PAD_LEFT);
     $weekDays = getDayNames();
     $categories = $this->getCategories();
     $eventDays = $this->getEventDays($month, $year);
     // First day of the month starts on which day?
     $first = mktime(0, 0, 0, $month, 1, $year);
     $offset = date('w', $first);
     // Fix offset - if day of week changed
     if ($this->weekStartOffset > 0) {
         $offset = $offset + (7 - $this->weekStartOffset);
         if ($offset >= 7) {
             $offset = $offset - 7;
         }
     }
     $daysInMonth = date('t', $first);
     // Previous month links
     $prevTS = strtotime("{$year}-{$month}-01 -1 month");
     // Make sure previous day is less than the total num of days in prev month
     $pDay = $day > date('t', $prevTS) ? date('t', $prevTS) : $day;
     list($pYear, $pMonth) = explode('-', date('Y-m', $prevTS));
     // Today links
     $tYear = fixDate('Y', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
     $tMonth = fixDate('m', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
     $tDay = fixDate('d', $this->fcmsUser->tzOffset, gmdate('Y-m-d H:i:s'));
     // Next month links
     $nextTS = strtotime("{$year}-{$month}-01 +1 month");
     // Make sure next day is less than the total num of days in next month
     $nDay = $day > date('t', $nextTS) ? date('t', $nextTS) : $day;
     list($nYear, $nMonth) = explode('-', date('Y-m', $nextTS));
     // Display the month
     echo '
         <table id="big-calendar" cellpadding="0" cellspacing="0">
             <tr>
                 <th colspan="2">
                     <a class="prev" href="?year=' . $pYear . '&amp;month=' . $pMonth . '&amp;day=' . $pDay . '">' . T_('Previous') . '</a> 
                     <a class="today" href="?year=' . $tYear . '&amp;month=' . $tMonth . '&amp;day=' . $tDay . '">' . T_('Today') . '</a> 
                     <a class="next" href="?year=' . $nYear . '&amp;month=' . $nMonth . '&amp;day=' . $nDay . '">' . T_('Next') . '</a>
                 </th>
                 <th colspan="3"><h3>' . formatDate('F Y', "{$year}-{$month}-{$day}") . '</h3></th>
                 <th class="views" colspan="2">
                     <a class="day" href="?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $day . '&amp;view=day">' . T_('Day') . '</a> | 
                     <a class="month" href="?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $day . '">' . T_('Month') . '</a>
                 </th>
             </tr>
             <tr>';
     // Weekday names
     for ($w = 0; $w <= 6; $w++) {
         echo '
                 <td class="weekDays">' . $weekDays[($w + $this->weekStartOffset) % 7] . '</td>';
     }
     echo '
             </tr>';
     $i = 0;
     // Display the days in the month, fill with events
     for ($d = 1 - $offset; $d <= $daysInMonth; $d++) {
         // start new row
         if ($i % 7 == 0) {
             echo '
             <tr>';
         }
         // display cell for date outside of this month
         if ($d < 1) {
             echo '
                 <td class="nonMonthDay">&nbsp;</td>';
         } else {
             // today
             if ($d == $day) {
                 echo '
                 <td class="monthToday">';
             } else {
                 echo '
                 <td class="monthDay">';
             }
             // add the add cal date link
             if ($this->fcmsUser->access <= 5) {
                 echo '<a class="add" href="?add=' . $year . '-' . $month . '-' . $d . '">' . T_('Add') . '</a>';
             }
             // display the day #
             echo '<a href="?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $d . '&amp;view=day">' . $d . '</a>';
             // display the events for each day
             if (in_array($d, $eventDays)) {
                 $this->displayEvents($month, $d, $year);
             }
             echo "</td>";
         }
         $i++;
         // if we have 7 <td> for the current week close the <tr>
         if ($i % 7 == 0) {
             echo '
             </tr>';
         }
     }
     // close any opening <tr> and insert any additional empty <td>
     if ($i % 7 != 0) {
         for ($j = 0; $j < 7 - $i % 7; $j++) {
             echo '
                 <td class="nonMonthDay">&nbsp;</td>';
         }
         echo '
             </tr>';
     }
     // Display the bottom menu of calendar
     echo '
             <tr class="actions">
                 <td style="text-align:left;" colspan="3">
                     <b>' . T_('Categories') . '</b><br/>
                     <ul id="category_menu">' . $categories . '
                         <li><a href="?category=add">' . T_('Add Category') . '</a></li>
                     </ul>
                 </td>
                 <td colspan="4">
                     ' . T_('Actions') . ': 
                     <a class="print" href="#" 
                         onclick="window.open(\'calendar.php?year=' . $year . '&amp;month=' . $month . '&amp;day=' . $day . '&amp;print=1\',
                         \'name\',\'width=700,height=400,scrollbars=yes,resizable=yes,location=no,menubar=no,status=no\'); 
                         return false;">' . T_('Print') . '</a> | 
                     <a href="?import=true">' . T_('Import') . '</a> | 
                     <a href="?export=true">' . T_('Export') . '</a>
                 </td>
             </tr>
         </table>';
 }
Exemple #3
0
/**
 * getDayName 
 * 
 * Given a number of the weekday 0-6, returns the translated word for that day.
 * 
 * @param int $d 
 * 
 * @return string
 */
function getDayName($d)
{
    $day = getDayNames();
    return $day[$d];
}