public function ajax_final_appointment() { $logic = new EALogic(); $table = 'ea_appointments'; $data = $_GET; unset($data['action']); $data['status'] = 'pending'; $appointment = $this->models->get_row('ea_appointments', $data['id'], ARRAY_A); // check IP if ($appointment['ip'] != $_SERVER['REMOTE_ADDR']) { $this->send_err_json_result('{"err":true}'); } $appointment['status'] = 'pending'; $response = $this->models->replace($table, $appointment, true); $meta = $this->models->get_all_rows('ea_meta_fields'); foreach ($meta as $f) { $fields = array(); $fields['app_id'] = $appointment['id']; $fields['field_id'] = $f->id; if (array_key_exists($f->slug, $data)) { $fields['value'] = $data[$f->slug]; } else { $fields['value'] = ''; } $response = $response && $this->models->replace('ea_fields', $fields, true, true); } if ($response == false) { $this->send_err_json_result('{"err":true}'); } else { EALogic::send_notification($data); $send_user_mail = $logic->get_option_value('send.user.email', false); if (!empty($send_user_mail)) { EALogic::send_status_change_mail($data['id']); } } $response = new stdClass(); $response->message = 'Ok'; $this->send_ok_json_result($response); }