public function index()
 {
     $user = \Auth::user();
     $times = $user->times;
     $today = new \Datetime("today");
     $factory = new \CalendR\Calendar();
     $month = $factory->getMonth($today->format('Y'), $today->format('m'));
     return view('dashboard.index', ['user' => $user, 'times' => $times, 'today' => $today, 'factory' => $factory, 'month' => $month]);
 }
 public function index(Request $request)
 {
     $this->view->title = 'Crews';
     $this->view->breadcrumbs = ['crews' => 'Crews'];
     $this->view->crews = Crew::orderBy('name', 'ASC')->get();
     $calendar = new \CalendR\Calendar();
     $this->view->months = [];
     $now = new \DateTime('First day of this month');
     for ($i = 0; $i < 6; $i++) {
         $this->view->months[] = $calendar->getMonth($now);
         $now->add(new \DateInterval('P1M'));
     }
     return $this->view;
 }
Esempio n. 3
0
 /**
  * Test: Invalid Constructor (Lazy)
  *
  * @access public
  * @dataProvider providerConstructInvalid
  * @return void
  */
 public function testConstructInvalidLazy($start)
 {
     $calendar = new \CalendR\Calendar();
     $calendar->setStrictDates(false);
     new Minute($start, $calendar->getFactory());
 }
Esempio n. 4
0
 public function calendar($args)
 {
     // @todo Validate args.
     $yearNum = isset($args['year']) ? $args['year'] : date('Y');
     $monthNum = isset($args['month']) ? $args['month'] : date('m');
     $template = new \WordPress\Tabulate\Template('calendar.html');
     $table = $this->get_table($args['table']);
     $template->table = $table;
     $template->action = 'calendar';
     $template->record = $table->get_default_record();
     $factory = new \CalendR\Calendar();
     $template->weekdays = $factory->getWeek(new \DateTime('Monday this week'));
     $month = $factory->getMonth(new \DateTime($yearNum . '-' . $monthNum . '-01'));
     $template->month = $month;
     $records = array();
     foreach ($table->get_columns('date') as $dateCol) {
         $dateColName = $dateCol->get_name();
         // Filter to the just the requested month.
         $table->add_filter($dateColName, '>=', $month->getBegin()->format('Y-m-d'));
         $table->add_filter($dateColName, '<=', $month->getEnd()->format('Y-m-d'));
         foreach ($table->get_records() as $rec) {
             $dateVal = $rec->{$dateColName}();
             // Initialise the day's list of records.
             if (!isset($records[$dateVal])) {
                 $records[$dateVal] = array();
             }
             // Add this record to the day's list.
             $records[$dateVal][] = $rec;
         }
     }
     // $records is grouped by date, with each item in a single date being
     // an array like: ['record'=>Record, 'column'=>$name_of_date_column]
     $template->records = $records;
     return $template->render();
 }
function cfs_lfq_calendar($args)
{
    if (CFS_LFQ_POST_TYPE) {
        $defaults = array('dates' => array(), 'months' => array(), 'weekdayLabel' => 'default', 'weekdayBase' => 0, 'element' => 'div', 'class' => '');
        $d = wp_parse_args($args, $defaults);
        extract($d, EXTR_SKIP);
        $locale = new WP_Locale();
        if ($weekdayLabel == 'en') {
            $wd = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
        } else {
            $wd = array_values($locale->weekday_abbrev);
        }
        $wd_en = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
        $today = date_i18n('Ymd');
        $factory = new CalendR\Calendar();
        $num = 1;
        foreach ($months as $month) {
            $month = $month . "01";
            $month = $factory->getMonth(date('Y', strtotime($month)), date('m', strtotime($month)));
            ?>
	<<?php 
            echo esc_html($element);
            ?>
 class="calendar-<?php 
            echo $num;
            ?>
 calendar-<?php 
            echo date('Y', strtotime($month)) . "-" . date('m', strtotime($month));
            if ($class) {
                ?>
 <?php 
                echo esc_html($class);
            }
            ?>
">
        <header>
        	<h4><?php 
            echo $month->format('M');
            ?>
</h4>
        </header>
        <table cellspacing="0" cellpadding="0" border="0">
            <thead>
				<tr>
					<?php 
            for ($i = 0; $i < 7; ++$i) {
                $weekday = ($weekdayBase + $i) % 7;
                $weekdayText = $wd[$weekday];
                $weekdayEn = $wd_en[$weekday];
                echo '<th class="dayweek ' . $weekdayEn . '">' . $weekdayText . '</th>';
            }
            ?>
				</tr>
        	</thead>
        	<tbody>
                <?php 
            foreach ($month as $week) {
                ?>
                    <tr>
                        <?php 
                foreach ($week as $day) {
                    ?>
                            <td class="<?php 
                    echo mb_strtolower($day->format('D'));
                    if ($day->format('Ymd') === $today) {
                        ?>
 today<?php 
                    }
                    if (!$month->includes($day)) {
                        ?>
 out-of-month<?php 
                    }
                    ?>
">
                                <?php 
                    if ($month->includes($day) && in_array($day->format('Ymd'), $dates)) {
                        $href = get_post_type_date_link(CFS_LFQ_POST_TYPE, $day->format('Y'), $day->format('m'), $day->format('d'));
                        $dayText = '<a href="' . $href . '"><span>' . $day->format('j') . '</span></a>';
                    } else {
                        $dayText = $day->format('j');
                    }
                    echo $dayText;
                    ?>
                            </td>
                        <?php 
                }
                ?>
                    </tr>
                <?php 
            }
            ?>
            </tbody>
        </table>
	</<?php 
            echo esc_html($element);
            ?>
>
<?php 
            $num++;
        }
    }
}
Esempio n. 6
0
 public static function providerGetFirstMondayAndLastSunday()
 {
     $factory = new \CalendR\Calendar();
     return array(array($factory->getMonth(2012, 1), '2011-12-26', '2012-02-05'), array($factory->getMonth(2012, 2), '2012-01-30', '2012-03-04'), array($factory->getMonth(2012, 3), '2012-02-27', '2012-04-01'), array($factory->getMonth(2012, 9), '2012-08-27', '2012-09-30'), array($factory->getMonth(2012, 10), '2012-10-01', '2012-11-04'), array($factory->getMonth(2012, 12), '2012-11-26', '2013-01-06'));
 }