Ver Mensaje Individual
  #10 (permalink)  
Antiguo 06/12/2008, 11:36
Avatar de vennersteve
vennersteve
 
Fecha de Ingreso: noviembre-2008
Ubicación: San Andrés - Isla
Mensajes: 26
Antigüedad: 15 años, 5 meses
Puntos: 0
Respuesta: Vender más de un artículo en la misma factura

Bueno, lo que hice fue lo siguiente:

Utilizando phpMyAdmin:

Código:
CREATE TABLE `2008` (
  `Student_Id` int(10) NOT NULL,
  `January` tinyint(1) NOT NULL,
  `February` tinyint(1) NOT NULL,
  `March` tinyint(1) NOT NULL,
  `April` tinyint(1) NOT NULL,
  `May` tinyint(1) NOT NULL,
  `June` tinyint(1) NOT NULL,
  `July` tinyint(1) NOT NULL,
  `August` tinyint(1) NOT NULL,
  `September` tinyint(1) NOT NULL,
  `October` tinyint(1) NOT NULL,
  `November` tinyint(1) NOT NULL,
  `December` tinyint(1) NOT NULL,
  PRIMARY KEY  (`Student_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `2009` (
  `Student_Id` int(10) NOT NULL,
  `January` tinyint(1) NOT NULL,
  `February` tinyint(1) NOT NULL,
  `March` tinyint(1) NOT NULL,
  `April` tinyint(1) NOT NULL,
  `May` tinyint(1) NOT NULL,
  `June` tinyint(1) NOT NULL,
  `July` tinyint(1) NOT NULL,
  `August` tinyint(1) NOT NULL,
  `September` tinyint(1) NOT NULL,
  `October` tinyint(1) NOT NULL,
  `November` tinyint(1) NOT NULL,
  `December` tinyint(1) NOT NULL,
  PRIMARY KEY  (`Student_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `2010` (
  `Student_Id` int(10) NOT NULL,
  `January` tinyint(1) NOT NULL,
  `February` tinyint(1) NOT NULL,
  `March` tinyint(1) NOT NULL,
  `April` tinyint(1) NOT NULL,
  `May` tinyint(1) NOT NULL,
  `June` tinyint(1) NOT NULL,
  `July` tinyint(1) NOT NULL,
  `August` tinyint(1) NOT NULL,
  `September` tinyint(1) NOT NULL,
  `October` tinyint(1) NOT NULL,
  `November` tinyint(1) NOT NULL,
  `December` tinyint(1) NOT NULL,
  PRIMARY KEY  (`Student_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `certificate` (
  `Certificate_Id` int(10) NOT NULL auto_increment,
  `Certificate_Date` varchar(10) NOT NULL,
  `Certificate_Detail` text NOT NULL,
  `Student_Id` int(10) NOT NULL,
  PRIMARY KEY  (`Certificate_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `guardian` (
  `Guardian_Id` int(10) NOT NULL auto_increment,
  `Guardian_FirstName` varchar(30) NOT NULL,
  `Guardian_SurName` varchar(30) NOT NULL,
  `Guardian_Address` varchar(100) NOT NULL,
  `Guardian_Phone` varchar(10) NOT NULL,
  `Guardian_MobilePhone` varchar(16) NOT NULL,
  `Guardian_Email` varchar(64) NOT NULL,
  PRIMARY KEY  (`Guardian_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `invoice` (
  `Invoice_Id` int(10) NOT NULL auto_increment,
  `Invoice_Date` varchar(10) NOT NULL,
  `User_Id` int(10) NOT NULL,
  `PaymentMode_Id` int(2) NOT NULL,
  `Guardian_Id` int(10) NOT NULL,
  PRIMARY KEY  (`Invoice_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `paymentmode` (
  `PaymentMode_Id` int(2) NOT NULL auto_increment,
  `PaymentMode_Name` varchar(16) NOT NULL,
  PRIMARY KEY  (`PaymentMode_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `picture` (
  `Picture_Id` int(10) NOT NULL auto_increment,
  `Picture_Filename` varchar(255) NOT NULL,
  `Picture_Name` varchar(32) NOT NULL,
  PRIMARY KEY  (`Picture_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `student` (
  `Student_Id` int(10) NOT NULL auto_increment,
  `Student_Date` varchar(10) NOT NULL,
  `Guardian_Id` int(10) NOT NULL,
  `Student_FirstName` varchar(30) NOT NULL,
  `Student_SurName` varchar(30) NOT NULL,
  `Student_Address` varchar(100) NOT NULL,
  `Student_Phone` varchar(10) NOT NULL,
  `Student_MobilePhone` varchar(16) NOT NULL,
  `Student_Email` varchar(64) NOT NULL,
  `Picture_Id` varchar(10) NOT NULL,
  PRIMARY KEY  (`Student_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `transaction` (
  `Transaction_Id` int(12) NOT NULL auto_increment,
  `Invoice_Id` int(10) NOT NULL,
  `Student_Id` int(10) NOT NULL,
  `Year_Id` int(3) NOT NULL,
  `Transaction_Quantity` varchar(3) NOT NULL,
  `Transaction_Description` varchar(255) NOT NULL,
  `Transaction_UnitPrice` varchar(9) NOT NULL,
  `Transaction_TotalPrice` varchar(10) NOT NULL,
  PRIMARY KEY  (`Transaction_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `user` (
  `User_Id` int(10) NOT NULL auto_increment,
  `User_Name` varchar(10) NOT NULL,
  `User_Password` varchar(16) NOT NULL,
  PRIMARY KEY  (`User_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

CREATE TABLE `year` (
  `Year_Id` int(2) NOT NULL auto_increment,
  `Year_Number` varchar(4) NOT NULL,
  PRIMARY KEY  (`Year_Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Creé las tablas de la manera indicada arriba...

Como pueden deducir los más experimentados, pretendo hacer una aplicación para registrar: acudientes, matrículas de alumnos, pagos de mensualidad por alumno, modos de pago, usuarios que tendrán acceso a la base de datos, certificados de estudio expedidos a cada alumno etc.

También quiero hacer un script para mostrar la información en tablas html paginando los registros y de alguna manera dibujar tablas con un color cuando se ha hecho el pago de un mes o de otro color cuando aún no se haya registrado el pago de dicho mes, para eso creé las tablas: 2008, 2009, 2010...

Quiero hacer un solo script para insertar, actualizar y seleccionar registros de las tablas de esta manera:

commit.php

Código PHP:
<?php
include("config.php"); // no se si es mejor usar include o require...
include("mysql.php"); // este requiere de mysql.php
switch ($_GET['action']) {
      case 
"add":
            switch (
$_GET['type']) {
                  case 
""// segun sea el caso, ej: acudiente, alumno, factura, etc
                        
Formulario segun tipo de objeto a insertar...
                  break;
            }
      case 
"edit":
            switch (
$_GET['type']) {
                  case 
""// segun sea el caso, ej: acudiente, alumno, factura, etc
                        
Formulario segun tipo de objeto a editar...
                  break;
            }
      case 
"view":
            switch (
$_GET['type']) {
                  case 
""// segun sea el caso, ej: acudiente, alumno, factura, etc
                        
Tablas HTML para mostrar registros paginados...
                  break;
            }
      break;
}
?>
Obviamente complementando el resto del script con las verificaciones a cookies y demás elementos que vengo utilizando hace unos días con ayuda de GatorV...

Será que me estoy complicando mucho la vida de esta manera o voy bien??