Material Master

This commit is contained in:
gandhimathi Bharathirajan 2017-04-13 00:23:03 +05:30
parent 9a80993826
commit 9956d0617b

View File

@ -3,11 +3,11 @@
require APPPATH . '/libraries/BaseController.php'; require APPPATH . '/libraries/BaseController.php';
/** /**
* Class : purchaseorder (PurchaseorderController) * Class : RawMaterial (PurchaseorderController)
* User Class to control all user related operations. * User Class to control all user related operations.
* @author : VenbaMail Mali * @author : Gandhimathi
* @version : 1.1 * @version : 1.1
* @since : 15 Feb 2016 * @since : 12 Apr 2017
*/ */
class rawmaterialdetails extends BaseController class rawmaterialdetails extends BaseController
{ {
@ -18,6 +18,8 @@ class rawmaterialdetails extends BaseController
{ {
parent::__construct(); parent::__construct();
$this->load->model('rawmaterialdetails_model'); $this->load->model('rawmaterialdetails_model');
$this->load->library('pagination');
$this->load->library('form_validation');
$this->isLoggedIn(); $this->isLoggedIn();
} }
/** /**
@ -41,8 +43,6 @@ class rawmaterialdetails extends BaseController
$searchText = $this->input->post('searchText'); $searchText = $this->input->post('searchText');
$data['searchText'] = $searchText; $data['searchText'] = $searchText;
$this->load->library('pagination');
$count = $this->rawmaterialdetails_model->rawmaterialListingCount($searchText); $count = $this->rawmaterialdetails_model->rawmaterialListingCount($searchText);
$returns = $this->paginationCompress ( "rawmaterialListing/", $count, 5 ); $returns = $this->paginationCompress ( "rawmaterialListing/", $count, 5 );
@ -60,33 +60,56 @@ class rawmaterialdetails extends BaseController
{ {
$this->load->model('rawmaterialdetails_model'); $this->load->model('rawmaterialdetails_model');
//$data['SupplierName'] = $this->rawmaterialdetails_model->getSupplierName(); $data['material'] = $this->rawmaterialdetails_model->getmaterialType();
$data['material'] = $this->rawmaterialdetails_model->getmaterial();
$data['UOM'] = $this->rawmaterialdetails_model->getUOM(); $data['UOM'] = $this->rawmaterialdetails_model->getUOM();
$this->global['pageTitle'] = 'siddharth : AddNew RawMaterial'; $this->global['pageTitle'] = 'siddharth : AddNew RawMaterial';
$this->loadViews("addRawmaterial", $this->global, $data, NULL); $this->loadViews("addRawmaterial", $this->global, $data, NULL);
} }
/*
/** Validation for Material Type Dropdown
* This function is used to add new Cost to the system */
function MaterialType_validate($selectValue)
{
//echo 'select_validate method called';
// 'none' is the first option and the text says something like "-Choose one-"
if($selectValue == '-1')
{
$this->form_validation->set_message('MaterialType_validate', 'Please Select Material Type.');
return false;
}
else // user picked something
{
return true;
}
}
/*
Validation for Material Type Dropdown
*/
function UOM_validate($selectValue)
{
//echo 'select_validate method called';
// 'none' is the first option and the text says something like "-Choose one-"
if($selectValue == '-1')
{
$this->form_validation->set_message('UOM_validate', 'Please Select UOM.');
return false;
}
else // user picked something
{
return true;
}
}
/* This function is used to add new Cost to the system
*/ */
function addNewRawMaterial() function addNewRawMaterial()
{ {
$this->load->library('form_validation');
//$PO = $this->input->post('costID');
//$this->form_validation->set_rules('CostCenterID','cost Name','trim');
$this->form_validation->set_rules('MaterialName','Material Name','trim|required|'); $this->form_validation->set_rules('MaterialName','Material Name','trim|required|');
$this->form_validation->set_rules('MaterialType','MaterialType','trim'); $this->form_validation->set_rules('MaterialType','MaterialType','trim|callback_MaterialType_validate');
$this->form_validation->set_rules('UOM','UOM','trim'); $this->form_validation->set_rules('UOM','UOM','trim|callback_UOM_validate');
if($this->form_validation->run() == FALSE) if($this->form_validation->run() == FALSE)
{ {
@ -94,59 +117,62 @@ class rawmaterialdetails extends BaseController
} }
else else
{ {
$MaterialName = ucwords(strtolower($this->input->post('MaterialName'))); $MaterialName = $this->input->post('MaterialName');
$MaterialType = $this->input->post('MaterialType'); $MaterialType = $this->input->post('MaterialType');
$UOM = $this->input->post('UOM'); $UOM = $this->input->post('UOM');
$CreatedBy = $this->input->post('CreatedBy'); $CreatedBy = $this->session->userdata('userId');
$chked = $this->input->post('isactive');
if( $chked != '')
{
$IsActive = '1';
}
else
{
$IsActive = '0';
}
$Material = array('MaterialName'=>$MaterialName, 'MaterialType'=>$MaterialType, 'UOM'=>$UOM,'CreatedBy'=>$CreatedBy,'IsActive' => $IsActive);
$RawMaterial = array('MaterialName'=>$MaterialName, 'MaterialType'=>$MaterialType, 'UOM'=>$UOM,'CreatedBy'=>$CreatedBy,'createdDate'=>date('Y-m-d H:i:sa'));
$this->load->model('rawmaterialdetails_model');
$result = $this->rawmaterialdetails_model->addNewRawMaterial($RawMaterial); $result = $this->rawmaterialdetails_model->addNewRawMaterial($RawMaterial);
if($result > 0) if($result > 0)
{ {
$this->session->set_flashdata('success', 'New RawMaterial created successfully'); //$this->session->set_flashdata('success', 'New RawMaterial created successfully');
echo "<script>alert('RawMaterial Created successfully!');</script>";
redirect('rawmaterialListing','refresh');
} }
else else
{ {
$this->session->set_flashdata('error', 'RawMaterial Not Create'); // $this->session->set_flashdata('error', 'RawMaterial Not Create');
echo "<script>alert('RawMaterial Not Created!');</script>";
redirect('rawmaterialListing','refresh');
} }
redirect('rawmaterialListing');
} }
} }
function viewRawmaterial($RID= '')
function viewRawmaterial($RawMaterialID = NULL)
{ {
$MaterialType = '';
$UOM = '';
if($RID == '')
{
$RawMaterialID = $_GET['RID'];
$MaterialType = $_GET['MType'];
$UOM = $_GET['UOM'];
}
else
{
$RawMaterialID = $RID;
}
$this->load->model('rawmaterialdetails_model'); $data['materialDetails'] = $this->rawmaterialdetails_model->getMaterialDetails($RawMaterialID);
$data['userRecords'] = $this->rawmaterialdetails_model->getuserInfo($RawMaterialID);
$data['material'] = $this->rawmaterialdetails_model->getmaterial();
$this->global['pageTitle'] = 'Siddharth : View MaterialMaster';
$this->loadViews("viewrawmaterial", $this->global,$data, NULL);
}
/**
* This function is used load user edit information
* @param number $userId : Optional : This is user id
*/
function editOldRawmaterial($RawMaterialID = NULL)
{
$data['material'] = $this->rawmaterialdetails_model->getmaterial();
$data['UOMList'] = $this->rawmaterialdetails_model->getUOM();
$data['userRecords'] = $this->rawmaterialdetails_model->getUserInfo($RawMaterialID);
$this->global['pageTitle'] = 'Siddharth : Edit MaterialMaster';
$this->loadViews("editOldrawmaterial", $this->global, $data, NULL);
$data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType );
$data['UOMList'] = $this->rawmaterialdetails_model->getUOM($UOM);
$this->global['pageTitle'] = 'Siddharth : Edit Material Master';
$this->loadViews("editOldRawmaterial", $this->global,$data, NULL);
} }
@ -155,23 +181,13 @@ class rawmaterialdetails extends BaseController
*/ */
function editRawmaterial() function editRawmaterial()
{ {
if($this->isAdmin() == TRUE)
if($this->isAdmin() == TRUE)
{ {
echo 'allowed admin'; $this->loadThis();
$this->loadThis();
} }
else else
{ {
//echo 'allowed data'; $MaterialCode = $this->input->post('MaterialCode');
$this->load->library('form_validation');
$MaterialCode = $this->input->post('MaterialCode');
$this->form_validation->set_rules('MaterialName','Material Name','trim|required|'); $this->form_validation->set_rules('MaterialName','Material Name','trim|required|');
$this->form_validation->set_rules('MaterialType','MaterialType','trim'); $this->form_validation->set_rules('MaterialType','MaterialType','trim');
$this->form_validation->set_rules('UOM','UOM','trim'); $this->form_validation->set_rules('UOM','UOM','trim');
@ -183,63 +199,45 @@ class rawmaterialdetails extends BaseController
} }
else else
{ {
$MaterialCode = $this->input->post('MaterialCode'); $MaterialCode = $this->input->post('MaterialCode');
$MaterialName = ucwords(strtolower($this->input->post('MaterialName'))); $MaterialName = $this->input->post('MaterialName');
$MaterialType = $this->input->post('MaterialType'); $MaterialType = $this->input->post('MaterialType');
$UOM = $this->input->post('UOM'); $UOM = $this->input->post('UOM');
$UpdatedBy = $this->input->post('UpdatedBy'); $UpdatedBy = $this->session->userdata ('userId');
$CreatedBy = $this->input->post('CreatedBy'); $chked = $this->input->post('isactive');
//echo $MaterialCode; if( $chked != '')
{
$IsActive = '1';
}
else
{
$IsActive = '0';
}
//echo 'passed model'; $RawMaterial = array();
$RawMaterial = array(); $RawMaterial = array('MaterialName'=>$MaterialName,'MaterialType'=>$MaterialType,'UpdatedBy'=>$UpdatedBy, 'UOM'=>$UOM,'IsActive' => $IsActive);
$RawMaterial = array('MaterialName'=>$MaterialName,'MaterialType'=>$MaterialType,'CreatedBy'=>$CreatedBy,'UpdatedBy'=>$UpdatedBy, 'UOM'=>$UOM, 'MaterialCode'=>$MaterialCode, 'UpdatedDate'=>date('Y-m-d H:i:sa'));
// echo ' before db Call';
$result = $this->rawmaterialdetails_model->editRawmaterial($RawMaterial, $MaterialCode); $result = $this->rawmaterialdetails_model->editRawmaterial($RawMaterial, $MaterialCode);
// echo ' After db Call';
if($result == true) if($result == true)
{ {
$this->session->set_flashdata('success', 'RawMaterial updated successfully'); redirect('rawmaterialListing','refresh');
// $this->session->set_flashdata('success', 'RawMaterial updated successfully');
echo "<script>alert('RawMaterial Updated successfully!');</script>";
} }
else else
{ {
$this->session->set_flashdata('error', 'RawMaterial updation failed'); redirect('rawmaterialListing','refresh');
echo "<script>alert('RawMaterial Record Not updated!');</script>";
// $this->session->set_flashdata('error', 'RawMaterial updation failed');
} }
redirect('rawmaterialListing');
} }
} }
} }
/**
* This function is used to delete the user using userId
* @return boolean $result : TRUE / FALSE
function deleteUser()
{
if($this->isAdmin() == TRUE)
{
echo(json_encode(array('status'=>'access')));
}
else
{
$userId = $this->input->post('userId');
$userInfo = array('isDeleted'=>1,'updatedBy'=>$this->vendorId, 'updatedDtm'=>date('Y-m-d H:i:sa'));
$result = $this->user_model->deleteUser($userId, $userInfo);
if ($result > 0) { echo(json_encode(array('status'=>TRUE))); }
else { echo(json_encode(array('status'=>FALSE))); }
}
}*/
function pageNotFound() function pageNotFound()
{ {
$this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';