/**
  * Export function:
  * - Returns false, if an error occured or if there are no orders to export
  * - Returns array, containing the filename and the file contents
  *
  * @return bool|array
  */
 public function export()
 {
     $collection = $this->_hasOrdersToExport();
     if (!$collection) {
         return false;
     }
     // Create new object and set store owner bank account data
     $file = new DTA(DTA_DEBIT);
     $file->setAccountFileSender($this->_getDebitHelper()->getBankAccount());
     // Add orders
     foreach ($collection as $order) {
         /* @var $orderModel Mage_Sales_Model_Order */
         $orderModel = Mage::getModel('sales/order')->load($order->getData('entity_id'));
         /* @var $payment Itabs_Debit_Model_Debit */
         $paymentMethod = $orderModel->getPayment()->getMethodInstance();
         $file->addExchange(array('name' => $paymentMethod->getAccountName(), 'bank_code' => $paymentMethod->getAccountBLZ(), 'account_number' => $paymentMethod->getAccountNumber()), round($order->getData('grand_total'), 2), array('Bestellung Nr. ' . $order->getData('increment_id')));
         $this->_getDebitHelper()->setStatusAsExported($order->getId());
     }
     $response = array('file_name' => $this->getFileName(), 'file_content' => $file->getFileContent());
     return $response;
 }
/**
 * Example how to use the meta data to create a "Begleitzettel",
 * a document to accompany and summarize a DTA disk.
 *
 * PHP version 4 and 5
 *
 * @category  Payment
 * @package   Payment_DTA
 * @author    Martin Schütte <*****@*****.**>
 * @copyright 2009 Martin Schütte
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
 * @version   SVN: $Id: example_begleitzettel.php 316502 2011-09-11 19:51:04Z mschuett $
 * @link      http://pear.php.net/package/Payment_DTA
 */
require_once 'Payment_DTA/DTA.php';
$dtaus = new DTA(DTA_CREDIT);
$DTA_test_account = array('name' => "Michael Mustermann", 'bank_code' => "16050000", 'account_number' => "3503007767");
$dtaus->setAccountFileSender($DTA_test_account);
$dtaus->addExchange(array('name' => "Emil Empfänger", 'bank_code' => "16050000", 'account_number' => "3503007767"), (double) 123.45, "Ein Verwendungszweck");
/*
 * some more transactions ...
 *
 * $dtaus->saveFile($filename)
 *
 */
$meta = $dtaus->getMetaData();
?>
<!doctype html>
<head>
    <title>Example DTA Begleitzettel</title>
</head>
 private function admin_createDta($dtaRequests)
 {
     $dtaFile = new DTA(DTA_DEBIT);
     $dtaFile->setAccountFileSender(array('name' => 'Ringelsoeckchen e.V.', 'bank_code' => 37050299, 'account_number' => 138274368));
     $this->Fee->Member->recursive = -1;
     foreach ($dtaRequests as $dtaRequest) {
         //Get member information
         $member = $this->Fee->Member->find('first', array('conditions' => array('id' => $dtaRequest['member_id'])));
         //Get yearly fee information
         $yearly_fee = $this->Fee->YearlyFee->find('first', array('conditions' => array('year' => $dtaRequest['year'])));
         $dtaFile->addExchange(array('name' => $member['Member']['account_holder'], 'bank_code' => $member['Member']['bank_code'], 'account_number' => $member['Member']['account_number']), $yearly_fee['YearlyFee']['fee'], array('Ringelsoeckche Beitrag ' . $dtaRequest['year'], $member['Member']['full_name']));
     }
     $dtaFile->saveFile(TMP . 'dta.dta');
     $this->viewClass = 'Media';
     $params = array('id' => 'dta.dta', 'name' => 'Mitgliedsbeitraege' . CakeTime::format('Y-m-d', time()), 'download' => true, 'extension' => 'dta', 'path' => TMP);
     $this->set($params);
 }
 * @category  Payment
 * @package   Payment_DTA
 * @author    Hermann Stainer <*****@*****.**>
 * @copyright 2003-2005 Hermann Stainer, Web-Gear
 * @license   http://www.debian.org/misc/bsd.license  BSD License (3 Clause)
 * @version   SVN: $Id: example_credit.php 300643 2010-06-22 00:21:19Z mschuett $
 * @link      http://pear.php.net/package/Payment_DTA
 */
require_once "Payment/DTA.php";
/**
* Initialize new DTA file.
* In this example the file contains credits.
* This means that in an exchange the sender is the person who pays money
* to the receiver.
*/
$dta_file = new DTA(DTA_CREDIT);
/**
* Set file sender. This is also the default sender for transactions.
*/
$dta_file->setAccountFileSender(array("name" => "Michael Mustermann", "bank_code" => 11112222, "account_number" => 654321));
/**
* Add transaction.
*/
$dta_file->addExchange(array("name" => "Franz Mueller", "bank_code" => 33334444, "account_number" => 13579000), 12.01, array("Credit Nr. 01234", "Information"));
/**
* Output DTA-File.
*/
echo $dta_file->getFileContent();
/**
* Write DTA-File.
*/
Exemple #5
0
 public function directDebit($paymentTypeKeys, $filters)
 {
     $db = Tinebase_Core::getDb();
     $tm = Tinebase_TransactionManager::getInstance();
     try {
         require_once 'Payment/DTA.php';
         if (!is_array($filters)) {
             $filters = Zend_Json::decode($filters);
         }
         if (!is_array($paymentTypeKeys)) {
             $paymentTypeKeys = Zend_Json::decode($paymentTypeKeys);
         }
         $filters[] = array('field' => 'banking_exp_date', 'operator' => 'isnull', 'value' => '');
         $rawFilters = $filters;
         $paymentTypeCount = count($paymentTypeKeys);
         $filters[] = array('field' => 'payment_method_id', 'operator' => 'equals', 'value' => $paymentTypeKeys[1]);
         $filter1 = new Billing_Model_OpenItemFilter($filters, 'AND');
         $filter = new Tinebase_Model_Filter_FilterGroup(array(), 'OR');
         $filter->addFilterGroup($filter1);
         if ($paymentTypeCount > 1) {
             unset($paymentTypeKeys[1]);
             foreach ($paymentTypeKeys as $paymentTypeKey) {
                 $newFilters = $rawFilters;
                 $newFilters[] = array('field' => 'payment_method_id', 'operator' => 'equals', 'value' => $paymentTypeKey);
                 $pFilterGroup = new Billing_Model_OpenItemFilter($newFilters, 'AND');
                 $filter->addFilterGroup($pFilterGroup);
             }
         }
         // start transaction
         $tId = $tm->startTransaction($db);
         // count membership matching filters
         $openItemIds = $this->search($filter, new Tinebase_Model_Pagination(array('sort' => 'due_date', 'dir' => 'ASC')), false, true);
         $tempFilePath = CSopen::instance()->getCustomerPath() . '/customize/data/documents/temp/';
         $mandators = \Tinebase_Config::getInstance()->getConfig('mandators', NULL, TRUE)->value;
         $mandator = $mandators[1]['bankdata'];
         $hash = md5(serialize($mandator) . microtime());
         $dtaFile = new DTA(DTA_DEBIT);
         $dtaFile->setAccountFileSender(array("name" => $mandator['account_holder'], "bank_code" => $mandator['bank_code'], "account_number" => $mandator['account_number']));
         // 		create DTA file
         foreach ($openItemIds as $openItemId) {
             $openItem = $this->get($openItemId);
             // value
             $val = (double) $openItem->__get('open_sum');
             $usage = $openItem->__get('usage');
             $u = explode(',', $usage);
             $u1 = $u2 = '';
             if (count($u) > 0) {
                 $u1 = $u[0];
                 $u2 = $u[1];
             } else {
                 $u1 = $usage;
             }
             if ($val > 0) {
                 $debitor = $openItem->getForeignRecordBreakNull('debitor_id', Billing_Controller_Debitor::getInstance());
                 if (!$debitor) {
                     continue;
                 }
                 $contact = $debitor->getForeignRecordBreakNull('contact_id', Addressbook_Controller_Contact::getInstance());
                 if (!$contact) {
                     continue;
                 }
                 $receipt = $openItem->getForeignRecordBreakNull('receipt_id', Billing_Controller_Receipt::getInstance());
                 $dtaFile->addExchange(array("name" => $contact->__get('bank_account_name'), "bank_code" => $contact->__get('bank_code'), "account_number" => $contact->__get('bank_account_number')), (string) $val, array($u1, $u2));
             }
             $openItem->__set('banking_exp_date', new Zend_Date());
             $this->update($openItem);
         }
         $dtaFile->saveFile($tempFilePath . 'DTAUS0' . $hash);
         $meta = $dtaFile->getMetaData();
         $date = strftime("%d.%m.%y", $meta["date"]);
         $execDate = strftime("%d.%m.%y", $meta["exec_date"]);
         $count = $meta["count"];
         $sumEUR = $meta["sum_amounts"];
         $sumKto = $meta["sum_accounts"];
         $sumBankCodes = $meta["sum_bankcodes"];
         $sender = $mandator['account_holder'];
         $senderBank = $mandator['bank'];
         $senderBankCode = $mandator['bank_code'];
         $senderAccount = $mandator['account_number'];
         $handoutContent = "Datenträger-Begleitzettel\n\tErstellungsdatum: {$date} \n\tAusführungsdatum: {$execDate}\n\tAnzahl der Lastschriften: {$count}\n\tSumme der Beträge in EUR: {$sumEUR}\n\tKontrollsumme Kontonummern: {$sumKto}\n\tKontrollsumme Bankleitzahlen: {$sumBankCodes}\n\tAuftraggeber: {$sender}\n\tBeauftragtes Bankinstitut: {$senderBank}\n\tBankleitzahl: {$senderBankCode}\n\tKontonummer: {$senderAccount}";
         $zip = new ZipArchive();
         $filename = "{$tempFilePath}/DTAUS0-{$ogNr}.zip";
         if ($zip->open($filename, ZIPARCHIVE::CREATE) !== TRUE) {
             exit("cannot open <{$filename}>\n");
         }
         $zip->addFromString("begleitzettel.txt", $handoutContent);
         $zip->addFile($tempFilePath . 'DTAUS0' . $hash, 'DTAUS0');
         $zip->close();
         header("Content-type: application/zip;\n");
         header("Content-Transfer-Encoding: binary");
         $len = filesize($filename);
         header("Content-Length: {$len};\n");
         $outname = "DTAUS0-{$ogNr}.zip";
         header("Content-Disposition: attachment; filename=\"{$outname}\";\n\n");
         readfile($filename);
         unlink($filename);
         $tm->commitTransaction($tId);
     } catch (Exception $e) {
         $tm->rollback($tId);
     }
 }
Exemple #6
0
    </form>
    <?php 
} else {
    $dtafilestring = isset($dtafilestring) ? $dtafilestring : file_get_contents($_FILES["userfile"]["tmp_name"]);
    if (!$dtafilestring) {
        print "<p class='status'>Fehler: Kann DTA-Datei nicht lesen...</p>" . "</body></html>";
        die;
    }
    switch (get_format($dtafilestring)) {
        case "DTAZV":
            print "<p class='status'>Lese DTAZV-Datei ...</p>";
            $dta = new DTAZV($dtafilestring);
            break;
        case "DTA":
            print "<p class='status'>Lese DTA-Datei ...</p>";
            $dta = new DTA($dtafilestring);
            break;
        default:
            print "<p class='error'>Datei nicht in DTA oder DTAZV-Format ...</p></body></html>";
            die;
    }
    $errors = $dta->getParsingErrors();
    if (count($errors)) {
        print "<h2>Fehler</h2>";
        print "<ol>";
        foreach ($errors as $e) {
            if (get_class($e) == "Payment_DTA_FatalParseException") {
                print "<li class='status error'>Schwerer Fehler: " . $e->getMessage() . "</li></ol></body></html>";
                die;
            } elseif (get_class($e) == "Payment_DTA_ParseException") {
                print "<li class='status error'>Fehler: " . $e->getMessage() . "<br/>Ursache: " . $e->getCause()->getMessage() . "</li>";