コード例 #1
0
ファイル: SchbasAccounting.php プロジェクト: Auwibana/babesk
 /**
  * based on the post-values given from Ajax, this function sets the
  * has-user-returned-the-message-value to "hasReturned"
  *
  * @return void
  */
 protected function userSetReturnedFormByBarcodeAjax()
 {
     $formDataStr = filter_input(INPUT_POST, 'barcode');
     if (!$formDataStr) {
         $this->SchbasAccountingInterface->dieError('Bitte auszutauschenden oder neuen Antrag einscannen!');
     }
     $formData = explode(' ', $formDataStr);
     if (count($formData) != 2) {
         $this->SchbasAccountingInterface->dieError('Bitte auszutauschenden oder neuen Antrag einscannen!');
     }
     $prepSchoolyear = $this->preparationSchoolyearGet();
     list($userId, $loanChoiceStr) = $formData;
     if ($userId && $loanChoiceStr) {
         $loanChoices = array('nl', 'ln', 'lr', 'ls');
         $user = $this->_em->find('DM:SystemUsers', $userId);
         if (!$user) {
             $this->SchbasAccountingInterface->dieError('Konnte den Benutzer nicht finden.');
         }
         $accounting = $this->_em->getRepository('DM:SchbasAccounting')->findOneBy(['user' => $user, 'schoolyear' => $prepSchoolyear]);
         if ($accounting) {
             http_response_code(409);
             die('Der Antrag für diesen Benutzer wurde bereits ' . 'eingescannt. Bitte löschen sie ihn manuell, um ihn neu ' . 'hinzuzufügen.');
         }
         if (!$this->isUserInSchoolyearCheck($user, $prepSchoolyear)) {
             http_response_code(400);
             die('Der Benutzer ist im Vorbereitungsschuljahr in keiner ' . 'Klasse');
         }
         if (in_array($loanChoiceStr, $loanChoices, true)) {
             require_once PATH_INCLUDE . '/Schbas/Loan.php';
             $loanHelper = new \Babesk\Schbas\Loan($this->_dataContainer);
             $loanChoice = $this->_em->getRepository('DM:SchbasLoanChoice')->findOneByAbbreviation($loanChoiceStr);
             try {
                 list($feeNormal, $feeReduced) = $loanHelper->loanPriceOfAllBookAssignmentsForUserCalculate($user);
                 if ($loanChoice->getAbbreviation() == "ln") {
                     $amountToPay = $feeNormal;
                 } else {
                     if ($loanChoice->getAbbreviation() == "lr") {
                         $amountToPay = $feeReduced;
                     } else {
                         $amountToPay = 0.0;
                     }
                 }
                 $accounting = new \Babesk\ORM\SchbasAccounting();
                 $accounting->setUser($user);
                 $accounting->setSchoolyear($prepSchoolyear);
                 $accounting->setLoanChoice($loanChoice);
                 $accounting->setPayedAmount(0.0);
                 $accounting->setAmountToPay($amountToPay);
                 $this->_em->persist($accounting);
                 $this->_em->flush();
                 die('success');
             } catch (\Exception $e) {
                 $this->_logger->logO('Error adding accounting-entry', ['sev' => 'error', 'moreJson' => $e->getMessage()]);
                 die('Ein Fehler ist beim Hinzufügen aufgetreten.');
             }
         } else {
             die('notValid');
         }
     } else {
         die('error');
     }
 }
コード例 #2
0
ファイル: LoanSystem.php プロジェクト: Auwibana/babesk
    private function showParticipationConfirmation()
    {
        $settingsRepo = $this->_em->getRepository('DM:SystemGlobalSettings');
        $user = $this->_em->find('DM:SystemUsers', $_SESSION['uid']);
        $prepSchoolyear = $this->preparationSchoolyearGet();
        $gradeQuery = $this->_em->createQuery('SELECT g FROM DM:SystemGrades g
			INNER JOIN g.attendances a
				WITH a.schoolyear = :schoolyear AND a.user = :user
		');
        $gradeQuery->setParameter('schoolyear', $prepSchoolyear);
        $gradeQuery->setParameter('user', $user);
        $grade = $gradeQuery->getOneOrNullResult();
        if (!$grade) {
            $this->_interface->dieError('Der Schüler ist nicht im nächsten Schuljahr eingetragen. ' . 'Bitte informieren sie die Schule.');
        }
        // $letterDateIso = $settingsRepo
        // 	->findOneByName('schbasDateCoverLetter')
        // 	->getValue();
        // $letterDate = date('d.m.Y', strtotime($letterDateIso));
        $letterDate = date('d.m.Y');
        $schbasDeadlineTransferIso = $settingsRepo->findOneByName('schbasDeadlineTransfer')->getValue();
        $schbasDeadlineTransfer = date('d.m.Y', strtotime($schbasDeadlineTransferIso));
        $schbasDeadlineClaimIso = $settingsRepo->findOneByName('schbasDeadlineClaim')->getValue();
        $schbasDeadlineClaim = date('d.m.Y', strtotime($schbasDeadlineClaimIso));
        $bankAccount = $settingsRepo->findOneByName('bank_details')->getValue();
        $bankData = explode('|', $bankAccount);
        //get loan fees
        $loanHelper = new \Babesk\Schbas\Loan($this->_dataContainer);
        $fees = $loanHelper->loanPriceOfAllBookAssignmentsForUserCalculate($user);
        list($feeNormal, $feeReduced) = $fees;
        $feedback = '';
        $loanChoice = filter_input(INPUT_POST, 'loanChoice');
        $loanFee = filter_input(INPUT_POST, 'loanFee');
        $siblings = filter_input(INPUT_POST, 'siblings');
        $eb_name = filter_input(INPUT_POST, 'eb_name');
        $eb_vorname = filter_input(INPUT_POST, 'eb_vorname');
        $eb_adress = filter_input(INPUT_POST, 'eb_adress');
        $eb_tel = filter_input(INPUT_POST, 'eb_tel');
        if ($loanChoice == 'noLoan') {
            $feedback = 'nl';
        } else {
            if ($loanFee == 'loanSoli') {
                $feedback = 'ls';
            } else {
                if ($loanFee == 'loanNormal') {
                    $feedback = 'ln';
                } else {
                    if ($loanFee == 'loanReduced') {
                        $feedback = 'lr';
                    }
                }
            }
        }
        $this->_smarty->assign('user', $user);
        $this->_smarty->assign('grade', $grade);
        $this->_smarty->assign('schoolyear', $prepSchoolyear->getLabel());
        $this->_smarty->assign('letterDate', $letterDate);
        $this->_smarty->assign('schbasDeadlineClaim', $schbasDeadlineClaim);
        $this->_smarty->assign('bankData', $bankData);
        $this->_smarty->assign('feeNormal', $feeNormal);
        $this->_smarty->assign('feeReduced', $feeReduced);
        $this->_smarty->assign('loanFee', $loanFee);
        $this->_smarty->assign('siblings', $siblings);
        $this->_smarty->assign('loanChoice', $loanChoice);
        $this->_smarty->assign('parentName', $eb_name);
        $this->_smarty->assign('parentForename', $eb_vorname);
        $this->_smarty->assign('parentAddress', $eb_adress);
        $this->_smarty->assign('parentTelephone', $eb_tel);
        $this->_smarty->assign('schbasDeadlineTransfer', $schbasDeadlineTransfer);
        $content = $this->_smarty->fetch(PATH_SMARTY_TPL . '/pdf/schbas-participation-confirmation.pdf.tpl');
        $schbasPdf = new \Babesk\Schbas\SchbasPdf($user->getId(), $grade->getGradelevel());
        $barcode = $user->getId() . ' ' . $feedback;
        $schbasPdf->create($content, $barcode);
        $schbasPdf->output();
    }