Daybook status updation update: kdk
This commit is contained in:
parent
025f0eeadb
commit
e75ca5500c
@ -153,7 +153,7 @@ class DayBook_Controller extends REST_Controller {
|
|||||||
$req['PaidDescription'] = $reqData['description_paid'];
|
$req['PaidDescription'] = $reqData['description_paid'];
|
||||||
$req['VoucherNumber'] = $reqData['voucherNumber'];
|
$req['VoucherNumber'] = $reqData['voucherNumber'];
|
||||||
$req['BranchCode'] = $reqData['branch'];
|
$req['BranchCode'] = $reqData['branch'];
|
||||||
$req['Name'] = $reqData['name'];
|
$req['Name'] = $reqData['name'];
|
||||||
$date = date('Y-m-d H:i:s');
|
$date = date('Y-m-d H:i:s');
|
||||||
$req['UpdatedOn'] = $date;
|
$req['UpdatedOn'] = $date;
|
||||||
$updatedayBookDetails = $this->daybook_model->update_dayBookDetails($req , $updateFor);// Check if the employee exist
|
$updatedayBookDetails = $this->daybook_model->update_dayBookDetails($req , $updateFor);// Check if the employee exist
|
||||||
|
|||||||
@ -67,7 +67,7 @@ class DayBook_model extends CI_Model
|
|||||||
$querys = "SELECT t1.*, t2.ListName, t3.TypeName , t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
|
$querys = "SELECT t1.*, t2.ListName, t3.TypeName , t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
|
||||||
LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
|
LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
|
||||||
WHERE STR_TO_DATE(t1.Date, '%d-%m-%Y') BETWEEN '$fromDate'
|
WHERE STR_TO_DATE(t1.Date, '%d-%m-%Y') BETWEEN '$fromDate'
|
||||||
AND '$toDate' AND t1.BranchCode = '$reqpayType' ORDER BY CreatedOn DESC";
|
AND '$toDate' AND t1.BranchCode = '$reqpayType' ORDER BY ID DESC";
|
||||||
|
|
||||||
// $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $fromDate);
|
// $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $fromDate);
|
||||||
// $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $toDate);
|
// $this->db->where(' STR_TO_DATE(t1.Date, %d-%m-%Y) >=', $toDate);
|
||||||
@ -86,7 +86,7 @@ class DayBook_model extends CI_Model
|
|||||||
$reqpayType = $reqDataBy['localBranchID'];
|
$reqpayType = $reqDataBy['localBranchID'];
|
||||||
$querys = "SELECT t1.*, t2.ListName, t3.TypeName, t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
|
$querys = "SELECT t1.*, t2.ListName, t3.TypeName, t5.Firstname as Approved_by_name FROM ".DAYBOOKMASTER." as t1 LEFT JOIN ".PICK_LIST_DETAILS." as t2 ON t2.ListCode = t1.Name LEFT JOIN ".INCOMEOUTCOMEMASTER." as t3 ON t3.ID = t1.Type
|
||||||
LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
|
LEFT JOIN ".LOGIN." as t4 ON t4.ID = t1.Approval_By LEFT JOIN ".STAFF." as t5 ON t5.StaffID = t4.StaffID
|
||||||
WHERE t1.BranchCode = '$reqpayType' ORDER BY CreatedOn DESC";
|
WHERE t1.BranchCode = '$reqpayType' ORDER BY ID DESC";
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
// $this->db->join('' . COURSE . ' as t2', 't2.UniversityID = t1.UniversityID', 'LEFT');
|
||||||
@ -239,7 +239,6 @@ class DayBook_model extends CI_Model
|
|||||||
$latestUpdateDetails1 = $latestUpdate1->result();
|
$latestUpdateDetails1 = $latestUpdate1->result();
|
||||||
$currBalance = $latestUpdateDetails1[0]->Balance;
|
$currBalance = $latestUpdateDetails1[0]->Balance;
|
||||||
|
|
||||||
|
|
||||||
$sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$upFor')
|
$sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$upFor')
|
||||||
ORDER BY ID ASC";
|
ORDER BY ID ASC";
|
||||||
$latestUpdate2 = $this->db->query($sql2);
|
$latestUpdate2 = $this->db->query($sql2);
|
||||||
@ -259,9 +258,9 @@ class DayBook_model extends CI_Model
|
|||||||
}
|
}
|
||||||
$result['updateDetailsStatus'] = true;
|
$result['updateDetailsStatus'] = true;
|
||||||
$result['message'] = "Successfully Details Updated";
|
$result['message'] = "Successfully Details Updated";
|
||||||
} else {
|
} else {
|
||||||
$result['updateDetailsStatus'] = false;
|
$result['updateDetailsStatus'] = false;
|
||||||
$result['message'] = "Something went wrong.please try again";
|
$result['message'] = "Something went wrong.please try again";
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
@ -305,26 +304,119 @@ class DayBook_model extends CI_Model
|
|||||||
$UpdatedBy = $arr[0]['UpdatedBy'];
|
$UpdatedBy = $arr[0]['UpdatedBy'];
|
||||||
$UpdatedOn = $arr[0]['UpdatedOn'];
|
$UpdatedOn = $arr[0]['UpdatedOn'];
|
||||||
$status = $arr[0]['Status'];
|
$status = $arr[0]['Status'];
|
||||||
$number = array();
|
// $number = array();
|
||||||
foreach($arr as $ar){
|
// foreach($arr as $ar){
|
||||||
array_push($number, $ar['ID']);
|
// array_push($number, $ar['ID']);
|
||||||
}
|
// }
|
||||||
$updateFor = implode(',', $number);
|
// $updateFor = implode(',', $number);
|
||||||
|
$updateFor = $arr[0]['ID'];
|
||||||
|
if( $status == "Pending" || $status == "Approved" || $status == "approved" || $status == "pending"){
|
||||||
|
|
||||||
$sql = "UPDATE ".DAYBOOKMASTER."
|
$mysql = "SELECT * FROM ".DAYBOOKMASTER." WHERE ID = '$updateFor'";
|
||||||
SET Status = '$status', Approval_By = '$Approval_By' ,
|
$updateDetails = $this->db->query($mysql);
|
||||||
Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn'
|
$updateDataDetails = $updateDetails->result();
|
||||||
WHERE id IN ($updateFor)";
|
$branch = $updateDataDetails[0]->BranchCode;
|
||||||
$mBranchDetails = $this->db->query($sql);
|
$Amount = 0;
|
||||||
// echo $mBranchDetails;
|
$Amount = $updateDataDetails[0]->Amount;
|
||||||
// echo $this->db->affected_rows(); exit();
|
|
||||||
if ($this->db->affected_rows() >= 1) {
|
$sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$updateFor')
|
||||||
$result['addStatus'] = true;
|
ORDER BY ID DESC
|
||||||
$result['message'] = "Successfully Details Updated";
|
LIMIT 1 ";
|
||||||
} else {
|
|
||||||
$result['addStatus'] = false;
|
$currBalance = 0;
|
||||||
$result['message'] = "Something went wrong.please try again";
|
$latestUpdate = $this->db->query($sql);
|
||||||
}
|
$latestUpdateDetails = $latestUpdate->result();
|
||||||
|
if($updateDataDetails[0]->Name == 'I002') {
|
||||||
|
//Income
|
||||||
|
$currBalance = $latestUpdateDetails[0]->Balance + $Amount;
|
||||||
|
}else if ($updateDataDetails[0]->Name == 'I001') {
|
||||||
|
//Expense
|
||||||
|
$currBalance = $latestUpdateDetails[0]->Balance - $Amount;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
// $currBalance = $latestUpdateDetails[0]->Balance + $Amount;
|
||||||
|
|
||||||
|
$sql = "UPDATE ".DAYBOOKMASTER."
|
||||||
|
SET Status = '$status', Approval_By = '$Approval_By' ,
|
||||||
|
Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance'
|
||||||
|
WHERE id = '$updateFor' ";
|
||||||
|
$mBranchDetails = $this->db->query($sql);
|
||||||
|
// echo $mBranchDetails;
|
||||||
|
// echo $this->db->affected_rows(); exit();
|
||||||
|
if ($this->db->affected_rows() >= 1) {
|
||||||
|
$sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor')
|
||||||
|
ORDER BY ID ASC";
|
||||||
|
$latestUpdate2 = $this->db->query($sql2);
|
||||||
|
$latestUpdateDetails2 = $latestUpdate2->result();
|
||||||
|
foreach( $latestUpdateDetails2 as $clip){
|
||||||
|
if($clip->Name == 'I002') {
|
||||||
|
//Income
|
||||||
|
$currBalance = $currBalance + $clip->Amount;
|
||||||
|
}else if ($clip->Name == 'I001') {
|
||||||
|
//Expense
|
||||||
|
$currBalance = $currBalance - $clip->Amount;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
$updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
|
||||||
|
$this->db->query($updateSql);
|
||||||
|
}
|
||||||
|
$result['addStatus'] = true;
|
||||||
|
$result['message'] = "Successfully Details Updated";
|
||||||
|
} else {
|
||||||
|
$result['addStatus'] = false;
|
||||||
|
$result['message'] = "Something went wrong.please try again";
|
||||||
|
}
|
||||||
|
} else if( $status == "Rejected" || $status == "rejected" ) {
|
||||||
|
|
||||||
|
|
||||||
|
$mysql = "SELECT * FROM ".DAYBOOKMASTER." WHERE ID = '$updateFor'";
|
||||||
|
$updateDetails = $this->db->query($mysql);
|
||||||
|
$updateDataDetails = $updateDetails->result();
|
||||||
|
$branch = $updateDataDetails[0]->BranchCode;
|
||||||
|
$Amount = 0;
|
||||||
|
$Amount = $updateDataDetails[0]->Amount;
|
||||||
|
|
||||||
|
$sql = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID < '$updateFor')
|
||||||
|
ORDER BY ID DESC
|
||||||
|
LIMIT 1 ";
|
||||||
|
|
||||||
|
$currBalance = 0;
|
||||||
|
$latestUpdate = $this->db->query($sql);
|
||||||
|
$latestUpdateDetails = $latestUpdate->result();
|
||||||
|
$currBalance = $latestUpdateDetails[0]->Balance;
|
||||||
|
|
||||||
|
$sql = "UPDATE ".DAYBOOKMASTER."
|
||||||
|
SET Status = '$status', Approval_By = '$Approval_By' ,
|
||||||
|
Approval_Comments = '$Approval_Comments', UpdatedBy = '$UpdatedBy' , UpdatedOn = '$UpdatedOn' , Balance = '$currBalance'
|
||||||
|
WHERE id = '$updateFor' ";
|
||||||
|
$mBranchDetails = $this->db->query($sql);
|
||||||
|
// echo $mBranchDetails;
|
||||||
|
// echo $this->db->affected_rows(); exit();
|
||||||
|
if ($this->db->affected_rows() >= 1) {
|
||||||
|
$sql2 = "SELECT * FROM ".DAYBOOKMASTER." WHERE (BranchCode = '$branch' AND ID > '$updateFor')
|
||||||
|
ORDER BY ID ASC";
|
||||||
|
$latestUpdate2 = $this->db->query($sql2);
|
||||||
|
$latestUpdateDetails2 = $latestUpdate2->result();
|
||||||
|
foreach( $latestUpdateDetails2 as $clip){
|
||||||
|
if($clip->Name == 'I002') {
|
||||||
|
//Income
|
||||||
|
$currBalance = $currBalance + $clip->Amount;
|
||||||
|
}else if ($clip->Name == 'I001') {
|
||||||
|
//Expense
|
||||||
|
$currBalance = $currBalance - $clip->Amount;
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
$updateSql = "UPDATE ".DAYBOOKMASTER." SET Balance ='$currBalance' WHERE ID = '$clip->ID'";
|
||||||
|
$this->db->query($updateSql);
|
||||||
|
}
|
||||||
|
$result['addStatus'] = true;
|
||||||
|
$result['message'] = "Successfully Details Updated";
|
||||||
|
} else {
|
||||||
|
$result['addStatus'] = false;
|
||||||
|
$result['message'] = "Something went wrong.please try again";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,11 @@ app.controller('daybookCtrl', ["$scope", "$rootScope", "toaster", "$filter", "ng
|
|||||||
const LOCALTYPE = localDetail.localType;
|
const LOCALTYPE = localDetail.localType;
|
||||||
if(LOCALTYPE === 'R002') {
|
if(LOCALTYPE === 'R002') {
|
||||||
$scope.currentDate = new Date();
|
$scope.currentDate = new Date();
|
||||||
|
var d = new Date();
|
||||||
|
$scope.oneMonthBefore = d.setMonth(d.getMonth()-1);
|
||||||
|
// alert($scope.oneMonthBefore);
|
||||||
var formate = "dd-MM-yyyy";
|
var formate = "dd-MM-yyyy";
|
||||||
$scope.searchData.date = $filter('date')(new Date($scope.currentDate), formate);
|
$scope.searchData.date = $filter('date')(new Date($scope.oneMonthBefore), formate);
|
||||||
$scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate);
|
$scope.searchData.dateTo = $filter('date')(new Date($scope.currentDate), formate);
|
||||||
$scope.getDayBookList();
|
$scope.getDayBookList();
|
||||||
$scope.getIncomeExpenseType_Status();
|
$scope.getIncomeExpenseType_Status();
|
||||||
|
|||||||
@ -107,7 +107,7 @@
|
|||||||
<th ng-click="sort('ListName')">Income/Expense
|
<th ng-click="sort('ListName')">Income/Expense
|
||||||
<span class="glyphicon sort-icon" ng-show="sortKey=='ListName'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
|
<span class="glyphicon sort-icon" ng-show="sortKey=='ListName'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>
|
||||||
</th>
|
</th>
|
||||||
<th>Voucher Number
|
<th>Voucher Number / Bill Number
|
||||||
<!--<span class="glyphicon sort-icon" ng-show="sortKey=='EmailID'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>-->
|
<!--<span class="glyphicon sort-icon" ng-show="sortKey=='EmailID'" ng-class="{'glyphicon-chevron-up':reverse,'glyphicon-chevron-down':!reverse}"></span>-->
|
||||||
</th>
|
</th>
|
||||||
<th>Paid To / Received From
|
<th>Paid To / Received From
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user