| [ PHPXref.com ] | [ Generated: Sun Jul 20 20:12:55 2008 ] | [ Scout Tracker 0.13 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 if ($script_name = basename($HTTP_SERVER_VARS["SCRIPT_NAME"]) == "functions.php" ) { 3 print "<meta http-equiv=\"refresh\" content=\"0; URL=../index.php\">"; 4 exit; 5 } 6 7 function verifydate($date) { 8 $time_return = strtotime($date); 9 $date_format = date('Y-m-d',$time_return); 10 $date_parts = explode('-',$date_format); 11 $check_date = checkdate($date_parts[1],$date_parts[2],$date_parts[0]); 12 13 if (!$check_date) { 14 return '0000-00-00'; 15 } else { 16 return $date_format; 17 } 18 } 19 20 function rank_table($rank_key, $scout_key) { 21 global $rowid; 22 global $db; 23 global $user_group; 24 global $print; 25 global $rank_position; 26 global $element_i; 27 28 if ($element_i == 0) { $element_i = 2; } 29 30 # get rank name for table header 31 $sql_out = mysql_query("Select rank_name, ol_reqs from tbl_rank where record_key=$rank_key;"); 32 while ($row = mysql_fetch_assoc($sql_out)) { extract($row); } 33 mysql_free_result($sql_out); 34 35 print "<table cellpadding=0 cellspacing=0> 36 <tr><td colspan=3><center><u><h3><a href=$ol_reqs target=\"_blank\">$rank_name</a></h3></center></u></td></tr>\n"; 37 38 # Build Rank Table 39 $sql_out = mysql_query("Select req_num,req_description as description from tbl_rank_requirements where rank_key = $rank_key ORDER BY record_key;"); 40 while ($row = mysql_fetch_assoc($sql_out)) { 41 extract($row); 42 43 $element_i = $element_i + 1; 44 $other_num=""; 45 $req_date=""; 46 $sql_out2 = mysql_query("select date as req_date,other_num from tbl_scout_rank where scout_key = $scout_key AND rank_key = $rank_key AND req_num = \"$req_num\";"); 47 while ($row = mysql_fetch_assoc($sql_out2)) { extract($row); } 48 mysql_free_result($sql_out2); 49 50 if ($req_date == '' && ($user_group > 1 || $print == "Y" )) { 51 $req_date = "___________"; 52 } else if ($user_group > 1 || $print == "Y" ) { 53 $req_date = date('M j, Y',strtotime($req_date)); 54 } 55 print "<tr><td width=4>\n"; 56 57 if ($description == "MB" || $description == "RMB") { 58 $element_i = $element_i + 1; 59 $mb_name = ""; 60 $sql_out3 = mysql_query("select badge_name as mb_name from tbl_merit_badge where record_key = '" . $other_num . "';"); 61 while ($row = mysql_fetch_assoc($sql_out3)) { extract($row); } 62 mysql_free_result($sql_out3); 63 $description2 = $mb_name . "<input type=hidden name=rank_mb[$rank_key][$req_num] value=\"$other_num\">"; 64 65 if ($mb_name == "" || is_null($mb_name)) { 66 $description2 = ""; 67 if ($description == "RMB") { 68 $description2 = "<b>Eagle Req.</b> Merit Badge"; 69 if ($print != "Y" ) { 70 $sqlmb = "SELECT c.record_key as mb_record_key,c.badge_name as mb_badge_name from tbl_scout as a 71 INNER JOIN tbl_scout_mb_cmplt as b on a.record_key = b.scout_key 72 RIGHT JOIN tbl_merit_badge as c on b.mb_key=c.record_key 73 WHERE a.record_key=$rowid and b.date is null and c.required='Y';"; 74 $description2 = "<select name=rank_mb[$rank_key][$req_num]>\n 75 <option value=\"\" selected=\"\">$description2</option>\n"; 76 } 77 } else { 78 $description2 = "Elective Merit Badge"; 79 if ($print != "Y" ) { 80 $sqlmb = "SELECT c.record_key as mb_record_key,c.badge_name as mb_badge_name from tbl_scout as a 81 INNER JOIN tbl_scout_mb_cmplt as b on a.record_key = b.scout_key 82 RIGHT JOIN tbl_merit_badge as c on b.mb_key=c.record_key 83 WHERE a.record_key=$rowid and b.date is null and c.required='N';"; 84 $description2 = "<select name=rank_mb[$rank_key][$req_num]>\n 85 <option value=\"\" selected=\"\">$description2</option>\n"; 86 } 87 } 88 if ($print != "Y" ) { 89 $sqlmb_out = mysql_query($sqlmb); 90 while ($row = mysql_fetch_assoc($sqlmb_out)) { 91 extract($row); 92 93 $description2 = $description2 . "<option value=\"$mb_record_key\">$mb_badge_name</option>\n"; 94 } 95 $db->debug = false; 96 $description2 = $description2 . "</select>"; 97 } 98 } 99 $description = $description2; 100 101 } else if ($description == "Service Project") { 102 $description = $description . " Hours: $other_num"; 103 if ($print != "Y" ) { 104 $element_i = $element_i + 1; 105 $description = $description . " <input type=text name=rank_sp[$rank_key][$req_num] value=\"$other_num\" size=2 maxlength=2>  "; 106 } 107 } 108 print " $req_num.</td><td nowrap>$description </td><td align=right nowrap> "; 109 if ($user_group <= "1" && $print != "Y") { 110 if ($req_date == "") { 111 $input_rank = "rank[$rank_key][$req_num]"; 112 } else { 113 $input_rank = "ud_rank[$rank_key][$req_num]"; 114 } 115 print "<input type=text name=$input_rank value=\"$req_date\" size=10 maxlength=10 116 onChange=\"var box=document.forms[0].elements[$element_i];var d=parseDate(box.value); 117 if(d==null){ 118 alert('Date string not recognizable!'); 119 box.value=''; 120 box.focus(); 121 } else { 122 box.value=formatDate(d,'yyyy-MM-dd'); 123 }\">"; 124 } else { 125 print "$req_date"; 126 } 127 print " </td></tr>\n"; 128 } 129 mysql_free_result($sql_out); 130 131 print "</table>\n"; 132 $db->debug = false; 133 if ($rank_position == "left") { 134 $rank_position = "right"; 135 } else { 136 $rank_position = "left"; 137 } 138 } 139 140 function add_rank_requirement($rowid, $rank_key, $req_num, $rank_req_date, $other_num, $other_item) { 141 global $db; 142 143 $rank_req_date = verifydate($rank_req_date); 144 if ($rank_req_date != "0000-00-00") { 145 $sql = mysql_query("INSERT into tbl_scout_rank 146 (scout_key, 147 rank_key, 148 date, 149 req_num, 150 other_num) 151 VALUES 152 (\"$rowid\" 153 ,\"$rank_key\" 154 ,\"$rank_req_date\" 155 ,\"$req_num\" 156 ,\"$other_num\" 157 );"); 158 if ( $other_item == 'mb' ) { 159 $sql = mysql_query("INSERT into tbl_scout_mb_cmplt 160 (scout_key, 161 mb_key, 162 date 163 ) 164 VALUES 165 (\"$rowid\" 166 ,\"$other_num\" 167 ,\"$rank_req_date\" 168 );"); 169 } 170 } else { 171 print "<center><h3><i>INVALID DATE ENTERED</i></h3></center>\n"; 172 } 173 } 174 175 function change_rank_requirement($rowid, $rank_key, $req_num, $rank_req_date, $other_num, $other_item) { 176 if ($rank_req_date == "0000-00-00" || $rank_req_date == "0") { 177 $sql = mysql_query("DELETE from tbl_scout_rank 178 WHERE scout_key = \"$rowid\" AND 179 rank_key = \"$rank_key\" AND 180 req_num = \"$req_num\";"); 181 182 if ($other_item == 'mb' ) { 183 $sql = mysql_query("DELETE from tbl_scout_mb_cmplt 184 WHERE scout_key = \"$rowid\" AND 185 mb_key = \"$other_num\";"); 186 } 187 } else { 188 $rank_req_date = verifydate($rank_req_date); 189 if ($rank_req_date != '0000-00-00') { 190 $sql = mysql_query("UPDATE tbl_scout_rank 191 set date = \"$rank_req_date\" 192 ,other_num = \"$other_num\" 193 WHERE scout_key = \"$rowid\" AND 194 rank_key = \"$rank_key\" AND 195 req_num = \"$req_num\";"); 196 if ($other_item == 'mb' ) { 197 $sql = mysql_query("UPDATE tbl_scout_mb_cmplt 198 set date = \"$rank_req_date\" 199 WHERE scout_key = \"$rowid\" AND 200 mb_key = \"$other_num\";"); 201 } 202 } else { 203 print "<center><h3><i>INVALID DATE ENTERED</i></h3></center>\n"; 204 } 205 } 206 } 207 208 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |