import('ttClientHelper');
import('ttInvoiceHelper');
import('ttCustomFieldHelper');
+import('ttExpenseHelper');
// ttOrgImportHelper - this class is a future replacement for ttImportHelper.
// Currently, it is work in progress.
$this->currentGroupCustomFieldOptionMap[$attrs['ID']] = $custom_field_option_id;
} else $this->errors->add($i18n->get('error.db'));
}
+
+ if ($name == 'CUSTOM_FIELD_LOG_ENTRY') {
+ // We get here when processing <custom_field_log_entry> tags for the current group.
+ if (!ttCustomFieldHelper::insertLogEntry(array(
+ // 'group_id' => $this->current_group_id, TODO: add this when group_id field is added to the table.
+ // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table.
+ 'log_id' => $this->currentGroupLogMap[$attrs['LOG_ID']],
+ 'field_id' => $this->currentGroupCustomFieldMap[$attrs['FIELD_ID']],
+ 'option_id' => $this->currentGroupCustomFieldOptionMap[$attrs['OPTION_ID']],
+ 'value' => $attrs['VALUE'],
+ 'status' => $attrs['STATUS']))) {
+ $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'));
+ }
+
+ if ($name == 'MONTHLY_QUOTA') {
+ if (!$this->insertMonthlyQuota($this->current_group_id,
+ // 'org_id' => $this->org_id, TODO: add this when org_id field is added to the table.
+ $attrs['YEAR'],
+ $attrs['MONTH'],
+ $attrs['MINUTES'])) {
+ $this->errors->add($i18n->get('error.db'));
+ }
+ }
}
}
$group_id = $mdb2->lastInsertID('tt_groups', 'id');
return $group_id;
}
+
+ // insertMonthlyQuota - a helper function to insert a monthly quota.
+ private function insertMonthlyQuota($group_id, $year, $month, $minutes) {
+ $mdb2 = getConnection();
+ $sql = "INSERT INTO tt_monthly_quotas (group_id, year, month, minutes) values ($group_id, $year, $month, $minutes)";
+ $affected = $mdb2->exec($sql);
+ return (!is_a($affected, 'PEAR_Error'));
+ }
}