apollo_developers/api/application/models/Batch_model.php
venbatechnologies@gmail.com 1809bcf9c9 fixed table for student details
2018-04-23 18:34:11 +05:30

141 lines
3.8 KiB
PHP
Executable File

<?php
/**
* Created by Visual Code studio
* User: Subaram
* Date: 11/26/17
* Time: 10:05 PM
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class Batch_model extends CI_Model {
/*
* Add batch details
* created by subaram
* */
public function addBatch($arrayDetails=null)
{
$this->db->select('BatchCode');
$this->db->where('BatchCode', $arrayDetails['BatchCode']);
if($this->db->get(BATCH)->first_row()){
$result['batchStatus'] = false;
$result['message'] = "This batch code is already exist.";
} else {
$this->db->insert(BATCH, $arrayDetails);
if ($this->db->affected_rows() == '1') {
$result['batchStatus'] = true;
$result['message'] = "Successfully Batch details added";
} else {
$result['batchStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
}
return $result;
}
/*
* Get batch details
* parama id
* created by srk
* */
public function getBatch()
{
$this->db->select('CU.BatchCode,CU.BatchName,CU.IsActive,CU.BatchDate,CU.IsDefault,US.UniversityID,US.UniversityName');
$this->db->from(BATCH.' as CU');
$this->db->join(UNIVERSITY.' as US', 'US.UniversityID = CU.UniversityID');
$this->db->order_by('CU.CreatedOn','DESC');
$batchDetails = $this->db->get();
if($batchDetails->result()){
$result['batchStatus'] = true;
$result['details'] = $batchDetails->result();
}
else {
$result['batchStatus'] = false;
$result['message'] = "No records found!";
}
$result['universityDetails'] = $this->getUniversityDetails();
return $result;
}
/*
* update batch details
* created by Srk
* */
public function updateBatch($arrayDetails=null)
{
$this->db->where('BatchCode',$arrayDetails['BatchCode']);
$upateStatus=$this->db->update(BATCH, $arrayDetails);
if($upateStatus){
$result['batchStatus'] = true;
$result['message'] = "Successfully Batch details updated";
}
else {
$result['batchStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
/*
* Get university details
* created by Srk
* */
public function getUniversityDetails()//doubt
{
$this->db->select('UniversityID,UniversityName');
$this->db->order_by('UniversityID','ASC');
$this->db->where('IsActive','1');
// $this->db->where_not_in('ID', $id);
$universityDetails = $this->db->get(UNIVERSITY);
return $universityDetails->result();
}
/*
* update default batch
* created by kms
* */
public function updateDefaultBatch($details=null){
$setDefaultBatch['IsDefault']=false;
$setDefaultBatch['UpdatedBy'] = $details['UpdatedBy'];
$setDefaultBatch['UpdatedOn'] = $details['UpdatedOn'];
// $this->db->where('BatchCode',$details['BatchCode']);
$this->db->where('UniversityID',$details['UniversityID']);
$upateStatus=$this->db->update(BATCH, $setDefaultBatch);
if($upateStatus){
$this->db->where('BatchCode',$details['BatchCode']);
$this->db->where('UniversityID',$details['UniversityID']);
$upateAfterStatus=$this->db->update(BATCH, $details);
$result['batchStatus'] = true;
$result['message'] = "Successfully Batch details updated";
}
else {
$result['batchStatus'] = false;
$result['message'] = "Something went wrong.please try again";
}
return $result;
}
}