<?php
require_once '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
require_once DOL_DOCUMENT_ROOT.'/tcpdf/tcpdf.php';
require_once '/class/categoriproductimport.class.php';

$def = array();
$parentcategorie = array();
$souscategorie = array();
$result = array();


$souscat = new Categoriproductimport($db);
//$category_tree = $souscat->getCategoriesTree(0);
//echo $category_tree; die;
//print_r('<pre>');
//print_r($category_tree);
//print_r('</pre>');
//die();


$pdf = new TCPDF('P', 'pt', 'A4', true, 'UTF-8', false);
    $pdf->setPrintHeader(false);
    $pdf->setPrintFooter(false);
    $pdf->SetFont('helvetica','',10);
    $pdf->AddPage();
    
    ob_start();
?>
        <style type="text/css">
            li {
                list-style: none;
                margin-left: 15px;
                padding-left: 5px;
            }
            table
            {
                font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
                border-collapse: collapse;
                width: 100%;
            }
            th
                {
                    border: 1px solid #ddd;
                    padding: 8px;
                    padding-top: 12px;
                    padding-bottom: 12px;
                    text-align: left;
                    background-color: #4CAF50;
                    color: white;
                    vertical-align: central;
                }
            tr:hover {background-color: #ddd;}
            tr:nth-child(even){background-color: #f2f2f2;}
            td
                {
                    border: 1px solid #ddd;
                    padding: 8px;
                    vertical-align: central;
                }
            h3 { text-align: center;}
        </style>
        <?php 
        $pdf->setJPEGQuality(75);
        $pdf->Image(DOL_URL_ROOT.'/img.jpg', 15, 10, 60, 40, 'JPG', '', '', true, 150, '', false, false, 1, false, false, false);
        $pdf->SetXY(15, 55);
        $pdf->writeHTML("Idéal", true, 0, true, 0);
        $pdf->SetXY(15, 65);
        $pdf->writeHTML("Avenue Kénédy", true, 0, true, 0);
        $pdf->SetXY(15, 75);
        $pdf->writeHTML("Téléphone: 69877556", true, 0, true, 0);
        $pdf->SetXY(15, 85);
        $pdf->writeHTML("Mail: ideal.com", true, 0, true, 0);
        $pdf->SetXY(310, 15);
        $date_formatter = new IntlDateFormatter('fr_FR',
                                             IntlDateFormatter::FULL,
                                             IntlDateFormatter::NONE);
        $pdf->SetXY(310, 30);
        $date_time = new DateTime(date("Y-m-d"));
        $pdf->writeHTML("Fait le: ".strftime($date_formatter->format($date_time),strtotime($date)), true, 0, true, 0);
        $pdf->SetXY(310, 45);
        
        echo $souscat->getCategoriesTree(0);
        
        $content = ob_get_clean();
        $pdf->writeHTML($content, true, 0, true, 0);
        $pdf->Output('rapportstock.pdf', 'D');

