diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index ac9d6370..bb07ee62 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -8086,9 +8086,7 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() { - $this->load->helper('SYMLINKS'); - SYMLINKS::createSymLinks(); - die(); + $pdid = $this->uri->segment(3); log_message('DEBUG',"getPDReportPDFpreview_post called ");//die(); $random_string = $this->uri->segment(2); @@ -8150,12 +8148,14 @@ public function getCompaniesListsFromGeneralFormRawJSON_post() $pdf_doc = $this->pdfgenerator->generate($report_data, $filename='version', $stream=false, $paper = 'A4', $orientation = "portrait"); //End of PDF Gen using DOM PDF $output_file2 = $this->external_path ."/pd_reports/" . $pdid . "/sample.pdf"; - $link = 'https://'. $this->config->item('full_server_name').'/ssa_external_data/'. ENVIRONMENT.'/pd_reports/'. $pdid . "/sample.pdf"; + $link_to_send = 'https://'. $this->config->item('full_server_name').'/ssa_external_data/'. ENVIRONMENT.'/pd_reports/'. $pdid . "/sample.pdf"; + + //$link_to_be_create = '/var/www/html/ssa_external_data/'. ENVIRONMENT.'/pd_reports/'. $pdid . "/sample.pdf"; + file_put_contents($output_file2, $pdf_doc); - //header("Access-Control-Allow-Methods: GET, OPTIONS"); - header('Access-Control-Allow-Origin: *'); - header("Access-Control-Allow-Methods: GET, POST, OPTIONS"); - echo json_encode(array('link'=>$link)); + $this->load->helper('SYMLINKS'); + SYMLINKS::createSymLinks($pdid,$output_file2); + echo json_encode(array('link'=>$link_to_send)); } diff --git a/api/application/helpers/external_dir_check_helper.php b/api/application/helpers/external_dir_check_helper.php index 3a96eaf1..1f12e39c 100644 --- a/api/application/helpers/external_dir_check_helper.php +++ b/api/application/helpers/external_dir_check_helper.php @@ -6,10 +6,17 @@ class EXTERNAL_DIR_CHECK // Create the logger - public static function checkExternalDirectory($pd_id = null) //$msg,$data,$log_type + public static function checkExternalDirectory($pd_id = null,$path_to_check = null) { //echo 'EXTERNAL_DIR_CHECK called'; - $path = XLPATH; + if($path_to_check == null) + { + $path = XLPATH; + } + else + { + $path = $path_to_check; + } if(!file_exists($path)) { mkdir($path,0777); diff --git a/api/application/helpers/symlinks_helper.php b/api/application/helpers/symlinks_helper.php index f2ed0c8b..d5a32f0f 100644 --- a/api/application/helpers/symlinks_helper.php +++ b/api/application/helpers/symlinks_helper.php @@ -6,13 +6,19 @@ class SYMLINKS - public static function createSymLinks($pd_id = null) + public static function createSymLinks($pd_id = null,$output_file2 = null) { //echo SELF::checkOS(); //check os - if(SELF::checkOS() == 'LINUX') + if(SELF::checkOS() === 'LINUX') { - + $symbalic_path = $_SERVER['DOCUMENT_ROOT'].'/ssa_external_data/'.ENVIRONMENT; + $link_to_be_create = '/var/www/html/ssa_external_data/'. ENVIRONMENT.'/pd_reports/'. $pd_id . "/sample.pdf"; + EXTERNAL_DIR_CHECK::checkExternalDirectory($pd_id,$symbalic_path); + if(!file_exists($link_to_be_create)) + { + symlink($output_file2,$link_to_be_create); + } } }