private function createPayoutSummary()
 {
     $sql_payout = "SELECT (CASE WHEN ra.id IS NULL THEN r.price ELSE ra.price END) AS price, r.src_id AS order_id,\n            (CASE WHEN sre.form_type = 1 THEN sre._1_fio ELSE sre._2_fio END) AS emp_fio, \n            (CASE WHEN srf.form_type = 1 THEN srf._1_fio ELSE srf._2_fio END) AS frl_fio,\n            fro.path, fro.fname, r.frl_id, frl.email \n            FROM reserves r\n            INNER JOIN reserves_payout_reqv rpr ON r.id = rpr.reserve_id\n            INNER JOIN sbr_reqv sre ON sre.user_id = r.emp_id\n            INNER JOIN sbr_reqv srf ON srf.user_id = r.frl_id\n            LEFT JOIN file_reserves_order fro ON r.src_id = fro.src_id AND fro.doc_type = ?i\n            LEFT JOIN reserves_arbitrage ra ON ra.reserve_id = r.id\n            INNER JOIN freelancer frl ON frl.uid = r.frl_id\n            WHERE rpr.pay_type = 'bank'\n            AND r.status IN (?l)\n            AND rpr.date > ? AND rpr.date < ?;";
     $data_payments = $this->db()->rows($sql_payout, DocGenReserves::LETTER_FRL_TYPE, array(ReservesModel::STATUS_PAYED, ReservesModel::STATUS_ARBITRAGE), $this->start, $this->end);
     $sql_back = "SELECT r.src_id AS order_id, r.emp_id,\n            (r.price - ra.price) AS price,\n            (CASE WHEN sre.form_type = 1 THEN sre._1_fio ELSE sre._2_fio END) AS emp_fio, \n            (CASE WHEN srf.form_type = 1 THEN srf._1_fio ELSE srf._2_fio END) AS frl_fio,\n            fro.path, fro.fname, emp.email\n            FROM reserves r\n            INNER JOIN reserves_bank rb ON r.id = rb.reserve_id\n            INNER JOIN reserves_arbitrage ra ON r.id = ra.reserve_id\n            INNER JOIN sbr_reqv sre ON sre.user_id = r.emp_id\n            LEFT JOIN sbr_reqv srf ON srf.user_id = r.frl_id\n            INNER JOIN employer emp ON emp.uid = r.emp_id\n            LEFT JOIN file_reserves_order fro ON r.src_id = fro.src_id AND fro.doc_type = ?i\n            WHERE r.status_back > 1\n            AND r.invoice_id IS NULL\n            AND ra.date_close > ? AND ra.date_close < ?;";
     $data_payback = $this->db()->rows($sql_back, DocGenReserves::ARBITRAGE_REPORT_TYPE, $this->start, $this->end);
     $reportGenerator = new ReservesAdminBankReportGeneratorModel();
     $this->generated_file_name = $reportGenerator->generate2($data_payments, $data_payback);
 }
Esempio n. 2
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/siteadmin/reserves/models/ReservesAdminBankReportGeneratorModel.php';
$reservesAdminBankReportGeneratorModel = new ReservesAdminBankReportGeneratorModel();
$payouts = array(array('frl_id' => 1, 'email' => '*****@*****.**', 'path' => '/dir/', 'fname' => 'file.pdf', 'order_id' => 42, 'frl_fio' => 'Леонид Агутин', 'price' => 5000, 'emp_fio' => 'Анжелика Варум'));
$paybacks = array(array('frl_id' => 1, 'email' => '*****@*****.**', 'path' => '/newdir/', 'fname' => 'file2.pdf', 'order_id' => 47, 'frl_fio' => 'Леонид Агутин', 'price' => 500, 'emp_fio' => 'Анжелика Варум'));
echo '<a href="' . WDCPREFIX . $reservesAdminBankReportGeneratorModel->generate2($payouts, $paybacks) . '">Файл</a>';