예제 #1
0
 public function testSimpleInsert()
 {
     $Equipment = new Object(array(Object::NAME => 'Equipment name', Object::TYPEID => $this->Typeid, Object::NOTES => 'Here are some notes', Object::DATE_START => '2015-01-01', Object::DATE_END => null));
     $Inserter = new Inserter($this->PDO, $Equipment);
     $Inserter->setAccountID(1);
     $Inserter->insert();
     $data = $this->PDO->query('SELECT * FROM `' . PREFIX . 'equipment` WHERE `accountid`=1')->fetch(PDO::FETCH_ASSOC);
     $New = new Object($data);
     $this->assertEquals('Equipment name', $New->name());
     $this->assertEquals('Here are some notes', $New->notes());
     $this->assertTrue($New->hasStartDate());
     $this->assertEquals('2015-01-01', $New->startDate());
     $this->assertTrue($New->isInUse());
     $this->assertEquals(null, $New->endDate());
 }
예제 #2
0
파일: UpdaterTest.php 프로젝트: 9x/Runalyze
 public function testSimpleUpdate()
 {
     $Inserter = new Inserter($this->PDO);
     $Inserter->setAccountID(1);
     $Inserter->insert(new Object(array(Object::NAME => 'Equipment name', Object::TYPEID => $this->Typeid, Object::NOTES => 'Here are some notes', Object::DATE_START => '2015-01-01', Object::DATE_END => '2015-02-02')));
     $Type = new Object($this->PDO->query('SELECT * FROM `' . PREFIX . 'equipment` WHERE `id`=' . $Inserter->insertedID())->fetch(PDO::FETCH_ASSOC));
     $Type->set(Object::NOTES, '');
     $Changed = clone $Type;
     $Changed->set(Object::DATE_END, null);
     $Updater = new Updater($this->PDO, $Changed, $Type);
     $Updater->setAccountID(1);
     $Updater->update();
     $Result = new Object($this->PDO->query('SELECT * FROM `' . PREFIX . 'equipment` WHERE `id`=' . $Inserter->insertedID())->fetch(PDO::FETCH_ASSOC));
     $this->assertEquals('Equipment name', $Result->name());
     $this->assertEquals('Here are some notes', $Result->notes());
     $this->assertTrue($Result->hasStartDate());
     $this->assertEquals('2015-01-01', $Result->startDate());
     $this->assertTrue($Result->isInUse());
     $this->assertEquals(null, $Result->endDate());
 }
예제 #3
0
파일: Updater.php 프로젝트: 9x/Runalyze
 /**
  * Keys to insert
  * @return array
  */
 protected function keys()
 {
     return array_merge(array(self::ACCOUNTID), Object::allDatabaseProperties());
 }
    /**
     * Display table
     */
    public function displayTable()
    {
        if (is_null($this->Equipment)) {
            $this->initTableData();
        }
        echo '<table id="list-of-all-equipment" class="fullwidth zebra-style">
			<thead>
				<tr>
					<th class="{sorter: \'x\'} small">' . __('x-times') . '</th>
					<th>' . __('Name') . '</th>
					<th class="{sorter: \'germandate\'} small">' . __('since') . '</th>
					<th class="{sorter: \'distance\'}">&Oslash; ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th>
					<th>&Oslash; ' . __('Pace') . '</th>
					<th class="{sorter: \'distance\'} small"><small>' . __('max.') . '</small> ' . Runalyze\Configuration::General()->distanceUnitSystem()->distanceUnit() . '</th>
					<th class="small"><small>' . __('min.') . '</small> ' . __('Pace') . '</th>
					<th class="{sorter: \'resulttime\'}">' . __('Time') . '</th>
					<th class="{sorter: \'distance\'}">' . __('Distance') . '</th>
					<th>' . __('Notes') . '</th>
				</tr>
			</thead>
			<tbody>';
        if (!empty($this->Equipment)) {
            foreach ($this->Equipment as $data) {
                $Object = new Model\Equipment\Object($data);
                $in_use = $Object->isInUse() ? '' : ' unimportant';
                $Pace = new Pace($Object->duration(), $Object->distance());
                $MaxPace = new Pace($data['pace_in_s'], 1);
                echo '<tr class="' . $in_use . ' r" style="position: relative">
					<td class="small">' . $data['num'] . 'x</td>
					<td class="b l">' . SearchLink::to('equipmentid', $Object->id(), $Object->name()) . '</td>
					<td class="small">' . $this->formatData($Object->startDate()) . '</td>
					<td>' . ($data['num'] != 0 ? Distance::format($Object->distance() / $data['num']) : '-') . '</td>
					<td>' . ($Object->duration() > 0 ? $Pace->asMinPerKm() . '/km' : '-') . '</td>
					<td class="small">' . Distance::format($data['dist']) . '</td>
					<td class="small">' . $MaxPace->asMinPerKm() . '/km' . '</td>
					<td>' . Duration::format($Object->duration()) . '</td>
					<td>' . Distance::format($Object->totalDistance()) . '</td>
					<td class="small">' . $Object->notes() . '</td>
				</tr>';
            }
        } else {
            echo '<tr><td colspan="9">' . __('You don\'t have any shoes') . '</td></tr>';
        }
        echo '</tbody>';
        echo '</table>';
        Ajax::createTablesorterFor("#list-of-all-equipment", true);
    }