From 302c4fdc613c30e49d8fc8c3e8da1ea2b6f14c56 Mon Sep 17 00:00:00 2001 From: Smart Date: Mon, 28 Oct 2024 13:56:24 +0530 Subject: [PATCH] GWM : ordering issue --- app/Controllers/Purchaseorder.php | 2 ++ app/Models/Purchaseorder_model.php | 33 ++++++++---------------------- app/Views/includes/new_header.php | 4 +++- app/Views/porelease_view.php | 6 +++--- app/Views/rawmaterialListing.php | 4 ++-- 5 files changed, 18 insertions(+), 31 deletions(-) diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index 29027f0f..21caa653 100755 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -2571,6 +2571,8 @@ class Purchaseorder extends BaseController $fromDate = date('Y-m-d', strtotime($fromDate)); $toDate = date('Y-m-d', strtotime($toDate)); } + + // dd($fromDate,$toDate); $q = "RELEASE"; $this->global['pageTitle'] = 'Purchase Order Release'; diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index d5f3f33f..cea45580 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -1596,8 +1596,6 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, $builder = $this->db->table('t_purchaseorder_master mast')->distinct() ->select('mast.PODate,mast.PONO,mast.TotalOrderValue,st.StatusCode,st.StatusName,emp.FirstName,mast.CreatedDate,ccm.CostCenterName,ccm.CostCenterCode,mast.POType as RType,mast.Remarks,DepartmentName,mast.ApprovedBy,(select EmpID from tbl_users where userId=mast.ApprovedBy )as EID,rmast.ReqType,mast.Status,mast.CapitalRange, (select FirstName from t_employee_details where EmpID=EID)as Approver,sup.SupplierName,sup.MSME') - // ->orderBy('mast.Status',"PO_CREATED"); - ->join('t_supplierdetailsn sup', 'sup.SupplierID = mast.SupplierID') ->join('t_status st', 'st.StatusCode=mast.Status') ->join('t_purchaseorder_lineitem req', 'req.PONO= mast.PONO') @@ -1608,30 +1606,12 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, ->join('t_employee_details as emp', 'emp.empid=tbl.empid', 'left') ->join('t_departmentdetails as Dep', 'Dep.DEPCode=emp.Departmentcode', 'left'); - - - // old Status Don't Delete it. - // if ($type == 'APPROVAL') { - // $builder->orWhere('mast.Status', PO_DRAFT); - // $builder->orWhere('mast.Status', PO_CREATED); - // $builder->orWhere('mast.Status', PO_APPROVER_ONHOLD); - // $builder->orWhere('mast.Status', PO_AWAITING_RELEASE); - // $builder->orWhere('mast.Status', PO_RELEASED); - // $builder->orWhere('mast.Status', REQITEM_Emergency_PO_CREATED); - // $builder->orderBy('mast.Status'); - // } - // else if ($type == 'RELEASE') { - // $builder->orWhere('mast.Status', PO_DRAFT); - // $builder->orWhere('mast.Status', PO_AWAITING_RELEASE); - // $builder->orWhere('mast.Status', PO_RELEASER_ONHOLD); - // $builder->orWhere('mast.Status', PO_RELEASED); - // $builder->orderBy('mast.Status'); - // } - $builder->where('mast.CreatedDate >=', $fromDate . '00:00:00'); - $builder->where('mast.CreatedDate <=', $toDate .'00:00:00'); + $builder->where('DATE(mast.CreatedDate) >=', $fromDate); + $builder->where('DATE(mast.CreatedDate) <=', $toDate); $builder->orderBy('mast.CreatedDate', 'DESC'); if ($type == 'RELEASE') { + $builder->groupStart(); $builder->orWhere('mast.Status', PO_DRAFT); $builder->orWhere('mast.Status', PO_CREATED); $builder->orWhere('mast.Status', PO_APPROVER_ONHOLD); @@ -1639,13 +1619,16 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, $builder->orWhere('mast.Status', PO_RELEASER_ONHOLD); $builder->orWhere('mast.Status', PO_RELEASED); $builder->orWhere('mast.Status', REQITEM_Emergency_PO_CREATED); - // $builder->orderBy('mast.Status'); + $builder->groupEnd(); } $result = $builder->get(); - + // Get the last executed query + // $lastQuery = $this->db->getLastQuery(); + // echo $lastQuery; + // die; return $result->getResult(); } diff --git a/app/Views/includes/new_header.php b/app/Views/includes/new_header.php index 639c97d6..20f02474 100755 --- a/app/Views/includes/new_header.php +++ b/app/Views/includes/new_header.php @@ -767,11 +767,13 @@