Exemple #1
0
 /**
  * Remove a tag from all applicants and add a new tag in its place
  * @param $tagId
  */
 public function actionEdit($tagId)
 {
     if ($tag = $this->_em->getRepository('Jazzee\\Entity\\Tag')->find($tagId)) {
         $applicants = $this->_em->getRepository('Jazzee\\Entity\\Applicant')->findTaggedByApplication($this->_application, $tag);
         $form = new \Foundation\Form();
         $form->setCSRFToken($this->getCSRFToken());
         $form->setAction($this->path("setup/tags/edit/{$tagId}"));
         $field = $form->newField();
         $field->setLegend('Change "' . $tag->getTitle() . '" Tag for ' . count($applicants) . ' applicants');
         $element = $field->newElement('TextInput', 'title');
         $element->setLabel('New Tag');
         $element->setValue($tag->getTitle());
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
         $applications = $this->_em->getRepository('\\Jazzee\\Entity\\Application')->findByProgram($this->_program);
         $form->newButton('submit', 'Change Tag');
         if ($input = $form->processInput($this->post)) {
             $newTag = $this->_em->getRepository('\\Jazzee\\Entity\\Tag')->findOneBy(array('title' => $input->get('title')));
             if (!$newTag) {
                 $newTag = new \Jazzee\Entity\Tag();
                 $newTag->setTitle($input->get('title'));
                 $this->_em->persist($newTag);
             }
             foreach ($applicants as $applicant) {
                 $applicant->removeTag($tag);
                 $applicant->addTag($newTag);
                 $this->_em->persist($applicant);
             }
             $this->addMessage('success', 'Changed tag for ' . count($applicants) . ' applicants');
             $this->redirectPath('setup/tags');
         }
         $this->setVar('form', $form);
     }
 }
 /**
  * Display index
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('changeprogram'));
     $field = $form->newField();
     $field->setLegend('Select Program');
     $element = $field->newElement('SelectList', 'program');
     $element->setLabel('Program');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $programs = $this->_em->getRepository('\\Jazzee\\Entity\\Program')->findBy(array('isExpired' => false), array('name' => 'ASC'));
     $userPrograms = $this->_user->getPrograms();
     foreach ($programs as $program) {
         if ($this->checkIsAllowed($this->controllerName, 'anyProgram') or in_array($program->getId(), $userPrograms)) {
             $element->newItem($program->getId(), $program->getName());
         }
     }
     if ($this->_program) {
         $element->setValue($this->_program->getId());
     }
     //only ask if the user already has a default cycle
     if ($this->_user->getDefaultProgram()) {
         $element = $field->newElement('RadioList', 'default');
         $element->setLabel('Set as your default');
         $element->newItem(0, 'No');
         $element->newItem(1, 'Yes');
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     }
     $form->newButton('submit', 'Change Program');
     if ($input = $form->processInput($this->post)) {
         $this->_program = $this->_em->getRepository('\\Jazzee\\Entity\\Program')->find($input->get('program'));
         //if they wish it, or if the user has no default cycle
         if (!$this->_user->getDefaultProgram() or $input->get('default')) {
             $this->_user->setDefaultProgram($this->_program);
             $this->_em->persist($this->_user);
             $this->addMessage('success', 'Default program changed to ' . $this->_program->getName());
         }
         unset($this->_store->AdminControllerGetNavigation);
         $this->addMessage('success', 'Program changed to ' . $this->_program->getName());
         $this->redirectPath('welcome');
     }
     $this->setVar('form', $form);
 }
Exemple #3
0
 /**
  * Display index
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setAction($this->path('changecycle'));
     $form->setCSRFToken($this->getCSRFToken());
     $field = $form->newField();
     $field->setLegend('Select Cycle');
     $element = $field->newElement('SelectList', 'cycle');
     $element->setLabel('Cycle');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $cycles = $this->_em->getRepository('\\Jazzee\\Entity\\Cycle')->findAll();
     foreach ($cycles as $cycle) {
         $element->newItem($cycle->getId(), $cycle->getName());
     }
     if ($this->_cycle) {
         $element->setValue($this->_cycle->getId());
     }
     //only ask if the user already has a default cycle
     if ($this->_user->getDefaultCycle()) {
         $element = $field->newElement('RadioList', 'default');
         $element->setLabel('Set as your default');
         $element->newItem(0, 'No');
         $element->newItem(1, 'Yes');
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     }
     $form->newButton('submit', 'Change Cycle');
     if ($input = $form->processInput($this->post)) {
         $this->_cycle = $this->_em->getRepository('\\Jazzee\\Entity\\Cycle')->find($input->get('cycle'));
         //if they wish it, or if the user has no default cycle
         if (!$this->_user->getDefaultCycle() or $input->get('default')) {
             $this->_user->setDefaultCycle($this->_cycle);
             $this->_em->persist($this->_user);
             $this->addMessage('success', 'Default cycle changed to ' . $this->_cycle->getName());
         }
         unset($this->_store->AdminControllerGetNavigation);
         $this->addMessage('success', 'Cycle changed to ' . $this->_cycle->getName());
         $this->redirectPath('welcome');
     }
     $this->setVar('form', $form);
 }
Exemple #4
0
 /**
  * List users in the programa and earch for new users
  */
 public function actionIndex()
 {
     $directory = $this->getAdminDirectory();
     $form = new \Foundation\Form();
     $field = $form->newField();
     $form->setAction($this->path("setup/users/index"));
     $form->setCSRFToken($this->getCSRFToken());
     $field->setLegend('Find Users');
     $element = $field->newElement('TextInput', 'firstName');
     $element->setLabel('First Name');
     $element = $field->newElement('TextInput', 'lastName');
     $element->setLabel('Last Name');
     $form->newButton('submit', 'Search');
     $results = array();
     //array of all the users who match the search
     if ($input = $form->processInput($this->post)) {
         $results = $directory->search($input->get('firstName'), $input->get('lastName'));
     }
     $this->setVar('results', $results);
     $this->setVar('users', $this->_em->getRepository('\\Jazzee\\Entity\\User')->findByProgram($this->_program));
     $this->setVar('roles', $this->_em->getRepository('\\Jazzee\\Entity\\Role')->findBy(array('program' => $this->_program->getId()), array('name' => 'asc')));
     $this->setVar('form', $form);
 }
 /**
  * Create a new preview
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/previewapplication/new"));
     $field = $form->newField();
     $field->setLegend('Create New Preview');
     $element = $field->newElement('SelectList', 'adminRole');
     $element->setLabel('Admin Role');
     $element->setInstructions('If you specifiy and admin role then anyone using the preview will be able to access the administrator functions using this role.  They will only be able to see applicants in the prevew application.');
     $element->newItem('', 'No access');
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Role')->findByProgram($this->_program->getId()) as $role) {
         $element->newItem($role->getId(), $role->getName());
     }
     $form->newButton('submit', 'Create Preview');
     if ($input = $form->processInput($this->post)) {
         if ($input->get('adminRole')) {
             $adminRole = $this->_em->getRepository('\\Jazzee\\Entity\\Role')->findOneBy(array('program' => $this->_program->getId(), 'id' => $input->get('adminRole')));
         } else {
             $adminRole = new \Jazzee\Entity\Role();
             $adminRole->setName('No Access');
         }
         $prefix = substr(md5(mt_rand() * mt_rand()), rand(0, 24), rand(6, 8));
         //clean out any wierd chars in program or cycle name
         $key = preg_replace("/[^a-z0-9\\._-]/i", '', $this->_program->getShortName() . $this->_cycle->getName()) . '-' . time() . '-' . \uniqid($prefix);
         $path = $this->getPathString($key);
         $doctrineConfig = $this->_em->getConfiguration();
         $connectionParams = array('driver' => 'pdo_sqlite', 'path' => $path);
         $previewEntityManager = \Doctrine\ORM\EntityManager::create($connectionParams, $doctrineConfig);
         $this->buildTemporaryDatabase($previewEntityManager);
         $this->createPreviewApplication($previewEntityManager, $adminRole);
         $this->addMessage('success', 'Created preview');
         $this->redirectPath('setup/previewapplication');
     }
     $this->setVar('form', $form);
 }
 /**
  * Setup the current application and cycle
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/copyapplication"));
     $field = $form->newField();
     $field->setLegend('Import Application');
     $element = $field->newElement('SelectList', 'application');
     $element->setLabel('Cycle to Copy');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $applications = $this->_em->getRepository('\\Jazzee\\Entity\\Application')->findByProgram($this->_program);
     foreach ($applications as $application) {
         $element->newItem($application->getId(), $application->getCycle()->getName());
     }
     $form->newButton('submit', 'Copy');
     if ($input = $form->processInput($this->post)) {
         $previousApplication = $this->_em->getRepository('\\Jazzee\\Entity\\Application')->find($input->get('application'));
         $this->_application = new \Jazzee\Entity\Application();
         $this->_application->setProgram($this->_program);
         $this->_application->setCycle($this->_cycle);
         $this->_application->inVisible();
         $this->_application->unPublish();
         if ($previousApplication->isByInvitationOnly()) {
             $this->_application->byInvitationOnly();
         }
         $this->_application->setContactName($previousApplication->getContactName());
         $this->_application->setContactEmail($previousApplication->getContactEmail());
         $this->_application->setWelcome($previousApplication->getWelcome());
         $this->_application->setOpen($previousApplication->getOpen()->format('c'));
         $this->_application->setClose($previousApplication->getClose()->format('c'));
         $this->_application->setBegin($previousApplication->getBegin()->format('c'));
         $this->_application->setStatusIncompleteText($previousApplication->getStatusIncompleteText());
         $this->_application->setStatusNoDecisionText($previousApplication->getStatusNoDecisionText());
         $this->_application->setStatusAdmitText($previousApplication->getStatusAdmitText());
         $this->_application->setStatusDenyText($previousApplication->getStatusDenyText());
         $this->_application->setStatusAcceptText($previousApplication->getStatusAcceptText());
         $this->_application->setStatusDeclineText($previousApplication->getStatusDeclineText());
         foreach ($previousApplication->getApplicationPages() as $previousPage) {
             $page = $this->addPage($previousPage->getPage());
             $applicationPage = new \Jazzee\Entity\ApplicationPage();
             $applicationPage->setApplication($this->_application);
             $applicationPage->setPage($page);
             $applicationPage->setKind($previousPage->getKind());
             $applicationPage->setTitle($previousPage->getTitle());
             $applicationPage->setMin($previousPage->getMin());
             $applicationPage->setMax($previousPage->getMax());
             $applicationPage->setName($previousPage->getName());
             if ($previousPage->isRequired()) {
                 $applicationPage->required();
             } else {
                 $applicationPage->optional();
             }
             if ($previousPage->answerStatusDisplay()) {
                 $applicationPage->showAnswerStatus();
             } else {
                 $applicationPage->hideAnswerStatus();
             }
             $applicationPage->setInstructions($previousPage->getInstructions());
             $applicationPage->setLeadingText($previousPage->getLeadingText());
             $applicationPage->setTrailingText($previousPage->getTrailingText());
             $applicationPage->setWeight($previousPage->getWeight());
             $this->_em->persist($applicationPage);
         }
         $templates = $this->_em->getRepository('Jazzee\\Entity\\Template')->findBy(array('application' => $previousApplication));
         foreach ($templates as $previousTemplate) {
             $template = new \Jazzee\Entity\Template($previousTemplate->getType());
             $template->setApplication($this->_application);
             $template->setTitle($previousTemplate->getTitle());
             $template->setText($previousTemplate->getText());
             $this->_em->persist($template);
         }
         $this->_em->persist($this->_application);
         $this->addMessage('success', 'Application copied successfully');
         unset($this->_store->AdminControllerGetNavigation);
         $this->redirectPath('setup/application');
     }
     $this->setVar('form', $form);
 }
Exemple #7
0
 /**
  * Edit a template
  */
 public function actionEdit($id)
 {
     if ($template = $this->_application->getTemplateById($id)) {
         $pdfLib = new PDFLib();
         $pdfLib->set_option("errorpolicy=exception");
         $tmpFile = tempnam($this->_config->getVarPath() . '/tmp/', 'pdftemplate');
         $document = $pdfLib->open_pdi_document($template->getTmpFilePath(), "");
         $pagecount = $pdfLib->pcos_get_number($document, "length:pages");
         $blocks = array();
         for ($pageNum = 0; $pageNum < $pagecount; $pageNum++) {
             $blockcount = $pdfLib->pcos_get_number($document, "length:pages[{$pageNum}]/blocks");
             for ($blockNum = 0; $blockNum < $blockcount; $blockNum++) {
                 $blocks[] = $pdfLib->pcos_get_string($document, "pages[{$pageNum}]/blocks[{$blockNum}]/Name");
             }
         }
         $blocks = array_unique($blocks);
         $form = new \Foundation\Form();
         $form->setCSRFToken($this->getCSRFToken());
         $form->setAction($this->path("setup/pdftemplates/edit/" . $template->getId()));
         $field = $form->newField();
         $field->setLegend('Edit Template Blocks');
         $element = $field->newElement('TextInput', 'title');
         $element->setLabel('Title');
         $element->setValue($template->getTitle());
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
         $blockElements = array('applicant-firstName' => 'Applicant: First Name', 'applicant-lastName' => 'Applicant: Last Name', 'applicant-middleName' => 'Applicant: Middle Name', 'applicant-suffix' => 'Applicant: Suffix', 'applicant-fullName' => 'Applicant: Full Name', 'applicant-email' => 'Applicant: Email', 'applicant-id' => 'Applicant: ID', 'applicant-externalid' => 'Applicant: External ID');
         foreach ($this->_application->getApplicationPages() as $applicationPage) {
             if ($applicationPage->getJazzeePage() instanceof \Jazzee\Interfaces\PdfPage) {
                 foreach ($applicationPage->getJazzeePage()->listPdfTemplateElements() as $key => $title) {
                     $blockElements[$key] = $title;
                 }
             }
         }
         foreach ($blocks as $blockName) {
             $element = $field->newElement('SelectList', 'block_' . $blockName);
             $element->setLabel("Block {$blockName}");
             $element->newItem(null, '');
             foreach ($blockElements as $id => $title) {
                 $element->newItem($id, $title);
             }
             if ($template->hasBlock($blockName)) {
                 $blockData = $template->getBlock($blockName);
                 switch ($blockData['type']) {
                     case 'applicant':
                         $element->setValue('applicant-' . $blockData['element']);
                         break;
                     case 'page':
                         $element->setValue('page-' . $blockData['pageId'] . '-element-' . $blockData['elementId']);
                         break;
                 }
             }
         }
         if ($input = $form->processInput($this->post)) {
             $template->setTitle($input->get('title'));
             $template->clearBlocks();
             $matches = array();
             //initialize for use in preg_match
             foreach ($blocks as $blockName) {
                 if ($blockElement = $input->get('block_' . $blockName)) {
                     if (preg_match('#applicant-([a-z]+)#i', $blockElement, $matches)) {
                         $template->addBlock($blockName, array('type' => 'applicant', 'element' => $matches[1]));
                     } else {
                         if (preg_match('#page-([0-9]+)-element-([0-9]+)#i', $blockElement, $matches)) {
                             $template->addBlock($blockName, array('type' => 'page', 'pageId' => $matches[1], 'elementId' => $matches[2]));
                         }
                     }
                 }
             }
             $this->getEntityManager()->persist($template);
             $this->addMessage('success', 'Template Saved Successfully');
             $this->redirectPath('setup/pdftemplates');
         }
         $form->newButton('submit', 'Save');
         $this->setVar('form', $form);
     } else {
         $this->addMessage('error', 'Unable to edit template.  It is not associated with this application.');
         $this->redirectPath('setup/pdftemplates');
     }
 }
Exemple #8
0
 /**
  * Edit an applicants external ID
  * @param integer $applicantId
  */
 public function actionEditExternalId($applicantId)
 {
     $applicant = $this->getApplicantById($applicantId);
     $form = new \Foundation\Form();
     $form->setAction($this->path("applicants/single/{$applicantId}/editExternalId"));
     $field = $form->newField();
     $field->setLegend('Change External ID for ' . $applicant->getFirstName() . ' ' . $applicant->getLastName());
     $element = $field->newElement('TextInput', 'externalId');
     $element->setLabel('External ID');
     $element->setFormat('Clear to remove the id');
     $element->setValue($applicant->getExternalId());
     $element->addValidator(new \Foundation\Form\Validator\SpecialObject($element, array('object' => $this->_application, 'method' => 'validateExternalId', 'errorMessage' => 'This is not a valid External ID for this program.')));
     $form->newButton('submit', 'Apply');
     if (!empty($this->post)) {
         $this->setLayoutVar('textarea', true);
         if ($input = $form->processInput($this->post)) {
             if ($input->get('externalId')) {
                 $applicant->setExternalId($input->get('externalId'));
                 $this->auditLog($applicant, 'External ID set to ' . $applicant->getExternalId());
                 $this->_em->persist($applicant);
                 $this->setLayoutVar('status', 'success');
             } else {
                 $applicant->setExternalId(null);
                 $this->auditLog($applicant, 'Removed External ID');
                 $this->_em->persist($applicant);
                 $this->setLayoutVar('status', 'success');
             }
         } else {
             $this->setLayoutVar('status', 'error');
         }
     }
     $this->setVar('result', array('actions' => $this->getActions($applicant)));
     $this->setVar('form', $form);
     $this->loadView('applicants_single/form');
 }
Exemple #9
0
 /**
  * Change applicant password
  */
 public function actionChangePassword()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->applyPath('account/changePassword'));
     $field = new \Foundation\Form\Field($form);
     $field->setLegend('Change Password');
     $form->addField($field);
     $element = $field->newElement('PasswordInput', 'password');
     $element->setLabel('Current Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('PasswordInput', 'newpassword');
     $element->setLabel('New Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('PasswordInput', 'confirm');
     $element->setLabel('Confirm Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\SameAs($element, 'newpassword'));
     $form->newButton('submit', 'Change Password');
     if ($input = $form->processInput($this->post)) {
         if ($this->_applicant->checkPassword($input->get('password'))) {
             $this->_applicant->setPassword($input->get('newpassword'));
             $this->_em->persist($this->_applicant);
             $this->addMessage('success', 'Your password was changed successfully.');
             $this->redirectApplyPath('account');
         } else {
             $form->getElementByName('password')->addMessage('Password Incorrect');
         }
     }
     $this->setVar('form', $form);
     $this->loadView($this->controllerName . '/form');
 }
Exemple #10
0
 /**
  * List all applicants
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('applicants/download'));
     $field = $form->newField();
     $field->setLegend('Download Applicants');
     $element = $field->newElement('RadioList', 'type');
     $element->setLabel('Type of Download');
     $element->newItem('xls', 'Excel');
     $element->newItem('xml', 'XML');
     $element->newItem('json', 'JSON');
     $element->newItem('pdfarchive', 'Archive of Multiple PDFs');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('CheckboxList', 'filters');
     $element->setLabel('Types of applicants');
     $element->newItem('unlocked', 'Incomplete');
     $element->newItem('locked', 'Locked');
     $element->newItem('admitted', 'Admitted');
     $element->newItem('denied', 'Denied');
     $element->newItem('accepted', 'Accepted');
     $element->newItem('declined', 'Declined');
     $tags = $this->_em->getRepository('\\Jazzee\\Entity\\Tag')->findByApplication($this->_application);
     foreach ($tags as $tag) {
         $element->newItem($tag->getId(), $tag->getTitle());
     }
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('RadioList', 'display');
     $element->setLabel('Display');
     $displays = array();
     foreach ($this->listDisplays() as $key => $display) {
         $displays[$key] = $display;
         $element->newItem($key, $display['name']);
     }
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Download Applicants');
     if ($input = $form->processInput($this->post)) {
         $filters = $input->get('filters');
         $applicationPages = array();
         foreach ($this->_application->getApplicationPages(\Jazzee\Entity\ApplicationPage::APPLICATION) as $pageEntity) {
             $pageEntity->getJazzeePage()->setController($this);
             $applicationPages[$pageEntity->getId()] = $pageEntity;
         }
         $applicantsArray = array();
         $minimalDisplay = new \Jazzee\Display\Minimal($this->_application);
         $ids = $this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->findIdsByApplication($this->_application);
         foreach ($ids as $id) {
             $applicant = $this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->findArray($id, $minimalDisplay);
             $selected = false;
             if (!$applicant['isLocked'] and in_array('unlocked', $filters)) {
                 $selected = true;
             }
             if ($applicant['isLocked']) {
                 if (in_array('locked', $filters)) {
                     $selected = true;
                 }
                 if ($applicant['decision']['finalAdmit'] and in_array('admitted', $filters)) {
                     $selected = true;
                 }
                 if ($applicant['decision']['finalDeny'] and in_array('denied', $filters)) {
                     $selected = true;
                 }
                 if ($applicant['decision']['acceptOffer'] and in_array('accepted', $filters)) {
                     $selected = true;
                 }
                 if ($applicant['decision']['declineOffer'] and in_array('declined', $filters)) {
                     $selected = true;
                 }
             }
             if (!$selected) {
                 $tagIds = array();
                 foreach ($applicant['tags'] as $arr) {
                     $tagIds[] = $arr['id'];
                 }
                 foreach ($filters as $value) {
                     if (array_key_exists($value, $tags)) {
                         $tag = $tags[$value];
                         if (in_array($tag->getId(), $tagIds)) {
                             $selected = true;
                         }
                     }
                 }
             }
             if ($selected) {
                 $applicantsArray[] = $applicant['id'];
             }
         }
         //end foreach applicants
         //use a full applicant display where display is needed
         $display = $this->getDisplay($displays[$input->get('display')]);
         unset($ids);
         switch ($input->get('type')) {
             case 'xls':
                 $this->makeXls($applicantsArray, $display);
                 break;
             case 'xml':
                 $this->makeXml($applicantsArray);
                 break;
             case 'json':
                 $this->makeJson($applicantsArray, $display);
                 break;
             case 'pdfarchive':
                 $this->makePdfArchive($applicantsArray, $display);
                 break;
         }
     }
     $this->setVar('form', $form);
 }
Exemple #11
0
 /**
  * Advanced Search Form
  */
 public function actionAdvanced()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('applicants/search/advanced'));
     $field = $form->newField();
     $field->setLegend('Advanced Search');
     $element = $field->newElement('Textarea', 'query');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\Json($element));
     $element->setLabel('Query');
     $form->newButton('submit', 'Search');
     if ($input = $form->processInput($this->post)) {
         $obj = json_decode($input->get('query'));
         $applicants = $this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->findApplicantsByQuery($obj, $this, $this->_application);
         $this->setVar('applicants', $applicants);
     }
     $this->setVar('form', $form);
     $this->loadView('applicants_search/index');
 }
Exemple #12
0
 /**
  * Bulk create applicants from a csv file
  */
 public function actionBulk()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('applicants/create/bulk'));
     $field = $form->newField();
     $field->setLegend('Create Applicants From File');
     $element = $field->newElement('FileInput', 'file');
     $element->setLabel('File');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\CSVArray($element));
     $element = $field->newElement('TextInput', 'notificationSubject');
     $element->setLabel('Subject for Notification Email');
     $element->setValue('New Application Account');
     $element = $field->newElement('Textarea', 'notificationMessage');
     $element->setLabel('Notification Email Message');
     $element->setFormat('Leave this blank if you do not want to notify the applicant of their new account');
     $notificationMessagereplacements = array('_Applicant_Name_', '_Deadline_', '_Link_', '_Email_', '_Password_');
     $element->setInstructions('You can use these tokens in the text, they will be replaced automatically: <br />' . implode('</br />', $notificationMessagereplacements));
     $element->setValue($this->_defaultEmail);
     $element = $field->newElement('DateInput', 'deadlineExtension');
     $element->setLabel('Deadline');
     $element->setFormat('If you wish to extend this applicants deadline past the application deadline enter it here.');
     if ($this->_application->getClose()) {
         $element->addValidator(new \Foundation\Form\Validator\DateAfter($element, $this->_application->getClose()->format('c')));
     }
     $form->newButton('submit', 'Upload File and create applicants');
     if ($input = $form->processInput($this->post)) {
         $newApplicants = $input->get('file');
         $first = $newApplicants[0];
         $requiredHeaders = array('External ID', 'First Name', 'Middle Name', 'Last Name', 'Suffix', 'Email Address', 'Password');
         $error = false;
         foreach ($requiredHeaders as $value) {
             if (!in_array($value, $first)) {
                 $form->getElementByName('file')->addMessage("The uploaded file must contain a column '{$value}'");
                 $error = true;
             }
         }
         if (!$error) {
             $headers = array_shift($newApplicants);
             $byKey = array();
             foreach ($newApplicants as $newApplicant) {
                 $arr = array();
                 foreach ($headers as $key => $value) {
                     $arr[$value] = $newApplicant[$key];
                 }
                 $byKey[] = $arr;
             }
             $newApplicants = $byKey;
             $results = array();
             foreach ($newApplicants as $newApplicant) {
                 $result = array('messages' => array(), 'applicant' => null, 'plainTextPassword' => '');
                 $duplicate = $this->_em->getRepository('Jazzee\\Entity\\Applicant')->findOneByEmailAndApplication($newApplicant['Email Address'], $this->_application);
                 if ($duplicate) {
                     $result['status'] = 'duplicate';
                     $result['messages'][] = 'An applicant with that email address already exists.';
                     $result['applicant'] = $duplicate;
                 } else {
                     if (!empty($newApplicant['External ID']) and !$this->_application->validateExternalId($newApplicant['External ID'])) {
                         $result['status'] = 'badExternalId';
                         $result['messages'][] = $newApplicant['External ID'] . ' is not a valid external ID for this program';
                         $result['applicantName'] = "{$newApplicant['First Name']} {$newApplicant['Last Name']}";
                         $result['applicantEmail'] = $newApplicant['Email Address'];
                     } else {
                         $result['status'] = 'success';
                         $applicant = new \Jazzee\Entity\Applicant();
                         $applicant->setApplication($this->_application);
                         $applicant->setEmail($newApplicant['Email Address']);
                         if ($newApplicant['Password']) {
                             $applicant->setPassword($newApplicant['Password']);
                             $plainTextPassword = $newApplicant['Password'];
                         } else {
                             $plainTextPassword = $applicant->generatePassword();
                         }
                         $applicant->setFirstName($newApplicant['First Name']);
                         $applicant->setMiddleName($newApplicant['Middle Name']);
                         $applicant->setLastName($newApplicant['Last Name']);
                         $applicant->setSuffix($newApplicant['Suffix']);
                         $applicant->setExternalId($newApplicant['External ID']);
                         if ($input->get('deadlineExtension')) {
                             $applicant->setDeadlineExtension($input->get('deadlineExtension'));
                         }
                         $this->_em->persist($applicant);
                         $result['applicant'] = $applicant;
                         $result['plainTextPassword'] = $plainTextPassword;
                         $result['messages'][] = 'Applicant Created Successfully';
                         if ($input->get('notificationMessage')) {
                             $replace = array($applicant->getFullName(), $applicant->getDeadline() ? $applicant->getDeadline()->format('l F jS Y g:ia') : '', $this->absoluteApplyPath("apply/{$this->_application->getProgram()->getShortName()}/{$this->_application->getCycle()->getName()}/applicant/login"), $applicant->getEmail(), $plainTextPassword);
                             $body = str_ireplace($notificationMessagereplacements, $replace, $input->get('notificationMessage'));
                             $subject = $input->get('notificationSubject') ? $input->get('notificationSubject') : 'New Application Account';
                             $email = $this->newMailMessage();
                             $email->AddCustomHeader('X-Jazzee-Applicant-ID:' . $applicant->getId());
                             $email->AddAddress($applicant->getEmail(), $applicant->getFullName());
                             $email->setFrom($this->_application->getContactEmail(), $this->_application->getContactName());
                             $email->Subject = $subject;
                             $email->Body = $body;
                             $email->Send();
                             $thread = new \Jazzee\Entity\Thread();
                             $thread->setSubject($subject);
                             $thread->setApplicant($applicant);
                             $message = new \Jazzee\Entity\Message();
                             $message->setSender(\Jazzee\Entity\Message::PROGRAM);
                             $message->setText(nl2br($body));
                             $message->read();
                             $thread->addMessage($message);
                             $this->_em->persist($thread);
                             $this->_em->persist($message);
                             $result['messages'][] = 'New account email sent';
                         }
                     }
                 }
                 $results[] = $result;
             }
             $this->setVar('results', $results);
             $this->_em->flush();
         }
     }
     $this->setVar('form', $form);
 }
Exemple #13
0
 /**
  * Send the invitaiton email
  * @param integer $answerID
  * @param array $postData
  */
 public function do_sendAdminInvitation($answerId, $postData)
 {
     $this->checkIsAdmin();
     if ($answer = $this->_applicant->findAnswerById($answerId)) {
         $path = $this->_controller->absolutePath('lor/' . $answer->getUniqueId());
         $link = str_ireplace('admin/', '', $path);
         $message = $this->getMessage($answer, $link);
         $form = new \Foundation\Form();
         $field = $form->newField();
         $field->setLegend('Send Invitation');
         $element = $field->newElement('Textarea', 'body');
         $element->setLabel('Email Text');
         $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
         $element->setValue($message->Body);
         if (!empty($postData)) {
             if ($input = $form->processInput($postData)) {
                 $message->Body = $input->get('body');
                 $message->Send();
                 $answer->lock();
                 $answer->markLastUpdate();
                 $this->_controller->getEntityManager()->persist($answer);
                 $this->_controller->setLayoutVar('status', 'success');
             } else {
                 $this->_controller->setLayoutVar('status', 'error');
             }
         }
         $form->newButton('submit', 'Send Email');
         return $form;
     }
     return false;
 }
Exemple #14
0
 /**
  * Create a new application
  * @param string $programShortName
  * @param string $cycleName
  * @return null
  */
 public function actionNew()
 {
     if ($this->_application->isByInvitationOnly()) {
         $this->addMessage('error', 'This application is by invitation only.  You cannot create an account.');
         $this->redirectApplyPath('');
     }
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->applyPath('applicant/new'));
     $field = new \Foundation\Form\Field($form);
     $field->setLegend('Create New Application');
     $form->addField($field);
     $element = $field->newElement('TextInput', 'first');
     $element->setLabel('First Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('TextInput', 'middle');
     $element->setLabel('Middle Name');
     $element = $field->newElement('TextInput', 'last');
     $element->setLabel('Last Name');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('TextInput', 'suffix');
     $element->setLabel('Suffix');
     $element->setFormat('Example: Jr., III');
     $element = $field->newElement('TextInput', 'email');
     $element->setLabel('Email Address');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\EmailAddress($element));
     $element->addFilter(new \Foundation\Form\Filter\Lowercase($element));
     $element = $field->newElement('PasswordInput', 'password');
     $element->setLabel('Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('PasswordInput', 'confirm-password');
     $element->setLabel('Confirm Password');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\SameAs($element, 'password'));
     if ($this->_config->getRecaptchaPrivateKey()) {
         //setup recaptcha element keys
         \Foundation\Form\Element\Captcha::setKeys($this->_config->getRecaptchaPrivateKey(), $this->_config->getRecaptchaPublicKey());
         $element = $field->newElement('Captcha', 'captcha');
     }
     $form->newButton('submit', 'Create Account');
     if ($input = $form->processInput($this->post)) {
         $duplicate = $this->_em->getRepository('Jazzee\\Entity\\Applicant')->findOneByEmailAndApplication($input->get('email'), $this->_application);
         if ($duplicate) {
             $this->addMessage('error', 'You have already started a ' . $this->_application->getProgram()->getName() . ' application.  Please login to retrieve it.');
             $this->redirectApplyPath('applicant/login');
         }
         $applicant = new \Jazzee\Entity\Applicant();
         $applicant->setApplication($this->_application);
         $applicant->setEmail($input->get('email'));
         $applicant->setPassword($input->get('password'));
         $applicant->setFirstName($input->get('first'));
         $applicant->setMiddleName($input->get('middle'));
         $applicant->setLastName($input->get('last'));
         $applicant->setSuffix($input->get('suffix'));
         $applicant->login();
         $this->_em->persist($applicant);
         //flush here to get the ID
         $this->_em->flush();
         $this->_store->expire();
         $this->_store->touchAuthentication();
         $this->_store->applicantID = $applicant->getId();
         $this->_authLog->info('New account login for applicant ' . $applicant->getId() . ' from ' . $_SERVER['REMOTE_ADDR']);
         $this->addMessage('success', 'Welcome to the ' . $this->_application->getProgram()->getName() . ' application.');
         $this->redirectApplyFirstPage();
     }
     $this->setVar('form', $form);
     if ($this->_config->getLoginMessage()) {
         $this->addMessage('error', $this->_config->getLoginMessage());
     }
 }
Exemple #15
0
 /**
  * Find Possible gre score matches
  * @param integer $answerID
  * @param array $postData
  */
 public function do_searchScores($postData)
 {
     $this->checkIsAdmin();
     $searchForm = new \Foundation\Form();
     $field = $searchForm->newField();
     $field->setLegend('Search Scores');
     $element = $field->newElement('TextInput', 'firstName');
     $element->setLabel('First Name');
     $element->setValue($this->_applicant->getFirstName());
     $element = $field->newElement('TextInput', 'lastName');
     $element->setLabel('Last Name');
     $element->setValue($this->_applicant->getLastName());
     $searchForm->newHiddenElement('level', 'search');
     $searchForm->newButton('submit', 'Search Scores');
     $matchForm = new \Foundation\Form();
     $field = $matchForm->newField();
     $field->setLegend('Select scores to match');
     $greElement = $field->newElement('CheckboxList', 'greMatches');
     $greElement->setLabel('Possible GRE');
     $toeflElement = $field->newElement('CheckboxList', 'toeflMatches');
     $toeflElement->setLabel('Possible TOEFL');
     $matchForm->newHiddenElement('level', 'match');
     $matchForm->newButton('submit', 'Match Scores');
     $form = $searchForm;
     if (!empty($postData)) {
         if ($postData['level'] == 'search') {
             if ($input = $searchForm->processInput($postData)) {
                 $matchForm->newHiddenElement('firstName', $input->get('firstName'));
                 $matchForm->newHiddenElement('lastName', $input->get('lastName'));
                 $existingScores = array();
                 foreach ($this->getAnswers() as $answer) {
                     $date = strtotime($this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_DATE)->getJazzeeElement()->displayValue($answer));
                     $uniqueId = $this->_applicationPage->getPage()->getElementByFixedId(self::FID_REGISTRATION_NUMBER)->getJazzeeElement()->displayValue($answer) . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_TYPE)->getJazzeeElement()->displayValue($answer) . date('m', $date) . date('Y', $date);
                     $existingScores[$uniqueId] = $answer;
                 }
                 foreach ($this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\GREScore')->findByName($input->get('firstName') . '%', $input->get('lastName') . '%') as $score) {
                     $uniqueId = $score->getRegistrationNumber() . 'GRE/GRE Subject' . $score->getTestDate()->format('m') . $score->getTestDate()->format('Y');
                     if (!array_key_exists($uniqueId, $existingScores)) {
                         $greElement->newItem($score->getId(), $score->getLastName() . ',  ' . $score->getFirstName() . ' ' . $score->getMiddleInitial() . ' ' . $score->getTestDate()->format('m/d/Y'));
                     } else {
                         if (!$existingScores[$uniqueId]->getGREScore()) {
                             $greElement->addMessage('The system found at least one match for a GRE score the applicant had previously entered.  You may need to refresh this page to view that match.');
                             $this->matchScore($existingScores[$uniqueId]);
                         }
                     }
                 }
                 foreach ($this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\TOEFLScore')->findByName($input->get('firstName') . '%', $input->get('lastName') . '%') as $score) {
                     $uniqueId = $score->getRegistrationNumber() . 'TOEFL' . $score->getTestDate()->format('m') . $score->getTestDate()->format('Y');
                     if (!array_key_exists($uniqueId, $existingScores)) {
                         $toeflElement->newItem($score->getId(), $score->getLastName() . ',  ' . $score->getFirstName() . ' ' . $score->getMiddleName() . ' ' . $score->getTestDate()->format('m/d/Y'));
                     } else {
                         if (!$existingScores[$uniqueId]->getTOEFLScore()) {
                             $toeflElement->addMessage('The system found at least one match for a TOEFL score the applicant had previously entered.  You may need to refresh this page to view that match.');
                             $this->matchScore($existingScores[$uniqueId]);
                         }
                     }
                 }
                 $form = $matchForm;
             }
         } else {
             if ($postData['level'] == 'match') {
                 $form = $matchForm;
                 //Re add all the matches to the elements so they will validate
                 foreach ($this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\GREScore')->findByName($postData['firstName'] . '%', $postData['lastName'] . '%') as $score) {
                     $greElement->newItem($score->getId(), $score->getLastName() . ',  ' . $score->getFirstName() . ' ' . $score->getMiddleInitial() . ' ' . $score->getTestDate()->format('m/d/Y'));
                 }
                 foreach ($this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\TOEFLScore')->findByName($postData['firstName'] . '%', $postData['lastName'] . '%') as $score) {
                     $toeflElement->newItem($score->getId(), $score->getLastName() . ',  ' . $score->getFirstName() . ' ' . $score->getMiddleName() . ' ' . $score->getTestDate()->format('m/d/Y'));
                 }
                 if ($input = $matchForm->processInput($postData)) {
                     //create a blank for so it can get values from parent::newAnswer
                     $this->_form = new \Foundation\Form();
                     if ($input->get('greMatches')) {
                         foreach ($input->get('greMatches') as $scoreId) {
                             $score = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\GREScore')->find($scoreId);
                             $arr = array('el' . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_REGISTRATION_NUMBER)->getId() => $score->getRegistrationNumber(), 'el' . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_DATE)->getId() => $score->getTestDate()->format('c'), 'el' . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_TYPE)->getId() => $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_TYPE)->getItemByValue('GRE/GRE Subject')->getId());
                             $newInput = new \Foundation\Form\Input($arr);
                             $this->newAnswer($newInput);
                         }
                     }
                     if ($input->get('toeflMatches')) {
                         foreach ($input->get('toeflMatches') as $scoreId) {
                             $score = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\TOEFLScore')->find($scoreId);
                             $arr = array('el' . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_REGISTRATION_NUMBER)->getId() => $score->getRegistrationNumber(), 'el' . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_DATE)->getId() => $score->getTestDate()->format('c'), 'el' . $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_TYPE)->getId() => $this->_applicationPage->getPage()->getElementByFixedId(self::FID_TEST_TYPE)->getItemByValue('TOEFL')->getId());
                             $newInput = new \Foundation\Form\Input($arr);
                             $this->newAnswer($newInput);
                         }
                     }
                     $this->_controller->setLayoutVar('status', 'success');
                 }
             }
         }
     }
     return $form;
 }
 /**
  * Decline Applicants
  */
 public function actionDeclineOffer()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('applicants/decisions/declineOffer'));
     $field = $form->newField();
     $field->setLegend('Decline Offer for applicants');
     $element = $field->newElement('CheckboxList', 'applicants');
     $element->setLabel('Select applicants to mark as declined');
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Applicant')->findApplicantsByName('%', '%', $this->_application) as $applicant) {
         if ($applicant->isLocked() and $applicant->getDecision()->can('declineOffer')) {
             $element->newItem($applicant->getId(), $applicant->getLastName() . ', ' . $applicant->getFirstName());
         }
     }
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $form->newButton('submit', 'Submit');
     if ($input = $form->processInput($this->post)) {
         $count = 0;
         foreach ($input->get('applicants') as $id) {
             $applicant = $this->getApplicantById($id);
             $applicant->getDecision()->declineOffer();
             $this->_em->persist($applicant);
             $this->auditLog($applicant, 'Decline Offer');
             $count++;
             if ($count > 100) {
                 $this->_em->flush();
                 $count = 0;
             }
         }
         $this->addMessage('success', count($this->post['applicants']) . ' applicant(s) declined.');
         $this->redirectPath('applicants/decisions');
     }
     $this->setVar('form', $form);
     $this->loadView('applicants_decisions/form');
 }
 /**
  * New Decision letter template
  */
 public function actionNew()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/decisionletters/new"));
     $field = $form->newField();
     $field->setLegend('New Template');
     $element = $field->newElement('RadioList', 'type');
     $element->setLabel('Type');
     $element->newItem(\Jazzee\Entity\Template::DECISION_ADMIT, 'Admit Letter');
     $element->newItem(\Jazzee\Entity\Template::DECISION_DENY, 'Deny Letter');
     $element->setValue(\Jazzee\Entity\Template::DECISION_ADMIT);
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element = $field->newElement('TextInput', 'title');
     $element->setLabel('Title');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\SafeHTML($element));
     $form->newButton('submit', 'Create');
     if ($input = $form->processInput($this->post)) {
         $template = new \Jazzee\Entity\Template($input->get('type'));
         $template->setTitle($input->get('title'));
         $template->setApplication($this->_application);
         $this->_em->persist($template);
         $this->_em->flush();
         $this->addMessage('success', $template->getTitle() . ' created.');
         $this->redirectPath('setup/decisionletters/edit/' . $template->getId());
     }
     $this->setVar('form', $form);
 }
Exemple #18
0
 public function testProcessInput()
 {
     $form = new \Foundation\Form();
     $this->assertFalse($form->processInput(array()));
     $form->setCSRFToken('testtoken');
     $this->assertFalse($form->processInput(array('test' => null)));
     $form = new \Foundation\Form();
     $element = $this->getMock('\\Foundation\\Form\\Element');
     $element->expects($this->once())->method('processInput')->will($this->returnValue(false));
     $field = $this->getMockBuilder('\\Foundation\\Form\\Field')->disableOriginalConstructor()->getMock();
     $field->expects($this->once())->method('getElements')->will($this->returnValue(array('fakename' => $element)));
     $form->addField($field);
     $this->assertFalse($form->processInput(array('test' => null)));
     $form = new \Foundation\Form();
     $element = $this->getMock('\\Foundation\\Form\\Element');
     $element->expects($this->once())->method('processInput')->will($this->returnValue(true));
     $field = $this->getMockBuilder('\\Foundation\\Form\\Field')->disableOriginalConstructor()->getMock();
     $field->expects($this->once())->method('getElements')->will($this->returnValue(array('fakename' => $element)));
     $form->addField($field);
     $arr = array('test1' => 'test1' . uniqid(), 'test2' => 'test2' . uniqid());
     $input = $form->processInput($arr);
     $this->assertInstanceOf('\\Foundation\\Form\\Input', $input);
     foreach ($arr as $key => $value) {
         $this->assertSame($value, $input->get($key));
     }
 }
Exemple #19
0
 /**
  * List all the pending payments in the system
  */
 public function actionIndex()
 {
     $this->setLayoutVar('pageTitle', 'Payment Report');
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path('payments/report'));
     $field = $form->newField();
     $field->setLegend('Search');
     $element = $field->newElement('CheckboxList', 'types');
     $element->setLabel('Payment Type');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $paymentTypes = array();
     foreach ($this->_em->getRepository('Jazzee\\Entity\\PaymentType')->findWithPayment() as $type) {
         $paymentTypes[$type->getId()] = $type;
     }
     foreach ($paymentTypes as $type) {
         $element->newItem($type->getId(), $type->getName());
     }
     $element = $field->newElement('DateInput', 'from');
     $element->setLabel('From');
     $element = $field->newElement('DateInput', 'to');
     $element->setLabel('To');
     $element->addValidator(new \Foundation\Form\Validator\DateAfterElement($element, 'from'));
     $element = $field->newElement('SelectList', 'program');
     $element->setLabel('Program');
     $element->newItem(null, '');
     $programs = array();
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Program')->findBy(array('isExpired' => false), array('name' => 'ASC')) as $program) {
         $programs[$program->getId()] = $program;
     }
     foreach ($programs as $program) {
         $element->newItem($program->getId(), $program->getName());
     }
     $element = $field->newElement('SelectList', 'cycle');
     $element->setLabel('Cycle');
     $element->newItem(null, '');
     $cycles = array();
     foreach ($this->_em->getRepository('\\Jazzee\\Entity\\Cycle')->findAll() as $cycle) {
         $cycles[$cycle->getId()] = $cycle;
     }
     foreach ($cycles as $cycle) {
         $element->newItem($cycle->getId(), $cycle->getName());
     }
     $payments = array();
     $form->newButton('submit', 'Search');
     if (empty($this->post)) {
         $from = new \DateTime('midnight yesterday');
         $to = new \DateTime('now');
         $payments = $this->_em->getRepository('\\Jazzee\\Entity\\Payment')->findByStatusArray(\Jazzee\Entity\Payment::SETTLED, array(), $from, $to);
         $this->setVar('resultsDescription', '');
         $description = sprintf('%s payments since midnight yesterday', count($payments));
         $this->setVar('searchResultsDescription', $description);
         $form->getElementByName('types')->setValue(array_keys($paymentTypes));
     } else {
         if ($input = $form->processInput($this->post)) {
             set_time_limit(120);
             $types = array();
             foreach ($input->get('types') as $id) {
                 $types[] = $paymentTypes[$id];
             }
             $program = $input->get('program') ? $programs[$input->get('program')] : null;
             $cycle = $input->get('cycle') ? $cycles[$input->get('cycle')] : null;
             $from = $input->get('from') ? new \DateTime($input->get('from')) : null;
             $to = $input->get('to') ? new \DateTime($input->get('to')) : null;
             $payments = $this->_em->getRepository('\\Jazzee\\Entity\\Payment')->findByStatusArray(\Jazzee\Entity\Payment::SETTLED, $types, $from, $to, $program, $cycle);
             //      $description = sprintf('%s results from search', count($payments));
             $this->setVar('searchResultsDescription', '');
         } else {
             $this->setVar('searchResultsDescription', '');
         }
     }
     foreach ($payments as &$payment) {
         $paymentType = $paymentTypes[$payment['type']['id']]->getJazzeePaymentType($this);
         $payment['notes'] = $paymentType->getPaymentNotesFromArray($payment);
     }
     $this->setVar('payments', $payments);
     $this->setVar('form', $form);
 }
Exemple #20
0
 /**
  * Edit the external ID validation
  */
 public function actionEditExternalIdValidation()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/application/editExternalIdValidation"));
     $field = $form->newField();
     $field->setLegend('Edit External iD Validation');
     $element = $field->newElement('TextInput', 'externalRegex');
     $element->setLabel('Regular Expression');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addValidator(new \Foundation\Form\Validator\IsRegex($element));
     $element->setValue($this->_application->getExternalIdValidationExpression());
     $form->newButton('submit', 'Save');
     if ($input = $form->processInput($this->post)) {
         $this->_application->setExternalIdValidationExpression($input->get('externalRegex'));
         $this->_em->persist($this->_application);
         $this->addMessage('success', 'External ID validation Saved.');
         $this->redirectPath('setup/application');
     }
     $this->setVar('form', $form);
     $this->loadView($this->controllerName . '/form');
 }
 /**
  * Setup the current application and cycle
  */
 public function actionIndex()
 {
     $form = new \Foundation\Form();
     $form->setCSRFToken($this->getCSRFToken());
     $form->setAction($this->path("setup/importapplication"));
     $field = $form->newField();
     $field->setLegend('Import Application');
     $element = $field->newElement('FileInput', 'file');
     $element->setLabel('XML Configuration');
     $element->addValidator(new \Foundation\Form\Validator\NotEmpty($element));
     $element->addFilter(new \Foundation\Form\Filter\Blob($element));
     $form->newButton('submit', 'Import');
     if ($input = $form->processInput($this->post)) {
         $xml = simplexml_load_string($input->get('file'));
         if (!$this->_application) {
             $this->_application = new \Jazzee\Entity\Application();
             $this->_application->setProgram($this->_program);
             $this->_application->setCycle($this->_cycle);
         }
         if ($this->_application->isPublished()) {
             $this->addMessage('error', 'This application is already published.  No changes can be made.');
             $this->redirectPath('setup/importapplication');
         }
         $pages = $this->_application->getApplicationPages();
         if (count($pages)) {
             $this->addMessage('error', 'This application already has pages.  You cannot import a configuration for an application with pages.');
             $this->redirectPath('setup/importapplication');
         }
         $preferences = $xml->xpath('/response/application/preferences');
         $arr = array();
         foreach ($preferences[0]->children() as $element) {
             $arr[$element->getName()] = (string) $element;
         }
         $this->_application->setContactName($arr['contactName']);
         $this->_application->setContactEmail($arr['contactEmail']);
         $this->_application->setWelcome(html_entity_decode($arr['welcome']));
         $this->_application->setOpen($arr['open']);
         $this->_application->setClose($arr['close']);
         $this->_application->setBegin($arr['begin']);
         $this->_application->setStatusIncompleteText($arr['statusIncompleteText']);
         $this->_application->setStatusNoDecisionText($arr['statusNoDecisionText']);
         $this->_application->setStatusAdmitText($arr['statusAdmitText']);
         $this->_application->setStatusDenyText($arr['statusDenyText']);
         $this->_application->setStatusAcceptText($arr['statusAcceptText']);
         $this->_application->setStatusDeclineText($arr['statusDeclineText']);
         if ($arr['visible'] == '1') {
             $this->_application->visible();
         }
         if ($arr['byinvitationonly'] == '1') {
             $this->_application->byInvitationOnly();
         } else {
             $this->_application->notByInvitationOnly();
         }
         if (array_key_exists('externalIdValidationExpression', $arr) and !empty($arr['externalIdValidationExpression'])) {
             $this->_application->setExternalIdValidationExpression($arr['externalIdValidationExpression']);
         }
         foreach ($xml->xpath('/response/application/preferences/templates/template') as $templates) {
             $arr2 = array();
             foreach ($templates[0]->children() as $element) {
                 $arr2[$element->getName()] = (string) $element;
             }
             $template = new \Jazzee\Entity\Template($arr2['type']);
             $template->setApplication($this->_application);
             $template->setTitle($arr2['title']);
             $template->setText($arr2['text']);
             $this->_em->persist($template);
         }
         foreach ($xml->xpath('/response/application/pages/page') as $element) {
             $attributes = $element->attributes();
             $page = $this->addPageFromXml($element);
             $applicationPage = new \Jazzee\Entity\ApplicationPage();
             $applicationPage->setApplication($this->_application);
             $applicationPage->setPage($page);
             $applicationPage->setKind((string) $attributes['kind']);
             $applicationPage->setName((string) $attributes['name']);
             $applicationPage->setTitle(html_entity_decode((string) $attributes['title']));
             $applicationPage->setMin((string) $attributes['min']);
             $applicationPage->setMax((string) $attributes['max']);
             if ((string) $attributes['required']) {
                 $applicationPage->required();
             } else {
                 $applicationPage->optional();
             }
             if ((string) $attributes['answerStatusDisplay']) {
                 $applicationPage->showAnswerStatus();
             } else {
                 $applicationPage->hideAnswerStatus();
             }
             $eattr = $element->xpath('instructions');
             $applicationPage->setInstructions((string) $eattr[0]);
             $eattr = $element->xpath('leadingText');
             $applicationPage->setLeadingText((string) $eattr[0]);
             $eattr = $element->xpath('trailingText');
             $applicationPage->setTrailingText((string) $eattr[0]);
             $applicationPage->setWeight((string) $attributes['weight']);
             $this->_em->persist($applicationPage);
         }
         $this->_em->persist($this->_application);
         $this->addMessage('success', 'Application imported successfully');
         unset($this->_store->AdminControllerGetNavigation);
     }
     $this->setVar('form', $form);
 }