<?php

$artid=$trfData['idarticletype'];

// parse new component  query for shoes

if ($artid=='1') {



$identpartlist = new WA_MySQLi_RS("identpartlist", $cmctrfdb, 0);

$identpartlist->setQuery("

    SELECT *

    FROM identificationparts

    LEFT JOIN partsordercimac ON partsordercimac.arttypeid = identificationparts.arttypeid

                              AND partsordercimac.partsidpicture = identificationparts.partsidnumber

    WHERE identificationparts.idtrfdetails = '$idtrf' 

    ORDER BY 

      CASE

        WHEN partsordercimac.partsidcimac IS NULL THEN 9999

        ELSE partsordercimac.partsidcimac

      END

");

$identpartlist->execute();





} else {

//parse new component query for other articles

$identpartlist = new WA_MySQLi_RS("identpartlist",$cmctrfdb,0);

$identpartlist->setQuery("SELECT * FROM identificationparts WHERE identificationparts.idtrfdetails='$idtrf'");

$identpartlist->execute();

}

$pdf->AddPage('P');

$pdf->SetFont('','B','10');

$pdf->Cell(190,6,$testPartsPdf,1,0,'C');

$pdf->Ln();

$pdf->SetFont('','','8');

$wa_startindex = 0;

while(!$identpartlist->atEnd()) {

  $wa_startindex = $identpartlist->Index;

$pdf->Cell(45,6,$partPdf,1,0,'L');

$descpart=$identpartlist->getColumnVal("description_identificationparts");

$pdf->Cell(145,6,$descpart,1,0,'L',TRUE);

    $pdf->Ln();

$pdf->Cell(45,6,$descriptionPdf,1,0,'L');

$materialpt=$identpartlist->getColumnVal("material_identificationparts"); 

$materialpt=html_entity_decode($materialpt);

$materialpt = iconv('UTF-8', 'windows-1252', $materialpt);

$pdf->Cell(145,6,$materialpt,1,0,'L', TRUE);

    $pdf->Ln();

$pdf->Cell(45,6,$articlePdf,1,0,'L');

$articlept=$identpartlist->getColumnVal("article_identificationparts"); 

$articlept=html_entity_decode($articlept);

$articlept = iconv('UTF-8', 'windows-1252', $articlept);

$pdf->Cell(145,6,$articlept,1,0,'L', TRUE);

    $pdf->Ln();

$pdf->Cell(45,6,$colorPdf,1,0,'L');

$pdf->Cell(145,6,$identpartlist->getColumnVal("color_identificationparts"),1,0,'L', TRUE);

$pdf->Ln();

$pdf->Cell(45,6,$whotest,1,0,'L');





$kindtest=$identpartlist->getColumnVal("kindoftest");

if ($kindtest == 'new') { $whotestreply=$tobetestedwho; }

else if ($kindtest == 'cmc') { $whotestreply=$alreadytestedcmc; }

else { $whotestreply=$alreradytestedtlab; }



$pdf->Cell(145,6,$whotestreply,1,0,'L', TRUE);

$pdf->Ln();

if ($identpartlist->getColumnVal("kindoftest")!='new') {

$cmcrepnumb=$identpartlist->getColumnVal("cmcreportnumber_identificationparts");

$cmcrepnumb=html_entity_decode($cmcrepnumb);

$cmcrepnumb = iconv('UTF-8', 'windows-1252', $cmcrepnumb);

$pdf->Cell(45,6,$reportPdf,1,0,'L');

$pdf->Cell(145,6,$cmcrepnumb,1,0,'L', TRUE);

 $pdf->Ln(); 

$pdf->Cell(45,6,$datePdf,1,0,'L');

$pdf->Cell(145,6,$identpartlist->getColumnVal("cmcreportdate_identificationparts"),1,0,'L', TRUE);   

$pdf->Ln();   

$pdf->Cell(45,6,$headedPdf,1,0,'L');

$pdf->Cell(145,6,$identpartlist->getColumnVal("reportof"),1,0,'L',TRUE);

$pdf->Ln();

}

$pdf->SetFillColor(192,192,192);

$pdf->Cell(190,3,'',1,0,'L',TRUE);

$pdf->SetFillColor(232, 242, 255);

    	$pdf->Ln();

  $identpartlist->moveNext();

}

$identpartlist->moveFirst(); //return RS to first record

unset($wa_startindex);

unset($wa_repeatcount);

$pdf->Ln();

/*

// parse issue by cmc

$identpartlistcmc = new WA_MySQLi_RS("identpartlist",$cmctrfdb,0);

$identpartlistcmc->setQuery("SELECT * FROM identificationparts WHERE identificationparts.idtrfdetails='$idtrf' AND identificationparts.kindoftest='cmc'");

$identpartlistcmc->execute();

if (!empty($identpartlistcmc->getColumnVal("ididentificationparts"))) {

$pdf->SetFont('','B','10');

$pdf->Cell(190,6,'Parti testate da CIMAC',1,0,'C');

$pdf->Ln();

$pdf->SetFont('','','8');

$wa_startindex = 0;

while(!$identpartlistcmc->atEnd()) {

  $wa_startindex = $identpartlistcmc->Index;

$pdf->Cell(45,6,'Parte',1,0,'L');

$descpart=$identpartlistcmc->getColumnVal("description_identificationparts");

$pdf->Cell(145,6,$descpart,1,0,'L',TRUE);

    $pdf->Ln();

$pdf->Cell(45,6,'Descrizione',1,0,'L');

$pdf->Cell(145,6,$identpartlistcmc->getColumnVal("material_identificationparts"),1,0,'L', TRUE);    

$pdf->Ln();

$pdf->Cell(45,6,'Articolo',1,0,'L');

$articlept=$identpartlistcmc->getColumnVal("article_identificationparts"); 

$articlept=html_entity_decode($articlept);

$articlept = iconv('UTF-8', 'windows-1252', $articlept);

$pdf->Cell(145,6,$articlept,1,0,'L', TRUE);

$pdf->Ln();    

$pdf->Cell(45,6,'Colore',1,0,'L');

$pdf->Cell(145,6,$identpartlistcmc->getColumnVal("color_identificationparts"),1,0,'L', TRUE);

 $pdf->Ln();   

$pdf->Cell(45,6,'Rapporto',1,0,'L');

$cmcrepnumb=$identpartlistcmc->getColumnVal("cmcreportnumber_identificationparts");

$cmcrepnumb=html_entity_decode($cmcrepnumb);

$cmcrepnumb = iconv('UTF-8', 'windows-1252', $cmcrepnumb);

$pdf->Cell(145,6,$cmcrepnumb,1,0,'L', TRUE);

 $pdf->Ln(); 

$pdf->Cell(45,6,'Data',1,0,'L');

$pdf->Cell(145,6,$identpartlistcmc->getColumnVal("cmcreportdate_identificationparts"),1,0,'L', TRUE);   

$pdf->Ln();   

$pdf->Cell(45,6,'Intestato',1,0,'L');

$pdf->Cell(145,6,$identpartlistcmc->getColumnVal("reportof"),1,0,'L',TRUE);

$pdf->Ln();

$pdf->SetFillColor(192,192,192);

$pdf->Cell(190,3,'',1,0,'L',TRUE);

$pdf->SetFillColor(232, 242, 255);

    

    	$pdf->Ln();

  $identpartlistcmc->moveNext();

}

$identpartlistcmc->moveFirst(); //return RS to first record

unset($wa_startindex);

unset($wa_repeatcount);

}

$pdf->Ln(); */

/*

// parse issue by trd

$identpartlisttrd = new WA_MySQLi_RS("identpartlist",$cmctrfdb,0);

$identpartlisttrd->setQuery("SELECT * FROM identificationparts WHERE identificationparts.idtrfdetails='$idtrf' AND identificationparts.kindoftest='trd'");

$identpartlisttrd->execute();

if (!empty($identpartlisttrd->getColumnVal("ididentificationparts"))) {

$pdf->SetFont('','B','10');

$pdf->Cell(190,6,'Parti testate da altro laboratorio',1,0,'C');

$pdf->Ln();

$pdf->SetFont('','','8');

$wa_startindex = 0;

while(!$identpartlisttrd->atEnd()) {

  $wa_startindex = $identpartlisttrd->Index;

    

$pdf->Cell(45,6,'Parte',1,0,'L');

$descpart=$identpartlisttrd->getColumnVal("description_identificationparts");

$pdf->Cell(145,6,$descpart,1,0,'L',TRUE);

    $pdf->Ln();

$pdf->Cell(45,6,'Descrizione',1,0,'L');

$pdf->Cell(145,6,$identpartlisttrd->getColumnVal("material_identificationparts"),1,0,'L', TRUE);    

$pdf->Ln();

$pdf->Cell(45,6,'Articolo',1,0,'L');

$articlept=$identpartlisttrd->getColumnVal("article_identificationparts"); 

$articlept=html_entity_decode($articlept);

$articlept = iconv('UTF-8', 'windows-1252', $articlept);

$pdf->Cell(145,6,$articlept,1,0,'L', TRUE);

$pdf->Ln();    

$pdf->Cell(45,6,'Colore',1,0,'L');

$pdf->Cell(145,6,$identpartlisttrd->getColumnVal("color_identificationparts"),1,0,'L', TRUE);

 $pdf->Ln();   

$pdf->Cell(45,6,'Rapporto',1,0,'L');

$cmcrepn=$identpartlisttrd->getColumnVal("cmcreportnumber_identificationparts");

$cmcrepn=html_entity_decode($cmcrepn);

$cmcrepn = iconv('UTF-8', 'windows-1252', $cmcrepn);

$pdf->Cell(145,6,$cmcrepn,1,0,'L', TRUE);

 $pdf->Ln();  

$pdf->Cell(45,6,'Data',1,0,'L');

$pdf->Cell(145,6,$identpartlisttrd->getColumnVal("cmcreportdate_identificationparts"),1,0,'L', TRUE);   

$pdf->Ln();   

$pdf->Cell(45,6,'Intestato',1,0,'L');

$pdf->Cell(145,6,$identpartlisttrd->getColumnVal("reportof"),1,0,'L',TRUE);

$pdf->Ln();

$pdf->SetFillColor(192,192,192);

$pdf->Cell(190,3,'',1,0,'L',TRUE);

$pdf->SetFillColor(232, 242, 255);

$pdf->Ln();

$pdf->SetFont('','','8'); 

    

    	$pdf->Ln();

  $identpartlisttrd->moveNext();

}

$identpartlisttrd->moveFirst(); //return RS to first record

unset($wa_startindex);

unset($wa_repeatcount);

}

$pdf->Ln(); */

?>