<?php

namespace App\Controllers;

//use CodeIgniter\API\ResponseTrait;
//$routes->post('/en/wrench/api/v1/faq',     'WrenchFaq::apigate');
class WrenchFaq extends BaseController
{

    //use ResponseTrait;
    // protected $db;
   // public $con_name = 'wrench_blog';

    public function learnMoreUser(){
        $total = 3;
        $data=[];
        $raw_json = file_get_contents('php://input');
        $in = json_decode($raw_json, true);

        $msgS = "<div style='width: 100%; min-height: 300px; border-radius: 10px; background-color: whitesmoke; padding: 10px;'>
                <b>Task and Jobs </b>
                <br>
                <iframe style='width: 100%; min-height: 250px; height: auto' width='100%'  src='https://www.youtube.com/embed/GhSxT7rk0y8?si=Q4guiwdl9vBmmQKF' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' referrerpolicy='strict-origin-when-cross-origin' allowfullscreen></iframe>
                <br>
                  <b>Go Further and Faster </b>
                  <br><hr>
                Looking for a platform to push that next campaign or get real feedback on that great app feature or just any task, connect with our thriving community to get it done fast.

                <br>
                <b><hr > </b>
                <br>
                <iframe style='width: 100%; min-height: 250px; height: auto' width='100%'  src='https://www.youtube.com/embed/GhSxT7rk0y8?si=Q4guiwdl9vBmmQKF' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' referrerpolicy='strict-origin-when-cross-origin' allowfullscreen></iframe>
                            <br>
                  <b>Do more. </b>
                  <br><hr>
                <br>
                Ready to launch your next campaign, get real feedback on your app, or tackle any task? Connect with our vibrant community for fast, affordable results.
                </div>";
        $data["result_list"][] = array(
            "uid" => '0000-0000-0000-000 A1',
            "topic" => "Task & Jobs ",
            "contents" => $msgS
        );

        $msgS = "<div style='width: 100%; min-height: 300px; border-radius: 10px; background-color: whitesmoke; padding: 10px;'>
                <b>Take the Stress Out and excite your kids to do more! </b>
                <br>
                <iframe style='width: 100%; min-height: 250px; height: auto' width='100%'  src='https://www.youtube.com/embed/GhSxT7rk0y8?si=Q4guiwdl9vBmmQKF' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' referrerpolicy='strict-origin-when-cross-origin' allowfullscreen></iframe>
                <br>
                Take the stress out of getting your kids excited about learning life skills! Leverage the science of motivation and go beyond chores to build a system of growth where families connect to inspire kids.
                 </div>";
        $data["result_list"][] = array(
            "uid" => '0000-0000-0000-000 A2',
            "topic" => "Family",
            "contents" => $msgS
        );

        $msgS = "<div style='width: 100%; min-height: 300px; border-radius: 10px; background-color: whitesmoke; padding: 10px;'>
                <b>Rewards  </b>
                <br>
                <iframe style='width: 100%; min-height: 250px; height: auto' width='100%'  src='https://www.youtube.com/embed/GhSxT7rk0y8?si=Q4guiwdl9vBmmQKF' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' referrerpolicy='strict-origin-when-cross-origin' allowfullscreen></iframe>
                <br>
                <b>Flexible and Customizable Rewards </b><br><hr>
                Our reward system is flexible because we know motivation differs for each person. We empower you to match reward with motivation to celebrate achievement.
                . </div>";
        $data["result_list"][] = array(
            "uid" => '0000-0000-0000-000 A3',
            "topic" => "Rewards",
            "contents" => $msgS
        );

        $msgS = "<div style='width: 100%; min-height: 300px; border-radius: 10px; background-color: whitesmoke; padding: 10px;'>
                <b>Playground  </b>
                <br>
                <iframe style='width: 100%; min-height: 250px; height: auto' width='100%'  src='https://www.youtube.com/embed/GhSxT7rk0y8?si=Q4guiwdl9vBmmQKF' title='YouTube video player' frameborder='0' allow='accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share' referrerpolicy='strict-origin-when-cross-origin' allowfullscreen></iframe>
                <br>
                <b>Interact and Explore </b><br><hr>
                Kids interact and explore with a suite of carefully selected content and games aimed at helping them learn financial skills. AI adapts to each child's unique learning style, ensuring personalized experiences that grow with them
                . </div>";
        $data["result_list"][] = array(
            "uid" => '0000-0000-0000-000 A4',
            "topic" => "Playground",
            "contents" => $msgS
        );

        return  $this->summaryReturnData($in,$data); //json_encode( $final_out );
    }

    public function apigate(){
        return json_encode( $this->apiFaqData() );
    }
    private function apiFaqData() {

        $total = 1;

        $data = array(
            "status" => 100,
            "total_record" => ($total - 1),
            "internal_return" => 0,
            "result_list" => array(),
        );
        $data["result_list"][] = array(
            "public" => "1",
            "title" => "What is WrenchBoard ?",
            "msg" => "WrenchBoard is the platform to set and rewards goals. Easily create plans for your kids or family, reward completion, or find others to perform tasks for you, or you can find opportunities to earn from any skill. ",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "How can I use WrenchBoard ?",
            "msg" => "Create your free account, add family and kids, and create and assign tasks. Reward when completed, or use your account to find the opportunity to earn rewards.  ",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "What is WrenchBoard family account ? ",
            "msg" => "WrenchBoard allows you to create accounts for your family or kids, assign specific goals, and reward achievements from the parent's account.",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "What is WrenchBoard Family Login ?",
            "msg" => "The family account is a subset of your account that you can manage from your account. You can control the task and earnings from your account, which will be the parent account. ",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "Do I need different account to post or perform task ?",
            "msg" => "You can use your one account to perform any variety of activities. You dont need a separate account.  ",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "Does WrenchBoard work on mobile devices?",
            "msg" => "Yes, you can browse from your mobile device. For the best experience, use our native app from app stores. ",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "What is WrenchBoard Market ?",
            "msg" => "The market is the place to see all jobs posted to the public, you can raise your hand by showing interest, and the owner can approve you starting the task. ",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "How does WrenchBoard protect my privacy?",
            "msg" => "We value the privacy of our patrons, and with this in our backbone, we strive to employ the best industry standards and practices to protect all privacy. We continuously abreast ourselves with the growing threat and endeavor to ensure we are always a step ahead. ",
        );

        $data["result_list"][] = array(
            "public" => "0",
            "title" => "What can I do with my wallet?",
            "msg" => "You can redeem your balance, transfer to your bank accounts, or any available options.",
        );

        $data["result_list"][] = array(
            "public" => "1",
            "title" => "How do I contact WrenchBoard Support?",
            "msg" => "We are here to hear you and assist you in any way possible. The best way is to go into your account and send a message to support or use our chat or support email.",
        );


        return $data;
    }


    public function helpgate(){
        return json_encode( $this->apiHelpData() );
    }
    private function apiHelpData() {

        $local_out =[];
        $call_backend = true;
        //  $local_out = $this->dummyData();
        $in["action"]=WRENCHBOARD_ACCT_HELPITEMS;
        $in["limit"]=20;
        $in["page"]=0;
        $in["member_id"]=0;
        if ( $call_backend ==  true  && $in["action"] !='' ){
            $wrenchboard = new  \App\Models\BackendModel();
            $ret = $wrenchboard->wrenchboard_api($in, $out);
            $out['internal_return'] = $ret;
        }
        else
        {
            $out =  $local_out;
        }

        $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(
                "title" => $out["title_${key}"],
                "uid" => $out["uid_${key}"],
                "public" => "1",
                "vid" => (rand(0,1)> 0) ? "https://www.youtube.com/embed/xZ4o180KFNk?si=zGuIgpfTb-Tc0o3H":'',
                "icon" => $out["icon_${key}"],
                "msg" => $out["contents_${key}"],
                "date" => $out["added_${key}"],

            );
        }

        return $res;
    }
}