]> wagnertech.de Git - timetracker.git/blobdiff - WEB-INF/lib/ttOrgImportHelper.class.php
Integrated expense items in new export-import.
[timetracker.git] / WEB-INF / lib / ttOrgImportHelper.class.php
index 17827986c682b96e08bd5302d0a1a1b669eb6c64..89428c4c9cd6a5732aff20e360e52319bf12e9da 100644 (file)
@@ -33,6 +33,7 @@ import('ttProjectHelper');
 import('ttClientHelper');
 import('ttInvoiceHelper');
 import('ttCustomFieldHelper');
+import('ttExpenseHelper');
 
 // ttOrgImportHelper - this class is a future replacement for ttImportHelper.
 // Currently, it is work in progress.
@@ -370,6 +371,23 @@ class ttOrgImportHelper {
           $this->errors->add($i18n->get('error.db'));
         }
       }
+
+      if ($name == 'EXPENSE_ITEM') {
+        // We get here when processing <expense_item> tags for the current group.
+        $expense_item_id = ttExpenseHelper::insert(array(
+          'date' => $attrs['DATE'],
+          'user_id' => $this->currentGroupUserMap[$attrs['USER_ID']],
+          'group_id' => $this->current_group_id,
+          // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table.
+          'client_id' => $this->currentGroupClientMap[$attrs['CLIENT_ID']],
+          'project_id' => $this->currentGroupProjectMap[$attrs['PROJECT_ID']],
+          'name' => $attrs['NAME'],
+          'cost' => $attrs['COST'],
+          'invoice_id' => $this->currentGroupInvoiceMap[$attrs['INVOICE_ID']],
+          'paid' => $attrs['PAID'],
+          'status' => $attrs['STATUS']));
+        if (!$expense_item_id) $this->errors->add($i18n->get('error.db'));
+      }
     }
   }