master module 4 vadivel J 27-12-2024
This commit is contained in:
parent
abe5758e00
commit
817d2882ec
@ -251,9 +251,18 @@ class Department extends BaseController
|
|||||||
|
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$departmentName = str_replace(" ","",$data['departmentName']);
|
$departmentName = str_replace(" ","",$data['departmentName']);
|
||||||
$depCode =$data['depCode'];
|
|
||||||
|
$depCode = $data['depCode'];
|
||||||
|
|
||||||
|
$headDepCode =$data['headDepCode'];
|
||||||
|
|
||||||
$departmentName = $data['departmentName'];
|
$departmentName = $data['departmentName'];
|
||||||
$result = $this->department_model->checkDepartmentName($depCode,$departmentName);
|
|
||||||
|
$departmentName = str_replace(" ","",$departmentName);
|
||||||
|
|
||||||
|
$result = $this->department_model->checkDepartmentName($departmentName , $headDepCode , $depCode);
|
||||||
|
|
||||||
|
|
||||||
return $this->response->setJSON($result);
|
return $this->response->setJSON($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
@ -10,38 +11,38 @@ class Department_model extends Model
|
|||||||
* @param string $searchText : This is optional search text
|
* @param string $searchText : This is optional search text
|
||||||
* @return number $count : This is row count
|
* @return number $count : This is row count
|
||||||
*/
|
*/
|
||||||
// function departmentListingCount($searchText = '')
|
// function departmentListingCount($searchText = '')
|
||||||
// {
|
// {
|
||||||
// ->select('BaseT.DepartmentID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration,BaseT.TIN,BaseT.PAN,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT');
|
// ->select('BaseT.DepartmentID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration,BaseT.TIN,BaseT.PAN,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT');
|
||||||
// $builder = $this->db->table('t_departmentdetails as BaseT');
|
// $builder = $this->db->table('t_departmentdetails as BaseT');
|
||||||
// //->join('tbl_users as users', 'users.userId = BaseT.userId','left');
|
// //->join('tbl_users as users', 'users.userId = BaseT.userId','left');
|
||||||
// //->join('T_SupplierDetails as ID', 'ID.DepartmentID = BaseT.DepartmentID','left');
|
// //->join('T_SupplierDetails as ID', 'ID.DepartmentID = BaseT.DepartmentID','left');
|
||||||
// if(!empty($searchText)) {
|
// if(!empty($searchText)) {
|
||||||
// $likeCriteria = "(BaseT.DepartmentID LIKE '%".$searchText."%'
|
// $likeCriteria = "(BaseT.DepartmentID LIKE '%".$searchText."%'
|
||||||
// OR BaseT.SupplierName LIKE '%".$searchText."%'
|
// OR BaseT.SupplierName LIKE '%".$searchText."%'
|
||||||
// OR BaseT.Address LIKE '%".$searchText."%'
|
// OR BaseT.Address LIKE '%".$searchText."%'
|
||||||
// OR BaseT.ContactNumber LIKE '%".$searchText."%'
|
// OR BaseT.ContactNumber LIKE '%".$searchText."%'
|
||||||
// OR BaseT.AlternateContactNumber LIKE '%".$searchText."%'
|
// OR BaseT.AlternateContactNumber LIKE '%".$searchText."%'
|
||||||
// OR BaseT.EmailAddress LIKE '%".$searchText."%'
|
// OR BaseT.EmailAddress LIKE '%".$searchText."%'
|
||||||
// OR BaseT.Exiseregistration LIKE '%".$searchText."%'
|
// OR BaseT.Exiseregistration LIKE '%".$searchText."%'
|
||||||
// OR BaseT.TIN LIKE '%".$searchText."%'
|
// OR BaseT.TIN LIKE '%".$searchText."%'
|
||||||
// OR BaseT.PAN LIKE '%".$searchText."%'
|
// OR BaseT.PAN LIKE '%".$searchText."%'
|
||||||
// OR BaseT.GSTNO LIKE '%".$searchText."%'
|
// OR BaseT.GSTNO LIKE '%".$searchText."%'
|
||||||
// OR BaseT.GSTRange LIKE '%".$searchText."%'
|
// OR BaseT.GSTRange LIKE '%".$searchText."%'
|
||||||
// OR BaseT.CollectrateAddress LIKE '%".$searchText."%'
|
// OR BaseT.CollectrateAddress LIKE '%".$searchText."%'
|
||||||
// OR BaseT.UANumber LIKE '%".$searchText."%'
|
// OR BaseT.UANumber LIKE '%".$searchText."%'
|
||||||
// OR BaseT.PaymentTerms LIKE '%".$searchText."%'
|
// OR BaseT.PaymentTerms LIKE '%".$searchText."%'
|
||||||
// OR BaseT.PaymentDays LIKE '%".$searchText."%'
|
// OR BaseT.PaymentDays LIKE '%".$searchText."%'
|
||||||
// OR BaseT.PayableAT LIKE '%".$searchText."%')";
|
// OR BaseT.PayableAT LIKE '%".$searchText."%')";
|
||||||
// $this->db->where($likeCriteria);
|
// $this->db->where($likeCriteria);
|
||||||
// }
|
// }
|
||||||
// //$this->db->where('BaseT.isDeleted', 0);
|
// //$this->db->where('BaseT.isDeleted', 0);
|
||||||
// //$this->db->where('BaseT.userId !=', 1);
|
// //$this->db->where('BaseT.userId !=', 1);
|
||||||
// $query =$builder->get();
|
// $query =$builder->get();
|
||||||
|
|
||||||
// return count($query-getResult());
|
// return count($query-getResult());
|
||||||
// }
|
// }
|
||||||
/**
|
/**
|
||||||
* This function is used to get the user listing count
|
* This function is used to get the user listing count
|
||||||
* @param string $searchText : This is optional search text
|
* @param string $searchText : This is optional search text
|
||||||
* @param number $page : This is pagination offset
|
* @param number $page : This is pagination offset
|
||||||
@ -51,13 +52,13 @@ class Department_model extends Model
|
|||||||
function departmentListing()
|
function departmentListing()
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('t_departmentdetails as BaseT')
|
$builder = $this->db->table('t_departmentdetails as BaseT')
|
||||||
->select('BaseT.CreatedDt,BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive')
|
->select('BaseT.CreatedDt,BaseT.DepartmentName, BaseT.DEPCode, BaseT.HeadDept, BaseT.IsActive')
|
||||||
->orderBy("BaseT.DEPCode", "desc");
|
->orderBy("BaseT.DEPCode", "desc");
|
||||||
$query =$builder->get();
|
$query = $builder->get();
|
||||||
$result = $query->getResult();
|
$result = $query->getResult();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// function ($searchText = '')
|
// function ($searchText = '')
|
||||||
// {
|
// {
|
||||||
// if(!empty($searchText)) {
|
// if(!empty($searchText)) {
|
||||||
@ -71,99 +72,141 @@ class Department_model extends Model
|
|||||||
// //$this->db->where('BaseT.userId !=', 1);
|
// //$this->db->where('BaseT.userId !=', 1);
|
||||||
// // $this->db->limit($page, $segment);
|
// // $this->db->limit($page, $segment);
|
||||||
// $query =$builder->get();
|
// $query =$builder->get();
|
||||||
|
|
||||||
// $result = $query->getResult();
|
// $result = $query->getResult();
|
||||||
// return $result;
|
// return $result;
|
||||||
// }
|
// }
|
||||||
/**
|
|
||||||
* This function used to get user information by id
|
|
||||||
* @param number $userId : This is user id
|
|
||||||
* @return array $result : This is user information
|
|
||||||
*/
|
|
||||||
|
|
||||||
function savedepartment($department)
|
|
||||||
{
|
|
||||||
|
|
||||||
$builder = $this->db->table('t_departmentdetails');
|
|
||||||
$builder->insert($department);
|
|
||||||
|
|
||||||
$SID = $this->db->affectedRows();
|
|
||||||
|
|
||||||
return $SID;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getdepcode()
|
|
||||||
{
|
|
||||||
//$limit = 12;
|
|
||||||
$builder = $this->db->table('t_departmentdetails')
|
|
||||||
->distinct()
|
|
||||||
->select('DEPCode, DepartmentName')
|
|
||||||
->where('IsActive =', 1);
|
|
||||||
//$this->db->limit($limit);
|
|
||||||
$query =$builder->get();
|
|
||||||
|
|
||||||
return $query->getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function used to get user information by id
|
* This function used to get user information by id
|
||||||
* @param number $userId : This is user id
|
* @param number $userId : This is user id
|
||||||
* @return array $result : This is user information
|
* @return array $result : This is user information
|
||||||
*/
|
*/
|
||||||
function getDeptInfo($DEPCode='')
|
|
||||||
|
function savedepartment($department)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$builder = $this->db->table('t_departmentdetails');
|
||||||
|
$builder->insert($department);
|
||||||
|
|
||||||
|
$SID = $this->db->affectedRows();
|
||||||
|
|
||||||
|
return $SID;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getdepcode()
|
||||||
|
{
|
||||||
|
//$limit = 12;
|
||||||
$builder = $this->db->table('t_departmentdetails')
|
$builder = $this->db->table('t_departmentdetails')
|
||||||
->select('*')
|
->distinct()
|
||||||
->where('DEPCode', $DEPCode);
|
->select('DEPCode, DepartmentName')
|
||||||
$query =$builder->get();
|
->where('IsActive =', 1);
|
||||||
|
//$this->db->limit($limit);
|
||||||
|
$query = $builder->get();
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
/* This function to get the Supplier Address on respective Supplier ID */
|
|
||||||
|
/**
|
||||||
function Updatedepartment($department, $DEPCode)
|
* This function used to get user information by id
|
||||||
|
* @param number $userId : This is user id
|
||||||
|
* @return array $result : This is user information
|
||||||
|
*/
|
||||||
|
function getDeptInfo($DEPCode = '')
|
||||||
|
{
|
||||||
|
$builder = $this->db->table('t_departmentdetails')
|
||||||
|
->select('*')
|
||||||
|
->where('DEPCode', $DEPCode);
|
||||||
|
$query = $builder->get();
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
/* This function to get the Supplier Address on respective Supplier ID */
|
||||||
|
|
||||||
|
function Updatedepartment($department, $DEPCode)
|
||||||
{
|
{
|
||||||
$this->db->table('t_departmentdetails')
|
$this->db->table('t_departmentdetails')
|
||||||
->where('DEPCode', $DEPCode)
|
->where('DEPCode', $DEPCode)
|
||||||
->update($department);
|
->update($department);
|
||||||
$res = $this->db->affectedRows();
|
$res = $this->db->affectedRows();
|
||||||
return $res;
|
return $res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reActivateDepartment($depCode , $updateInfo){
|
function reActivateDepartment($depCode, $updateInfo)
|
||||||
|
{
|
||||||
$this->db->table('t_departmentdetails')
|
$this->db->table('t_departmentdetails')
|
||||||
->where('DEPCode', $depCode)
|
->where('DEPCode', $depCode)
|
||||||
->update($updateInfo);
|
->update($updateInfo);
|
||||||
$res = $this->db->affectedRows();
|
$res = $this->db->affectedRows();
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function deleteDepartment($depCode , $updateInfo){
|
function deleteDepartment($depCode, $updateInfo)
|
||||||
|
{
|
||||||
$this->db->table('t_departmentdetails')
|
$this->db->table('t_departmentdetails')
|
||||||
->where('DEPCode', $depCode)
|
->where('DEPCode', $depCode)
|
||||||
->update($updateInfo);
|
->update($updateInfo);
|
||||||
$res = $this->db->affectedRows();
|
$res = $this->db->affectedRows();
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function checkDepartmentName($depCode ,$departmentName){
|
function checkDepartmentName($departmentName, $headDepCode, $depCode)
|
||||||
$builder = $this->db->table('t_departmentdetails');
|
{
|
||||||
|
|
||||||
if(!empty($depCode)){
|
$builder = $this->db->table('t_departmentdetails');
|
||||||
$builder = $builder -> where(' DEPCode !=', $depCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
$builder = $builder->where('REPLACE(DepartmentName , " ", "") ',$departmentName);
|
//post
|
||||||
$query = $builder->get();
|
if(empty($depCode)) {
|
||||||
$result =$query->getResultArray();
|
$builder = $builder->where(' HeadDept =', $headDepCode);
|
||||||
return $result;
|
}
|
||||||
|
|
||||||
|
//put
|
||||||
|
if(!empty($depCode)){
|
||||||
|
|
||||||
|
//allowing current department name to be changed
|
||||||
|
//but not other department to get same name
|
||||||
|
|
||||||
|
$builder = $builder->where(' DEPCode !=', $depCode);
|
||||||
|
$builder = $builder->where(' HeadDept =', $headDepCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
$builder = $builder->where('REPLACE(DepartmentName , " ", "") ', $departmentName);
|
||||||
|
|
||||||
|
$query = $builder->get();
|
||||||
|
|
||||||
|
$result = $query->getResultArray();
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@ -113,14 +113,14 @@
|
|||||||
|
|
||||||
$("#deptBtnId").on('click',function(){
|
$("#deptBtnId").on('click',function(){
|
||||||
let departmentName = $("#DepartmentName").val().trim();
|
let departmentName = $("#DepartmentName").val().trim();
|
||||||
let depCode =$("#DEPCode").val()??'';
|
let headDepCode =$("#HeadDept").val()??'';
|
||||||
|
let depCode =$("#DEPCode").val() ?? '';
|
||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:"POST",
|
type:"POST",
|
||||||
data:{departmentName,depCode},
|
data:{departmentName,headDepCode ,depCode},
|
||||||
url:"<?php echo base_url();?>checkDepartmentName",
|
url:"<?php echo base_url();?>checkDepartmentName",
|
||||||
success:function(data){
|
success:function(data){
|
||||||
|
|
||||||
if(data && data.length >0){
|
if(data && data.length >0){
|
||||||
let isActive = data[0]. IsActive;
|
let isActive = data[0]. IsActive;
|
||||||
if(isActive == 1){
|
if(isActive == 1){
|
||||||
|
|||||||
@ -176,10 +176,12 @@
|
|||||||
$("#deptBtnId").on('click',function(){
|
$("#deptBtnId").on('click',function(){
|
||||||
let departmentName = $("#DepartmentName").val().trim();
|
let departmentName = $("#DepartmentName").val().trim();
|
||||||
let depCode =$("#DEPCode").val();
|
let depCode =$("#DEPCode").val();
|
||||||
|
let headDepCode = $("#HeadDept").val();
|
||||||
|
|
||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:"POST",
|
type:"POST",
|
||||||
data:{departmentName,depCode},
|
data:{departmentName,headDepCode ,depCode},
|
||||||
url:"<?php echo base_url();?>checkDepartmentName",
|
url:"<?php echo base_url();?>checkDepartmentName",
|
||||||
success:function(data){
|
success:function(data){
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user