group started in sales adv filter : ps

This commit is contained in:
VE10-Sanjeev 2023-04-10 14:12:43 +05:30
parent ef98920ace
commit dc722781be

View File

@ -33,35 +33,41 @@ class Sales_PD_Model extends SPARQ_Model {
}
if(($pd_from_date != "" || $pd_from_date != null) && ($pd_to_date != "" || $pd_to_date != null)) {
// $this->db->where('SALES_PD_DATA.createdon BETWEEN '. "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
if($pd_status[0] == "STARTED" ){
if(!empty($pd_status) && $pd_status[0] == "STARTED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
}else if($pd_status[0] == "COMPLETED" ){
}else if(!empty($pd_status) && $pd_status[0] == "COMPLETED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
}else{
$this->db->group_start();
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
$this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d') BETWEEN ". "'$pd_from_date'". ' AND '. "'$pd_to_date'" );
$this->db->group_end();
}
}
else if($pd_from_date != "" && $pd_from_date != null) {
// $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date);
if($pd_status[0] == "STARTED" ){
if(!empty($pd_status) && $pd_status[0] == "STARTED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date);
}else if($pd_status[0] == "COMPLETED" ){
}else if(!empty($pd_status) && $pd_status[0] == "COMPLETED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date);
}else{
$this->db->group_start();
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_from_date);
$this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_from_date);
$this->db->group_end();
}
}
else if($pd_to_date != "" && $pd_to_date != null) {
// $this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date);
if($pd_status[0] == "STARTED" ){
if(!empty($pd_status) && $pd_status[0] == "STARTED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date);
}else if($pd_status[0] == "COMPLETED" ){
}else if(!empty($pd_status) && $pd_status[0] == "COMPLETED" ){
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date);
}else{
$this->db->group_start();
$this->db->where("DATE_FORMAT(SALES_PD_DATA.completed_date,'%Y-%m-%d')",$pd_to_date);
$this->db->or_where("DATE_FORMAT(SALES_PD_DATA.createdon,'%Y-%m-%d')",$pd_to_date);
$this->db->group_end();
}
}
if(!empty($pd_products)){