DataDump api : ps

This commit is contained in:
sanjeev.p 2021-08-09 12:10:58 +05:30
parent b5e611c746
commit c6f04ab04a
4 changed files with 1979 additions and 32 deletions

8
api/application/config/routes.php Normal file → Executable file
View File

@ -292,7 +292,7 @@ $route['(getRawData/:any)'] = 'Data_Dump_Controller/getRawData';
$route['loadSalesPDTemplate'] = 'Sales_PD_Controller/loadSalesPDTemplate';
$route['saveSalesPD'] = 'Sales_PD_Controller/saveSalesPD';
$route['(downloadSalesPDReport/:any)'] = 'Sales_PD_Controller/getSalesPDReport';
$route['(downloadSalesPDReport/:any)'] = 'Sales_PD_Controller/getSalesPDReport';
$route['listSalesPD/(:any)'] = 'Sales_PD_Controller/listSalesPD';
$route['listSalesPD/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD';
$route['listSalesPD/(:any)/(:any)/(:any)'] = 'Sales_PD_Controller/listSalesPD';
@ -320,4 +320,8 @@ $route['getSMCPDImgSectionData'] = 'SMC_Credit_PD_Controller/getSMCPDImgSectionD
$route['smcCreditPDReport'] = 'SMC_Credit_PD_Controller/smcCreditPDReport';
$route['getCMUsers'] = 'SMC_Credit_PD_Controller/getCMUsers';
$route['smcCreditPDMisReport'] = 'SMC_Credit_PD_Controller/smcCreditPDMisReport';
$route['getCompanyListForSMCList'] = 'SMC_Credit_PD_Controller/getCompanyListForSMCList';
$route['getCompanyListForSMCList'] = 'SMC_Credit_PD_Controller/getCompanyListForSMCList';
$route['getRequestForDataDump'] = 'Request_DataDump_Controller/getRequestForDataDump';
$route['getMasterForDataDump'] = 'Request_DataDump_Controller/getMasterForDataDump';
$route['downloadDataDump'] = 'Request_DataDump_Controller/downloadDataDump2';

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require_once( APPPATH.'/third_party/PHPExcel/Classes/PHPExcel.php');
class Excel extends PHPExcel {
// var $debug = false;
function __construct()
{
parent::__construct();
}
}

62
api/application/models/Data_Dump_Model.php Normal file → Executable file
View File

@ -72,48 +72,50 @@ class Data_Dump_Model extends SPARQ_Model {
}
}
function getRequestForDataDump($pdid,$fd=null,$td=null,$type){
$this->db->select('t_pd_form_details_json.pd_form_detail_json_id, t_pd_form_details_json.fk_pd_id, t_pd_form_details_json.fk_form_id, t_pd_form_details_json.isactive, t_pd_form_details_json.json, DATE_FORMAT(t_pd_form_details_json.createdon,"%d/%m/%Y %H:%i:%s") as createdon, t_pd_form_details_json.processed_json, t_pd_form_details_json.updatedon');
$this->db->from('t_pd_form_details_json');
function getRequestForDataDump($arr){
$pdid = $arr['pd_id'];
$fromd = $arr['from_date'];$tod= $arr['to_date'];
$type = $arr['pd_type_id'];$prod = $arr['product_id'];
$cseg = $arr['customer_segment_id'];
### 2 tables t_pd_form_details_json and t_pd_triggered
$this->db->select('PDFORMDETAILSJSON.pd_form_detail_json_id, PDFORMDETAILSJSON.fk_pd_id, PDFORMDETAILSJSON.fk_form_id, PDFORMDETAILSJSON.isactive, PDFORMDETAILSJSON.json, DATE_FORMAT(PDFORMDETAILSJSON.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDFORMDETAILSJSON.processed_json, PDFORMDETAILSJSON.updatedon,PDTRIGGER.completed_on,PDTRIGGER.fk_product_id, PDTRIGGER.fk_customer_segment,PDTRIGGER.fk_pd_type,PDTRIGGER.pd_status,PDTRIGGER.createdon');
$this->db->from(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON');
$this->db->join(PDTRIGGER.' as PDTRIGGER','PDTRIGGER.pd_id = PDFORMDETAILSJSON.fk_pd_id ','LEFT');
if(!empty($pdid))
{
$this->db->where_in('t_pd_form_details_json.fk_pd_id',$pdid);
$this->db->where_in('PDFORMDETAILSJSON.fk_pd_id',$pdid);
}
if(($fd != "" || $fd != null) && ($td != "" || $td != null)) {
if($type == "Createdon" ){
$this->db->where('t_pd_form_details_json.createdon BETWEEN '. "'$fd'". ' AND '. "'$td'" );
}else if($type == "Updatedon" ){
$this->db->where('t_pd_form_details_json.updatedon BETWEEN '. "'$fd'". ' AND '. "'$td'" );
}else{
$this->db->where('t_pd_form_details_json.updatedon BETWEEN '. "'$fd'". ' AND '. "'$td'" );
}
$this->db->where('PDTRIGGER.createdon BETWEEN '. "'$fd'". ' AND '. "'$td'" );
}
else if($fd != "" && $fd != null) {
if($type == "Createdon" ){
$this->db->where("DATE_FORMAT(t_pd_form_details_json.createdon,'%Y-%m-%d')",$fd);
}else if($type == "Updatedon" ){
$this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$fd);
}else{
$this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$fd);
}
$this->db->where("DATE_FORMAT(PDTRIGGER.createdon,'%Y-%m-%d')",$fd);
}
else if($td != "" && $td != null) {
if($type == "Createdon" ){
$this->db->where("DATE_FORMAT(t_pd_form_details_json.createdon,'%Y-%m-%d')",$td);
}else if($type == "Updatedon" ){
$this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$td);
}else{
$this->db->where("DATE_FORMAT(t_pd_form_details_json.updatedon,'%Y-%m-%d')",$td);
}
$this->db->where("DATE_FORMAT(PDTRIGGER.createdon,'%Y-%m-%d')",$td);
}
$this->db->WHERE('t_pd_form_details_json.isactive',1);
$this->db->order_by('t_pd_form_details_json.pd_form_detail_json_id','desc');
if($prod != ""){
$this->db->where('PDTRIGGER.fk_product_id',$prod);
}
if($type != ""){
$this->db->where('PDTRIGGER.fk_pd_type',$type);
}
if($cseg != ""){
$this->db->where('PDTRIGGER.fk_customer_segment',$cseg);
}
$this->db->WHERE('PDFORMDETAILSJSON.isactive',1);
$this->db->order_by('PDFORMDETAILSJSON.pd_form_detail_json_id','desc');
$result = $this->db->get()->result_array();
// echo count($result);print_r($result);die();
// print_r($this->db->last_query());die();
// echo count($result);print_r($result);print_r($this->db->last_query());die();
return $result;
}
public function filtermasterfordatadumprequest(){
$result['pdtype'] = $this->db->select('PDTYPE.pd_type_id,PDTYPE.type_name')->from(PDTYPE.' as PDTYPE')->WHERE('PDTYPE.isactive',1)->GET()->result_array();
$result['product'] = $this->db->select('PRODUCTS.product_id,PRODUCTS.name,PRODUCTS.abbr')->from(PRODUCTS.' as PRODUCTS')->WHERE('PRODUCTS.isactive',1)->GET()->result_array();
$result['customersegment'] = $this->db->select('CUSTOMERSEGMENT.customer_segment_id,CUSTOMERSEGMENT.name,CUSTOMERSEGMENT.abbr')->from(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT')->WHERE('CUSTOMERSEGMENT.isactive',1)->GET()->result_array();
$result['pdid'] = $this->db->select('PDTRIGGER.pd_sno,PDTRIGGER.pd_id')->from(PDTRIGGER.' as PDTRIGGER')->WHERE('PDTRIGGER.pd_status !=',"TRUNCATED")->GET()->result_array();
return $result;
}
}