| Server IP : 52.9.100.119 / Your IP : 216.73.216.193 Web Server : Apache/2.4.61 (Amazon) OpenSSL/1.0.2k-fips PHP/7.3.30 Phusion_Passenger/5.1.5 System : Linux ip-172-31-9-35 4.14.355-196.618.amzn1.x86_64 #1 SMP Mon Apr 7 17:09:50 UTC 2025 x86_64 User : root ( 0) PHP Version : 7.3.30 Disable Function : exec,passthru,shell_exec,system,popen,proc_open MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /data/html/domik-general/ |
Upload File : |
<?php
header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json,application/x-www-form-urlencoded,multipart/form-data');
header('Access-Control-Allow-Headers: Content-Type');
require 'lib/rb_conf.php';
R::fancyDebug(FALSE);
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
set_time_limit(5000);
$inputFileType = 'Xlsx';
$inputFileName = 'hospitales.xlsx';
$hosp_arr = array();
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = $reader->load($inputFileName);
$sheet = $spreadsheet->getActiveSheet();
foreach ($sheet->getRowIterator(3) as $fila){
$test_array = array();
foreach ($fila->getCellIterator() as $celda){
$valor = $celda->getValue();
if($valor != null){
array_push($test_array,$valor);
}
}
if(count($test_array) == 3){
$esp_x = explode("- ",$test_array[2]);
unset($esp_x[0]);
$hosp_arr[] = [$test_array[0],$test_array[1],$esp_x];
}
}
foreach ($hosp_arr as $hospital){
$hosp_bean = R::findOrCreate( 'hospital', ['name' => $hospital[0]]);
$area_bean = R::findOrCreate( 'area', ['name' => $hospital[1],'hospital'=>$hosp_bean]);
foreach ($hospital[2] as $posicion){
$especialidad_bean = R::findOrCreate( 'position', ['name' => $posicion,'area'=>$area_bean]);
}
}
echo "Todo listo";