chore: version inicial del codigo fuente del LMS Estafeta

This commit is contained in:
2026-10-02 20:33:12 -06:00
commit c8bb6b97b9
1572 changed files with 457520 additions and 0 deletions
+94
View File
@@ -0,0 +1,94 @@
<?php
require_once __DIR__.'/auth_guard.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once "../config.php";
require __DIR__ . '/../vendor/autoload.php';
$return = new stdClass();
//print_r($_FILES); die;
$files = $_FILES['customFileUpdate'];
$file_path = $files['tmp_name'][0]; // temporary upload path of the first file
$fileName = 'tmpusers.xlsx';
$dir_subida = '../data/tmpusers.xlsx';
move_uploaded_file($file_path, $dir_subida);
/** Identify the type of $inputFileName **/
$inputFileType = \PhpOffice\PhpSpreadsheet\IOFactory::identify($dir_subida);
/** Create a new Reader of the type that has been identified **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = $reader->load($dir_subida);
/** Convert Spreadsheet Object to an Array for ease of use **/
$schdeules = $spreadsheet->getActiveSheet()->toArray();
unlink($dir_subida);
$return = new stdClass();
//paso 1 verifcar headers
$headers = $schdeules[0];
global $link;
dbConnect();
if(!in_array ( "numempl", $headers )){
$return->error = "1";
$return->msg = "No existe la columna número de empleado (numempl)";
}else{
$values = array_splice ($schdeules, 1, sizeof($schdeules)-1);
$return->procesados = sizeof($values);
$return->correctos = 0;
$return->results = [];
foreach ($values as $value) {
if( $value[0] == "" ){
array_push ($return->results, '<span class="text-danger font-weight-bold">Usuario sin numempl: '.implode(', ', $value) .'<span>');
}else if(userExist($value[0])){
$sql = 'UPDATE user SET ';
foreach ($headers as $key => $campo) {
if($campo != 'numempl'){
if(($key+1) == sizeof($headers)){
$sql .= $campo.'= "'.$value[$key].'"';
}else{
$sql .= $campo.'= "'.$value[$key].'",';
}
}
}
$sql .= ' WHERE numempl = '.$value[0];
/*
$sql = 'UPDATE user SET '.implode(', ', $headers).') VALUES (';
$sql .= "'".$value[0]."', ";
$sql .= "'".$value[1]."', ";
$sql .= "'".$value[2]."', ";
$sql .= "'".$value[3]."', ";
$sql .= "'".$value[4]."', ";
$sql .= "'".$value[6]."')";
*/
if(mysqli_query($link, $sql)){
$return->correctos++;
array_push ($return->results, 'El usuario: ' . $value[0] . ' se actualizó correctamente');
}else{
array_push ($return->results, 'El usuario: ' . $value[0] . ' error: '. mysqli_error($link));
}
}else{
array_push ($return->results, 'El usuario: ' . $value[0] . ' no existe');
}
}
}
function userExist($numempl){
global $link;
dbConnect();
$sql ="select * from user where numempl = '$numempl'";
$result = mysqli_query($link, $sql);
if ( mysqli_num_rows($result) <= 0 ) {
return false;
}else{
return true;
}
}
echo json_encode($return, JSON_UNESCAPED_UNICODE);
?>