コード例 #1
0
ファイル: Loan.php プロジェクト: Auwibana/babesk
 private function loanDisplay($cardnumber)
 {
     $loanHelper = new \Babesk\Schbas\Loan($this->_dataContainer);
     $prepSchoolyear = $loanHelper->schbasPreparationSchoolyearGet();
     $user = $this->userByCardnumberGet($cardnumber);
     $loanChoice = false;
     $accounting = $this->_em->getRepository('DM:SchbasAccounting')->findOneBy(['user' => $user, 'schoolyear' => $prepSchoolyear]);
     if ($accounting !== Null) {
         $userPaid = $this->userPaidForLoanCheck($accounting);
         $userSelfpayer = $this->selfpayerCheck($accounting);
         $loanChoice = $accounting->getLoanChoice()->getAbbreviation();
         $formSubmitted = true;
     } else {
         $userPaid = false;
         $userSelfpayer = false;
         $formSubmitted = false;
     }
     $exemplarsLent = $this->exemplarsStillLendByUserGet($user);
     $booksSelfpaid = $user->getSelfpayingBooks();
     // The books that are already lend to the user will be highlighted
     $booksToLoan = $loanHelper->loanBooksOfUserGet($user, ['includeAlreadyLend' => true]);
     $booksToLoanWithLent = [];
     foreach ($booksToLoan as $book) {
         $alreadyLent = false;
         foreach ($exemplarsLent as $exemplar) {
             if ($book === $exemplar->getBook() && $book->getId() == $exemplar->getBook()->getId()) {
                 $alreadyLent = true;
                 break;
             }
         }
         $booksToLoanWithLent[] = ['book' => $book, 'alreadyLent' => $alreadyLent];
     }
     $this->_smarty->assign('user', $user);
     $this->_smarty->assign('formSubmitted', $formSubmitted);
     $this->_smarty->assign('loanChoice', $loanChoice);
     $this->_smarty->assign('userPaid', $userPaid);
     $this->_smarty->assign('userSelfpayer', $userSelfpayer);
     $this->_smarty->assign('exemplarsLent', $exemplarsLent);
     $this->_smarty->assign('booksSelfpaid', $booksSelfpaid);
     $this->_smarty->assign('booksToLoan', $booksToLoanWithLent);
     $this->displayTpl('user-loan-list.tpl');
 }
コード例 #2
0
ファイル: SchbasAccounting.php プロジェクト: Auwibana/babesk
    private function bookOverview()
    {
        $loanHelper = new \Babesk\Schbas\Loan($this->_dataContainer);
        $schoolyear = $this->_em->getRepository('DM:SystemSchoolyears')->findOneByActive(true);
        $gradeId = filter_input(INPUT_POST, 'grade');
        if (!$gradeId) {
            $this->_interface->dieError('Keine Klasse übergeben');
        }
        $grade = $this->_em->find('DM:SystemGrades', $gradeId);
        $query = $this->_em->createQuery('SELECT u FROM DM:SystemUsers u
			INNER JOIN u.attendances a
			INNER JOIN a.schoolyear s WITH s = :schoolyear
			INNER JOIN a.grade g WITH g = :grade
			ORDER BY u.name, u.forename
		');
        $query->setParameter('grade', $grade);
        $query->setParameter('schoolyear', $schoolyear);
        $users = $query->getResult();
        // The only difference between the PDF for booksToReturn and
        // booksToLoan is the title and the included books
        $pdfTitle = '';
        $syName = $schoolyear->getLabel();
        $gradename = $grade->getGradelevel() . $grade->getLabel();
        // [{ user: {<userdata>}, books: [{<bookdata>}] }]
        $usersWithBooks = [];
        if (isset($_POST['booksToReturn'])) {
            $pdfTitle = "Abzugebende Bücher für {$gradename} ({$syName})";
            foreach ($users as $user) {
                $books = $loanHelper->lendBooksToReturnOfUserGet($user, $schoolyear);
                $usersWithBooks[] = ['user' => $user, 'books' => $books];
            }
        } else {
            if (isset($_POST['booksToLoan'])) {
                $pdfTitle = "Noch auszuleihende Bücher für {$gradename} ({$syName})";
                foreach ($users as $user) {
                    $books = $loanHelper->loanBooksOfUserGet($user, ['schoolyear' => $schoolyear]);
                    $usersWithBooks[] = ['user' => $user, 'books' => $books];
                }
            }
        }
        $date = date('d.m.Y H:i:s');
        $this->_smarty->assign('grade', $grade);
        $this->_smarty->assign('date', $date);
        $this->_smarty->assign('usersWithBooks', $usersWithBooks);
        $this->_smarty->assign('pdfTitle', $pdfTitle);
        $pdfContent = $this->_smarty->fetch(PATH_SMARTY_TPL . '/pdf/schbas-books-overview.pdf.tpl');
        $pdf = new GeneralPdf($this->_pdo);
        $pdf->create($pdfTitle, $pdfContent);
        $pdf->output();
    }
コード例 #3
0
ファイル: LoanSystem.php プロジェクト: Auwibana/babesk
    private function showMainMenu()
    {
        $prepSchoolyear = $this->preparationSchoolyearGet();
        $user = $this->_em->getReference('DM:SystemUsers', $_SESSION['uid']);
        $gradelevelStmt = $this->_pdo->prepare("SELECT gradelevel FROM SystemGrades g\n\t\t\t\tLEFT JOIN SystemAttendances uigs\n\t\t\t\t\tON uigs.gradeId = g.ID\n\t\t\t\tWHERE uigs.userId = ? AND uigs.schoolyearId = @activeSchoolyear\n\t\t");
        $gradelevelStmt->execute(array($_SESSION['uid']));
        $gradelevel = $gradelevelStmt->fetchColumn();
        //Check if we got an entry back
        if ($gradelevel === false) {
            $this->_logger->log('User accessing Schbas not in a grade!', 'Notice', Null, json_encode(array('uid' => $_SESSION['uid'])));
            $this->_interface->dieError('Du bist in keiner Klasse eingetragen!');
        }
        $gradelevel = strval(intval($gradelevel) + 1);
        // Filter fuer Abijahrgang
        if ($gradelevel == "13") {
            $this->_smarty->display($this->_smartyPath . 'lastGrade.tpl');
        }
        $loanHelper = new \Babesk\Schbas\Loan($this->_dataContainer);
        $fees = $loanHelper->loanPriceOfAllBookAssignmentsForUserCalculate($user);
        list($feeNormal, $feeReduced) = $fees;
        $loanbooksTest = $loanHelper->loanBooksOfUserGet($user, ['includeSelfpay' => true, 'includeAlreadyLend' => true]);
        $query = $this->_em->createQuery('SELECT b FROM DM:SchbasBook b
			INNER JOIN b.selfpayingUsers u WITH u = :user
		');
        $query->setParameter('user', $user);
        $selfpayingBooks = $query->getResult();
        // [ {
        //     'book': '<book>',
        //     'selfpaying': '<boolean>'
        // } ]
        $booksWithSelfpayingStatus = array();
        $selfpayingBooksColl = new ArrayCollection($selfpayingBooks);
        foreach ($loanbooksTest as $book) {
            $isSelfpaying = $selfpayingBooksColl->contains($book);
            $booksWithSelfpayingStatus[] = ['book' => $book, 'selfpaying' => $isSelfpaying];
        }
        $this->_smarty->assign('booksWithStatus', $booksWithSelfpayingStatus);
        $this->_smarty->assign('feeNormal', $feeNormal);
        $this->_smarty->assign('feeReduced', $feeReduced);
        $this->_smarty->assign('prepSchoolyear', $prepSchoolyear);
        $this->_smarty->assign('BaBeSkTerminal', $this->checkIsKioskMode());
        $this->_smarty->assign('loanShowForm', isset($_POST['loanShowForm']));
        $this->_smarty->assign('loanShowBuy', isset($_POST['loanShowBuy']));
        $this->_smarty->display($this->_smartyPath . 'menu.tpl');
    }