Formatter mocdel
This commit is contained in:
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
//www-api/app/Models/.php
|
||||
class ResultFormatter extends Model
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
// parent::__construct();
|
||||
}
|
||||
public function formatCreateTranspData($in) {
|
||||
$in["member_id"] = $in["session_member_id"];
|
||||
$in['firstname'] = $in['patientinfo_firstname'];
|
||||
$in['lastname'] = $in['patientinfo_lastname'];
|
||||
$in['from_phone'] = $in['patientinfo_phone']; //
|
||||
|
||||
$in['from_street'] = $in['pickupaddress_streetaddress']; //
|
||||
//$in['from_aptno'] = $in['pickupaddress_aptno']; //
|
||||
$in['from_zipcode'] = $in['pickupaddress_zip']; //
|
||||
|
||||
$in['from_city'] = $in['pickupaddress_city']; //
|
||||
$in['from_state'] = $in['pickupaddress_state']; //
|
||||
$in['to_street'] = $in['dropoffaddress_streetaddress']; //
|
||||
//$in['to_aptno'] = $in['dropoffaddress_aptno']; //
|
||||
$in['to_zipcode'] = $in['dropoffaddress_zip']; //
|
||||
$in['to_city'] = $in['dropoffaddress_city']; //
|
||||
$in['to_state'] = $in['dropoffaddress_state']; //
|
||||
$in['facilityname'] = $in['dropoffaddress_facilityname']; //
|
||||
$in['transport_date'] = $in['datetime_currentdate'] . " " . $in['datetime_currentTime'];
|
||||
|
||||
// payment information
|
||||
$in['paymenttype'] = $in['paymentinfo_paymenttype']; //
|
||||
$in['paymentid'] = $in['paymentinfo_paymentid']; //
|
||||
$in['cardname'] = $in['paymentinfo_fullname']; //
|
||||
$in['cardnumber'] = $in['paymentinfo_cardnumber']; //
|
||||
$in['exp_month'] = $in['paymentinfo_exp_month']; //
|
||||
$in['exp_year'] = $in['paymentinfo_exp_year']; //
|
||||
$in['cvc'] = $in['paymentinfo_cvc']; //
|
||||
|
||||
|
||||
return $in;
|
||||
}
|
||||
public function processOutJson($in, $out) {
|
||||
if ($in["action"] != MEDTRANS_USER_GET_TRANSLIST) {
|
||||
// return $out;
|
||||
}
|
||||
|
||||
|
||||
switch ($in["action"]) {
|
||||
case MEDTRANS_USER_GET_TRANSLIST:
|
||||
|
||||
$total = $out["total_record"];
|
||||
$res = array(
|
||||
"status" => $out["status"],
|
||||
"total_record" => ($total - 1),
|
||||
"internal_return" => $out["internal_return"],
|
||||
"result_list" => array(),
|
||||
);
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$key = sprintf("%05d", $i);
|
||||
$res["result_list"][] = array(
|
||||
"transport_date" => $out["transport_date_${key}"],
|
||||
"firstname" => $out["firstname_${key}"],
|
||||
"lastname" => $out["lastname_${key}"],
|
||||
"from_phone" => $out["from_phone_${key}"],
|
||||
"from_street" => $out["from_street_${key}"],
|
||||
"to_street" => $out["to_street_${key}"],
|
||||
"from_city" => $out["from_city_${key}"],
|
||||
"to_city" => $out["to_city_${key}"],
|
||||
"from_state" => $out["from_state_${key}"],
|
||||
"to_state" => $out["to_state_${key}"],
|
||||
"from_zipcode" => $out["from_zipcode_${key}"],
|
||||
"to_zipcode" => $out["to_zipcode_${key}"],
|
||||
"flags" => $out["flags_${key}"],
|
||||
"miles" => $out["distance_${key}"],
|
||||
"transport" => $out["transport_${key}"],
|
||||
"translate" => $out["translate_${key}"],
|
||||
"lang_code" => $out["lang_code_${key}"],
|
||||
"language" => $out["language_${key}"]
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
case MEDTRANS_USER_GET_LANGUAGE:
|
||||
$total = $out["total_record"];
|
||||
$res = array(
|
||||
"status" => $out["status"],
|
||||
"total_record" => ($total - 1),
|
||||
"internal_return" => $out["internal_return"],
|
||||
"result_list" => array(),
|
||||
);
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$key = sprintf("%05d", $i);
|
||||
$res["result_list"][] = array(
|
||||
"language" => $out["language_${key}"],
|
||||
"code" => $out["code_${key}"]
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
||||
case MEDTRANS_TRANSP_LISTLOCATION:
|
||||
|
||||
$total = $out["total_record"];
|
||||
$res = array(
|
||||
"status" => $out["status"],
|
||||
"total_record" => ($total - 1),
|
||||
"internal_return" => $out["internal_return"],
|
||||
"result_list" => array(),
|
||||
);
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$key = sprintf("%05d", $i);
|
||||
$res["result_list"][] = array(
|
||||
"agent_id" => $out["agent_id_${key}"],
|
||||
"street" => $out["street_${key}"],
|
||||
"city" => $out["city_${key}"],
|
||||
"id" => $out["id_${key}"],
|
||||
"state" => $out["state_${key}"],
|
||||
"zipcode" => $out["zipcode_${key}"],
|
||||
"state" => $out["state_${key}"]
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case MEDTRANS_TRANSP_GETREASON:
|
||||
|
||||
$total = $out["total_record"];
|
||||
$res = array(
|
||||
"status" => $out["status"],
|
||||
"total_record" => ($total - 1),
|
||||
"internal_return" => $out["internal_return"],
|
||||
"result_list" => array(),
|
||||
);
|
||||
for ($i = 0; $i < $total; $i++) {
|
||||
$key = sprintf("%05d", $i);
|
||||
$res["result_list"][] = array(
|
||||
"key" => $out["lkey_${key}"],
|
||||
"name" => $out["name_${key}"],
|
||||
"lorder" => $out["lorder_${key}"]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return $out;
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user