<?php // mainframe is an API workhorse, lots of 'core' interaction routines $mainframe = new mosMainFrame($database, '', '.'); $mainframe->initSession(); /** get the information about the current user from the sessions table */ $my = $mainframe->getUser(); $username = $my->username; $userpositions = ArrayFromQuery($con, "select con_position, jos_contact_details.name \n from jos_contact_details, jos_users\n where jos_users.username = '******'\n and jos_users.name = jos_contact_details.name"); if (count($userpositions) == 0) { echo "<script>window.location.replace('" . BASE_URL . "');</script>"; die('Not logged on'); }
<body onload="Load();LoadTableData();"> <script> <?php $table = 'ctcweb9_newsletter.historyitem'; $detail = 'ctcweb9_newsletter.historydetail'; $tablecols = JsonFromQuery($con, "SHOW FULL COLUMNS FROM {$table}"); $detailcols = JsonFromQuery($con, "SHOW FULL COLUMNS FROM {$detail}"); $where = "1=1"; $filterdate = $_POST["filterdate"]; $filtertable = $_POST["filtertable"]; $filterids = $_POST["filterids"]; $filterlimit = $_POST["filterlimit"]; $filterids = trim($filterids, ','); $filtertables = array("All" => "Select history for all tables", "ctcweb9_newsletter.events" => "Select history for this table", "ctcweb9_newsletter.notices" => "Select history for this table", "ctcweb9_newsletter.reports" => "Select history for this table", "ctcweb9_newsletter.fields" => "Select history for this table", "ctcweb9_newsletter.newsletters" => "Select history for this table"); $filterdates = array("All" => "Select history for all dates", "Current" => "Select history for the current newsletter"); $filterdates += ArrayFromQuery($con, "SELECT\tdistinct date_format(datetime,'%Y-%m')\tvalue, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Select history for this month' \t\ttitle\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$table}"); $startdate = ValueFromSql($con, "SELECT max(DATE_ADD(prev.issuedate,INTERVAL 1 DAY)) \n\t\t\t\t\t\t\t\t\t\t\t FROM ctcweb9_newsletter.newsletters prev,\n\t\t\t\t\t\t\t\t\t\t\t\t\tctcweb9_newsletter.newsletters curr\n\t\t\t\t\t\t\t\t\t\t\t WHERE prev.issuedate < curr.issuedate AND curr.iscurrent"); if (!array_key_exists($filtertable, $filtertables)) { $filtertable = "All"; } if ($filtertable != "All") { $where .= " AND `table` = '{$filtertable}'"; } if ($filterids != "") { $where .= " AND `id` in ({$filterids})"; } if ($filterids != "" && $filterdate == "") { $filterdate = "All"; } if ($filterlimit == "" || $filterlimit == "0") { $filterlimit = "1000";
$issuedate = $current["issuedate"]; $search = $_POST["search"]; $searchexpr = "0"; $sectionexpr = "1"; $dateexpr = "1"; if ($section != "All" && $section != "") { $sectionexpr = "`section` = '{$section}'"; } if ($date == "Current" || $date == "") { $dateexpr = "`date` >= '{$issuedate}'"; } if ($search != "") { $searchexpr = "((`title` LIKE '%{$search}%') OR " . " (`text` LIKE '%{$search}%'))"; } $sections = array("All" => ""); $sections += ArrayFromQuery($con, "SELECT DISTINCT section value, '' title FROM {$table}"); $dates = array("All" => "Select All dates", "Current" => "Select dates for the current newsletter"); $con->query("UPDATE {$table} SET `order` = id WHERE `order` < 0"); ?> </script> <form name="newsletterform" method="post" onsubmit="return false"> <?php require 'tabs.inc.php'; ?> <div> <?php require 'buttons.inc.php'; ?> Section: <select name="section" id="section" onchange="Save()">
} if ($search != "") { $searchexpr = "(leader LIKE '%{$search}%') OR\n (grade LIKE '%{$search}%') OR\n (title LIKE '%{$search}%') OR\n (text LIKE '%{$search}%')"; } $triplengths = "SELECT triplength name " . " FROM {$table} " . " WHERE triplength IS NOT NULL and triplength <> ''" . " GROUP BY triplength"; $grades = "SELECT grade name " . " FROM {$table} " . " WHERE grade IS NOT NULL and grade <> ''" . " GROUP BY grade"; $costs = "SELECT cost name " . " FROM {$table} " . " WHERE cost IS NOT NULL and cost <> ''" . " GROUP BY cost"; $maps = "SELECT name id," . " concat(`name`,' ',`title`) name," . " name in ( SELECT map1 FROM {$table} UNION " . " SELECT map2 FROM {$table} UNION " . " SELECT map3 FROM {$table} ) common " . " FROM ctcweb9_newsletter.maps " . " ORDER BY name"; $leaders = "SELECT fullName AS name,\n primaryEmail AS email,\n homePhone AS phone,\n concat( fullName,' ',homePhone,' ',primaryEmail,' ') as title,\n fullName in\n (select leader from {$table}) as common\n FROM ctcweb9_ctc.view_members\n WHERE status = 'Active'\n ORDER BY name"; $eventtypes = "select 'Social' name union select 'Trip' name"; $departurepoints = "select 'Z (Shell) Papanui' name union select 'Caltex Russley' name union select 'Contact Leader' name"; $cols = JsonFromQuery($con, "SHOW FULL COLUMNS FROM {$table}"); $rows = JsonFromQuery($con, "SELECT *, ({$searchexpr}) found\n FROM {$table}\n WHERE ({$where}) or ({$searchexpr})"); $types = array("All" => "Select trips and social events", "Social Events" => "Select social events only", "Trips" => "Select day trips and weekend trips", "Weekend Trips" => "Select weekend trips only", "Day Trips" => "Select day trips only"); $dates = array("All" => "Select All dates", "Current" => "Select dates for the current newsletter"); $dates += ArrayFromQuery($con, "SELECT distinct date_format(date,'%Y') value, '' title\n FROM {$table}\n UNION\n SELECT distinct date_format(date,'%Y-%m') value, '' title\n FROM {$table}"); ?> </script> <?php require 'tabs.inc.php'; ?> <form name="newsletterform" method="post" onsubmit="return false;"> <div> <?php require 'buttons.inc.php'; ?> Trip/Social: <select name="type" id="type" onchange="Save()"> <?php echo ArrayToOptions($types, $_POST['type'], "All"); ?>