forked from science-ation/science-ation
assign the project number based on a config format when the form is received
fix checkin report to show the projectnumber
This commit is contained in:
parent
58122f4344
commit
0f5e201b97
@ -168,8 +168,54 @@ echo mysql_Error();
|
|||||||
{
|
{
|
||||||
//actually set it to 'closed'
|
//actually set it to 'closed'
|
||||||
mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'");
|
mysql_query("UPDATE registrations SET status='complete' WHERE num='".$_POST['registration_number']."'");
|
||||||
//FIXME: assign the project number here as well!
|
$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[]=$r->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("Registration of form %1 successfully completed",array($registration_number)));
|
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'])
|
else if($_POST['action']=="receivedyesnocash" && $_POST['registration_number'])
|
||||||
|
@ -17,6 +17,7 @@ if($catr=mysql_fetch_object($catq))
|
|||||||
registrations.num AS reg_num,
|
registrations.num AS reg_num,
|
||||||
registrations.status,
|
registrations.status,
|
||||||
projects.title,
|
projects.title,
|
||||||
|
projects.projectnumber,
|
||||||
projects.projectdivisions_id
|
projects.projectdivisions_id
|
||||||
FROM
|
FROM
|
||||||
registrations
|
registrations
|
||||||
@ -81,7 +82,7 @@ if($catr=mysql_fetch_object($catq))
|
|||||||
$table['data'][]=array($status_text,$r->proj_num,$r->title,$students,i18n($divr->division_shortform));
|
$table['data'][]=array($status_text,$r->proj_num,$r->title,$students,i18n($divr->division_shortform));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$table['data'][]=array($r->proj_num,$r->title,$students,i18n($divr->division_shortform));
|
$table['data'][]=array($r->projectnumber,$r->title,$students,i18n($divr->division_shortform));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user