<?php
/**
 * @copyright ONE/DEPO Project
 * @license   PHP License 3.01 <http://www.php.net/license/3_01.txt>
 */

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * 出荷指示済更新＆CSVデータ出力
 *
 * @package     Admin_Ordermanage_Instruction_Export
 * @author      netnee <mail@example.com>
 * @access      public
 */
class Admin_Ordermanage_Instruction_Export_Out
{
    /**
     * execute
     *
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Admin_Ordermanage_Instruction_Export_Outが実行されました", "Admin_Ordermanage_Instruction_Export_Out#execute");
        
        
        $this->exportCSV();
        
        return 'success';
    }
    
    function exportCSV()
    {
        $filepathname = DATAEXPORT_DL_DIR . "/instruction-list.csv";
        $filename = "instruction-list.csv";
        
        $len = filesize($filepathname);
        header("Cache-Control: public");
        header("Pragma: public");
        header ("Content-Disposition: inline ; filename=$filename");
        header ("Content-type: text/octet-stream");
        header ("Content-Length: ". $len);
        $handle = fopen ($filepathname, "r");
        while (!feof ($handle)) {
            $buffer = fgets($handle, 4096);
            $buffer = mb_convert_encoding($buffer, "SJIS","UTF-8");
            echo $buffer;
        }
        fclose ($handle);

        return TRUE;
    }
}
?>
