voucherserie_export.php

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

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5