manuality manage multiple pages
/*------------------ Page 1 -----------------*/
sc_pdf_print($cell_folio); //folio of the order
//prin info of the provider
sc_pdf_print_mult($cell_id_provedor, 4.2333333333333);
sc_pdf_print($cell_id_contacto);
sc_pdf_print($cell_fecha_pedido);
sc_pdf_print($cell_id_ot);
sc_pdf_print($cell_proyecto);
sc_pdf_print($cell_credito_dias);
sc_pdf_print($cell_fecha_entrega);
sc_pdf_print_mult($cell_entregar_en, 4.2333333333333);
sc_pdf_print($cell_estaus_odc);
sc_pdf_print($cell_calle);
sc_pdf_print($cell_colonia);
sc_pdf_print($cell_municipio);
sc_pdf_print($cell_telefono);sc_pdf_image('ODC_superior.png',0,0,216);
sc_pdf_set_y(80);
foreach ({compra_detalle} as $NM_ind => $Dados)
{
$i = sc_pdf_get_y(); //get the "Y" position
$pagina = 0; //assign value to number of page only to manage pages
if ($i > 245){ //in a letter page if the "Y" position if for research the end of the page create new page
sc_pdf_add_page('P', 'Letter');
sc_pdf_image('ODC_titulo.png',0,0,216); //this put an image of the title of the page, only to look good the image is png whit transparency
$i = 40; //assign new value to $i
$pagina++; //add one to pagina
sc_pdf_print($cell_folio);
}
sc_pdf_set_y($i); //assign a value to the "y" position
// print the line of values this is shopping order
sc_pdf_print_sub_sel($cell_compra_detalle_cpr_odc_detalle_catidad[$NM_ind]);
sc_pdf_print_sub_sel_mult($cell_compra_detalle_unidad[$NM_ind], 3.5277777777778);
sc_pdf_print_sub_sel_mult($cell_compra_detalle_cpr_odc_detalle_des_producto[$NM_ind], 3.5277777777778);
sc_pdf_print_sub_sel($cell_compra_detalle_cpr_odc_detalle_precio_uni[$NM_ind]);
sc_pdf_print_sub_sel($cell_compra_detalle_precio2[$NM_ind]);
$y = sc_pdf_get_y(); //obtain the value of position of "Y"
$h = $y-$i; //calculate the height of the line
$h = $h+23; //sum 23 millimeters
sc_pdf_rect(4,$i-4,204,$h, 'D'); //draw a rectangle to that line
sc_pdf_set_y($y+23); //set the new "Y" position
}
$j = sc_pdf_get_y();
switch ($pagina){
case 0: //si es la primer pagina //check if it is the firts page
if ($j >= 160){ //if the position is most of 160 millimeter create another page, thas its because the bottom of the order its big and need more espace
sc_pdf_add_page('P', 'Letter');
sc_pdf_image('ODC_titulo.png',0,0,216);
sc_pdf_print($cell_folio);
} //else do noting
break;
default: //si la pagina no es la primera //if not first page
if ($j >= 1152){ //check the last Y position
sc_pdf_image('ODC_titulo.png',0,0,216);
sc_pdf_add_page('P', 'Letter');
sc_pdf_print($cell_folio);
sc_pdf_print($cell_folio);
}
}
sc_pdf_image('ODC_inferior.png',0,0,216); //insert the image of the bottom png whit transparency
//print the fields results
sc_pdf_print($cell_mond);
sc_pdf_print($cell_one);
sc_pdf_print($cell_tow);
sc_pdf_print($cell_text);
sc_pdf_print($cell_retencion);
sc_pdf_print($cell_total);
sc_pdf_print($cell_solicito);
This cost me had works and lot of reader fpdf.org documentation and trial and error. its not perfect, but I think its guide in the correct way. IN total uses tree images one its only top, one its only bottom and one its both, for best need other with the info of the bottom but in the top and change the “Y” position of the results depending of value of page valiable.
There are the to sql details.
CREATE TABLE `cpr_odc` (
`id_odc` INT(5) UNSIGNED NOT NULL AUTO_INCREMENT,
`folio` INT(5) UNSIGNED ZEROFILL NULL DEFAULT NULL,
`id_provedor` INT(5) UNSIGNED NULL DEFAULT NULL,
`id_contacto` INT(5) UNSIGNED NULL DEFAULT NULL,
`fecha_pedido` DATE NOT NULL,
`id_ot` INT(5) NULL DEFAULT NULL,
`proyecto` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8_spanish2_ci',
`credito_dias` INT(4) UNSIGNED NOT NULL DEFAULT '0',
`fecha_entrega` DATE NULL DEFAULT NULL,
`entregar_en` INT(4) UNSIGNED NOT NULL DEFAULT '2',
`estaus_odc` INT(4) UNSIGNED NOT NULL DEFAULT '1',
`id_comprador` INT(5) UNSIGNED NULL DEFAULT '1',
`id_moneda` INT(2) UNSIGNED NOT NULL DEFAULT '1',
PRIMARY KEY (`id_odc`),
INDEX `FK_cpr_odc_cpr_estatus_odc` (`estaus_odc`),
INDEX `id_provedor` (`id_provedor`),
INDEX `entregar_en` (`entregar_en`),
INDEX `id_comprador` (`id_comprador`),
INDEX `id_moneda` (`id_moneda`),
INDEX `id_contacto` (`id_contacto`),
CONSTRAINT `FK_cpr_odc_cpr_estatus_odc` FOREIGN KEY (`estaus_odc`) REFERENCES `cpr_estatus_odc` (`id_estatus_odc`) ON UPDATE NO ACTION ON DELETE NO ACTION
)
COLLATE='utf8_spanish2_ci'
ENGINE=InnoDB;
CREATE TABLE `cpr_odc_detalle` (
`id_detalle_odc` INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
`id_odc` INT(5) UNSIGNED NOT NULL,
`catidad` DOUBLE UNSIGNED NOT NULL,
`unidad` INT(10) UNSIGNED NOT NULL,
`des_producto` TEXT NOT NULL COLLATE 'utf8_spanish2_ci',
`precio_uni` DOUBLE NOT NULL,
`entregados` DOUBLE NULL DEFAULT '0',
`fecha` DATETIME NULL DEFAULT NULL,
`iva` INT(3) UNSIGNED NULL DEFAULT '16',
`one_dim` DOUBLE(7,3) NULL DEFAULT '1.000',
`tow_dim` DOUBLE(7,3) NULL DEFAULT '1.000',
`mat1` INT(5) UNSIGNED NULL DEFAULT NULL,
`mat2` INT(5) UNSIGNED NULL DEFAULT NULL,
`mat3` INT(5) UNSIGNED NULL DEFAULT NULL,
`id_ot` INT(5) UNSIGNED NULL DEFAULT NULL,
PRIMARY KEY (`id_detalle_odc`),
INDEX `FK_cpr_odc_detalle_cpr_unidades` (`unidad`),
INDEX `FK_cpr_odc_detalle_cpr_odc` (`id_odc`),
INDEX `FK_cpr_odc_detalle_alm_mat_clave1` (`mat1`),
INDEX `FK_cpr_odc_detalle_alm_mat_clave2` (`mat2`),
INDEX `FK_cpr_odc_detalle_alm_mat_clave3` (`mat3`)
)
COLLATE='utf8_spanish2_ci'
ENGINE=InnoDB
In the pdf it this
SELECT
id_odc,
folio,
id_provedor,
id_contacto,
fecha_pedido,
id_ot,
proyecto,
credito_dias,
fecha_entrega,
entregar_en,
estaus_odc,
id_comprador,
id_moneda
FROM
cpr_odc
WHERE id_odc = [ODC]
AND
SELECT
catidad,
cpr_unidades.nombre_unidad
AS unidad,
des_producto,
precio_uni,
CASE campos WHEN 3 THEN (catidad * precio_uni)
WHEN 0 THEN (catidad * precio_uni)
WHEN 1 THEN (catidad * precio_uni * one_dim)
WHEN 2 THEN (catidad * precio_uni * one_dim/100 *tow_dim/100)
END AS precio2 FROM cpr_odc_detalle JOIN cpr_unidades
ON cpr_odc_detalle.unidad = cpr_unidades.id_unidad
WHERE id_odc = {id_odc}
THE results its calling from a view create for that but is complicated and only its because the inner need of the company