From 9a14cf1f6af88984cbbe2fc5810b1355762b7743 Mon Sep 17 00:00:00 2001 From: diddipoeler Date: Sat, 20 Jan 2024 12:45:17 +0100 Subject: [PATCH] #1661 --- admin/models/projectteams.php | 3 +- admin/models/smimageimports.php | 2 +- admin/models/teamplayer.php | 85 +++++++++++++++++++++++++++++++++ admin/statistics/base.php | 2 +- site/models/staff.php | 21 +++++++- 5 files changed, 107 insertions(+), 6 deletions(-) diff --git a/admin/models/projectteams.php b/admin/models/projectteams.php index b34136c279..0547a03b6b 100644 --- a/admin/models/projectteams.php +++ b/admin/models/projectteams.php @@ -540,8 +540,7 @@ function getTeams($country = '') if ( $postcountry ) { - //$this->jsmquery->select('0 AS value, concat(t.name,' - ',t.id,'' ) AS text,t.info'); - $this->jsmquery->select('0 AS value, concat(t.name,"-",t.id) AS text,t.info'); + $this->jsmquery->select('st.id AS value, concat(t.name,"-",t.id) AS text,t.info'); $this->jsmquery->from('#__sportsmanagement_team AS t'); $this->jsmquery->join('LEFT', '#__sportsmanagement_season_team_id AS st on st.team_id = t.id'); $this->jsmquery->join('LEFT', '#__sportsmanagement_club AS c ON c.id = t.club_id'); diff --git a/admin/models/smimageimports.php b/admin/models/smimageimports.php index c1d4c1efa6..74816dc45e 100644 --- a/admin/models/smimageimports.php +++ b/admin/models/smimageimports.php @@ -69,7 +69,7 @@ function getXMLFolder() $query->select(array('folder as id', 'folder as name')) ->from('#__sportsmanagement_pictures') ->order('folder ASC') - ->group('folder ASC'); + ->group('folder'); $db->setQuery($query); diff --git a/admin/models/teamplayer.php b/admin/models/teamplayer.php index 59ca1ce2f7..e81efce2aa 100644 --- a/admin/models/teamplayer.php +++ b/admin/models/teamplayer.php @@ -548,6 +548,91 @@ public function save($data) } // Update personendaten + if ($data['injury_date'] == '') +{ +$data['injury_date'] = '0'; +} +if ($data['injury_end'] == '') +{ +$data['injury_end'] = '0'; +} +if ($data['suspension_date'] == '') +{ +$data['suspension_date'] = '0'; +} +if ($data['suspension_end'] == '') +{ +$data['suspension_end'] = '0'; +} +if ($data['away_date'] == '') +{ +$data['away_date'] = '0'; +} +if ($data['away_end'] == '') +{ +$data['away_end'] = '0'; +} +if ($data['injury_date_start'] == '') +{ +$data['injury_date_start'] = '0000-00-00'; +} +if ($data['injury_date_end'] == '') +{ +$data['injury_date_end'] = '0000-00-00'; +} +if ($data['susp_date_start'] == '') +{ +$data['susp_date_start'] = '0000-00-00'; +} +if ($data['susp_date_end'] == '') +{ +$data['susp_date_end'] = '0000-00-00'; +} +if ($data['away_date_start'] == '') +{ +$data['away_date_start'] = '0000-00-00'; +} +if ($data['away_date_end'] == '') +{ +$data['away_date_end'] = '0000-00-00'; +} +if ($data['injury_date_start'] != '0000-00-00' && +$data['injury_date_start'] != '') +{ +$data['injury_date_start'] = +sportsmanagementHelper::convertDate($data['injury_date_start'], 0); +} +if ($data['injury_date_end'] != '0000-00-00' && +$data['injury_date_end'] != '') +{ +$data['injury_date_end'] = +sportsmanagementHelper::convertDate($data['injury_date_end'], 0); +} +if ($data['susp_date_start'] != '0000-00-00' && +$data['susp_date_start'] != '') +{ +$data['susp_date_start'] = +sportsmanagementHelper::convertDate($data['susp_date_start'], 0); +} +if ($data['susp_date_end'] != '0000-00-00' && +$data['susp_date_end'] != '') +{ +$data['susp_date_end'] = +sportsmanagementHelper::convertDate($data['susp_date_end'], 0); +} +if ($data['away_date_start'] != '0000-00-00' && +$data['away_date_start'] != '') +{ +$data['away_date_start'] = +sportsmanagementHelper::convertDate($data['away_date_start'], 0); +} +if ($data['away_date_end'] != '0000-00-00' && +$data['away_date_end'] != '') +{ +$data['away_date_end'] = +sportsmanagementHelper::convertDate($data['away_date_end'], 0); +} + // Fields to update. $fields = array( $this->jsmdb->quoteName('injury') . '=\'' . $data['injury'] . '\'', diff --git a/admin/statistics/base.php b/admin/statistics/base.php index 5c4817378a..1dafee7ea0 100644 --- a/admin/statistics/base.php +++ b/admin/statistics/base.php @@ -527,7 +527,7 @@ function getQuotedSids($id_field = 'stat_ids') $event_ids = $params->get($id_field); - if (!count($event_ids)) + if ($event_ids == null || !count($event_ids)) { // Log::add(Text::sprintf('STAT %s/%s WRONG CONFIGURATION', $this->_name, $this->id), Log::WARNING, 'jsmerror'); return (array(0)); diff --git a/site/models/staff.php b/site/models/staff.php index 74d20a9db4..8445372a87 100644 --- a/site/models/staff.php +++ b/site/models/staff.php @@ -80,7 +80,7 @@ function getPresenceStats($project_id, $person_id) // Create a new query object. $db = sportsmanagementHelper::getDBConnection(true, self::$cfg_which_database); $query = $db->getQuery(true); - +/** $query = ' SELECT count(mp.id) AS present FROM #__sportsmanagement_match_staff AS mp INNER JOIN #__sportsmanagement_match AS m ON mp.match_id=m.id @@ -89,6 +89,19 @@ function getPresenceStats($project_id, $person_id) WHERE tp.person_id=' . $this->_db->Quote((int) $person_id) . ' AND pt.project_id=' . $this->_db->Quote((int) $project_id) . ' AND tp.published = 1'; + */ + +$query = ' SELECT count(mp.id) AS present + FROM #__sportsmanagement_match_staff AS mp + INNER JOIN #__sportsmanagement_match AS m ON mp.match_id=m.id + INNER JOIN #__sportsmanagement_season_team_person_id AS tp ON +tp.id=mp.team_staff_id + INNER JOIN #__sportsmanagement_project_team AS pt ON +m.projectteam1_id=pt.id + WHERE tp.person_id=' . $this->_db->Quote((int) $person_id) . ' + AND pt.project_id=' . $this->_db->Quote((int) $project_id) . ' + AND tp.published = 1'; + $db->setQuery($query, 0, 1); $inoutstat = $db->loadResult(); @@ -219,7 +232,11 @@ function getStaffHistory($order = 'ASC') $query->join('INNER', '#__sportsmanagement_project AS p ON p.id = tt.project_id'); $query->join('INNER', '#__sportsmanagement_season AS s ON s.id = p.season_id'); $query->join('INNER', '#__sportsmanagement_league AS l ON l.id = p.league_id'); - $query->join('LEFT', '#__sportsmanagement_project_position AS ppos ON ppos.id = o.project_position_id'); + + //$query->join('LEFT', '#__sportsmanagement_project_position AS ppos ON ppos.id = o.project_position_id'); + $query->join('LEFT', '#__sportsmanagement_person_project_position AS ppp ON ppp.person_id = o.person_id and ppp.project_id = p.id and ppp.persontype = o.persontype'); +$query->join('LEFT', '#__sportsmanagement_project_position AS ppos ON ppos.id = ppp.project_position_id'); + $query->join('LEFT', '#__sportsmanagement_position AS pos ON pos.id = ppos.position_id '); $query->where('o.person_id = ' . self::$personid); $query->where('pr.published = 1');