Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2014-12-09-14-48-51
[civicrm-core.git] / CRM / Financial / BAO / ExportFormat.php
index f91d1f2c7a7f35cbbf02dc4e5de1e35b8c63d181..d804265e4fa59ef3080100edb1b04b8c41cff151 100644 (file)
@@ -52,7 +52,7 @@ class CRM_Financial_BAO_ExportFormat {
   static protected $_template;
 
   /**
-   * class constructor
+   * Class constructor
    */
   function __construct() {
     if ( !isset( self::$_template ) ) {
@@ -61,11 +61,19 @@ class CRM_Financial_BAO_ExportFormat {
   }
 
   // Override to assemble the appropriate subset of financial data for the specific export format
+  /**
+   * @param array $exportParams
+   *
+   * @return mixed
+   */
   function export($exportParams) {
     $this->_exportParams = $exportParams;
     return $exportParams;
   }
 
+  /**
+   * @param null $fileName
+   */
   function output($fileName = NULL) {
     switch ($this->getFileExtension()) {
       case 'csv':
@@ -81,23 +89,39 @@ class CRM_Financial_BAO_ExportFormat {
     }
   }
 
+  /**
+   * @return string
+   */
   function getMimeType() {
     return 'text/plain';
   }
 
+  /**
+   * @return string
+   */
   function getFileExtension() {
     return 'txt';
   }
 
   // Override this if appropriate
+  /**
+   * @return null
+   */
   function getTemplateFileName() {
     return null;
   }
 
+  /**
+   * @return object
+   */
   static function &getTemplate() {
     return self::$_template;
   }
 
+  /**
+   * @param $var
+   * @param null $value
+   */
   function assign($var, $value = NULL) {
     self::$_template->assign($var, $value);
   }
@@ -108,6 +132,12 @@ class CRM_Financial_BAO_ExportFormat {
    * Depending on the output format might want to override this, e.g. for IIF tabs need to be escaped etc,
    * but for CSV it doesn't make sense because php has built in csv output functions.
    */
+  /**
+   * @param $s
+   * @param string $type
+   *
+   * @return null
+   */
   static function format($s, $type = 'string') {
     if (!empty($s)) {
       return $s;
@@ -145,6 +175,12 @@ class CRM_Financial_BAO_ExportFormat {
     }
   }
 
+  /**
+   * @param $batchIds
+   * @param string $fileName
+   *
+   * @throws CRM_Core_Exception
+   */
   static function createActivityExport($batchIds, $fileName) {
     $session = CRM_Core_Session::singleton();
     $values = array();
@@ -158,7 +194,7 @@ class CRM_Financial_BAO_ExportFormat {
       $paymentInstrument = array_flip(CRM_Contribute_PseudoConstant::paymentInstrument('label'));
       $values['payment_instrument_id'] = array_search($values['payment_instrument_id'], $paymentInstrument);
     }
-    $details = '<p>' . ts('Record: ') . $values['title'] . '</p><p>' . ts('Description: ') . '</p><p>' . ts('Created By: ') . $createdBy . '</p><p>' . ts('Created Date: ') . $values['created_date'] . '</p><p>' . ts('Last Modified By: ') . $modifiedBy . '</p><p>' . ts('Payment Instrument: ') . $values['payment_instrument_id'] . '</p>';
+    $details = '<p>' . ts('Record:') . ' ' . $values['title'] . '</p><p>' . ts('Description:') . '</p><p>' . ts('Created By:') . " $createdBy" . '</p><p>' . ts('Created Date:') . ' ' . $values['created_date'] . '</p><p>' . ts('Last Modified By:') . ' ' . $modifiedBy . '</p><p>' . ts('Payment Instrument:') . ' ' . $values['payment_instrument_id'] . '</p>';
     $subject = '';
     if (!empty($values['total'])) {
       $subject .= ts('Total') . '['. CRM_Utils_Money::format($values['total']) .'],';
@@ -190,6 +226,13 @@ class CRM_Financial_BAO_ExportFormat {
     CRM_Activity_BAO_Activity::create($activityParams);
   }
 
+  /**
+   * @param array $files
+   * @param null $destination
+   * @param bool $overwrite
+   *
+   * @return bool
+   */
   function createZip($files = array(), $destination = NULL, $overwrite = FALSE) {
     //if the zip file already exists and overwrite is false, return false
     if (file_exists($destination) && !$overwrite) {