diff --git a/api/application/controllers/Request_DataDump_Controller.php b/api/application/controllers/Request_DataDump_Controller.php index 70fdde63..dceb1c04 100755 --- a/api/application/controllers/Request_DataDump_Controller.php +++ b/api/application/controllers/Request_DataDump_Controller.php @@ -50,6 +50,9 @@ class Request_DataDump_Controller extends REST_Controller { // echo "i am in controller"; print_r($requested_details); count($requested_details); $file = APPPATH.'docs/RequestDataDump.xls'; if (file_exists($file)){ + if (file_exists(APPPATH."docs/DataDump.xls")) { + unlink(APPPATH.'docs/DataDump.xls'); + } // echo "\n The file $file exists"; // $pathinfo = pathinfo($file); print_r($pathinfo); require_once APPPATH .'third_party/PHPExcel/Classes/PHPExcel/IOFactory.php'; @@ -63,7 +66,7 @@ class Request_DataDump_Controller extends REST_Controller { // '25', 'Vendor PD Form', // '26', 'Photograph', $A=0;$B=0;$C=0;$E=0;$F=0;$G=0;$I=0;$L=0;$N=0;$O=0;$S=0; // GobalScope; - $CI=0;$SU=0;$FI=0;$FAD=0;$BI=0;$BB=0;$BA=0; + $CI=0;$SU=0;$FI=0;$FAD=0;$BI=0;$BB=0;$BA=0;$EI=0; // print_r($requested_details);die(); for($i=0;$i < count($requested_details);$i++){ // echo "\n inx : ".$i; @@ -148,10 +151,15 @@ class Request_DataDump_Controller extends REST_Controller { $max = count($companies);} if (count($companyWithRelationships) >= count($individuals) && count($companyWithRelationships) >= count($companies)){ $max = count($companyWithRelationships);} - for($x=$G;$x<($G+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$G;$x<($G+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $G = ($G+$max);} + else{ + $XL->getActiveSheet()->setCellValue('A'.$G,$processedJson['pdid']); + $G++; } - $G = ($G+$max); }### General Info Ends Here. ### '5', 'Address Details', @@ -207,10 +215,16 @@ class Request_DataDump_Controller extends REST_Controller { } $XL->getActiveSheet()->setCellValue('W'.$A,$processedJson['address_form_remark']); $max = max(count($addresses),count($alternativeAddresses)); - for($x=$A;$x<($A+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$A;$x<($A+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $A = $A+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$A,$processedJson['pdid']); + $A++; } - $A = $A+$max; + } ### Address Dtls Ends Here. ### '10', 'Loan Details', @@ -387,10 +401,16 @@ class Request_DataDump_Controller extends REST_Controller { ->setCellValue('U'.$FAD,"-")->setCellValue('V'.$FAD,"-")->setCellValue('W'.$FAD,"-")->setCellValue('X'.$FAD,"-")->setCellValue('Y'.$FAD,"-"); } $max = max($familymemberdetailscount,count($familydetails)); - for($x=$FAD;$x<($FAD+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$FAD;$x<($FAD+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $FAD = $FAD+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$FAD,$processedJson['pdid']); + $FAD++; } - $FAD = $FAD+$max; + } @@ -491,7 +511,6 @@ class Request_DataDump_Controller extends REST_Controller { ->setCellValue('U'.$E,!empty($processedJson['tot_outstanding_loans'])?$processedJson['tot_outstanding_loans']:"-") ->setCellValue('V'.$E,!empty($processedJson['currentloan_remarks'])?$processedJson['currentloan_remarks']:"-"); $exist_loan = $processedJson['loan_details']; - // print_r($exist_loan ); if(!empty($exist_loan)){ for($j=0;$jsetCellValue('O'.$E,"-")->setCellValue('P'.$E,"-")->setCellValue('Q'.$E,"-")->setCellValue('R'.$E,"-")->setCellValue('S'.$E,"-")->setCellValue('T'.$E,"-"); } - $max = count($exist_details); + $max = count($exist_loan); for($x=$E;$x<($E+$max);$x++){ $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); } @@ -750,53 +769,53 @@ class Request_DataDump_Controller extends REST_Controller { ### '12', 'Employment Information', if($processedJson['formid'] == 12){ $XL->setActiveSheetIndex(11); - if($E==0)$E=3; - $XL->getActiveSheet()->setCellValue('A'.$E,$processedJson['pdid']) - ->setCellValue('B'.$E,$processedJson['employer_name']) - ->setCellValue('C'.$E,$processedJson['employer_in_brief']) - ->setCellValue('D'.$E,$processedJson['how_long_year']) - ->setCellValue('E'.$E,$processedJson['how_long_month']) - ->setCellValue('F'.$E,$processedJson['total_business_experience']) - ->setCellValue('G'.$E,$processedJson['total_business_previous_experience']) - ->setCellValue('H'.$E,$processedJson['was_met']) - ->setCellValue('I'.$E,$processedJson['name_person_met']) - ->setCellValue('J'.$E,$processedJson['designation_person_met']) - ->setCellValue('K'.$E,$processedJson['others_person_met']) - ->setCellValue('L'.$E,$processedJson['photo_id_card']) - ->setCellValue('M'.$E,$processedJson['photo_id_others']) - ->setCellValue('N'.$E,$processedJson['visiting_card']) - ->setCellValue('O'.$E,$processedJson['confirm_salary']) - ->setCellValue('P'.$E,$processedJson['sal_amount_was_not_confirmed']) - ->setCellValue('Q'.$E,$processedJson['attendance_seen']) - ->setCellValue('R'.$E,$processedJson['sal_reg_seen']) - ->setCellValue('S'.$E,$processedJson['cash_voucher']) - ->setCellValue('T'.$E,$processedJson['sal_certificate']) - ->setCellValue('U'.$E,$processedJson['sal_slip']) - ->setCellValue('V'.$E,$processedJson['other_doc']) - ->setCellValue('X'.$E,implode(",",$processedJson['doc_not_available'])) - ->setCellValue('W'.$E,$processedJson['other_doc_name']) - ->setCellValue('Y'.$E,$processedJson['doc_not_available_specify']) - ->setCellValue('Z'.$E,$processedJson['mode_of_getting_salary']) - ->setCellValue('AA'.$E,$processedJson['from_date_the_salary_is_rcv']) - ->setCellValue('AB'.$E,$processedJson['to_date_the_salary_is_rcv']) - ->setCellValue('AD'.$E,$processedJson['reason_not_sal_pay']) - ->setCellValue('AE'.$E,$processedJson['paid_amount']) - ->setCellValue('AC'.$E,$processedJson['sal_paid_regularly']) - ->setCellValue('AF'.$E,$processedJson['gross_monthly_salary']) - ->setCellValue('AG'.$E,$processedJson['net_monthly_salary']) - ->setCellValue('AH'.$E,$processedJson['bonus_incentive']) - ->setCellValue('AI'.$E,$processedJson['bonus_frequency']) - ->setCellValue('AJ'.$E,$processedJson['bonus_type']) - ->setCellValue('AK'.$E,$processedJson['bonus_type_other']) - ->setCellValue('AL'.$E,$processedJson['id_card_issued_company']) - ->setCellValue('AM'.$E,$processedJson['why_company_id_proof_not_available']) - ->setCellValue('AN'.$E,$processedJson['employment_remarks']); + if($EI==0)$EI=3; + $XL->getActiveSheet()->setCellValue('A'.$EI,$processedJson['pdid']) + ->setCellValue('B'.$EI,$processedJson['employer_name']) + ->setCellValue('C'.$EI,$processedJson['employer_in_brief']) + ->setCellValue('D'.$EI,$processedJson['how_long_year']) + ->setCellValue('E'.$EI,$processedJson['how_long_month']) + ->setCellValue('F'.$EI,$processedJson['total_business_experience']) + ->setCellValue('G'.$EI,$processedJson['total_business_previous_experience']) + ->setCellValue('H'.$EI,$processedJson['was_met']) + ->setCellValue('I'.$EI,$processedJson['name_person_met']) + ->setCellValue('J'.$EI,$processedJson['designation_person_met']) + ->setCellValue('K'.$EI,$processedJson['others_person_met']) + ->setCellValue('L'.$EI,$processedJson['photo_id_card']) + ->setCellValue('M'.$EI,$processedJson['photo_id_others']) + ->setCellValue('N'.$EI,$processedJson['visiting_card']) + ->setCellValue('O'.$EI,$processedJson['confirm_salary']) + ->setCellValue('P'.$EI,$processedJson['sal_amount_was_not_confirmed']) + ->setCellValue('Q'.$EI,$processedJson['attendance_seen']) + ->setCellValue('R'.$EI,$processedJson['sal_reg_seen']) + ->setCellValue('S'.$EI,$processedJson['cash_voucher']) + ->setCellValue('T'.$EI,$processedJson['sal_certificate']) + ->setCellValue('U'.$EI,$processedJson['sal_slip']) + ->setCellValue('V'.$EI,$processedJson['other_doc']) + ->setCellValue('X'.$EI,implode(",",$processedJson['doc_not_available'])) + ->setCellValue('W'.$EI,$processedJson['other_doc_name']) + ->setCellValue('Y'.$EI,$processedJson['doc_not_available_specify']) + ->setCellValue('Z'.$EI,$processedJson['mode_of_getting_salary']) + ->setCellValue('AA'.$EI,$processedJson['from_date_the_salary_is_rcv']) + ->setCellValue('AB'.$EI,$processedJson['to_date_the_salary_is_rcv']) + ->setCellValue('AD'.$EI,$processedJson['reason_not_sal_pay']) + ->setCellValue('AE'.$EI,$processedJson['paid_amount']) + ->setCellValue('AC'.$EI,$processedJson['sal_paid_regularly']) + ->setCellValue('AF'.$EI,$processedJson['gross_monthly_salary']) + ->setCellValue('AG'.$EI,$processedJson['net_monthly_salary']) + ->setCellValue('AH'.$EI,$processedJson['bonus_incentive']) + ->setCellValue('AI'.$EI,$processedJson['bonus_frequency']) + ->setCellValue('AJ'.$EI,$processedJson['bonus_type']) + ->setCellValue('AK'.$EI,$processedJson['bonus_type_other']) + ->setCellValue('AL'.$EI,$processedJson['id_card_issued_company']) + ->setCellValue('AM'.$EI,$processedJson['why_company_id_proof_not_available']) + ->setCellValue('AN'.$EI,$processedJson['employment_remarks']); // [check_validated] => // [how_was_it_validated] => // [why_was_it_not_validated] => // [any_delays] => // [name_board_img] => SAVED - $E++; + $EI++; } ### Employement Info Ends Here ### '13', 'Business Information', @@ -1151,10 +1170,16 @@ class Request_DataDump_Controller extends REST_Controller { // if(count($partners) >= count($personswithrelationships)){$max = count($partners);} // else{$max = count($personswithrelationships);} $max=max(count($partners),count($manufacturingactivitydetails),count($personswithrelationships),count($retailtradingactivitydetails),count($wholesaletradingactivitydetails),count($serviceprovideractivitydetails)); - for($x=$BI;$x<($BI+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$BI;$x<($BI+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $BI = $BI+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$BI,$processedJson['pdid']); + $BI++; } - $BI = $BI+$max; + } ### Buiness Form Ends here ### '21', 'Business Banking', @@ -1307,10 +1332,16 @@ class Request_DataDump_Controller extends REST_Controller { } $max = max(count($buinessassetdetails),count($buinessassetaddress)); - for($x=$BA;$x<($BA+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$BA;$x<($BA+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $BA = $BA+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$BA,$processedJson['pdid']); + $BA++; } - $BA = $BA+$max; + } ### Buiness Assets Ends Here ### '14', 'Financial Information', @@ -1414,16 +1445,24 @@ class Request_DataDump_Controller extends REST_Controller { // [inventory_holding_period] => // [creditor_payment_period] => $max=max(count($date_per_financial),count($estimated_value)); - for($x=$F;$x<($F+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$F;$x<($F+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $F = $F+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$F,$processedJson['pdid']); + $F++; } - $F = $F+$max; + } ### 'Financial Info Ends Here ### '1', 'Supplier Details', if($processedJson['formid'] == 1){ // echo "Form ID".$processedJson['formid']; + // echo "count".count($processedJson); + // print_r($processedJson); $XL->setActiveSheetIndex(16); if($SU==0)$SU=3; $a=$SU;$b=$SU;$c=$SU; @@ -1536,10 +1575,16 @@ class Request_DataDump_Controller extends REST_Controller { } $XL->getActiveSheet()->setCellValue('AP'.$SU,!empty($processedJson['bill_info'])?$processedJson['bill_info']:"-")->setCellValue('AQ'.$SU,!empty($processedJson['supplier_info_form_remark'])?$processedJson['supplier_info_form_remark']:"-"); $max=max($MDcount,$TDcount,$SDcount); - for($x=$SU;$x<($SU+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + + if($max>0){ + for($x=$SU;$x<($SU+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $SU = $SU+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$SU,$processedJson['pdid']); + $SU++; } - $SU = $SU+$max; } ### Supplier Ends Here ### '2', 'Client Details', @@ -1652,10 +1697,16 @@ class Request_DataDump_Controller extends REST_Controller { ->setCellValue('AJ'.$CI,"-")->setCellValue('AK'.$CI,"-")->setCellValue('AL'.$CI,"-")->setCellValue('AM'.$CI,"-")->setCellValue('AN'.$CI,"-")->setCellValue('AO'.$CI,"-")->setCellValue('AP'.$CI,"-"); } $max=max($CMDcount,$CTDcount,$CSDcount); - for($x=$CI;$x<($CI+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$CI;$x<($CI+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $CI = $CI+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$CI,$processedJson['pdid']); + $CI++; } - $CI = $CI+$max; + } ### Client Ends Here ### '11', 'Stock Details', @@ -1762,10 +1813,16 @@ class Request_DataDump_Controller extends REST_Controller { $XL->getActiveSheet()->setCellValue('AK'.$S,!empty($processedJson['service_goods_remarks'])?$processedJson['service_goods_remarks']:"-"); $XL->getActiveSheet()->setCellValue('AL'.$S,!empty($processedJson['stock_remarks'])?$processedJson['stock_remarks']:"-"); $max=max($SMDcount1,$SMDcount1,$SRDcount,$STDcount,$SSDcount); - for($x=$S;$x<($S+$max);$x++){ - $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + if($max>0){ + for($x=$S;$x<($S+$max);$x++){ + $XL->getActiveSheet()->setCellValue('A'.$x,$processedJson['pdid']); + } + $S = $S+$max; + }else{ + $XL->getActiveSheet()->setCellValue('A'.$S,$processedJson['pdid']); + $S++; } - $S = $S+$max; + } ### Stock Details Here @@ -1863,20 +1920,31 @@ class Request_DataDump_Controller extends REST_Controller { $content = trim(file_get_contents(APPPATH.'docs/DataDump.xls')); return $content; } - public function downloadDataDump2_post(){ + public function downloadDataDump2_get(){ // $pth = file_get_contents(APPPATH."docs/DataDump.xls"); // $nme = "sample_file.xls"; // force_download($nme, $pth); - - $data = read_file(APPPATH."docs/DataDump.xls"); // Use file helper to read the file's - $name = "DataDump".date('Y-m-d-H-i-s').'.xls'; - force_download($name, $data); - // $data['dStatus'] = true; - // $data['status'] = REST_Controller::HTTP_OK; - // $this->response($data,REST_Controller::HTTP_OK); - - + if (file_exists(APPPATH."docs/DataDump.xls")) { + header("Content-Type: application/x-binary"); + header("Content-Transfer-Encoding: Binary"); + header("Content-Length:".filesize($file)); + header("Content-Disposition: attachment; filename=".$name); + $file = read_file(APPPATH."docs/DataDump.xls"); // Use file helper to read the file's + $name = "DataDump".date('Y-m-d-H-i-s').'.xls'; + force_download($name, $file); + } else { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NO_CONTENT; + $data['message'] = "The file does not exist"; + $this->response($data,REST_Controller::HTTP_OK); + } + // exit; } + // public function getXL_get(){ + // $data = read_file(APPPATH."docs/DataDump.xls"); // Use file helper to read the file's + // $name = "DataDump".date('Y-m-d-H-i-s').'.xls'; + // force_download($name, $data); + // } public function downloadDataDump5_get(){ $temp_base64_string = "DataDump.xls"; $title = "Request Data Dump";