Archive Deletions : ps
This commit is contained in:
parent
120c729062
commit
c5cf338d9f
@ -2521,23 +2521,28 @@ public function filterSalesPDList_post() {
|
||||
$value = $this->SMC_Credit_PD_Model->selectCustomRecords($select, $condit, PDTRIGGER);
|
||||
//print_r($this->db->last_query());print_r($value);die();
|
||||
if(!empty($value)){
|
||||
$flag = 0;$ids=array();
|
||||
$flag = 0;$ids=array(); $flag2=0;
|
||||
foreach( $value as $k => $v)
|
||||
{
|
||||
if($v['is_the_data_transfer_cet'] == 1){
|
||||
// echo "... ... ".$v['pd_id'];
|
||||
$updt_arr['pd_status'] = ARCHIVED;
|
||||
$updt_where = array('pd_id' => $v['pd_id'], 'pd_status' => COMPLETED);
|
||||
$result = $this->SMC_Credit_PD_Model->updateRecords($updt_arr, PDTRIGGER, $updt_where);
|
||||
if($result) $flag = $flag+1;
|
||||
log_message('ERROR', '#### SMC credit PDID '.$v['pd_id'].'-'.$v['pd_sno'].' in ARCHIVED status ');
|
||||
// $this->archivedSMCCreditPDDeleted($v['pd_id'],$day_limit);
|
||||
$this->archivedSMCCreditPDDeletion($v['pd_id'],$v['excel_file_id'],$v['fk_lender_id'],$day_limit);
|
||||
array_push($ids, $v['pd_id'].'-'.$v['pd_sno']);
|
||||
}else{
|
||||
log_message('ERROR', '#### SMC credit PDID '.$v['pd_id'].'-'.$v['pd_sno'].' is in Completed status because Data not transfer to CET');
|
||||
$flag2++;
|
||||
}
|
||||
|
||||
}
|
||||
log_message('ERROR', '#### '.$flag. '/'.count($value).' (archived pd/total pd) below this date '.$day_limit);
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['message'] = $flag. '/'.count($value).' SMC credit PD in ARCHIVED status ('.implode(', ', $ids).')';
|
||||
$data['message'] = $flag. '/'.count($value).' SMC credit PD in ARCHIVED status ('.implode(', ', $ids).') '.$flag2.' data are in Completed status because Data not transfer to CET';
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
@ -2546,16 +2551,59 @@ public function filterSalesPDList_post() {
|
||||
}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
// public function archivedSMCCreditPDDeleted($pdid){
|
||||
// log_message('ERROR', '#### Old Deleted');
|
||||
// $addr_dtls = $this->PD_Model->selectCustomRecords($addr_fields, $addr_cond_arr, PDADDRESS);
|
||||
// $json_dtls = $this->PD_Model->selectCustomRecords($json_fields, $json_cond_arr, PDFORMDETAILSJSON);
|
||||
// $docs_dtls = $this->PD_Model->selectCustomRecords($docs_fields, $docs_cond_arr, PDDOCUMENTS);
|
||||
// // $destination_path = $this->external_path . "/pd_reports/" . $pdid . "/" . $file;
|
||||
// // unlink($destination_path);
|
||||
|
||||
|
||||
// }
|
||||
public function archivedSMCCreditPDDeletion($pdid,$excel_file_id,$pdlenid,$day_limit){
|
||||
log_message('ERROR', '#### Old SMC Credit PD Deletion JSON,Doc,XL,Addr '.$pdid);
|
||||
$json_dtls = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), $json_cond_arr, SMC_CREDIT_PD_SECTION_DATA);
|
||||
|
||||
$json_cond_arr = array('fk_pd_id'=>$pdid);
|
||||
$json_dtls = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), $json_cond_arr, SMC_CREDIT_PD_SECTION_DATA);
|
||||
if(!empty($json_dtls)){
|
||||
$json_result = $this->SMC_Credit_PD_Model->delete_data(array('column'=>'fk_pd_id','value'=>$pdid,'table'=>SMC_CREDIT_PD_SECTION_DATA));
|
||||
log_message('ERROR', '#### SMC Credit PD Data '.count($json_dtls).' JSON Deleted for this '.$pdid.' result '.$json_result);
|
||||
}else log_message('ERROR', '#### SMC Credit PD Data '.count($json_dtls).' JSON Deleted for this '.$pdid);
|
||||
|
||||
$docs_cond_arr = array('fk_smc_credit_pd_id'=>$pdid);
|
||||
$docs_dtls = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), $docs_cond_arr, SMC_CREDIT_PD_DOCS);
|
||||
if(!empty($docs_dtls)){
|
||||
$docs_result = $this->SMC_Credit_PD_Model->delete_data(array('column'=>'fk_smc_credit_pd_id','value'=>$pdid,'table'=>SMC_CREDIT_PD_DOCS));
|
||||
log_message('ERROR', '#### SMC Credit PD '.count($docs_dtls).' Docs Deleted for this '.$pdid.' result '.$docs_result);
|
||||
$destination_path = $this->external_path . "/pd".$pdid."/pd_reports";
|
||||
$fileList=array();
|
||||
if(is_dir($destination_path)){
|
||||
$files = glob($destination_path.'/*');
|
||||
log_message('ERROR', '#### SMC Credit PD '.count($files).' Local Files Deleted for this '.$pdid.' ('.implode(', ', $fileList).')');
|
||||
rmdir($destination_path);
|
||||
} else log_message('ERROR', '#### There is No SMC Credit PD Local Files for this '.$pdid);
|
||||
$this->deleteS3Images($pdlenid,$pdid);
|
||||
}else log_message('ERROR', '#### SMC Credit PD '.count($docs_dtls).' Docs Entries Deleted for this '.$pdid);
|
||||
|
||||
|
||||
$xl_cond_arr = array('id'=>$excel_file_id);
|
||||
$xl_dtls = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), $xl_cond_arr, SMC_EXCEL_FILELIST);
|
||||
if(!empty($xl_dtls)){
|
||||
$xl_result = $this->SMC_Credit_PD_Model->delete_data(array('column'=>'id','value'=>$excel_file_id,'table'=>SMC_EXCEL_FILELIST));
|
||||
log_message('ERROR', '#### SMC Credit PD '.count($xl_dtls).' XL details Deleted for this '.$pdid.' result '.$xl_result);
|
||||
}else log_message('ERROR', '#### SMC Credit PD '.count($xl_dtls).' XL details Deleted for this '.$pdid);
|
||||
|
||||
$addr_cond_arr = array('file_id'=>$pdid);
|
||||
$addr_dtls = $this->SMC_Credit_PD_Model->selectCustomRecords(array('*'), $addr_cond_arr, SMC_TEMP_ADDRESS);
|
||||
if(!empty($addr_dtls)){
|
||||
|
||||
$addr_result = $this->SMC_Credit_PD_Model->delete_data(array('column'=>'file_id','value'=>$pdid,'table'=>SMC_TEMP_ADDRESS));
|
||||
log_message('ERROR', '#### SMC Credit PD '.count($addr_dtls).' Address Details Deleted for this '.$pdid.' result '.$addr_result);
|
||||
}else log_message('ERROR', '#### SMC Credit PD '.count($addr_dtls).' Address Details Deleted for this '.$pdid);
|
||||
}
|
||||
|
||||
public function deleteS3Images($pdLenId,$pdid){
|
||||
$bucketName = LENDER_BUCKET_NAME_PREFIX . $pdLenId;
|
||||
$key = 'pd' . $pdid;
|
||||
$allFiles = $this->aws_s3->getAllObjectsInaBucket($bucketName, $key);
|
||||
log_message('ERROR', '#### SMC Credit PD '.count(array($allFiles)).' S3 Files Deleted For this '.$pdid);
|
||||
$this->aws_s3->deleteMatchingObjects($bucketName, $key);
|
||||
$allOptimizedFiles = $this->aws_s3->getAllObjectsInaBucket(OPTIMIZED_IMAGE_BUCKET_NAME, $key);
|
||||
log_message('ERROR', '#### SMC Credit PD '.count(array($allOptimizedFiles)).' S3 optimized Files Deleted For this '.$pdid);
|
||||
$this->aws_s3->deleteMatchingObjects(OPTIMIZED_IMAGE_BUCKET_NAME, $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2070,21 +2070,27 @@ public function filterSalesPDList_post() {
|
||||
// print_r($this->db->last_query());die();
|
||||
// echo count($value);
|
||||
if(!empty($value)){
|
||||
$flag = 0;$ids=array();
|
||||
$flag = 0;$ids=array();$flag2=0;
|
||||
foreach( $value as $k => $v)
|
||||
{
|
||||
if($v['is_the_data_transfer_cet'] == 1){
|
||||
// echo "... ... ".$v['sales_pd_id'];
|
||||
$updt_arr['status'] = ARCHIVED;
|
||||
$updt_where = array('sales_pd_id' => $v['sales_pd_id'], 'status' => COMPLETED);
|
||||
$result = $this->Sales_PD_Model->updateRecords($updt_arr, SALES_PD_DATA, $updt_where);
|
||||
if($result) $flag = $flag+1;
|
||||
log_message('ERROR', '#### Sales PDID '.$v['sales_pd_id']." - ".$v['sales_pd_sno'].' in ARCHIVED status ');
|
||||
$this->archivedSalesPDDeletion($v['sales_pd_id'],$v['lender_id'],$day_limit);
|
||||
array_push($ids, $v['sales_pd_id']." - ".$v['sales_pd_sno']);
|
||||
}else{
|
||||
log_message('ERROR', '#### Sales PDID '.$v['sales_pd_id'].'-'.$v['pd_sno'].' is in Completed status because Data not transfer to CET');
|
||||
$flag2++;
|
||||
}
|
||||
}
|
||||
log_message('ERROR', '#### '.$flag. '/'.count($value).' (archived pd/total pd) below this date '.$day_limit);
|
||||
$data['dataStatus'] = true;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
$data['message'] = $flag. '/'.count($value).' sales PD in ARCHIVED status ('.implode(', ', $ids).')';
|
||||
$data['message'] = $flag. '/'.count($value).' sales PD in ARCHIVED status ('.implode(', ', $ids).' ) '.$flag2.' data are in Completed status because Data not transfer to CET';
|
||||
}else{
|
||||
$data['dataStatus'] = false;
|
||||
$data['status'] = REST_Controller::HTTP_OK;
|
||||
@ -2093,7 +2099,38 @@ public function filterSalesPDList_post() {
|
||||
}
|
||||
$this->response($data,REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
function archivedSalesPDDeletion($sales_pd_id,$pdLenId,$day_limit){
|
||||
log_message('ERROR', '#### Old Sales PD Data Deletion Doc,JSON'.$sales_pd_id);
|
||||
|
||||
$json_cond_arr = array('sales_pd_id'=>$sales_pd_id);
|
||||
$json_dtls = $this->Sales_PD_Model->selectCustomRecords(array('*'), $json_cond_arr, SALESPD_SECTION_DATA);
|
||||
if(!empty($json_dtls)){
|
||||
$json_result = $this->Sales_PD_Model->delete_data(array('column'=>'sales_pd_id','value'=>$sales_pd_id,'table'=>SALESPD_SECTION_DATA))
|
||||
log_message('ERROR', '#### Sales PD Data '.count($json_dtls).' JSON Deleted for this '.$sales_pd_id.' result '.$json_result);
|
||||
}else log_message('ERROR', '#### Sales PD Data '.count($json_dtls).' JSON Deleted for this '.$sales_pd_id);
|
||||
|
||||
$docs_cond_arr = array('fk_sales_pd_id'=>$sales_pd_id);
|
||||
$docs_dtls = $this->Sales_PD_Model->selectCustomRecords(array('*'), $docs_cond_arr, SALEPD_DOCS);
|
||||
if(!empty($docs_dtls)){
|
||||
$docs_result = $this->Sales_PD_Model->delete_data(array('column'=>'fk_sales_pd_id','value'=>$sales_pd_id,'table'=>SALEPD_DOCS))
|
||||
log_message('ERROR', '#### Sales PD '.count($docs_dtls).' Docs Entires Deleted for this '.$sales_pd_id.' result '.$docs_result);
|
||||
$destination_path = $this->external_path . "/sales_pd/".$sales_pd_id;
|
||||
if(is_dir($destination_path)){
|
||||
$files = glob($destination_path.'/*');
|
||||
log_message('ERROR', '#### Sales PD '.count($files).' Local Files Deleted for this '.$sales_pd_id);
|
||||
rmdir($destination_path);
|
||||
$this->deleteS3Images($pdLenId,$sales_pd_id);
|
||||
} else log_message('ERROR', '#### There is No Sales PD Local Files for this '.$sales_pd_id);
|
||||
}else log_message('ERROR', '#### Sales PD '.count($docs_dtls).' Docs Entries Deleted for this '.$sales_pd_id);
|
||||
|
||||
}
|
||||
public function deleteS3Images($pdLenId,$sales_pd_id){
|
||||
$bucketName = LENDER_BUCKET_NAME_PREFIX . $pdLenId;
|
||||
$key = 'sales_pd/'.$sales_pd_id;
|
||||
$allFiles = $this->aws_s3->getAllObjectsInaBucket($bucketName, $key);
|
||||
log_message('ERROR', '#### Sales PD '.count($allFiles).' S3 Files Deleted For this '.$sales_pd_id);
|
||||
$this->aws_s3->deleteMatchingObjects($bucketName, $key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -290,6 +290,13 @@ return $result;
|
||||
echo $copied_objects;
|
||||
|
||||
}
|
||||
|
||||
public function deleteMatchingObjects($bucket,$key)
|
||||
{
|
||||
$result = $this->S3->deleteMatchingObjects($bucket,$key);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@ -152,5 +152,11 @@ class SMC_Credit_PD_Model extends SPARQ_Model {
|
||||
}
|
||||
|
||||
|
||||
|
||||
function delete_data($arr)
|
||||
{
|
||||
$this->db->where($arr['column'],$arr['value']);
|
||||
$this->db->delete($arr['table']);
|
||||
if ($this->db->affected_rows() > 0) return TRUE;
|
||||
else return FALSE;
|
||||
}
|
||||
}
|
||||
@ -110,5 +110,11 @@ class Sales_PD_Model extends SPARQ_Model {
|
||||
// $sql = 'insert into sineedgeprod.t_salespd_section_data(sales_pd_id, section_id, status, section_data, createdby, isactive) select sales_pd_id, section_id, status, section_data, createdby, isactive from sineedgeprod.t_salespd_section_data WHERE sales_pd_id = 1768 and section_id = 1 and isactive = 1;';
|
||||
// $modified = $this->db->query($sql);
|
||||
}
|
||||
|
||||
function delete_data($arr)
|
||||
{
|
||||
$this->db->where($arr['column'],$arr['value']);
|
||||
$this->db->delete($arr['table']);
|
||||
if ($this->db->affected_rows() > 0) return TRUE;
|
||||
else return FALSE;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user