siddharth_application/application/controllers/rawmaterialdetails.php
2017-04-05 19:38:02 +05:30

251 lines
8.2 KiB
PHP

<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php';
/**
* Class : purchaseorder (PurchaseorderController)
* User Class to control all user related operations.
* @author : VenbaMail Mali
* @version : 1.1
* @since : 15 Feb 2016
*/
class rawmaterialdetails extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('rawmaterialdetails_model');
$this->isLoggedIn();
}
/**
* This function used to load the first screen of the user
*/
public function index()
{
$this->global['pageTitle'] = 'Siddharth : RawMaterialDetails';
$this->loadViews("rawmaterialListing", $this->global, NULL , NULL);
}
/**
* This function is used to load the RawMaterialDetails list
*/
function rawmaterialListing()
{
$this->load->model('rawmaterialdetails_model');
$searchText = $this->input->post('searchText');
$data['searchText'] = $searchText;
$this->load->library('pagination');
$count = $this->rawmaterialdetails_model->rawmaterialListingCount($searchText);
$returns = $this->paginationCompress ( "rawmaterialListing/", $count, 5 );
$data['userRecords'] = $this->rawmaterialdetails_model->rawmaterialListing($searchText, $returns["page"], $returns["segment"]);
$this->global['pageTitle'] = 'Siddharth : RawMaterial Listing';
$this->loadViews("rawmaterialListing", $this->global, $data, NULL);
}
/**
* This function is used to load the add new cost */
function addRawMaterial()
{
$this->load->model('rawmaterialdetails_model');
//$data['SupplierName'] = $this->rawmaterialdetails_model->getSupplierName();
$data['material'] = $this->rawmaterialdetails_model->getmaterial();
$data['UOM'] = $this->rawmaterialdetails_model->getUOM();
$this->global['pageTitle'] = 'siddharth : AddNew RawMaterial';
$this->loadViews("addRawmaterial", $this->global, $data, NULL);
}
/**
* This function is used to add new Cost to the system
*/
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('MaterialType','MaterialType','trim');
$this->form_validation->set_rules('UOM','UOM','trim');
if($this->form_validation->run() == FALSE)
{
$this->addRawMaterial();
}
else
{
$MaterialName = ucwords(strtolower($this->input->post('MaterialName')));
$MaterialType = $this->input->post('MaterialType');
$UOM = $this->input->post('UOM');
$CreatedBy = $this->input->post('CreatedBy');
$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);
if($result > 0)
{
$this->session->set_flashdata('success', 'New RawMaterial created successfully');
}
else
{
$this->session->set_flashdata('error', 'RawMaterial Not Create');
}
redirect('rawmaterialListing');
}
}
function viewRawmaterial($RawMaterialID = NULL)
{
$this->load->model('rawmaterialdetails_model');
$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);
}
/**
* This function is used to edit the user information
*/
function editRawmaterial()
{
if($this->isAdmin() == TRUE)
{
echo 'allowed admin';
$this->loadThis();
}
else
{
//echo 'allowed data';
$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('MaterialType','MaterialType','trim');
$this->form_validation->set_rules('UOM','UOM','trim');
if($this->form_validation->run() == FALSE)
{
$this->editRawmaterial($RawmaterialID);
}
else
{
$MaterialCode = $this->input->post('MaterialCode');
$MaterialName = ucwords(strtolower($this->input->post('MaterialName')));
$MaterialType = $this->input->post('MaterialType');
$UOM = $this->input->post('UOM');
$UpdatedBy = $this->input->post('UpdatedBy');
$CreatedBy = $this->input->post('CreatedBy');
//echo $MaterialCode;
//echo 'passed model';
$RawMaterial = array();
$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);
// echo ' After db Call';
if($result == true)
{
$this->session->set_flashdata('success', 'RawMaterial updated successfully');
}
else
{
$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()
{
$this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
}
?>