· 7 years ago · Mar 03, 2019, 01:36 AM
1CREATE TABLE IF NOT EXISTS `ticket` (
2 `id` int(11) NOT NULL AUTO_INCREMENT,
3 `id_usuario` int(11) NOT NULL,
4 `tipo_solicitud` set('1','2','3','4') NOT NULL,
5 `prioridad` set('300','400','500','600','700','800','900','1000','1500','2000','2500','3000','3500','4000','4500','5000','5500','6000','6500','7000','7500','8000','8500','9000','9500','10000','10500','11000','11500','12000') NOT NULL,
6 `titulo` varchar(12) NOT NULL,
7 `observacion` text NOT NULL,
8 PRIMARY KEY (`id`)
9) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
10
11CREATE TABLE IF NOT EXISTS `usuario` (
12 `id` int(11) NOT NULL AUTO_INCREMENT,
13 `id_persona` int(11) NOT NULL,
14 `id_departamento` int(11) NOT NULL,
15 `nombre` varchar(31) NOT NULL,
16 `clave` char(32) NOT NULL,
17 `tipo` set('1','2','3','4','5') NOT NULL,
18 `cartera` int(6) NOT NULL,
19 PRIMARY KEY (`id`),
20 UNIQUE KEY `id_persona` (`id_persona`),
21 UNIQUE KEY `nombre` (`nombre`)
22) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
23
24<?php function addTicket($conexion){
25
26 mysqli_query($conexion, "INSERT INTO ticket (id_usuario, tipo_solicitud, prioridad, titulo, observacion, status, fecha_creacion, hora_creacion)
27 VALUES ('".$this->idUsuario."', '".$this->tipoSolicitud."', '".$this->prioridad."', '".$this->titulo."',
28 '".$this->observacion."', '".$this->status."', '".$this->fecha."', '".$this->hora."')")
29 or die("Error insertando nuevo Ticket: ".mysqli_error($conexion));
30 }
31
32?>
33
34mysqli_query($conexion,"UPDATE usuario SET cartera='cartera - ".$this->prioridad."' WHERE id=".mysqli_insert_id($conexion)." ");