<?php
namespace App\Models;

use CodeIgniter\Model;

class myfitResetPass extends baseModel
{
   // protected $db;
  //  public $con_name = 'mermsemr';

    public function __construct()
    {
        parent::__construct();
      //  $this->db = \Config\Database::connect($this->con_name);
    }

    /*
      Reset password will be in stages 

      STAGE 1 : Resquest _start password change - user get a code 
    */
    public function resetPass($in)
    {
        $change_state = $in['stage'];

        switch ($change_state) {
            case START_PASS_CHANGE:
                $this->startPassReset($in);
                break;

            case CONFIRM_PASS_PIN:
                break;

            case CONFIRM_PASS_CHANGE:
                break;
        }

        $reminder_category = [];
        $sqlQ = 'SELECT * FROM members_resetpass';

        $query = $this->db->query($sqlQ);
        $data['resetpass_data'] = $query->getResultArray();
        return $inx = [
            'reminder_category' => $reminder_category,
            'reminders' => $data['resetpass_data'],
            'status' => 1,
            'raw_data' => $in,
        ];
    }

    private startPassReset($in){
        $username = trim($in['username']);
        $sqlQ = "SELECT * FROM members WHERE username='".$username."' ";
        $query = $this->db->query($sqlQ);
        if($query &&  count($query->getResultArray())== 0  ){
        
            
        }
        else{
            $valid_call=false;
            $error_msg='Unable to continue';
            $status=-1;  
        }
        return 0;
    }
}
