Пример #1
0
 /**
  * Execute post contribution script
  *
  * @param ExternalScript $es     External script to execute
  * @param array          $extra  Extra informations on contribution
  *                                  Defaults to null
  * @param array          $pextra Extra information on payment
  *                                  Defaults to null
  *
  * @return mixed Script return value on success, values and script output on fail
  */
 public function executePostScript(ExternalScript $es, $extra = null, $pextra = null)
 {
     global $zdb, $preferences;
     $payment = array('type' => $this->getPaymentType());
     if ($pextra !== null && is_array($pextra)) {
         $payment = array_merge($payment, $pextra);
     }
     if (!file_exists(GALETTE_CACHE_DIR . '/pdf_contribs')) {
         @mkdir(GALETTE_CACHE_DIR . '/pdf_contribs');
     }
     $voucher_path = null;
     if ($this->_id !== null) {
         $voucher = new PdfContribution($this, $zdb, $preferences);
         $voucher->store(GALETTE_CACHE_DIR . '/pdf_contribs');
         $voucher_path = $voucher->getPath();
     }
     $contrib = array('date' => $this->_date, 'type' => $this->getRawType(), 'amount' => $this->amount, 'voucher' => $voucher_path, 'category' => array('id' => $this->type->id, 'label' => $this->type->libelle), 'payment' => $payment);
     if ($this->_member !== null) {
         $m = new Adherent((int) $this->_member);
         $member = array('name' => $m->sfullname, 'email' => $m->email, 'organization' => $m->isCompany() ? 1 : 0, 'status' => array('id' => $m->status, 'label' => $m->sstatus), 'country' => $m->country);
         if ($m->isCompany()) {
             $member['organization_name'] = $m->company_name;
         }
         $contrib['member'] = $member;
     }
     if ($extra !== null && is_array($extra)) {
         $contrib = array_merge($contrib, $extra);
     }
     $res = $es->send($contrib);
     if ($res !== true) {
         Analog::log('An error occured calling post contribution ' . "script:\n" . $es->getOutput(), Analog::ERROR);
         $res = _T("Contribution informations") . "\n";
         $res .= print_r($contrib, true);
         $res .= "\n\n" . _T("Script output") . "\n";
         $res .= $es->getOutput();
     }
     return $res;
 }
Пример #2
0
 *
 * @author    Johan Cwiklinski <*****@*****.**>
 * @copyright 2013-2014 The Galette Team
 * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
 * @version   SVN: $Id$
 * @link      http://galette.tuxfamily.org
 */
use Galette\IO\PdfContribution;
use Galette\IO\Pdf;
use Galette\Entity\Adherent;
use Galette\Entity\Contribution;
use Galette\Entity\PdfModel;
use Galette\Entity\PdfInvoice;
use Galette\Entity\PdfReceipt;
use Analog\Analog;
/** @ignore */
require_once 'includes/galette.inc.php';
if (!$login->isLogged()) {
    header("location: index.php");
    die;
}
if (!$login->isAdmin() && !$login->isStaff()) {
    header("location: voir_adherent.php");
    die;
}
if (!isset($_GET['id_cotis'])) {
    throw new \RuntimeException('Contribution id is mandatory.');
}
$contribution = new Contribution((int) $_GET['id_cotis']);
$pdf = new PdfContribution($contribution, $zdb, $preferences);
$pdf->download();