Code Duplication    Length = 31-31 lines in 2 locations

web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php 2 locations

@@ 141-171 (lines=31) @@
138
		$this->session->set_userdata('advance_search', 0);
139
		$this->session->set_userdata('account_search', "");
140
	}
141
	function fssipdevices_save($user_flg = false) {
142
		$add_array = $this->input->post();
143
		if (!$user_flg) {
144
			$data['form'] = $this->form->build_form($this->freeswitch_form->get_freeswith_form_fields($add_array['id']), $add_array);
145
		} else {
146
			$data['form'] = $this->form->build_form($this->freeswitch_form->fsdevice_form_fields_for_customer($add_array["accountcode"],$add_array['id']),  $add_array);
147
		}
148
		if ($add_array['id'] != '') {
149
			$data['page_title'] = 'Freeswitch SIP Devices';
150
			if ($this->form_validation->run() == FALSE) {
151
				$data['validation_errors'] = validation_errors();
152
				echo $data['validation_errors'];
153
				exit;
154
			} else {
155
				$this->freeswitch_model->edit_freeswith($add_array, $add_array['id']);
156
				echo json_encode(array("SUCCESS"=> "SIP Device Updated Successfully!"));
157
				exit;
158
			}
159
		} else {
160
			$data['page_title'] = 'Create Freeswitch SIP Devices';
161
			if ($this->form_validation->run() == FALSE) {
162
				$data['validation_errors'] = validation_errors();
163
				echo $data['validation_errors'];
164
				exit;
165
			} else {
166
				$this->freeswitch_model->add_freeswith($add_array);
167
				echo json_encode(array("SUCCESS"=> "SIP Device Added Successfully!"));
168
				exit;
169
			}
170
		}
171
	}
172
	function customer_fssipdevices_save($user_flg = false) {
173
		$add_array = $this->input->post();      
174
		if (!$user_flg) {
@@ 172-202 (lines=31) @@
169
			}
170
		}
171
	}
172
	function customer_fssipdevices_save($user_flg = false) {
173
		$add_array = $this->input->post();      
174
		if (!$user_flg) {
175
			$data['form'] = $this->form->build_form($this->freeswitch_form->get_freeswith_form_fields(), $add_array);
176
		} else {
177
			$data['form'] = $this->form->build_form($this->freeswitch_form->fsdevice_form_fields_for_customer($add_array["accountcode"],$add_array['id']), $add_array);
178
		}
179
		if ($add_array['id'] != '') {
180
			$data['page_title'] = 'Edit Freeswitch SIP Devices';
181
			if ($this->form_validation->run() == FALSE) {
182
				$data['validation_errors'] = validation_errors();
183
				echo $data['validation_errors'];
184
				exit;
185
			} else {
186
				$this->freeswitch_model->edit_freeswith($add_array, $add_array['id']);
187
				echo json_encode(array("SUCCESS"=> "SIP Device Updated Successfully!"));
188
				exit;
189
			}
190
		} else {
191
			$data['page_title'] = 'Create Freeswitch SIP Devices';
192
			if ($this->form_validation->run() == FALSE) {
193
				$data['validation_errors'] = validation_errors();
194
				echo $data['validation_errors'];
195
				exit;
196
			} else {
197
				$this->freeswitch_model->add_freeswith($add_array);
198
				echo json_encode(array("SUCCESS"=> "SIP Device Added Successfully!"));
199
				exit;
200
			}
201
		}
202
	}
203
	function user_fssipdevices_save($user_flg = false) {
204
		$add_array = $this->input->post();
205
		$data['form'] = $this->form->build_form($this->freeswitch_form->fsdevice_form_fields_for_customer($add_array["accountcode"],$add_array['id']), $add_array);