projects should be assigned a project number once registration forms have been received, whether or not they still owe money. Resolves issue 101.

This commit is contained in:
justin 2006-08-20 00:02:31 +00:00
parent a169e422e6
commit 808290f631

View File

@ -188,66 +188,79 @@ echo mysql_Error();
} }
else if($_POST['action']=="receivedyes" && $_POST['registration_number']) else if(($_POST['action']=="receivedyes" || $_POST['action']=="receivedyesnocash") && $_POST['registration_number']) {
{
//actually set it to 'closed'
mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'");
$q=mysql_query("SELECT id FROM registrations WHERE num='".$_POST['registration_number']."'");
$r=mysql_fetch_object($q);
$reg_id=$r->id;
$q=mysql_query("SELECT projects.projectcategories_id, projects.projectdivisions_id FROM projects WHERE registrations_id='$reg_id'");
$r=mysql_fetch_object($q);
$projectnumber=$config['project_num_format']; $checkNumQuery=mysql_query("SELECT projectnumber FROM projects, registrations WHERE projects.registrations_id = registrations.id AND "
//first replace the division and category . "num='".$_POST['registration_number']."'");
$projectnumber=str_replace('D',$r->projectdivisions_id,$projectnumber); $checkNumResults=mysql_fetch_object($checkNumQuery);
$projectnumber=str_replace('C',$r->projectcategories_id,$projectnumber); $projectnum=$checkNumResults->projectnumber;
if($projectnum == null)
{
$q=mysql_query("SELECT id FROM registrations WHERE num='".$_POST['registration_number']."'");
$r=mysql_fetch_object($q);
$reg_id=$r->id;
$q=mysql_query("SELECT projects.projectcategories_id, projects.projectdivisions_id FROM projects WHERE registrations_id='$reg_id'");
$r=mysql_fetch_object($q);
//now change the N to a % so we can use it as a wildcard $projectnumber=$config['project_num_format'];
$querynum=str_replace('N','%',$projectnumber); //first replace the division and category
$searchq=mysql_query("SELECT projectnumber FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber LIKE '$querynum'"); $projectnumber=str_replace('D',$r->projectdivisions_id,$projectnumber);
if(mysql_num_rows($searchq)) $projectnumber=str_replace('C',$r->projectcategories_id,$projectnumber);
{
//first, put them all in an array //now change the N to a % so we can use it as a wildcard
$proj_nums=array(); $querynum=str_replace('N','%',$projectnumber);
while($searchr=mysql_fetch_object($searchq)) $searchq=mysql_query("SELECT projectnumber FROM projects WHERE year='".$config['FAIRYEAR']."' AND projectnumber LIKE '$querynum'");
if(mysql_num_rows($searchq))
{ {
$proj_nums[]=$searchr->projectnumber; //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";
} }
//we will eventually find a good number, so lets loop forever until we find a good one $projectnumber=str_replace('N',$Nnum,$projectnumber);
$testnum=1; mysql_query("UPDATE projects SET projectnumber='$projectnumber' WHERE registrations_id='$reg_id' AND year='".$config['FAIRYEAR']."'");
$Nnum=1; echo happy(i18n("Assigned Project Number: %1",array($projectnumber)));
$ok=false; }
do if($_POST['action']=="receivedyes")
{ {
$Nnum=sprintf("%02d",$testnum); //actually set it to 'closed'
$test_projectnumber=str_replace('N',$Nnum,$projectnumber); mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'");
if(!in_array($test_projectnumber,$proj_nums))
$ok=true;
$testnum++;
}while(!$ok);
} echo happy(i18n("Registration of form %1 successfully completed",array($registration_number)));
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']."'");
echo happy(i18n("Registration of form %1 successfully completed",array($registration_number))); }
echo happy(i18n("Assigned Project Number: %1",array($projectnumber))); else if($_POST['action']=="receivedyesnocash")
{
//actually set it to 'closed'
mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='".$_POST['registration_number']."'");
echo happy(i18n("Registration of form %1 marked as payment pending",array($registration_number)));
}
} }
else if($_POST['action']=="receivedyesnocash" && $_POST['registration_number'])
{
//actually set it to 'closed'
mysql_query("UPDATE registrations SET status='paymentpending' WHERE num='".$_POST['registration_number']."'");
echo happy(i18n("Registration of form %1 marked as payment pending",array($registration_number)));
}
else if($_POST['action']=="receivedno" && $_POST['registration_number']) else if($_POST['action']=="receivedno" && $_POST['registration_number'])
{ {
echo notice(i18n("Registration of form %1 cancelled",array($registration_number))); echo notice(i18n("Registration of form %1 cancelled",array($registration_number)));