Skip to content

Commit

Permalink
accion admin_list_class_import
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroOmatech committed Jun 18, 2019
1 parent efd54e7 commit 946c62e
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/admin/accions/admin_list_class_import.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function render()

$objPHPExcel = \PhpOffice\PhpSpreadsheet\IOFactory::load($_FILES['file_class']['tmp_name']);

//Cambiar por security -> db
$conn = config("database.connections.mysql");
$connection_params = array(
'dbname' => $conn['database'],
Expand Down Expand Up @@ -60,7 +59,6 @@ public function render()

$have_niceurl = false;

//por cada fila / elemento nuevo
foreach ($worksheet->getRowIterator() as $row) {


Expand All @@ -76,13 +74,10 @@ public function render()
} else {

$stop = 0;

$instance = array();

//por cada celda / columna
foreach ($cellIterator as $key => $cell) {


$type_attribute = explode('#', $attributes[$key]);

//S, U, K, T, Y
Expand Down Expand Up @@ -136,8 +131,6 @@ public function render()
$maps = $this->searchAddressOnGoogle($value);
if(isset($maps['geometry']) && isset($maps['geometry']['location']) && isset($maps['geometry']['location']['lat']) && isset($maps['geometry']['location']['lng']) ){
$instance[$excel_attribute] = $maps['geometry']['location']['lat'].':'.$maps['geometry']['location']['lng'].'@'.$value;
}else{
$instance[$excel_attribute] = '0:0@'.$value;
}

break;
Expand All @@ -160,7 +153,6 @@ public function render()
$count = 0;

while ($inst_id != -1) {
//-1 si no existe, es lo que buscamos
$inst_id = $loader->getInstIDFromNomIntern($name_class, $value);
if ($inst_id != -1) {
$value = $value_attr . '-' . $count;
Expand Down Expand Up @@ -212,7 +204,7 @@ public function render()

while ($end == false) {

//por cada idioma, miro si existe la url, 'all', 'ca', 'es', 'en'
//languages: 'all', 'ca', 'es', 'en'
foreach ($langs as $lang) {

$nice_url = $loader->clean_url($value);
Expand All @@ -226,7 +218,6 @@ public function render()
}
}

//si no existe termino el bucle y guardo el valor, sino añado un count y vuelvo a mirar por cada idioma si existe
if ($search == false) {
$end = true;
$have_niceurl = true;
Expand All @@ -250,10 +241,9 @@ public function render()

}

//instance con todos los values, ahora es cuando se han de guardar en la base de datos
$inst_id = $loader->insertInstanceWithExternalID($id_class, $instance['nom_intern'], '', $batch_id, $instance, 'P');

//si tiene url, añadirla y si ha encontrado el array con las niceurls

if (isset($inst_id) && !empty($inst_id) && $have_niceurl == true && isset($niceurls) && !empty($niceurls)) {
foreach ($niceurls as $name_atr => $urlnice) {

Expand All @@ -265,9 +255,6 @@ public function render()
$result = $loader->insertUrlNice($urlnice, $inst_id, $lang);
}
}
//$loader->insertUrlNice($nice_url, $inst_id, $lang);
} else {
//mensaje de que no se ha creado la niceurl correctamente
}

if (isset($inst_id) && !empty($inst_id)) {
Expand Down

0 comments on commit 946c62e

Please sign in to comment.