Merge pull request #4899 from colemanw/INFRA-132
[civicrm-core.git] / CRM / Financial / BAO / ExportFormat.php
index 727d1d93166abd2cdb51fb493e104beb9ec4f4be..d664af865a3efec31d5c396c59d3ba307bb37d69 100644 (file)
@@ -38,7 +38,6 @@
  * Create a subclass for a specific format.
  * @see http://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Specifications+-++Batches#CiviAccountsSpecifications-Batches-%C2%A0Overviewofimplementation
  */
-
 class CRM_Financial_BAO_ExportFormat {
 
   /*
@@ -55,7 +54,7 @@ class CRM_Financial_BAO_ExportFormat {
    * Class constructor
    */
   public function __construct() {
-    if ( !isset( self::$_template ) ) {
+    if (!isset(self::$_template)) {
       self::$_template = CRM_Core_Smarty::singleton();
     }
   }
@@ -78,14 +77,14 @@ class CRM_Financial_BAO_ExportFormat {
     switch ($this->getFileExtension()) {
       case 'csv':
         self::createActivityExport($this->_batchIds, $fileName);
-      break;
+        break;
 
       case 'iif':
         $tplFile = $this->getHookedTemplateFileName();
         $out = self::getTemplate()->fetch($tplFile);
         $fileName = $this->putFile($out);
         self::createActivityExport($this->_batchIds, $fileName);
-      break;
+        break;
     }
   }
 
@@ -108,7 +107,7 @@ class CRM_Financial_BAO_ExportFormat {
    * @return null
    */
   public function getTemplateFileName() {
-    return null;
+    return NULL;
   }
 
   /**
@@ -150,7 +149,7 @@ class CRM_Financial_BAO_ExportFormat {
   public function initiateDownload() {
     $config = CRM_Core_Config::singleton();
     //zip files if more than one.
-    if (count($this->_downloadFile)>1) {
+    if (count($this->_downloadFile) > 1) {
       $zip = $config->customFileUploadDir . 'Financial_Transactions_' . date('YmdHis') . '.zip';
       $result = $this->createZip($this->_downloadFile, $zip, TRUE);
       if ($result) {
@@ -197,14 +196,14 @@ class CRM_Financial_BAO_ExportFormat {
     $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']) .'],';
+      $subject .= ts('Total') . '[' . CRM_Utils_Money::format($values['total']) . '],';
     }
     if (!empty($values['item_count'])) {
-      $subject .= ' ' . ts('Count') . '['. $values['item_count'] .'],';
+      $subject .= ' ' . ts('Count') . '[' . $values['item_count'] . '],';
     }
 
     //create activity.
-    $subject .=  ' ' . ts('Batch') . '['. $values['title'] .']';
+    $subject .= ' ' . ts('Batch') . '[' . $values['title'] . ']';
     $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
     $activityParams = array(
       'activity_type_id' => array_search('Export Accounting Batch', $activityTypes),
@@ -215,7 +214,7 @@ class CRM_Financial_BAO_ExportFormat {
       'source_record_id' => $values['id'],
       'target_contact_id' => $session->get('userID'),
       'details' => $details,
-      'attachFile_1' => array (
+      'attachFile_1' => array(
         'uri' => $fileName,
         'type' => 'text/csv',
         'location' => $fileName,
@@ -249,7 +248,7 @@ class CRM_Financial_BAO_ExportFormat {
     }
     if (count($validFiles)) {
       $zip = new ZipArchive();
-      if ($zip->open($destination,$overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
+      if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
         return FALSE;
       }
       foreach ($validFiles as $file) {
@@ -259,7 +258,7 @@ class CRM_Financial_BAO_ExportFormat {
       return file_exists($destination);
     }
     else {
-        return FALSE;
-      }
+      return FALSE;
+    }
   }
 }