Skip to content

Commit

Permalink
korrektur
Browse files Browse the repository at this point in the history
  • Loading branch information
diddipoeler committed Dec 30, 2024
1 parent 23876a2 commit e5a21be
Showing 1 changed file with 41 additions and 33 deletions.
74 changes: 41 additions & 33 deletions site/models/staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ class sportsmanagementModelStaff extends BaseDatabaseModel
static $personid = 0;
static $teamplayerid = 0;
static $teamid = 0;

/**
* data array for staff history
*
* @var array
*/
static $_history = null;
static $_inproject = null;
static $cfg_which_database = 0;
Expand Down Expand Up @@ -67,34 +61,31 @@ function getPresenceStats($project_id, $person_id)
{
$app = Factory::getApplication();
$option = Factory::getApplication()->input->getCmd('option');

// Create a new query object.
$db = sportsmanagementHelper::getDBConnection(true, self::$cfg_which_database);
$inoutstat = 0;
$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
INNER JOIN #__sportsmanagement_team_staff 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';
*/

$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';

$query->select('count(mp.id) AS present');
$query->from('#__sportsmanagement_match_staff AS mp');
$query->join('INNER', '#__sportsmanagement_match AS m ON mp.match_id = m.id');
$query->join('INNER', '#__sportsmanagement_season_team_person_id AS tp ON tp.id = mp.team_staff_id');
$query->join('INNER', '#__sportsmanagement_project_team AS pt ON m.projectteam1_id = pt.id');
$query->where('pt.project_id = ' . $projectid);
$query->where('tp.person_id = ' . $personid);
$query->where('tp.published = 1');


try
{
$db->setQuery($query, 0, 1);
$inoutstat = $db->loadResult();
}
catch (Exception $e)
{
$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()), 'notice');
$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_FILE_ERROR_FUNCTION_FAILED', __FILE__, __LINE__), 'notice');
}

$db->disconnect(); // See: http://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_disconnect

return $inoutstat;
}
Expand Down Expand Up @@ -127,8 +118,6 @@ function getTeamStaff()
{
$app = Factory::getApplication();
$option = Factory::getApplication()->input->getCmd('option');

// Create a new query object.
$db = sportsmanagementHelper::getDBConnection(true, self::$cfg_which_database);
$query = $db->getQuery(true);

Expand All @@ -147,10 +136,19 @@ function getTeamStaff()
$query->where('pt.project_id = ' . self::$projectid);
$query->where('ts.person_id = ' . self::$personid);
$query->where('ts.published = 1');

try
{
$db->setQuery($query);
self::$_inproject = $db->loadObject();
}
catch (Exception $e)
{
$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()), 'notice');
$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_FILE_ERROR_FUNCTION_FAILED', __FILE__, __LINE__), 'notice');
}
}

$db->disconnect(); // See: http://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_disconnect

return self::$_inproject;
}
Expand Down Expand Up @@ -236,12 +234,22 @@ function getStaffHistory($order = 'DESC')
$query->where('o.persontype = 2');
//$query->order('s.ordering ' . $order . ', l.ordering ASC, p.name ASC ');
$query->order('s.name '. $order.', p.name '. $order );
try
{
$db->setQuery($query);
self::$_history = $db->loadObjectList();
}
catch (Exception $e)
{
$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()), 'notice');
$app->enqueueMessage(Text::sprintf('COM_SPORTSMANAGEMENT_FILE_ERROR_FUNCTION_FAILED', __FILE__, __LINE__), 'notice');
}

if (!self::$_history)
{
}

$db->disconnect(); // See: http://api.joomla.org/cms-3/classes/JDatabaseDriver.html#method_disconnect

return self::$_history;
}
Expand Down

0 comments on commit e5a21be

Please sign in to comment.