| @@ 111-148 (lines=38) @@ | ||
| 108 | */ |
|
| 109 | private function createOrder($input) |
|
| 110 | { |
|
| 111 | if (isset($input['contact_id']) && (int)$input['contact_id'] > 0) { |
|
| 112 | $this->contact = new Contact($this->kernel, (int)$input['contact_id']); |
|
| 113 | ||
| 114 | $contact_person_id = 0; |
|
| 115 | // It is a company and contactperson is given. We try to see if we can find the contact person. |
|
| 116 | if (isset($input['contactperson']) && $input['contactperson'] != '') { |
|
| 117 | $input['type'] = 'corporation'; |
|
| 118 | ||
| 119 | // If the contact is a company their might already be a contact person. |
|
| 120 | if ($this->contact->get('type') == 'company' && isset($this->contact->contactperson)) { |
|
| 121 | $contact_persons = $this->contact->contactperson->getList(); |
|
| 122 | foreach ($contact_persons as $contact_person) { |
|
| 123 | // This is only a comparing on name, this might not be enough. |
|
| 124 | if ($contact_person['name'] == $input['contactperson']) { |
|
| 125 | $contact_person_id = $contact_person['id']; |
|
| 126 | break; |
|
| 127 | } |
|
| 128 | } |
|
| 129 | } |
|
| 130 | } |
|
| 131 | } else { |
|
| 132 | $this->contact = new Contact($this->kernel); |
|
| 133 | $contact_person_id = 0; |
|
| 134 | ||
| 135 | // checks whether it is a company |
|
| 136 | if (isset($input['contactperson']) && $input['contactperson'] != '') { |
|
| 137 | $input['type'] = 'corporation'; // firma |
|
| 138 | } |
|
| 139 | ||
| 140 | if (isset($input['customer_ean']) && $input['customer_ean'] != '') { |
|
| 141 | // sets preffered invoice to electronic. |
|
| 142 | $input['type'] = 'corporation'; // firma |
|
| 143 | $input['preferred_invoice'] = 3; |
|
| 144 | } else { |
|
| 145 | // sets preffered invoice to email. Should be a setting in webshop. |
|
| 146 | $input['preferred_invoice'] = 2; |
|
| 147 | } |
|
| 148 | } |
|
| 149 | ||
| 150 | if (isset($input['customer_ean'])) { |
|
| 151 | $input['ean'] = $input['customer_ean']; |
|
| @@ 108-145 (lines=38) @@ | ||
| 105 | */ |
|
| 106 | private function createOrder($input) |
|
| 107 | { |
|
| 108 | if (isset($input['contact_id']) && (int)$input['contact_id'] > 0) { |
|
| 109 | $this->contact = new Contact($this->kernel, (int)$input['contact_id']); |
|
| 110 | ||
| 111 | $contact_person_id = 0; |
|
| 112 | // It is a company and contactperson is given. We try to see if we can find the contact person. |
|
| 113 | if (isset($input['contactperson']) && $input['contactperson'] != '') { |
|
| 114 | $input['type'] = 'corporation'; |
|
| 115 | ||
| 116 | // If the contact is a company their might already be a contact person. |
|
| 117 | if ($this->contact->get('type') == 'company' && isset($this->contact->contactperson)) { |
|
| 118 | $contact_persons = $this->contact->contactperson->getList(); |
|
| 119 | foreach ($contact_persons as $contact_person) { |
|
| 120 | // This is only a comparing on name, this might not be enough. |
|
| 121 | if ($contact_person['name'] == $input['contactperson']) { |
|
| 122 | $contact_person_id = $contact_person['id']; |
|
| 123 | break; |
|
| 124 | } |
|
| 125 | } |
|
| 126 | } |
|
| 127 | } |
|
| 128 | } else { |
|
| 129 | $this->contact = new Contact($this->kernel); |
|
| 130 | $contact_person_id = 0; |
|
| 131 | ||
| 132 | // s�rger for at tjekke om det er et firma |
|
| 133 | if (isset($input['contactperson']) && $input['contactperson'] != '') { |
|
| 134 | $input['type'] = 'corporation'; // firma |
|
| 135 | } |
|
| 136 | ||
| 137 | if (isset($input['customer_ean']) && $input['customer_ean'] != '') { |
|
| 138 | // sets preffered invoice to electronic. |
|
| 139 | $input['type'] = 'corporation'; // firma |
|
| 140 | $input['preferred_invoice'] = 3; |
|
| 141 | } else { |
|
| 142 | // sets preffered invoice to email. Should be a setting in webshop. |
|
| 143 | $input['preferred_invoice'] = 2; |
|
| 144 | } |
|
| 145 | } |
|
| 146 | ||
| 147 | if (isset($input['customer_ean'])) { |
|
| 148 | $input['ean'] = $input['customer_ean']; |
|