Esempio n. 1
0
 /**
  * @return \Runalyze\Activity\Pace
  */
 public function pace()
 {
     if (null == $this->LapPace) {
         $this->LapPace = new Pace($this->LapDuration->seconds(), $this->LapDistance->kilometer());
     }
     return $this->LapPace;
 }
Esempio n. 2
0
 /**
  * Subtract another distance
  * @param \Runalyze\Activity\Distance $object
  * @return \Runalyze\Activity\Distance $this-reference
  */
 public function subtract(Distance $object)
 {
     $this->Kilometer -= $object->kilometer();
     return $this;
 }
 /**
  * Parse post data for equipment
  */
 protected function parsePostDataForSingleEquipment()
 {
     $DB = DB::getInstance();
     $accountId = SessionAccountHandler::getId();
     $Equipments = $this->Model->allEquipments();
     $Equipments[] = new Equipment\Entity();
     foreach ($Equipments as $Equipment) {
         $isNew = !$Equipment->hasID();
         $id = $isNew ? -1 : $Equipment->id();
         $AdditionalDistance = new Distance();
         $AdditionalDistance->setInPreferredUnit($_POST['equipment']['additional_km'][$id]);
         $NewEquipment = clone $Equipment;
         $NewEquipment->set(Equipment\Entity::NAME, $_POST['equipment']['name'][$id]);
         $NewEquipment->set(Equipment\Entity::TYPEID, (int) $_POST['equipment']['typeid'][$id]);
         $NewEquipment->set(Equipment\Entity::ADDITIONAL_KM, $AdditionalDistance->kilometer());
         $NewEquipment->set(Equipment\Entity::DATE_START, $this->stringToDatetime($_POST['equipment']['date_start'][$id]));
         $NewEquipment->set(Equipment\Entity::DATE_END, $this->stringToDatetime($_POST['equipment']['date_end'][$id]));
         $NewEquipment->set(Equipment\Entity::NOTES, $_POST['equipment']['notes'][$id]);
         if ($isNew) {
             if ($NewEquipment->name() != '') {
                 $Inserter = new Equipment\Inserter($DB, $NewEquipment);
                 $Inserter->setAccountID($accountId);
                 $Inserter->insert();
             }
         } elseif (isset($_POST['equipment']['delete'][$id])) {
             $DB->deleteByID('equipment', (int) $id);
         } else {
             $Updater = new Equipment\Updater($DB, $NewEquipment, $Equipment);
             $Updater->setAccountID($accountId);
             $Updater->update();
         }
     }
     $this->Model->clearCache('equipment');
 }