Permalink
Browse files

added category e-mail

  • Loading branch information...
RocketMan committed Jul 25, 2018
1 parent 066f1ec commit d3de602cd577822dd9fbc8797ac43daa8931379e
Showing with 29 additions and 43 deletions.
  1. +10 −30 controllers/RunDaily.php
  2. +1 −1 css/zoostyle.css
  3. +1 −0 db/categories.sql
  4. +1 −0 db/zkdbSchema.sql
  5. +1 −1 engine/IChart.php
  6. +7 −5 engine/impl/Chart.php
  7. +8 −6 ui/AddManager.php
View
@@ -238,45 +238,25 @@ private function buildChart($start, $end, $limit="", $category="", $cmj=0, $crd=
private function sendChartGenreEMail($start, $date, $month) {
list($y,$m,$d) = explode("-", $date);
$genreAddr = [
"9"=>"reggae", // reggae
"8"=>"classical", // classical/experimental
"7"=>"world", // reggae/world
"6"=>"jazz", // jazz
"5"=>"hiphop", // hip-hop
"4"=>"metal", // heavy shit
"3"=>"rpm", // dance
"2"=>"country", // country
"1"=>"blues" // blues
];
// genre director default e-mail domain same as md's
$domain = Engine::param('email')['md'];
$i = strpos($base, '@');
if($i !== false)
$domain = substr($base, $i);
foreach($genreAddr as $genre => $address) {
$i = strpos($address, '@');
if($i === false)
$address .= $domain;
foreach($this->catCodes as $index => $genre) {
// skip undefined categories
if(!$genre["name"] || !$genre["code"])
continue;
$address = $genre["email"];
// skip genre e-mail if no valid address
if(!strpos($address, '@')) {
echo "Skipping ".$this->catCodes[$genre-1]["name"]." monthly e-mail due to invalid address: $address\n";
echo "Skipping ".$genre["name"]." monthly e-mail due to invalid or missing address: $address\n";
continue;
}
// Build the chart
$chart = $this->buildChart($start, $date, 0, $genre, 1);
// Apply the template
$body = str_replace($template, '%date%', date("F Y", mktime(0,0,0,$month,$d,$y)));
$body = str_replace($body, '%chart%', $charts);
$chart = $this->buildChart($start, $date, 0, $genre["id"], 1);
// Setup the headers
$subject = Engine::param('station').": ".
$this->catCodes[$genre-1]["name"] . " monthly totals, " .
$genre["name"] . " monthly totals, " .
date("m/Y", mktime(0,0,0,$month,$d,$y));
$headers = "From: ".Engine::param('station')." ".
@@ -285,7 +265,7 @@ private function sendChartGenreEMail($start, $date, $month) {
// send the mail
$stat = mail($address, $subject, $chart, $headers);
echo "Sending ".$this->catCodes[$genre-1]["name"]." monthly e-mail: ".
echo "Sending ".$genre["name"]." monthly e-mail: ".
($stat?"OK":"FAILED!")."\n";
}
}
View
@@ -302,7 +302,7 @@ TH.sec {
border-color: #3b0000;
}
.success {
color: #ffcc33;
color: #006600;
}
.text {
padding: 2px;
View
@@ -31,6 +31,7 @@ CREATE TABLE IF NOT EXISTS `categories` (
`name` varchar(80) NOT NULL DEFAULT '',
`code` char(1) DEFAULT NULL,
`director` varchar(80) DEFAULT NULL,
`email` varchar(80) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1;
View
@@ -99,6 +99,7 @@ CREATE TABLE IF NOT EXISTS `categories` (
`name` varchar(80) NOT NULL DEFAULT '',
`code` char(1) DEFAULT NULL,
`director` varchar(80) DEFAULT NULL,
`email` varchar(80) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `name` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=1;
View
@@ -32,7 +32,7 @@
const CAT_CODE = 1;
const CAT_FULL = 2;
function getCategories();
function updateCategory($i, $name, $code, $dir);
function updateCategory($i, $name, $code, $dir, $email);
function getNextAID();
function getAddDates($limit="");
function getAdd($date);
View
@@ -32,21 +32,23 @@ class ChartImpl extends BaseImpl implements IChart {
private static $labelCache;
public function getCategories() {
$query = "SELECT id, name, code, director FROM categories ORDER BY id";
$query = "SELECT id, name, code, director, email " .
"FROM categories ORDER BY id";
$stmt = $this->prepare($query);
return $this->executeAndFetchAll($stmt);
}
public function updateCategory($i, $name, $code, $dir) {
public function updateCategory($i, $name, $code, $dir, $email) {
$query = "UPDATE categories SET " .
"name=?, code=?, director=? " .
"name=?, code=?, director=?, email=? " .
"WHERE id=?";
$stmt = $this->prepare($query);
$stmt->bindValue(1, $name);
$stmt->bindValue(2, strtoupper($code));
$stmt->bindValue(3, $dir);
$stmt->bindValue(4, $i);
$success = $stmt->execute($stmt);
$stmt->bindValue(4, $email);
$stmt->bindValue(5, $i);
$success = $stmt->execute();
// mysql_affected_rows will return 0 if the SET values in the
// query are exactly the same as the existing columns; hence,
View
@@ -908,31 +908,33 @@ public function addManagerCats() {
$name = $_POST["name".$i];
$code = $_POST["code".$i];
$dir = $_POST["dir".$i];
$success &= Engine::api(IChart::class)->updateCategory($i, $name, $code, $dir);
$email = $_POST["email".$i];
$success &= Engine::api(IChart::class)->updateCategory($i, $name, $code, $dir, $email);
}
}
?>
<FORM ACTION="" METHOD=POST>
<TABLE CELLPADDING=2 CELLSPACING=0 BORDER=0>
<TR><TH>&nbsp;</TH><TH>Category</TH><TH>Code&nbsp;</TH><TH>Director</TH></TR>
<TR><TH>&nbsp;</TH><TH>Category</TH><TH>Code&nbsp;</TH><TH>Director</TH><TH>E-Mail Address</TH></TR>
<?php
$cats = Engine::api(IChart::class)->getCategories();
foreach($cats as $index => $cat) {
$i = $cat["id"];
echo " <TR><TD ALIGN=RIGHT>$i.</TD>\n";
echo " <TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=name$i VALUE=\"".htmlentities(stripslashes($cat["name"]))."\" CLASS=input SIZE=20 MAXLENGTH=80></TD>\n";
echo " <TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=code$i VALUE=\"".htmlentities(stripslashes($cat["code"]))."\" CLASS=input SIZE=4 MAXLENGTH=1></TD>\n";
echo " <TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=dir$i VALUE=\"".htmlentities(stripslashes($cat["director"]))."\" CLASS=input SIZE=30 MAXLENGTH=80></TD></TR>\n";
echo " <TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=dir$i VALUE=\"".htmlentities(stripslashes($cat["director"]))."\" CLASS=input SIZE=20 MAXLENGTH=80></TD>\n";
echo " <TD ALIGN=LEFT><INPUT TYPE=TEXT NAME=email$i VALUE=\"".htmlentities(stripslashes($cat["email"]))."\" CLASS=input SIZE=20 MAXLENGTH=80></TD></TR>\n";
}
?>
<TR><TD>&nbsp;</TD>
<TD COLSPAN=3 ALIGN=LEFT><INPUT TYPE=SUBMIT VALUE=" Update Categories "></TD></TR>
<TD COLSPAN=4 ALIGN=LEFT><INPUT TYPE=SUBMIT VALUE=" Update Categories "></TD></TR>
<?php
if($seq == "update") {
if($success)
echo " <TR><TD>&nbsp;</TD><TD CLASS=\"header\" ALIGN=LEFT COLSPAN=2>Categories updated.</TD></TR>\n";
echo " <TR><TD>&nbsp;</TD><TD CLASS=\"success\" ALIGN=LEFT COLSPAN=3>Categories updated.</TD></TR>\n";
else
echo " <TR><TD>&nbsp;</TD><TD CLASS=\"header\" ALIGN=LEFT COLSPAN=2 CLASS=\"error\">Updated failed.</TD></TR>\n";
echo " <TR><TD>&nbsp;</TD><TD CLASS=\"error\" ALIGN=LEFT COLSPAN=3>Updated failed.</TD></TR>\n";
}
?>
</TABLE>

0 comments on commit d3de602

Please sign in to comment.