function renderHtml() { $betaling = new VIH_Model_Betaling($this->context->name()); $onlinebetaling = new VIH_Onlinebetaling('capture'); $eval = $onlinebetaling->capture($betaling->get('transactionnumber'), (int) $betaling->get('amount') * 100); if ($eval) { if (!empty($eval['qpstat']) and $eval['qpstat'] === '000') { if ($betaling->setStatus('approved')) { $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id')); $historik->save(array('type' => 'dankort', 'comment' => 'Capture transaktion #' . $betaling->get('transactionnumber'))); } return new k_SeeOther($this->context->url('../')); } else { // An error occured with the capture // Dumping return data for debugging /* echo "<pre>"; var_dump($eval); echo "</pre>"; */ $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id')); $historik->save(array('type' => 'dankort', 'comment' => 'Fejl ved capture af transaktion #' . $betaling->get('transactionnumber'))); throw new Exception('Betalingen kunne ikke hæves, formentlig fordi den er ugyldig'); } } else { throw new Exception('Der var en kommunikationsfejl med Onlinebetalingen'); } return 'error'; }
function postForm() { $tilmelding = new VIH_Model_KortKursus_Tilmelding($this->context->name()); $allowed_brev_type = array('' => '_fejl_', 'rykker.php' => 'rykker', 'depositumrykker.php' => 'depositumrykker', 'depositum.php' => 'depositum', 'bekraeftelse.php' => 'bekraeftelse', 'depositumbekraeftelse.php' => 'depositumbekraeftelse'); $brev_type = $this->body('type'); $brev_type_key = array_search($brev_type, $allowed_brev_type); if ($brev_type_key === false) { throw new Exception("Ugyldig brev type"); } include dirname(__FILE__) . '/breve/' . $brev_type_key; if ($this->body('send_email')) { $mail = new VIH_Email(); $mail->setSubject(ucfirst($brev_type) . " fra Vejle Idrætshøjskole"); $mail->setBody($brev_tekst); $mail->addAddress($tilmelding->get('email'), $tilmelding->get('navn')); if (!$mail->send()) { throw new Exception("Email blev ikke sendt. Der opstod en fejl. Du kan forsøge igen eller kontakte ham den dovne webmaster"); } $historik = new VIH_Model_Historik('kortekurser', $tilmelding->get("id")); $historik->save(array('type' => $brev_type, 'comment' => "Sendt via e-mail")); return new k_SeeOther($this->context->url()); } elseif ($this->body('send_pdf')) { $historik = new VIH_Model_Historik('kortekurser', $tilmelding->get("id")); $historik->save(array('type' => $brev_type, 'comment' => "Sendt via post")); return new k_SeeOther($this->url(null . '.pdf', array('type' => $brev_type))); } return $this->render(); }
function postForm() { $tilmelding = $this->getTilmelding(); if ($this->getForm()->validate()) { // confirm skal gemme en oplysning om, at kunden har konfirmeret betingelserne if ($this->body('confirm')) { if (!$tilmelding->confirm()) { throw new Exception('Kunne ikke bekræfte ordre ' . $tilmelding->get('id')); } if ($tilmelding->get('email')) { $historik = new VIH_Model_Historik('kortekurser', $tilmelding->get('id')); if (!$tilmelding->sendEmail()) { if (!$historik->save(array('type' => 'kode', 'comment' => 'Bekræftelse på onlinetilmelding kunne ikke sendes'))) { throw new Exception('Historikken kunne ikke gemmes'); } } else { if (!$historik->save(array('type' => 'kode', 'comment' => 'Bekræftelse på onlinetilmelding'))) { throw new Exception('Historikken kunne ikke gemmes'); } } } return new k_SeeOther($this->context->url('kvittering')); } else { throw new Exception('Ordren skal godkendes'); } } return $this->render(); }
public function postForm() { $tilmelding = new VIH_Model_LangtKursus_OnlineTilmelding($this->context->name()); if ($this->getForm()->validate()) { if (!$tilmelding->setStatus('tilmeldt')) { throw new Exception('Status kunne ikke sættes'); } if ($this->body('confirm')) { if (!$tilmelding->confirm()) { throw new Exception('Tilmelding ' . $tilmelding->getId() . ' kunne ikke bekr�ftes'); } if ($tilmelding->get('email')) { $historik = new VIH_Model_Historik('langekurser', $tilmelding->get('id')); if (!$tilmelding->sendEmail()) { if (!$historik->save(array('type' => 'kode', 'comment' => 'Bekræftelse på onlinetilmelding kunne ikke sendes'))) { throw new Exception('Historikken kunne ikke gemmes'); } throw new Exception('E-mailen kunne ikke sendes til ordre ' . $tilmelding->getId()); } else { if (!$historik->save(array('type' => 'kode', 'comment' => 'Bekræftelse på onlinetilmelding'))) { throw new Exception('Historikken kunne ikke gemmes'); } } } return new k_SeeOther($this->context->url('kvittering')); } } else { return $this->getForm()->toHTML(); } return $this->render(); }
function postForm() { $tilmelding = new VIH_Model_LangtKursus_Tilmelding($this->context->name()); $tilmelding->loadBetaling(); $historik = new VIH_Model_Historik('langekurser', $tilmelding->get("id")); $historik->save(array('type' => 'betalingsopgørelse', 'comment' => "Sendt via post")); return new k_SeeOther($this->url(null) . '.pdf'); }
function renderHtml() { $tilmelding = new VIH_Model_KortKursus_Tilmelding($this->name()); if (is_numeric($this->query('sletdeltager'))) { $deltager = new VIH_Model_KortKursus_Tilmelding_Deltager($tilmelding, $this->query('sletdeltager')); $deltager->delete(); } elseif ($this->query('action') == 'sendemail') { if ($tilmelding->sendEmail()) { $historik = new VIH_Model_Historik('kortekurser', $tilmelding->get('id')); if (!$historik->save(array('type' => 'kode', 'comment' => 'Kode sendt med e-mail'))) { throw new Exception('Historikken kunne ikke gemmes'); } } else { throw new Exception('E-mailen kunne ikke sendes'); } } if ($this->query('slet_historik_id')) { $historik = new VIH_Model_Historik(intval($this->query('slet_historik_id'))); $historik->delete(); } $deltagere = $tilmelding->getDeltagere(); $historik_object = new VIH_Model_Historik('kortekurser', $tilmelding->get("id")); $betalinger = new VIH_Model_Betaling('kortekurser', $tilmelding->get("id")); if ($this->query('registrer_betaling')) { if ($betalinger->save(array('type' => 'giro', 'amount' => $this->query('beloeb')))) { $betalinger->setStatus('approved'); return new k_SeeOther($this->url()); } else { throw new Exception("Betalingen kunne ikke gemmes. Det kan skyldes et ugyldigt beløb"); } } $tilmelding->loadBetaling(); $this->document->setTitle('Tilmelding #' . $tilmelding->getId()); $this->document->addOption('Tilbage til liste', $this->url('../')); $this->document->addOption('Ret', $this->url('edit')); $this->document->addOption('Slet', $this->url(null, array('delete'))); if ($tilmelding->get('email')) { $this->document->addOption('E-mail', $this->url('email')); } $this->document->addOption('Kundens side', KORTEKURSER_LOGIN_URI . $tilmelding->get('code')); $data = array('deltagere' => $deltagere, 'indkvartering' => !$tilmelding->kursus->isFamilyCourse(), 'type' => $tilmelding->get('keywords'), 'vis_slet' => 'ja'); $historik = array('historik' => $historik_object->getList(), 'tilmelding' => $tilmelding); $historik_tpl = $this->templates->create('tilmelding/historik'); $betaling_data = array('caption' => 'Afventende betalinger', 'betalinger' => $betalinger->getList('not_approved'), 'msg_ingen', 'Der er ingen afventende betalinger.'); $prisoversigt_data = array('tilmelding' => $tilmelding); $prisoversigt_tpl = $this->templates->create('kortekurser/tilmelding/prisoversigt'); $deltager_tpl = $this->templates->create('kortekurser/deltagere'); $betaling_tpl = $this->templates->create('tilmelding/betalinger'); $tilmelding = array('tilmelding' => $tilmelding, 'historik_object' => $historik_object, 'deltagere' => $deltager_tpl->render($this, $data), 'status' => $tilmelding->get('status'), 'prisoversigt' => $prisoversigt_tpl->render($this, $prisoversigt_data), 'historik' => $historik_tpl->render($this, $historik), 'betalinger' => $betaling_tpl->render($this, $betaling_data)); $tpl = $this->templates->create('kortekurser/tilmelding'); return $tpl->render($this, $tilmelding); }
function postForm() { $tilmelding = VIH_Model_LangtKursus_Tilmelding::factory($this->context->name()); $tilmelding->loadBetaling(); if ($this->getForm()->validate()) { // create a payment which functions as an third party id at quickpay // payment is coupled with the current registration // after pbs update the status of the payment // set status to 000 if captured at PBS $eval = false; $betaling = $tilmelding->betalingFactory(); $submitted_amount = $this->body('amount'); if (is_array($submitted_amount)) { $amount = 0; foreach ($submitted_amount as $amount) { $total_amount += $amount; } } elseif (is_numeric($submitted_amount)) { $total_amount = $submitted_amount; } else { throw new Exception('De postede beløbsværdier er ikke gyldige'); } $betaling_amount = $total_amount / 100; $betaling_id = $betaling->save(array('type' => 'quickpay', 'amount' => $betaling_amount)); if ($betaling_id == 0) { throw new Exception("Kunne ikke oprette betaling"); } $onlinebetaling = new VIH_Onlinebetaling('authorize'); $onlinebetaling->addCustomVar("Kursusnavn", "Langtkursus: " . $tilmelding->kursus->get("kursusnavn")); $onlinebetaling->addCustomVar("Navn", $tilmelding->get("navn")); $onlinebetaling->addCustomVar("Tilmelding_ID", $tilmelding->get("id")); $eval = $onlinebetaling->authorize($this->body('cardnumber'), $this->body('yy') . $this->body('mm'), $this->body('cvd'), $betaling_id, $total_amount); if ($eval) { if ($eval['qpstat'] === '000') { $betaling->setTransactionnumber($eval['transaction']); $betaling->setStatus('completed'); $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id')); if (!$historik->save(array('betaling_id' => $betaling->get('id'), 'type' => 'dankort', 'comment' => 'Onlinebetaling # ' . $betaling->get('transactionnumber')))) { throw new Exception('Der var en fejl med at gemme historikken.'); } return new k_SeeOther($this->context->url()); } else { // An error occured with the authorize $this->extra_text .= "<p><strong>Der opstod en fejl under transaktionen. " . $onlinebetaling->statuskoder[$eval['qpstat']] . ". Du kan prøve igen.</strong></p>"; } } else { throw new Exception('Kommunikationsfejl med PBS og QuickPay'); } } return $this->render(); }
/** * NOTICE: First we need to make a local payment, so we have a * local id to use for capture at quickpay. * When the payment has been captured we set status = 000 */ function postForm() { $tilmelding = VIH_Model_KortKursus_Tilmelding::factory($this->context->name()); if ($this->getForm()->validate()) { $eval = false; $betaling = new VIH_Model_Betaling("kortekurser", $tilmelding->get("id")); $betaling_amount = $this->body('amount') / 100; $betaling_id = $betaling->save(array('type' => 'quickpay', 'amount' => $betaling_amount)); if ($betaling_id == 0) { throw new Exception("Kunne ikke oprette betaling"); } $onlinebetaling = new VIH_Onlinebetaling('authorize'); $onlinebetaling->addCustomVar("Kursusnavn", "Kortkursus: " . $tilmelding->kursus->getKursusNavn()); $onlinebetaling->addCustomVar("Kontaktnavn", $tilmelding->get("navn")); $onlinebetaling->addCustomVar("Tilmelding_ID", $tilmelding->get("id")); $eval = $onlinebetaling->authorize($this->body('cardnumber'), $this->body('yy') . $this->body('mm'), $this->body('cvd'), $betaling_id, $this->body('amount')); if ($eval) { if ($eval['qpstat'] === '000') { // The authorization was completed $betaling->setTransactionnumber($eval['transaction']); $betaling->setStatus('completed'); $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id')); if (!$historik->save(array('betaling_id' => $betaling->get('id'), 'type' => 'dankort', 'comment' => 'Onlinebetaling # ' . $betaling->get('transactionnumber')))) { throw new Exception('Der var en fejl med at gemme historikken.'); } return new k_SeeOther($this->context->url()); } else { // An error occured with the authorize $this->extra_text = '<p class="warning">Der opstod en fejl under transaktionen. ' . $onlinebetaling->statuskoder[$eval['qpstat']] . '. Du kan prøve igen.</p>'; } } else { $this->extra_text = 'Kommunikationsfejl med PBS eller QuickPay'; } } return $this->render(); }
$onlinebetaling = new VIH_Onlinebetaling('authorize'); $onlinebetaling->addCustomVar('Elevforeningsmedlem', $contact['number']); $onlinebetaling->addCustomVar('Kontaktid', $contact['id']); $eval = $onlinebetaling->authorize($form->exportValue('cardnumber'), $form->exportValue('yy') . $form->exportValue('mm'), $form->exportValue('cvd'), $betaling_id, $betaling_amount_quickpay); if ($eval) { if ($eval['qpstat'] === '000') { // The authorization was completed /* echo 'Authorization: ' . $qpstatText["" . $eval['qpstat'] . ""] . '<br />'; echo "<pre>"; var_dump($eval); echo "</pre>"; */ $betaling->setTransactionnumber($eval['transaction']); $betaling->setStatus('completed'); $historik = new VIH_Model_Historik($betaling->get('belong_to'), $betaling->get('belong_to_id')); if (!$historik->save(array('type' => 'dankort', 'comment' => 'Onlinebetaling # ' . $betaling->get('transactionnumber')))) { trigger_error('Der var en fejl med at gemme historikken.', E_USER_ERROR); } $data = array('belong_to' => 'order', 'belong_to_id' => $order_id, 'transaction_number' => $eval['transaction'], 'transaction_status' => $eval['qpstat'], 'pbs_status' => $eval['pbsstat'], 'amount' => $betaling_amount); $client->saveOnlinePayment($data); //$client->addOnlinePayment($order_id, $eval['transaction'], $eval['qpstat'], $betaling_amount); header("Location: index.php"); exit; } else { // An error occured with the authorize $error = '<p class="warning">Der opstod en fejl under transaktionen. ' . $onlinebetaling->statuskoder[$eval['qpstat']] . '. Du kan prøve igen.</p>'; /* echo 'Authorization: ' . $qpstatText["" . $eval['qpstat'] . ""] . '<br />'; echo "<pre>"; var_dump($eval);
function renderHtml() { $tilmelding = $this->getTilmelding(); if ($this->query('get_prices')) { if (!$tilmelding->getPriserFromKursus()) { throw new Exception('Priser kunne ikke hentes'); } else { return new k_SeeOther($this->url()); } } $historik = new VIH_Model_Historik('langekurser', $tilmelding->get("id")); $betalinger = new VIH_Model_Betaling('langekurser', $tilmelding->get("id")); $rater = $tilmelding->getRater(); if ($this->query('action') == 'sendemail') { if ($tilmelding->sendEmail()) { if (!$historik->save(array('type' => 'kode', 'comment' => 'Kode sendt med e-mail'))) { throw new Exception('Historikken kunne ikke gemmes'); } } else { throw new Exception('E-mailen kunne ikke sendes'); } } elseif ($this->query('action') == 'opretrater') { if (!$tilmelding->opretRater()) { throw new Exception('Raterne kunne ikke oprettes'); } else { return new k_SeeOther($this->url()); } } elseif ($this->query('registrer_betaling')) { if ($betalinger->save(array('type' => 'giro', 'amount' => $this->query('beloeb')))) { $betalinger->setStatus('approved'); } else { throw new Exception("Betalingen kunne ikke gemmes. Det kan skyldes et ugyldigt beløb"); } } elseif ($this->query('slet_historik_id')) { $historik = new VIH_Model_Historik(intval($this->query('slet_historik_id'))); $historik->delete(); } $tilmelding->loadBetaling(); $this->document->setTitle('Tilmelding #' . $tilmelding->get('id')); $this->document->addOption('Til kursus', $this->url('../../' . $tilmelding->kursus->get('id'))); $this->document->addOption('Tilmeldinger', $this->url('../../' . $tilmelding->kursus->get('id') . '/tilmeldinger')); $this->document->addOption('Ret', $this->url(null, array('edit'))); $this->document->addOption('Delete', $this->url(null, array('delete'))); $this->document->addOption('Protokol', $this->url('../../../protokol/holdliste/' . $tilmelding->get('id'))); $this->document->addOption('Brev', $this->url('brev')); $this->document->addOption('F*g', $this->url('f*g')); $this->document->addOption('Diplom', $this->url('diplom')); $this->document->addOption('Kundens side', LANGEKURSER_LOGIN_URI . $tilmelding->get('code')); $opl_data = array('tilmelding' => $tilmelding); $pris_data = array('tilmelding' => $tilmelding); $betal_data = array('betalinger' => $betalinger->getList('not_approved'), 'caption' => 'Betalinger'); $hist_data = array('tilmelding' => $tilmelding, 'historik' => $historik->getList()); $opl_tpl = $this->templates->create('langekurser/tilmelding/oplysninger'); $pris_tpl = $this->templates->create('langekurser/tilmelding/prisoversigt'); $betal_tpl = $this->templates->create('tilmelding/betalinger'); $his_tpl = $this->templates->create('tilmelding/historik'); $data = array('tilmelding' => $tilmelding, 'oplysninger' => $opl_tpl->render($this, $opl_data), 'prisoversigt' => $pris_tpl->render($this, $pris_data), 'betalinger' => $betal_tpl->render($this, $betal_data), 'historik' => $his_tpl->render($this, $hist_data)); // rater if (count($rater) > 0) { $rater_tpl = $this->templates->create('langekurser/tilmelding/rater'); $rater_data = array('tilmelding' => $tilmelding); $data['rater'] = $rater_tpl->render($this, $rater_data); } else { if ($tilmelding->kursus->antalRater() > 0) { $data['rater'] = '<p><a href="' . $this->url(null, array('get_prices' => $tilmelding->get('id'))) . '">Hent priserne fra kurset</a>. Der er endnu ikke oprettet nogen rater <a href="' . $this->url(null, array('action' => 'opretrater')) . '">Opret →</a></p>'; } else { $data['rater'] = '<p>Der er endnu ikke oprettet rater på selve kurset. Dem skal du lige oprette først <a href="' . $this->url('../../' . $tilmelding->getKursus()->get('id') . '/rater') . '">Opret →</a></p>'; } } $data['message'] = ''; $tpl = $this->templates->create('langekurser/tilmelding'); return $tpl->render($this, $data); }