function obtenerArancel($colegio_ID, $curso, $aran_anio) { DBConnect($this->dbh, BD_SIGA); $SQL = "SELECT * FROM arancel WHERE FK_colegios_colegio_ID = '{$colegio_ID}'\r\n AND FK_curso = '{$curso}'\r\n AND aran_anio = '{$aran_anio}'"; $result = DBQuery($SQL, $this->dbh); $row = DBFetchArray($result); DBConnect($dbh); //dpr($_SESSION['colegio']->colegio_ID); if (!$row['aran_monto']) { switch ($_SESSION['colegio']->colegio_ID) { case "abello": $row['aran_monto'] = ArancelColegio::ABELLO; break; case "edupac": $row['aran_monto'] = ArancelColegio::EDUPAC; break; case "dor": if (substr($curso, 0, -1) >= 9) { $row['aran_monto'] = ArancelColegio::DOR_MEDIA; } else { $row['aran_monto'] = ArancelColegio::DOR_BASICA; } break; } //$_SESSION[''] = } return $row; }
function obtenerDB($db_ID) { $SQL = "SELECT * FROM db WHERE db_ID = '{$db_ID}'"; $result = DBQuery($SQL, $this->dbh); $row = DBFetchArray($result); return (object) $row; }
function calc_salida_mes($mes) { DBConnect($dbh); //dpr($mes); $totalmes = 0; $SQL = "SELECT SUM(cantidad) AS salidas_totales FROM salidas WHERE fecha LIKE '%/{$mes}/%'"; $result = DBQuery($SQL, $dbh); $row = DBFetchArray($result); return $row['salidas_totales']; }
function listaPersonal($colegio_ID, $pers_tipo) { //DBConnect($this->dbh, BD_SIGA); $listPersonas = array(); $sql = "SELECT * FROM dorcl_siga.personal AS ps\r\n INNER JOIN dorcl_siga.personas AS p\r\n ON ps.FK_personas_per_ID = p.per_ID\r\n WHERE p.FK_colegios_colegio_ID = '" . $colegio_ID . "'\r\n AND ps.pers_tipo = '" . $pers_tipo . "'"; $result = DBQuery($sql, $this->dbh); while ($row = DBFetchArray($result)) { $listPersonas[$row['per_ID']] = $row; } mysql_select_db($_SESSION['base_datos']->nombrebd); return $listPersonas; }
function obtenerStyle($colegio_ID) { DBConnect($this->dbh, BD_SIGA); if (!$colegio_ID) { throw new Exception("Se requiere el colegio ID, para obtener el style"); } $sql = "SELECT * FROM style WHERE FK_colegios_colegio_ID = '" . $colegio_ID . "'"; $result = DBQuery($sql, $this->dbh); $row = DBFetchArray($result); mysql_select_db($_SESSION['base_datos']->nombrebd); if (!$row) { $row['style_ID'] = "0"; $row['FK_colegios_colegio_ID'] = $colegio_ID; $row['style_css'] = "style.css"; $row['style_path'] = "default"; } return $row; }
function obtenerMatricula($datos) { DBConnect($this->dbh, BD_SIGA); if (!$datos['FK_rut']) { throw new MatriculaException(MatriculaException::ATRIBUTO_REQUERIDO_RUT_MSG); } if (!$datos['FK_colegios_colegio_ID']) { throw new MatriculaException(MatriculaException::ATRIBUTO_REQUERIDO_COLEGIO_ID_MSG); } if (!$datos['matric_anio']) { throw new MatriculaException(MatriculaException::ATRIBUTO_REQUERIDO_ANIO_MSG); } $sql = "SELECT * FROM matriculas WHERE FK_rut = '" . $datos['FK_rut'] . "'\n AND FK_colegios_colegio_ID = '" . $datos['FK_colegios_colegio_ID'] . "'\n AND matric_anio = '" . $datos['matric_anio'] . "'"; $result = DBQuery($sql, $this->dbh); $row = DBFetchArray($result); mysql_select_db($_SESSION['base_datos']->nombrebd); return $row; }
public function obtenerIVAexcento($anio_mes, $detalle = false) { $boletas = array(); //dpr($mes); $trans_fecha_ini = $anio_mes . "-01"; $trans_fecha_fin = $anio_mes . "-31"; $SQL = "SELECT * FROM transaccion AS t\r\n INNER JOIN historial AS h\r\n ON h.FK_transaccion_trans_ID = t.trans_ID\r\n WHERE t.FK_anulaciones_anu_ID IS NULL\r\n AND t.trans_tipo_pago = 'boleta'\r\n AND (h.cuota <> 'IVA19' AND h.tipo <> 'boleta19')\r\n AND t.trans_fecha_pago >= '{$trans_fecha_ini}'\r\n AND t.trans_fecha_pago <= '{$trans_fecha_fin}'\r\n ORDER BY t.trans_fecha_pago, t.trans_num_boleta"; //dpr($SQL); $result = DBQuery($SQL, $this->dbh); while ($row = DBFetchArray($result)) { if (!isset($boletas[$row['trans_fecha_pago']]['sumatoria'])) { $boletas[$row['trans_fecha_pago']]['sumatoria'] = 0; } if (!isset($boletas[$row['trans_fecha_pago']]['boleta_inicial'])) { $boletas[$row['trans_fecha_pago']]['boleta_inicial'] = $row['trans_num_boleta']; } if (!isset($boletas[$row['trans_fecha_pago']]['boleta_final'])) { $boletas[$row['trans_fecha_pago']]['boleta_final'] = $row['trans_num_boleta']; } $boletas[$row['trans_fecha_pago']]['boleta_final'] = $row['trans_num_boleta']; $boletas[$row['trans_fecha_pago']]['sumatoria'] += $row['trans_monto'] + $row['trans_interes']; if ($detalle) { $boletas[$row['trans_fecha_pago']]['detalles'][$row['trans_ID']] = $row; } } return $boletas; }
public function obtenerNotasAlumno($rut) { $SQL = "SELECT * FROM notas WHERE rut = '{$rut}'"; $result = DBQuery($SQL, $this->dbh); $notas_alumno = array(); while ($row = DBFetchArray($result)) { $notas_alumno[$row['ramo']] = $row; } return $notas_alumno; }
protected function addRelatedObjects(array $options, array $result) { $result = parent::addRelatedObjects($options, $result); $hostPrototypeIds = array_keys($result); // adding discovery rule if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) { $relationMap = $this->createRelationMap($result, 'hostid', 'parent_itemid', 'host_discovery'); $discoveryRules = API::DiscoveryRule()->get(['output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true]); $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule'); } // adding group links if ($options['selectGroupLinks'] !== null && $options['selectGroupLinks'] != API_OUTPUT_COUNT) { $groupPrototypes = DBFetchArray(DBselect('SELECT hg.group_prototypeid,hg.hostid' . ' FROM group_prototype hg' . ' WHERE ' . dbConditionInt('hg.hostid', $hostPrototypeIds) . ' AND hg.groupid IS NOT NULL')); $relationMap = $this->createRelationMap($groupPrototypes, 'hostid', 'group_prototypeid'); $groupPrototypes = API::getApiService()->select('group_prototype', ['output' => $options['selectGroupLinks'], 'group_prototypeids' => $relationMap->getRelatedIds(), 'preservekeys' => true]); foreach ($groupPrototypes as &$groupPrototype) { unset($groupPrototype['name']); } unset($groupPrototype); $result = $relationMap->mapMany($result, $groupPrototypes, 'groupLinks'); } // adding group prototypes if ($options['selectGroupPrototypes'] !== null && $options['selectGroupPrototypes'] != API_OUTPUT_COUNT) { $groupPrototypes = DBFetchArray(DBselect('SELECT hg.group_prototypeid,hg.hostid' . ' FROM group_prototype hg' . ' WHERE ' . dbConditionInt('hg.hostid', $hostPrototypeIds) . ' AND hg.groupid IS NULL')); $relationMap = $this->createRelationMap($groupPrototypes, 'hostid', 'group_prototypeid'); $groupPrototypes = API::getApiService()->select('group_prototype', ['output' => $options['selectGroupPrototypes'], 'group_prototypeids' => $relationMap->getRelatedIds(), 'preservekeys' => true]); foreach ($groupPrototypes as &$groupPrototype) { unset($groupPrototype['groupid']); } unset($groupPrototype); $result = $relationMap->mapMany($result, $groupPrototypes, 'groupPrototypes'); } // adding host if ($options['selectParentHost'] !== null && $options['selectParentHost'] != API_OUTPUT_COUNT) { $relationMap = new CRelationMap(); $dbRules = DBselect('SELECT hd.hostid,i.hostid AS parent_hostid' . ' FROM host_discovery hd,items i' . ' WHERE ' . dbConditionInt('hd.hostid', $hostPrototypeIds) . ' AND hd.parent_itemid=i.itemid'); while ($relation = DBfetch($dbRules)) { $relationMap->addRelation($relation['hostid'], $relation['parent_hostid']); } $hosts = API::Host()->get(['output' => $options['selectParentHost'], 'hostids' => $relationMap->getRelatedIds(), 'templated_hosts' => true, 'nopermissions' => true, 'preservekeys' => true]); $result = $relationMap->mapOne($result, $hosts, 'parentHost'); } // adding templates if ($options['selectTemplates'] !== null) { if ($options['selectTemplates'] != API_OUTPUT_COUNT) { $relationMap = $this->createRelationMap($result, 'hostid', 'templateid', 'hosts_templates'); $templates = API::Template()->get(['output' => $options['selectTemplates'], 'templateids' => $relationMap->getRelatedIds(), 'preservekeys' => true]); $result = $relationMap->mapMany($result, $templates, 'templates'); } else { $templates = API::Template()->get(['hostids' => $hostPrototypeIds, 'countOutput' => true, 'groupCount' => true]); $templates = zbx_toHash($templates, 'hostid'); foreach ($result as $hostid => $host) { $result[$hostid]['templates'] = isset($templates[$hostid]) ? $templates[$hostid]['rowscount'] : 0; } } } // adding inventory if ($options['selectInventory'] !== null) { $relationMap = $this->createRelationMap($result, 'hostid', 'hostid'); // only allow to retrieve the hostid and inventory_mode fields $output = []; if ($this->outputIsRequested('hostid', $options['selectInventory'])) { $output[] = 'hostid'; } if ($this->outputIsRequested('inventory_mode', $options['selectInventory'])) { $output[] = 'inventory_mode'; } $inventory = API::getApiService()->select('host_inventory', ['output' => $output, 'filter' => ['hostid' => $hostPrototypeIds]]); $result = $relationMap->mapOne($result, zbx_toHash($inventory, 'hostid'), 'inventory'); } return $result; }
function obtenerAsistencia($rut, $periodo) { if ($periodo == "2S") { $periodo = "anual"; } $SQL = "SELECT asistencia FROM " . $this->schema . "transversales WHERE FK_alumnos_rut = '{$rut}'\r\n AND transv_periodo='{$periodo}'"; $result = DBQuery($SQL, $this->dbh); $row = DBFetchArray($result); return $row['asistencia']; }
protected function addRelatedObjects(array $options, array $result) { $result = parent::addRelatedObjects($options, $result); $groupIds = array_keys($result); sort($groupIds); // adding hosts if ($options['selectHosts'] !== null) { if ($options['selectHosts'] !== API_OUTPUT_COUNT) { $relationMap = $this->createRelationMap($result, 'groupid', 'hostid', 'hosts_groups'); $hosts = API::Host()->get(array('output' => $options['selectHosts'], 'nodeids' => $options['nodeids'], 'hostids' => $relationMap->getRelatedIds(), 'preservekeys' => true)); if (!is_null($options['limitSelects'])) { order_result($hosts, 'host'); } $result = $relationMap->mapMany($result, $hosts, 'hosts', $options['limitSelects']); } else { $hosts = API::Host()->get(array('nodeids' => $options['nodeids'], 'groupids' => $groupIds, 'countOutput' => true, 'groupCount' => true)); $hosts = zbx_toHash($hosts, 'groupid'); foreach ($result as $groupid => $group) { if (isset($hosts[$groupid])) { $result[$groupid]['hosts'] = $hosts[$groupid]['rowscount']; } else { $result[$groupid]['hosts'] = 0; } } } } // adding templates if ($options['selectTemplates'] !== null) { if ($options['selectTemplates'] !== API_OUTPUT_COUNT) { $relationMap = $this->createRelationMap($result, 'groupid', 'hostid', 'hosts_groups'); $hosts = API::Template()->get(array('output' => $options['selectTemplates'], 'nodeids' => $options['nodeids'], 'templateids' => $relationMap->getRelatedIds(), 'preservekeys' => true)); if (!is_null($options['limitSelects'])) { order_result($hosts, 'host'); } $result = $relationMap->mapMany($result, $hosts, 'templates', $options['limitSelects']); } else { $hosts = API::Template()->get(array('nodeids' => $options['nodeids'], 'groupids' => $groupIds, 'countOutput' => true, 'groupCount' => true)); $hosts = zbx_toHash($hosts, 'groupid'); foreach ($result as $groupid => $group) { if (isset($hosts[$groupid])) { $result[$groupid]['templates'] = $hosts[$groupid]['rowscount']; } else { $result[$groupid]['templates'] = 0; } } } } // adding discovery rule if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) { // discovered items $discoveryRules = DBFetchArray(DBselect('SELECT gd.groupid,hd.parent_itemid' . ' FROM group_discovery gd,group_prototype gp,host_discovery hd' . ' WHERE ' . dbConditionInt('gd.groupid', $groupIds) . ' AND gd.parent_group_prototypeid=gp.group_prototypeid' . ' AND gp.hostid=hd.hostid')); $relationMap = $this->createRelationMap($discoveryRules, 'groupid', 'parent_itemid'); $discoveryRules = API::DiscoveryRule()->get(array('output' => $options['selectDiscoveryRule'], 'nodeids' => $options['nodeids'], 'itemids' => $relationMap->getRelatedIds(), 'preservekeys' => true)); $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule'); } // adding group discovery if ($options['selectGroupDiscovery'] !== null) { $groupDiscoveries = API::getApi()->select('group_discovery', array('output' => $this->outputExtend('group_discovery', array('groupid'), $options['selectGroupDiscovery']), 'filter' => array('groupid' => $groupIds), 'preservekeys' => true, 'nodeids' => get_current_nodeid(true))); $relationMap = $this->createRelationMap($groupDiscoveries, 'groupid', 'groupid'); $groupDiscoveries = $this->unsetExtraFields($groupDiscoveries, array('groupid'), $options['selectGroupDiscovery']); $result = $relationMap->mapOne($result, $groupDiscoveries, 'groupDiscovery'); } return $result; }
function obtenerCursosDelCiclo($cic_ID) { $SQL = "SELECT * FROM curso WHERE FK_ciclo_cic_ID = {$cic_ID}\r\n ORDER BY curso"; $result = DBQuery($SQL, $this->dbh); while ($row = DBFetchArray($result)) { $cursos[] = $row['curso']; } return $cursos; }
function index() { $ingreso_valido = false; session_destroy(); $alumnoSIGA = new stdClass(); $colegioSIGA = new stdClass(); $bdSIGA = new stdClass(); $rut = $_POST['rut']; DBconnect($dbh, "dorcl_siga"); $SQL = "SELECT * FROM db INNER JOIN colegios AS c ON c.FK_db_db_ID = db_ID"; $result = DBQuery($SQL, $dbh); while ($row = DBFetchArray($result)) { $bd = "dorcl_" . $row['bd'] . $row['anio']; $bdSIGA->db_ID = $row['db_ID']; $_SESSION['path'] = $bdSIGA->bd = $row['bd']; $bdSIGA->anio = $row['anio']; $bdSIGA->nombrebd = $bd; $_SESSION['base_datos'] = $bdSIGA; $SQL = "SELECT * FROM colegios WHERE FK_db_db_ID = '{$row['db_ID']}'"; $colegioSIGA->nombre = $row['nombre']; $colegioSIGA->direccion = $row['direccion']; $colegioSIGA->telefono = $row['telefono']; $colegioSIGA->rbd = $row['rbd']; $_SESSION['colegio'] = $colegioSIGA; mysql_select_db($bd); //dpr($bd); $SQL = "SELECT * FROM alumnos WHERE rut = '{$rut}' AND ultima_matricula = '" . $row['anio'] . "'"; $result3 = DBQuery($SQL, $dbh); //dpr($SQL); if ($row3 = DBFetchArray($result3)) { //dpr($row3); //dpr($_SESSION); $alumnoSIGA->rut = $row3['rut']; $alumnoSIGA->curso = $row3['curso']; $alumnoSIGA->nombres = $row3['nombres']; $alumnoSIGA->apellidop = $row3['apellidop']; $_SESSION['alumno'] = $alumnoSIGA; $data['nombre_alumno'] = $row3['nombres'] . " " . $row3['apellidop']; $_SESSION['token'] = TOKEN; $_SESSION['bd_siga'] = "dorcl_siga"; //echo "XS"; $ingreso_valido = true; break; } } //dpr($_SESSION); if ($ingreso_valido) { //dpr($_SESSION); //$ses = $_SERVER['HTTP_COOKIE']; //dpr($ses); $class_alumno = new alumno(); $class_apoderado = new apoderado(); $class_notas = new notas(); $class_mensualidad = new mensualidad(); $data['apoderado'] = $class_apoderado->obtenerApoderado($rut); $data['notas'] = $class_notas->obtenerNotasAlumno($rut); $data['mensualidad'] = $class_mensualidad->obtenerMensualidad($rut); //moveLocation("alumnos/ingreso",2,"",""); $this->load->view('ALUM-ingreso_valido', $data); //moveLocation("alumnos/ingreso",2,"",""); } else { moveLocation("../ingreso.php", 0, 6); } }
/** * Disable actions that do not have operations. */ protected function disableActionsWithoutOperations(array $actionids) { $actions = DBFetchArray(DBselect('SELECT DISTINCT a.actionid' . ' FROM actions a' . ' WHERE NOT EXISTS (SELECT NULL FROM operations o WHERE o.actionid=a.actionid)' . ' AND ' . dbConditionInt('a.actionid', $actionids))); $actions_without_operations = zbx_objectValues($actions, 'actionid'); if ($actions_without_operations) { $this->disableActions($actions_without_operations); } }
protected function addRelatedObjects(array $options, array $result) { $result = parent::addRelatedObjects($options, $result); $hostids = array_keys($result); // adding inventories if ($options['selectInventory'] !== null) { $relationMap = $this->createRelationMap($result, 'hostid', 'hostid'); $inventory = API::getApiService()->select('host_inventory', ['output' => $options['selectInventory'], 'filter' => ['hostid' => $hostids]]); $result = $relationMap->mapOne($result, zbx_toHash($inventory, 'hostid'), 'inventory'); } // adding hostinterfaces if ($options['selectInterfaces'] !== null) { if ($options['selectInterfaces'] != API_OUTPUT_COUNT) { $interfaces = API::HostInterface()->get(['output' => $this->outputExtend($options['selectInterfaces'], ['hostid', 'interfaceid']), 'hostids' => $hostids, 'nopermissions' => true, 'preservekeys' => true]); // we need to order interfaces for proper linkage and viewing order_result($interfaces, 'interfaceid', ZBX_SORT_UP); $relationMap = $this->createRelationMap($interfaces, 'hostid', 'interfaceid'); $interfaces = $this->unsetExtraFields($interfaces, ['hostid', 'interfaceid'], $options['selectInterfaces']); $result = $relationMap->mapMany($result, $interfaces, 'interfaces', $options['limitSelects']); } else { $interfaces = API::HostInterface()->get(['hostids' => $hostids, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true]); $interfaces = zbx_toHash($interfaces, 'hostid'); foreach ($result as $hostid => $host) { $result[$hostid]['interfaces'] = isset($interfaces[$hostid]) ? $interfaces[$hostid]['rowscount'] : 0; } } } // adding screens if ($options['selectScreens'] !== null) { if ($options['selectScreens'] != API_OUTPUT_COUNT) { $screens = API::TemplateScreen()->get(['output' => $this->outputExtend($options['selectScreens'], ['hostid']), 'hostids' => $hostids, 'nopermissions' => true]); if (!is_null($options['limitSelects'])) { order_result($screens, 'name'); } // inherited screens do not have a unique screenid, so we're building a map using array keys $relationMap = new CRelationMap(); foreach ($screens as $key => $screen) { $relationMap->addRelation($screen['hostid'], $key); } $screens = $this->unsetExtraFields($screens, ['hostid'], $options['selectScreens']); $result = $relationMap->mapMany($result, $screens, 'screens', $options['limitSelects']); } else { $screens = API::TemplateScreen()->get(['hostids' => $hostids, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true]); $screens = zbx_toHash($screens, 'hostid'); foreach ($result as $hostid => $host) { $result[$hostid]['screens'] = isset($screens[$hostid]) ? $screens[$hostid]['rowscount'] : 0; } } } // adding discovery rule if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) { // discovered items $discoveryRules = DBFetchArray(DBselect('SELECT hd.hostid,hd2.parent_itemid' . ' FROM host_discovery hd,host_discovery hd2' . ' WHERE ' . dbConditionInt('hd.hostid', $hostids) . ' AND hd.parent_hostid=hd2.hostid')); $relationMap = $this->createRelationMap($discoveryRules, 'hostid', 'parent_itemid'); $discoveryRules = API::DiscoveryRule()->get(['output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'preservekeys' => true]); $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule'); } // adding host discovery if ($options['selectHostDiscovery'] !== null) { $hostDiscoveries = API::getApiService()->select('host_discovery', ['output' => $this->outputExtend($options['selectHostDiscovery'], ['hostid']), 'filter' => ['hostid' => $hostids], 'preservekeys' => true]); $relationMap = $this->createRelationMap($hostDiscoveries, 'hostid', 'hostid'); $hostDiscoveries = $this->unsetExtraFields($hostDiscoveries, ['hostid'], $options['selectHostDiscovery']); $result = $relationMap->mapOne($result, $hostDiscoveries, 'hostDiscovery'); } return $result; }
function obtenerAlumno($rut) { $SQL = "SELECT * FROM alumnos WHERE rut = '{$rut}'"; $result = DBQuery($SQL, $this->dbh); $row = DBFetchArray($result); return $row; }
function obtenerAlumnosSinRamo($curso, $nom_ramo) { $class_alumnos = new alumno(); $datos_alumnos = array(); $SQL = "SELECT * FROM alumnos AS al\r\n\t\t\t\tWHERE al.curso = '{$curso}'\r\n\t\t\t\tAND al.ultima_matricula = '" . $_SESSION['base_datos']->anio . "'"; $result = DBQuery($SQL, $this->dbh); while ($row = DBFetchArray($result)) { $alumnos[$row["rut"]] = $row["rut"]; } $SQL = "SELECT al.* FROM alumnos AS al\r\n\t\t\t\tINNER JOIN notas as n\r\n\t\t\t\tON al.rut = n.rut\r\n\t\t\t\tWHERE al.curso = '{$curso}'\r\n\t\t\t\tAND n.ramo = '{$nom_ramo}'\r\n\t\t\t\tAND al.ultima_matricula = '" . $_SESSION['base_datos']->anio . "'"; $result = DBQuery($SQL, $this->dbh); while ($row = DBFetchArray($result)) { $alumnos_inscritos[$row["rut"]] = $row["rut"]; } if (count($alumnos_inscritos) > 0) { $alumnos_desinscritos = array_diff($alumnos, $alumnos_inscritos); } else { $alumnos_desinscritos = $alumnos; } if (count($alumnos_desinscritos) > 0) { foreach ($alumnos_desinscritos as $rut => $val) { $datos_alumnos[$rut] = $class_alumnos->obtenerAlumno($rut); } } return $datos_alumnos; }