class/Command/ReApplicationFormSubmitCommand.php
<?php
namespace Homestead\Command;
use \Homestead\StudentFactory;
use \Homestead\CommandFactory;
use \Homestead\UserStatus;
use \Homestead\NotificationView;
class ReApplicationFormSubmitCommand extends Command {
private $term;
public function setTerm($term){
$this->term = $term;
}
public function getRequestVars()
{
return array('action'=>'ReApplicationFormSubmit', 'term'=>$this->term);
}
public function execute(CommandContext $context)
{
$term = $context->get('term');
$student = StudentFactory::getStudentByUsername(UserStatus::getUsername(), $term);
$errorCmd = CommandFactory::getCommand('ShowReApplication');
$errorCmd->setTerm($term);
$depositAgreed = $context->get('deposit_check');
if(is_null($depositAgreed)){
\NQ::simple('hms', NotificationView::ERROR, 'You must check the box indicating you understand the License Contract deposit fees.');
$errorCmd->redirect();
}
// Data sanity checking
$doNotCall = $context->get('do_not_call');
$number = $context->get('number');
if(is_null($doNotCall)){
// do not call checkbox was not selected, so check the number
if(is_null($number)){
\NQ::simple('hms', NotificationView::ERROR, 'Please provide a cell-phone number or click the checkbox stating that you do not wish to share your number with us.');
$errorCmd->redirect();
}
}
//$mealPlan = $context->get('meal_plan');
/* Emergency Contact Sanity Checking */
$emergencyName = $context->get('emergency_contact_name');
$emergencyRelationship = $context->get('emergency_contact_relationship');
$emergencyPhone = $context->get('emergency_contact_phone');
$emergencyEmail = $context->get('emergency_contact_email');
if (empty($emergencyName) || empty($emergencyRelationship) || empty($emergencyPhone) || empty($emergencyEmail)) {
\NQ::simple('hms', NotificationView::ERROR, 'Please complete all of the emergency contact person information.');
$errorCmd->redirect();
}
/* Missing Persons Sanity Checking */
$missingPersonName = $context->get('missing_person_name');
$missingPersonRelationship = $context->get('missing_person_relationship');
$missingPersonPhone = $context->get('missing_person_phone');
$missingPersonEmail = $context->get('missing_person_email');
if (empty($missingPersonName) || empty($missingPersonRelationship) || empty($missingPersonPhone) || empty($missingPersonEmail)) {
\NQ::simple('hms', NotificationView::ERROR, 'Please complete all of the missing persons contact information.');
$errorCmd->redirect();
}
$reviewCmd = CommandFactory::getCommand('ReApplicationFormSave');
$reviewCmd->setTerm($term);
$reviewCmd->loadContext($context);
$reviewCmd->redirect();
}
}