FIX_Cost and Material master : ps

This commit is contained in:
VE10-Sanjeev 2024-08-07 12:41:42 +00:00
parent f71a1c1c16
commit 634b4720a3
10 changed files with 286 additions and 2406 deletions

View File

@ -61,19 +61,12 @@ $routes->post('materialExist','Rawmaterialdetails::checkmaterial');
$routes->get('viewRawmaterial','Rawmaterialdetails::viewRawmaterial');
$routes->post('rawmaterialdetails/editRawmaterial', 'Rawmaterialdetails::editRawmaterial');
$routes->get('exportmaterial' , 'Rawmaterialdetails::exportmaterial');
$routes->get('rawmaterialdetailsautocomplete' , 'Rawmaterialdetails::autocomplete');
// Cost Center Routes
$routes->get('costListing', 'CostCenter::index');
$routes->get('addCostCenter', 'CostCenter::addCostCenter');
$routes->get('editCostCenter', 'CostCenter::editCostCenter');
$routes->get('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit....
$routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter');
$routes->post('saveCostCenter', 'CostCenter::saveCostCenter');
$routes->post('updateCostCenter', 'CostCenter::updateCostCenter');
$routes->post('CostCenter/AddCostDepartment','CostCenter::AddCostDepartment');
$routes->post('CostCenter/DeleteCostDepartment','CostCenter::DeleteCostDepartment');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'CostCenter/GetBudgetForYear','CostCenter::GetBudgetForYear');
$routes->match(['GET', 'POST', 'PUT', 'DELETE'],'deletecost', 'CostCenter::deletecost');
$routes->get('exportcost', 'CostCenter::exportcost');
// Asset Detail Routes

View File

@ -52,122 +52,47 @@ class CostCenter extends BaseController
}
/**
* This function is used to load the add new cost Center */
function addCostCenter()
{
$data['Department'] = $this->costcenter_model->getDepartment();
$data['BudgetType'] = $this->costcenter_model->getConfigValue('C004');
$data['Approver'] = $this->costcenter_model->getApproverName();
$data['FiscalYear'] = $this->costcenter_model->getFiscalYear();
$this->global['pageTitle'] = 'Add Cost Center';
$this->loadViews("addCostCenter", $this->global, $data, NULL);
}
function Dep_SelectedDepartment($selectValue)
{
//echo 'select_validate method called';
// 'none' is the first option and the text says something like "-Choose one-"
if (strlen($selectValue) <= 0) {
// $this->validator->setMessage('Dep_SelectedDepartment', 'Please Select Department.');
return false;
} else // user picked something
{
return true;
}
}
/**
* This function is used to add new Cost to the system
* This function is used to add/edit Cost
*/
function saveCostCenter()
{
// $this->validator->setRules([
// 'CostName' => 'trim|required',
// 'CostCode' => 'trim|required',
// ]);
// if ($this->validator->run() == FALSE) {
// $this->addCostCenter();
// } else {
public function fetchCostCenterDetails() {
$id = $this->request->getPost('id');
$CostCenterName = $this->request->getPost('CostCenterName');
$CostCenterName = ($CostCenterName !== null && is_string($CostCenterName)) ? strtoupper(trim($CostCenterName)) : null;
$userId = $this->session->get('userId');
$approverId = $this->session->get('EmpID');
$currentdt = get_current_date_time();
$data = ['status' => false, 'message' => 'An error occurred while creating cost details'];
if ($id == 0) {
$lastccid = $this->costcenter_model->lastCCID();
$lastccid = (int)$lastccid++;
$newccc = generateCostCenterCode($lastccid);
log_message('debug', 'newccc returned: ' . $newccc);
$CostCode = $this->request->getPost('CostCode');
$CostCode = ($CostCode !== null && is_string($CostCode)) ? strtoupper(trim($CostCode)) :null;
$CostName = $this->request->getPost('CostName');
$CostName = ($CostName !== null && is_string($CostName)) ? strtoupper(trim($CostName)) :null;
$CreateBy = $this->session->get('userId');
$SelectedDepartment = $this->request->getPost('txtSelectedDepartment');
// $ApproverName = $this->request->getPost('ApprovedBy');
$ApproverName = $this->session->get('EmpID');
$comma_separated = explode(':', (string)$SelectedDepartment);
// $comma_separated = $this->costcenter_model->getDepartment();
// print_r($comma_separated);die;
$createddt = get_current_date_time();
$CodeExists = $this->costcenter_model->checkCostDetailsExists($CostCode);
if (count($CodeExists) == 0) {
$Cost = array('CostCenterCode' => $CostCode, 'CostCenterName' => $CostName, 'ApprovedBy' => $ApproverName, 'CreatedBy' => $CreateBy, 'createdDate' => $createddt);
$this->costcenter_model->saveCostCenter($Cost);
$Cost = ['CostCenterCode' => $newccc,
'CostCenterName' => $CostCenterName,
'ApprovedBy' => $approverId,
'CreatedBy' => $userId,
'CreatedDate' => $currentdt
];
if ($this->costcenter_model->saveCostCenter($Cost) > 0) {
$data = ['status' => true, 'message' => 'Successfully created cost details'];
}
for ($j = 0; $j < count($comma_separated); $j++) {
$DeptCode = $comma_separated[$j];
$this->costcenter_model->DeleteDepartment($DeptCode, $CostCode);
$Dept = array('CostCenterCode' => $CostCode, 'DEPCode' => $DeptCode, 'CreatedBy' => $CreateBy, 'createdDate' => $createddt);
$this->costcenter_model->addCostCenterDepartment($Dept);
}
$RowCount = $this->request->getPost('txtRowCount');
for ($i = 1; $i <= $RowCount; $i++) {
$BudgetType = $this->request->getPost('BudgetType' . $i);
$BudgetYear = $this->request->getPost('BudgetYear' . $i);
$BudgetAmount = $this->request->getPost('BudgetAmount' . $i);
$Remarks = $this->request->getPost('Remarks' . $i);
$this->costcenter_model->DeleteBudget($BudgetType, $BudgetYear, $CostCode);
$Budget = array('CostCenterCode' => $CostCode, 'BudgetType' => $BudgetType, 'BudgetYear' => $BudgetYear, 'BudgetAmount' => $BudgetAmount, 'Remarks' => $Remarks, 'CreatedBy' => $CreateBy, 'createdDate' => $createddt);
$this->costcenter_model->addBudget($Budget);
}
echo 'Successfully Created Cost details';
// }
}
/**
* This function is used load user edit information
* @param number $userId : Optional : This is user id
*/
function editCostCenter($CostCode = NULL)
{
if ($CostCode == '') {
$CostCenterID = $_GET['CostCode'];
} else {
$CostCenterID = $CostCode;
$Cost = ['CostCenterName' => $CostCenterName,'UpdatedBy' => $userId,'UpdatedDate' => $currentdt];
if ($this->costcenter_model->updateCostCenter($Cost, $id) > 0) {
$data = ['status' => true, 'message' => 'Successfully updated cost details'];
}
}
$data['CostMaster'] = $this->costcenter_model->GetCostCenterMaster($CostCenterID);
$data['CostDepts'] = $this->costcenter_model->GetCostCenterDepartment($CostCenterID);
$data['CostBudget'] = $this->costcenter_model->GetCostCenterBudget($CostCenterID);
$data['DeptList'] = $this->costcenter_model->GetDepartmentNotinCostCenter($CostCenterID);
$data['BudType'] = $this->costcenter_model->GetBudgetTypeNotinCostCenter($CostCenterID, 'C004');
$data['BudYear'] = $this->costcenter_model->GetBudgetYear($CostCenterID);
$data['FiscalYear'] = $this->costcenter_model->getFiscalYear();
//print_r(count($data['BudType']));
$this->global['pageTitle'] = 'Edit Cost';
$this->loadViews("editCostCenter", $this->global, $data, NULL);
return $this->response->setJSON($data);
}
/**
* delete the Cost
*/
function deleteCostCenter($CostCode = NULL)
{
@ -183,246 +108,9 @@ class CostCenter extends BaseController
}
function GetBudgetForYear()
{
//$id = $this->request->getPost('id');
$BudYear = $_GET['BudYear'];
$CostCenterID = $_GET['CostCode'];
$result = $this->costcenter_model->GetCostCenterBudgetByYear($CostCenterID, $BudYear);
$BudList = $this->costcenter_model->GetCostBudgetTypeByYear($CostCenterID, 'C004', $BudYear);
$HTML = "";
$HTML2 = "";
$index = 0;
// $HTML2 = $BudList[0]['ConfigValue'];
//if($BudList->num_rows() > 0){
for ($j = 0; $j < count($BudList); $j++) {
$ConfigValue = $BudList[$j]['ConfigValue'];
$HTML2 .= "<option value='" . $ConfigValue . "'>" . $ConfigValue . "</option>";
}
for ($i = 0; $i < count($result); $i++) {
$index = $index + 1;
$BudgetType = $result[$i]['BudgetType'];
$BudgetYear = $result[$i]['BudgetYear'];
$BudgetAmount = $result[$i]['BudgetAmount'];
$Remarks = $result[$i]['Remarks'];
$HTML .= "<tr id='" . $index . "'>
<td align='left'>" . $BudgetType . "</td>
<input type='hidden' name='BudgetType" . $index . "' id='BudgetType" . $index . "' value='" . $BudgetType . "'/>
<input type='hidden' name='BudgetYear" . $index . "' id='BudgetYear" . $index . "' value='" . $BudgetYear . "'/>
<input type='hidden' name='BudgetAmount" . $index . "' id='BudgetAmount" . $index . "' value='" . $BudgetAmount . "'/>
<input type='hidden' name='Remarks" . $index . "' id='Remarks" . $index . "' value='" . $Remarks . "'/>
<td align='left'>" . $BudgetYear . "</td>
<td align='left'>" . $BudgetAmount . "</td>
<td align='left'>" . $Remarks . "</td>
<td>
<a data-target='#Edit' data-id=" . $index . " data-userid=" . $index . " data-toggle='modal' href='#Edit'><i class='fa fa-pencil' data-toggle='tooltip' title='Click here to view/Edit the " . $BudgetType . " Budget details'></i>&nbsp;&nbsp;&nbsp;</a> </td></tr>
";
}
$HTML .= "<input type='hidden' name='txtRowCount' id='txtRowCount' value='" . $index . "'/>";
die(json_encode(array('Html' => $HTML, 'BudYear' => $HTML2)));
// echo $HTML2;
}
/**
* This function is used to edit the user information
* export the Cost
*/
function updateCostCenter()
{
$CostCode = $this->request->getPost('CostCode');
$CostCode = ($CostCode !== null && is_string($CostCode)) ? strtoupper(trim($CostCode)) :null;
$CostName = $this->request->getPost('CostName');
$CostName = ($CostName !== null && is_string($CostName)) ? strtoupper(trim($CostName)) :null;
$updatedBy = $this->session->get('userId');
$SelectedDepartment = (string)$this->request->getPost('txtSelectedDepartment');
// $ApproverName = $this->request->getPost('ApprovedBy');
// $ApproverName = $this->session->get('EmpID');
$ApproverName = NULL;
$comma_separated = [];
print_r(strlen($SelectedDepartment));
if(strlen($SelectedDepartment)>0)
{
$comma_separated = explode(':', $SelectedDepartment);
}
$updateddt = get_current_date_time();
$Cost = array( 'CostCenterName'=>$CostName,'ApprovedBy'=>$ApproverName,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt);
$this->costcenter_model->EditCost($Cost,$CostCode);
if(count($comma_separated)>= 1)
{
for ($j = 0; $j < count($comma_separated); $j++)
{
// $DeptCode = $comma_separated[$j];
// $this->costcenter_model->DeleteDepartment( $DeptCode,$CostCode);
// $Dept = array('CostCenterCode'=>$CostCode, 'DEPCode'=>$DeptCode,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt);
// $this->costcenter_model->addCostCenterDepartment($Dept);
}
}
$RowCount = $this->request->getPost('txtRowCount');
if($RowCount){
for ($i = 1; $i <= $RowCount; $i++)
{
$BudgetType = $this->request->getPost('BudgetType'.$i);
$BudgetYear = $this->request->getPost('BudgetYear'.$i);
$BudgetAmount = $this->request->getPost('BudgetAmount'.$i);
$Remarks = $this->request->getPost('Remarks'.$i);
// $this->costcenter_model->DeleteBudget($BudgetType,$BudgetYear,$CostCode);
$Budget = array('CostCenterCode'=>$CostCode, 'BudgetType'=>$BudgetType,'BudgetYear'=>$BudgetYear,'BudgetAmount'=>$BudgetAmount,'Remarks'=>$Remarks,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt);
$ExistYearBudget = $this->costcenter_model->CheckExistBudget($BudgetType,$BudgetYear,$CostCode);
// print_r($Budget);
if($ExistYearBudget){
$this->costcenter_model->updateBudget($Budget,$BudgetType,$BudgetYear,$CostCode);
}
else{
$this->costcenter_model->addBudget($Budget);
}
}
}
echo('Successfully Updated Cost details');
}
function DeleteCostDepartment()
{
// echo "dasf";
// die();
$CostCode = $this->request->getPost('CostCode');
$CostCode = ($CostCode !== null && is_string($CostCode)) ? strtoupper(trim($CostCode)) :null;
$CostName = $this->request->getPost('CostName');
$CostName = ($CostName !== null && is_string($CostName)) ? strtoupper(trim($CostName)) :null;
$updatedBy = $this->session->get('userId');
$SelectedDepartment = $this->request->getPost('txtSelectedDepartment');
$this->costcenter_model->DeleteDepartment($SelectedDepartment, $CostCode);
echo ("Department Removed Successfully");
}
function AddCostDepartment()
{
$CostCode = $this->request->getPost('CostCode');
$CostCode = ($CostCode !== null && is_string($CostCode)) ? strtoupper(trim($CostCode)) :null;
$CostName = $this->request->getPost('CostName');
$CostName = ($CostName !== null && is_string($CostName)) ? strtoupper(trim($CostName)) :null;
$updatedBy = $this->session->get('userId');
$SelectedDepartment = $this->request->getPost('txtSelectedDepartment');
// $updatedBy = $this->session->get ( 'userId' );
$updateddt = get_current_date_time();
$Dept = array('CostCenterCode' => $CostCode, 'DEPCode' => $SelectedDepartment, 'CreatedBy' => $updatedBy, 'createdDate' => $updateddt, 'UpdatedBy' => $updatedBy, 'UpdatedDate' => $updateddt);
$this->costcenter_model->addCostCenterDepartment($Dept);
echo ("Department Added Successfully");
}
// function AddCostDepartment()
// {
// // echo "343";
// // die();
// $CostCode = strtoupper(trim($this->request->getPost('CostCode')));
// $CostName = strtoupper(trim($this->request->getPost('CostName')));
// $updatedBy = $this->session->get ( 'userId' );
// $SelectedDepartment = $this->request->getPost('txtSelectedDepartment');
// //echo $SelectedDepartment;
// //die();
// $ApproverName = $this->request->getPost('ApprovedBy');
// $comma_separated = "";
// //print_r(strlen($SelectedDepartment));
// if(strlen($SelectedDepartment)>0)
// {
// $comma_separated = explode(':', $SelectedDepartment);
// }
// //die();
// //echo count($comma_separated);
// $updateddt = get_current_date_time();
// if(count($comma_separated)>= 1)
// {
// for ($j = 0; $j < count($comma_separated); $j++)
// {
// $DeptCode = $comma_separated[$j];
// $this->costcenter_model->DeleteDepartment( $DeptCode,$CostCode);
// $Dept = array('CostCenterCode'=>$CostCode, 'DEPCode'=>$DeptCode,'CreatedBy'=>$updatedBy,'createdDate'=>$updateddt,'UpdatedBy'=>$updatedBy,'UpdatedDate'=>$updateddt);
// //print_r($Dept);
// $this->costcenter_model->addCostCenterDepartment($Dept);
// }
// echo "Updated";
// }
// }
function viewcost($CostCenterID = NULL)
{
if ($CostCenterID == null) {
redirect('costListing');
}
$data['Cost'] = $this->costcenter_model->getuserinfo($CostCenterID);
//$data['users'] = $this->purchaseorder_model->getusers();
$this->global['pageTitle'] = 'View Cost';
$this->loadViews("viewcost", $this->global, $data, NULL);
}
/**
* This function is used to delete the user using userId
* @return boolean $result : TRUE / FALSE
*/
function deletecost()
{
// if($this->isAdmin() == TRUE)
// {
// echo(json_encode(array('status'=>'access')));
// }
// else
// {
$CostCenterID = $this->request->getPost('CostCentreID');
$cost = array('CreateDate' => date('Y-m-d H:i:sa'));
$result = $this->costcenter_model->deletecost($cost, $CostCenterID);
if ($result > 0) {
echo (json_encode(array('status' => TRUE)));
} else {
echo (json_encode(array('status' => FALSE)));
}
//}
}
function exportcost()
{

View File

@ -237,6 +237,7 @@ class Rawmaterialdetails extends BaseController
}
$data['materialDetails'] = $this->rawmaterialdetails_model->getMaterialDetails($RawMaterialID);
$data['material'] = $this->rawmaterialdetails_model->getmaterialType();
$data['currentstock'] = $this->rawmaterialdetails_model->getMaterialstock($RawMaterialID, $currentdate);
$data['materialType'] = $this->rawmaterialdetails_model->getmaterialType($MaterialType);
$data['materialCategory'] = $this->rawmaterialdetails_model->getmaterialCategory($MaterialCategory);

View File

@ -130,4 +130,20 @@ if (!function_exists('trans')) {
return $lang_string;
}
}
}
if (!function_exists('generateCostCenterCode')) {
function generateCostCenterCode($id)
{
if ($id < 10) {
$CostCenterCode = 'C00' . $id;
} elseif ($id < 100) {
$CostCenterCode = 'C0' . $id;
} else {
$CostCenterCode = 'C' . $id;
}
return $CostCenterCode;
}
}

View File

@ -16,7 +16,7 @@ class Costcenter_model extends Model
function CostListing()
{
$builder = $this->db->table('t_costcenter_master as Cost')
->select('Cost.CostCenterCode as code,Cost.CostCenterName as CostCenterName , Cost.ApprovedBy as ApprovedBy,Emp.FirstName as FirstName,Emp.Designation as Designation ,Cost.CreatedDate,Cost.IsActive,Cost.DeletedBy,Cost.DeletedBy')
->select('Cost.id as id, Cost.CostCenterCode as code,Cost.CostCenterName as CostCenterName , Cost.ApprovedBy as ApprovedBy,Emp.FirstName as FirstName,Emp.Designation as Designation ,Cost.CreatedDate,Cost.IsActive,Cost.DeletedBy,Cost.DeletedBy')
->join('t_employee_details as Emp', 'Emp.EmpID=Cost.ApprovedBy');
@ -30,21 +30,29 @@ class Costcenter_model extends Model
* This function used to get user information by id
* @param number $userId : This is user id
* @return array $result : This is user information
*/
function saveCostCenter($Cost)
{
*/
public function saveCostCenter($Cost) {
$this->db->transStart();
$builder = $this->db->table('t_costcenter_master');
$builder->insert($Cost);
$insert_id = $this->db->affectedRows();
$this->db->transComplete();
return $insert_id;
$builder->insert($Cost);
$aff_row = $this->db->affectedRows();
$this->db->transComplete();
return $aff_row;
}
public function updateCostCenter($Cost, $id) {
$this->db->table('t_costcenter_master')
->where('id', $id)
->update($Cost);
$aff_row = $this->db->affectedRows();
return $aff_row;
}
public function lastCCID(){
$query = $this->db->table('t_costcenter_master')->select('id')->orderBy('id', 'DESC')->limit(1)->get();
$lastCCID = $query->getRow()->id;
return $lastCCID;
}
function getFiscalYear()
{
$builder = $this->db->table('t_company_details')
@ -54,44 +62,6 @@ function saveCostCenter($Cost)
return $query->getResult();
}
function addCostCenterDepartment($Dept)
{
$this->db->transStart();
$builder = $this->db->table('t_costcenter_departments');
$builder->insert($Dept);
$insert_id = $this->db->affectedRows();
$this->db->transComplete();
return $insert_id;
}
function addBudget($Budget)
{
$this->db->transStart();
$builder = $this->db->table('t_costcenter_budget');
$builder->insert($Budget);
$insert_id = $this->db->affectedRows();
$this->db->transComplete();
return $insert_id;
}
function getApproverName()
{
$builder = $this->db->table('t_employee_details')
->select('EmpID,FirstName,LastName,Designation')
->where('Departmentcode ', 'DEP10');
$query =$builder->get();
return $query->getResult();
}
/**
* This function used to get user information by id
* @param number $userId : This is user id
@ -337,19 +307,7 @@ where Dept.DEPCode not in
}
}
/* *//**
* This function is used to get the Department details from t_departmentdetails
* @return array $result : This is result of the query
*/
function getDepartment()
{
$builder = $this->db->table('t_departmentdetails')
->select('DEPCode, DepartmentName')
->where('IsActive =', 1);
$query =$builder->get();
return $query->getResult();
}
/**
* This function is used to get the Config value from configuration table
* @return array $result : This is result of the query

View File

@ -1,871 +0,0 @@
<?php
$FYStart ='';
$FYEnd ='';
$FYear = '';
$opt = array("0"=>'Select Budget Year');
if(!empty($FiscalYear))
{
foreach ($FiscalYear as $Fy)
{
$FYStart =$Fy->StartYear;
$FYEnd =$Fy->EndYear;
}
//$FYear = $FYStart." - ".$FYEnd ;
}
for($i=1;$i<5;$i++)
{
$FYear = $FYStart." - ".$FYEnd ;
$opt[$FYear] = $FYear;
$FYStart++;
$FYEnd++;
}
//print_r($opt);
?>
<script>
$(function() {
var d = new Date();
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear() ;
var SIAStartYear = year - 2015;
var mindt = year-70;
var maxdt = year-15;
// $("#AddYear").datepicker({
//minDate : new Date(year-SIAStartYear,1,1),
//maxDate :new Date(year+3,1,1),
//dateFormat: 'yy', changeYear: true,
//});
// $("#EditYear").datepicker({
// minDate : new Date(year-SIAStartYear,1,1),
//maxDate :new Date(year+3,1,1),
// dateFormat: 'yy', changeYear: true,
//});
//$('#selectDistriList').multiSelect();
});
</script>
<style>
.ui-datepicker-month {
display: none;
}
.ui-datepicker-prev{
display: none;
}
.ui-datepicker-next{
display: none;
}
</style>
<div class="content-wrapper" style="min-height: 537px;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Add Cost List</center>
</h1>
</section>
<section class="content">
<div style="text-align:right;">
<a href="<?php echo base_url() ?>costListing" class="btn btn-cancel" value="Back">Back</a>
</div>
<br>
<div class="row">
<!-- left column -->
<div class="col-md-12">
<div class="box box-success">
<!-- form start -->
<?php
$attributes = array('class' => 'form-label-left addCost ','name' => 'addCost','id' => 'addCost');
echo form_open(base_url().'saveCostCenter/',$attributes); ?>
<div class="box-body">
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="form-group">
<label for="CostName">Cost Center Code </label><font color="Red">*</font>
<div class="form-group">
<?php
$data = array('name' => 'CostCode','value' => set_value('CostCode'),'id'=>'CostCode', 'class' => 'form-control' ,'required' => 'true','style'=>'text-transform:uppercase;','maxlength'=>'10' );
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="Description">Cost Center Name </label><font color="Red">*</font>
<div class="form-group">
<?php
$data = array('name' => 'CostName','value' => set_value('CostName'),'id'=>'CostName', 'class' => 'form-control' ,'required' => 'true','style'=>'text-transform:uppercase;','maxlength'=>'100');
echo form_input($data);
?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<div class="col-md-4">
<label>Department</label>
<div>
<?php
$options = array("0"=>'Select Department');
//print_r( $options);
if(!empty($Department))
{
foreach ($Department as $SID):
$options[$SID->DEPCode] = $SID->DEPCode.' '.' - '.' '.$SID->DepartmentName;
endforeach;
}
echo form_multiselect('distriList', $options,set_value('distriList',$options),'id="distriList"' ,'class="form-control required"','required="true"');
?>
</div>
</div>
<div class="col-md-4">
<center>
<a style="color:white" href="javascript:void(0);" id="addPop"><button type="button" style="margin: 30px 0px 0px 15px;" class="btn btn-success">Add</button></a><br>
<a style="color:white" href="javascript:void(0);" id="removePop"><button type="button" style="margin: 10px 0px 0px 15px;" class="btn btn-success">Remove</button></a><br>
</center>
</div>
<div class="col-md-4">
<b>&nbsp;</b>
<?php
$option["0"] = 'Selected Department';
echo form_multiselect('selectDistriList[]', $option,set_value('selectDistriList[]',$option),'id="selectDistriList"','size="10"');
?>
</div>
</div>
<div class="col-md-6">
<!-- <label for="CostName">Approved By </label><font color="Red">*</font> -->
<!-- <div class="form-group"> -->
<?php
$options = array("-1"=>'Select Approver');
//print_r( $options);
if(!empty($Approver))
{
foreach ($Approver as $SID):
$options[$SID->EmpID] = $SID->EmpID . " - " . $SID->FirstName . " - " . $SID->Designation;
endforeach;
}
// echo form_dropdown('ApprovedBy',$options,set_value('ApprovedBy'),'id="ApprovedBy"', 'class = "form-control "'); ?>
<!-- </div> -->
</div>
</div>
</div>
</div>
<br>
<div col="row">
<div style="text-align:right">
<a onclick="OpenModal()" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add Budget</a>
<!-- Modal -->
<div class="modal fade" id="addbudgetmodel" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Add Budget</center>
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Budget Type :
</div>
<div class="col-md-5">
<?php
$options = array("-1"=>'Select Budget Type');
//print_r( $options);
if(!empty($BudgetType))
{
foreach ($BudgetType as $SID):
$options[$SID->ConfigValue] = $SID->ConfigValue;
endforeach;
}
echo form_dropdown('Addbudget',$options,set_value('Addbudget'),'id="Addbudget"', 'class = "form-control "'); ?>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Budget Year :
</div>
<div class="col-md-5">
<?php echo form_dropdown('AddYear', $opt,set_value('AddYear'),'id="AddYear"' ,'class="form-control required"','required="true"'); ?>
</div>
</div>
</div>
<!-- <div class="form-group"> -->
<!-- <div class="row"> -->
<!-- <div class="col-md-3 col-md-offset-2"> -->
<!-- Budget Amount : -->
<!-- </div> -->
<!-- <div class="col-md-5"> -->
<input class="form-control" onkeypress="return isNumberKey(event);" name="AddAmout" class="form-control" id="AddAmout" type="hidden" value=0>
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Remarks :
</div>
<div class="col-md-5">
<input class="form-control" name="AddRemarks" class="form-control" id="AddRemarks" type="text">
</div>
</div>
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClick" ID="tempClick" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
</div>
</div>
</div>
</div>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table id="BudgetTable" class="table table-striped responsive-utilities jambo_table" >
<thead style="background-color: #CFCFCF;">
<th>Budget Type</th>
<th>Budget Year</th>
<!-- <th>Budget Amount</th> -->
<th>Remarks</th>
<th>Action</th>
</thead>
<tbody id="tempAppend">
</tbody>
</table>
<!-- Modal For edit -->
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close"
data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<h4 class="modal-title" id="myModalLabel">
<center> Edit Budget</center>
</h4>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Budget Type :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'Editbudget', 'value' => set_value('Editbudget'),'id'=>'Editbudget', 'class' => 'form-control','readonly'=>'true');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Budget Year :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'EditYear', 'value' => set_value('EditYear'),'id'=>'EditYear', 'class' => 'form-control','onkeypress'=>'return isNumberKey(event);','onkeypress'=>'return false;');
echo form_input($data);
?>
</div>
</div>
</div>
<!-- <div class="form-group"> -->
<!-- <div class="row"> -->
<!-- <div class="col-md-3 col-md-offset-2">
Budget Amount :
</div> -->
<!-- <div class="col-md-5"> -->
<?php
$data = array('name' => 'EditAmout', 'value' => set_value('EditAmout'),'id'=>'EditAmout', 'class' => 'form-control','onkeypress'=>'return isNumberKey(event);');
echo form_hidden($data);
?>
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Remarks :
</div>
<div class="col-md-5">
<?php
$data = array('name' => 'EditRemarks', 'value' => set_value('EditRemarks'),'id'=>'EditRemarks', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal" style="margin-top: -24px;" value="Cancel">Cancel</a>
<a class="btn btn-success font tempClickEdit" ID="tempClickEdit" style="margin-top: -24px;"><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="content"></div>
<div class="box-footer" style="text-align:right">
<input type="hidden" name="txtSelectedDepartment" id="txtSelectedDepartment" />
<input type="hidden" name="txtRowCount" id="txtRowCount" />
<!-- <input type="reset" class="btn btn-success" value="Cancel" />-->
<a href="<?php echo base_url() ?>costListing" class="btn btn-cancel" id="cancel" value="Cancel">Cancel</a>
<input type="submit" class="btn btn-success" value="Submit" />
</div>
</div>
</form>
</div>
</div>
<div class="col-md-4">
<?php
helper('form');
$error = session()->getFlashdata('error');
if($error)
{
?>
<div class="alert alert-danger alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('error'); ?>
</div>
<?php } ?>
<?php
$success = session()->getFlashdata('success');
if($success)
{
?>
<div class="alert alert-success alert-dismissable">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<?php echo session()->getFlashdata('success'); ?>
</div>
<?php } ?>
<div class="row">
<div class="col-md-12">
<?php //echo validation_errors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>'); ?>
</div>
</div>
</div>
</div>
</section>
</div>
<script type="text/html" id="tempList">
<tr id="<%=index%>">
<?php
$data = array('name' => '"Budget[<%=index%>][index]"', 'value' => set_value('<%=index%>'),'id'=>'"Budget[<%=index%>][index]"', 'class' => 'form-control','type'=>'hidden');
echo form_input($data);
?>
<td align="left"><%=BudgetType%></td>
<td align="left"><%=BudgetYear%></td>
<td align="left" style="display: none;"><%=BudgetAmount%></td>
<td align="left"><%=Remarks%></td>
<td>
<a data-target='#Edit' data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#Edit"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <%=BudgetType%> Budget details"></i>&nbsp;&nbsp;&nbsp;</a>
</td>
</tr>
</script>
<script>
function OpenModal()
{
if($('#CostCode').val()=='')
{
alert('Please Enter the Costcenter Code');
$('#CostCode').focus();
return false;
}
else if($('#CostName').val()=='')
{
alert('Please Enter the Costcenter Name');
$('#CostName').focus();
return false;
}
else if($('#txtSelectedDepartment').val()=='')
{
alert('Please Select the Department');
$('#selectDistriList').focus();
return false;
}
// else if($('#ApprovedBy').val() == "-1")
// {
// alert('Please Select the Approver');
// $('#ApprovedBy').focus();
// return false;
// }
else
{
$('#addbudgetmodel').modal('show');
}
}
var index = '1';
var numbers = /^[0-9]+$/;
var userid = '';
$("#Edit").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
$('#Editbudget').val($('#BudgetTable tr:eq('+ userid +') td:eq(0)').text());
$('#EditYear').val($('#BudgetTable tr:eq('+ userid +') td:eq(1)').text());
$('#EditAmout').val($('#BudgetTable tr:eq('+ userid +') td:eq(2)').text()).hide();
$('#EditRemarks').val($('#BudgetTable tr:eq('+ userid +') td:eq(3)').text());
});
var typeArray = [];
var typeflag = 0;
var iflag = 0;
$('.tempClick').click(function(){
if ($("#Addbudget option:selected").val() =='-1' )
{
alert('Please Select the Budget Type ');
//return;
}
//if ($("#AddYear option:selected").val() =='0' )
if($('#AddYear').val() == '0' )
{
alert('Please Enter the Budget Year');
//return;
}
// if(document.getElementById('AddAmout').value == '' )
// {
// alert('Please Enter the Budget Amount');
// // return;
// }
if ($("#Addbudget option:selected").val() !='-1' && $('#AddYear').val() != '0' && $('#AddAmout').val() != '' )
{
$('#BudgetTable').show();
var temp = index;
var BudType = $("#Addbudget option:selected").val();
var BudYear = $("#AddYear").val();
var BudAmount = $("#AddAmout").val() ? $("#AddAmout").val() : 0;
//$('#Addbudget option[value='+BudType+']').remove();
var BudRemarks = $('#AddRemarks').val();
$('#AddYear').val('');
$('#AddAmout').val('');
$('#AddRemarks').val('');
var str = (BudType.concat(BudYear));
//alert('outsideeachfunction'+str);
$.each(typeArray,function(i,item){
//alert('each'+item+'input'+BudType);
//alert('str'+str);
if(str == item)
{
iflag=iflag+1;
//alert('iflag'+iflag);
}
});
//alert('i value'+iflag);
//alert('array'+typeArray);
if(iflag == 0)
{
typeArray.push(str);
typeflag = 1;
index = parseInt(index)+1;
var template = jQuery("#tempList").html();
$('#tempAppend').append(_.template(template,{index:temp,BudgetType:BudType,BudgetYear:BudYear,BudgetAmount:BudAmount,Remarks:BudRemarks}));
}
else
{
alert(" Budget Type and Budget Year values Already Exsits in our database!");
iflag = 0;
}
var theForm = $(".addCost");
addHidden(theForm,"BudgetType"+temp,BudType);
addHidden(theForm,"BudgetYear"+temp,BudYear);
addHidden(theForm,"BudgetAmount"+temp,BudAmount);
addHidden(theForm,"Remarks"+temp,BudRemarks);
$('#txtRowCount').val(temp);
CountRows();
}
});
function addHidden(theForm, key, value) {
// Create a hidden input element, and append it to the form:
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;
input.id = key;
input.value = value;
theForm.append(input);
}
$('.tempClickEdit').click(function(){
if(document.getElementById('EditYear').value == '' )
{
alert('Please Enter the Budget Year');
//return;
}
// if(document.getElementById('EditAmout').value == '' )
// {
// alert('Please Enter the Budget Amount');
// // return;
// }
if ( $('#EditAmout').val() != '' && $('#EditYear').val() != '' )
{
var temp = userid;
var BudYear = $("#EditYear").val();
var BudAmount = $("#EditAmout").val();
var BudRemarks = $('#EditRemarks').val();
$('#BudgetTable tr:eq('+ temp +') td:eq(1)').text(BudYear);
$('#BudgetTable tr:eq('+ temp +') td:eq(2)').text(BudAmount).hide();
$('#BudgetTable tr:eq('+ temp +') td:eq(3)').text(BudRemarks);
$('#BudgetYear'+temp).val(BudYear);
$('#BudgetAmount'+temp).val(BudAmount).hide();
$('#Remarks'+temp).val(BudRemarks);
}
else
{
alert('Please enter all the values');
}
});
function ConfirmDelete()
{
var x = confirm("Are you sure you want to delete?");
if (x)
return true;
else
return false;
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
function Rowcount()
{
var rowCount = $('#BudgetTable').length;
if(rowCount=='4')
{
$("#addbudgetmodel").modal('hide');
}
else
{
$("#addbudgetmodel").modal('show');
}
}
var totalRowCount = 0;
var rowCount = 0;
var table = document.getElementById("BudgetTable");
var rows = table.getElementsByTagName("tr");
function CountRows() {
totalRowCount = 0;
rowCount = 0;
table = document.getElementById("BudgetTable");
rows = table.getElementsByTagName("tr")
for (var i = 0; i < rows.length; i++) {
totalRowCount++;
if (rows[i].getElementsByTagName("td").length > 0) {
rowCount++;
}
}
var message = "Total Row Count: " + totalRowCount;
message += "\nRow Count: " + rowCount;
//alert(message);
if(totalRowCount>"16")
{
$("#addbudgetmodel").modal('hide');
}
else
{
return false;
}
}
</script>
<script>
$('#addPop').click(function () {
if ($('#distriList option:selected').val() != null) {
if($('#distriList option:selected').val()==0 ){
alert('please select Department');
}
else
{
var tempSelect = $('#distriList option:selected').val();
var tempText = $('#distriList option:selected').text();
var o = new Option(tempText,tempSelect);
var hidval = tempSelect;
var orgVal = $('#txtSelectedDepartment').val();
var Selectedval = ''
if(orgVal != '')
{
Selectedval = orgVal + ':' + hidval;
}
else
{
Selectedval = hidval
}
$('#txtSelectedDepartment').val(Selectedval);
$(o).html(tempText);
$("#selectDistriList").append(o);
$('#distriList option:selected').remove();
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
tempSelect = '';
tempText = '';
Selectedval = '';
}
} else {
alert("Before add please select any position.");
}
});
$('#removePop').click(function () {
if ($('#selectDistriList option:selected').val() != null) {
if($('#selectDistriList option:selected').val() == 0){
//alert('cannot removed');
}
else
{
Selectedval ='';
$('#txtSelectedDepartment').val(Selectedval);
var tempSelect = $('#selectDistriList option:selected').val();
$('#selectDistriList option:selected').remove().appendTo('#distriList');
$("#selectDistriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#distriList").attr('selectedIndex', '-1').find("option:selected").removeAttr("selected");
$("#distriList").val(tempSelect);
tempSelect = '';
}
}
else {
alert("Before remove please select any position.");
}
});
var baseurl = "<?php print base_url(); ?>";
$(".addCost").submit(function(e) {
e.preventDefault();
if(validate())
{
$('#content').loader('show');
$.ajax({
data:$('.addCost').serialize(),
type:"POST",
url:"<?php echo base_url() ?>saveCostCenter",
success:function(data) {
if(data)
{
console.log(data);
$('#content').loader('hide');
alert(data);
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
// window.location = baseurl + 'costListing';
}
else
{
alert("Error");
}
}
});
}
});
function validate()
{
if($("#txtSelectedDepartment").val().length < 1)
{
alert('Please Select Department');
return false;
}
else if($("#txtRowCount").val().length < 1)
{
alert('Please Add Budget');
return false;
}
// else if($("option:selected", $("#ApprovedBy")).val() == '-1')
// {
// alert('Please Select Approver Names');
// return false;
// }
else
{
return true;
}
}
</script>

View File

@ -196,7 +196,7 @@
$('#MatCate').autocomplete("option", "minLength", 0);
},
serviceUrl: "<?php echo base_url(); ?>rawmaterialdetails/autocomplete",
serviceUrl: "<?php echo base_url(); ?>rawmaterialdetailsautocomplete",
onSelect: function(suggestion) {
var data = suggestion.ConfigValue;

View File

@ -1,98 +1,190 @@
<div class="content-wrapper">
<section class="content">
<div class="content-wrapper">
<section class="content">
<div class="box">
<div class="box-header">
<CENTER><h3 class="box-title"> Cost Details</h3></CENTER>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 text-right">
<div class="form-group">
<a class="btn btn-success" href="<?php echo base_url(); ?>addCostCenter">Add New Cost List</a>
<a class="btn btn-success" href="<?php echo base_url(); ?>exportcost">Export Cost Details <i class="fa fa-download"aira-hidden="true"></i></a>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<table id="datatable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;" >
<thead style="background-color: #ddd;">
<tr>
<th>Cost Center Code</th>
<th>Cost Center Name</th>
<th>Created By</th>
<th>Create Date</th>
<th>Active</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if(!empty($userRecords))
{
foreach($userRecords as $record)
{
?>
<tr>
<td><?php echo $record->code ?></td>
<td><?php echo $record->CostCenterName ?></td>
<!-- <td><?php echo $record->ApprovedBy ?></td> -->
<td><?php echo $record->FirstName ?></td>
<td align="right"><?php
$date = new DateTime($record->CreatedDate);
echo $date->format('d-m-Y'); ?></td>
<td><?php
$R='';
$record->IsActive == 1?$R='ACTIVE':$R='INACTIVE';
echo $R;
?></td>
<td>
<?php
if($record->DeletedBy == ''){
?>
<a href="<?php echo base_url().'editCostCenter?CostCode='.$record->code; ?>"><i class="fa fa-pencil"></i>&nbsp;&nbsp;&nbsp;</a>
<a href="<?php echo base_url().'deleteCostCenter?CostCode='.$record->code; ?>"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
<div class="box-header">
<CENTER>
<h3 class="box-title"> Cost Details</h3>
</CENTER>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 text-right">
<div class="form-group">
<a data-toggle="modal" href="#ccwizard" data-id="0" data-name="" class="btn btn-success">Add New Cost List</a>
<a class="btn btn-success" href="<?php echo base_url(); ?>exportcost">Export Cost Details <i class="fa fa-download" aira-hidden="true"></i></a>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<table id="datatable" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #ddd;">
<tr>
<th>Create Date</th>
<th>Create Time</th>
<th>Cost Center Code</th>
<th>Cost Center Name</th>
<th>Created By</th>
<th>Active</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($userRecords)) {
foreach ($userRecords as $record) {
<!-- <a href="<?php echo base_url().'CostCenter/viewcost?CostCode='.$record->code; ?>"><i class="fa fa-eye"></i>&nbsp;&nbsp;&nbsp;</a> -->
<?php } ?>
</td>
</tr>
<?php
}
$createdat = new DateTime($record->CreatedDate);
$date = $createdat->format('d-m-Y');
$time = $createdat->format('h:i A');
?>
<tr></td>
<td align="right"><?php echo $date; ?></td>
<td align="right"><?php echo $time; ?></td>
<td><?php echo $record->code ?></td>
<td><?php echo $record->CostCenterName ?></td>
<!-- <td><?php echo $record->ApprovedBy ?></td> -->
<td><?php echo $record->FirstName ?></td>
<td><?php
$R = '';
$record->IsActive == 1 ? $R = 'ACTIVE' : $R = 'INACTIVE';
echo $R;
?></td>
<td>
<?php
if ($record->DeletedBy == '') {
?>
<a data-toggle="modal" href="#ccwizard" data-id="<?php echo $record->id; ?>" data-name="<?php echo $record->CostCenterName; ?>" ><i class="fa fa-pencil"></i></a>
<a href="<?php echo base_url() . 'deleteCostCenter?CostCode=' . $record->code; ?>"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
<?php } ?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script type="text/javascript">
$(function () {
$.fn.dataTable.moment( 'DD-MM-YYYY' );
$('#datatable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
// "columnDefs" : [{"targets":3, "type":"date-eu"}],
"aaSorting": [[ 3, "desc" ]],
"info": true,
"autoWidth": true
});
});
</script>
<!-- <script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script> -->
}
?>
</tbody>
</table>
</div>
</div>
</div>
<!-- for Add and edit Modal -->
<div class="modal fade" id="ccwizard" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only">Close</span>
</button>
<center><h4 class="modal-title" id="myModalLabel"></h4></center>
</div>
<!-- Modal Body -->
<div class="modal-body">
<form id="costCenterForm" class="form-horizontal" role="form">
<div class="form-group">
<div class="row">
<div class="col-md-3 col-md-offset-2">
Cost Center Name:
</div>
<div class="col-md-5">
<input type="text" name="CostCenterName" id="CostCenterName" class="form-control">
<input type="hidden" name="id" id="id" class="form-control">
</div>
</div>
</div>
</form>
</div>
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-cancel" data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClick" id="tempClick">
<span class="bold">Submit</span>
</a>
</div>
</div>
</div>
</div>
</section>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<script src="https://cdn.datatables.net/plug-ins/1.10.16/sorting/datetime-moment.js"></script>
<script type="text/javascript">
$(function() {
$.fn.dataTable.moment('DD-MM-YYYY');
$('#datatable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
// "columnDefs" : [{"targets":3, "type":"date-eu"}],
"aaSorting": [
[3, "desc"]
],
"info": true,
"autoWidth": true
});
});
</script>
<script>
$(document).ready(function() {
$("#ccwizard").on("shown.bs.modal", function(e) {
var id = $(e.relatedTarget).data('id');
var name = $(e.relatedTarget).data('name');
$('#CostCenterName').val('');
$('#id').val(id);
if (id == 0) {
$('.modal-title').html("Add CostCenter");
} else {
$('.modal-title').html("Edit CostCenter");
$('#CostCenterName').val(name);
}
});
$('#tempClick').click(function() {
if ($('#CostCenterName').val() === '') {
alert('Please Enter the Cost Center Name');
return;
}
var formData = {
id: $('#id').val(),
CostCenterName: $('#CostCenterName').val()
};
$.ajax({
type: 'POST',
url: "<?php echo base_url();?>fetchCostCenterDetails",
data: formData,
dataType: 'json',
success: function(response) {
if (response.status) {
alert(response.message);
$('#ccwizard').modal('hide');
location.reload();
} else {
alert(response.message);
}
},
error: function(xhr, status, error) {
alert('An error occurred: ' + error);
}
});
});
});
</script>
<!-- <script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script> -->

File diff suppressed because it is too large Load Diff

View File

@ -142,12 +142,30 @@ if ($total <= $reorder) {
</div>
</div>
<div class="col-md-2">
<!-- <div class="col-md-2">
<div class="form-group">
<label for="MaterialType">Material Type</label>
<input type="text" class="form-control" readonly id="MaterialType" name="MaterialType" value="<?php echo $MaterialType; ?>">
</div>
</div> -->
<div class="col-md-2">
<div class="form-group">
<label for="MaterialType">Material Type</label>
<font color="Red">*</font>
<select class="form-control select2" required id="MaterialType" name="MaterialType">
<?php
if (!empty($material)) {
foreach ($material as $SID) {
?>
<option value="<?= $SID->ConfigValue ?>" <?php if (($MaterialType === $SID->ConfigValue)) echo "selected"; ?>>
<?php echo $SID->ConfigValue ?></option>
<?php
}
}
?>
</select>
</div>
</div>
<div class="col-md-3">
@ -310,6 +328,7 @@ if ($total <= $reorder) {
$("#UOM").select2();
$("#MaterialType").select2();
/** ---- auto search code -------- */
$('#MaterialCategory').autocomplete({
@ -318,7 +337,7 @@ if ($total <= $reorder) {
$('#MaterialCategory').autocomplete("option", "minLength", 0);
},
serviceUrl: "<?php echo base_url(); ?>rawmaterialdetails/autocomplete",
serviceUrl: "<?php echo base_url(); ?>rawmaterialdetailsautocomplete",
onSelect: function(suggestion) {
var data = suggestion.ConfigValue;