From d1e571adca5f96879adc6583fd1bc043df9ef634 Mon Sep 17 00:00:00 2001 From: dev-chiefworks Date: Sun, 24 Apr 2022 12:21:54 -0400 Subject: [PATCH] Load slide card --- app/Controllers/Savvy.php | 13 +++++++ app/Models/userCards.php | 72 ++++++++++++++++++++++++++++++--------- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/app/Controllers/Savvy.php b/app/Controllers/Savvy.php index 6b279e3..7a78d9a 100644 --- a/app/Controllers/Savvy.php +++ b/app/Controllers/Savvy.php @@ -203,6 +203,19 @@ private function testCards(){ switch ($endpoint) { + case 'subscribedcarddata': + + $in["action"] = SAVVY_USERSAPP_SLIDECARD; + $cards = new \App\Models\userCards(); + $inx['card_type'] = 55000; + // $in['card_count'] =20; + $out = []; + $outX = []; + $inx["action"] = SAVVY_USERSAPP_SLIDECARD; + $outX["action"] = SAVVY_USERSAPP_SLIDECARD; + $cards->loadSliderCard($inx, $outX); + $out = $this->processOutJson($outX, $outX); + break; case 'getsavedtrips': $inx['action'] = SAVVY_USER_GETSAVEDTRIPS; diff --git a/app/Models/userCards.php b/app/Models/userCards.php index 93f6d2e..1cb70fb 100644 --- a/app/Models/userCards.php +++ b/app/Models/userCards.php @@ -36,7 +36,7 @@ class userCards extends Model{ $member = $this->getMember($member_id); if ($member) { $survey = $this->getCardBySurvey($member); - $this->getCardsByType($out, $member, $card_type, $card_count); + $this->getCardsByType($out, $member_id, $card_type, $card_count); } } @@ -65,9 +65,9 @@ class userCards extends Model{ return null; } - private function getCardsByType(&$out, $member, $card_type, $limit = 10) + private function getCardsByType(&$out, $member_id, $card_type, $limit = 10) { - $member_id = $member['id']; + $query =''; switch ($card_type) { @@ -109,26 +109,66 @@ class userCards extends Model{ $deal_card_count = 0; $survey_card_count = 0; $blog_card_count = 0; - $r = $this->db->query( $query ); - $out['total_record_raw'] = $r->getNumRows(); - $out['total_record'] = $r->getNumRows(); + $out['retval'] = PHP_API_OK; $out['internal_return'] = PHP_API_OK; $query = $query . " LIMIT " . $limit . ""; - $r = $this->db->query( $query ); // with limits + $saveCards = $this->db->query( $query ); // with limits + $out['total_record_raw'] = $saveCards->getNumRows(); + $out['total_record'] = $saveCards->getNumRows(); + $result = []; - - if ($r) { + if ($saveCards != null) { + $out["total_record"] = $saveCards->getNumRows(); $ic = 0; - while ($f = $r->getRowArray()) { + $this->logArray2("card lines total_record => ".$saveCards->getNumRows()); + + + foreach ($saveCards->getResultArray() as $f) { + $this->logArray2("card lines total => ".$ic); + $suffix = str_pad($ic, 5, '0', STR_PAD_LEFT); + $out['name_' . $suffix] = $f['name']; + $out['assign_id_' . $suffix] = $f['assign_id']; + $out['card_id_' . $suffix] = $f['card_id']; + $out['can_save_' . $suffix] = $f['can_save']; + $out['short_title_' . $suffix] = $f['short_title']; + $out['title_' . $suffix] = $f['short_title']; + $out['background_picture_' . $suffix] = $f['background_picture']; + $out['button1_' . $suffix] = $f['button1']; + $out['button1_text_' . $suffix] = $f['button1_text']; + $out['button1_action_' . $suffix] = $f['button1_action']; + $out['expires_' . $suffix] = $f['card_expiration']; + $out['template_' . $suffix] = $f['template']; + $out['card_canexpire_' . $suffix] = $f['card_canexpire']; + $out['card_action_type_' . $suffix] = $f['card_action_type']; + $out['card_action_data_' . $suffix] = $f['card_action_data']; + $out['titleshow_' . $suffix] = $f['titleshow']; + $out['multiple_answer_' . $suffix] = $f['multiple_answer']; + $out['use_short_title_' . $suffix] = $f['use_short_title']; + $out['target_key_' . $suffix] = $f['target_key']; + $out['target_text_' . $suffix] = $f['target_text']; + $out['description_' . $suffix] = $f['description']; + $out['long_description_' . $suffix] = $f['long_description']; + $out['card_behavior_' . $suffix] = $f['card_behavior']; + $out['card_type_' . $suffix] = $f['card_type']; + $out['card_time_' . $suffix] = $f['card_time']; + $out['card_country_' . $suffix] = $f['card_country']; + $out['card_location_' . $suffix] = $f['card_location']; + $out['latitude_' . $suffix] = $f['latitude']; + $out['longitude_' . $suffix] = $f['longitude']; + $out['card_order_' . $suffix] = $f['card_order']; + $out['background_color_' . $suffix] = $f['background_color']; + $out['blog_id_' . $suffix] = $f['blog_id']; + $out['expiration_' . $suffix] = $f['expiration']; - - - - - $out['total_record'] = $ic; - } + //$out['card_action_type_' . $suffix] = $f['card_action_type']; + //$out['card_action_data_' . $suffix] = $f['card_action_data']; + $ic++; + } + } + $ret = PHP_API_OK; + $out["status"] = "OK"; return 0; }