Merge pull request #5076 from colemanw/Attachment
[civicrm-core.git] / CRM / Financial / BAO / ExportFormat / CSV.php
index 3c871ba52beda566400acf4558fe08e29998666e..88bd60d6f102ee432221d5f172a17aac42983c21 100644 (file)
@@ -1,8 +1,7 @@
 <?php
-
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
@@ -24,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
  *
  */
 
-/*
- * @see http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
+/**
+ * @link http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
  */
-
 class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat {
 
   // For this phase, we always output these records too so that there isn't data referenced in the journal entries that isn't defined anywhere.
@@ -48,22 +46,22 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
   );
 
   /**
-   * class constructor
+   * Class constructor
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
   }
 
   /**
-   * @param $exportParams
+   * @param array $exportParams
    */
-  function export($exportParams) {
+  public function export($exportParams) {
     $export = parent::export($exportParams);
 
     // Save the file in the public directory
     $fileName = self::putFile($export);
 
-    foreach ( self::$complementaryTables as $rct ) {
+    foreach (self::$complementaryTables as $rct) {
       $func = "export{$rct}";
       $this->$func();
     }
@@ -75,11 +73,11 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
   }
 
   /**
-   * @param $batchId
+   * @param int $batchId
    *
    * @return Object
    */
-  function generateExportQuery($batchId) {
+  public function generateExportQuery($batchId) {
     $sql = "SELECT
       ft.id as financial_trxn_id,
       ft.trxn_date,
@@ -122,7 +120,7 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
       WHERE eb.batch_id = ( %1 )";
 
     $params = array(1 => array($batchId, 'String'));
-    $dao = CRM_Core_DAO::executeQuery( $sql, $params );
+    $dao = CRM_Core_DAO::executeQuery($sql, $params);
 
     return $dao;
   }
@@ -132,10 +130,10 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
    *
    * @return string
    */
-  function putFile($export) {
+  public function putFile($export) {
     $config = CRM_Core_Config::singleton();
-    $fileName = $config->uploadDir.'Financial_Transactions_'.$this->_batchIds.'_'.date('YmdHis').'.'.$this->getFileExtension();
-    $this->_downloadFile[] = $config->customFileUploadDir.CRM_Utils_File::cleanFileName(basename($fileName));
+    $fileName = $config->uploadDir . 'Financial_Transactions_' . $this->_batchIds . '_' . date('YmdHis') . '.' . $this->getFileExtension();
+    $this->_downloadFile[] = $config->customFileUploadDir . CRM_Utils_File::cleanFileName(basename($fileName));
     $out = fopen($fileName, 'w');
     fputcsv($out, $export['headers']);
     unset($export['headers']);
@@ -154,7 +152,7 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
    * @param array $values
    * @return array
    */
-  function formatHeaders($values) {
+  public function formatHeaders($values) {
     $arrayKeys = array_keys($values);
     $headers = '';
     if (!empty($arrayKeys)) {
@@ -169,15 +167,13 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
    * Generate CSV array for export
    *
    * @param array $export
-   *
    */
-  function makeCSV($export) {
+  public function makeCSV($export) {
     foreach ($export as $batchId => $dao) {
       $financialItems = array();
       $this->_batchIds = $batchId;
       while ($dao->fetch()) {
-        $creditAccountName = $creditAccountType =
-          $creditAccount = NULL;
+        $creditAccountName = $creditAccountType = $creditAccount = NULL;
         if ($dao->credit_account) {
           $creditAccountName = $dao->credit_account_name;
           $creditAccountType = $dao->credit_account_type_code;
@@ -219,16 +215,17 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat
   /**
    * @return string
    */
-  function getFileExtension() {
+  public function getFileExtension() {
     return 'csv';
   }
 
-  function exportACCNT() {
+  public function exportACCNT() {
   }
 
-  function exportCUST() {
+  public function exportCUST() {
   }
 
-  function exportTRANS() {
+  public function exportTRANS() {
   }
+
 }