forked from science-ation/science-ation
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:
parent
a169e422e6
commit
808290f631
@ -188,65 +188,78 @@ echo mysql_Error();
|
||||
|
||||
|
||||
}
|
||||
else if($_POST['action']=="receivedyes" && $_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'];
|
||||
//first replace the division and category
|
||||
$projectnumber=str_replace('D',$r->projectdivisions_id,$projectnumber);
|
||||
$projectnumber=str_replace('C',$r->projectcategories_id,$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']."'");
|
||||
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']."'");
|
||||
$checkNumResults=mysql_fetch_object($checkNumQuery);
|
||||
$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);
|
||||
|
||||
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" && $_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)));
|
||||
$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);
|
||||
|
||||
//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']."'");
|
||||
echo happy(i18n("Assigned Project Number: %1",array($projectnumber)));
|
||||
}
|
||||
if($_POST['action']=="receivedyes")
|
||||
{
|
||||
//actually set it to 'closed'
|
||||
mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'");
|
||||
|
||||
|
||||
echo happy(i18n("Registration of form %1 successfully completed",array($registration_number)));
|
||||
|
||||
|
||||
}
|
||||
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']=="receivedno" && $_POST['registration_number'])
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user