[ PHPXref.com ] [ Generated: Sun Jul 20 20:12:55 2008 ] [ Scout Tracker 0.13 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/includes/ -> leadership_log.php (source)

   1  <?php
   2  if ($script_name = basename($HTTP_SERVER_VARS["SCRIPT_NAME"]) == "leadership_log.php" ) {
   3   print "<meta http-equiv=\"refresh\" content=\"0; URL=../index.php\">";
   4   exit;
   5  }
   6  
   7  $sql = mysql_query("select first_name,last_name from tbl_scout where record_key=$rowid");
   8  extract(mysql_fetch_assoc($sql));
   9  
  10  $sql = mysql_query("select position as assignment from tbl_scout_leadership where scout_key=$rowid and enddate='0000-00-00'");
  11  if ($sql) {
  12   extract(mysql_fetch_assoc($sql));
  13  }
  14  
  15  print "<center><h2>$assignment $first_name $last_name</h2>
  16  <p><h3>Leadership Log</h3></center>";
  17  
  18  if ($add_leadership == "Y" && $user_group < 2 ) {
  19   foreach ($position as $leadership_key => $position_data) {
  20    $check_sdate = verifydate($startdate[$leadership_key]);
  21    if ($enddate[$leadership_key] == '') {
  22     $check_edate = '';
  23    } else {
  24     $check_edate = verifydate($enddate[$leadership_key]);
  25    }
  26    if ($check_sdate != '0000-00-00') {
  27     if ($leadership_key == '000' && $position_data != '') {
  28      $sql_insert = mysql_query("insert into tbl_scout_leadership
  29                                 (scout_key
  30                                 ,startdate
  31                                 ,enddate
  32                                 ,position
  33                                 ) values
  34                                 (\"$rowid\"
  35                                 ,\"$check_sdate\"
  36                                 ,\"$check_edate\"
  37                                 ,\"$position_data\"
  38                                 )
  39                                 ");
  40     }
  41     if ($leadership_key != '000') {
  42      if ($delete[$leadership_key] == "Y") {
  43       mysql_query("delete from tbl_scout_leadership where record_key = \"$leadership_key\"");
  44      } else {
  45       mysql_query("update tbl_scout_leadership
  46                    set
  47                    position=\"$position_data\"
  48                    ,startdate=\"$check_sdate\"
  49                    ,enddate=\"$check_edate\"
  50                    where record_key=\"$leadership_key\"
  51                    ");
  52      }
  53     }
  54    }
  55   }
  56  }
  57  if ($user_group < 2 && $print != "Y") {
  58   print "<form method=POST action=./index.php>
  59    <input type=hidden name=leadership_log value=Y>
  60    <input type=hidden name=add_leadership value=Y>
  61    <input type=hidden name=rowid value=$rowid>
  62    <input type=submit value=Submit><p>";
  63    print "<center><b>Required: Position and Start Date.<br>Leave End Date blank if currently serving in that position.</b><p>";
  64    $i = 3;
  65  }
  66  
  67  print "<table class=white align=center border=1><tr align=center><td><b>Position</td><td><b>Start Date</td><td><b>End Date</td><td><b>Months</td>";
  68  if ($user_group < 2 && $print != "Y") {
  69   print "<td><b>Delete</td>";
  70  }
  71  print "</tr>";
  72  
  73  $total_length = 0;
  74  
  75  $sql = mysql_query("select record_key as leadership_key,startdate,enddate,position from tbl_scout_leadership where scout_key=$rowid order by startdate");
  76  
  77  while ($row = mysql_fetch_assoc($sql)) {
  78   extract($row);
  79   list($start_year,$start_month,$start_day) = explode('-',$startdate);
  80   if ($enddate != "0000-00-00") {
  81    $current = "";
  82    list($end_year,$end_month,$end_day) = explode('-',$enddate);
  83   } else {
  84    $enddate = 'Present';
  85    list($end_year,$end_month,$end_day) = explode('-',date("Y-m-d",time()));
  86    $current = "To Date:";
  87   }
  88   $length = ($end_year * 12 + $end_month) - ($start_year * 12 + $start_month);
  89   $total_length = $total_length + $length;
  90   
  91   if ($user_group < 2 && $print != "Y" ) {
  92    $i = $i + 2;
  93    print "<tr>
  94            <td><input type=text size=20 maxlength=20 name=position[$leadership_key] value=\"$position\"></td>
  95            <td><input type=text size=10 maxlength=10 name=startdate[$leadership_key] value='$startdate'
  96                   onChange=\"var box=document.forms[0].elements[$i];var d=parseDate(box.value);
  97                           if(d==null){
  98                            alert('Date string not recognizable!');
  99                            box.value='';
 100                            box.focus();
 101                           } else {
 102                            box.value=formatDate(d,'yyyy-MM-dd');
 103                           }\"></td>";
 104    $i = $i + 1;
 105    print "\n<td><input type=text size=10 maxlength=10 name=enddate[$leadership_key] value='$enddate'
 106                   onChange=\"var box=document.forms[0].elements[$i];var d=parseDate(box.value);
 107                           if(d==null){
 108                            alert('Date string not recognizable!');
 109                            box.value='';
 110                            box.focus();
 111                           } else {
 112                            box.value=formatDate(d,'yyyy-MM-dd');
 113                           }\"></td>
 114            <td align=center><b>$current $length</td>
 115        <td align=center><input type=checkbox name=delete[$leadership_key] value=Y></td>
 116           </tr>";
 117   $i = $i + 1;
 118   } else {
 119    print "<tr>
 120            <td>$position</td>
 121            <td>$startdate</td>
 122            <td>$enddate</td>
 123            <td align=center><b>$length</td>
 124           </tr>";
 125   }
 126   
 127  }
 128  mysql_free_result($sql);
 129  
 130  if ($user_group <2 && $print != "Y") {
 131   $i = $i + 2;
 132   print "<tr>
 133           <td><input type=text size=20 maxlength=20 name=position[000]></td>
 134           <td><input type=text size=10 maxlength=10 name=startdate[000]
 135                  onChange=\"var box=document.forms[0].elements[$i];var d=parseDate(box.value);
 136                           if(d==null){
 137                            alert('Date string not recognizable!');
 138                            box.value='';
 139                            box.focus();
 140                           } else {
 141                            box.value=formatDate(d,'yyyy-MM-dd');
 142                           }\"></td>";
 143   $i = $i + 1;
 144   print "\n<td><input type=text size=10 maxlength=10 name=enddate[000]
 145                  onChange=\"var box=document.forms[0].elements[$i];var d=parseDate(box.value);
 146                           if(d==null){
 147                            alert('Date string not recognizable!');
 148                            box.value='';
 149                            box.focus();
 150                           } else {
 151                            box.value=formatDate(d,'yyyy-MM-dd');
 152                           }\"></td>";
 153  } else {
 154   print "<tr><td></td><td></td><td></td>";
 155  }
 156  print "<td>Total: $total_length</td><td></td>";
 157  print "</tr>";
 158  
 159  print "</table>";
 160  if ($user_group <2 && $print != "Y") {
 161   print "<center><input type=submit value=Submit></center></form>";
 162  }
 163  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]