Trips data
This commit is contained in:
@@ -203,6 +203,13 @@ private function testCards(){
|
||||
|
||||
|
||||
switch ($endpoint) {
|
||||
|
||||
case 'getsavedtrips':
|
||||
$inx['action'] = SAVVY_USER_GETSAVEDTRIPS;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case 'refreshsession':
|
||||
if (isset($inx['sessionid'])){
|
||||
$inx['accessToken'] = $inx['sessionid'];
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class userTrips extends Model{
|
||||
protected $db;
|
||||
public $con_name = 'dbFloat';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->db = \Config\Database::connect($this->con_name);
|
||||
}
|
||||
|
||||
private function logArray3($in){
|
||||
if (!is_array($in)){
|
||||
log_message('critical', "NOT ARRAY => $in \n");
|
||||
return;
|
||||
}
|
||||
foreach($in as $key => $value){
|
||||
$vl='';
|
||||
if (is_array($value)){
|
||||
foreach($value as $kk => $vv){
|
||||
$vl .= "$kk => $vv \n";
|
||||
}
|
||||
}
|
||||
else{
|
||||
$vl=$value;
|
||||
}
|
||||
|
||||
log_message('critical', "$key=>".$vl);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
long savvyLoadSavedTrips($in, CVars &$out) {
|
||||
|
||||
$ret = PHP_API_BAD_PARAM;
|
||||
$member_id = $in['member_id'];
|
||||
$out["total_record"] = 0;
|
||||
$out['session_valid'] = '';
|
||||
$out['internal_return'] = PHP_API_OK;
|
||||
|
||||
|
||||
long ret = PHP_API_BAD_PARAM;
|
||||
char vname[20];
|
||||
try {
|
||||
// REQ_LONG(in, "status", 0, -1);
|
||||
REQ_LONG(in, "member_id", 0, -1);
|
||||
|
||||
out["total_record"] = "0";
|
||||
|
||||
|
||||
$saveTrips = $this->db->query("SELECT * FROM members_trips WHERE member_id = $member_id AND status = 1 ORDER BY trip_date DESC");
|
||||
|
||||
if ($saveTrips != null) {
|
||||
$out["total_record"] = $saveTrips->getNumRows();
|
||||
$ic = 0;
|
||||
$this->logArray2("card lines total_record => ".$saveTrips->getNumRows());
|
||||
|
||||
foreach ($saveTrips->getResultArray() as $f) {
|
||||
// $this->logArray3("Saved Trips total => ".$ic);
|
||||
$suffix = str_pad($ic, 5, '0', STR_PAD_LEFT);
|
||||
$out['trip_name_' . $suffix] = $f['trip_name'];
|
||||
$out['trip_id_' . $suffix] = $f['id'];
|
||||
$out['from_' . $suffix] = $f['trip_from'];
|
||||
$out['to_' . $suffix] = $f['trip_to'];
|
||||
$out['date_' . $suffix] = $f['trip_date'];
|
||||
$out['country_' . $suffix] = $f['country'];
|
||||
$out['color_' . $suffix] = $f['color'];
|
||||
}
|
||||
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user