Changeset 12


Ignore:
Timestamp:
Aug 29, 2019, 12:14:23 AM (5 years ago)
Author:
chronos
Message:
  • Added: Summary page with total numbers of items in all categories.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/SQL/Structure.sql

    r2 r12  
    33-- https://www.phpmyadmin.net/
    44--
    5 -- Počítač: localhost:3306
    6 -- Vytvořeno: Pon 10. zář 2018, 00:54
    7 -- Verze serveru: 5.7.23-0ubuntu0.18.04.1
    8 -- Verze PHP: 7.1.15-0ubuntu0.17.10.1
     5-- Host: localhost:3306
     6-- Generation Time: Aug 29, 2019 at 12:02 AM
     7-- Server version: 10.3.17-MariaDB-0ubuntu0.19.04.1
     8-- PHP Version: 7.2.19-0ubuntu0.19.04.2
    99
    1010SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
    1111SET time_zone = "+00:00";
    1212
     13
     14/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
     15/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
     16/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
     17/*!40101 SET NAMES utf8mb4 */;
     18
    1319--
    14 -- Databáze: `teribear`
     20-- Database: `teribear`
    1521--
     22CREATE DATABASE IF NOT EXISTS `teribear` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
     23USE `teribear`;
    1624
    1725-- --------------------------------------------------------
    1826
    1927--
    20 -- Struktura tabulky `Runner`
     28-- Table structure for table `Runner`
    2129--
    2230
    2331CREATE TABLE `Runner` (
    2432  `Id` int(11) NOT NULL,
    25   `Name` varchar(255) CHARACTER SET utf8 NOT NULL,
     33  `Name` varchar(255) NOT NULL,
    2634  `Gender` int(11) NOT NULL,
    27   `Team` int(11) NOT NULL,
     35  `Team` int(11) DEFAULT NULL,
    2836  `ChipNumber` int(11) NOT NULL
    29 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    30 
    31 --
    32 -- RELACE PRO TABULKU `Runner`:
    33 --   `Team`
    34 --       `Team` -> `Id`
    35 --
     37) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
    3638
    3739-- --------------------------------------------------------
    3840
    3941--
    40 -- Struktura tabulky `RunnerStat`
     42-- Table structure for table `RunnerStat`
    4143--
    4244
     
    4850  `Rank` int(11) NOT NULL,
    4951  `Money` int(11) NOT NULL
    50 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    51 
    52 --
    53 -- RELACE PRO TABULKU `RunnerStat`:
    54 --   `Runner`
    55 --       `Runner` -> `Id`
    56 --
     52) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
    5753
    5854-- --------------------------------------------------------
    5955
    6056--
    61 -- Struktura tabulky `Team`
     57-- Table structure for table `Team`
    6258--
    6359
    6460CREATE TABLE `Team` (
    6561  `Id` int(11) NOT NULL,
    66   `Name` varchar(255) CHARACTER SET utf8 NOT NULL,
    67   `WebId` int(11) NOT NULL
    68 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
     62  `Name` varchar(255) NOT NULL,
     63  `WebId` int(11) NOT NULL,
     64  `IsFamily` int(11) NOT NULL
     65) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
     66
     67-- --------------------------------------------------------
    6968
    7069--
    71 -- RELACE PRO TABULKU `Team`:
     70-- Table structure for table `TeamStat`
     71--
     72
     73CREATE TABLE `TeamStat` (
     74  `Id` int(11) NOT NULL,
     75  `Time` datetime NOT NULL,
     76  `Team` int(11) NOT NULL,
     77  `Distance` decimal(10,1) NOT NULL,
     78  `Rank` int(11) NOT NULL,
     79  `Money` int(11) NOT NULL
     80) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
     81
     82--
     83-- Indexes for dumped tables
    7284--
    7385
    7486--
    75 -- Klíče pro exportované tabulky
    76 --
    77 
    78 --
    79 -- Klíče pro tabulku `Runner`
     87-- Indexes for table `Runner`
    8088--
    8189ALTER TABLE `Runner`
     
    8492
    8593--
    86 -- Klíče pro tabulku `RunnerStat`
     94-- Indexes for table `RunnerStat`
    8795--
    8896ALTER TABLE `RunnerStat`
     
    9199
    92100--
    93 -- Klíče pro tabulku `Team`
     101-- Indexes for table `Team`
    94102--
    95103ALTER TABLE `Team`
     
    97105
    98106--
    99 -- AUTO_INCREMENT pro tabulky
     107-- Indexes for table `TeamStat`
     108--
     109ALTER TABLE `TeamStat`
     110  ADD PRIMARY KEY (`Id`),
     111  ADD KEY `Team` (`Team`);
     112
     113--
     114-- AUTO_INCREMENT for dumped tables
    100115--
    101116
    102117--
    103 -- AUTO_INCREMENT pro tabulku `Runner`
     118-- AUTO_INCREMENT for table `Runner`
    104119--
    105120ALTER TABLE `Runner`
    106   MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=59;
     121  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18158;
    107122--
    108 -- AUTO_INCREMENT pro tabulku `RunnerStat`
     123-- AUTO_INCREMENT for table `RunnerStat`
    109124--
    110125ALTER TABLE `RunnerStat`
    111   MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=41;
     126  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=136448;
    112127--
    113 -- AUTO_INCREMENT pro tabulku `Team`
     128-- AUTO_INCREMENT for table `Team`
    114129--
    115130ALTER TABLE `Team`
    116   MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
     131  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12718;
    117132--
    118 -- Omezení pro exportované tabulky
     133-- AUTO_INCREMENT for table `TeamStat`
     134--
     135ALTER TABLE `TeamStat`
     136  MODIFY `Id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4088;
     137--
     138-- Constraints for dumped tables
    119139--
    120140
    121141--
    122 -- Omezení pro tabulku `Runner`
     142-- Constraints for table `Runner`
    123143--
    124144ALTER TABLE `Runner`
     
    126146
    127147--
    128 -- Omezení pro tabulku `RunnerStat`
     148-- Constraints for table `RunnerStat`
    129149--
    130150ALTER TABLE `RunnerStat`
    131151  ADD CONSTRAINT `RunnerStat_ibfk_1` FOREIGN KEY (`Runner`) REFERENCES `Runner` (`Id`);
     152
     153--
     154-- Constraints for table `TeamStat`
     155--
     156ALTER TABLE `TeamStat`
     157  ADD CONSTRAINT `TeamStat_ibfk_1` FOREIGN KEY (`Team`) REFERENCES `Team` (`Id`);
     158
     159/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
     160/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
     161/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  • trunk/index.php

    r11 r12  
    3636  {
    3737    $Output = '<div>'.
     38      '<a href="'.$this->Link('/').'">Summary</a> '.
    3839      '<a href="'.$this->Link('/runners').'">Runners</a> '.
    3940      '<a href="'.$this->Link('/teams').'">Teams</a> '.
     
    592593  function ShowMain()
    593594  {
    594     return "";
     595    $Output = '';
     596    $DbResult = $this->Database->select('Runner', 'COUNT(*) AS Total');
     597    $DbRow = $DbResult->fetch_assoc();
     598    $RunnersCount = $DbRow['Total'];
     599
     600    $Output = '';
     601    $DbResult = $this->Database->select('Runner', 'COUNT(*) AS Total', 'Gender=1');
     602    $DbRow = $DbResult->fetch_assoc();
     603    $MenCount = $DbRow['Total'];
     604
     605    $Output = '';
     606    $DbResult = $this->Database->select('Runner', 'COUNT(*) AS Total', 'Gender=2');
     607    $DbRow = $DbResult->fetch_assoc();
     608    $WomenCount = $DbRow['Total'];
     609
     610    $Output = '';
     611    $DbResult = $this->Database->select('Runner', 'COUNT(*) AS Total', 'Gender=3');
     612    $DbRow = $DbResult->fetch_assoc();
     613    $KidsCount = $DbRow['Total'];
     614
     615    $DbResult = $this->Database->select('Team', 'COUNT(*) AS Total', 'IsFamily=0');
     616    $DbRow = $DbResult->fetch_assoc();
     617    $TeamsCount = $DbRow['Total'];
     618
     619    $DbResult = $this->Database->select('Team', 'COUNT(*) AS Total', 'IsFamily=1');
     620    $DbRow = $DbResult->fetch_assoc();
     621    $FamiliesCount = $DbRow['Total'];
     622   
     623    $Output .= '<div class="page-title">Summary</div>';
     624    $Output .= '<table class="WideTable">';
     625    $Output .= '<tr><th>Category</th><th>Total count</th></tr>';
     626    $Output .= '<tr><td>Runners</td><td>'.$RunnersCount.'</td></tr>';
     627    $Output .= '<tr><td>Men</td><td>'.$MenCount.'</td></tr>';
     628    $Output .= '<tr><td>Women</td><td>'.$WomenCount.'</td></tr>';
     629    $Output .= '<tr><td>Kids</td><td>'.$KidsCount.'</td></tr>';
     630    $Output .= '<tr><td>Teams</td><td>'.$TeamsCount.'</td></tr>';
     631    $Output .= '<tr><td>Families</td><td>'.$FamiliesCount.'</td></tr>';
     632    $Output .= '</table>';
     633
     634    return $Output;
    595635  }
    596636
     
    632672    {
    633673      if($this->PathItems[0] == 'sync') $Output .= $this->ShowSync();
    634       else if($this->PathItems[0] == 'empty') $Output .= $this->ShowEmpty();
     674      //else if($this->PathItems[0] == 'empty') $Output .= $this->ShowEmpty();
    635675      else if($this->PathItems[0] == 'runner') $Output .= $this->ShowRunner();
    636676      else if($this->PathItems[0] == 'runners') $Output .= $this->ShowRunners();
Note: See TracChangeset for help on using the changeset viewer.