Exemplo n.º 1
0
 protected function outputPdf()
 {
     $assistantsCost = filter_input(INPUT_GET, 'assistantsCost');
     $toolsCost = filter_input(INPUT_GET, 'toolsCost');
     if (isset($assistantsCost)) {
         $assistantsCost = str_replace(',', '.', $assistantsCost);
         $assistantsCost = money_format('%.2n', floatval($assistantsCost));
     }
     if (isset($toolsCost)) {
         $toolsCost = str_replace(',', '.', $toolsCost);
         $toolsCost = money_format('%.2n', floatval($toolsCost));
     }
     $otherCosts = [];
     if (isset($_GET['otherCosts']) && count($_GET['otherCosts'])) {
         $otherCosts = $_GET['otherCosts'];
         $otherCosts = array_map(function ($otherCost) {
             $date = date('d.m.Y', strtotime($otherCost['date']));
             $amount = money_format('%.2n', floatval($otherCost['amount']));
             return ['amount' => $amount, 'date' => $date, 'recipient' => $otherCost['recipient']];
         }, $_GET['otherCosts']);
     }
     $data = $this->calculateData();
     $today = date('d.m.Y H:i');
     $title = "Schbas Statistik ({$today})";
     $this->_smarty->assign('data', $data);
     $this->_smarty->assign('assistantsCost', $assistantsCost);
     $this->_smarty->assign('toolsCost', $toolsCost);
     $this->_smarty->assign('otherCosts', $otherCosts);
     $this->_smarty->assign('title', $title);
     $pdf = new GeneralPdf($this->_pdo);
     $html = $this->_smarty->fetch(PATH_SMARTY_TPL . '/pdf/schbas-statistics.pdf.tpl');
     $pdf->create($title, $html);
     $pdf->output();
 }
Exemplo n.º 2
0
    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();
    }
Exemplo n.º 3
0
 /**
  * Creates an PDF with the Orders of all SoliUsers in a given week or month.
  * @param $kw week/month number
  * @param $weekMode true, if filtered by week
  * 					false, if filtered by month
  */
 function AllSoliOrdersToPDFByWeekOrMonth($dataContainer, $kw, $weekMode)
 {
     require_once PATH_ACCESS . '/UserManager.php';
     require_once PATH_INCLUDE . '/pdf/GeneralPdf.php';
     $userManager = new UserManager();
     $pdo = $dataContainer->getPdo();
     $smarty = $dataContainer->getSmarty();
     if ($weekMode) {
         $firstDay = getFirstDayOfWeek(date('Y'), $kw);
         $days = 5;
         $title = "SoliBestellungen Kalenderwoche " . $kw;
     } else {
         $firstDay = mktime(0, 0, 0, $kw, 1, date('Y'));
         $days = cal_days_in_month(CAL_GREGORIAN, $kw, date('Y'));
         $month_ger = array('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember');
         $title = "SoliBestellungen " . $month_ger[$kw - 1];
         $kw = $month_ger[$kw - 1];
     }
     $secs_per_day = 86400;
     $number = 0;
     $sum_pricediff = 0.0;
     $solis = $userManager->getAllSoli();
     foreach ($solis as $soli) {
         $pricediff = 0.0;
         $SoliOrders[$number]['soli'] = $soli;
         $orders = array();
         for ($i = 0; $i < $days; $i++) {
             $buffer = array();
             try {
                 $buffer = $this->soliOrderManager->getOrdersByUserandMealdate($soli['ID'], date('Y-m-d', $firstDay + $i * $secs_per_day));
             } catch (MySQLVoidDataException $e) {
                 //	$this->soliInterface->showMsg($this->msg['ERR_ORDERS_NOT_FOUND']);
             }
             foreach ($buffer as &$order) {
                 $orders[] = $order;
             }
         }
         foreach ($orders as &$order) {
             $pricediff += $order['mealprice'] - $order['soliprice'];
         }
         $sum_pricediff += $pricediff;
         $SoliOrders[$number]['orders'] = $orders;
         $SoliOrders[$number]['pricediff'] = $pricediff;
         $number++;
     }
     $smarty->assign('SoliOrders', $SoliOrders);
     $smarty->assign('weekMode', $weekMode);
     $smarty->assign('ordering_date', $kw);
     $smarty->assign('sum', $sum_pricediff);
     $pdf_content = $smarty->fetch(PATH_SMARTY_TPL . '/pdf/orders_of_soliuser_per_week.pdf.tpl');
     $pdf = new GeneralPdf($pdo);
     $pdf->create($title, $pdf_content);
     $pdf->output();
 }
Exemplo n.º 4
0
 /**
  * Prints a PDF with all Recharges in the Interval the User selected
  */
 protected function rechargeBalancePdfPrint()
 {
     extract($this->timestampsFromIntervalInputGet($_POST['date']));
     $rechargesToPrint = $this->rechargesFetchBetween(date('Y-m-d H:i:s', $start), date('Y-m-d H:i:s', $end));
     $table = $this->rechargesAsHtmlTable($rechargesToPrint);
     $sum = $this->rechargesSum($rechargesToPrint);
     $table .= '<p></p><p></p><b>' . _g('Sum:') . ' ' . $sum . '</b>';
     $title = _g('Balance-Print for the days from %1$s to %2$s', date('d.m.Y', $start), date('d.m.Y', $end - 1));
     $html = "<p align='center'><h2>{$title}</h2></p><br />" . $table;
     require_once PATH_INCLUDE . '/pdf/GeneralPdf.php';
     $pdf = new GeneralPdf($this->_pdo);
     $pdf->create($title, $html);
     $pdf->output();
 }
Exemplo n.º 5
0
 /**
  * Sends a pdf with an overview over the fetched users to the client
  */
 private function pdfSend()
 {
     $pdfTitle = filter_input(INPUT_GET, 'pdf-title');
     $opt = [];
     $opt['specialFilter'] = filter_input(INPUT_GET, 'specialFilter');
     // We want all users to be printed into the pdf
     $this->_usersPerPage = 9999;
     $data = $this->userdataFetch($_GET['filter'], $_GET['filterForColumns'], $_GET['sortColumn'], 1, $opt);
     $this->_smarty->assign('title', $pdfTitle);
     $this->_smarty->assign('users', $data['users']);
     $html = $this->_smarty->fetch(PATH_SMARTY_TPL . '/pdf/schbas-record-receipt-user-list.pdf.tpl');
     $pdf = new \GeneralPdf($this->_pdo);
     $pdf->create($pdfTitle, $html);
     $pdf->output();
 }