コード例 #1
0
    public function printStats()
    {
        list($totals, $breakdowns) = $this->getStats();
        if ((int) $this->congregationid) {
            $headcount = Headcount::fetch('congregation', $this->date, $this->congregationid);
        } else {
            $headcount = Headcount::fetch('person_group', $this->date, $this->groupid);
        }
        ?>
		<table class="table valign-middle attendance-stats table-bordered" style="width: 40ex">
		<?php 
        if ($headcount) {
            ?>
			<tr class="headcount">
				<th><?php 
            echo _('Total Headcount');
            ?>
</th>
				<td colspan="3">
					<b>
					<?php 
            echo $headcount;
            ?>
					</b>
				</td>
			</tr>
			<?php 
        }
        foreach (array(1 => 'Present', 0 => 'Absent') as $present => $label) {
            ?>
			<tr class="<?php 
            echo strtolower($label);
            ?>
">
				<th rowspan="<?php 
            echo count($breakdowns[$present]);
            ?>
">Marked <?php 
            echo $label;
            ?>
</th>
				<td rowspan="<?php 
            echo count($breakdowns[$present]);
            ?>
">
					<b><?php 
            echo $totals[$present];
            ?>
</b>
				</td>
			<?php 
            if (!empty($breakdowns[$present])) {
                ?>
				<td><?php 
                echo $breakdowns[$present][0]['status'];
                ?>
</td>
				<td><?php 
                echo $breakdowns[$present][0]['total'];
                ?>
</td>
				<?php 
            } else {
                ?>
				<td>&nbsp;</td>
				<td>&nbsp;</td>
				<?php 
            }
            ?>
			</tr>
			<?php 
            for ($i = 1; $i < count($breakdowns[$present]); $i++) {
                ?>
				<tr class="<?php 
                echo strtolower($label);
                ?>
">
					<td><?php 
                echo $breakdowns[$present][$i]['status'];
                ?>
</td>
					<td><?php 
                echo $breakdowns[$present][$i]['total'];
                ?>
</td>
				</tr>
				<?php 
            }
        }
        if ($headcount) {
            ?>
			<tr class="extras">
				<th>Extras</th>
				<td colspan="3"><b><?php 
            echo $headcount - $totals[1];
            ?>
</b></td>
			</tr>
			<?php 
        }
        ?>
		</table>
		<?php 
    }
コード例 #2
0
    function printView()
    {
        if (empty($this->_record_sets)) {
            // STEP 1 - choose congregation and date
            ?>
			<form method="get" class="well well-small clearfix">
				<input type="hidden" name="view" value="<?php 
            echo $_REQUEST['view'];
            ?>
" />
				<table class="attendance-config-table valign-middle">
					<tr>
						<th>For</th>
						<td colspan="2" class="fill-me">
							<?php 
            print_widget('age_bracket', array('type' => 'select', 'options' => array('' => 'All age brackets') + explode(',', AGE_BRACKET_OPTIONS), 'default' => '', 'allow_empty' => false), $this->_age_bracket);
            ?>
						</td>
					</tr>
					<tr>
						<th rowspan="2">In</th>
						<td class="valign-top">
							<label class="radio">
								<input type="radio" name="for_type" 
									value="congregationid" id="for_type_congregation" 
									data-toggle="enable" data-target="#congregationchooser select"
									<?php 
            if (empty($this->_groupid)) {
                echo 'checked="checked"';
            }
            ?>
								>
								Congregation(s) &nbsp;
							</label>
						</td>
						<td class="fill-me">
							<table id="congregationchooser" class="expandable table-condensed no-padding" cellspacing="0">
						<?php 
            $congs = $this->_congregationids ? $this->_congregationids : array(0);
            foreach ($congs as $congid) {
                ?>
							<tr>
								<td>
								<?php 
                print_widget('congregationid[]', array('type' => 'reference', 'references' => 'congregation', 'order_by' => 'name', 'allow_empty' => true, 'empty_text' => '-- Choose --'), $congid);
                ?>
								</td>
							</tr>
							<?php 
            }
            ?>
							</table>
						</td>
					</tr>
					<tr>
						<td>
							<label class="radio">
								<input type="radio" name="for_type" 
									value="groupid" id="for_type_group"
									data-toggle="enable" data-target="#groupchooser select" 
									<?php 
            if (!empty($this->_groupid)) {
                echo 'checked="checked"';
            }
            ?>
								>
								Group
							</label>
						</td>
						<td class="fill-me" id="groupchooser">
							<?php 
            print_widget('groupid', array('type' => 'reference', 'references' => 'person_group', 'filter' => array('can_record_attendance' => '1', 'is_archived' => 0)), $this->_groupid);
            ?>
						</td>
					</tr>
					<tr>
						<th>On</th>
						<td colspan="2">
							<?php 
            print_widget('attendance_date', array('type' => 'date'), $this->_attendance_date);
            ?>
						</td>
					</tr>
				<?php 
            if ($GLOBALS['system']->featureEnabled('PHOTOS')) {
                ?>
					<tr>
						<th></th>
						<td>
							<label class="checkbox">
								<input type="checkbox" name="show_photos" value="1" <?php 
                if ($this->_show_photos) {
                    echo 'checked="checked"';
                }
                ?>
 />
								Show photos
							</label>
						</td>
					</tr>
					<?php 
            }
            ?>
				</table>
				<button type="submit" class="btn attendance-config-submit">Continue <i class="icon-chevron-right"></i></button>
				<input type="hidden" name="params_submitted" value="1" />
			</form>
			<?php 
        } else {
            if (empty($_POST['attendances_submitted'])) {
                $_SESSION['enter_attendance_token'] = md5(time());
                // STEP 2 - enter attendances
                ob_start();
                ?>
			<form method="post" class="attendance warn-unsaved" action="?view=attendance__record">
				<input type="hidden" name="for_type" value="<?php 
                echo ents($_REQUEST['for_type']);
                ?>
" />
				<input type="hidden" name="attendance_date" value="<?php 
                echo $this->_attendance_date;
                ?>
" />
				<input type="hidden" name="age_bracket" value="<?php 
                echo $this->_age_bracket;
                ?>
" />
				<input type="hidden" name="show_photos" value="<?php 
                echo $this->_show_photos;
                ?>
" />
				<input type="hidden" name="enter_attendance_token" value="<?php 
                echo $_SESSION['enter_attendance_token'];
                ?>
" />
				<input type="hidden" name="attendances_submitted" value="1" />

				<p class="visible-desktop smallprint">For greatest speed, press P for present and A for absent.  The cursor will automatically progress to the next person.  To go back, use the arrow keys.</p>
				<?php 
                $totalPrinted = 0;
                foreach ($this->_record_sets as $i => $set) {
                    if ((int) $set->congregationid) {
                        ?>
						<input type="hidden" name="congregationid[]" value="<?php 
                        echo $set->congregationid;
                        ?>
" />
						<?php 
                        $congregation = $GLOBALS['system']->getDBObject('congregation', (int) $set->congregationid);
                        $title = $congregation->getValue('name') . ' Congregation';
                    } else {
                        if ($set->groupid) {
                            $group =& $GLOBALS['system']->getDBObject('person_group', $set->groupid);
                            $title = $group->getValue('name') . ' Group';
                            ?>
						<input type="hidden" name="groupid" value="<?php 
                            echo $set->groupid;
                            ?>
" />
						<?php 
                        } else {
                            return;
                        }
                    }
                    if (strlen($set->age_bracket)) {
                        $GLOBALS['system']->includeDBClass('person');
                        $p = new Person();
                        $p->setValue('age_bracket', $set->age_bracket);
                        $title = $p->getFormattedValue('age_bracket') . ' in ' . $title;
                    }
                    ?>
					<h3><?php 
                    echo ents($title);
                    ?>
</h3>
					<div class="width-really-auto form-inline">
						<?php 
                    $setPrinted = $set->printForm($i);
                    if ($setPrinted > 0) {
                        $totalPrinted += $setPrinted;
                        if ((int) $set->congregationid) {
                            $headcountFieldName = 'headcount[congregation][' . $set->congregationid . ']';
                            $headcountValue = Headcount::fetch('congregation', $this->_attendance_date, $set->congregationid);
                        } else {
                            $headcountFieldName = 'headcount[group][' . $set->groupid . ']';
                            $headcountValue = Headcount::fetch('person_group', $this->_attendance_date, $set->groupid);
                        }
                        ?>
							<div class="container row-fluid control-group">
								<p class="span6">
									Total headcount:
									<input type="text" class="int-box" name="<?php 
                        echo $headcountFieldName;
                        ?>
" value="<?php 
                        echo $headcountValue;
                        ?>
" size="5" />
								</p>
								<p class="span6 align-right nowrap">
									<input type="submit" class="btn" value="Save All Attendances" />
									<a href="?view=attendance__record" class="btn">Cancel</a>
								</p>
							</div>
							<?php 
                    } else {
                        ?>
							<i>(No persons in this listing)</i>
							<?php 
                    }
                    ?>
					</div>
					<?php 
                }
                ?>
			</form>
			<?php 
                if (ini_get('max_input_vars') && $totalPrinted > ini_get('max_input_vars')) {
                    ob_end_clean();
                    print_message("The parameters you have selected will list more persons " . "than your server can process.  Please narrow down your parameters, " . "or ask your server administrator to increase the PHP max_input_vars setting" . " (currently " . ini_get('max_input_vars') . ')', 'error');
                } else {
                    ob_flush();
                }
            } else {
                // STEP 3 - confirmation
                foreach ($this->_record_sets as $set) {
                    if ($set->congregationid) {
                        $congregation = $GLOBALS['system']->getDBObject('congregation', (int) $set->congregationid);
                        $title = $congregation->getValue('name') . ' congregation';
                    } else {
                        $group =& $GLOBALS['system']->getDBObject('person_group', $set->groupid);
                        $title = $group->getValue('name') . ' group';
                    }
                    echo '<h3>' . $title . '</h3>';
                    $set->printStats();
                }
                ?>
			<p><a href="?view=<?php 
                echo $_REQUEST['view'];
                ?>
"><i class="icon-pencil"></i>Record more attendances</a></p>
			<p><a href="?view=persons__reports"><i class="icon-list"></i>Analyse attendance using a person report</a></p>
			<?php 
            }
        }
    }