config = &$CONF; $this->ref_tables = array(); $this->ref_values = array(); $this->fields = array( '1' => 'id', '2' => 'nombre', '3' => 'apellidos', '4' => 'cif', '5' => 'fecha_nacimiento', '6' => 'nacionalidad', '7' => 'telefono', '8' => 'email', '10' => 'evaluacion', '11' => 'telefonicas', '12' => 'coche', '13' => 'poblacion', '14' => 'fecha_entrevista', '15' => 'fecha_entrevista', ); $this->query_order = array( 'a' => 'ASC', 'd' => 'DESC' ); $this->records_view = array('order' => array('1','3','2','4','5','6','7','8'), 'width' => array('25', '160', '100', '100', '70', '100','85','140'), 'orderby' => array(true, true, true, true, true, true, true, true), 'search' => array(true, true, true, true, true, false, true, true) ); /* Tablas de referencia */ $this->ref_tables = array( 'candidate_nationality' => 'ref_nacionalidad', 'candidate_deduction' => 'ref_retenciones', 'candidate_zones' => 'ref_zonas', 'candidate_state' => 'ref_provincias', 'candidate_knowledge' => 'ref_conocimientos', 'candidate_languages' => 'ref_idiomas', 'candidate_preferences' => 'ref_preferencias', 'candidate_class_type' => 'ref_tipos_clase', 'candidate_id_type' => 'ref_identificacion' ); $this->fields_table = array( 'candidate_zones' => 'candidato_zonas', 'candidate_knowledge' => 'candidato_conocimientos', 'candidate_languages' => 'candidato_idiomas', 'candidate_preferences' => 'candidato_preferencias', 'candidate_class_type' => 'candidato_tipo_clase', 'candidate_companies' => 'candidato_empresa' ); $this->getReferenceValues(); } //----------------------------------------------------------------------------------- // getReferenceValues // Obtiene el listado de los datos de las tablas de referencia. function getReferenceValues() { if ( count($this->ref_tables) > 0 ) { while ( list($field) = each($this->ref_tables) ) { $SQL_query = db_query('SELECT id, nombre FROM ' . $this->ref_tables[$field] . ' ORDER BY nombre'); if ( db_num_rows($SQL_query) > 0 ) { while ( $SQL_values = db_fetch_array($SQL_query) ) $this->ref[$field][$SQL_values['id']] = $SQL_values['nombre']; } } reset($this->ref_tables); } } //----------------------------------------------------------------------------------- // getRecordList // Obtiene un listado de registros de la BBDD. function getRecordList(&$page, $order_field = 1, $order_type = 'd', $SQL_records_filter = '' ) { $records_list = array(); if ( !isset( $this->fields[$order_field] ) ) $order_field = 1; if ( !isset( $this->query_order[$order_type] ) ) $order_type = 'd'; $SQL_records_query = db_query('SELECT COUNT(*) AS total FROM candidatos' . $SQL_records_filter); $SQL_records = db_fetch_array($SQL_records_query); if ( $SQL_records['total'] > 0 ) { $page = check_records_page($page, $SQL_records['total']); $this->num_records = $SQL_records['total']; $SQL_records_order = ' ORDER BY ' . $this->fields[$order_field] . ' ' . $this->query_order[$order_type]; $SQL_records_limit = ' LIMIT ' . ( ( $page - 1 ) * $this->config['max_num_regs_list'] ) . ', ' . $this->config['max_num_regs_list']; $SQL_query = db_query('SELECT id, nombre, apellidos, cif, fecha_nacimiento, nacionalidad, telefono, email FROM candidatos' . $SQL_records_filter . $SQL_records_order . $SQL_records_limit); while ( $SQL_record = db_fetch_array($SQL_query) ) { $records_list[$SQL_record['id']]['1'] = $SQL_record['id']; $records_list[$SQL_record['id']]['2'] = stripslashes($SQL_record['nombre']); $records_list[$SQL_record['id']]['3'] = stripslashes($SQL_record['apellidos']); $records_list[$SQL_record['id']]['4'] = $SQL_record['cif']; $records_list[$SQL_record['id']]['5'] = $SQL_record['fecha_nacimiento']; $records_list[$SQL_record['id']]['6'] = $this->ref['candidate_nationality'][$SQL_record['nacionalidad']]; $records_list[$SQL_record['id']]['7'] = $SQL_record['telefono']; $records_list[$SQL_record['id']]['8'] = $SQL_record['email']; } } return $records_list; } //----------------------------------------------------------------------------------- // generateFilterQuery function generateFilterQuery( $filter_field = '', $filter_values = '', $adv_search = '', $rawFilter = FALSE ) { $SQL_filter = ( $rawFilter ? '' : ' WHERE 1 '); if ( is_array($filter_values) ) { if ( count($filter_values) > 0 ) { while ( list($id) = each($filter_values) ) { if ( isset( $this->fields[$id]) && !empty($filter_values[$id]) ) $SQL_filter .= ' AND' . $this->fields[$id] . ' LIKE \'%' . addslashes($filter_values[$id]) . '%\''; } } } elseif ( trim($filter_values) != '' && isset( $this->fields[$filter_field] ) ) $SQL_filter .= ' AND ' . $this->fields[$filter_field] . ' LIKE \'%' . addslashes($filter_values) . '%\''; if ( is_array($adv_search) ) { if ( in_array($adv_search['filter_show'], array('>','<','=')) ) { if ( is_numeric($adv_search['filter_number']) && $adv_search['filter_date'] > '0' ) { switch ( $adv_search['filter_date'] ) { case '365': $date = mktime(0,0,0, date('n'), date('j'), ( date('Y') - $adv_search['filter_number'] ) ); break; case '30': $date = mktime(0,0,0,( date('n') - $adv_search['filter_number'] ), date('j'), date('Y') ); break; default: $date = mktime(0,0,0,date('n'),( date('j') - ($adv_search['filter_number'] * $adv_search['filter_date']) ), date('Y') ); break; } $SQL_filter .= ' AND fecha_entrevista ' . $adv_search['filter_show'] . '"' . date('Y-m-d', $date) . '"'; } } } return $SQL_filter; } //----------------------------------------------------------------------------------- // advancedSearch function advancedSearch( $params ) { $candidates = array(); $referenceIds = array(); $SQL_where = ''; $noValues = false; while ( list($field) = each($params) ) { if ( is_array($params[$field]) && $this->fields_table[$field] ) { // GESTION DE CAMPOS MULTIPLES while ( list($i) = each($params[$field]) ) { $ids = array(); $SQL_query = db_query('SELECT id_candidato FROM ' . $this->fields_table[$field] . ' WHERE id_campo = \'' . $params[$field][$i] . '\''); if ( db_num_rows($SQL_query) > 0 ) { while ( $SQL_values = db_fetch_array($SQL_query) ) $ids[] = $SQL_values['id_candidato']; if ( count($referenceIds) > 0 ) $referenceIds = array_intersect($ids, $referenceIds); else $referenceIds = $ids; if ( count($referenceIds) == 0 ) { $noValues = true; break(2); } } else { $noValues = true; break(2); } } if ( count($candidates) > 0 ) $candidates = array_intersect($referenceIds, $candidates); else $candidates = $referenceIds; if ( count($candidates) == 0 ) { $noValues = true; break; } } else { // GESTION CAMPOS SIMPLES $classField = substr($field, 1); if ( $params[$field] != '' && $this->fields[$classField] ) { switch ( $classField ) { case '10': $SQL_operator = '>='; break; case '14': if ( @checkdate(substr($params[$field],3,2),substr($params[$field],0,2),substr($params[$field],6) ) ) { $startDate = mktime(0,0,0,substr($params[$field],3,2),substr($params[$field],0,2),substr($params[$field],6)); $SQL_operator = '>='; $params[$field] = date('Y-m-d', $startDate); } else { $SQL_operator = '='; $params[$field] = '1000-01-01'; } break; case '15': if ( @checkdate(substr($params[$field],3,2),substr($params[$field],0,2),substr($params[$field],6) ) ) { $startDate = mktime(0,0,0,substr($params[$field],3,2),substr($params[$field],0,2),substr($params[$field],6)); $SQL_operator = '<='; $params[$field] = date('Y-m-d', $startDate); } else { $SQL_operator = '='; $params[$field] = '1000-01-01'; } break; default: $SQL_operator = '='; } $SQL_where .= ' AND ' . $this->fields[$classField] . ' ' . $SQL_operator . ' \'' . addslashes($params[$field]) . '\''; } } } if ( !$noValues ) { // GESTION CAMPOS DE BUSQUEDA POR DEFECTO if ( !empty($params['filter_by']) && trim($params['filter_name']) != '' ) { $SQL_where .= $this->generateFilterQuery($params['filter_by'], $params['filter_name'], '', TRUE); } } if ( !$noValues && is_array($params['timetable'])) { // HORARIO COMPATIBLE $timeValues = $this->manageTime($params['timetable']); $candidateTimes = array(); $referenceIds = array(); while ( list($id) = each($params['timetable']) ) { $ids = array(); ereg("^([1-7]{1})-([0-9]{1,2})-([0-9]{1,2})$", $timeValues[$id], $interval ); $SQL_query = db_query('SELECT ph.id FROM candidato_horario ph LEFT JOIN candidatos p ON ph.id = p.id WHERE ( ph.dia_inicio <= \'' . $interval[1] . '\' AND ph.dia_fin >= \'' . $interval[1] . '\' ) AND ( ph.hora_inicio <= \'' . $interval[2] . '\' AND ph.hora_fin >= \'' . $interval[3] . '\' )'); if ( db_num_rows($SQL_query) > 0 ) { while ( $SQL_values = db_fetch_array($SQL_query) ) $ids[] = $SQL_values['id']; if ( count($referenceIds) > 0 ) $referenceIds = array_intersect($ids, $referenceIds); else $referenceIds = $ids; if ( count($referenceIds) == 0 ) { $noValues = true; break; } } else { $noValues = true; break; } } if ( count($candidates) > 0 && count($referenceIds) > 0 ) $candidates = array_intersect($referenceIds, $candidates); else $candidates = $referenceIds; if ( count($candidates) == 0 ) $noValues = true; } if ( !$noValues ) { if ( count($candidates) > 0 && !empty($SQL_where) ) { $SQL_query = db_query('SELECT id FROM candidatos WHERE 1' . $SQL_where); if ( db_num_rows($SQL_query) > 0 ) { $ids = array(); while ( $SQL_values = db_fetch_array($SQL_query) ) $ids[] = $SQL_values['id']; $candidates = array_intersect($ids, $candidates); if ( count($candidates) > 0 ) $SQL_filter = 'AND id IN (' . implode(',', $candidates) . ')'; else $SQL_filter = ' AND id = \'0\''; } else $SQL_filter = ' AND id = \'0\''; } else $SQL_filter = $SQL_where . ( count($candidates) > 0 ? ' AND id IN (' . implode(',', $candidates) . ')' : '' ); } else $SQL_filter = ' AND id = \'0\''; return $SQL_filter; } //----------------------------------------------------------------------------------- // manageTime function manageTime($times) { $intervals = array(); if ( is_array($times) ) { foreach ( $times AS $time ) { if ( ereg("^([1-7]{1})-([0-9]{1,2})-([0-9]{1,2})$", $time ) ) $intervals[] = $time; elseif( ereg("^([1-7]{1})-([0-9]{1,2})-([0-9]{1,2})-([0-9]{1,2})$", $time, $interval ) ) { for ( $i=$interval[1]; $i<=$interval[2]; $i++ ) $intervals[] = $i . '-' . $interval[3] . '-' . $interval[4]; } } } return $intervals; } //----------------------------------------------------------------------------------- // deleteRecord // Elimina un registro de la BBDD. function deleteRecord($record) { $error .= ''; if ( $this->checkRecord($record) ) { if ( @db_query('DELETE FROM candidatos WHERE id = \'' . $record . '\'') ) { $error .= 0; @db_query('DELETE FROM candidato_horario WHERE id = \'' . $record . '\''); while ( list($database) = each($this->fields_table) ) @db_query('DELETE FROM ' . $this->fields_table[$database] . ' WHERE id_candidato = \'' . $record . '\''); } else $error .= 2; } else $error .= 1; return $error; } //----------------------------------------------------------------------------------- // checkRecord // Comprueba si existe o no un registro function checkRecord(&$record) { settype($record, "integer"); $SQL_check_record = db_query('SELECT count(*) AS total FROM candidatos WHERE id = \'' . $record . '\''); $SQL_num_records = db_fetch_array($SQL_check_record); if ( $SQL_num_records['total'] == 1 ) return true; else return false; } //----------------------------------------------------------------------------------- // getRecordValues // Obtiene los valores para el registro indicado. function getRecordValues($record) { if ( $this->checkRecord($record) ) { $SQL_check_record = db_query('SELECT id, nombre AS candidate_name, apellidos AS candidate_surname, tipo_identificacion AS candidate_id_type, cif AS candidate_nif, DATE_FORMAT(fecha_nacimiento, "%d/%m/%Y") AS candidate_birthdate, nacionalidad AS candidate_nationality, telefono AS candidate_phone, telefono_2 AS candidate_phone_2, fax AS candidate_fax, email AS candidate_email, retenciones AS candidate_deduction, direccion AS candidate_address, numero AS candidate_number, piso_bloque AS candidate_floor, localidad AS candidate_city, codigo_postal AS candidate_postalcod, poblacion AS candidate_state, observaciones AS candidate_comments, IF(experiencia, experiencia, \'\') AS candidate_experience, IF(evaluacion > 0, evaluacion, \'\') AS candidate_evaluation, IF(tarifa > 0, tarifa, \'\') AS candidate_rate, IF(fecha_entrevista, DATE_FORMAT(fecha_entrevista, "%d/%m/%Y"), \'\') AS candidate_date_interview, IF(fecha_inicio, DATE_FORMAT(fecha_inicio, "%d/%m/%Y"), \'\') AS candidate_start_date, IF(fecha_fin, DATE_FORMAT(fecha_fin, "%d/%m/%Y"), \'\') AS candidate_end_date, telefonicas AS candidate_telephone_class, coche AS candidate_car, puntos_fuertes AS candidate_strengths, puntos_debiles AS candidate_weaknessess FROM candidatos WHERE id = \'' . $record . '\''); if ( db_num_rows($SQL_check_record) == 1 ) { $this->candidate = db_fetch_array($SQL_check_record); strip_slashes($this->candidate); $this->getReferenceIds($record); return $this->candidate; } else return false; } else return false; } //----------------------------------------------------------------------------------- // getReferenceIds // Obtiene los valores de los campos de tipo multiple asignados a un candidato. function getReferenceIds ( $record ) { while ( list($field) = each($this->fields_table) ) { $SQL_query = db_query('SELECT id_campo FROM ' . $this->fields_table[$field] . ' WHERE id_candidato = \'' . $record . '\''); if ( db_num_rows($SQL_query) > 0 ) { while ( $SQL_values = db_fetch_array($SQL_query) ) $this->candidate[$field][] = $SQL_values['id_campo']; } } } //----------------------------------------------------------------------------------- // manageRecord // - Recibe los parametros enviados desde el formulario mediante metodo POST. // - Determina el tipo de accion a realizar (INSERT o UPDATE). // - Trata los valores recibidos. // - Genera un codigo de error correspondiente a las acciones realizadas. // // [1] > Tipo de accion // [2] > Campo nombre // [3] > Campo Fecha Nacimiento // [4] > Campo NIF // [5] > Resultado de la accion sobre la BBDD. function manageRecord(&$params) { $action; $error; // Chequeo y tratamiento de los valores recibidos if ( isset($params['record_id']) ) { if ( ereg("^[0-9]+$", $params['record_id'] ) && $params['record_id'] > 0 ) { if ( $this->checkRecord($params['record_id']) ) $action = 'update'; } else unset($params['record_id']); } else $action = 'insert'; $params['candidate_nif'] = eregi_replace("[^a-z0-9]", '', $params['candidate_nif']); $params['candidate_evaluation'] = ereg_replace(',', '.', $params['candidate_evaluation']); $params['candidate_rate'] = ereg_replace(',', '.', $params['candidate_rate']); $candidate_birthdate = $this->validateDate($params['candidate_birthdate']); $candidate_date_interview = $this->validateDate($params['candidate_date_interview']); $candidate_start_date = $this->validateDate($params['candidate_start_date']); $candidate_end_date = $this->validateDate($params['candidate_end_date']); $this->validateParams($params); // Generacion del codigo de error $error = ( $action == '' ? 1 : 0 ); $error .= ( empty($params['candidate_name']) ? 1 : 0 ); $error .= ( !empty($params['candidate_nif']) && !$this->checkNif($params['candidate_nif'], $params['record_id']) ? 1 : 0 ); $error .= ( !$candidate_birthdate ? 1 : 0 ); // Acciones sobre la BBDD if ( ereg("^0+$", $error) ) { format_record($params); if ( $action == 'insert' ) { if ( db_query('INSERT INTO candidatos (nombre, apellidos, tipo_identificacion, cif, fecha_nacimiento, nacionalidad, telefono, telefono_2, fax, email, direccion, numero, piso_bloque, localidad, codigo_postal, poblacion, retenciones, observaciones, experiencia, fecha_alta, evaluacion, tarifa, fecha_entrevista, fecha_inicio, fecha_fin, telefonicas, coche, puntos_fuertes, puntos_debiles) VALUES (\'' . $params['candidate_name'] . '\', \'' . $params['candidate_surname'] . '\', \'' . $params['candidate_id_type'] . '\', \'' . $params['candidate_nif'] . '\', \'' . $candidate_birthdate . '\', \'' . $params['candidate_nationality'] . '\', \'' . $params['candidate_phone'] . '\', \'' . $params['candidate_phone_2'] . '\', \'' . $params['candidate_fax'] . '\', \'' . $params['candidate_email'] . '\', \'' . $params['candidate_address'] . '\', \'' . $params['candidate_number'] . '\', \'' . $params['candidate_floor'] . '\', \'' . $params['candidate_city'] . '\', \'' . $params['candidate_postalcod'] . '\', \'' . $params['candidate_state'] . '\', \'' . $params['candidate_deduction'] . '\', \'' . $params['candidate_comments'] . '\', \'' . $params['candidate_experience'] . '\', now(), \'' . $params['candidate_evaluation'] . '\', \'' . $params['candidate_rate'] . '\', \'' . $candidate_date_interview . '\', \'' . $candidate_start_date . '\', \'' . $candidate_end_date . '\', \'' . $params['candidate_telephone_class'] . '\', \'' . $params['candidate_car'] . '\', \'' . $params['candidate_strengths'] . '\', \'' . $params['candidate_weaknessess'] . '\' )') ) { $candidate_id = db_insert_id(); $this->manageReferenceValues('insert', $candidate_id, $params); $params['record_id'] = $candidate_id; $error .= 0; } else $error .= 1; } elseif ( $action == 'update' ) { if ( db_query('UPDATE candidatos SET nombre = \'' . $params['candidate_name'] . '\', apellidos = \'' . $params['candidate_surname'] . '\', tipo_identificacion = \'' . $params['candidate_id_type'] . '\', cif = \'' . $params['candidate_nif'] . '\', fecha_nacimiento = \'' . $candidate_birthdate . '\', nacionalidad = \'' . $params['candidate_nationality'] . '\', telefono = \'' . $params['candidate_phone'] . '\', telefono_2 = \'' . $params['candidate_phone_2'] . '\', fax = \'' . $params['candidate_fax'] . '\', email = \'' . $params['candidate_email'] . '\', direccion = \'' . $params['candidate_address'] . '\', numero = \'' . $params['candidate_number'] . '\', piso_bloque = \'' . $params['candidate_floor'] . '\', localidad = \'' . $params['candidate_city'] . '\', codigo_postal = \'' . $params['candidate_postalcod'] . '\', poblacion = \'' . $params['candidate_state'] . '\', retenciones = \'' . $params['candidate_deduction'] . '\', observaciones = \'' . $params['candidate_comments'] . '\', experiencia = \'' . $params['candidate_experience'] . '\', evaluacion = \'' . $params['candidate_evaluation'] . '\', tarifa = \'' . $params['candidate_rate'] . '\', fecha_entrevista = \'' . $candidate_date_interview . '\', fecha_inicio = \'' . $candidate_start_date . '\', fecha_fin = \'' . $candidate_end_date . '\', telefonicas = \'' . $params['candidate_telephone_class'] . '\', coche = \'' . $params['candidate_car'] . '\', puntos_fuertes = \'' . $params['candidate_strengths'] . '\', puntos_debiles = \'' . $params['candidate_weaknessess'] . '\' WHERE id = \'' . $params['record_id'] . '\'') ) { $this->manageReferenceValues('update', $params['record_id'], $params); $error .= 0; } else $error .= 2; } } strip_slashes($params); return $error; } //----------------------------------------------------------------------------------- // validateParams // Comprueba los datos recibidos de los campos de tipo multiple con los valores de // las tablas de referencia. function validateParams( &$params ) { while ( list($field) = each($this->ref_tables) ) { if ( !empty($params[$field]) ) { if ( is_array($params[$field]) ) { while ( list($id) = each($params[$field]) ) { if ( !$this->ref[$field][$params[$field][$id]] ) unset($params[$field][$id]); } } else { if ( !$this->ref[$field][$params[$field]] ) unset($params[$field]); } } } reset($this->ref_tables); } //----------------------------------------------------------------------------------- // manageReferenceValues // INSERTA, ACTUALIZA y BORRA los valores de las tablas de referencia. function manageReferenceValues( $action, $candidate_id, $params ) { while ( list($field) = each($this->fields_table) ) { if ( is_array($params[$field]) ) { if ( $action == 'update' ) { $ids = array(); $values = array(); $SQL_query = db_query('SELECT id_campo FROM ' . $this->fields_table[$field] . ' WHERE id_candidato = \'' . $candidate_id . '\''); if ( db_num_rows($SQL_query) > 0 ) { while ( $SQL_values = db_fetch_array($SQL_query) ) $values[] = $SQL_values['id_campo']; } } while ( list($id) = each($params[$field]) ) { if ( $action == 'insert' ) @db_query('INSERT INTO ' . $this->fields_table[$field] . ' (id_candidato, id_campo) VALUES (\'' . $candidate_id . '\', \'' . $params[$field][$id] . '\')'); elseif ( $action == 'update' ) { if ( !in_array($params[$field][$id], $values) ) { @db_query('INSERT INTO ' . $this->fields_table[$field] . ' (id_candidato, id_campo) VALUES (\'' . $candidate_id . '\', \'' . $params[$field][$id] . '\')'); $ids[] = $params[$field][$id]; } else $ids[] = $params[$field][$id]; } } if ( $action == 'update' ) { $delete_ids = array_diff($values, $ids); if ( count($delete_ids) > 0 ) db_query('DELETE FROM ' . $this->fields_table[$field] . ' WHERE id_candidato = \'' . $candidate_id . '\' AND id_campo IN (' . implode(',', $delete_ids) . ')'); } } } reset($this->fields_table); } //----------------------------------------------------------------------------------- // validateDate // Comprueba que la fecha suministrada es una fecha valida. Si es asi, devuelve la fe // cha formateada para MySQL. function validateDate( &$date ) { if ( !empty($date) && ereg("^([0-9]{1,2})\/([0-9]{1,2})\/([0-9]{4})$", $date, $regs ) ) { if ( checkdate($regs[2], $regs[1], $regs[3]) ) return $regs[3] . '-' . $regs[2] . '-' . $regs[1]; else { unset($date); return false; } } else { unset($date); return false; } } //----------------------------------------------------------------------------------- // checkNif function checkNif( $nif, $record = '' ) { $SQL_query = db_query('SELECT count(*) AS total FROM candidatos WHERE cif = \'' . $nif . '\'' . ( !empty($record) ? ' AND id != \'' . $record . '\'' : '' ) ); $SQL_values = db_fetch_array($SQL_query); if ( $SQL_values['total'] > 0 ) return false; else return true; } //----------------------------------------------------------------------------------- // candidateToTeacher function candidateToTeacher( $record ) { $error = 0; $relationTables = array( 'candidato_zonas' => 'profesor_zonas', 'candidato_conocimientos' => 'profesor_conocimientos', 'candidato_idiomas' => 'profesor_idiomas', 'candidato_preferencias' => 'profesor_preferencias', 'candidato_tipo_clase' => 'profesor_tipo_clase', 'candidato_empresa' => 'profesor_empresa' ); if ( $this->checkRecord($record) ) { if ( @db_query('INSERT INTO profesores ( id_candidato, nombre, apellidos, tipo_identificacion, cif, fecha_nacimiento, nacionalidad, telefono, telefono_2, fax, email, direccion, numero, piso_bloque, localidad, codigo_postal, poblacion, telefonicas, coche, fecha_entrevista, evaluacion, retenciones, observaciones, experiencia, fecha_alta, puntos_fuertes, puntos_debiles) SELECT ' . $record . ', nombre, apellidos, tipo_identificacion, cif, fecha_nacimiento, nacionalidad, telefono, telefono_2, fax, email, direccion, numero, piso_bloque, localidad, codigo_postal, poblacion, telefonicas, coche, fecha_entrevista, evaluacion, retenciones, observaciones, experiencia, NOW(), puntos_fuertes, puntos_debiles FROM candidatos WHERE id = \'' . $record . '\'') ) { $error .= 0; $newTeacher = db_insert_id(); while ( list($tabla_origen, $tabla_destino) = each($relationTables) ) { @db_query('INSERT INTO ' . $tabla_destino . ' (id_profesor, id_campo) SELECT ' . $newTeacher . ', id_campo FROM ' . $tabla_origen . ' WHERE id_candidato = \'' . $record . '\''); @db_query('DELETE FROM ' . $tabla_origen . ' WHERE id = \'' . $record . '\''); } @db_query('INSERT INTO profesor_tarifas ( id_registro, id_tarifa, importe ) SELECT \'' . $newTeacher .'\', \'1\', tarifa FROM candidatos WHERE id = \'' . $record . '\''); @db_query('DELETE FROM candidatos WHERE id = \'' . $record . '\''); } else $error .= 1; } else $error .= 1; return $error; } //----------------------------------------------------------------------------------- // manageCandidateCompany function manageCandidateCompany( $params, $record ) { $error = ''; $error .= ( $params['search_company_id'] ? 0 : 1 ); if ( ereg("^0+$", $error) ) { if ( @db_query('INSERT INTO candidato_empresa ( id_candidato, id_campo ) VALUES (\'' . $record . '\', \'' . $params['search_company_id'] . '\')') ) $error .= 0; else $error .= 1; } return $error; } //----------------------------------------------------------------------------------- // deleteCandidateCompany function deleteCandidateCompany( $record, $company ) { @db_query('DELETE FROM candidato_empresa WHERE id_candidato = \'' . $record . '\' AND id_campo = \'' . $company . '\''); } } ?>