-
- if ($name == 'CLIENT' && $this->canImport) {
- // Prepare a list of project ids.
- if ($this->currentElement['PROJECTS']) {
- $projects = explode(',', $this->currentElement['PROJECTS']);
- foreach ($projects as $id)
- $mapped_projects[] = $this->projectMap[$id];
- }
-
- $this->clientMap[$this->currentElement['ID']] =
- ttClientHelper::insert(array(
- 'group_id' => $this->group_id,
- 'name' => $this->currentElement['NAME'],
- 'address' => $this->currentElement['ADDRESS'],
- 'tax' => $this->currentElement['TAX'],
- 'projects' => $mapped_projects,
- 'status' => $this->currentElement['STATUS']));
-
- // Update client_id for tt_users to a mapped value.
- // We did not do it during user insertion because clientMap was not ready then.
- if ($this->currentElement['ID'] != $this->clientMap[$this->currentElement['ID']])
- ttClientHelper::setMappedClient($this->group_id, $this->currentElement['ID'], $this->clientMap[$this->currentElement['ID']]);
- }
-
- if ($name == 'INVOICE' && $this->canImport) {
- $this->invoiceMap[$this->currentElement['ID']] =
- ttInvoiceHelper::insert(array(
- 'group_id' => $this->group_id,
- 'name' => $this->currentElement['NAME'],
- 'date' => $this->currentElement['DATE'],
- 'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']],
- 'discount' => $this->currentElement['DISCOUNT'],
- 'status' => $this->currentElement['STATUS']));
- }
-
- if ($name == 'MONTHLY_QUOTA' && $this->canImport) {
- $this->insertMonthlyQuota($this->group_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['MINUTES']);
- }
-
- if ($name == 'LOG_ITEM' && $this->canImport) {
- $this->logMap[$this->currentElement['ID']] =
- ttTimeHelper::insert(array(
- 'user_id' => $this->userMap[$this->currentElement['USER_ID']],
- 'group_id' => $this->group_id,
- 'date' => $this->currentElement['DATE'],
- 'start' => $this->currentElement['START'],
- 'finish' => $this->currentElement['FINISH'],
- 'duration' => $this->currentElement['DURATION'],
- 'client' => $this->clientMap[$this->currentElement['CLIENT_ID']],
- 'project' => $this->projectMap[$this->currentElement['PROJECT_ID']],
- 'task' => $this->taskMap[$this->currentElement['TASK_ID']],
- 'invoice' => $this->invoiceMap[$this->currentElement['INVOICE_ID']],
- 'note' => (isset($this->currentElement['COMMENT']) ? $this->currentElement['COMMENT'] : ''),
- 'billable' => $this->currentElement['BILLABLE'],
- 'paid' => $this->currentElement['PAID'],
- 'status' => $this->currentElement['STATUS']));
- }
-
- if ($name == 'CUSTOM_FIELD' && $this->canImport) {
- $this->customFieldMap[$this->currentElement['ID']] =
- ttCustomFieldHelper::insertField(array(
- 'group_id' => $this->group_id,
- 'type' => $this->currentElement['TYPE'],
- 'label' => $this->currentElement['LABEL'],
- 'required' => $this->currentElement['REQUIRED'],
- 'status' => $this->currentElement['STATUS']));
- }
-
- if ($name == 'CUSTOM_FIELD_OPTION' && $this->canImport) {
- $this->customFieldOptionMap[$this->currentElement['ID']] =
- ttCustomFieldHelper::insertOption(array(
- 'field_id' => $this->customFieldMap[$this->currentElement['FIELD_ID']],
- 'value' => $this->currentElement['VALUE']));
- }
-
- if ($name == 'CUSTOM_FIELD_LOG_ENTRY' && $this->canImport) {
- ttCustomFieldHelper::insertLogEntry(array(
- 'log_id' => $this->logMap[$this->currentElement['LOG_ID']],
- 'field_id' => $this->customFieldMap[$this->currentElement['FIELD_ID']],
- 'option_id' => $this->customFieldOptionMap[$this->currentElement['OPTION_ID']],
- 'value' => $this->currentElement['VALUE'],
- 'status' => $this->currentElement['STATUS']));
- }
-
- if ($name == 'EXPENSE_ITEM' && $this->canImport) {
- ttExpenseHelper::insert(array(
- 'date' => $this->currentElement['DATE'],
- 'user_id' => $this->userMap[$this->currentElement['USER_ID']],
- 'group_id' => $this->group_id,
- 'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']],
- 'project_id' => $this->projectMap[$this->currentElement['PROJECT_ID']],
- 'name' => $this->currentElement['NAME'],
- 'cost' => $this->currentElement['COST'],
- 'invoice_id' => $this->invoiceMap[$this->currentElement['INVOICE_ID']],
- 'paid' => $this->currentElement['PAID'],
- 'status' => $this->currentElement['STATUS']));
- }
-
- if ($name == 'FAV_REPORT' && $this->canImport) {
- $user_list = '';
- if (strlen($this->currentElement['USERS']) > 0) {
- $arr = explode(',', $this->currentElement['USERS']);
- foreach ($arr as $v)
- $user_list .= (strlen($user_list) == 0 ? '' : ',').$this->userMap[$v];
- }
- ttFavReportHelper::insertReport(array(
- 'name' => $this->currentElement['NAME'],
- 'user_id' => $this->userMap[$this->currentElement['USER_ID']],
- 'client' => $this->clientMap[$this->currentElement['CLIENT_ID']],
- 'option' => $this->customFieldOptionMap[$this->currentElement['CF_1_OPTION_ID']],
- 'project' => $this->projectMap[$this->currentElement['PROJECT_ID']],
- 'task' => $this->taskMap[$this->currentElement['TASK_ID']],
- 'billable' => $this->currentElement['BILLABLE'],
- 'users' => $user_list,
- 'period' => $this->currentElement['PERIOD'],
- 'from' => $this->currentElement['PERIOD_START'],
- 'to' => $this->currentElement['PERIOD_END'],
- 'chclient' => (int) $this->currentElement['SHOW_CLIENT'],
- 'chinvoice' => (int) $this->currentElement['SHOW_INVOICE'],
- 'chpaid' => (int) $this->currentElement['SHOW_PAID'],
- 'chip' => (int) $this->currentElement['SHOW_IP'],
- 'chproject' => (int) $this->currentElement['SHOW_PROJECT'],
- 'chstart' => (int) $this->currentElement['SHOW_START'],
- 'chduration' => (int) $this->currentElement['SHOW_DURATION'],
- 'chcost' => (int) $this->currentElement['SHOW_COST'],
- 'chtask' => (int) $this->currentElement['SHOW_TASK'],
- 'chfinish' => (int) $this->currentElement['SHOW_END'],
- 'chnote' => (int) $this->currentElement['SHOW_NOTE'],
- 'chcf_1' => (int) $this->currentElement['SHOW_CUSTOM_FIELD_1'],
- 'chunits' => (int) $this->currentElement['SHOW_WORK_UNITS'],
- 'group_by1' => $this->currentElement['GROUP_BY1'],
- 'group_by2' => $this->currentElement['GROUP_BY2'],
- 'group_by3' => $this->currentElement['GROUP_BY3'],
- 'chtotalsonly' => (int) $this->currentElement['SHOW_TOTALS_ONLY']));
- }
- $this->currentTag = '';