diff --git a/application/config/constants.php b/application/config/constants.php index 2bf8ea01..55016a5d 100755 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -145,7 +145,7 @@ define('REVENUE', 'REVENUE'); define('SERVICE', 'SERVICE'); define('IMPORT', 'IMPORT'); define('CAPITAL', 'CAPITAL'); - +define('SYSTEM_ADMIN', '1'); // Tax Type define('PERCENTAGE', 'PERCENTAGE'); define('LUMPSUM', 'LUMP SUM'); diff --git a/application/controllers/CostCenter.php b/application/controllers/CostCenter.php index 55cea728..f6317b5f 100755 --- a/application/controllers/CostCenter.php +++ b/application/controllers/CostCenter.php @@ -46,17 +46,10 @@ class CostCenter extends BaseController $this->global['pageTitle'] = 'Siddharth : Cost List'; - if($this->DEPCode == FINANCE ) - { + $this->loadViews("costListing", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - - } + } /** @@ -186,16 +179,10 @@ class CostCenter extends BaseController $this->global['pageTitle'] = 'Siddharth : Edit Cost'; - if($this->DEPCode == FINANCE ) - { + $this->loadViews("editOldcost", $this->global, $data,NULL); - } - - else - { - $this->loadViews("access", $this->global, $data,NULL); - } + } function GetBudgetForYear() diff --git a/application/controllers/MRIRcontroller.php b/application/controllers/MRIRcontroller.php index 2ddfaaa5..0c3a4ffb 100755 --- a/application/controllers/MRIRcontroller.php +++ b/application/controllers/MRIRcontroller.php @@ -92,18 +92,14 @@ class MRIRcontroller extends BaseController $this->global['pageTitle'] = 'Siddharth : Billing '; $data['Billing'] = $this->mrir_model->view_mrir_Billing(); - if($this->DEPCode == FINANCE) - { + $this->loadViews("viewmrirforbilling", $this->global,$data , NULL); - } - - else - { - $this->loadViews("access", $this->global,$data , NULL); - } + } + + public function viewmMaterialDistributionList() { $this->global['pageTitle'] = 'Siddharth : Distribution list '; @@ -111,16 +107,10 @@ public function viewmMaterialDistributionList() $data['Distribution'] = $this->mrir_model->ViewDistributionList(); $data['status'] = $this->mrir_model->getStatus(); - if($this->DEPCode == STORE) - { + $this->loadViews("MaterialIssueList", $this->global,$data , NULL); - } - - else - { - $this->loadViews("access", $this->global,$data , NULL); - } + } @@ -146,17 +136,10 @@ public function viewmMaterialDistributionList() - if($this->DEPCode == STORE || $this->DEPCode == QUALITY) - { + $this->loadViews("viewinwardgateregister",$this->global,$data,NULL); - } - - else - { - $this->loadViews("access",$this->global,$data,NULL); - - } + } @@ -173,16 +156,11 @@ public function viewmMaterialDistributionList() $this->global['pageTitle'] = 'Siddharth : View Material Inspection Report'; //print_r( $data); - if($this->DEPCode == STORE || $this->DEPCode == QUALITY) - { + + $this->loadViews("viewmaterialinspectionreport", $this->global,$data,NULL); - } - - else - { - $this->loadViews("access", $this->global,$data,NULL); - } + } diff --git a/application/controllers/emergencypurchaseorder.php b/application/controllers/emergencypurchaseorder.php index ac33b11d..466be65c 100755 --- a/application/controllers/emergencypurchaseorder.php +++ b/application/controllers/emergencypurchaseorder.php @@ -72,16 +72,10 @@ class emergencypurchaseorder extends BaseController $data['PoTypeOptions'] = $this->purchaseorder_model->getConfigValue('C026'); - if($this->DEPCode == PURCHASE ) - { + $this->loadViews("alterpurchaseorder", $this->global, $data, Null); - } - - else - { - $this->loadViews("access", $this->global, $data, Null); - } + } /** @@ -870,19 +864,12 @@ $RequestedBy = $this->input->post('drpDepartment'); $this->global['pageTitle'] = 'Siddharth : Purchase Orders'; - if($this->DEPCode == PURCHASE ) - { + $this->loadViews("POlist", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - - } } + function Req_validate($selectValue) { //echo 'select_validate method called'; diff --git a/application/controllers/employeedetails.php b/application/controllers/employeedetails.php index c65a319b..bbe77473 100755 --- a/application/controllers/employeedetails.php +++ b/application/controllers/employeedetails.php @@ -44,17 +44,9 @@ class employeedetails extends BaseController $this->global['pageTitle'] = 'Siddharth : Employee Listing'; - if($this->role == ROLE_ADMIN || $this->DEPCode == HR) - { - $this->loadViews("employeeListing", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - } + } /* diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index b721f090..b8d28204 100755 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -41,18 +41,10 @@ class inwardgateregister extends BaseController $this->global['pageTitle'] = 'Siddharth : Inward Gate Register Details'; $data['IGR']= $this->inwardgateregister_model->igrListing(); - if($this->Designation == SECURITY) - { $this->loadViews("viewIGRDetails",$this->global,$data,NULL); - } - - else - { - $this->loadViews("access",$this->global,$data,NULL); - - } + } function addinwardgateregister() @@ -65,16 +57,9 @@ class inwardgateregister extends BaseController $data['PO_NO'] = $this->inwardgateregister_model->getpurchaseorder(); //print_r($data['PO_NO']); - if($this->Designation == SECURITY) - { $this->loadViews("inwardgateregister", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - } + } function getDateformat($Val) diff --git a/application/controllers/login.php b/application/controllers/login.php index d4155eb0..c7d57bc4 100755 --- a/application/controllers/login.php +++ b/application/controllers/login.php @@ -70,6 +70,11 @@ class Login extends CI_Controller if(count($result) > 0) { + + // $det= $this->login_model->Accessdep($res->EmpID); + // print_r($det); + // die(); + foreach ($result as $res) { $sessionArray = array('userId'=>$res->userId, @@ -79,6 +84,7 @@ class Login extends CI_Controller 'Designation'=>$res->Designation, 'DEPCode'=>$res->DEPCode, 'HeadDept'=>$res->HeadDept, + 'depaccess'=>$this->login_model->Accessdep($res->EmpID), 'DepartmentName'=>$res->DepartmentName, 'EmpID' => $res->EmpID, 'isLoggedIn' => TRUE diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index 7674f375..0bb76034 100755 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -51,16 +51,12 @@ class purchaseorder extends BaseController //print_r($data['PONO']); - if($this->DEPCode == PURCHASE) - { + $this->loadViews("advancerequest", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - } + } + + function requisition() { $data['DeptList'] = $this->purchaseorder_model->getDepartmentListForAllReq(); @@ -74,17 +70,12 @@ class purchaseorder extends BaseController /* End Here */ $this->global['pageTitle'] = 'Siddharth : Create PO from Requisition List'; - if($this->DEPCode== PURCHASE) - { + $this->loadViews("createPOfromRequistion", $this->global, $data,Null); - } + - else - { - $this->loadViews("access", $this->global, $data,Null); - } } @@ -106,16 +97,12 @@ class purchaseorder extends BaseController $this->global['pageTitle'] = 'Siddharth : Purchase Orders'; - if($this->DEPCode == PURCHASE ) - { + + $this->loadViews("POlist", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - } + + } diff --git a/application/controllers/requisitionform.php b/application/controllers/requisitionform.php index 0007d51d..f7460039 100755 --- a/application/controllers/requisitionform.php +++ b/application/controllers/requisitionform.php @@ -39,18 +39,10 @@ class requisitionform extends BaseController $data['TotNoOfLine'] =$this->requistion_model->getRequistionList($userID); - if (($this->role == ROLE_MANAGER || $this->role == ROLE_EMPLOYEE || $this->role == ROLE_ADMIN ) && $this->Designation != SECURITY) - { - + $this->loadViews("requisitionlisting", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - - } + } /** @@ -87,16 +79,10 @@ class requisitionform extends BaseController $data['AppList'] = $this->requistion_model->getApproverRequistList($userID); - if($this->role == ROLE_MANAGER ) - { + $this->loadViews("requisitionlistapproval", $this->global, $data, NULL); - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - } + } diff --git a/application/controllers/servicepurchaseorder.php b/application/controllers/servicepurchaseorder.php index 39418fef..8832a235 100755 --- a/application/controllers/servicepurchaseorder.php +++ b/application/controllers/servicepurchaseorder.php @@ -36,18 +36,9 @@ class servicepurchaseorder extends BaseController //print_r($data["Billing"]); - if($this->DEPCode == FINANCE) - { - $this->loadViews("serviceporeport", $this->global,$data,null); - } - - else - { - $this->loadViews("access", $this->global,$data,null); - - } + } diff --git a/application/controllers/storerequisitionlist.php b/application/controllers/storerequisitionlist.php index f321e53e..8507da99 100755 --- a/application/controllers/storerequisitionlist.php +++ b/application/controllers/storerequisitionlist.php @@ -51,17 +51,11 @@ class storerequisitionlist extends BaseController $this->global['pageTitle'] = 'Siddharth : StoreRequisition Listing'; $userId= $this->session->userdata ('userId'); $data['Store'] = $this->storerequistion_model->Storeall($userId); - if ($this->Designation != SECURITY && $this->DEPCode != HR ) - { + $this->loadViews("storerequisition", $this->global,$data,null); - } - - else - { - $this->loadViews("access", $this->global,$data,null); - } + } /** @@ -85,8 +79,6 @@ class storerequisitionlist extends BaseController function EditStoreRequistion() { - if ($this->Designation != SECURITY && $this->DEPCode != HR ) - { $StoreReqNo = $_GET['StoreReqNo']; //$StoreReqNo= $this->input->post('id'); @@ -102,12 +94,7 @@ class storerequisitionlist extends BaseController $data['LineItem']=$this ->storerequistion_model->editstorerequistions($StoreReqNo); $this->loadViews("editstorerequisition", $this->global,$data,null); - } - - else - { - $this->load->view('access'); - } + } @@ -215,15 +202,9 @@ class storerequisitionlist extends BaseController $data['Status']= $this->storerequistion_model->getStatus(); $data['TotNoOfLine']=$this->storerequistion_model->getRequistionList(); //print_r($data['TotNoOfLine']); - if ( $this->Designation != SECURITY && $this->DEPCode != HR ) - { + $this->loadViews("storerequisitionlisting", $this->global,$data,null); - } - - else - { - $this->loadViews("access", $this->global,$data,null); - } + } @@ -240,15 +221,11 @@ class storerequisitionlist extends BaseController $data['ReqListDetails'] = $this->storerequistion_model->getRequistDetails($StoreReqNo); //print_r($data['ReqItem']); - if($this->DEPCode == STORE) - { - $this->loadViews("issueStoreRequistion", $this->global,$data,null); - } + - else - { - $this->loadViews("access", $this->global,$data,null); - } + $this->loadViews("issueStoreRequistion", $this->global,$data,null); + + } function UpdateIssueRequistion() diff --git a/application/controllers/storestatus.php b/application/controllers/storestatus.php index 70b1a210..9cf80181 100755 --- a/application/controllers/storestatus.php +++ b/application/controllers/storestatus.php @@ -52,15 +52,9 @@ class storestatus extends BaseController $data['MaterialList'] = $this->store_model->GetAllMaterialList(); $data['StockStatus'] = $this->store_model->GetConfigValue('C021'); - if($this->DEPCode == STORE) - { + $this->loadViews("storestatus", $this->global, $data,null); - } - - else - { - $this->loadViews("access", $this->global, $data,null); - } + } /** diff --git a/application/controllers/supplier.php b/application/controllers/supplier.php index 457e35da..8ccfbce7 100755 --- a/application/controllers/supplier.php +++ b/application/controllers/supplier.php @@ -45,21 +45,11 @@ class supplier extends BaseController $this->global['pageTitle'] = 'Siddharth Industries : Supplier Listing'; - if($this->role == ROLE_ADMIN || $this->DEPCode == SALES || $this->DEPCode == FINANCE ||$this->DEPCode == HR) - { - - if($this->DEPCode != FINANCE && $this->DEPCode != HR) - { + $this->loadViews("supplierListing", $this->global, $data, NULL); - } - } - - else - { - $this->loadViews("access", $this->global, $data, NULL); - } + } /** * This function is used to load the add new supplier */ @@ -73,20 +63,10 @@ class supplier extends BaseController $this->global['pageTitle'] = 'siddharth : Add New Supplier'; - if($this->role == ROLE_ADMIN || $this->DEPCode == SALES || $this->DEPCode == FINANCE ||$this->DEPCode == HR) - { - - if($this->DEPCode != FINANCE && $this->DEPCode != HR) - { + $this->loadViews("addsupplier", $this->global,$data, NULL); - } - } - - else - { - $this->loadViews("access", $this->global,$data, NULL); - } + } /** * This function is used to check whether PAN already exist or not diff --git a/application/controllers/user.php b/application/controllers/user.php index a9b5a8e6..53cbabd7 100755 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -20,6 +20,7 @@ class user extends BaseController $this->load->model('user_model'); $this->load->model('dahsboard_Model'); $this->load->library('form_validation'); + $this->load->model('costcenter_model'); $this->isLoggedIn(); } @@ -1019,6 +1020,8 @@ function attendanceyear($empID ='') $data['EmpList'] = $this->user_model->getAllEmployees(); $data['roles'] = $this->user_model->getUserRoles(); + + $data['Department'] = $this->costcenter_model->getDepartment(); $this->global['pageTitle'] = 'Siddharth : Add New User'; @@ -1080,15 +1083,15 @@ function attendanceyear($empID ='') */ function addNewUser() { - if($this->isAdmin() == TRUE) - { - $this->loadThis(); - } - else - { + // if($this->isAdmin() == TRUE) + // { + // $this->loadThis(); + // } + // else + // { $this->form_validation->set_rules('EmpList','EmpList','trim|callback_Employee_validateS'); - $this->form_validation->set_rules('role','role','trim|callback_Role_validate'); + $this->form_validation->set_rules('role','role','trim|callback_Role_validate'); $this->form_validation->set_rules('password','Password','required|max_length[20]'); $this->form_validation->set_rules('cpassword','Confirm Password','trim|required|matches[password]|max_length[20]'); @@ -1099,37 +1102,87 @@ function attendanceyear($empID ='') } else { - $EmpID = $this->input->post('EmpList'); - $roleId = $this->input->post('role'); - $password = $this->input->post('password'); - $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); - $Createddt = $dt->format('Y-m-d H:i:s'); + $EmpID = $this->input->post('EmpList'); + $roleId = $this->input->post('role'); + $password = $this->input->post('password'); + $dt = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $Createddt = $dt->format('Y-m-d H:i:s'); $email = $this->input->post('MailID'); + + $SelectedDepartment = $this->input->post('txtSelectedDepartment'); + + + $comma_separated = explode(':', $SelectedDepartment); - $userInfo = array('email'=>$email,'EmpID'=>$EmpID,'password'=>getHashedPassword($password),'roleId'=>$roleId,'createdBy'=>$this->vendorId,'createdDtm'=>$Createddt); - + $userInfo = array('email'=>$email,'EmpID'=>$EmpID,'password'=>getHashedPassword($password),'roleId'=>$roleId,'createdBy'=>$this->vendorId,'createdDtm'=>$Createddt); + $result = $this->user_model->addNewUser($userInfo); + + for ($j = 0; $j < count($comma_separated); $j++) + { + $DeptCode = $comma_separated[$j]; + + $userdept=array('EmpID'=>$EmpID,'Departmentcode'=>$DeptCode); + + $access= $this->user_model->addAccess($userdept); + + //echo $access; + } if($result > 0) { - - redirect('userListing','refresh'); - echo ""; + + redirect('userListing','refresh'); + echo ""; - } + } + else { - + redirect('userListing','refresh'); - echo ""; + echo ""; } } + //} + } + + + + + +function Adduserdepartment() + { + $empid= $this->input->post('Eid'); + $Depcode= $this->input->post('Department'); + $userdept=array('EmpID'=>$empid,'Departmentcode'=>$Depcode); + + $access= $this->user_model->addAccess($userdept); + if($access>0) + { + echo "Successfully Added"; } } + + function Deleteuserdepartment() + { + $empid= $this->input->post('Eid'); + $Depcode= $this->input->post('Department'); + $userdept=array('EmpID'=>$empid,'Departmentcode'=>$Depcode); + + $access= $this->user_model->DeleteAccess($empid,$Depcode); + + if($access>0) + { + echo "Successfully Deleted"; + } + + } + /** * This function is used load user edit information @@ -1149,7 +1202,7 @@ function attendanceyear($empID ='') } $Uid = $_GET['UID']; - + $Empid = $_GET['EMPID']; $data['roles'] = $this->user_model->getUserRoles(); @@ -1158,7 +1211,9 @@ function attendanceyear($empID ='') $data['EmpList'] = $this->user_model->GetEmployeeDetails($Uid); //print_r($data); + $data['Departmentlist'] = $this->costcenter_model->getDepartmentnotadded($Empid); $data['EmpRole'] = $this->user_model->GetRoleNameByUserID($Uid); + $data['AccessDept'] = $this->costcenter_model ->getaccessDept($Empid); // $data['userInfo'] = $this->user_model->getUserInfo($userId); diff --git a/application/libraries/BaseController.php b/application/libraries/BaseController.php index cff31c77..dd9bdcec 100755 --- a/application/libraries/BaseController.php +++ b/application/libraries/BaseController.php @@ -49,11 +49,13 @@ class BaseController extends CI_Controller { $this->HeadDept = $this->session->userdata ( 'HeadDept' ); $this->DepartmentName = $this->session->userdata ( 'DepartmentName' ); $this->EmpID = $this->session->userdata ( 'EmpID' ); + $this->depaccess = $this->session->userdata ('depaccess'); $this->global ['name'] = $this->name; $this->global ['role'] = $this->role; $this->global ['role_text'] = $this->roleText; $this->global ['DEPCode'] = $this->DEPCode; $this->global ['Designation'] = $this->Designation; + $this->global ['DepAccesslist'] = $this->depaccess; } } diff --git a/application/models/costcenter_model.php b/application/models/costcenter_model.php index 7ca4e2ce..38c48c1e 100755 --- a/application/models/costcenter_model.php +++ b/application/models/costcenter_model.php @@ -217,6 +217,36 @@ function addNewcost($Cost) return $query->result(); } + + + + function getDepartmentnotadded($Empid) + { + + $subQuery = 'select Dept.DEPCode,Dept.DepartmentName from T_DepartmentDetails Dept +left join T_AccessDepartments Ass on Ass.Departmentcode= Dept.DEPCode +where Dept.DEPCode not in +(select Ass.Departmentcode from T_AccessDepartments Ass where EmpID=?) group by Dept.DEPCode'; + + $query = $this->db->query($subQuery, array($Empid)); + + + return $query->result(); + } + + + function getaccessDept($Empid) + { + + $this->db->select('Ass.Departmentcode as AssDep,Dep.DepartmentName'); + $this->db->from('T_AccessDepartments Ass'); + $this->db->join('T_DepartmentDetails Dep', 'Dep.DEPCode = Ass.Departmentcode','left'); + $this->db->where('EmpID ',$Empid); + + $query = $this->db->get(); + + return $query->result(); + } /** diff --git a/application/models/login_model.php b/application/models/login_model.php index 9d18a501..05c80345 100755 --- a/application/models/login_model.php +++ b/application/models/login_model.php @@ -33,6 +33,19 @@ class Login_model extends CI_Model return array(); } } + + function Accessdep($EmpID) + { + + $this->db->select('EmpID, Departmentcode as AssDep'); + $this->db->from('T_AccessDepartments'); + $this->db->where('EmpID', $EmpID); + + + $query = $this->db->get(); + // print_r( $this->db->last_query()); + return $query->result(); + } } ?> diff --git a/application/views/addNew.php b/application/views/addNew.php index 74803ae3..f6090c8c 100755 --- a/application/views/addNew.php +++ b/application/views/addNew.php @@ -1,3 +1,10 @@ + + + + + + +