368 lines
14 KiB
PHP
Executable File
368 lines
14 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Date: 11/9/17
|
|
* Time: 5:28 PM
|
|
*/
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class University_model extends CI_Model
|
|
{
|
|
|
|
/*
|
|
* get university details
|
|
* params:
|
|
* created by kdk
|
|
* */
|
|
|
|
/*
|
|
* get University Details
|
|
*/
|
|
|
|
// get university list
|
|
public function get_university_list() {
|
|
$this->db->select('*');
|
|
$this->db->order_by('CreatedOn', 'DESC');
|
|
$this->db->from(UNIVERSITY);
|
|
$univDetails = $this->db->get();
|
|
$universityDetails = $univDetails->result();
|
|
if (count($universityDetails) > 0) {
|
|
$results['univList'] = true;
|
|
$results['university_details'] = $universityDetails;
|
|
} else {
|
|
$results['univList'] = false;
|
|
$results['message'] = 'No record found';
|
|
}
|
|
return $results;
|
|
}
|
|
|
|
// update univesity details
|
|
public function update_university_details($updateFor, $Arr) {
|
|
$this->db->where('UniversityID', $updateFor);
|
|
$this->db->update(UNIVERSITY, $Arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['updateUniversityStatus'] = true;
|
|
$result['message'] = "Successfully University details Updated";
|
|
} else {
|
|
$result['updateUniversityStatus'] = false;
|
|
$result['message'] = "Successfully University details Updated";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// check exist details
|
|
public function check_Univ_Exist($data, $check) {
|
|
// check update for mobile number
|
|
$this->db->select('*');
|
|
$this->db->from(UNIVERSITY);
|
|
$this->db->where('UniversityID', $data);
|
|
if ($this->db->get()->first_row()) {
|
|
$result['existUniv'] = true;
|
|
$result['message'] = "This University Id is already exist!";
|
|
} else {
|
|
$result['existUniv'] = false;
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
// add university details
|
|
public function insert_Univ($arr) {
|
|
$this->db->insert(UNIVERSITY, $arr);
|
|
if ($this->db->affected_rows() == '1') {
|
|
$result['addUniv'] = true;
|
|
$result['message'] = "Successfully University details added";
|
|
} else {
|
|
$result['addUniv'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
public function addActivity($arrayDetails=null,$jsonData=null)
|
|
{
|
|
$this->db->select('ActivityID,ActivityName');
|
|
|
|
$this->db->where('ActivityName', $arrayDetails['ActivityName']);
|
|
|
|
if($this->db->get(ACTIVITY)->first_row()){
|
|
$result['activityStatus'] = false;
|
|
$result['message'] = "Activity name is already exist!";
|
|
}
|
|
else{
|
|
|
|
$this->db->insert(ACTIVITY, $arrayDetails);
|
|
if($this->db->affected_rows() == '1'){
|
|
$last = $this->db->order_by('ActivityID',"desc")->limit(1)->get(ACTIVITY)->row();
|
|
$lastActivityID=$last->ActivityID;
|
|
|
|
if($jsonData){
|
|
|
|
foreach ($jsonData as $srow){
|
|
$status_array["StatusName"]=$srow['id'];
|
|
$status_array["ActivityID"]=$lastActivityID;
|
|
$status_array["IsActive"]=$arrayDetails['IsActive'];
|
|
$status_array["CreatedBy"]=$arrayDetails['CreatedBy'];
|
|
$status_array["CreatedOn"]=$arrayDetails['CreatedOn'];
|
|
$this->db->insert(ACTIVITY_STATUS, $status_array);
|
|
}
|
|
}
|
|
$result['activityStatus'] = true;
|
|
$result['message'] = "Successfully activity details added";
|
|
|
|
}
|
|
else {
|
|
$result['activityStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
/*
|
|
* get Activity details
|
|
* parama id
|
|
* created by Surendiran
|
|
* */
|
|
|
|
public function getActivity()
|
|
{
|
|
$this->db->distinct();
|
|
$this->db->select('ActivityID,ActivityName,Description,IsActive');
|
|
$this->db->order_by('ActivityID','DESC');
|
|
$activityDetails=$this->db->get(ACTIVITY);
|
|
if($activityDetails->result()){
|
|
|
|
$activity_result['activityStatus'] = true;
|
|
foreach ($activityDetails->result() as $row){
|
|
$result_array['ActivityID'] = $row->ActivityID;
|
|
$result_array['ActivityName'] = $row->ActivityName;
|
|
$result_array['IsActive'] = $row->IsActive;
|
|
$result_array['Description'] = $row->Description;
|
|
$this->db->select('AVS.StatusID,PLD.ListCode,PLD.ListName');
|
|
$this->db->from(ACTIVITY_STATUS .' as AVS');
|
|
$this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = AVS.StatusName');
|
|
$this->db->where('AVS.ActivityID',$row->ActivityID);
|
|
$this->db->where('AVS.IsActive','1');
|
|
$result_array['statusDetails']=$this->db->get()->result();
|
|
$result[]=$result_array;
|
|
}
|
|
|
|
$activity_result['details'] = $result;
|
|
|
|
|
|
}
|
|
else {
|
|
$activity_result['activityStatus'] = false;
|
|
$activity_result['details'] = "No records found!";
|
|
}
|
|
$activity_result['masterStatusList']=$this->getAllStatusList('1');
|
|
return $activity_result;
|
|
|
|
}
|
|
/*
|
|
* get status details
|
|
* created by kms
|
|
* */
|
|
|
|
public function getAllStatusList($groupName=null)
|
|
{
|
|
$this->db->select('ListCode,ListName');
|
|
$this->db->where('ListGroup',$groupName);
|
|
$this->db->where('IsActive','1');
|
|
$this->db->order_by('ListCode','ASC');
|
|
$status = $this->db->get(PICK_LIST_DETAILS);
|
|
return $status->result();
|
|
}
|
|
|
|
|
|
/*
|
|
* update activity details details
|
|
* created by Surendiran
|
|
* */
|
|
public function updateActivity($arrayDetails=null,$jsonData=null) {
|
|
|
|
$this->db->select('ActivityName');
|
|
$this->db->where('ActivityName',$arrayDetails['ActivityName']);
|
|
$this->db->where('ActivityID !=',$arrayDetails['ActivityID']);
|
|
if($this->db->get(ACTIVITY)->first_row()){
|
|
$result['activityStatus'] = false;
|
|
$result['message'] = "Activity name is already exist!";
|
|
}
|
|
else{
|
|
|
|
$this->db->where('ActivityID ',$arrayDetails['ActivityID']);
|
|
$updateStatus=$this->db->update(ACTIVITY, $arrayDetails);
|
|
if($updateStatus){
|
|
$deactiveStatus['IsActive']=false;
|
|
$deactiveStatus['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
|
$deactiveStatus['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
|
$this->db->where('ActivityID ',$arrayDetails['ActivityID']);
|
|
$updateActivityStatusDeactive = $this->db->update(ACTIVITY_STATUS, $deactiveStatus);
|
|
if($updateActivityStatusDeactive){
|
|
|
|
if($jsonData){
|
|
|
|
foreach ($jsonData as $urow){
|
|
|
|
$this->db->select('StatusName');
|
|
$this->db->where('StatusName',$urow);
|
|
$this->db->where('ActivityID',$arrayDetails['ActivityID']);
|
|
if($this->db->get(ACTIVITY_STATUS)->first_row()){
|
|
$existStatusUpdate['IsActive']=true;
|
|
$existStatusUpdate['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
|
$existStatusUpdate['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
|
$this->db->where('StatusName',$urow);
|
|
$this->db->where('ActivityID',$arrayDetails['ActivityID']);
|
|
$this->db->update(ACTIVITY_STATUS, $existStatusUpdate);
|
|
}
|
|
else{
|
|
$update_array["StatusName"]=$urow;
|
|
$update_array["ActivityID"]=$arrayDetails['ActivityID'];
|
|
$update_array["IsActive"]=true;
|
|
$update_array["CreatedBy"]=$arrayDetails['UpdatedBy'];
|
|
$update_array["CreatedOn"]=$arrayDetails['UpdatedOn'];
|
|
$this->db->insert(ACTIVITY_STATUS, $update_array);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
else{
|
|
$activateStatus['IsActive']=true;
|
|
$this->db->where('ActivityID ',$arrayDetails['ActivityID']);
|
|
$this->db->update(ACTIVITY_STATUS, $activateStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
$result['activityStatus'] = true;
|
|
$result['message'] = "Successfully activity details updated";
|
|
}
|
|
|
|
|
|
}
|
|
else {
|
|
$result['activityStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
/*
|
|
* get default activity details
|
|
* created by kms
|
|
* */
|
|
public function getDefaultActivity()
|
|
{
|
|
$arr = array('ListGroup'=>2,'ListGroup'=>6);
|
|
$this->db->distinct();
|
|
$this->db->select('ListName,ListCode,IsActive');
|
|
$this->db->order_by('ListName','ASC');
|
|
$this->db->or_where('ListGroup','2');
|
|
$this->db->or_where('ListGroup','6');
|
|
$this->db->or_where('ListGroup','7');
|
|
$this->db->or_where('ListGroup','8');
|
|
$this->db->or_where('ListGroup','9');
|
|
$defaultActivityDetails=$this->db->get(PICK_LIST_DETAILS);
|
|
if($defaultActivityDetails->result()){
|
|
$activity_result['activityStatus'] = true;
|
|
foreach ($defaultActivityDetails->result() as $row){
|
|
$result_array['ActivityID'] = $row->ListCode;
|
|
$result_array['ActivityName'] = $row->ListName;
|
|
$result_array['IsActive'] = $row->IsActive;
|
|
$this->db->select('DA.StudentActivityCode,PLD.ListCode,PLD.ListName');
|
|
$this->db->from(DEFAULTACTIVITY .' as DA');
|
|
$this->db->join(PICK_LIST_DETAILS.' as PLD', 'PLD.ListCode = DA.StatusCode');
|
|
// $this->db->where('PLD.IsActive','1');
|
|
$this->db->where('DA.IsActive','1');
|
|
$this->db->where('DA.StudentActivityCode',$row->ListCode);
|
|
$result_array['statusDetails']=$this->db->get()->result();
|
|
$result[]=$result_array;
|
|
}
|
|
|
|
$activity_result['details'] = $result;
|
|
|
|
|
|
}
|
|
else {
|
|
$activity_result['activityStatus'] = false;
|
|
$activity_result['details'] = "No records found!";
|
|
}
|
|
$activity_result['masterStatusList']=$this->getAllStatusList('1');
|
|
return $activity_result;
|
|
|
|
}
|
|
/*
|
|
* update default activity status
|
|
* created by kms
|
|
* */
|
|
public function updateDefaultActivity($arrayDetails=null,$jsonData=null) {
|
|
|
|
|
|
$deactiveStatus['IsActive']=false;
|
|
$deactiveStatus['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
|
$deactiveStatus['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
|
$this->db->where('StudentActivityCode ',$arrayDetails['StudentActivityCode']);
|
|
$updateActivityStatusDeactive = $this->db->update(DEFAULTACTIVITY, $deactiveStatus);
|
|
if($updateActivityStatusDeactive){
|
|
|
|
if($jsonData){
|
|
|
|
foreach ($jsonData as $urow){
|
|
|
|
$this->db->select('StatusCode');
|
|
$this->db->where('StatusCode',$urow);
|
|
$this->db->where('StudentActivityCode',$arrayDetails['StudentActivityCode']);
|
|
if($this->db->get(DEFAULTACTIVITY)->first_row()){
|
|
$existStatusUpdate['IsActive']=true;
|
|
$existStatusUpdate['UpdatedBy']=$arrayDetails['UpdatedBy'];
|
|
$existStatusUpdate['UpdatedOn']=$arrayDetails['UpdatedOn'];
|
|
$this->db->where('StatusCode',$urow);
|
|
$this->db->where('StudentActivityCode',$arrayDetails['StudentActivityCode']);
|
|
$this->db->update(DEFAULTACTIVITY, $existStatusUpdate);
|
|
}
|
|
else{
|
|
$update_array["StatusCode"]=$urow;
|
|
$update_array["StudentActivityCode"]=$arrayDetails['StudentActivityCode'];
|
|
$update_array["IsActive"]=true;
|
|
$update_array["CreatedBy"]=$arrayDetails['UpdatedBy'];
|
|
$update_array["CreatedOn"]=$arrayDetails['UpdatedOn'];
|
|
$this->db->insert(DEFAULTACTIVITY, $update_array);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
/*else{
|
|
$activateStatus['IsActive']=true;
|
|
$this->db->where('StudentActivityCode ',$arrayDetails['StudentActivityCode']);
|
|
$this->db->update(DEFAULTACTIVITY, $activateStatus);
|
|
|
|
}*/
|
|
|
|
|
|
|
|
$result['activityStatus'] = true;
|
|
$result['message'] = "Successfully status updated";
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
$result['activityStatus'] = false;
|
|
$result['message'] = "Something went wrong.please try again";
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
}
|
|
|
|
} |