Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
108 lines (104 sloc) 4.7 KB
<?php
include 'config.inc.php';
include LIB_PATH . '/db.php';
function populateValue($data, $label) {
if (isset($data) && !empty($data)) {
return $data->$label;
} else {
return $_POST[$label];
}
}
if (isset($_GET) && !empty($_GET)) {
switch ($_GET["origin"]) {
case "view":
$post = $db->reading
->select()
->one()
->where('id = :id', [':id' => $_GET["readingId"]])
->run();
break;
}
}
if (isset($_POST) && !empty($_POST)) {
switch ($_POST["origin"]) {
case "calendar":
break;
case "new":
$post = $db->reading;
$id = $db->reading
->insert()
->data([
'copticDate' => $_POST["copticDate"],
'westernDate' => $_POST["westernDate"],
'liturgyPauline' => $_POST["liturgyPauline"],
'liturgyCatholic' => $_POST["liturgyCatholic"],
'liturgyPraxis' => $_POST["liturgyPraxis"],
'synaxerion' => $_POST["liturgySynaxerion"],
'liturgyPsalm' => $_POST["liturgyPsalm"],
'liturgyGospel' => $_POST["liturgyGospel"],
'vesperPsalm' => $_POST["vesperPsalm"],
'vesperGospel' => $_POST["vesperGospel"],
])
->run();
break;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/styles.css" />
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css" />
</head>
<body>
<div class="jumbotron">
<div class="container">
<h1>Add readings</h1>
<p class="text-primary"><a href="index.php">Back to calendar view</a>.</p>
</div>
</div>
<form class="form-horizontal" id="addReadingForm" method="post" action="readings.php">
<p class="text-primary">Required fields are followed by <strong><abbr title="required">*</abbr></strong>.</p>
  <section>
<label for="date">Coptic Date</label>
<input type="text" name="copticDate" id="copticDate" readonly value="<?php echo populateValue($post, 'copticDate');?>">
<label for="date">Western Date</label>
<input type="text" name="westernDate" id="westernDate" readonly value="<?php echo populateValue($post, 'westernDate');?>">
<section>
<h2>Ashiya</h2>
<div class="form-group">
<label for="vesperPsalm">Psalm <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="vesperPsalm" id="vesperPsalm"><?php echo populateValue($post, 'vesperPsalm');?></textarea>
<label for="vesperGospel">Gospel <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="vesperGospel" id="vesperGospel"><?php echo populateValue($post, 'vesperGospel');?></textarea>
</div>
</section>
<section>
<h2>Liturgy</h2>
<div class="form-group">
<label for="liturgyPauline">Pauline <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="liturgyPauline" id="liturgyPauline"><?php echo populateValue($post, 'liturgyPauline');?></textarea>
<label for="liturgyCatholic">Catholic <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="liturgyCatholic" id="liturgyCatholic"><?php echo populateValue($post, 'liturgyCatholic');?></textarea>
<label for="liturgyPraxis">Praxis <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="liturgyPraxis" id="liturgyPraxis"><?php echo populateValue($post, 'liturgyPraxis');?></textarea>
</div>
<div class="form-group">
<label for="liturgySynaxerion">Synaxerion <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="liturgySynaxerion" id="liturgySynaxerion"><?php echo populateValue($post, 'synaxerion');?></textarea>
</div>
<div class="form-group">
<label for="liturgyPsalm">Psalm <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="liturgyPsalm" id="liturgyPsalm"><?php echo populateValue($post, 'liturgyPsalm');?></textarea>
<label for="liturgyGospel">Gospel <abbr title="required">*</abbr></label>
<textarea class="form-control" rows="15" name="liturgyGospel" id="liturgyGospel"><?php echo populateValue($post, 'liturgyGospel');?></textarea>
</div>
</section>
<button type="submit" class="btn btn-primary btn-lg btn-block">Save</button>
<input type="hidden" name="origin" id="origin" value="new">
</form>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="bower_components/jquery.redirect/jquery.redirect.js"></script>
<script src="app.js"></script>
</body>
</html>