<commit_before><?php
header('Access-Control-Allow-Origin: *');
defined('BASEPATH') OR exit('No direct script access allowed');

class School_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getSchool($argPost)
    {
        $query = $this->db->select('*')
            ->from('gsp_school')
            ->where(array('userid' => $argPost))
            ->get();
        if ($query->num_rows() > 0) {
            $row = $query->row();
            $school = array(
                'userid' => $row->userid,
                'name' => $row->name,
                'address1' => $row->address1,
                'address2' => $row->address2,
                'country' => $row->country,
                'state' => $row->state,
                'district' => $row->district,
                'city' => $row->city,
                'pincode' => $row->pincode,
                'std' => $row->std,
                'telephone' => $row->telephone,
                'country_code' => $row->country_code,
                'schoolemail' => $row->schoolemail,
                'principle_name' => $row->principle_name,
                'mobile' => $row->mobile,
                'coname' => $row->coname,
                'coemail' => $row->coemail,
                'comobile' => $row->comobile,
//<<<<<<< Updated upstream
                'progress'=>$row->progress,

//            );
//=======
//                'progress' => $row->progress,
//>>>>>>> Stashed changes

            );
            return $school;
        }
        return $school = array("name" => "Sunil");
    }

    public function RegisterUser($argPost)
    {
        $update = array(
            'userid' => $argPost['userid'],
            'name' => $argPost['name'],
            'address1' => $argPost['address1'],
            'address2' => $argPost['address2'],
            'country' => $argPost['country'],
            'state' => $argPost['state'],
            'district' => $argPost['district'],
            'city' => $argPost['city'],
            'pincode' => $argPost['pincode'],
            'std' => $argPost['std'],
            'telephone' => $argPost['telephone'],
            'country_code' => $argPost['country_code'],
            'schoolemail' => $argPost['schoolemail'],
            'principle_name' => $argPost['principle_name'],
            'mobile' => $argPost['mobile'],
            'coname' => $argPost['coname'],
            'coemail' => $argPost['coemail'],
            'comobile' => $argPost['comobile'],
            'date_added' => date('Y-m-d H:i:s')
        );
        if ($this->db->insert('gsp_school', $update)) {
            //Sending Mail To The School
            $insert_id = $this->db->insert_id();
            $query = $this->db->select('a.*, b.email AS emailfiled, b.password, b.username, c.name AS state_name, d.name AS district_name')
                ->from('gsp_school AS a')
                ->join('gsp_user AS b', 'a.userid=b.id', 'left')
                ->join('states AS c', 'a.state=c.id', 'left')
                ->join('cities AS d', 'a.district=d.id', 'left')
                ->where('a.id', $insert_id)
                ->get()->row();
			$date = date('d M Y H:i:s');
            //echo '<pre>'; print_r($query); exit;
            $this->load->library('email');
            $config['mailtype'] = 'html';
            $this->email->initialize($config);
            $from = "<EMAIL>";
//<<<<<<< Updated upstream
           // $arrMails=array($query->schoolemail, $query->coemail);
//=======
            $arrMails = array($query->schoolemail, $query->coemail, '<EMAIL>', '<EMAIL>', '<EMAIL>', '<EMAIL>');
//>>>>>>> Stashed changes
            $to = $arrMails;
            $subject = "GSP Audit Registration".$date;
            $msg = "Dear &nbsp;";
            $msg .= $query->coname . "," . "<br/><br/>";
            $msg .= "Thank you for registering your school '" . $query->name . "', for GSP (Green Schools Programme) Audit 2017. Your account has been successfully created.<br><br>";
            $msg .= "To participate in GSP Audit 2017, please remember to save your username and password given below.<br><br>";
//            $msg .= "The launch date of GSP Audit 2017 will be announced at www.greenschoolsprogramme.org, in July 2017.<br><br>";
            $msg .= "URL: http://www.greenschoolsprogramme.org/audit2017 <br/><br/>";
            $msg .= "Username: " . $query->coemail . "<br><br>";
            $msg .= "Password: " . $query->password . "<br><br>";
            $msg .= "In case of any further queries please feel free to write back to us.<br><br>";
            $msg .= "Thanks,<br><br>";
            $msg .= "The Green Schools Programme Team <br><br>";
            $msg .= "<strong>Your registration details are as follows: </strong><br><br>";
            $msg .= "Name of School: " . $query->name . "<br><br>";
            $msg .= "Address Line 1: " . $query->address1 . "<br><br>";
            $msg .= "Address Line 2: " . $query->address2 . "<br><br>";
            $msg .= "State: " . $query->state_name . "<br><br>";
            $msg .= "District: " . $query->district_name . "<br><br>";
            $msg .= "City: " . $query->city . "<br><br>";
            $msg .= "Pincode: " . $query->pincode . "<br><br>";
            $msg .= "Land Line No: " . "91 - " . $query->std . " - " . $query->telephone . "<br><br>";
            $msg .= "Principal's Name: " . $query->principle_name . "<br><br>";
            $msg .= "Moblile Number: " . $query->mobile . "<br><br>";
            $msg .= "GSP Coordinator's Name: " . $query->coname . "<br><br>";
            $msg .= "GSP Coordinator's Email: " . $query->coemail . "<br><br>";
            $msg .= "Mobile Number: " . $query->comobile . "<br><br>";
            $this->email->to($to);
            //$this->email->cc('<EMAIL>', '<EMAIL>', '<EMAIL>', '<EMAIL>');
            $this->email->from($from, "Green Schools Programme");
            $this->email->subject($subject);
            $this->email->message($msg);
            $this->email->send();
            //echo $this->email->print_debugger();
            //die();
            return true;
        }
    }

    public function GetRegistered()
    {
        $query = $this->db->select('*')
            ->from('gsp_school')
            ->get();
        if ($query->num_rows() > 0) {
            $row = $query->result_array();
            return $row;
        }
    }

    public function getSchools()
    {
        $query = $this->db->select('COUNT(*) count')
            ->from('gsp_school')
            ->get();
        $row = $query->row();
        return $row->count;
    }

    public function getState($stateID)
    {
        $data = $this->db->select('*')->where('id ', $stateID)->from('states')->get()->row()->name;
        return $data;
    }

    /*
     * Get Cities
     */
    public function getCity($cityID)
    {
        $data = $this->db->select('*')->where('id ', $cityID)->from('cities')->get()->row()->name;
        return $data;
    }

    public function SubmitAPIAnswers($data)
    {
        if (isset($data)) {
            try {
                $this->db->set($data['questionid'], $data['answer'])
                    ->where(array('userid' => $data['userid']))//which row want to upgrade
                    ->update('gsp_school');
                return "SCHOOL Updated";
            } catch (Exception $e) {
                return "Invalid Key";
            }
        }
    }
}

?>
<commit_msg>Update School_model.php<commit_after><?php
header('Access-Control-Allow-Origin: *');
defined('BASEPATH') OR exit('No direct script access allowed');

class School_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function getSchool($argPost)
    {
        $query = $this->db->select('*')
            ->from('gsp_school')
            ->where(array('userid' => $argPost))
            ->get();
        if ($query->num_rows() > 0) {
            $row = $query->row();
            $school = array(
                'userid' => $row->userid,
                'name' => $row->name,
                'address1' => $row->address1,
                'address2' => $row->address2,
                'country' => $row->country,
                'state' => $row->state,
                'district' => $row->district,
                'city' => $row->city,
                'pincode' => $row->pincode,
                'std' => $row->std,
                'telephone' => $row->telephone,
                'country_code' => $row->country_code,
                'schoolemail' => $row->schoolemail,
                'principle_name' => $row->principle_name,
                'mobile' => $row->mobile,
                'coname' => $row->coname,
                'coemail' => $row->coemail,
                'comobile' => $row->comobile,
//<<<<<<< Updated upstream
                'progress'=>$row->progress,

//            );
//=======
//                'progress' => $row->progress,
//>>>>>>> Stashed changes

            );
            return $school;
        }
        return $school = array("name" => "Sunil");
    }

    public function RegisterUser($argPost)
    {
        $update = array(
            'userid' => $argPost['userid'],
            'name' => $argPost['name'],
            'address1' => $argPost['address1'],
            'address2' => $argPost['address2'],
            'country' => $argPost['country'],
            'state' => $argPost['state'],
            'district' => $argPost['district'],
            'city' => $argPost['city'],
            'pincode' => $argPost['pincode'],
            'std' => $argPost['std'],
            'telephone' => $argPost['telephone'],
            'country_code' => $argPost['country_code'],
            'schoolemail' => $argPost['schoolemail'],
            'principle_name' => $argPost['principle_name'],
            'mobile' => $argPost['mobile'],
            'coname' => $argPost['coname'],
            'coemail' => $argPost['coemail'],
            'comobile' => $argPost['comobile'],
            'date_added' => date('Y-m-d H:i:s')
        );
        if ($this->db->insert('gsp_school', $update)) {
            //Sending Mail To The School
            $insert_id = $this->db->insert_id();
            $query = $this->db->select('a.*, b.email AS emailfiled, b.password, b.username, c.name AS state_name, d.name AS district_name')
                ->from('gsp_school AS a')
                ->join('gsp_user AS b', 'a.userid=b.id', 'left')
                ->join('states AS c', 'a.state=c.id', 'left')
                ->join('cities AS d', 'a.district=d.id', 'left')
                ->where('a.id', $insert_id)
                ->get()->row();
			$date = date('d M Y');
            //echo '<pre>'; print_r($query); exit;
            $this->load->library('email');
            $config['mailtype'] = 'html';
            $this->email->initialize($config);
            $from = "<EMAIL>";
//<<<<<<< Updated upstream
           // $arrMails=array($query->schoolemail, $query->coemail);
//=======
            $arrMails = array($query->schoolemail, $query->coemail, '<EMAIL>', '<EMAIL>', '<EMAIL>', '<EMAIL>');
//>>>>>>> Stashed changes
            $to = $arrMails;
            $subject = "GSP Audit Registration".$date;
            $msg = "Dear &nbsp;";
            $msg .= $query->coname . "," . "<br/><br/>";
            $msg .= "Thank you for registering your school '" . $query->name . "', for GSP (Green Schools Programme) Audit 2017. Your account has been successfully created.<br><br>";
            $msg .= "To participate in GSP Audit 2017, please remember to save your username and password given below.<br><br>";
//            $msg .= "The launch date of GSP Audit 2017 will be announced at www.greenschoolsprogramme.org, in July 2017.<br><br>";
            $msg .= "URL: http://www.greenschoolsprogramme.org/audit2017 <br/><br/>";
            $msg .= "Username: " . $query->coemail . "<br><br>";
            $msg .= "Password: " . $query->password . "<br><br>";
            $msg .= "In case of any further queries please feel free to write back to us.<br><br>";
            $msg .= "Thanks,<br><br>";
            $msg .= "The Green Schools Programme Team <br><br>";
            $msg .= "<strong>Your registration details are as follows: </strong><br><br>";
            $msg .= "Name of School: " . $query->name . "<br><br>";
            $msg .= "Address Line 1: " . $query->address1 . "<br><br>";
            $msg .= "Address Line 2: " . $query->address2 . "<br><br>";
            $msg .= "State: " . $query->state_name . "<br><br>";
            $msg .= "District: " . $query->district_name . "<br><br>";
            $msg .= "City: " . $query->city . "<br><br>";
            $msg .= "Pincode: " . $query->pincode . "<br><br>";
            $msg .= "Land Line No: " . "91 - " . $query->std . " - " . $query->telephone . "<br><br>";
            $msg .= "Principal's Name: " . $query->principle_name . "<br><br>";
            $msg .= "Moblile Number: " . $query->mobile . "<br><br>";
            $msg .= "GSP Coordinator's Name: " . $query->coname . "<br><br>";
            $msg .= "GSP Coordinator's Email: " . $query->coemail . "<br><br>";
            $msg .= "Mobile Number: " . $query->comobile . "<br><br>";
            $this->email->to($to);
            //$this->email->cc('<EMAIL>', '<EMAIL>', '<EMAIL>', '<EMAIL>');
            $this->email->from($from, "Green Schools Programme");
            $this->email->subject($subject);
            $this->email->message($msg);
            $this->email->send();
            //echo $this->email->print_debugger();
            //die();
            return true;
        }
    }

    public function GetRegistered()
    {
        $query = $this->db->select('*')
            ->from('gsp_school')
            ->get();
        if ($query->num_rows() > 0) {
            $row = $query->result_array();
            return $row;
        }
    }

    public function getSchools()
    {
        $query = $this->db->select('COUNT(*) count')
            ->from('gsp_school')
            ->get();
        $row = $query->row();
        return $row->count;
    }

    public function getState($stateID)
    {
        $data = $this->db->select('*')->where('id ', $stateID)->from('states')->get()->row()->name;
        return $data;
    }

    /*
     * Get Cities
     */
    public function getCity($cityID)
    {
        $data = $this->db->select('*')->where('id ', $cityID)->from('cities')->get()->row()->name;
        return $data;
    }

    public function SubmitAPIAnswers($data)
    {
        if (isset($data)) {
            try {
                $this->db->set($data['questionid'], $data['answer'])
                    ->where(array('userid' => $data['userid']))//which row want to upgrade
                    ->update('gsp_school');
                return "SCHOOL Updated";
            } catch (Exception $e) {
                return "Invalid Key";
            }
        }
    }
}

?>

{'fraction_non_alphanumeric': 0.2049759871931697, 'fraction_numerical': 0.0048025613660619, 'mean_word_length': 1.7982456140350878, 'pattern_counts': {'":': 0, '<': 153, '<?xml version=': 0, '>': 461, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1990500', 'n_tokens_mistral': 4645, 'n_tokens_neox': 4480, 'n_words': 924}