/**
     * @return string
     */
    protected function getEquipmentCode()
    {
        $Code = '
			<table class="fullwidth zebra-style c">
				<thead>
					<tr>
						<th>' . __('Name') . '</th>
						<th>' . __('Category') . '</th>
						<th>' . __('prev. distance') . '</th>
						<th>' . __('Start of use') . '</th>
						<th>' . __('End of use') . '</th>
						<th>' . __('Notes') . '</th>
						<th>' . __('delete') . ' ' . $this->getDeleteIcon() . '</th>
					</tr>
				</thead>
				<tbody>';
        $Types = $this->Model->allEquipmentTypes();
        $Equipments = $this->Model->allEquipments();
        $Equipments[] = new Equipment\Entity();
        foreach ($Equipments as $Equipment) {
            $isNew = !$Equipment->hasID();
            $id = $isNew ? -1 : $Equipment->id();
            $delete = $isNew ? '' : '<input type="checkbox" class="delete-checkbox" name="equipment[delete][' . $id . ']">';
            $Code .= '
					<tr class="' . ($isNew ? ' unimportant' : '') . '">
						<td><input type="text" size="30" name="equipment[name][' . $id . ']" value="' . $Equipment->name() . '"></td>
						<td><select name="equipment[typeid][' . $id . ']">';
            foreach ($Types as $Type) {
                $Code .= '<option value="' . $Type->id() . '"' . HTML::Selected($Type->id() == $Equipment->typeid()) . '>' . $Type->name() . '</option>';
            }
            $AdditionalDistance = new Distance($Equipment->additionalDistance());
            $Code .= '</select></td>
						<td><span class="input-with-unit"><input type="text" class="small-size" name="equipment[additional_km][' . $id . ']" value="' . round($AdditionalDistance->valueInPreferredUnit()) . '"><label class="input-unit">' . $AdditionalDistance->unit() . '</label></span></td>
						<td><input type="text" class="small-size pick-a-date" placeholder="dd.mm.YYYY" name="equipment[date_start][' . $id . ']" value="' . $this->datetimeToString($Equipment->startDate()) . '"></td>
						<td><input type="text" class="small-size pick-a-date" placeholder="dd.mm.YYYY" name="equipment[date_end][' . $id . ']" value="' . $this->datetimeToString($Equipment->endDate()) . '"></td>
						<td><input type="text" size="fullwidth" name="equipment[notes][' . $id . ']" value="' . $Equipment->notes() . '"></td>
						<td>' . $delete . '</td>
					</tr>';
        }
        $Code .= '
			</tbody>
		</table>';
        return $Code;
    }
Example #2
0
 /**
  * Add line for average and goal
  */
 protected function addAverage()
 {
     if ($this->showsAverage()) {
         $BasicEndurance = new BasicEndurance();
         $BasicEndurance->readSettingsFromConfiguration();
         $Result = $BasicEndurance->asArray();
         $Avg = new Distance($this->factorForWeekKm() * $Result['weekkm-percentage'] * $BasicEndurance->getTargetWeekKm());
         $Goal = new Distance($this->factorForWeekKm() * $BasicEndurance->getTargetWeekKm());
         $LabelKeys = array_keys($this->getXLabels());
         $this->addThreshold('y', round($Avg->valueInPreferredUnit()), '#999');
         $this->addThreshold('y', round($Goal->valueInPreferredUnit()), '#999');
         $this->addAnnotation(-1, round($Avg->valueInPreferredUnit()), __('avg:') . '&nbsp;' . $Avg->string(true, 0), 0, -10);
         $this->addAnnotation(end($LabelKeys), round($Goal->valueInPreferredUnit()), __('goal:') . '&nbsp;' . $Goal->string(true, 0), 0, -10);
     }
 }