diff --git a/admin/project_editor.php b/admin/project_editor.php index 4d82f87..67f8eeb 100644 --- a/admin/project_editor.php +++ b/admin/project_editor.php @@ -23,7 +23,7 @@ ?> "; echo "\n"; echo ""; + + + echo ("

".i18n("Other Actions")."


"); + + echo "
\n"; + echo "\n"; + echo "id\">\n"; + echo "\n"; + echo "\n"; + echo "
"; + } else { diff --git a/admin/registration_receivedforms.php b/admin/registration_receivedforms.php index 6077995..bd2b0ab 100644 --- a/admin/registration_receivedforms.php +++ b/admin/registration_receivedforms.php @@ -193,74 +193,23 @@ echo mysql_Error(); } else if(($_POST['action']=="receivedyes" || $_POST['action']=="receivedyesnocash") && $_POST['registration_number']) { - $checkNumQuery=mysql_query("SELECT projectnumber FROM projects, registrations WHERE projects.registrations_id = registrations.id AND " - . "num='".$_POST['registration_number']."'"); + $regnum = intval($_POST['registration_number']); + $checkNumQuery=mysql_query("SELECT projectnumber + FROM projects, registrations + WHERE projects.registrations_id = registrations.id + AND num='$regnum' + AND registrations.year='{$config['FAIRYEAR']}'"); $checkNumResults=mysql_fetch_object($checkNumQuery); $projectnum=$checkNumResults->projectnumber; if($projectnum == null) { - $q=mysql_query("SELECT id FROM registrations WHERE num='".$_POST['registration_number']."'"); + $q=mysql_query("SELECT id FROM registrations WHERE num='$regnum' AND year='{$config['FAIRYEAR']}'"); $r=mysql_fetch_object($q); - $reg_id=$r->id; - $q=mysql_query("SELECT projects.projectcategories_id, - projects.projectdivisions_id, - projectcategories.category_shortform, - projectdivisions.division_shortform - FROM - projects, - projectcategories, - projectdivisions - WHERE - registrations_id='$reg_id' - AND projects.projectdivisions_id=projectdivisions.id - AND projects.projectcategories_id=projectcategories.id - AND projectcategories.year='{$config['FAIRYEAR']}' - AND projectdivisions.year='{$config['FAIRYEAR']}' - "); - echo mysql_error(); - $r=mysql_fetch_object($q); - - $projectnumber=$config['project_num_format']; - //first replace the division and category - $projectnumber=str_replace('D',$r->projectdivisions_id,$projectnumber); - $projectnumber=str_replace('C',$r->projectcategories_id,$projectnumber); - $projectnumber=str_replace('d',$r->division_shortform,$projectnumber); - $projectnumber=str_replace('c',$r->category_shortform,$projectnumber); - - //now change the N to a % so we can use it as a wildcard - $querynum=str_replace('N','%',$projectnumber); - $searchq=mysql_query("SELECT projectnumber FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber LIKE '$querynum'"); - if(mysql_num_rows($searchq)) - { - //first, put them all in an array - $proj_nums=array(); - while($searchr=mysql_fetch_object($searchq)) - { - $proj_nums[]=$searchr->projectnumber; - } - - //we will eventually find a good number, so lets loop forever until we find a good one - $testnum=1; - $Nnum=1; - $ok=false; - do - { - $Nnum=sprintf("%02d",$testnum); - $test_projectnumber=str_replace('N',$Nnum,$projectnumber); - if(!in_array($test_projectnumber,$proj_nums)) - $ok=true; - $testnum++; - }while(!$ok); - - - } - else - { - $Nnum="01"; - } - - $projectnumber=str_replace('N',$Nnum,$projectnumber); - mysql_query("UPDATE projects SET projectnumber='$projectnumber' WHERE registrations_id='$reg_id' AND year='".$config['FAIRYEAR']."'"); + $reg_id = $r->id; + + $projectnumber = generate_project_number($reg_id); + + mysql_query("UPDATE projects SET projectnumber='$projectnumber' WHERE registrations_id='$reg_id' AND year='{$config['FAIRYEAR']}'"); echo happy(i18n("Assigned Project Number: %1",array($projectnumber))); } if($_POST['action']=="receivedyes") diff --git a/register_participants.inc.php b/register_participants.inc.php index 3f32325..e484c6b 100644 --- a/register_participants.inc.php +++ b/register_participants.inc.php @@ -264,5 +264,88 @@ function tourStatus($reg_id="") } +function generate_project_number($registration_id) +{ + global $config; + + $reg_id = $registration_id; + + $q=mysql_query("SELECT projects.projectcategories_id, + projects.projectdivisions_id, + projectcategories.category_shortform, + projectdivisions.division_shortform + FROM + projects, + projectcategories, + projectdivisions + WHERE + registrations_id='$reg_id' + AND projects.projectdivisions_id=projectdivisions.id + AND projects.projectcategories_id=projectcategories.id + AND projectcategories.year='{$config['FAIRYEAR']}' + AND projectdivisions.year='{$config['FAIRYEAR']}' + "); + echo mysql_error(); + print("SELECT projects.projectcategories_id, + projects.projectdivisions_id, + projectcategories.category_shortform, + projectdivisions.division_shortform + FROM + projects, + projectcategories, + projectdivisions + WHERE + registrations_id='$reg_id' + AND projects.projectdivisions_id=projectdivisions.id + AND projects.projectcategories_id=projectcategories.id + AND projectcategories.year='{$config['FAIRYEAR']}' + AND projectdivisions.year='{$config['FAIRYEAR']}' + "); + $r=mysql_fetch_object($q); + + $projectnumber=$config['project_num_format']; + + //first replace the division and category + $projectnumber=str_replace('D',$r->projectdivisions_id,$projectnumber); + $projectnumber=str_replace('C',$r->projectcategories_id,$projectnumber); + $projectnumber=str_replace('d',$r->division_shortform,$projectnumber); + $projectnumber=str_replace('c',$r->category_shortform,$projectnumber); + + //now change the N to a % so we can use it as a wildcard + $querynum=str_replace('N','%',$projectnumber); + $searchq=mysql_query("SELECT projectnumber FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber LIKE '$querynum'"); + if(mysql_num_rows($searchq)) + { + //first, put them all in an array + $proj_nums=array(); + while($searchr=mysql_fetch_object($searchq)) + { + $proj_nums[]=$searchr->projectnumber; + } + + //we will eventually find a good number, so lets loop forever until we find a good one + $testnum=1; + $Nnum=1; + $ok=false; + do + { + $Nnum=sprintf("%02d",$testnum); + $test_projectnumber=str_replace('N',$Nnum,$projectnumber); + if(!in_array($test_projectnumber,$proj_nums)) + $ok=true; + $testnum++; + }while(!$ok); + + + } + else + { + $Nnum="01"; + } + + $projectnumber=str_replace('N',$Nnum,$projectnumber); + + return $projectnumber; +} ?>