- add posibility to add missing data within the list
- section for adding new corona trainee - list (of the last month) can be send to an eMail
This commit is contained in:
@@ -56,9 +56,6 @@ if( empty($someOptions['dontFetch' ]) ) $someOptions['dontFetch' ] = false;
|
||||
}
|
||||
$pdoResult = $pdoStatement->execute();
|
||||
|
||||
//if(!$pdoResult)
|
||||
//echo("Strange! \"".$aQueryString."\" failed without exception!");
|
||||
|
||||
if($someOptions['dontFetch']){
|
||||
$ret = NULL;
|
||||
}
|
||||
@@ -82,24 +79,35 @@ if( empty($someOptions['dontFetch' ]) ) $someOptions['dontFetch' ] = false;
|
||||
);
|
||||
}
|
||||
}
|
||||
//var_dump($ret);
|
||||
//var_dump($aQueryString);
|
||||
//var_dump($aBindArray);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function getLastAttendances($db){
|
||||
function getLastAttendances($db, $minDate=null){
|
||||
if ($minDate == null){
|
||||
$minDate = new DateTime;
|
||||
$minDate->sub(new DateInterval("P1M")); // from the current date subtract a *P*eriod of *1* *M*onth
|
||||
}
|
||||
|
||||
$query = <<<SQL
|
||||
SELECT date, vorname, name, corona_PLZ, corona_telephon, corona_eMail
|
||||
SELECT userId, date, vorname, name, corona_PLZ, corona_telephon, corona_eMail
|
||||
FROM `cwsvjudo`.`anwesenheit`
|
||||
JOIN `cwsvjudo`.`wkParticipo_Users`
|
||||
ON `cwsvjudo`.`anwesenheit`.`userId` = `cwsvjudo`.`wkParticipo_Users`.`id`
|
||||
JOIN `cwsvjudo`.`wkParticipo_Users`
|
||||
ON `cwsvjudo`.`anwesenheit`.`userId` = `cwsvjudo`.`wkParticipo_Users`.`id`
|
||||
WHERE :minDate <= date
|
||||
ORDER BY `date` DESC, `name`;
|
||||
SQL;
|
||||
$params = array();
|
||||
$params = array(
|
||||
'minDate' => array('value' => $minDate->format('Y-m-d'), 'data_type' => PDO::PARAM_STR)
|
||||
);
|
||||
$options = array();
|
||||
$ret = dbQuery($db, $query, $params, $options);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function getJudokasInTraining($dbConnection, $attributeName){
|
||||
function getUsersWithAttribute($dbConnection, $attributeName){
|
||||
$query = <<<SQL
|
||||
SELECT userId, name, vorname
|
||||
FROM `cwsvjudo`.`wkParticipo_Users`
|
||||
@@ -115,6 +123,20 @@ SQL;
|
||||
return dbQuery($dbConnection, $query, $params);
|
||||
}
|
||||
|
||||
function giveUserAnUserAttribute($dbConnection, $userId, $attributeName){
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`wkParticipo_user<=>userAttributes` (`userId`, `attributeId`)
|
||||
SELECT :userId, `id`
|
||||
FROM `cwsvjudo`.`wkParticipo_userAttributes`
|
||||
WHERE `name` = :attributeName;
|
||||
SQL;
|
||||
$params = array(
|
||||
':userId' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT),
|
||||
':attributeName' => array('value'=>$attributeName, 'data_type'=>PDO::PARAM_STR)
|
||||
);
|
||||
return dbQuery($dbConnection, $query, $params);
|
||||
}
|
||||
|
||||
function giveJudokasAttendence($dbConnection, $date, $ids){
|
||||
$values = array();
|
||||
try{
|
||||
@@ -129,4 +151,39 @@ function giveJudokasAttendence($dbConnection, $date, $ids){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// updates corona data of an user
|
||||
function updateCoronaData($db, $userId, $columnName, $columnValue){
|
||||
$coronaColumnNames = ["corona_PLZ", "corona_telephon", "corona_eMail"];
|
||||
|
||||
if( !in_array( $columnName, $coronaColumnNames) ){
|
||||
return;
|
||||
}
|
||||
$query = "UPDATE `cwsvjudo`.`wkParticipo_Users` SET `".$columnName."`=:val WHERE `id`=:id;";
|
||||
$params = array(
|
||||
':val' => array('value'=>$columnValue, 'data_type'=>PDO::PARAM_STR),
|
||||
':id' => array('value'=>$userId, 'data_type'=>PDO::PARAM_INT)
|
||||
);
|
||||
dbQuery($db, $query, $params);
|
||||
return;
|
||||
}
|
||||
|
||||
function addCoronaUser($db, $name, $vorname, $corona_PLZ, $corona_telephon, $corona_eMail){
|
||||
$query = <<<SQL
|
||||
INSERT INTO `cwsvjudo`.`wkParticipo_Users` (name, vorname, corona_PLZ, corona_telephon, corona_eMail)
|
||||
VALUES (:name, :vorname, :plz, :telephon, :email);
|
||||
SQL;
|
||||
$params = array(
|
||||
':name' => array('value'=>$name, 'data_type'=>PDO::PARAM_STR),
|
||||
':vorname' => array('value'=>$vorname, 'data_type'=>PDO::PARAM_STR),
|
||||
':plz' => array('value'=>$corona_PLZ, 'data_type'=>PDO::PARAM_STR),
|
||||
':telephon' => array('value'=>$corona_telephon, 'data_type'=>PDO::PARAM_STR),
|
||||
':email' => array('value'=>$corona_eMail, 'data_type'=>PDO::PARAM_STR),
|
||||
);
|
||||
dbQuery($db, $query, $params);
|
||||
|
||||
$newId = $db->lastInsertId();
|
||||
giveUserAnUserAttribute($db, $newId, "inTraining");
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user