voucherserie_export.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class VoucherSerie_Export extends oxAdminDetails
00009 {
00016     public function render()
00017     {
00018         parent::render();
00019 
00020         $sFilepath = oxConfig::getParameter( "filepath" );
00021         if ( !isset( $sFilepath)) {
00022             $sFilepath = getShopBasePath();
00023             $sFilepath.= "export/oxexport.csv";
00024         }
00025 
00026         $this->_aViewData["filepath"] =  $sFilepath;
00027         return "voucherserie_export.tpl";
00028     }
00029 
00035     public function export()
00036     {
00037         $sFilepath = oxConfig::getParameter( "filepath");
00038         oxSession::setVar( "filepath", $sFilepath);
00039 
00040         $oSerie = oxNew( "oxvoucherserie" );
00041         $oSerie->load(oxConfig::getParameter("oxid"));
00042 
00043         $oDB = oxDb::getDb();
00044 
00045         $sSelect = "select oxvouchernr from oxvouchers where oxvoucherserieid = '" . $oSerie->oxvoucherseries__oxid->value . "'";
00046         $rs = $oDB->execute($sSelect);
00047         // if first, delete the file
00048         $fp = @fopen( $sFilepath, "w");
00049         if ( $fp) {
00050              fputs( $fp, "Gutschein\n");
00051             while (!$rs->EOF) {
00052 
00053                 $sLine = "";
00054 
00055                 foreach ( $rs->fields as $field)
00056                     $sLine .= $field/*.$myConfig->sCSVSign*/;
00057                 $sLine .= "\n";
00058 
00059                 fputs( $fp, $sLine);
00060 
00061                 $rs->moveNext();
00062             }
00063             fclose( $fp);
00064             $this->_aViewData["exportCompleted"] = true;
00065         } else
00066             $this->_aViewData["exportCompleted"] =false;
00067     }
00068 }

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5