function reportCard(node) { window.open("matchcard.php?id=" + node); } <?php } } $crud = new MatchCrud(); $crud->dialogwidth = 450; $crud->title = "Match Details"; $crud->allowAdd = false; $crud->allowEdit = isUserInRole("SUPERUSER"); $crud->allowRemove = false; $crud->allowFilter = false; $crud->allowView = false; $crud->table = "{$_SESSION['DB_PREFIX']}matchdetails"; if (isUserInRole("ADMIN")) { $crud->sql = "SELECT A.*, A.id AS uniqueid,\n\t\t\t\t\t B.name AS refereename, C.age,\n\t\t\t\t\t C.name AS submittedteamname\n\t\t\t\t\t FROM {$_SESSION['DB_PREFIX']}matchdetails A\n\t\t\t\t\t LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}referee B\n\t\t\t\t\t ON B.id = A.refereeid\n\t\t\t\t\t LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}teamagegroup C\n\t\t\t\t\t ON C.id = A.teamid\n\t\t\t\t\t ORDER BY A.id DESC"; } else { if (isUserInRole("SECRETARY")) { $clubid = getLoggedOnClubID(); $crud->sql = "SELECT A.*, A.id AS uniqueid,\n\t\t\t\t\t B.name AS refereename, C.age,\n\t\t\t\t\t C.name AS submittedteamname\n\t\t\t\t\t FROM {$_SESSION['DB_PREFIX']}matchdetails A\n\t\t\t\t\t LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}referee B\n\t\t\t\t\t ON B.id = A.refereeid\n\t\t\t\t\t LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}teamagegroup C\n\t\t\t\t\t ON C.id = A.teamid\n\t\t\t\t\t WHERE C.teamid = {$clubid};\n\t\t\t\t\t ORDER BY A.id DESC"; } else { $teamid = getLoggedOnTeamID(); $crud->sql = "SELECT A.*, A.id AS uniqueid,\n\t\t\t\t\t B.name AS refereename, C.age,\n\t\t\t\t\t C.name AS submittedteamname\n\t\t\t\t\t FROM {$_SESSION['DB_PREFIX']}matchdetails A\n\t\t\t\t\t LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}referee B\n\t\t\t\t\t ON B.id = A.refereeid\n\t\t\t\t\t LEFT OUTER JOIN {$_SESSION['DB_PREFIX']}teamagegroup C\n\t\t\t\t\t ON C.id = A.teamid\n\t\t\t\t\t WHERE A.teamid = {$teamid};\n\t\t\t\t\t ORDER BY A.id DESC"; } } $crud->columns = array(array('name' => 'matchdate', 'length' => 12, 'datatype' => 'date', 'label' => 'Match Date'), array('name' => 'ageref', 'function' => 'ageReference', 'sortcolumn' => 'C.age', 'type' => 'DERIVED', 'length' => 10, 'editable' => false, 'bind' => false, 'filter' => false, 'label' => 'Age Group'), array('name' => 'division', 'length' => 17, 'label' => 'Division / Group', 'type' => 'COMBO', 'options' => array(array('value' => 'X', 'text' => 'N/A'), array('value' => 'P', 'text' => 'Premier'), array('value' => '1', 'text' => '1'), array('value' => '2', 'text' => '2'), array('value' => '3', 'text' => '3'), array('value' => '4', 'text' => '4'), array('value' => '5', 'text' => '5'), array('value' => '6', 'text' => '6'), array('value' => 'A', 'text' => 'A'), array('value' => 'B', 'text' => 'B'), array('value' => 'C', 'text' => 'C'), array('value' => 'D', 'text' => 'D'), array('value' => 'E', 'text' => 'E'), array('value' => 'F', 'text' => 'F'), array('value' => 'G', 'text' => 'G'), array('value' => 'H', 'text' => 'H'))), array('name' => 'leaguecup', 'length' => 15, 'label' => 'Competition', 'type' => 'COMBO', 'options' => array(array('value' => 'L', 'text' => 'League'), array('value' => 'N', 'text' => 'Combination'), array('value' => 'C', 'text' => 'Challenge Cup'), array('value' => 'T', 'text' => 'Challenge Trophy'))), array('name' => 'hometeam', 'length' => 28, 'editable' => false, 'bind' => false, 'label' => 'Home Team'), array('name' => 'hometeamscore', 'length' => 5, 'align' => 'center', 'label' => 'Score'), array('name' => 'opposition', 'length' => 28, 'editable' => false, 'bind' => false, 'label' => 'Away Team'), array('name' => 'awayteamscore', 'length' => 5, 'align' => 'center', 'label' => 'Score'), array('name' => 'id', 'length' => 5, 'filter' => false, 'bind' => false, 'editable' => false, 'pk' => true, 'label' => 'ID'), array('name' => 'teamid', 'type' => 'DATACOMBO', 'length' => 28, 'label' => 'Submitted By Team', 'table' => 'teamagegroup', 'required' => true, 'table_id' => 'id', 'alias' => 'submittedteamname', 'table_name' => 'name')); $crud->subapplications = array(array('title' => 'Match Result Form', 'imageurl' => 'images/print.png', 'script' => 'reportCard')); $crud->run();
} ?> } ); function processCard() { if (! isDate($("#matchdate").val())) { pwAlert("Date of Match must be a valid date"); return false; } if ($("#hometeamid").val() != "<?php echo getLoggedOnTeamID(); ?> " && $("#oppositionid").val() != "<?php echo getLoggedOnTeamID(); ?> ") { pwAlert("Either home or away team must be your team and MUST be selected from the dropdown list"); return false; } if ($("#agegroupid").val() == 0) { pwAlert("Age group must be specified"); return false; } if ($("#hometeamid").val() == "0" || $("#hometeamid").val() == "") { pwAlert("Home team must be specified"); return false; }
<table width='75%' cellspacing=5> <tr> <td>Date of Match</td> <td> <input type="text" class="datepicker" id="matchdate" name="matchdate" value="<?php if (isset($_POST['matchdate'])) { echo $_POST['matchdate']; } ?> " /> </td> <td>Age Group</td> <td> <?php createCombo("agegroupid", "id", "name", "{$_SESSION['DB_PREFIX']}teamagegroup", "WHERE teamid = " . getLoggedOnTeamID(), true); ?> </td> </tr> <tr> <td>League / Cup</td> <td> <SELECT id="leaguecup" name="leaguecup"> <OPTION value="L">League</OPTION> <OPTION value="C">Challenge Cup</OPTION> <OPTION value="T">Challenge Trophy</OPTION> </SELECT> </td> <td>Division</td> <td> <SELECT id="division" name="division">
function getFilteredData($sql) { if (!isset($_SESSION['SITE_CONFIG'])) { return $sql; } $parser = new PHPSQLParser($sql); $tablealias = null; $data = getSiteConfigData(); foreach ($parser->parsed['FROM'] as $table) { if ($table['table'] == "horizon_members") { if ($table['alias'] != "") { $tablealias = $table['alias']['name']; } else { $tablealias = $table['table']; } } } // echo $sql . "\n"; // print_r($parser->parsed); if (!isset($parser->parsed['WHERE'])) { /* Create where clause. */ $parser->parsed['WHERE'] = array(); } else { /* Add to the where clause. */ $parser->parsed['WHERE'][] = array("expr_type" => "operator", "base_expr" => "AND", "sub_tree" => ""); } if (isUserInRole($data->adminrole) || isUserInRole($data->managementrole)) { /* Do nothing, access rights to all. */ return $sql; } if (isUserInRole($data->trainingmanagementrole)) { /* Not restricted by anything training related. * Page roles will prevent access to parts of the system * that are not appropriate to training management. */ return $sql; } if (isUserInRole($data->officeadminrole)) { /* Restricted to. * Personal details for APPRAISALS only. */ foreach ($parser->parsed['FROM'] as $table) { if ($table['table'] != "horizon_appraisal") { $parser->parsed['WHERE'][] = array("expr_type" => "colref", "base_expr" => $tablealias . ".member_id", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "const", "base_expr" => getLoggedOnMemberID(), "sub_tree" => ""); } } } if (isUserInRole($data->compliancerole)) { foreach ($parser->parsed['FROM'] as $table) { if ($table['table'] == "horizon_holiday") { /* Compliance don't restrict holidays */ return $sql; } } /* Restricted to. * All technicians and team leaders. */ $parser->parsed['WHERE'][] = array("expr_type" => "bracket_expression", "sub_tree" => array(array("expr_type" => "colref", "base_expr" => $tablealias . ".position", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => "'" . $data->technicianposition . "'", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "OR", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => $tablealias . ".position", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => "'" . $data->teamleaderposition . "'", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "OR", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => $tablealias . ".member_id", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => getLoggedOnMemberID(), "sub_tree" => ""))); } else { if (isUserInRole($data->regionalservicemanagerrole)) { /* Restricted to. * All personnel and team leaders. */ $parser->parsed['OPTIONS'][] = "DISTINCT"; $parser->parsed['FROM'][] = array("expr_type" => "table", "table" => "horizon_userteams", "alias" => array("as" => "", "name" => "horizon_userteams", "base_expr" => "horizon_userteams"), "join_type" => "JOIN", "ref_type" => "ON", "ref_clause" => array(array("expr_type" => "colref", "base_expr" => "horizon_userteams.memberid", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => getLoggedOnMemberID(), "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "OR", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => $tablealias . ".member_id", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => getLoggedOnMemberID(), "sub_tree" => ""))); $parser->parsed['WHERE'][] = array("expr_type" => "bracket_expression", "sub_tree" => array(array("expr_type" => "colref", "base_expr" => "horizon_userteams.teamid", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => $tablealias . ".teamid", "sub_tree" => ""))); } else { if (isUserInRole($data->officerole)) { $appraisal = false; foreach ($parser->parsed['FROM'] as $table) { if ($table['table'] == "horizon_appraisal") { /* Compliance don't restrict holidays */ $appraisal = true; } } if (!$appraisal) { return $sql; } /* Restricted to. * All technicians and team leaders. */ $parser->parsed['WHERE'][] = array("expr_type" => "bracket_expression", "sub_tree" => array(array("expr_type" => "colref", "base_expr" => $tablealias . ".position", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => "'" . $data->technicianposition . "'", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "OR", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => $tablealias . ".position", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => "'" . $data->teamleaderposition . "'", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "OR", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => $tablealias . ".member_id", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => getLoggedOnMemberID(), "sub_tree" => ""))); } else { if (isUserInRole($data->officemanagerrole)) { /* Restricted to. * All personnel and team leaders. */ $parser->parsed['OPTIONS'][] = "DISTINCT"; $parser->parsed['FROM'][] = array("expr_type" => "table", "table" => "horizon_userroles", "alias" => array("as" => "", "name" => "horizon_userroles", "base_expr" => "horizon_userroles"), "join_type" => "JOIN", "ref_type" => "ON", "ref_clause" => array(array("expr_type" => "colref", "base_expr" => "horizon_userroles.memberid", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "colref", "base_expr" => $tablealias . ".member_id", "sub_tree" => ""))); $parser->parsed['WHERE'][] = array("expr_type" => "bracket_expression", "sub_tree" => array(array("expr_type" => "colref", "base_expr" => "horizon_userroles.roleid", "sub_tree" => ""), array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""), array("expr_type" => "const", "base_expr" => "'" . $data->officepersonnelrole . "'", "sub_tree" => ""))); } else { if (isUserInRole($data->teamleaderrole)) { /* Restricted to. * Team personnel and themselves. */ $parser->parsed['WHERE'][] = array("expr_type" => "colref", "base_expr" => $tablealias . ".teamid", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "const", "base_expr" => getLoggedOnTeamID(), "sub_tree" => ""); } else { if (isUserInRole($data->areacoordinatorrole)) { /* Restricted to. * Team personnel and themselves. */ $parser->parsed['WHERE'][] = array("expr_type" => "colref", "base_expr" => $tablealias . ".teamid", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "const", "base_expr" => getLoggedOnTeamID(), "sub_tree" => ""); } else { /* Restricted to. * Technician Level 1 – Personal details. */ $parser->parsed['WHERE'][] = array("expr_type" => "colref", "base_expr" => $tablealias . ".member_id", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "operator", "base_expr" => "=", "sub_tree" => ""); $parser->parsed['WHERE'][] = array("expr_type" => "const", "base_expr" => getLoggedOnMemberID(), "sub_tree" => ""); } } } } } } $creator = new PHPSQLCreator($parser->parsed); $created = $creator->created; return $created; }