Sample-CorePHP-Repository/extract_data.php
kris@sentientgeeks.com 01ed2f0b15 initial Commit
2021-02-09 10:26:46 +05:30

2705 lines
94 KiB
PHP

<?php
{
session_start();
require_once("dbconnect.php");
$step = 1;
if(isset($_REQUEST['step']) && $_REQUEST['step'] != "")
{
$step = $_REQUEST['step'];
}
$sql = "select * from ath_Seasons where id = ".$_REQUEST['season_id'];
$result = sqlsrv_query($conn,$sql);
$row = sqlsrv_fetch_array($result);
$season_year = $row['season_year'];
//Begin:- Step 1: Extract data *******************************************************
if(isset($_REQUEST['bStep1']) && $_REQUEST['bStep1'] == 'Extract Data' && $step == 1)
{
// inserting raw data into table
$meet_name = $_REQUEST['hMeet'];
$meet_id = $_REQUEST['meet'];
$extract_sex = $_REQUEST['extractSex'];
$data = $_REQUEST['tData'];
$lines = explode("\n", $data);
$header_row = "";
$detail_row = "";
$row_count = 0;
// Save text data
$arrParams[]= "";
$sql = "insert into ath_Importdatatable_Master (entry_date,extract_sex, meet_id, text_data, process_status) values (getdate(), '".$extract_sex."', '".$meet_id."', '".str_replace("'","''", $data)."',0); SELECT SCOPE_IDENTITY()";
$result = sqlsrv_query($conn, $sql, $arrParams);
sqlsrv_next_result($result);
sqlsrv_fetch($result);
$master_id = sqlsrv_get_field($result, 0);
// Save log master
$arrParams[]= "";
$sql = "insert into ath_Importdatatable_Master_Log (master_id,entry_date, process_status) values ('".$master_id."',getdate(),0); SELECT SCOPE_IDENTITY()";
$result = sqlsrv_query($conn, $sql, $arrParams);
sqlsrv_next_result($result);
sqlsrv_fetch($result);
$log_id = sqlsrv_get_field($result, 0);
// Save text data
$sql = "delete from ath_Importdatatable";
$result = sqlsrv_query($conn, $sql);
//identifying data format
if(strpos($data,"TEK's")!==false)
{
$format_type = 1; //hi-tek's format
//echo "hi-tek"; exit;
}
else if(strpos($data,"Leone Timing") !== false || strpos($data,"Yen Timing") !== false)
{
$format_type = 2; //Leone Timing & Results Services (cross country)
// echo "Leone"; exit;
}
else
{
$format_type = 0; //race tab format
//echo "race"; exit;
}
if("".$_REQUEST['file_format'] == "1")
{
$format_type = 3;
}
//--------------------------
// including extract data logic ----------------------
switch ($format_type)
{
case 0:
include('racetab_format.php');
//echo "race";exit;
break;
case 1:
include('hy-tek_format_txt.php');
//echo "hy-tek";exit;
break;
case 2:
include('leone_timing_format_txt.php');
//echo "leone_tim";exit;
break;
case 3:
include('csv_format.php');
break;
default:
}
//-----------------------------------------------------
//$output .= "</table>";
//$_SESSION['extract_data_sajan'] = $output;
// Save log master
$url = "extract_data.php?season_id=".$_REQUEST['season_id']."&step=2&master_id=".$master_id;
$url = $url."&log_id=".$log_id;
header("location: ".$url);
die();
}
//End:- Step 1: Extract data *******************************************************
//Begin:- RE-PROCESS pending records **************************************************
if(isset($_REQUEST['reprocess']) && $_REQUEST['reprocess']=='1' && $step == 2)
{
$sql = "delete from ath_Importdatatable";
$rs = sqlsrv_query($conn, $sql);
$sql = "insert into ath_Importdatatable (Meet,Event,race_level,Round,Place,perform_time_char,performance,Number,meet_id,event_id,athlete_id,perform_time,Sex,performance_id,school_id,school_name,athlete_name,header_row,detail_row,event_type, class_year, event_unit, group_id)
select Meet,Event,race_level,Round,Place,perform_time_char,performance,Number,meet_id,event_id,athlete_id,perform_time,Sex,performance_id,school_id,school_name,athlete_name,header_row,detail_row,event_type,class_year, event_unit, group_id from ath_Importdatatable_history
where master_id = ".$_REQUEST['master_id']." and log_id =".$_REQUEST['log_id']. " order by Event,race_level,Round,Sex,Place";
$rs = sqlsrv_query($conn, $sql);
$rows_affected = sqlsrv_rows_affected( $rs);
$arrParams[]= "";
$sql = "insert into ath_Importdatatable_Master_Log (master_id,entry_date, process_status) values ('".$_REQUEST['master_id']."',getdate(),0); SELECT SCOPE_IDENTITY()";
$result = sqlsrv_query($conn, $sql, $arrParams);
sqlsrv_next_result($result);
sqlsrv_fetch($result);
$log_id = sqlsrv_get_field($result, 0);
$sql = "UPDATE ath_Importdatatable_Master_Log SET total_result = ".$rows_affected." WHERE id =".$log_id;
$rs = sqlsrv_query($conn, $sql);
$url = "extract_data.php?season_id=".$_REQUEST['season_id']."&step=2&master_id=".$_REQUEST['master_id'];
$url = $url."&log_id=".$log_id;
header("location: ".$url);
die();
}
//End:- RE-PROCESS pending records **************************************************
//Begin:- Step 2: Update School ID ****************************************************
if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') ) && $step == 2)
{
$row_count = 0;
$sql = "select * from ath_Importdatatable where isnull(school_id,0) = 0 and isnull(school_name,'') != '' order by id";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
$sql = "select id from ath_schools where School_name_long = '". str_replace("'","''", trim($row['school_name']))."' or School_name = '". str_replace("'","''", trim($row['school_name']))."' or LTRIM(RTRIM(alt_names)) = '". str_replace("'","''", trim($row['school_name']))."' or (',' + LTRIM(RTRIM(alt_names)) + ',') LIKE '%,' + '".str_replace("'","''", trim($row['school_name']))."' + ',%' ";
//echo $sql;
$rsSchool = sqlsrv_query($conn,$sql);
$rowSchool = sqlsrv_fetch_array($rsSchool);
$school_id = 0+$rowSchool['id'];
if($school_id>0)
{
$sql = "update ath_Importdatatable set school_id = ".$school_id." where id = ".$row['id'];
$rs = sqlsrv_query($conn, $sql);
$row_count++;
}
}
}
if(isset($_REQUEST['bStep2Save']) && $_REQUEST['bStep2Save'] == 'Save Changes')
{
$school_count = $_REQUEST['hSchoolCount'];
for($i=0; $i<$school_count; $i++)
{
$id = $_REQUEST['hId'.$i];
$athlete_name = $_REQUEST['athleteName'.$id];
$school_name = $_REQUEST['schoolName'.$id];
$sql = "update ath_Importdatatable set school_name = '". str_replace("'","''",$school_name)."', athlete_name = '". str_replace("'","''",$athlete_name)."' where id = ".$id;
$rs = sqlsrv_query($conn, $sql);
}
}
if(isset($_REQUEST['bStep2Next']) && $_REQUEST['bStep2Next'] == 'Next')
{
$master_id = $_REQUEST['master_id'];
// Save log master
$url ="extract_data.php?season_id=".$_REQUEST['season_id']."&step=3&master_id=".$master_id;
if(isset($_REQUEST['log_id']))
{
$log_id = $_REQUEST['log_id'];
$url = $url."&log_id=".$log_id;
}
header("location: ".$url);
die();
}
//End:- Step 2: Update School ID ****************************************************
//Begin:- Step 3: Update Event ID ***************************************************
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') ) && $step == 3)
{
ini_set('max_execution_time', 300);
$row_count = 0;
$sql = "select * from ath_Importdatatable where isnull(event_id,0) = 0 and isnull(Event,'') != '' order by id";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
$sql = "select id, unit from ath_events where event_name = '". str_replace("'","''", trim($row['Event']))."' or LTRIM(RTRIM(alt_event_names)) = '". str_replace("'","''", trim($row['Event']))."' or (',' + LTRIM(RTRIM(alt_event_names)) + ',') LIKE '%,' + '".str_replace("'","''", trim($row['Event']))."' + ',%' ";
$rsEvent = sqlsrv_query($conn,$sql);
$rowEvent = sqlsrv_fetch_array($rsEvent);
$event_id = 0+$rowEvent['id'];
$event_unit = $rowEvent['unit'];
if($event_id>0)
{
$sql = "update ath_Importdatatable set event_id = ".$event_id.", event_unit = '".$event_unit."' where id = ".$row['id'];
$rs = sqlsrv_query($conn, $sql);
$row_count++;
}
}
}
if(isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')
{
$group_id_count = $_REQUEST['hEventCount'];
for($i=1; $i<=$group_id_count; $i++)
{
$id = $_REQUEST['hId'.$i];
$event_name = $_REQUEST['eventName'.$id];
$race_level = $_REQUEST['raceLevel'.$id];
$round = $_REQUEST['Round'.$id];
$sql = "update ath_Importdatatable set race_level = '".str_replace("'","''",$race_level)."', round = '".str_replace("'","''",$round)."', Event = '". str_replace("'","''",$event_name)."' where group_id = ".$id;
$rs = sqlsrv_query($conn, $sql);
}
}
if(isset($_REQUEST['bStep3Next']) && $_REQUEST['bStep3Next'] == 'Next')
{
$master_id = $_REQUEST['master_id'];
// Save log master
$url ="extract_data.php?season_id=".$_REQUEST['season_id']."&step=4&master_id=".$master_id;
if(isset($_REQUEST['log_id']))
{
$log_id = $_REQUEST['log_id'];
$url = $url."&log_id=".$log_id;
}
header("location: ".$url);
die();
}
//End:- Step 3: Update Event ID ***************************************************
//Begin:- Step 4: Update Athlete ID ***********************************************
if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') ) && $step == 4)
{
ini_set('max_execution_time', 300);
$row_count = 0;
$sql = "select * from ath_Importdatatable where isnull(athlete_id,0) = 0 and isnull(Athlete_name,'') != '' order by id";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
if( strpos($row["athlete_name"],",") !== false)
{
$name_array = explode(",", $row["athlete_name"]);
if(count($name_array) == 2)
{
$firstname = $name_array[1];
$lastname = $name_array[0];
}
else
{
$lastname = $name_array[0];
$lastname = "";
for($i=1; $i<count($name_array); $i++)
{
$firstname .= $name_array[$i]." ";
}
}
}
else
{
$name_array = explode(" ", $row["athlete_name"]);
if(count($name_array) == 2)
{
$firstname = $name_array[0];
$lastname = $name_array[1];
}
else
{
$firstname = $name_array[0];
$lastname = "";
for($i=1; $i<count($name_array); $i++)
{
$lastname .= $name_array[$i]." ";
}
}
}
ini_set('max_execution_time', 300);
$athlete_name = trim($firstname)." ".trim($lastname);
$sql = " select a.id from ath_athletes_all a, ath_athlete_roster r
where a.id = r.Athlete_Id and a.school_id = ".$row['school_id']." and r.season_id = ".$_REQUEST['season_id']."
and a.sex = '".$row['Sex']."' and (
ltrim(rtrim(a.firstname)) + ' ' + ltrim(rtrim(a.lastname)) = '". str_replace("'","''", trim($athlete_name))."'
or ltrim(rtrim(a.lastname)) + ' ' + ltrim(rtrim(a.firstname)) = '". str_replace("'","''", trim($athlete_name))."'
or alt_names like '%". str_replace("'","''", trim($athlete_name))."%'
) ";
$rsAthlete = sqlsrv_query($conn,$sql);
$rowAthlete = sqlsrv_fetch_array($rsAthlete);
$athlete_id = 0+$rowAthlete['id'];
if($athlete_id>0)
{
$sql = "update ath_Importdatatable set athlete_id = ".$athlete_id." where id = ".$row['id'];
$rs = sqlsrv_query($conn, $sql);
$row_count++;
}
else
{
$sql = "select id from ath_athletes_all where school_id = ".$row['school_id']." and sex = '".$row['Sex']."' and (ltrim(rtrim(firstname)) + ' ' + ltrim(rtrim(lastname)) = '". str_replace("'","''", trim($athlete_name))."' or ltrim(rtrim(lastname)) + ' ' + ltrim(rtrim(firstname)) = '". str_replace("'","''", trim($athlete_name))."' or alt_names like '%". str_replace("'","''", trim($athlete_name))."%') ";
$rsAthlete = sqlsrv_query($conn,$sql);
$rowAthlete = sqlsrv_fetch_array($rsAthlete);
$athlete_id = 0+$rowAthlete['id'];
if($athlete_id>0)
{
$sql = "update ath_Importdatatable set athlete_id = ".$athlete_id." where id = ".$row['id'];
$rs = sqlsrv_query($conn, $sql);
$row_count++;
}
}
}
}
if(isset($_REQUEST['bStep4Save']) && $_REQUEST['bStep4Save'] == 'Save Changes')
{
$school_count = $_REQUEST['hAthleteCount'];
for($i=0; $i<$school_count; $i++)
{
$id = $_REQUEST['hId'.$i];
$classYear = isset($_REQUEST['tClassYear'.$id]) && $_REQUEST['tClassYear'.$id] != "" && is_numeric($_REQUEST['tClassYear'.$id])?$_REQUEST['tClassYear'.$id]:0;
$athlete_name = $_REQUEST['athleteName'.$id];
$sql = "update ath_Importdatatable set athlete_name = '". str_replace("'","''",$athlete_name)."'";
if($classYear>0)
$sql .= ", class_year = ".$classYear."";
$sql .= " where id = ".$id;
$rs = sqlsrv_query($conn, $sql);
if($classYear>0)
{
$sql = "update ath_athletes_all set class_year = ".$classYear." where ID = ".$_REQUEST['hAthleteId'.$id];
$rs = sqlsrv_query($conn, $sql);
}
}
}
if(isset($_REQUEST['bStep4Next']) && $_REQUEST['bStep4Next'] == 'Next')
{
$master_id = $_REQUEST['master_id'];
// Save log master
$url ="extract_data.php?season_id=".$_REQUEST['season_id']."&step=5&master_id=".$master_id;
if(isset($_REQUEST['log_id']))
{
$log_id = $_REQUEST['log_id'];
$url = $url."&log_id=".$log_id;
}
header("location: ".$url);
die();
}
//End:- Step 4: Update Athlete ID ***********************************************
//Begin:- Step 5: Update Time/Distance ******************************************
if(((isset($_REQUEST['bStep5']) && $_REQUEST['bStep5'] == 'Update Time/Distance') || (isset($_REQUEST['bStep5Reprocess']) && $_REQUEST['bStep5Reprocess'] == 'Reprocess') ) && $step == 5)
{
ini_set('max_execution_time', 300);
$sql = "update ath_Importdatatable set perform_time_char = replace(perform_time_char,'-',' Ft ') where isnull(perform_time_char,'') != '' and event_unit = 'D'";
$rs = sqlsrv_query($conn, $sql);
$sql = "update ath_Importdatatable set perform_time_char = perform_time_char + ' In.' where isnull(perform_time_char,'') != '' and charindex('In.',perform_time_char)=0 and event_unit = 'D'";
$rs = sqlsrv_query($conn, $sql);
$row_count = 0;
$sql = "select * from ath_Importdatatable where isnull(perform_time,0.00) = 0 and isnull(perform_time_char,'') != '' order by id";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
try
{
if($row['perform_time_char'] != "" && $row['event_unit'] == "T")
{
$sql = "update ath_Importdatatable set perform_time = dbo.timetoInt(perform_time_char) where id = ".$row['id'];
$rs = sqlsrv_query($conn, $sql);
$row_count++;
}
if($row['perform_time_char'] != "" && $row['event_unit'] == "D")
{
$sql = "update ath_Importdatatable set perform_time = dbo.distancetoInt(perform_time_char) where id = ".$row['id'];
$rs = sqlsrv_query($conn, $sql);
$row_count++;
}
}
catch(Exception $e)
{
}
}
}
if(isset($_REQUEST['bStep5Save']) && $_REQUEST['bStep5Save'] == 'Save Changes')
{
$time_count = $_REQUEST['hTimeCount'];
for($i=0; $i<$time_count; $i++)
{
$id = $_REQUEST['hId'.$i];
$perform_time_char = $_REQUEST['Time'.$id];
$sql = "update ath_Importdatatable set perform_time_char = '". str_replace("'","''",$perform_time_char)."' where id = ".$id;
$rs = sqlsrv_query($conn, $sql);
}
}
if(isset($_REQUEST['bStep5Next']) && $_REQUEST['bStep5Next'] == 'Next')
{
$master_id = $_REQUEST['master_id'];
// Save log master
$url ="extract_data.php?season_id=".$_REQUEST['season_id']."&step=6&master_id=".$master_id;
if(isset($_REQUEST['log_id']))
{
$log_id = $_REQUEST['log_id'];
$url = $url."&log_id=".$log_id;
}
header("location: ".$url);
die();
}
//End:- Step 5: Update Time/Distance ***********************************************
//Begin:- Step 6: Insert into performance table ***********************************************
if(isset($_REQUEST['bStep6']) && $_REQUEST['bStep6'] == 'Insert into performance table' && $step == 6)
{
ini_set('max_execution_time', 300);
$master_id = $_REQUEST['master_id'];
if(isset($_REQUEST['log_id']))
{
$log_id = $_REQUEST['log_id'];
}
//updating performance_id for individual performances
$sql = "UPDATE ath_Importdatatable
SET performance_id = ath_Performances_all.id
FROM ath_Importdatatable
INNER JOIN ath_Performances_all ON
ath_Importdatatable.meet_id = ath_Performances_all.meet_id
and ath_Importdatatable.event_id = ath_Performances_all.event_id
and ath_Importdatatable.athlete_id = ath_Performances_all.athlete_id
and ath_Importdatatable.perform_time = ath_Performances_all.perform_time
and ath_Importdatatable.round = ath_Performances_all.race_round
and ath_Importdatatable.race_level = ath_Performances_all.race_level
where ath_Importdatatable.performance_id is null and isnull(event_type,'I') = 'I'";
$rs = sqlsrv_query($conn, $sql);
//updating performance_id for relay performances
$sql = "UPDATE ath_Importdatatable
SET performance_id = ath_Performances_Relay.id
FROM ath_Importdatatable
INNER JOIN ath_Performances_Relay ON
ath_Importdatatable.meet_id = ath_Performances_Relay.meet_id
and ath_Importdatatable.event_id = ath_Performances_Relay.event_id
and ath_Importdatatable.perform_time = ath_Performances_Relay.perform_time
and ath_Importdatatable.round = ath_Performances_Relay.race_round
and ath_Importdatatable.race_level = ath_Performances_Relay.race_level
where ath_Importdatatable.performance_id is null and isnull(event_type,'') = 'R'";
$rs = sqlsrv_query($conn, $sql);
/*
$sql = "select timing from ath_meets_all where id = (select top 1 meet_id from ath_Importdatatable)" ;
$rsMeet = sqlsrv_query($conn, $sql);
$rowMeet = sqlsrv_fetch_array($rsMeet);
if($rowMeet['timing'] == "A")
{
$electronic_timer = 1;
}
else
{
$electronic_timer = 0;
}
*/
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
//inserting induvidual performances
$sql = "insert into ath_Performances_all (athlete_id,place,perform_time_char,perform_time,meet_id,event_id,race_round,race_level,entry_date,verified_status,user_id,electronic_timer)
select athlete_id,place,perform_time_char,perform_time,meet_id,event_id,round,race_level, convert(varchar(10), getdate(),101) as entry_date, 0 as verified_status,10 as user_id,electronic_timer from ath_Importdatatable
where isnull(event_id,0) <> 0 and isnull(school_id,0) <> 0 and isnull(athlete_id,0) <> 0 and isnull(perform_time,0.00) <> 0 and isnull(performance_id,0) = 0 and isnull(event_type,'') = 'I'";
//echo $sql."<br>";
$rs = sqlsrv_query($conn, $sql, $params, $options);
$row_count = sqlsrv_num_rows($rs);
//inserting new roster
/*
$sqlroster = "insert into ath_athlete_roster(Athlete_Id,Season_Id,create_date,status)
select distinct athlete_id,".$_REQUEST['season_id']." as Season_Id,getdate() as create_date,0 as status from ath_Importdatatable
where isnull(event_id,0) <> 0 and isnull(school_id,0) <> 0 and isnull(athlete_id,0) <> 0
and isnull(perform_time,0.00) <> 0 and isnull(performance_id,0) = 0 and isnull(event_type,'') = 'I'
and athlete_id NOT IN(select distinct Athlete_Id
from ath_athlete_roster where Season_Id=".$_REQUEST['season_id'].")";
$rsroster = sqlsrv_query($conn, $sqlroster, $params, $options);
*/
//inserting new roster end
/*
$sql = "insert into ath_Performances_all (athlete_id,place,perform_time_char,perform_time,meet_id,event_id,race_round,race_level,entry_date,verified_status,user_id)
select athlete_id,place,performance,perform_time,meet_id,event_id,round,race_level, convert(varchar(10), getdate(),101) as entry_date,0 as verified_status,10 as user_id from ath_Importdatatable
where isnull(event_id,0) <> 0 and isnull(school_id,0) <> 0 and isnull(athlete_id,0) <> 0 and isnull(performance,'') <> '' and isnull(perform_time,0.00) <> 0 and isnull(performance_id,0) = 0 and isnull(event_type,'I') = 'I'";
$rs = sqlsrv_query($conn, $sql, $params, $options);
$row_count += sqlsrv_num_rows($rs);
*/
//inserting relay performances
$sql = "insert into ath_Performances_Relay(school_id, place, perform_time_char, perform_time, meet_id, event_id, sex, race_round, race_level)
select school_id, place, perform_time_char, perform_time, meet_id, event_id, sex, round, race_level from ath_Importdatatable
where isnull(event_id,0) <> 0 and isnull(school_id,0) <> 0 and isnull(perform_time,0.00) <> 0 and isnull(performance_id,0) = 0 and isnull(event_type,'') = 'R'";
$rs = sqlsrv_query($conn, $sql, $params, $options);
$row_count += sqlsrv_num_rows($rs);
// Save log master
$sql = "insert into ath_Importdatatable_History (Meet,Event,race_level,Round,Place,perform_time_char,performance,Number,meet_id,event_id,athlete_id,perform_time,Sex,performance_id,school_id,school_name,athlete_name,header_row,detail_row,master_id,log_id, event_type,class_year,event_unit, group_id)
select Meet,Event,race_level,Round,Place,perform_time_char,performance,Number,meet_id,event_id,athlete_id,perform_time,Sex,performance_id,school_id,school_name,athlete_name,header_row,detail_row,".$master_id." as master_id,".$log_id.", event_type,class_year,event_unit, group_id from ath_Importdatatable
where ( (isnull(event_type,'I') = 'I' and (athlete_id is null OR school_id is null OR event_id is null OR perform_time is null)) or (isnull(event_type,'') = 'R' and (school_id is null OR event_id is null OR perform_time is null)) )";
$rs = sqlsrv_query($conn, $sql,$params, $options);
$pending_count = sqlsrv_num_rows($rs);
// Save log master
$sql = "UPDATE ath_Importdatatable_Master_Log SET process_status = 1,pending_result =".$pending_count." WHERE id =".$log_id;
$rs = sqlsrv_query($conn, $sql);
// Save text data
//echo "<a href='extract_data.php?season_id=".$_REQUEST['season_id'].">Continue to enter results</a>";
}
//End:- Step 6: Insert into performance table ***********************************************
if(isset($_REQUEST['bStep6Continue']) && $_REQUEST['bStep6Continue'] == 'Continue to enter results' && $step == 6)
{
header("location: extract_data.php?season_id=".$_REQUEST['season_id']);
die();
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Extract Data</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="js/bootstrap.js"></script>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script>
var athletes_array = new Array();
//
$(function() {
$( "#dialog-school" ).dialog({
autoOpen: false,
resizable: false,
height:200,
modal: true,
buttons:
{
"Save": function()
{
var id = $("#dialog-school").data('id');
var schoolname = $("#schoolName"+id).val();
var dat = 'action=AddAltSchool&name='+schoolname.trim()+'&schoolid='+$('#school').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$( "#dialog-school" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function schoolPopup(id){
$("#dialog-school").data('id', id).dialog("open");
}
/*Participating Schools Alternate name*/
$(function() {
$("#dialog-part-School-Alt").dialog({
autoOpen: false,
resizable: false,
height:200,
modal: true,
buttons:
{
"Save": function()
{
var id = $("#dialog-part-School-Alt").data('id');
var schoolname = $("#parSchoolName"+id).val();
var dat = 'action=AddAltSchool&name='+schoolname.trim()+'&schoolid='+$('#partschool').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#dialog-part-School-Alt" ).dialog('close');
alert("Alternate name added successfully");
var alternate = msg.split("|");
$("#parOrgSchoolName"+id).val(alternate[1]);
$("#parLeagueName"+id).val(alternate[2]);
$("#parSchoolId"+id).val(alternate[0]);
$("#bAddPartSchool"+id).hide();
$("#bPartAltSchool"+id).hide();
$("#bEditSchoo"+id).hide();
$("#bPartRemoveAltSchool"+id).show();
//$("#colActionId"+id).html('<input type="button" class="btn btn-primary" id="bRemoveAlt'+id+'" style="height:20px; width:40px; padding:0px; font-size:11px" value="Remove Alternate" onclick="removePartSchoolAlternate('+id+');"/>');
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function partSchoolAltPopup(id){
$("#dialog-part-School-Alt").data('id', id).dialog("open");
}
/*Participating Schools Alternate name End*/
/*Participating Schools Remove Alternate name*/
$(function() {
$("#dialog-part-School-Alt-Remove").dialog({
autoOpen: false,
resizable: false,
height:300,
width:500,
modal: true,
buttons:
{
"Yes": function()
{
var id = $("#dialog-part-School-Alt-Remove").data('id');
var schoolname = $("#parSchoolName"+id).val();
var dat = 'action=RemoveAltSchool&name='+schoolname.trim()+'&schoolid='+$("#parSchoolId"+id).val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#dialog-part-School-Alt-Remove" ).dialog('close');
alert("Alternate name removed successfully");
$("#parOrgSchoolName"+id).val('');
$("#parLeagueName"+id).val('');
$("#parSchoolId"+id).val('');
$("#bAddPartSchool"+id).show();
$("#bPartAltSchool"+id).show();
$("#bEditSchoo"+id).show();
$("#bPartRemoveAltSchool"+id).hide();
//$("#colActionId"+id).html('<input type="button" class="btn btn-primary" id="bRemoveAlt'+id+'" style="height:20px; width:40px; padding:0px; font-size:11px" value="Remove Alternate" onclick="removePartSchoolAlternate('+id+');"/>');
}
});
},
NO: function() {
$( this ).dialog( "close" );
}
}
});
});
function partSchoolRemoveAltPopup(id){
$("#dialog-part-School-Alt-Remove").data('id', id).dialog("open");
var name = $("#parSchoolName"+id).val();
var orgname = $("#parOrgSchoolName"+id).val();
$("#spanRemoveAlternate").text('"'+name+'" ');
$("#spanRemoveOrginal").text('"'+orgname+'" ');
}
/*Participating Schools Remove Alternate name End*/
$(function() {
$( "#dialog-event" ).dialog({
autoOpen: false,
resizable: false,
height:550, width:700,
modal: true,
buttons:
{
"Save": function()
{
var id = $("#dialog-event").data('id');
if($('input[name=event]').is(":checked")==false)
{
alert('Please select an event');
return false;
}
var eventname = $("#eventName"+id).val();
var dat = 'action=AddAltEvent&name='+eventname.trim()+'&eventid='+$('#event:checked').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$( "#dialog-event" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function eventPopup(id){
if($("#eventName"+id).val()=="")
{
alert('Alternate event name cannot be blank')
return false;
}
$("#dialog-event").data('id', id).dialog("open");
$("#selEvent").html($("#eventName"+id).val());
}
$(function() {
$( "#dialog-athlete" ).dialog({
autoOpen: false,
resizable: false,
height:650, width:800,
modal: true,
buttons:
{
"Save": function()
{
var id = $("#dialog-athlete").data('id');
var athlete_id = $("#hAtheleteID").val();
if(athlete_id=="")
{
alert('Please select an athlete');
return false;
}
var dat = 'action=updateAthlete&id='+id+'&athlete_id='+athlete_id;
//alert(dat);
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#td"+id).html(athlete_id);
$( "#dialog-athlete" ).dialog('close');
//$( this ).dialog( "close" );
}
});
},
Cancel: function()
{
$( this ).dialog( "close" );
}
}
});
});
function athletePopup(id){
$("#div_athletes").html("<div align='center' style='vertical-align:middle; text-align:center;' ><img src='../Images/ajax-loader.gif' align='middle'></div>");
$("#dialog-athlete").data('id', id).dialog("open");
var school_id = $("#hSchoolId"+id).val();
var sex = $("#hSex"+id).val();
var athleteName = $("#athleteName"+id).val();
var dat = 'action=SearchAthlete&season_id=<?php echo $_REQUEST['season_id']; ?>&school_id='+school_id+'&sex='+sex+'&athleteName='+athleteName;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#div_athletes").html(msg);
}
});
}
function showAthletes(){
$("#div_athletes").html("<div align='center' style='vertical-align:middle; text-align:center;' ><img src='../Images/ajax-loader.gif' align='middle'></div>");
var id = $("#dialog-athlete").data('id');
var school_id = $("#hSchoolId"+id).val();
var sex = $("#hSex"+id).val();
var dat = 'action=SearchAthlete&season_id=<?php echo $_REQUEST['season_id']; ?>&school_id='+school_id+'&sex='+sex;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#div_athletes").html(msg);
}
});
}
function showAllAthletes()
{
$("#div_athletes").html("<div align='center' style='vertical-align:middle; text-align:center;' ><img src='../Images/ajax-loader.gif' align='middle'></div>");
var id = $("#dialog-athlete").data('id');
var athleteName = $("#athleteName"+id).val();
var sex = $("#hSex"+id).val();
var dat = 'action=ShowAllAthletes&season_id=<?php echo $_REQUEST['season_id']; ?>&sex='+sex+'&athlete_name='+athleteName;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#div_athletes").html(msg);
}
});
}
function setAthleteID(id)
{
$("#hAtheleteID").val(id)
}
// Save text data
$(function() {
$( "#dialog-master-detail" ).dialog({
autoOpen: false,
resizable: false,
height:650, width:1020,
modal: true,
buttons:
{
Cancel: function()
{
$( this ).dialog( "close" );
}
}
});
});
function showDetailedMasterData(master_id,log_id){
$("#div_master_detail_data").html("<div align='center' style='vertical-align:middle; text-align:center;' ><img src='../Images/ajax-loader.gif' align='middle'></div>");
$("#dialog-master-detail").data('master_id', master_id).dialog("open");
var dat = 'action=showDetailedMasterData&master_id='+master_id+'&log_id='+log_id;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#div_master_detail_data").html(msg);
}
});
}
// Save text data
$(function() {
$( "#dialog-add-athlete" ).dialog({
autoOpen: false,
resizable: false,
height:300, width:450,
modal: true,
buttons: {
"Save": function(){
var errorMsg = "";
if($('#firstname').val().trim() == "" || $('#lastname').val().trim() == "" || $('#athschool').val().trim() == "" )
{
alert('Please enter mandatory fields');
return false;
}
var id = $("#dialog-add-athlete").data('id');
var sex = $("#hSex"+id).val();
var dat = 'action=AddAthlete&id='+id+'&firstname='+$('#firstname').val()+'&lastname='+$('#lastname').val()+'&dob='+$('#dob').val()+'&schoolid='+$('#athschool').val()+'&classyear='+$('#classyear').val()+'&sex='+sex ;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
alert(msg);
$("#td"+id).html(msg);
$( "#dialog-add-athlete" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function addAthletePopup(id){
$("#dialog-add-athlete").data('id', id).dialog("open");
$("#firstname").val('');
$("#lastname").val('');
$("#athschool").val('');
$("#dob").val('');
$("#classyear").val('');
var name = $("#athleteName"+id).val();
if(name!="")
{
if(name.indexOf(',')>0)
{
var namearr = name.split(',');
if(namearr.length == 2)
{
$("#firstname").val(namearr[1]);
$("#lastname").val(namearr[0]);
}
else
{
$("#lastname").val(namearr[0]);
var firstname = '';
for(i=1; i<namearr.length;i++)
firstname += namearr[i] + ' ';
$("#firstname").val(firstname.trim());
}
}
else
{
var namearr = name.split(' ');
if(namearr.length == 1)
{
$("#firstname").val(namearr[0]);
$("#lastname").val('');
}
else if(namearr.length == 2)
{
$("#firstname").val(namearr[0]);
$("#lastname").val(namearr[1]);
}
else
{
$("#firstname").val(namearr[0]);
var lastname = '';
for(i=1; i<namearr.length;i++)
lastname += namearr[i] + ' ';
$("#lastname").val(lastname.trim());
}
}
}
$("#athschool").val($("#hSchoolId"+id).val());
$("#classyear").val($("#hClassYear"+id).val());
var d = new Date();
var n = d.getFullYear();
}
$(function() {
$( "#dob" ).datepicker();
});
//Add New school
$(function() {
$( "#dialog-add-school" ).dialog({
autoOpen: false,
resizable: false,
height:210, width:450,
modal: true,
buttons: {
"Save": function(){
var errorMsg = "";
if($('#schoollongname').val().trim() == "" || $('#schoolshortname').val().trim() == "" || $('#athleague').val().trim() == "")
{
alert('Please enter mandatory fields');
return false;
}
var id = $("#dialog-add-school").data('id');
var dat = 'action=AddSchool&id='+id+'&schoollongname='+$('#schoollongname').val()+'&schoolshortname='+$('#schoolshortname').val()+'&leagueid='+$('#athleague').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#td"+id).html(msg);
$( "#dialog-add-school" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function addSchoolPopup(id){
$("#dialog-add-school").data('id', id).dialog("open");
$("#schoollongname").val('');
$("#schoolshortname").val('');
$("#athleague").val('');
var name = $("#schoolName"+id).val();
$("#schoollongname").val(name);
$("#schoolshortname").val(name);
}
/*Add new school from participating schools*/
$(function() {
$( "#dialog-add-part-school" ).dialog({
autoOpen: false,
resizable: false,
height:210, width:450,
modal: true,
buttons:{
"Save": function() {
var errorMsg = "";
if($('#partschoollongname').val().trim() == "" || $('#partschoolshortname').val().trim() == "" || $('#partathleague').val().trim() == "")
{
alert('Please enter mandatory fields');
return false;
}
var id = $("#dialog-add-part-school").data('id');
var dat = 'action=AddPartSchool&schoollongname='+$('#partschoollongname').val()+'&schoolshortname='+$('#partschoolshortname').val()+'&leagueid='+$('#partathleague').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#dialog-add-part-school").dialog('close');
alert('School added successfully.');
var newschooldetails = msg.split("|");
$("#parSchoolId"+id).val(newschooldetails[1]);
$("#parLeagueName"+id).val(newschooldetails[0]);
$("#bAddPartSchool"+id).hide();
$("#bPartAltSchool"+id).hide();
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function addPartSchoolPopup(id){
$("#dialog-add-part-school").data('id', id).dialog("open");
$("#partschoollongname").val('');
$("#partschoolshortname").val('');
$("#partathleague").val('');
var name = $("#parSchoolName"+id).val();
$("#partschoollongname").val(name);
$("#partschoolshortname").val(name);
}
/*End*/
//Participating School Edit
$(function() {
$( "#dialog-edit-part-school" ).dialog({
autoOpen: false,
resizable: false,
height:210, width:450,
modal: true,
buttons: {
"Save": function() {
var errorMsg = "";
/*if($('#schooleditname').val().trim() == "" || $('#schooleditid').val().trim() == ""||$.isNumeric($('#schooleditid').val().trim())==false)*/
if($('#schooleditname').val().trim() == "")
{
alert('Please enter mandatory fields');
if($('#schooleditid').val().trim() != "" && $.isNumeric($('#schooleditid').val().trim())==false)
{
return false;
}
return false;
}
var id = $("#dialog-edit-part-school").data('id');
var oldSchoolId = $("#dialog-edit-part-school").data('oldid');
var oldSchoolName = $("#dialog-edit-part-school").data('oldname');
/*var dat = 'action=EditPartSchool&oldSchoolId='+oldSchoolId+'&oldSchoolName='+oldSchoolName+'&schooleditname='+$('#schooleditname').val()+'&schoolid='+$('#schooleditid').val();*/
var dat = 'action=EditPartSchool&oldSchoolId='+oldSchoolId+'&oldSchoolName='+oldSchoolName+'&schooleditname='+$('#schooleditname').val()+'&schoolid='+$('#schooleditid').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
alert("School eidited successfully.");
$("#parSchoolName"+id).val($('#schooleditname').val());
$("#parSchoolId"+id).val($('#schooleditid').val());
$("#parSchoolId"+id).val($('#schooleditid').val());
$("#parLeagueName"+id).val(msg);
$("#parOrgSchoolName"+id).val('');
$("#dialog-edit-part-school" ).dialog('close');
//$("#dialog-participating-schools").dialog("close");
//document.location.reload(true);
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function editPartSchoolPopup(id){
var orgschoolname = $("#parOrgSchoolName"+id).val();
if(orgschoolname != '')
{
alert("Please remove previously added alternate name.");
return false;
}
$("#dialog-edit-part-school").data('id', id).dialog("open");
$("#schooleditname").val('');
$("#schooleditid").val('');
var name = $("#parSchoolName"+id).val();
var schid = $("#parSchoolId"+id).val();
$("#dialog-edit-part-school").data('oldname', name).dialog("open");
$("#dialog-edit-part-school").data('oldid', schid).dialog("open");
$("#schooleditname").val(name);
$("#schooleditid").val(schid);
}
//End
//Participating School delete
$(function() {
$("#dialog-delete-part-school" ).dialog({
autoOpen: false,
resizable: false,
height:210, width:450,
modal: true,
buttons:
{
"Yes": function()
{
var id = $("#dialog-delete-part-school").data('id');
var name = $("#parSchoolName"+id).val();
var dat = 'action=DeletePartSchool&schoolName='+name;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#dialog-delete-part-school" ).dialog('close');
alert("School deleted successfully.");
$('#rowparSchool'+id).remove();
}
});
},
No: function() {
$( this ).dialog( "close" );
}
}
});
});
function deletePartSchoolPopup(id){
$("#dialog-delete-part-school").data('id', id).dialog("open");
var name = $("#parSchoolName"+id).val();
$("#spanPartSchoolName").text('"'+name+'" ');
}
//End
$(function() {
$( "#dialog-alt-athlete" ).dialog({
autoOpen: false,
resizable: false,
height:450, width:700,
modal: true,
buttons:
{
"Save": function()
{
var id = $("#dialog-alt-athlete").data('id');
if($('input[name=altAthleteId]').is(":checked")==false)
{
alert('Please select an athlete');
return false;
}
var id = $("#dialog-alt-athlete").data('id');
var athletename = $("#athleteName"+id).val();
var dat = 'action=AddAltAthlete&name='+athletename.trim()+'&athleteid='+$('#altAthleteId:checked').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#td"+id).html($('#altAthleteId:checked').val()+'<input type="hidden" id="hAthleteId'+ id +'" name="hAthleteId'+ id +'" value="'+$('#altAthleteId:checked').val()+'">');
$( "#dialog-alt-athlete" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
});
function addAltAthletePopup(id){
var athleteName = $("#athleteName"+id).val();
if(athleteName=="")
{
alert('Athlete name cannot be blank');
return false;
}
$("#div_alt_athletes").html("<div align='center' style='vertical-align:middle; text-align:center;' ><img src='../Images/ajax-loader.gif' align='middle'></div>");
$("#dialog-alt-athlete").data('id', id).dialog("open");
var sex = $("#hSex"+id).val();
var schoolId = $("#hSchoolId"+id).val();
var athleteName = $("#athleteName"+id).val();
var dat = 'action=ShowAltAthletes&season_id=<?php echo $_REQUEST['season_id']; ?>&athlete_name='+athleteName+'&schoolId='+schoolId+'&sex='+sex+'&athleteName='+athleteName;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#div_alt_athletes").html(msg);
}
});
}
$(function() {
$( "#dialog-athlete_bulk" ).dialog({
autoOpen: false,
resizable: false,
height:550, width:500,
modal: true,
buttons:
{
"Save": function()
{
//$(this).attr("disabled", true);
var recCount = $("#hCount").val();
var j = 0;
for(i=0; i<recCount; i++)
{
if($("#chkSelect_"+i).is(':checked'))
{
var firstname = $("#firstname_"+i).val().trim();
var lastname = $("#lastname_"+i).val().trim();
var school_id = $("#school_id_"+i).val().trim();
if(firstname != "" && lastname != "" && school_id != "" )
{
var id = $("#id_"+i).val();
var sex = $("#sex_"+i).val();
var grade = $("#grade_"+i).val();
var classyear = $("#classyear_"+i).val();
athletes_array[j] = new Array()
athletes_array[j][0] = id;
athletes_array[j][1] = firstname;
athletes_array[j][2] = lastname;
athletes_array[j][3] = school_id;
athletes_array[j][4] = sex;
athletes_array[j][5] = grade;
athletes_array[j][6] = classyear;
j++;
}
}
}
if(athletes_array.length>0)
{
SaveBulkAthletes(0);
}
else
{
alert("Please select any athlete to save");
$( this ).dialog( "close" );
return;
}
},
Cancel: function()
{
$( this ).dialog( "close" );
}
}
});
});
function SaveBulkAthletes(row)
{
var dat = 'action=BulkAddAthlete&id='+athletes_array[row][0]+'&firstname='+athletes_array[row][1]+'&lastname='+athletes_array[row][2]+'&schoolid='+athletes_array[row][3]+'&classyear='+athletes_array[row][6]+'&grade='+athletes_array[row][5]+'&sex='+athletes_array[row][4] ;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#td"+athletes_array[row][0]).html(msg);
row++;
if(row < athletes_array.length)
{
SaveBulkAthletes(row);
}
else
{
alert("Athletes added successfully");
$( "#dialog-athlete_bulk" ).dialog('close');
}
}
});
}
function bulkAddAthletePopup(){
$("#div_athletes_bulk").html("<div align='center' style='vertical-align:middle; text-align:center;' ><img src='../Images/ajax-loader.gif' align='middle'></div>");
$("#dialog-athlete_bulk").data('id', '0').dialog("open");
var dat = 'action=ShowAthletesForBulkAdd&season_id=<?php echo $_REQUEST['season_id']; ?>';
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#div_athletes_bulk").html(msg);
}
});
}
function SelectAll()
{
$('input:checkbox').not(this).prop('checked', $("#checkall").is(':checked'));
}
function bulkEditSchoolPopup(){
$("#dialog-edit-school").data('id', '0').dialog("open");
$("#oldschoolname").val('');
$("#newschoolname").val('');
}
$(function() {
$( "#dialog-edit-school" ).dialog({
autoOpen: false,
resizable: false,
height:200, width:400,
modal: true,
buttons:
{
"Save": function()
{
if($("#oldschoolname").val().trim() == "" || $("#newschoolname").val().trim() == "")
{
alert('Please fill the school name');
return false;
}
var oldschoolname = $("#oldschoolname").val();
var newschoolname = $("#newschoolname").val();
var dat = 'action=BulkEditSchool&oldschoolname='+oldschoolname.trim()+'&newschoolname='+newschoolname;
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
alert("Successfully updated the school names");
$( "#dialog-edit-school" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$(this ).dialog( "close" );
}
}
});
});
function participatingSchools(){
$("#dialog-participating-schools").dialog("open");
$('#dialog-participating-schools').bind('dialogclose', function(event) {
//alert('closed');
$("input[name = 'bStep2Reprocess']").trigger('click');
});
}
$(function() {
$("#dialog-participating-schools" ).dialog({
autoOpen: false,
resizable: false,
height:400, width:850,
modal: true,
buttons:
{
/*"Save": function()
{
var errorMsg = "";
if($('#schoollongname').val().trim() == "" || $('#schoolshortname').val().trim() == "" || $('#athleague').val().trim() == "")
{
alert('Please enter mandatory fields');
return false;
}
var id = $("#dialog-add-school").data('id');
var dat = 'action=AddSchool&id='+id+'&schoollongname='+$('#schoollongname').val()+'&schoolshortname='+$('#schoolshortname').val()+'&leagueid='+$('#athleague').val();
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
$("#td"+id).html(msg);
$( "#dialog-add-school" ).dialog('close');
// $( this ).dialog( "close" );
}
});
},
Cancel: function() {
$( this ).dialog( "close" );
}*/
}
});
});
</script>
<!--Styles-->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<!--Style End-->
<!-- Mainly scripts -->
<script>
function setMeetName(obj)
{
document.getElementById('hMeet').value = obj.options[obj.selectedIndex].text;
var meetId = $('#meet').val();
var meetName = document.getElementById('hMeet').value;
//var dat = 'action=ShowMasterTextData&meetId='+meetId+'&meetName='+meetName;
var dat = 'action=ShowMasterTextData&meetId='+meetId+'&meetName='+meetName+'&season_id='+<?php echo $_REQUEST['season_id']; ?>;
//alert("here"+dat);
$.ajax({
type: "POST",
url: 'ajax.php',
data: dat,
success: function(msg){
document.getElementById('div_master_data').innerHTML = msg;
}
});
}
function validate()
{
if(document.getElementById('meet').value == "")
{
alert("Please select meet");
return false;
}
if(document.getElementById('tData').value == "")
{
alert("Please input data");
return false;
}
return true;
}
</script>
<!-- Mainly scripts end-->
<style>
td {
padding:2px;
}
th {
padding:2px;
}
</style>
</head>
<body>
<div style="width:100%; vertical-align:top;" id="maindiv">
<div style="width:100%;"><img src="images/newheadder.jpg" style="width:100%; height:auto;" /></div>
<div style="float:right; font-size:12px; font-weight:bold; padding:5px">
<a target="_blank" href="../reports/updateRaceID.cfm" >Update RaceID</a>&nbsp;|&nbsp;
<a target="_blank" href="../reports/updateRaceID_relay.cfm" >Update Relay RaceID</a>
</div>
<?php if($step==1) { ?>
<div style="width:100%;padding:15px; ">
<div style="text-align:left;color:#36C; ">
<h3>Step 1: Extract performanace data into temp. table</h3>
</div>
<div id="fileUpload">
<div id="msg" style="width:360px;"></div>
<div id="animateuploading" style="display:none;width:360px;" align="center"><img src="images/uploading.gif" alt="Uploading..."></div>
<form name="export1" method="post">
<div style="width:100%;"> <span>
<label for="fileMdb">Select Meet:</label>
</span> <span>
<select id="meet" name="meet" onchange="setMeetName(this);">
<option value="">Meet name</option>
<?php
if(isset($_REQUEST['season_id']))
{
$sSnId = $_REQUEST['season_id'];
$sql = "select ID as meet_id,meet_name,convert(varchar(10),meet_date,101) as meet_date from ath_Meets_all where ID > 0 ";
$sql .= " and season_ID =".$sSnId." order by meet_name";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
echo "<option value='".$row['meet_id']."' ".(isset($_REQUEST['meet']) && $_REQUEST['meet'] == $row['meet_id'] ? "selected" : "").">".$row['meet_name'].", ".$row['meet_date']."</option>";
}
}
?>
</select>
</span><br/><br/>
<span>
<label for="extSex">Select Sex:</label>&nbsp;&nbsp;
</span>
<span>
<select id="extractSex" name="extractSex">
<option value="B">Both</option>
<option value="M">Boys</option>
<option value="F">Girls</option>
</select>
</span>
Select file format:
<select id="file_format" name="file_format">
<option value="0" >Fixed width</option>
<option value="1" >CSV</option>
</select>
</div>
<br/>
<div id="div_master_data"></div>
<br/>
<div style="width:100%;">
<textarea id="tData" name="tData" style="width:80%" rows="10"><?php if(isset($_REQUEST['tData'])) echo $_REQUEST['tData']; ?>
</textarea>
</div>
<br/>
<div>
<input type="submit" class="btn btn-primary" id="bStep1" name="bStep1" value="Extract Data" onclick="return validate();" />
</div>
<input type="hidden" id="hMeet" name="hMeet" />
</form>
</div>
</div>
<?php } ?>
<?php if($step==2) { ini_set('max_execution_time', 300); ?>
<div style="width:100%; padding:15px; " >
<form name="export2" method="post">
<div style="text-align:left;color:#36C; ">
<h3>Step 2: Update School ID</h3>
</div>
<?php if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') ) && $step == 2) { ?>
<div style="text-align:left;color:#090;" align="left">
<h4><?php echo $row_count." rows updated"; ?></h4>
</div>
<?php } ?>
<div align="right">
<?php
if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep2Save']) && $_REQUEST['bStep2Save'] == 'Save Changes')) && $step == 2)
{
?>
<input type="button" class="btn btn-primary" name="bParticipateSchool" value="Participating Schools" onclick="participatingSchools();" />
&nbsp;
<input type="button" class="btn btn-primary" name="bBulkEditSchool" value="Bulk Edit School" onclick="bulkEditSchoolPopup();" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep2Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep2Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep2Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep2" value="Update School Id" />
<?php
}
?>
</div>
<br />
<div>
<table border='1' style='padding:4px; font-size:12px;' width="100%">
<tr style='font-weight:bold; '>
<th>Race Level</th>
<th>Round</th>
<th>Sex</th>
<th>Event</th>
<th>Place</th>
<th>Athlete</th>
<th style="width:350px;">School</th>
<th>School Id</th>
<th>Time/Distance</th>
<th>Performance data</th>
</tr>
<?php
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep2Save']) && $_REQUEST['bStep2Save'] == 'Save Changes')) && $step == 2)
$sql = "select * from ath_Importdatatable order by id"; //where school_id is null
else
$sql = "select * from ath_Importdatatable order by id";
$result = sqlsrv_query($conn,$sql,$params,$options);
$cnt = sqlsrv_num_rows($result);
$i=0;
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
?>
<tr>
<td><?php echo $row['race_level']; ?></td>
<td><?php echo $row['Round']; ?></td>
<td><?php echo $row['Sex']=="M"?"Boys":"Girls"; ?></td>
<td><?php echo $row['Event']; ?></td>
<td><?php echo $row['Place']; ?></td>
<td><?php
if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep2Save']) && $_REQUEST['bStep2Save'] == 'Save Changes')) && $step == 2)
{
?>
<input type="text" name="athleteName<?php echo $row['id']; ?>" id="athleteName<?php echo $row['id']; ?>" value="<?php echo $row['athlete_name']; ?>" style="width:100%" />
<?php
}
else
{
echo $row['athlete_name'];
}
?></td>
<td><?php
if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep2Save']) && $_REQUEST['bStep2Save'] == 'Save Changes')) && $step == 2)
{
?>
<input type="hidden" id="hId<?php echo $i; ?>" name="hId<?php echo $i; ?>" value="<?php echo $row['id']; ?>" />
<input type="text" name="schoolName<?php echo $row['id']; ?>" id="schoolName<?php echo $row['id']; ?>" value="<?php echo $row['school_name']; ?>" style="width:50%" />
&nbsp; Add as:
<input type="button" class="btn btn-primary" style="height:20px; width:60px; padding:0px; font-size:11px" id="bAddSchool<?php echo $row['id']; ?>" value="Alternate" onclick='schoolPopup(<?php echo $row['id']; ?>);' />
<input type="button" class="btn btn-primary" id="bAddAthlete<?php echo $row['id']; ?>" style="height:20px; width:40px; padding:0px; ; font-size:11px" value="New" onclick='addSchoolPopup(<?php echo $row['id']; ?>);' />
<?php
}
else
{
echo $row['school_name'];
}
?></td>
<td id="td<?php echo $row['id']; ?>"><?php echo $row['school_id']; ?></td>
<td><?php echo $row['perform_time_char']; ?></td>
<td><?php echo $row['detail_row']; ?></td>
</tr>
</tr>
<?php
$i++;
}
?>
</table>
<input type="hidden" name="hSchoolCount" id="hSchoolCount" value="<?php echo $cnt; ?>" />
</div>
<br />
<div align="right">
<?php
if(((isset($_REQUEST['bStep2']) && $_REQUEST['bStep2'] == 'Update School Id') || (isset($_REQUEST['bStep2Reprocess']) && $_REQUEST['bStep2Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep2Save']) && $_REQUEST['bStep2Save'] == 'Save Changes')) && $step == 2)
{
?>
<input type="submit" class="btn btn-primary" name="bStep2Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep2Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep2Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep2" value="Update School Id" />
<?php
}
?>
</div>
</form>
<?php
$log_id1 = isset($_REQUEST['log_id'])?trim($_REQUEST['log_id']):0;
$master_id1 = isset($_REQUEST['master_id'])?trim($_REQUEST['master_id']):0;
$sql1 = "select * from ath_Importdatatable_Master_Log_Details where log_id = '".$log_id1."' and master_id = '".$master_id1."' and status = 'FAILURE' order by id";
$result1 = sqlsrv_query($conn,$sql1,$params,$options);
$cnt1 = sqlsrv_num_rows($result1);
$i=1;
if($cnt1>0)
{
?>
<h3 style="color:red">FAILED RECORDS</h3>
<div style="margin:5px; border: thin solid red">
<?php
while ($row = sqlsrv_fetch_array($result1))
{
?>
<table width="100%" style="margin 10px; border:thin solid #000;">
<tr>
<td width="80px" align="left"><?php echo $i++; ?>.</td>
<td align="left">
<pre>
<u><?php echo $row['header_text']; ?></u><br/>
<?php echo $row['raw_record']; ?>
</pre>
</td>
<td width="200px" ><pre><?php echo $row['error']; ?></pre></td>
</tr>
</table>
<?php
}
?>
</div>
<?php
}
?>
</div>
<?php } ?>
<?php if($step==3) { ini_set('max_execution_time', 300);?>
<div style="width:100%; padding:15px; " >
<form name="export3" method="post">
<div style="text-align:left;color:#36C; ">
<h3>Step 3: Update Event ID</h3>
</div>
<?php if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') ) && $step == 3) { ?>
<div style="text-align:left;color:#090;" align="left">
<h4><?php echo $row_count." rows updated"; ?></h4>
</div>
<?php } ?>
<div align="right">
<?php
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')) && $step == 3)
{
?>
<input type="submit" class="btn btn-primary" name="bStep3Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep3Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep3Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep3" value="Update Event Id" />
<?php
}
?>
</div>
<br />
<div>
<table border='1' style='padding:4px; font-size:12px;' width="100%">
<tr style='font-weight:bold; '>
<th width="5%">Race Level</th>
<th width="5%">Round</th>
<th width="5%">Sex</th>
<th width="20%">Event Name</th>
<th width="5%">Event Id</th>
<th width="5%">Place</th>
<th width="10%">Athlete</th>
<th width="10%">School</th>
<th width="5%">School Id</th>
<th width="7%">Time / Distance</th>
<th>Perfomance data</th>
</tr>
<?php
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
/*
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')) && $step == 3)
$sql = "select * from ath_Importdatatable where event_id is null order by id";
else
$sql = "select * from ath_Importdatatable order by id";
*/
$sql = "select * from ath_Importdatatable where isnull(school_id,0) > 0 order by id"; //isnull(event_id,0) = 0 and
$result = sqlsrv_query($conn,$sql,$params,$options);
$cnt = sqlsrv_num_rows($result);
$i=0;
$group_id_change = -1;
$group_id_max = -1;
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
?>
<tr>
<td>
<?php
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')) && $step == 3)
{
if($group_id_change != $row['group_id'])
{
?>
<input type="text" name="raceLevel<?php echo $row['group_id']; ?>" id="raceLevel<?php echo $row['group_id']; ?>" value="<?php echo $row['race_level']; ?>" style="width:100%" />
<?php
}
}
else
{
echo $row['race_level'];
}
?>
</td>
<td>
<?php
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')) && $step == 3)
{
if($group_id_change != $row['group_id'])
{
?>
<input type="text" name="Round<?php echo $row['group_id']; ?>" id="Round<?php echo $row['group_id']; ?>" value="<?php echo $row['Round']; ?>" style="width:100%" />
<?php
}
}
else
{
echo $row['Round'];
}
?>
</td>
<td>
<?php
if($group_id_change != $row['group_id'])
{
echo $row['Sex']=="M"?"Boys":"Girls";
}
?>
</td>
<td>
<?php
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')) && $step == 3)
{
if($group_id_change != $row['group_id'])
{
?>
<input type="hidden" id="hId<?php echo $row['group_id']; ?>" name="hId<?php echo $row['group_id']; ?>" value="<?php echo $row['group_id']; ?>" />
<input type="text" name="eventName<?php echo $row['group_id']; ?>" id="eventName<?php echo $row['group_id']; ?>" value="<?php echo $row['Event']; ?>" style="width:75%" />
<input type="button" class="btn btn-primary" id="bAddEvent<?php echo $row['group_id']; ?>" style="height:20px; width:50px; padding:0px;" value="Add" onclick='eventPopup(<?php echo $row['group_id']; ?>);' />
<?php
}
}
else
{
echo $row['Event'];
}
?>
</td>
<td><?php echo $row['event_id']; ?></td>
<td><?php echo $row['Place']; ?></td>
<td><?php echo $row['athlete_name']; ?></td>
<td><?php echo $row['school_name'];?></td>
<td><?php echo $row['school_id']; ?></td>
<td><?php echo $row['perform_time_char']; ?></td>
<td><?php echo $row['detail_row']; ?></td>
</tr>
</tr>
<?php
$i++;
if($group_id_change != $row['group_id'])
{
$group_id_change = $row['group_id'];
}
$group_id_max = $group_id_change;
}
?>
</table>
<input type="hidden" name="hEventCount" value="<?php echo $group_id_max; ?>" />
</div>
<br />
<div align="right">
<?php
if(((isset($_REQUEST['bStep3']) && $_REQUEST['bStep3'] == 'Update Event Id') || (isset($_REQUEST['bStep3Reprocess']) && $_REQUEST['bStep3Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep3Save']) && $_REQUEST['bStep3Save'] == 'Save Changes')) && $step == 3)
{
?>
<input type="submit" class="btn btn-primary" name="bStep3Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep3Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep3Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep3" value="Update Event Id" />
<?php
}
?>
</div>
</form>
</div>
<?php } ?>
<?php if($step==4) { ini_set('max_execution_time', 300);?>
<div style="width:100%; padding:15px;" >
<form name="export4" method="post">
<div style="text-align:left;color:#36C; ">
<h3>Step 4: Update Athlete ID</h3>
</div>
<?php if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') ) && $step == 4) { ?>
<div style="text-align:left;color:#090;" align="left">
<h4><?php echo $row_count." rows updated"; ?></h4>
</div>
<?php } ?>
<div style="float:left;display:inline;">
<div style="width:20px;height:20px;background-color:#FFCC99;float:left;"></div><span style="float:left;">&nbsp;Stands for sec8 schools result.</span><br>
<div style="width:20px;height:20px;background-color:#FF6;float:left;"></div><span style="float:left;">&nbsp;Stands for Chsaa schools result.</span>
</div>
<div align="right">
<?php
if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep4Save']) && $_REQUEST['bStep4Save'] == 'Save Changes')) && $step == 4)
{
?>
<input type="button" class="btn btn-primary" name="bBulkAddAthletes" value="Bulk Add Athletes" onclick="bulkAddAthletePopup();" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep4Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep4Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep4Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep4" value="Update Athlete Id" />
<?php
}
?>
</div>
<br />
<div>
<table border='1' style='padding:4px; font-size:12px;' width="100%">
<tr style='font-weight:bold; '>
<th>Race Level</th>
<th>Round</th>
<th>Sex</th>
<th>Event Name</th>
<th>Place</th>
<th>Athlete Name</th>
<th>Athlete Id</th>
<th>School</th>
<th>School Id</th>
<th>Class year</th>
<th>Time/Distance</th>
<th>Performance data</th>
</tr>
<?php
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
/*
if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep4Save']) && $_REQUEST['bStep4Save'] == 'Save Changes')) && $step == 4)
$sql = "select * from ath_Importdatatable where athlete_id is null order by id";
else
$sql = "select * from ath_Importdatatable order by id";
*/
$sql = "select * from ath_Importdatatable where isnull(event_id,0) > 0 and isnull(school_id,0) > 0 order by id"; // isnull(athlete_id,0) = 0 and
$result = sqlsrv_query($conn,$sql,$params,$options);
$cnt = sqlsrv_num_rows($result);
$i=0;
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
//To identify section8 league
$sql_sec8_league = "select league_id from ath_schools where id=".$row['school_id']; // isnull(athlete_id,0) = 0 and
$league_result = sqlsrv_query($conn,$sql_sec8_league);
$schools_league = "";
while ($league_row = sqlsrv_fetch_array($league_result))
{
$schools_league = $league_row['league_id'];
}
//To identify section8 league end
?>
<tr <?php if($schools_league==1){ ?> style="background-color:#FFCC99;" <?php }else if($schools_league==3){ ?> style="background-color:#FF6;" <?php } ?> >
<td><?php echo $row['race_level']; ?></td>
<td><?php echo $row['Round']; ?></td>
<td><?php echo $row['Sex']=="M"?"Boys":"Girls"; ?></td>
<td><?php
echo $row['Event'];
?></td>
<td><?php echo $row['Place']; ?></td>
<td><?php
if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep4Save']) && $_REQUEST['bStep4Save'] == 'Save Changes')) && $step == 4)
{
?>
<input type="hidden" id="hId<?php echo $i; ?>" name="hId<?php echo $i; ?>" value="<?php echo $row['id']; ?>" />
<input type="text" name="athleteName<?php echo $row['id']; ?>" id="athleteName<?php echo $row['id']; ?>" value="<?php echo $row['athlete_name']; ?>" style="width:50%" />
<input type="button" class="btn btn-primary" id="bSearchAthlete<?php echo $row['id']; ?>" style="height:20px; width:50px; padding:0px;" value="Search" onclick='athletePopup(<?php echo $row['id']; ?>);' />
<input type="button" class="btn btn-primary" id="bAddAthlete<?php echo $row['id']; ?>" style="height:20px; width:50px; padding:0px;" value="Add" onclick='addAthletePopup(<?php echo $row['id']; ?>);' />
<input type="button" class="btn btn-primary" id="bAltAthlete<?php echo $row['id']; ?>" style="height:20px; width:50px; padding:0px;" value="Alt" onclick='addAltAthletePopup(<?php echo $row['id']; ?>);' />
<input type="hidden" id="hSchoolId<?php echo $row['id']; ?>" name="hSchoolId<?php echo $row['id']; ?>" value="<?php echo $row['school_id']; ?>" />
<input type="hidden" id="hSex<?php echo $row['id']; ?>" name="hSex<?php echo $row['id']; ?>" value="<?php echo $row['Sex']; ?>" />
<input type="hidden" id="hClassYear<?php echo $row['id']; ?>" name="hClassYear<?php echo $row['id']; ?>" value="<?php echo $row['class_year']; ?>" />
<?php
}
else
{
echo $row['athlete_name'];
}
?></td>
<td id="td<?php echo $row['id']; ?>"><?php echo $row['athlete_id']; ?><input type="hidden" id="hAthleteId<?php echo $row['id']; ?>" name="hAthleteId<?php echo $row['id']; ?>" value="<?php echo $row['athlete_id']; ?>" /></td>
<td><?php
echo $row['school_name'];
?></td>
<td><?php echo $row['school_id']; ?></td>
<td>
<?php
if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep4Save']) && $_REQUEST['bStep4Save'] == 'Save Changes')) && $step == 4 && $row['athlete_id'] != "" && $row['athlete_id'] != "0")
{
$ath_class_year="";
$sql = "select class_year from ath_athletes_all where ID = ".$row['athlete_id'];
$rsAth = sqlsrv_query($conn, $sql,$params, $options);
if(sqlsrv_num_rows($rsAth)>0)
{
$rowAth = sqlsrv_fetch_array($rsAth);
$ath_class_year=$rowAth['class_year'];
}
?>
<input type="text" id="tClassYear<?php echo $row['id']; ?>" name="tClassYear<?php echo $row['id']; ?>" style="width:50px" value="<?php echo $row['class_year']; ?>" <?php echo $ath_class_year=="" || $ath_class_year=="0"?"":"disabled" ?> />
<?php
}
else
{
echo $row['class_year'];
}
?>
</td>
<td><?php echo $row['perform_time_char']; ?></td>
<td><?php echo $row['detail_row']; ?></td>
</tr>
</tr>
<?php
$i++;
}
?>
</table>
<input type="hidden" name="hAthleteCount" value="<?php echo $cnt; ?>" />
</div>
<br />
<div align="right">
<?php
if(((isset($_REQUEST['bStep4']) && $_REQUEST['bStep4'] == 'Update Athlete Id') || (isset($_REQUEST['bStep4Reprocess']) && $_REQUEST['bStep4Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep4Save']) && $_REQUEST['bStep4Save'] == 'Save Changes')) && $step == 4)
{
?>
<input type="submit" class="btn btn-primary" name="bStep4Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep4Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep4Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep4" value="Update Athlete Id" />
<?php
}
?>
</div>
</form>
</div>
<?php } ?>
<?php if($step==5) { ini_set('max_execution_time', 300); ?>
<div style="width:100%; padding:15px; " >
<form name="export5" method="post">
<div style="text-align:left;color:#36C; ">
<h3>Step 5: Update Performance Time/Distance</h3>
</div>
<?php if(isset($_REQUEST['bStep5']) && $_REQUEST['bStep5'] == 'Update Time/Distance' && $step == 5) { ?>
<div style="text-align:left;color:#090;" align="left">
<h4><?php echo $row_count." rows updated"; ?></h4>
</div>
<?php } ?>
<div align="right">
<?php
if(((isset($_REQUEST['bStep5']) && $_REQUEST['bStep5'] == 'Update Time/Distance') || (isset($_REQUEST['bStep5Reprocess']) && $_REQUEST['bStep5Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep5Save']) && $_REQUEST['bStep5Save'] == 'Save Changes')) && $step == 5)
{
?>
<input type="submit" class="btn btn-primary" name="bStep5Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep5Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep5Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep5" value="Update Time/Distance" />
<?php
}
?>
</div>
<br />
<div>
<table border='1' style='padding:4px; font-size:12px;' width="100%">
<tr style='font-weight:bold; '>
<th>Race Level</th>
<th>Round</th>
<th>Sex</th>
<th>Event Name</th>
<th>Place</th>
<th>Athlete Name</th>
<th>Athlete Id</th>
<th>School</th>
<th>School Id</th>
<th>Time/Distance</th>
<th>Time/Distance (int)</th>
<th>Performance data</th>
</tr>
<?php
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
/*
if(((isset($_REQUEST['bStep5']) && $_REQUEST['bStep5'] == 'Update Time/Distance') || (isset($_REQUEST['bStep5Reprocess']) && $_REQUEST['bStep5Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep5Save']) && $_REQUEST['bStep5Save'] == 'Save Changes')) && $step == 5)
$sql = "select * from ath_Importdatatable where athlete_id is null order by id";
else
$sql = "select * from ath_Importdatatable order by id";
*/
$sql = "select * from ath_Importdatatable where
((isnull(athlete_id,0) > 0 and isnull(event_type,'I')='I') or (isnull(event_type,'')='R'))
and isnull(event_id,0) > 0
and isnull(school_id,0) > 0
order by id"; //isnull(perform_time,0) = 0 and
$result = sqlsrv_query($conn,$sql,$params,$options);
$cnt = sqlsrv_num_rows($result);
$i=0;
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
?>
<tr>
<td><?php echo $row['race_level']; ?></td>
<td><?php echo $row['Round']; ?></td>
<td><?php echo $row['Sex']=="M"?"Boys":"Girls"; ?></td>
<td><?php
echo $row['Event'];
?></td>
<td><?php echo $row['Place']; ?></td>
<td>
<?php
echo $row['athlete_name'];
?>
</td>
<td id="td<?php echo $row['id']; ?>"><?php echo $row['athlete_id']; ?></td>
<td><?php
echo $row['school_name'];
?></td>
<td><?php echo $row['school_id']; ?></td>
<td>
<?php
if(((isset($_REQUEST['bStep5']) && $_REQUEST['bStep5'] == 'Update Time/Distance') || (isset($_REQUEST['bStep5Reprocess']) && $_REQUEST['bStep5Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep5Save']) && $_REQUEST['bStep5Save'] == 'Save Changes')) && $step == 5)
{
?>
<input type="hidden" id="hId<?php echo $i; ?>" name="hId<?php echo $i; ?>" value="<?php echo $row['id']; ?>" />
<input type="text" name="Time<?php echo $row['id']; ?>" id="Time<?php echo $row['id']; ?>" value="<?php echo $row['perform_time_char']; ?>" style="width:100%" />
<?php
}
else
{
echo $row['perform_time_char'];
}
?>
</td>
<td><?php echo $row['perform_time']; ?></td>
<td><?php echo $row['detail_row']; ?></td>
</tr>
</tr>
<?php
$i++;
}
?>
</table>
<input type="hidden" name="hTimeCount" value="<?php echo $cnt; ?>" />
</div>
<br />
<div align="right">
<?php
if(((isset($_REQUEST['bStep5']) && $_REQUEST['bStep5'] == 'Update Time/Distance') || (isset($_REQUEST['bStep5Reprocess']) && $_REQUEST['bStep5Reprocess'] == 'Reprocess') || (isset($_REQUEST['bStep5Save']) && $_REQUEST['bStep5Save'] == 'Save Changes')) && $step == 5)
{
?>
<input type="submit" class="btn btn-primary" name="bStep5Reprocess" value="Reprocess" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep5Save" value="Save Changes" />
&nbsp;
<input type="submit" class="btn btn-primary" name="bStep5Next" value="Next" />
<?php
}
else
{
?>
<input type="submit" class="btn btn-primary" name="bStep5" value="Update Time/Distance" />
<?php
}
?>
</div>
</form>
</div>
<?php } ?>
<?php if($step==6) { ini_set('max_execution_time', 300); ?>
<div style="width:100%; padding:15px; " >
<form name="export6" method="post">
<div style="text-align:left;color:#36C; ">
<h3>Step 6: Insert into performance table</h3>
</div>
<?php if(isset($_REQUEST['bStep6']) && $_REQUEST['bStep6'] == 'Insert into performance table' && $step == 6)
{
?>
<div style="text-align:left;color:#090;" align="left">
<h4><?php echo $row_count." rows inserted"; ?></h4>
</div>
<div align="right">
<input type="submit" class="btn btn-primary" name="bStep6Continue" value="Continue to enter results" />
</div>
<?php
}
else
{
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$sql = "select * from ath_Importdatatable where isnull(perform_time,0) > 0 and (( isnull(athlete_id,0) > 0 and isnull(event_type,'I')='I' ) or (isnull(event_type,'')='R')) and isnull(event_id,0) > 0 and isnull(school_id,0) > 0 order by id";
$result = sqlsrv_query($conn,$sql,$params,$options);
$cnt = sqlsrv_num_rows($result);
$i=0;
?>
<div style="text-align:left;color:#090;" align="left">
<h4><?php echo $cnt." rows to insert"; ?></h4>
</div>
<div align="right">
<input type="submit" class="btn btn-primary" name="bStep6" value="Insert into performance table" />
</div>
<br />
<div>
<table border='1' style='padding:4px; font-size:12px;' width="100%">
<tr style='font-weight:bold; '>
<th>Race Level</th>
<th>Round</th>
<th>Sex</th>
<th>Event Name</th>
<th>Event Id</th>
<th>Place</th>
<th>Athlete Name</th>
<th>Athlete Id</th>
<th>School</th>
<th>School Id</th>
<th>Time/Distance</th>
<th>Time/Distance (int)</th>
<th>Performance data</th>
</tr>
<?php
while ($row = sqlsrv_fetch_array($result))
{
ini_set('max_execution_time', 300);
?>
<tr>
<td><?php echo $row['race_level']; ?></td>
<td><?php echo $row['Round']; ?></td>
<td><?php echo $row['Sex']=="M"?"Boys":"Girls"; ?></td>
<td><?php echo $row['Event']; ?></td>
<td><?php echo $row['event_id']; ?></td>
<td><?php echo $row['Place']; ?></td>
<td><?php echo $row['athlete_name']; ?></td>
<td><?php echo $row['athlete_id']; ?></td>
<td><?php echo $row['school_name']; ?></td>
<td><?php echo $row['school_id']; ?></td>
<td><?php echo $row['perform_time_char']; ?></td>
<td><?php echo $row['perform_time']; ?></td>
<td><?php echo $row['detail_row']; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
</div>
<?php
}
?>
</form>
</div>
<?php
}
?>
</div>
<div id="dialog-school" title="Add to alternate names list" style="display:none;"> School:&nbsp;
<select id="school" name="school">
<option value="">(Select School)</option>
<?php
$sql = "SELECT ID,School_name from ath_Schools order by School_name";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
echo "<option value='".$row['ID']."'>".$row['School_name']."</option>";
}
?>
</select>
</div>
<!--Participating Schools Alternate name add-->
<div id="dialog-part-School-Alt" title="Add to alternate names list" style="display:none;"> School:&nbsp;
<select id="partschool" name="partschool">
<option value="">(Select School)</option>
<?php
$sql = "SELECT ID,School_name from ath_Schools order by School_name";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
echo "<option value='".$row['ID']."'>".$row['School_name']."</option>";
}
?>
</select>
</div>
<!--Participating Schools Alternate name add end-->
<div id="dialog-event" title="Add to alternate names list" style="display:none; font-size:11px;">
<?php
$params = array();
$params[] = "";
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
$sql = "SELECT ID,event_name from ath_Events order by event_name";
$rs = sqlsrv_query($conn,$sql,$params,$options);
$rec_count = sqlsrv_num_rows($rs);
$var_cols = 4;
if ($rec_count > 0)
{
$col_count = 0;
$count = 0;
$remainder = $rec_count%$var_cols;
if($remainder > 0 && $col_count < $remainder )
$rows_per_col = floor($rec_count/$var_cols) + 1;
else
$rows_per_col = floor($rec_count/$var_cols) ;
echo '<table><tr><td>Selected Event:&nbsp;</td><td style="font-weight:bold;" id="selEvent"></td></tr></table><br>';
echo '<table width="100%" class="table" cellspacing="0"><tr>';
echo '<td><table>';
while ($row = sqlsrv_fetch_array($rs))
{
if ($count == $rows_per_col)
{
$col_count++;
$count = 0;
echo '</table></td>';
if($col_count < $var_cols) echo '<td><table>';
if($remainder > 0 && $col_count < $remainder )
$rows_per_col = floor($rec_count/$var_cols) + 1;
else
$rows_per_col = floor($rec_count/$var_cols) ;
}
echo '<tr><td><input type="radio" value="'.$row['ID'].'" id="event" name="event" />'.$row['event_name'].'</td></tr>';
$count++;
}
echo '</table></td>';
echo '</tr></table>';
}
?>
</div>
<div id="dialog-athlete" title="Search Athlete" style="display:none;">
<div id="div_athletes"></div>
<input type="hidden" id="hAtheleteID" />
</div>
<div id="dialog-add-athlete" title="Add Athlete" style="display:none;">
<div id="div_add_athletes"></div>
<table width="100%" cellpadding="2" cellspacing="2" style="font-size:12px;">
<tr>
<td align="right">First name: <font color="#FF0000">*</font></td><td><input type="text" id="firstname" name="firstname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">Last name: <font color="#FF0000">*</font></td><td><input type="text" id="lastname" name="lastname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">DOB: </td><td><input type="text" id="dob" name="dob" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">School: <font color="#FF0000">*</font></td>
<td>
<select id="athschool" name="athschool" style="width:100%;">
<option value="">(Select School)</option>
<?php
$sql = "SELECT ID,School_name from ath_Schools order by School_name";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
echo "<option value='".$row['ID']."'>".$row['School_name']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td align="right">Class year: </td>
<td>
<select id="classyear" name="classyear" style="width:100%;">
<option value="">(Select Class year)</option>
<?php
for($i=date('Y'); $i<date('Y')+11; $i++)
{
?>
<option value="<?php echo $i; ?>"><?php echo $i; ?></option>
<?php
}
?>
</select>
</td>
</tr>
</table>
</div>
<!--Add New School-->
<div id="dialog-add-school" title="Add School" style="display:none;">
<div id="div_add_school"></div>
<table width="100%" cellpadding="2" cellspacing="2" style="font-size:12px;">
<tr>
<td align="right">School long name: <font color="#FF0000">*</font></td><td><input type="text" id="schoollongname" name="schoollongname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">School short name: <font color="#FF0000">*</font></td><td><input type="text" id="schoolshortname" name="schoolshortname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">League: <font color="#FF0000">*</font></td>
<td>
<select id="athleague" name="athleague" style="width:100%;">
<option value="">(Select League)</option>
<?php
$sql = "SELECT ID,league_name from ath_League order by league_name";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
echo "<option value='".$row['ID']."'>".$row['league_name']."</option>";
}
?>
</select>
</td>
</tr>
</table>
</div>
<!--Participating Add New School-->
<div id="dialog-add-part-school" title="Add School" style="display:none;">
<div id="div_add_school"></div>
<table width="100%" cellpadding="2" cellspacing="2" style="font-size:12px;">
<tr>
<td align="right">School long name: <font color="#FF0000">*</font></td><td><input type="text" id="partschoollongname" name="partschoollongname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">School short name: <font color="#FF0000">*</font></td><td><input type="text" id="partschoolshortname" name="partschoolshortname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">League: <font color="#FF0000">*</font></td>
<td>
<select id="partathleague" name="partathleague" style="width:100%;">
<option value="">(Select League)</option>
<?php
$sql = "SELECT ID,league_name from ath_League order by league_name";
$result = sqlsrv_query($conn,$sql);
while ($row = sqlsrv_fetch_array($result))
{
echo "<option value='".$row['ID']."'>".$row['league_name']."</option>";
}
?>
</select>
</td>
</tr>
</table>
</div>
<!--Participating Add New School End-->
<!--Edit Participating School-->
<div id="dialog-edit-part-school" title="Edit School" style="display:none;">
<div id="div_edit_school"></div>
<table width="100%" cellpadding="2" cellspacing="2" style="font-size:12px;">
<tr>
<td align="right">School name: <font color="#FF0000">*</font></td><td><input type="text" id="schooleditname" name="schooleditname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">School Id: <font color="#FF0000">*</font></td><td><input type="text" id="schooleditid" name="schooleditid" style="width:100%;" /></td>
</tr>
</table>
</div>
<!--End-->
<!--Delete Participating School-->
<div id="dialog-delete-part-school" title="Delete School?" style="display:none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><span name="spanPartSchoolName" id="spanPartSchoolName"></span>school will be deleted. Are you sure you want to delete?</p>
</div>
<!--End-->
<!--Delete Participating Schools Alternate name-->
<div id="dialog-part-School-Alt-Remove" title="Remove alternate?" style="display:none;">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>
<span name="spanRemoveAlternate" id="spanRemoveAlternate"></span> school will be removed from <span name="spanRemoveOrginal" id="spanRemoveOrginal"></span> alternate names . Are you sure you want to remove?</p>
</div>
<!--End-->
<div id="dialog-master-detail" title="Detailed Master Data" style="display:none;">
<div id="div_master_detail_data"></div>
</div>
<div id="dialog-alt-athlete" title="Add Alternate Athletes" style="display:none;">
<div id="div_alt_athletes"></div>
<input type="hidden" id="hAltAtheleteID" />
</div>
<div id="dialog-athlete_bulk" title="Bulk Add Athlete" style="display:none;">
<input type="checkbox" id="checkall" checked="checked" onclick="SelectAll()" /> Check All
<div id="div_athletes_bulk"></div>
</div>
<!--bulk update School-->
<div id="dialog-edit-school" title="Rename schools on this meet" style="display:none;">
<div id="div_edit_school"></div>
<table width="100%" cellpadding="2" cellspacing="2" style="font-size:12px;">
<tr>
<td align="right">Replace all school names: <font color="#FF0000">*</font></td><td><input type="text" id="oldschoolname" name="oldschoolname" style="width:100%;" /></td>
</tr>
<tr>
<td align="right">With: <font color="#FF0000">*</font></td><td><input type="text" id="newschoolname" name="newschoolname" style="width:100%;" /></td>
</tr>
</table>
</div>
<!--Participating Schools-->
<div id="dialog-participating-schools" title="Participating Schools" style="display:none;">
<div id="participating-schools"></div>
<table border='1' style='padding:4px; font-size:12px;text-align:left;' width="100%">
<tr style='font-weight:bold;'>
<th>School Name</th><th>Alternate added school</th><th>League</th><th>School Id</th><th>Action</th>
</tr>
<?php
$sql = "SELECT distinct I.school_name,I.alter_name_added_school,S.id as schoolId,L.hashtag as league ,L.id
from ath_importdatatable as I Left JOIN ath_schools as S ON
LTRIM(RTRIM(I.school_name))=S.School_name or LTRIM(RTRIM(I.school_name))=S.School_name_long or LTRIM(RTRIM(I.school_name))=S.alt_names or
(',' + LTRIM(RTRIM(S.alt_names)) + ',') LIKE '%,'+LTRIM(RTRIM(I.school_name))+',%'
Left JOIN ath_league L
ON L.id=S.league_Id
order by L.id,I.school_name";
$result = sqlsrv_query($conn,$sql);
$ParID = 0;
while ($row = sqlsrv_fetch_array($result))
{
/*echo '<tr><td>'.$row['school_name'].'</td><td>'.$row['league'].'</td><td>'.$row['schoolId'].'</td>';*/
echo '<tr id="rowparSchool'.$ParID.'">
<td style="width:23%;" id="colparSchoolName'.$ParID.'"><input type="text" name="parSchoolName'.$ParID.'" id="parSchoolName'.$ParID.'" value="'.$row["school_name"].'" style="width:100%;border:0;background-color:#fff;" disabled="disabled" /></td>
<td style="width:23%;" id="colparOrgSchoolName'.$ParID.'"><input type="text" name="parOrgSchoolName'.$ParID.'" id="parOrgSchoolName'.$ParID.'" value="'.$row["alter_name_added_school"].'" style="width:100%;border:0;background-color:#fff;" disabled="disabled" /></td>';
echo '<td style="width:10%;" id="colparLeagueName'.$ParID.'"><input type="text" name="parLeagueName'.$ParID.'" id="parLeagueName'.$ParID.'" value="'.$row['league'].'" style="width:100%;border:0;background-color:#fff;" disabled="disabled" /></td>';
echo '<td style="width:10%;" id="colparSchoolId'.$ParID.'"><input type="text" name="parSchoolId'.$ParID.'" id="parSchoolId'.$ParID.'" value="'.$row["schoolId"].'" style="width:100%;border:0;background-color:#fff;" disabled="disabled" /></td>
<td style="width:34%;" id="colActionId'.$ParID.'">';
if($row['alter_name_added_school'] != '')
{
$display = "display:inline-block;";
}
else
{
$display = "display:none;";
}
echo '&nbsp;<input type="button" class="btn btn-primary" style="height:20px; width:120px; padding:0px; font-size:11px;'.$display.'" id="bPartRemoveAltSchool'.$ParID.'" value="Remove Alternate" onclick="partSchoolRemoveAltPopup('.$ParID.');" />';
if($row['schoolId']=='')
{
$display_new_alt = "display:inline-block;";
}
else
{
$display_new_alt = "display:none;";
}
echo '&nbsp;<input type="button" class="btn btn-primary" style="height:20px; width:60px; padding:0px; font-size:11px;'.$display_new_alt.'" id="bPartAltSchool'.$ParID.'" value="Alternate" onclick="partSchoolAltPopup('.$ParID.');" />
<input type="button" class="btn btn-primary" id="bAddPartSchool'.$ParID.'" style="height:20px; width:40px; padding:0px; ; font-size:11px;'.$display_new_alt.'" value="New" onclick="addPartSchoolPopup('.$ParID.');" />';
if($row['alter_name_added_school'] == '')
{
echo '&nbsp;<input type="button" class="btn btn-primary" id="bEditSchoo'.$ParID.'" style="height:20px; width:40px; padding:0px; font-size:11px" value="Edit" onclick="editPartSchoolPopup('.$ParID.');"/>';
echo '&nbsp;<input type="button" class="btn btn-primary" id="bDeleteSchool'.$ParID.'" style="height:20px; width:40px; padding:0px; font-size:11px" value="Delete" onclick="deletePartSchoolPopup('.$ParID.');"/>';
}
echo '</td></tr>';
$ParID++;
}
?>
</table>
</div>
</body>
</html>