Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Grupos
- $(document).ready(function (){
- var idenprof = metodosprof.setidprof();
- var iden = {
- identificacion: idenprof
- };
- $.ajax({
- type: 'GET',
- url: '/upcphp/grupos.php',
- data: iden
- //async: false
- }).done(function(msg) {
- var str = $.trim(msg);
- if(str !== "0"){
- //console.log(str);
- var vector = (JSON.parse(str));
- var len = (vector.length);
- //console.log(len);
- function ArregloHorario(arreglo, tamano){
- var asignaturas = [];
- for(var i = 0; i < tamano; i++){
- var asignatura = new Object();
- var asignatura = {
- codigo: arreglo[i].CodiAsig,
- asignatura: arreglo[i].NombAsig+"-"+arreglo[i].Grupo,
- identificacion: arreglo[i].CeduEstu,
- nombre: arreglo[i].NombEstu,
- apellido: arreglo[i].ApelEstu
- };
- asignaturas.push(asignatura);
- }
- return asignaturas;
- }
- var Arreglog = ArregloHorario(vector, len);
- console.log(Arreglog);
- var base = metodos.getBD();
- //Crear tabla horario profesor
- function TablaGrupos(database){
- database.transaction(function (tx){
- var sql = 'CREATE TABLE IF NOT EXISTS Grupos(asignatura text primary key, codigo text,\n\
- identificacion integer, nombre text, apellido text)';
- tx.executeSql(sql);
- });
- }
- TablaGrupos(base);
- /*Insertar Datos Horario Profesor con validacion*/
- function InsertDatosHoraProf(database, arreglo){
- var prof = arreglo;
- var largo = prof.length;
- //console.log(largo);
- database.transaction(function (tx) {
- var consulta = 'SELECT * FROM Grupos';
- tx.executeSql(consulta, [], function (tx, results){
- var mostrar = results.rows.length;
- var sql = 'INSERT INTO Grupos(asignatura, codigo, identificacion, nombre, apellido)\n\
- VALUES(?,?,?,?,?)';
- var sqldelete = 'DELETE FROM Grupos';
- if (mostrar === 0){
- for(var i = 0; i < largo; i++){
- tx.executeSql(sql, [prof[i].asignatura, prof[i].codigo, prof[i].identificacion,
- prof[i].nombre, prof[i].apellido]);
- }
- }else{
- tx.executeSql(sqldelete);
- for(var i = 0; i < largo; i++){
- tx.executeSql(sql, [prof[i].asignatura, prof[i].codigo, prof[i].identificacion,
- prof[i].nombre, prof[i].apellido]);
- }
- }
- });
- });
- }
- InsertDatosHoraProf(base, Arreglog);
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement