Esempio n. 1
0
function print_all_reports()
{
    global $atskaite_veids;
    global $lang;
    global $translate;
    global $arrsum;
    global $C_REP;
    global $pavadzimes_tabula;
    global $output_pdf;
    global $output_xml;
    global $output_xml_dir;
    $arrfinal = array();
    $output = "";
    for ($grup = 1; $grup <= $_POST['grup']; $grup++) {
        //Valoda
        if (isset($_POST['valoda' . $grup])) {
            $lang = $_POST['valoda' . $grup];
        } else {
            $lang = 'LAT';
        }
        //        if($_POST['pavadzime']==''){$_POST['pavadzime_head'] = $mpav['pavadzime_head'];}
        if (trim($_POST['pavadzime']) != '') {
            $_POST['pavadzime_head'] = $_POST['pavadzime'];
        }
        set_param('akts_nr', $_POST['akts_nr_head']);
        set_param('pircejs_head', $_POST['pircejs_head']);
        set_param('pircejs_regnum', $_POST['pircejs_regnum']);
        set_param('pardevejs_head', $_POST['pardevejs_head']);
        set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
        set_param('pieg_lig_num', $_POST['pieg_lig_num']);
        set_param('datums', $_POST['datums_head']);
        set_param('iecirknis', $_POST['iecirknis_head']);
        set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
        set_param('pavadzime_head', $_POST['pavadzime_head']);
        set_param('transport_firm', $_POST['transport_firm']);
        set_param('auto', $_POST['auto_head']);
        set_param('soferis', $_POST['soferis_head']);
        set_param('vieta', $_POST['vieta_head']);
        set_param('piezimes', $_POST['piezimes_head']);
        set_param('atbildigais', $_POST['atbildigais_head']);
        set_param('parbaudija', $_POST['parbaudija_head']);
        set_param('veidoja', $_POST['veidoja_head']);
        set_param('custom11', $_POST['custom11_head']);
        set_param('custom12', $_POST['custom12_head']);
        set_param('sortiments', $_POST['sortiments_head']);
        set_param('standarts', $_POST['standarts_head']);
        set_param('metode', $_POST['metode_head']);
        set_param('raukums', $_POST['raukums_head']);
        set_param('merinstruments', $_POST['merinstruments_head']);
        set_param('terminsh', $_POST['terminsh_head']);
        $xml_vars['gvalues' . $grup . '1'] = $_POST['gvalues' . $grup . '1'];
        $xml_vars['gvalues' . $grup . '1_1'] = $_POST['gvalues' . $grup . '1_1'];
        $xml_vars['gvalues' . $grup . '1_2'] = $_POST['gvalues' . $grup . '1_2'];
        $xml_vars['gvalues' . $grup . '2'] = $_POST['gvalues' . $grup . '2'];
        $xml_vars['gvalues' . $grup . '2_1'] = $_POST['gvalues' . $grup . '2_1'];
        $xml_vars['gvalues' . $grup . '2_2'] = $_POST['gvalues' . $grup . '2_2'];
        $xml_vars['gvalues' . $grup . '3'] = $_POST['gvalues' . $grup . '3'];
        $xml_vars['gvalues' . $grup . '3_1'] = $_POST['gvalues' . $grup . '3_1'];
        $xml_vars['gvalues' . $grup . '3_2'] = $_POST['gvalues' . $grup . '3_2'];
        $xml_vars['gvalues' . $grup . '4'] = $_POST['gvalues' . $grup . '4'];
        $xml_vars['gvalues' . $grup . '4_1'] = $_POST['gvalues' . $grup . '4_1'];
        $xml_vars['gvalues' . $grup . '4_2'] = $_POST['gvalues' . $grup . '4_2'];
        $xml_vars['virsmeri' . $grup] = $_POST['virsmeri' . $grup];
        $xml_vars['virsmeri' . $grup . '_1'] = $_POST['virsmeri' . $grup . '_1'];
        $xml_vars['virsmeri' . $grup . '_2'] = $_POST['virsmeri' . $grup . '_2'];
        $xml_vars['virsmeri_brakim' . $grup] = $_POST['virsmeri_brakim' . $grup];
        $xml_vars['virsmeri_brakim' . $grup . '_1'] = $_POST['virsmeri_brakim' . $grup . '_1'];
        $xml_vars['virsmeri_brakim' . $grup . '_2'] = $_POST['virsmeri_brakim' . $grup . '_2'];
        $xml_vars['koeficients' . $grup] = $_POST['koeficients' . $grup];
        $xml_vars['koeficients' . $grup . '_1'] = $_POST['koeficients' . $grup . '_1'];
        $xml_vars['koeficients' . $grup . '_2'] = $_POST['koeficients' . $grup . '_2'];
        $xml_vars['raukums' . $grup] = $_POST['raukums' . $grup];
        $xml_vars['raukums' . $grup . '_1'] = $_POST['raukums' . $grup . '_1'];
        $xml_vars['raukums' . $grup . '_2'] = $_POST['raukums' . $grup . '_2'];
        $xml_vars['pavadzime'] = $_POST['pavadzime'];
        /////////////////////////////////////////////////////////////////////////
        if ($grup == 1) {
            //        $output = $output . "	<html>";
            //        $output = $output . "	<head>";
            if ($output_pdf) {
                require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/g-atskaite.php';
                $g_atskaite = new g_atskaite();
                $g_atskaite->open_pdf();
                $g_atskaite->report_header_pdf($_POST, $lang, $translate);
            } else {
                $output = $output . "\t\t\t\t\t\t <title>Atskaite " . $lang . "</title>";
                $output = $output . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
                $output = $output . "\t\t\t\t\t\t</head>";
                $output = $output . "\t\t\t\t\t\t<center>";
                $output = $output . "\t<STYLE TYPE=\"text/css\">";
                $output = $output . "\t  TD { font-size: 12px; }";
                $output = $output . "\t</STYLE>";
                $output = $output . "\t<table border=0 width=90%><td align=center valign='top'>";
                $output = $output . "\t<table border=0 width=100%><tr>";
                $output = $output . "\t<td width=540><img src=\"images/vmf.gif\"></td>";
                $output = $output . " <td align=center>VMF&nbsp;MI&nbsp;P&nbsp;02.01.02.\n<br />2.variants (12.11.2010.)</td>";
                $output = $output . "\t</tr></table></td>";
                $output = $output . "\t<tr><td align=center valign='top'>";
                $output = $output . "\t<table>";
                $output = $output . "\t<tr>";
                $output = $output . "\t <td align=center width=50></td>";
                $output = $output . "\t <td align=center valign=center><font size=5>" . $translate['virsraksts'][$lang] . get_param('akts_nr') . "</font></td>";
                $output = $output . "\t</tr>";
                $output = $output . "\t</table>";
                $output = $output . "\t<br>";
                $output = $output . "\t<table cellspacing=0 cellpadding=0>";
                if ($_POST['contract_num']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['liguma_nr'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['contract_num'] . "</font></td>";
                }
                if ($_POST['pircejs_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['pircejs'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['pircejs_head'] . "</font></td>";
                }
                if ($_POST['pardevejs_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['pardevejs'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['pardevejs_head'] . "</font></td>";
                }
                if ($_POST['datums_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['datums'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['datums_head'] . "</font></td>";
                }
                if ($_POST['pavadzime_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['pavadzime'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['pavadzime_head'] . "</font></td>";
                }
                if ($_POST['iecirknis_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['iecirknis'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['iecirknis_head'] . "</font></td>";
                }
                if ($_POST['auto_head'] && $atskaite_veids != "nelss") {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['auto_nr'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['auto_head'] . "</font></td>";
                }
                if (strlen($_POST['soferis_head']) > 1) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['soferis'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['soferis_head'] . "</font></td>";
                }
                if ($_POST['vieta_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['uzm_vieta'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['vieta_head'] . "</font></td>";
                }
                if ($_POST['custom12_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $_POST['custom11_head'] . "&nbsp;</font></td><td><font size=3>" . $_POST['custom12_head'] . "</font></td>";
                }
                if ($_POST['sortiments_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['sortiments'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['sortiments_head'] . "</font></td>";
                }
                if ($_POST['standarts_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['standarts'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['standarts_head'] . "</font></td>";
                }
                if ($_POST['metode_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['metode'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['metode_head'] . "</font></td>";
                }
                if ($_POST['raukums_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['raukums'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['raukums_head'] . "</font></td>";
                }
                if ($_POST['merinstruments_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['merinst'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['merinstruments_head'] . "</font></td>";
                }
                if ($_POST['terminsh_head']) {
                    $output = $output . "<tr><td align=right><font size=3>" . $translate['v_term'][$lang] . ":&nbsp;</font></td><td><font size=3>" . $_POST['terminsh_head'] . "</font></td>";
                }
                $output = $output . "</table>";
                $output = $output . "<br><br><br>";
                $output = $output . "<table><tr><td>";
                $output = $output . "<table border=0 cellspacing=0 cellpadding=0>";
            }
        }
        $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
        $C_REP = new C_REPORT($_POST, $DB_CON, $output_xml, $grup);
        if ($C_REP->ERRORS) {
            //            $output = $output . "<html>";
            //            $output = $output . "<head>";
            $output = $output . "<title>Kļūda!</title>";
            $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $output = $output . "</head>";
            $output = $output . "<center>";
            $output = $output . "<STYLE TYPE=\"text/css\">";
            $output = $output . "  TD { font-size: 12px; }";
            $output = $output . "</STYLE>";
            $output = $output . "</style>";
            $output = $output . "<body>";
            $output = $output . "<p class='pagestart'></p><center><br><br>";
            $output = $output . "<b><font color=red>Kļūda!</font></b>";
            $output = $output . "<br><br>";
            $output = $output . $C_REP->ERRORS;
            $output = $output . "</center>";
            /*            $output = $output . "<br><br>";
                        $output = $output . "<input type=button value=\"Atkārtot\" onclick=\"history.back(-1)\">";
            			$output = $output . "<br><br>";*/
            //            $output = $output . "</body>";
            //            $output = $output . "</html>";
            echo $output;
            return $output;
        }
        if ($grup == 1) {
            //šī ir pirmā grupēšanas nosacījumu kopa, kopējam summas no $arr
            $arrsum = $C_REP->arr[count($C_REP->arr) - 1];
            if ($_POST['grup'] != 1) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
            }
            $arrfinal = $C_REP->arr;
        } else {
            //šī nav pirmā grupēšanas nosacījumu kopa, tāpēc pieskaitam doto apakšsummu kopīgajai summai
            $arrsum[summa]->skaits = $arrsum[summa]->skaits + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits;
            $arrsum[summa]->skaits_bad = $arrsum[summa]->skaits_bad + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits_bad;
            $arrsum[summa]->bruto = $arrsum[summa]->bruto + $C_REP->arr[count($C_REP->arr) - 1][summa]->bruto;
            $arrsum[summa]->virsmers = $arrsum[summa]->virsmers + $C_REP->arr[count($C_REP->arr) - 1][summa]->virsmers;
            $arrsum[summa]->redukcija_d = $arrsum[summa]->redukcija_d + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_d;
            $arrsum[summa]->redukcija_l = $arrsum[summa]->redukcija_l + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_l;
            $arrsum[summa]->brakis = $arrsum[summa]->brakis + $C_REP->arr[count($C_REP->arr) - 1][summa]->brakis;
            $arrsum[summa]->neto = $arrsum[summa]->neto + $C_REP->arr[count($C_REP->arr) - 1][summa]->neto;
            if ($grup != $_POST['grup']) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
                //ja nav pēdējā nosacījumu kopa, iztīram kopsummas rindu
            } else {
                $C_REP->arr[count($C_REP->arr) - 1] = $arrsum;
                //ja ir pēdējā nosacījumu kopa, atgriežam kopsummu
            }
            $arrfinal = array_merge($arrfinal, $C_REP->arr);
        }
    }
    if ($_POST['reg_atsk'] == 'on') {
        $skaits = $arrsum[summa]->skaits;
        $skaits_brakis = $arrsum[summa]->skaits_bad;
        $bruto = $arrsum[summa]->bruto;
        $virsmers = $arrsum[summa]->virsmers;
        $redukcija_d = $arrsum[summa]->redukcija_d;
        $redukcija_l = $arrsum[summa]->redukcija_l;
        $redukcija_kopa = $redukcija_l + $redukcija_d;
        $brakis = $arrsum[summa]->brakis;
        $neto = $arrsum[summa]->neto;
        $pavadzime = $_POST['pavadzime'];
        if (trim($_POST['pavadzime']) == '') {
            $pavadzime = $_POST['pavadzime_head'];
        }
        $akta_nr = $_POST['akts_nr_head'];
        $pircejs = $_POST['pircejs_head'];
        $dataKey = explode("/", $_POST['akts_nr_head']);
        $atskaites_veids = get_AtskaitesVeids($dataKey[1]);
        //        set_param('pircejs_regnum',$_POST['pircejs_regnum']);
        $pardevejs = $_POST['pardevejs_head'];
        //        set_param('pardevejs_regnum',$_POST['pardevejs_regnum']);
        $liguma_nr = $h;
        $datums = $_POST['datums_head'];
        $datums = substr($datums, -5, 4) . "-" . substr($datums, -8, 2) . "-" . substr($datums, 0, 2);
        $iecirknis = $_POST['iecirknis_head'];
        $cirsmas_kods = $_POST['cirsmas_kods_head'];
        //        set_param('pavadzime_head',$_POST['pavadzime_head']);
        //        set_param('transport_firm',$_POST['transport_firm']);
        $auto = $_POST['auto_head'];
        $soferis = $_POST['soferis_head'];
        $vieta = AI_returnPlace($_POST['vieta_head']);
        //        set_param('piezimes',$_POST['piezimes_head']);
        //        set_param('atbildigais',$_POST['atbildigais_head']);
        //        set_param('parbaudija',$_POST['parbaudija_head']);
        $veidoja = $_POST['veidoja_head'];
        $piegade = $_POST['kods'];
        //        $atskaites_veids = $_GET["veids"];
        //        set_param('custom11',$_POST['custom11_head']);
        //        set_param('custom12',$_POST['custom12_head']);
        $sortiments = $_POST['sortiments_head'];
        //        set_param('standarts',$_POST['standarts_head']);
        $metode = $_POST['metode_head'];
        //        set_param('raukums',$_POST['raukums_head']);
        //        set_param('merinstruments',$_POST['merinstruments_head']);
        //        set_param('terminsh',$_POST['terminsh_head']);
        $regSQL = "INSERT INTO g_registrs (pircejs,pardevejs,atskaites_veids,piegadatajs,akta_nr,pavadzime,datums_piegade,vieta,soferis,auto_nr,sortiments,skaits_kopa,bruto,neto,virsmers,redukcija,skaits_brakis,brakis,lietotajs_veidoja,atskaites_nr,opcija) VALUES ('{$pircejs}','{$pardevejs}','{$atskaites_veids}','{$piegade}','{$akta_nr}','{$pavadzime}','{$datums}','{$vieta}','{$soferis}','{$auto}','{$sortiments}',{$skaits},{$bruto},{$neto},{$virsmers},{$redukcija_kopa},{$skaits_brakis},{$brakis},'{$veidoja}','{$liguma_nr}','A')";
        mysql_query($regSQL);
    }
    if (!$_POST['negrupet']) {
        usort($arrfinal, 'CompareArrays');
    }
    $arrfinal[-1] = $C_REP->arr[-1];
    $C_REP->arr = $arrfinal;
    if (!$output_pdf) {
        if ($output_xml) {
            $xml_arr = $C_REP->GetXML($pavadzimes_tabula);
            $xml = $xml_arr['file_content'];
        } else {
            $output = $output . $C_REP->GetHTML();
        }
    } else {
        $C_REP->GetHTML($g_atskaite);
    }
    if (!empty($_POST['pavadzime'])) {
        $pavXMLNum = trim($_POST['pavadzime']);
    } else {
        $pavXMLNum = trim($_POST['pavadzime_head']);
    }
    if ($output_xml) {
        $xml = iconv("UTF-8", "cp1257", $xml);
        if (!file_exists("../batch/xml/" . $output_xml_dir) || !is_dir("../batch/xml/" . $output_xml_dir)) {
            mkdir("../batch/xml/" . $output_xml_dir, 0777);
            chmod("../batch/xml/" . $output_xml_dir, 0777);
        }
        if (file_exists("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml")) {
            $output = $output . '</table><BR><BR></td></tr>';
            file_put_contents("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . "_1.xml", $xml);
            $output .= "<font color=red>Šāda pavadzīme jau ir veidota! ../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml </font><BR>";
            $output = $output . "</table></table>";
        } else {
            $output = $output . '</table><BR><BR></td></tr>';
            $arr_Compare = AI_getcompare($pavXMLNum, 'test');
            if ($arr_Compare['skaits_kopa'] != $xml_arr['skaits']) {
                $starpibaSkaitsBalki = $arr_Compare['skaits_kopa'] - $xml_arr['skaits'];
                $output .= "<font color=red>Failā esošo baļķu skaits nesakrīt ar reģistrā esošo baļķu skaitu par " . $starpibaSkaitsBalki . "!</font><BR>";
            }
            if ($arr_Compare['akta_nr'] != $xml_arr['akta_nr']) {
                $starpibaAktaNr = $xml_arr['akta_nr'];
                $output .= "<font color=red>Failā esošais akta numurs(" . $starpibaAktaNr . ") nesakrīt ar reģistrā esošo akta numuru!</font><BR>";
            }
            if ($arr_Compare['bruto'] != $xml_arr['bruto_kopa']) {
                $starpibaBrutoBalki = $arr_Compare['bruto'] - $xml_arr['bruto_kopa'];
                $output .= "<font color=red>Failā esošo baļķu bruto nesakrīt ar reģistrā esošo baļķu bruto par " . $starpibaBrutoBalki . "!</font><BR>";
            }
            file_put_contents("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml", $xml);
            $output .= "Izveidots fails <br />../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml<BR>";
            $output .= "Akta numurs failā " . $xml_arr['akta_nr'] . ".<BR>";
            $output .= "Baļķu skaits failā " . $xml_arr['skaits'] . ".<BR>";
            $output .= "Bruto tilpums failā " . $xml_arr['bruto_kopa'] . " m3.<BR>";
            $output = $output . "</table></table>";
        }
        echo $output;
    } elseif ($output_pdf) {
        $show_reject_codes = !($atskaite_veids == 'vika' || $atskaite_veids == 'gaujaskoks' || $atskaite_veids == 'smiltene' || $atskaite_veids == 'bsw' || $atskaite_veids == 'vudlande' || $atskaite_veids == 'pata_ab');
        $g_atskaite->report_footer_pdf($_POST, $lang, $translate, $show_reject_codes);
        $location = $g_atskaite->pdf_save($atskaite_veids, $_POST['pavadzime']);
        echo "<a href='{$location}'>Atskaite PDF formātā</a><br /><br />";
    } else {
        $output = $output . '</table><BR><BR></td></tr>';
        if ($_POST['piezimes_head']) {
            $output = $output . '<tr><td align=left>' . $translate['piezimes'][$lang] . ': ' . $_POST['piezimes_head'] . '</td></tr>';
        }
        /*Atskaite tiek pievienota papildus informācija par brāki, izņemot VIKAWOOD atskaiti*/
        if ($atskaite_veids == 'vika' || $atskaite_veids == 'gaujaskoks' || $atskaite_veids == 'smiltene' || $atskaite_veids == 'bsw' || $atskaite_veids == '4plus' || $atskaite_veids == 'vudlande' || $atskaite_veids == 'pata_ab' || $atskaite_veids == 'nelss' || $atskaite_veids == 'piebalgas' || $atskaite_veids == 'latvijas_finieris' || $atskaite_veids == 'stora_enso' || $atskaite_veids == 'osukalni' || $atskaite_veids == 'incukalns') {
            $output = $output . "<tr><td height=20></td></tr>";
        } else {
            $output = $output . "<tr><td height=1><br><font size=1><b>Brāķa kodu atšifrējums:</b><br/>0 - Par tievu <br/>1 - Par garu <br/>2 - Max resnākā vieta par lielu <br/>3 - Max tievgalis par lielu <br/>4 - Gadskārtas, Meža trupe, saspiesta koksne, gala plaisas <br/>5 - Sausānis, kaltuši, sānu plaisas <br/>6 - Zari <br>7 - Līkumainība <br/>8 - Cits <br/>9 - Par īsu <br/><br/></td></tr>";
        }
        /************************************************************************************/
        if ($_POST['parbaudija_head'] == 0) {
            if ($_POST['parbaudija_un_atbildigais_head'] == 6) {
                $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
                $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
                $output = $output . "</table></table>";
                //	$output = $output . "</body>";
                //	$output = $output . "</html>";
                echo $output;
            } else {
                $output = $output . "<tr><td align=left>Pārbaudīja/ atbildīgā persona ..................................................." . get_person($_POST['parbaudija_un_atbildigais_head']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
                $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
                $output = $output . "</table></table>";
                //      $output = $output . "</body>";
                //	$output = $output . "</html>";
                echo $output;
            }
        } else {
            $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   <br><br><br>Pārbaudīja .............................................................." . get_person($_POST['parbaudija_head']) . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t   <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
            $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
            $output = $output . "</table></table>";
            //          $output = $output . "</body>";
            //          $output = $output . "</html>";
            echo $output;
        }
    }
}
Esempio n. 2
0
function print_all_reports($atskaites_kods, $tmp_returnResult)
{
    global $lang;
    global $translate;
    global $arrsum;
    global $C_REP;
    global $pavadzimes_tabula;
    global $output_pdf;
    global $subMakeAll;
    global $output_xml;
    global $prefix_subname;
    global $output_xml_dir;
    $arrfinal = array();
    $output = "";
    $tmp_translation['pavadzime'] = "<b>Pavadzīme</b>";
    $tmp_translation['fsc'] = "Sertifikācija";
    $tmp_translation['transp_darba_uzd'] = "Transp. darba uzd.";
    $tmp_translation['pircejs_regnum'] = "Pircējs Reg. Num.";
    $tmp_translation['pardevejs_regnum'] = "Pārdevējs Reg. Num.";
    $tmp_translation['transport_firm'] = "Transp. firma";
    $tmp_translation['kad_piegad'] = "<b>Pavadzīmes datums</b>";
    $tmp_translation['kad_uzmer'] = "Uzm. datums";
    $tmp_translation['auto_head'] = "Automašīnas nr.";
    $tmp_translation['soferis_head'] = "Šoferis";
    $tmp_translation['iecirknis_head'] = "Iecirknis";
    $tmp_translation['pircejs_head'] = "Pircējs";
    $tmp_translation['pardevejs_head'] = "Pārdevējs";
    $tmp_translation['standarts_head'] = "Standarts";
    $tmp_translation['metode_head'] = "Metode";
    $tmp_translation['cirsma_head'] = "Cirsma";
    $tmp_translation['iecirknis_head'] = "Iecirknis";
    $tmp_translation['vieta_head'] = "Uzmērīšanas vieta";
    $tmp_translation['custom12_head'] = $_POST['custom11_head'];
    $tmp_translation['piezimes_head'] = "Piezīmes";
    $tmp_translation['sortiments_head'] = "Sortiments";
    $tmp_translation['raukums_head'] = "Raukums";
    $tmp_translation['merinstruments_head'] = "Mērinstruments";
    $tmp_translation['terminsh_head'] = "Pārbaudes termiņš";
    $lang = 'LAT';
    if (trim($_POST['pavadzime']) != '') {
        $_POST['pavadzime_head'] = $_POST['pavadzime'];
    }
    set_param('akts_nr', $_POST['akts_nr_head']);
    set_param('fsc', $_POST['fsc']);
    set_param('pircejs_head', $_POST['pircejs_head']);
    set_param('pircejs_regnum', $_POST['pircejs_regnum']);
    set_param('pardevejs_head', $_POST['pardevejs_head']);
    set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
    set_param('pieg_lig_num', $_POST['pieg_lig_num']);
    set_param('datums', $_POST['datums_head']);
    set_param('iecirknis', $_POST['iecirknis_head']);
    set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
    set_param('pavadzime_head', $_POST['pavadzime_head']);
    set_param('transport_firm', $_POST['transport_firm']);
    set_param('auto', $_POST['auto_head']);
    set_param('soferis', $_POST['soferis_head']);
    set_param('vieta', $_POST['vieta_head']);
    set_param('piezimes', $_POST['piezimes_head']);
    set_param('atbildigais', $_POST['atbildigais_head']);
    set_param('parbaudija', $_POST['parbaudija_head']);
    set_param('veidoja', $_POST['veidoja_head']);
    set_param('custom11', $_POST['custom11_head']);
    set_param('custom12', $_POST['custom12_head']);
    set_param('sortiments', $_POST['sortiments_head']);
    set_param('standarts', $_POST['standarts_head']);
    set_param('metode', $_POST['metode_head']);
    set_param('raukums', $_POST['raukums_head']);
    set_param('merinstruments', $_POST['merinstruments_head']);
    set_param('terminsh', $_POST['terminsh_head']);
    if ($output_pdf) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/g-atskaite.php';
        $g_atskaite = new g_atskaite();
        $g_atskaite->open_pdf();
        $g_atskaite->report_header_pdf($_POST, $lang, $translate);
    } else {
        $newOutput = $newOutput . "\t\t\t\t\t\t <title>Atskaite " . $lang . "</title>";
        $newOutput = $newOutput . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
        $newOutput = $newOutput . "\t\t\t\t\t\t</head>";
        $newOutput = $newOutput . "\t\t\t\t\t\t<center>";
        $newOutput = $newOutput . "\t<STYLE TYPE=\"text/css\">";
        $newOutput = $newOutput . "\t  TD { font-size: 12px; }";
        $newOutput = $newOutput . "\t</STYLE>";
        $newOutput = $newOutput . "\t<table border=0 width=90%><td align=center valign='top'>";
        $newOutput = $newOutput . "\t<table border=0 width=100%><tr>";
        if (($atskaites_kods == 16 || $subMakeAll) && !$output_pdf) {
            $newOutput = $newOutput . "\t<td width=540><img src=\"images/vmf.gif\"></td><td align=center>VMF&nbsp;MI&nbsp;P&nbsp;02.01.02.\n<br />3. variants (22.02.2011.)</td></tr></table><table><tr><td align=center width=50></td>";
        } else {
            $newOutput = $newOutput . "\t<td width=540><img src=\"images/vmf.gif\"></td><td align=center>VMF&nbsp;MI&nbsp;P&nbsp;02.01.04.\n<br />1. variants (12.11.2010.)</td></tr></table><table><tr><td align=center width=50></td>";
        }
        $newOutput = $newOutput . "\t <td align=center valign=center><font size=5>Testēšanas pārskats nr." . get_param('akts_nr') . "</font></td>";
        $newOutput = $newOutput . "\t</tr></table><br><table cellspacing=0 cellpadding=0 style=\"width:850;\">";
        foreach ($_POST['head'] as $key => $tmp_item_head) {
            $newOutput = $newOutput . "<tr><td align=right><font size=3>" . $tmp_translation[$key] . ":&nbsp;</font></td><td><font size=3>" . $tmp_item_head . "</font></td>";
        }
        $newOutput = $newOutput . "</table><br>";
    }
    //Insert Global new
    $genGlobal_registrs_id = 0;
    if (!$output_xml && !$output_pdf) {
        if ($_POST['reg_atsk'] == 'on') {
            $pavadzime_tmpIns = $_POST['pavadzime'];
            $mysqlGlobal_registrs_insert_txt = "INSERT INTO `g_registrs` (`datums_registrets`,`pavadzime`,`opcija`) values ('" . date("Y-m-d H:i:s") . "','{$pavadzime_tmpIns}','U')";
            $mysqlGlobal_registrs_insert = mysql_query($mysqlGlobal_registrs_insert_txt);
            $genGlobal_registrs_id = mysql_insert_id();
        }
    }
    $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
    $C_REP = new C_REPORT($_POST, $DB_CON, $output_xml, $prefix_subname, $atskaites_kods, $output_pdf, $subMakeAll, $genGlobal_registrs_id, $pavadzime_tmpIns);
    $newOutput .= "<table style=\"border-width:1px;border-style:solid;width:750;\">";
    foreach ($C_REP->arrPrintOut as $tmp_item_1) {
        if ($tmp_item_1['nosaukums'] == 1) {
            $newOutput .= "<tr bgcolor=\"#e1e1e1\" style=\"font-weight:bold;\">";
        } else {
            $newOutput .= "<tr>";
        }
        foreach ($tmp_item_1 as $key => $tmp_item_2) {
            if (($atskaites_kods == 16 || $atskaites_kods == 666 || $subMakeAll || trim($_POST['pavadzime_head']) == '') && !$output_pdf) {
                if ($key != "nosaukums" && $key != "brakis_un_neto" && $key != "redukcija_un_virsmers") {
                    //            if($key != "nosaukums"){
                    $newOutput .= "<td align=center ><font size=3>";
                    $newOutput .= $tmp_item_2;
                    $newOutput .= "</font></td>";
                }
            } else {
                if ($key != "nosaukums" && $key != "garums" && $key != "virsmers" && $key != "redukcija" && $key != "redukcija_un_virsmers") {
                    //            if($key != "nosaukums"){
                    $newOutput .= "<td align=center ><font size=3>";
                    $newOutput .= $tmp_item_2;
                    $newOutput .= "</font></td>";
                }
            }
        }
        $newOutput .= "</tr>";
    }
    $newOutput .= "</table><br /><br /><br /><br />";
    if ($_POST['piezimes_head']) {
        $newOutput = $newOutput . '<tr><td align=left>' . $tmp_translation['piezimes_head'] . ': ' . $_POST['piezimes_head'] . '<br /><br /><br /><br /><br /></td></tr>';
    }
    if ($_POST['parbaudija_head'] == 0) {
        if ($_POST['parbaudija_un_atbildigais_head'] == 6) {
            $newOutput = $newOutput . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n                                            <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
            $newOutput = $newOutput . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
            $newOutput = $newOutput . "</table>";
        } else {
            $newOutput = $newOutput . "<tr><td align=left>Pārbaudīja/ atbildīgā persona ..................................................." . get_person($_POST['parbaudija_un_atbildigais_head']) . "\n                                            <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
            $newOutput = $newOutput . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
            $newOutput = $newOutput . "</table>";
        }
    } else {
        $newOutput = $newOutput . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "\n                                           <br><br><br>Pārbaudīja .............................................................." . get_person($_POST['parbaudija_head']) . "\n                                           <br><br><br>Sagatavoja " . get_person($_POST['veidoja_head']) . "</td></tr>";
        $newOutput = $newOutput . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Skaistkalnes iela 1, Rīga, LV-1004 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
        $newOutput = $newOutput . "</table>";
    }
    if (!$output_xml && !$output_pdf) {
        if ($_POST['reg_atsk'] == 'on') {
            $skaits = $C_REP->regSuperSum[skaits];
            $skaits_brakis = $C_REP->regSuperSum[skaits_brakis];
            $bruto = $C_REP->regSuperSum[bruto];
            $virsmers = $C_REP->regSuperSum[virsmers];
            $redukcija_kopa = $C_REP->regSuperSum[redukcija];
            $brakis = $C_REP->regSuperSum[brakis];
            $neto = $C_REP->regSuperSum[neto];
            $pavadzime = $_POST['pavadzime'];
            if (trim($_POST['pavadzime']) == '') {
                $pavadzime = $_POST['pavadzime_head'];
            }
            $akta_nr = $_POST['akts_nr_head'];
            $pircejs = $_POST['head']['pircejs_head'];
            $dataKey = explode("/", $_POST['akts_nr_head']);
            $atskaites_veids = get_AtskaitesVeids($dataKey[1]);
            $pardevejs = $_POST['head']['pardevejs_head'];
            $liguma_nr = $h;
            $datums = $_POST['head']['kad_uzmer'];
            $datums_piegade = $_POST['head']['kad_piegad'];
            $temp_datums = $datums;
            $temp_datums_arr = explode('.', $temp_datums);
            $datums = $temp_datums_arr[2] . '-' . $temp_datums_arr[1] . '-' . $temp_datums_arr[0];
            $temp_datums_piegad_arr = explode('.', $datums_piegade);
            $datums_piegade = $temp_datums_piegad_arr[2] . '-' . $temp_datums_piegad_arr[1] . '-' . $temp_datums_piegad_arr[0];
            if ($_POST['datums_head']) {
                $datums = $_POST['datums_head'];
                $datums = substr($datums, -5, 4) . "-" . substr($datums, -8, 2) . "-" . substr($datums, 0, 2);
            }
            $iecirknis = $_POST['iecirknis_head'];
            $piegade = $_POST['kods'];
            $cirsmas_kods = $_POST['cirsmas_kods_head'];
            $auto = $_POST['head']['auto_head'];
            $soferis = $_POST['head']['soferis_head'];
            $vieta = AI_returnPlace($_POST['vieta_head']);
            $veidoja = $_POST['veidoja_head'];
            $sortiments = $_POST['head']['sortiments_head'];
            $metode = $_POST['head']['metode_head'];
            $regSQL_update = "UPDATE `g_registrs` SET `pircejs` = '{$pircejs}', `pardevejs` = '{$pardevejs}', `atskaites_veids` = '{$atskaites_veids}', `piegadatajs` = '{$piegade}', `akta_nr` = '{$akta_nr}', `datums_piegade` = '{$datums_piegade}', `iecirknis` = '{$iecirknis}', `datums_uzmer` = '{$datums}', `vieta` = '{$vieta}', `soferis` = '{$soferis}', `auto_nr` = '{$auto}', `sortiments` = '{$sortiments}', `skaits_kopa` = '{$skaits}', `bruto` = '{$bruto}', `neto` = '{$neto}', `virsmers` = '{$virsmers}', `redukcija` = '{$redukcija_kopa}', `skaits_brakis` = '{$skaits_brakis}', `brakis` = '{$brakis}', `lietotajs_veidoja` = '{$veidoja}', `atskaites_nr` = '{$liguma_nr}', `opcija` = 'A' WHERE `id` = {$genGlobal_registrs_id}";
            //        $regSQL = "INSERT INTO g_registrs (pircejs,pardevejs,atskaites_veids,piegadatajs,akta_nr,pavadzime,datums_piegade,vieta,soferis,auto_nr,sortiments,skaits_kopa,bruto,neto,virsmers,redukcija,skaits_brakis,brakis,lietotajs_veidoja,atskaites_nr,opcija) VALUES ('$pircejs','$pardevejs','$atskaites_veids','$piegade','$akta_nr','$pavadzime','$datums','$vieta','$soferis','$auto','$sortiments',$skaits,$bruto,$neto,$virsmers,$redukcija_kopa,$skaits_brakis,$brakis,'$veidoja','$liguma_nr','A')";
            //        echo $regSQL;
            mysql_query($regSQL_update);
        }
    }
    if (!$_POST['negrupet']) {
        usort($arrfinal, 'CompareArrays');
    }
    $arrfinal[-1] = $C_REP->arr[-1];
    $C_REP->arr = $arrfinal;
    if (!$output_pdf) {
        if ($output_xml) {
            $atskaite_veids = $_GET['veids'];
            $xml_arr = $C_REP->GetXML_new($atskaites_kods);
            $xml = $xml_arr['file_content'];
        } else {
            //		$output = $output . $C_REP->GetHTML();
        }
    } else {
        //		$C_REP->GetHTML($g_atskaite);
    }
    if (!empty($_POST['pavadzime'])) {
        $pavXMLNum = trim($_POST['pavadzime']);
    } else {
        $pavXMLNum = trim($_POST['pavadzime_head']);
    }
    if ($output_xml) {
        $xml = iconv("UTF-8", "cp1257", $xml);
        //		if(!file_exists("../batch/xml/".$output_xml_dir) || !is_dir("../batch/xml/".$output_xml_dir)){
        //			mkdir("../batch/xml/".$output_xml_dir, 0777);
        //			chmod("../batch/xml/".$output_xml_dir, 0777);
        //		}
        //		$returnResult = "../batch/xml/".$output_xml_dir;
        $new_xml_data_file = $tmp_returnResult . "/" . $pavXMLNum . ".xml";
        if (file_exists($new_xml_data_file)) {
            $output = $output . '</table><BR><BR></td></tr>';
            file_put_contents("../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . "_1.xml", $xml);
            $output .= "<font color=red>Šāda pavadzīme jau ir veidota! ../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml </font><BR>";
            $output = $output . "</table></table>";
        } else {
            //      $output = $output . '</table><BR><BR></td></tr>';
            $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $arr_Compare = AI_getcompare($pavXMLNum, 'test');
            file_put_contents($new_xml_data_file, $xml);
            $output .= "<table width='580' style='border-width:1px;border-style:solid;' width=100%>";
            $output .= "<thead><td align=center bgcolor=#7EB000><b>*.<i>XML</i> datu faila pārbaude</b><br></td></tr></thead>";
            $output .= "<tbody>";
            if ($arr_Compare['skaits_kopa'] != $xml_arr['skaits']) {
                $starpibaSkaitsBalki = $arr_Compare['skaits_kopa'] - $xml_arr['skaits'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu skaits nesakrīt ar reģistrā esošo baļķu skaitu par " . $starpibaSkaitsBalki . "!</font></td></tr>";
            }
            if ($arr_Compare['akta_nr'] != $xml_arr['akta_nr']) {
                $starpibaAktaNr = $xml_arr['akta_nr'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošais akta numurs(" . $starpibaAktaNr . ") nesakrīt ar reģistrā esošo akta numuru!</font></td></tr>";
            }
            if (round($arr_Compare['neto'], 3) != round($xml_arr['neto_kopa'], 3)) {
                $starpibaNetoBalki = $arr_Compare['neto'] - $xml_arr['neto_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu neto nesakrīt ar reģistrā esošo baļķu neto par " . $starpibaNetoBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['brakis'], 3) != round($xml_arr['brakis_kopa'], 3)) {
                $starpibaBrakisBalki = $arr_Compare['brakis'] - $xml_arr['brakis_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu brāķis nesakrīt ar reģistrā esošo baļķu brāķi par " . $starpibaBrakisBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['redukcija'], 3) != round($xml_arr['redukcija_kopa'], 3)) {
                $starpibaRedukcijaBalki = $arr_Compare['redukcija'] - $xml_arr['redukcija_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu redukcija nesakrīt ar reģistrā esošo baļķu redukciju par " . $starpibaRedukcijaBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['virsmers'], 3) != round($xml_arr['virsmers_kopa'], 3)) {
                $starpibaVirsmersBalki = $arr_Compare['virsmers'] - $xml_arr['virsmers_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu virsmērs nesakrīt ar reģistrā esošo baļķu virsmēru par " . $starpibaVirsmersBalki . "!</font></td></tr>";
            }
            if (round($arr_Compare['bruto'], 3) != round($xml_arr['bruto_kopa'], 3)) {
                $starpibaBrutoBalki = $arr_Compare['bruto'] - $xml_arr['bruto_kopa'];
                $output .= "<tr><td collspan='2'><font color=red>Failā esošo baļķu bruto nesakrīt ar reģistrā esošo baļķu bruto par " . $starpibaBrutoBalki . "!</font></td></tr>";
            }
            $output .= "<tr><td collspan=2>Izveidots fails <a href='../batch/xml/" . $output_xml_dir . "/" . $pavXMLNum . ".xml' target='_blank'>{$pavXMLNum}</a></td></tr>";
            $output .= "<tr><td>Akta numurs failā " . $xml_arr['akta_nr'] . "</td></tr>";
            $output .= "<tr><td>Baļķu skaits failā " . $xml_arr['skaits'] . "</td></tr>";
            $output .= "<tr><td>Bruto tilpums failā " . $xml_arr['bruto_kopa'] . " m3</td></tr>";
            $output .= "<tr><td>Brāķa tilpums failā " . $xml_arr['brakis_kopa'] . " m3</td></tr>";
            $output .= "<tr><td>Neto tilpums failā " . $xml_arr['neto_kopa'] . "m3</td></tr>";
            //			$output .= "<tr><td>Virsmēra tilpums failā </td><td>".$xml_arr['virsmers_kopa']." m3</td></tr>";
            //			$output .= "<tr><td>Redukcijas tilpums failā </td><td>".$xml_arr['redukcija_kopa']." m3</td></tr>";
            $output = $output . "</tbody></table>";
        }
        echo $output;
    } elseif ($output_pdf) {
        $show_reject_codes = false;
        $g_atskaite->report_pdf($C_REP->arrPrintOut);
        $g_atskaite->report_footer_pdf($_POST, $lang, $translate, $show_reject_codes);
        $new_xml_data_file = $tmp_returnResult . "/" . $pavXMLNum . ".pdf";
        $location = $g_atskaite->pdf_save($new_xml_data_file, $pavXMLNum);
        //    echo '<iframe width="50%" style="height: 85em;" src="'.$location.'"></iframe>';
        //		echo "<a href='$location'>Atskaite PDF formātā</a><br /><br />";
    } else {
        echo $newOutput;
    }
    return true;
}
Esempio n. 3
0
function print_report()
{
    $output = '';
    $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
    $C_REP = new C_REPORT($_POST, $DB_CON, false);
    /////////////////////////////////////////////////////////////////////////
    $_POST['pavadzime_head'] = $_POST['pavadzime'];
    set_param('akts_nr', $_POST['akts_nr_head']);
    set_param('pircejs_head', $_POST['pircejs_head']);
    set_param('pircejs_regnum', $_POST['pircejs_regnum']);
    set_param('pardevejs_head', $_POST['pardevejs_head']);
    set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
    set_param('pieg_lig_num', $_POST['pieg_lig_num']);
    set_param('datums', $_POST['datums_head']);
    set_param('iecirknis', $_POST['iecirknis_head']);
    set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
    set_param('pavadzime_head', $_POST['pavadzime_head']);
    set_param('transport_firm', $_POST['transport_firm']);
    set_param('auto', $_POST['auto_head']);
    set_param('soferis', $_POST['soferis_head']);
    set_param('vieta', $_POST['vieta_head']);
    set_param('piezimes', $_POST['piezimes_head']);
    set_param('atbildigais', $_POST['atbildigais_head']);
    set_param('custom11', $_POST['custom11_head']);
    set_param('custom12', $_POST['custom12_head']);
    set_param('sortiments', $_POST['sortiments_head']);
    set_param('standarts', $_POST['standarts_head']);
    set_param('metode', $_POST['metode_head']);
    set_param('raukums', $_POST['raukums_head']);
    set_param('merinstruments', $_POST['merinstruments_head']);
    set_param('terminsh', $_POST['terminsh_head']);
    $xml_vars['gvalues1'] = $_POST['gvalues1'];
    $xml_vars['gvalues1_1'] = $_POST['gvalues1_1'];
    $xml_vars['gvalues1_2'] = $_POST['gvalues1_2'];
    $xml_vars['gvalues2'] = $_POST['gvalues2'];
    $xml_vars['gvalues2_1'] = $_POST['gvalues2_1'];
    $xml_vars['gvalues2_2'] = $_POST['gvalues2_2'];
    $xml_vars['gvalues3'] = $_POST['gvalues3'];
    $xml_vars['gvalues3_1'] = $_POST['gvalues3_1'];
    $xml_vars['gvalues3_2'] = $_POST['gvalues3_2'];
    $xml_vars['gvalues4'] = $_POST['gvalues4'];
    $xml_vars['gvalues4_1'] = $_POST['gvalues4_1'];
    $xml_vars['gvalues4_2'] = $_POST['gvalues4_2'];
    $xml_vars['virsmeri'] = $_POST['virsmeri'];
    $xml_vars['virsmeri_1'] = $_POST['virsmeri_1'];
    $xml_vars['virsmeri_2'] = $_POST['virsmeri_2'];
    $xml_vars['koeficients'] = $_POST['koeficients'];
    $xml_vars['koeficients_1'] = $_POST['koeficients_1'];
    $xml_vars['koeficients_2'] = $_POST['koeficients_2'];
    $xml_vars['raukums'] = $_POST['raukums'];
    $xml_vars['raukums_1'] = $_POST['raukums_1'];
    $xml_vars['raukums_2'] = $_POST['raukums_2'];
    $xml_vars['pavadzime'] = $_POST['pavadzime'];
    /////////////////////////////////////////////////////////////////////////
    if ($C_REP->ERRORS) {
        $output = $output . "<html>";
        $output = $output . "<head>";
        $output = $output . "<title>Kļūda!</title>";
        $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
        $output = $output . "</head>";
        $output = $output . "<center>";
        $output = $output . "<STYLE TYPE=\"text/css\">";
        $output = $output . "  TD { font-size: 12px; }";
        $output = $output . "</STYLE>";
        $output = $output . "</style>";
        $output = $output . "<body>";
        $output = $output . "<p class='pagestart'></p><center><br><br>";
        $output = $output . "<b><font color=red>Kļūda!</font></b>";
        $output = $output . "<br><br>";
        $output = $output . $C_REP->ERRORS;
        $output = $output . "</center>";
        $output = $output . "<br><br>";
        $output = $output . "<input type=button value=\"Atkārtot\" onclick=\"history.back(-1)\">";
        $output = $output . "</body>";
        $output = $output . "</html>";
        return $output;
    }
    $output = $output . "\t<html>";
    $output = $output . "\t<head>";
    $output = $output . "\t\t\t\t\t\t <title>Atskaite</title>";
    $output = $output . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
    $output = $output . "\t\t\t\t\t\t</head>";
    $output = $output . "\t\t\t\t\t\t<center>";
    $output = $output . "\t<STYLE TYPE=\"text/css\">";
    $output = $output . "\t  TD { font-size: 12px; }";
    $output = $output . "\t</STYLE>";
    $output = $output . "\t<table border=0 width=90%>";
    $output = $output . "\t<tr>";
    $output = $output . "\t<td><img src=\"images/vmf.gif\"></td>";
    $output = $output . "\t</tr>";
    $output = $output . "\t<tr><td align=center>";
    $output = $output . "\t<table>";
    $output = $output . "\t<tr>";
    $output = $output . "\t <td align=center width=50></td>";
    $output = $output . "\t <td align=center valign=center><font size=5>Testēšanas pārskats nr. " . get_param('akts_nr') . "</font></td>";
    $output = $output . "\t</tr>";
    $output = $output . "\t</table>";
    $output = $output . "\t<br>";
    $output = $output . "\t<table cellspacing=0 cellpadding=0>";
    if ($_POST['contract_num']) {
        $output = $output . "<tr><td align=right>Līguma Nr.:&nbsp;</td><td>" . $_POST['contract_num'] . "</td>";
    }
    if ($_POST['pircejs_head']) {
        $output = $output . "<tr><td align=right>Pircējs:&nbsp;</td><td>" . $_POST['pircejs_head'] . "</td>";
    }
    if ($_POST['pardevejs_head']) {
        $output = $output . "<tr><td align=right>Pārdevējs:&nbsp;</td><td>" . $_POST['pardevejs_head'] . "</td>";
    }
    if ($_POST['datums_head']) {
        $output = $output . "<tr><td align=right>Datums:&nbsp;</td><td>" . $_POST['datums_head'] . "</td>";
    }
    if ($_POST['pavadzime_head']) {
        $output = $output . "<tr><td align=right>Pavadzīme:&nbsp;</td><td>" . $_POST['pavadzime_head'] . "</td>";
    }
    if ($_POST['iecirknis_head']) {
        $output = $output . "<tr><td align=right>Iecirknis:&nbsp;</td><td>" . $_POST['iecirknis_head'] . "</td>";
    }
    if ($_POST['auto_head']) {
        $output = $output . "<tr><td align=right>Automašīnas nr.:&nbsp;</td><td>" . $_POST['auto_head'] . "</td>";
    }
    if ($_POST['soferis_head']) {
        $output = $output . "<tr><td align=right>Šoferis:&nbsp;</td><td>" . $_POST['soferis_head'] . "</td>";
    }
    if ($_POST['vieta_head']) {
        $output = $output . "<tr><td align=right>Uzmērīšanas vieta:&nbsp;</td><td>" . $_POST['vieta_head'] . "</td>";
    }
    if ($_POST['custom12']) {
        $output = $output . "<tr><td align=right>" . $custom11 . "&nbsp;</td><td>" . $_POST['custom12'] . "</td>";
    }
    if ($_POST['sortiments_head']) {
        $output = $output . "<tr><td align=right>Sortiments:&nbsp;</td><td>" . $_POST['sortiments_head'] . "</td>";
    }
    if ($_POST['standarts_head']) {
        $output = $output . "<tr><td align=right>Standarts:&nbsp;</td><td>" . $_POST['standarts_head'] . "</td>";
    }
    if ($_POST['metode_head']) {
        $output = $output . "<tr><td align=right>Metode un paņēmiens:&nbsp;</td><td>" . $_POST['metode_head'] . "</td>";
    }
    if ($_POST['raukums_head']) {
        $output = $output . "<tr><td align=right>Raukums:&nbsp;</td><td>" . $_POST['raukums_head'] . "</td>";
    }
    if ($_POST['merinstruments_head']) {
        $output = $output . "<tr><td align=right>Mērinstruments:&nbsp;</td><td>" . $_POST['merinstruments_head'] . "</td>";
    }
    if ($_POST['terminsh_head']) {
        $output = $output . "<tr><td align=right>Verificēšanas termiņš:&nbsp;</td><td>" . $_POST['terminsh_head'] . "</td>";
    }
    $output = $output . "</table>";
    $output = $output . "<br><br><br>";
    $output = $output . "<table><tr><td>";
    $output = $output . $C_REP->GetHTML();
    $output = $output . '<BR><BR></td></tr>';
    if ($_POST['piezimes_head']) {
        $output = $output . '<tr><td align=left>Piezīmes: ' . $_POST['piezimes_head'] . '</td></tr>';
    }
    $output = $output . "<tr><td height=20></td></tr>";
    $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "</td></tr>";
    $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Artilērijas iela 40, korpuss 12, Rīga, LV-1009 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
    $output = $output . "</table></table>";
    $output = $output . "</body>";
    $output = $output . "</html>";
    return $output;
}
Esempio n. 4
0
function print_all_reports()
{
    global $lang;
    global $translate;
    global $arrsum;
    global $C_REP;
    $arrfinal = array();
    $output = "";
    for ($grup = 1; $grup <= $_POST['grup']; $grup++) {
        //Valoda
        if (isset($_POST['valoda' . $grup])) {
            $lang = $_POST['valoda' . $grup];
        } else {
            $lang = 'LAT';
        }
        $_POST['pavadzime_head'] = $_POST['pavadzime'];
        set_param('akts_nr', $_POST['akts_nr_head']);
        set_param('pircejs_head', $_POST['pircejs_head']);
        set_param('pircejs_regnum', $_POST['pircejs_regnum']);
        set_param('pardevejs_head', $_POST['pardevejs_head']);
        set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
        set_param('pieg_lig_num', $_POST['pieg_lig_num']);
        set_param('datums', $_POST['datums_head']);
        set_param('iecirknis', $_POST['iecirknis_head']);
        set_param('cirsmas_kods', $_POST['cirsmas_kods_head']);
        set_param('pavadzime_head', $_POST['pavadzime_head']);
        set_param('transport_firm', $_POST['transport_firm']);
        set_param('auto', $_POST['auto_head']);
        set_param('soferis', $_POST['soferis_head']);
        set_param('vieta', $_POST['vieta_head']);
        set_param('piezimes', $_POST['piezimes_head']);
        set_param('atbildigais', $_POST['atbildigais_head']);
        set_param('custom11', $_POST['custom11_head']);
        set_param('custom12', $_POST['custom12_head']);
        set_param('sortiments', $_POST['sortiments_head']);
        set_param('standarts', $_POST['standarts_head']);
        set_param('metode', $_POST['metode_head']);
        set_param('raukums', $_POST['raukums_head']);
        set_param('merinstruments', $_POST['merinstruments_head']);
        set_param('terminsh', $_POST['terminsh_head']);
        $xml_vars['gvalues' . $grup . '1'] = $_POST['gvalues' . $grup . '1'];
        $xml_vars['gvalues' . $grup . '1_1'] = $_POST['gvalues' . $grup . '1_1'];
        $xml_vars['gvalues' . $grup . '1_2'] = $_POST['gvalues' . $grup . '1_2'];
        $xml_vars['gvalues' . $grup . '2'] = $_POST['gvalues' . $grup . '2'];
        $xml_vars['gvalues' . $grup . '2_1'] = $_POST['gvalues' . $grup . '2_1'];
        $xml_vars['gvalues' . $grup . '2_2'] = $_POST['gvalues' . $grup . '2_2'];
        $xml_vars['gvalues' . $grup . '3'] = $_POST['gvalues' . $grup . '3'];
        $xml_vars['gvalues' . $grup . '3_1'] = $_POST['gvalues' . $grup . '3_1'];
        $xml_vars['gvalues' . $grup . '3_2'] = $_POST['gvalues' . $grup . '3_2'];
        $xml_vars['gvalues' . $grup . '4'] = $_POST['gvalues' . $grup . '4'];
        $xml_vars['gvalues' . $grup . '4_1'] = $_POST['gvalues' . $grup . '4_1'];
        $xml_vars['gvalues' . $grup . '4_2'] = $_POST['gvalues' . $grup . '4_2'];
        $xml_vars['virsmeri' . $grup] = $_POST['virsmeri' . $grup];
        $xml_vars['virsmeri' . $grup . '_1'] = $_POST['virsmeri' . $grup . '_1'];
        $xml_vars['virsmeri' . $grup . '_2'] = $_POST['virsmeri' . $grup . '_2'];
        $xml_vars['koeficients' . $grup] = $_POST['koeficients' . $grup];
        $xml_vars['koeficients' . $grup . '_1'] = $_POST['koeficients' . $grup . '_1'];
        $xml_vars['koeficients' . $grup . '_2'] = $_POST['koeficients' . $grup . '_2'];
        $xml_vars['raukums' . $grup] = $_POST['raukums' . $grup];
        $xml_vars['raukums' . $grup . '_1'] = $_POST['raukums' . $grup . '_1'];
        $xml_vars['raukums' . $grup . '_2'] = $_POST['raukums' . $grup . '_2'];
        $xml_vars['pavadzime'] = $_POST['pavadzime'];
        /////////////////////////////////////////////////////////////////////////
        if ($C_REP->ERRORS) {
            //$output = $output . "<html>";
            //$output = $output . "<head>";
            $output = $output . "<title>Kļūda!</title>";
            $output = $output . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $output = $output . "</head>";
            $output = $output . "<center>";
            $output = $output . "<STYLE TYPE=\"text/css\">";
            $output = $output . "  TD { font-size: 12px; }";
            $output = $output . "</STYLE>";
            $output = $output . "</style>";
            $output = $output . "<body>";
            $output = $output . "<p class='pagestart'></p><center><br><br>";
            $output = $output . "<b><font color=red>Kļūda!</font></b>";
            $output = $output . "<br><br>";
            $output = $output . $C_REP->ERRORS;
            $output = $output . "</center>";
            $output = $output . "<br><br>";
            $output = $output . "<input type=button value=\"Atkārtot\" onclick=\"history.back(-1)\">";
            //$output = $output . "</body>";
            //$output = $output . "</html>";
            return $output;
        }
        if ($grup == 1) {
            //$output = $output . "	<html>";
            //$output = $output . "	<head>";
            $output = $output . "\t\t\t\t\t\t <title>Atskaite " . $lang . "</title>";
            $output = $output . "\t\t\t\t\t\t <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
            $output = $output . "\t\t\t\t\t\t</head>";
            $output = $output . "\t\t\t\t\t\t<center>";
            $output = $output . "\t<STYLE TYPE=\"text/css\">";
            $output = $output . "\t  TD { font-size: 12px; }";
            $output = $output . "\t</STYLE>";
            $output = $output . "\t<table border=0 width=90%>";
            $output = $output . "\t<tr>";
            $output = $output . "\t<td><img src=\"images/vmf.gif\"></td>";
            $output = $output . "\t</tr>";
            $output = $output . "\t<tr><td align=center valign='top'>";
            $output = $output . "\t<table>";
            $output = $output . "\t<tr>";
            $output = $output . "\t <td align=center width=50></td>";
            $output = $output . "\t <td align=center valign=center><font size=5>" . $translate['virsraksts'][$lang] . get_param('akts_nr') . "</font></td>";
            $output = $output . "\t</tr>";
            $output = $output . "\t</table>";
            $output = $output . "\t<br>";
            $output = $output . "\t<table cellspacing=0 cellpadding=0>";
            if ($_POST['contract_num']) {
                $output = $output . "<tr><td align=right>" . $translate['liguma_nr'][$lang] . ":&nbsp;</td><td>" . $_POST['contract_num'] . "</td>";
            }
            if ($_POST['pircejs_head']) {
                $output = $output . "<tr><td align=right>" . $translate['pircejs'][$lang] . ":&nbsp;</td><td>" . $_POST['pircejs_head'] . "</td>";
            }
            if ($_POST['pardevejs_head']) {
                $output = $output . "<tr><td align=right>" . $translate['pardevejs'][$lang] . ":&nbsp;</td><td>" . $_POST['pardevejs_head'] . "</td>";
            }
            if ($_POST['datums_head']) {
                $output = $output . "<tr><td align=right>" . $translate['datums'][$lang] . ":&nbsp;</td><td>" . $_POST['datums_head'] . "</td>";
            }
            if ($_POST['pavadzime_head']) {
                $output = $output . "<tr><td align=right>" . $translate['pavadzime'][$lang] . ":&nbsp;</td><td>" . $_POST['pavadzime_head'] . "</td>";
            }
            if ($_POST['iecirknis_head']) {
                $output = $output . "<tr><td align=right>" . $translate['iecirknis'][$lang] . ":&nbsp;</td><td>" . $_POST['iecirknis_head'] . "</td>";
            }
            if ($_POST['auto_head']) {
                $output = $output . "<tr><td align=right>" . $translate['auto_nr'][$lang] . ":&nbsp;</td><td>" . $_POST['auto_head'] . "</td>";
            }
            if ($_POST['soferis_head']) {
                $output = $output . "<tr><td align=right>" . $translate['soferis'][$lang] . ":&nbsp;</td><td>" . $_POST['soferis_head'] . "</td>";
            }
            if ($_POST['vieta_head']) {
                $output = $output . "<tr><td align=right>" . $translate['uzm_vieta'][$lang] . ":&nbsp;</td><td>" . $_POST['vieta_head'] . "</td>";
            }
            if ($_POST['custom12']) {
                $output = $output . "<tr><td align=right>" . $custom11 . "&nbsp;</td><td>" . $_POST['custom12'] . "</td>";
            }
            if ($_POST['sortiments_head']) {
                $output = $output . "<tr><td align=right>" . $translate['sortiments'][$lang] . ":&nbsp;</td><td>" . $_POST['sortiments_head'] . "</td>";
            }
            if ($_POST['standarts_head']) {
                $output = $output . "<tr><td align=right>" . $translate['standarts'][$lang] . ":&nbsp;</td><td>" . $_POST['standarts_head'] . "</td>";
            }
            if ($_POST['metode_head']) {
                $output = $output . "<tr><td align=right>" . $translate['metode'][$lang] . ":&nbsp;</td><td>" . $_POST['metode_head'] . "</td>";
            }
            if ($_POST['raukums_head']) {
                $output = $output . "<tr><td align=right>" . $translate['raukums'][$lang] . ":&nbsp;</td><td>" . $_POST['raukums_head'] . "</td>";
            }
            if ($_POST['merinstruments_head']) {
                $output = $output . "<tr><td align=right>" . $translate['merinst'][$lang] . ":&nbsp;</td><td>" . $_POST['merinstruments_head'] . "</td>";
            }
            if ($_POST['terminsh_head']) {
                $output = $output . "<tr><td align=right>" . $translate['v_term'][$lang] . ":&nbsp;</td><td>" . $_POST['terminsh_head'] . "</td>";
            }
            $output = $output . "</table>";
            $output = $output . "<br><br><br>";
            $output = $output . "<table><tr><td>";
            $output = $output . "<table border=0 cellspacing=0 cellpadding=0>";
        }
        $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
        $C_REP = new C_REPORT($_POST, $DB_CON, false, $grup);
        if ($grup == 1) {
            //šī ir pirmā grupēšanas nosacījumu kopa, kopējam summas no $arr
            $arrsum = $C_REP->arr[count($C_REP->arr) - 1];
            if ($_POST['grup'] != 1) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
            }
            $arrfinal = $C_REP->arr;
        } else {
            //šī nav pirmā grupēšanas nosacījumu kopa, tāpēc pieskaitam doto apakšsummu kopīgajai summai
            $arrsum[summa]->skaits = $arrsum[summa]->skaits + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits;
            $arrsum[summa]->skaits_bad = $arrsum[summa]->skaits_bad + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits_bad;
            $arrsum[summa]->bruto = $arrsum[summa]->bruto + $C_REP->arr[count($C_REP->arr) - 1][summa]->bruto;
            $arrsum[summa]->virsmers = $arrsum[summa]->virsmers + $C_REP->arr[count($C_REP->arr) - 1][summa]->virsmers;
            $arrsum[summa]->redukcija_d = $arrsum[summa]->redukcija_d + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_d;
            $arrsum[summa]->redukcija_l = $arrsum[summa]->redukcija_l + $C_REP->arr[count($C_REP->arr) - 1][summa]->redukcija_l;
            $arrsum[summa]->brakis = $arrsum[summa]->brakis + $C_REP->arr[count($C_REP->arr) - 1][summa]->brakis;
            $arrsum[summa]->neto = $arrsum[summa]->neto + $C_REP->arr[count($C_REP->arr) - 1][summa]->neto;
            if ($grup != $_POST['grup']) {
                $C_REP->arr[count($C_REP->arr) - 1] = array();
                //ja nav pēdējā nosacījumu kopa, iztīram kopsummas rindu
            } else {
                $C_REP->arr[count($C_REP->arr) - 1] = $arrsum;
                //ja ir pēdējā nosacījumu kopa, atgriežam kopsummu
            }
            //$C_REP->arr[-1] = array(); //virsrakstus nevajag
            $arrfinal = array_merge($arrfinal, $C_REP->arr);
        }
        /*
        if ($grup < $_POST['grup']) {
        	echo "<p style='page-break-before:always;'>";
        }
        */
    }
    usort($arrfinal, 'CompareArrays');
    $arrfinal[-1] = $C_REP->arr[-1];
    $C_REP->arr = $arrfinal;
    $output = $output . $C_REP->GetHTML();
    $output = $output . '</table><BR><BR></td></tr>';
    if ($_POST['piezimes_head']) {
        $output = $output . '<tr><td align=left>' . $translate['piezimes'][$lang] . ': ' . $_POST['piezimes_head'] . '</td></tr>';
    }
    $output = $output . "<tr><td height=20></td></tr>";
    $output = $output . "<tr><td align=left>" . $translate['atb_persona'][$lang] . " ..................................................." . $_POST['atbildigais_head'] . "</td></tr>";
    $output = $output . "<tr><td align=right><br><font size=1>" . $translate['veikts'][$lang] . " SIA VMF LATVIA  <br>Reģ.nr.: 40003405130<br>Artilērijas iela 40, korpuss 12, Rīga, LV-1009 <br>" . $translate['talrunis'][$lang] . " +371 29470949 " . $translate['fakss'][$lang] . " + 371 67223718 " . $translate['epasts'][$lang] . " vmflatvia@vmf.lv</td></tr>";
    $output = $output . "</table></table>";
    echo $output;
}
Esempio n. 5
0
function print_report($grup)
{
    $DB_CON = new C_DB('localhost', DATABASE, LOGIN, PWD);
    $C_REP = new C_REPORT($_POST, $DB_CON, true, $grup);
    global $arrsum;
    //echo '$grup = ' . $grup;
    //print_r ($C_REP->arr);
    if ($grup == 1) {
        $arrsum = $C_REP->arr[count($C_REP->arr) - 1];
    } else {
        $arrsum[summa]->skaits = $arrsum[summa]->skaits + $C_REP->arr[count($C_REP->arr) - 1][summa]->skaits;
    }
    if ($grup == $_POST['grup']) {
        if ($arrsum[summa]->skaits != $arrsum[correct_count]) {
            $C_REP->ERRORS .= "Kļūda grupēšanā! Sagrupēti " . (int) $arrsum[summa]->skaits . " baļķi no " . $arrsum[correct_count] . ".<br><br>";
        }
    }
    /////////////////////////////////////////////////////////////////////////
    $_POST['pavadzime_head'] = $_POST['pavadzime'];
    set_param('akts_nr', $_POST['akts_nr_head']);
    set_param('pircejs_head', $_POST['pircejs_head']);
    set_param('pircejs_regnum', $_POST['pircejs_regnum']);
    set_param('pardevejs_head', $_POST['pardevejs_head']);
    set_param('pardevejs_regnum', $_POST['pardevejs_regnum']);
    set_param('pieg_lig_num', $_POST['pieg_lig_num']);
    set_param('datums', $_POST['datums_head']);
    set_param('iecirknis', $_POST['iecirknis_head']);
    set_param('pavadzime_head', $_POST['pavadzime_head']);
    set_param('transport_firm', $_POST['transport_firm']);
    set_param('auto', $_POST['auto_head']);
    set_param('soferis', $_POST['soferis_head']);
    set_param('vieta', $_POST['vieta_head']);
    set_param('piezimes', $_POST['piezimes_head']);
    set_param('atbildigais', $_POST['atbildigais_head']);
    set_param('custom11', $_POST['custom11_head']);
    set_param('custom12', $_POST['custom12_head']);
    $xml_vars['gvalues' . $grup . '1'] = $_POST['gvalues' . $grup . '1'];
    $xml_vars['gvalues' . $grup . '1_1'] = $_POST['gvalues' . $grup . '1_1'];
    $xml_vars['gvalues' . $grup . '1_2'] = $_POST['gvalues' . $grup . '1_2'];
    $xml_vars['gvalues' . $grup . '2'] = $_POST['gvalues' . $grup . '2'];
    $xml_vars['gvalues' . $grup . '2_1'] = $_POST['gvalues' . $grup . '2_1'];
    $xml_vars['gvalues' . $grup . '2_2'] = $_POST['gvalues' . $grup . '2_2'];
    $xml_vars['gvalues' . $grup . '3'] = $_POST['gvalues' . $grup . '3'];
    $xml_vars['gvalues' . $grup . '3_1'] = $_POST['gvalues' . $grup . '3_1'];
    $xml_vars['gvalues' . $grup . '3_2'] = $_POST['gvalues' . $grup . '3_2'];
    $xml_vars['gvalues' . $grup . '4'] = $_POST['gvalues' . $grup . '4'];
    $xml_vars['gvalues' . $grup . '4_1'] = $_POST['gvalues' . $grup . '4_1'];
    $xml_vars['gvalues' . $grup . '4_2'] = $_POST['gvalues' . $grup . '4_2'];
    $xml_vars['virsmeri' . $grup] = $_POST['virsmeri' . $grup];
    $xml_vars['virsmeri' . $grup . '_1'] = $_POST['virsmeri' . $grup . '_1'];
    $xml_vars['virsmeri' . $grup . '_2'] = $_POST['virsmeri' . $grup . '_2'];
    $xml_vars['koeficients' . $grup] = $_POST['koeficients' . $grup];
    $xml_vars['koeficients' . $grup . '_1'] = $_POST['koeficients' . $grup . '_1'];
    $xml_vars['koeficients' . $grup . '_2'] = $_POST['koeficients' . $grup . '_2'];
    $xml_vars['raukums' . $grup] = $_POST['raukums' . $grup];
    $xml_vars['raukums' . $grup . '_1'] = $_POST['raukums' . $grup . '_1'];
    $xml_vars['raukums' . $grup . '_2'] = $_POST['raukums' . $grup . '_2'];
    $xml_vars['pavadzime'] = $_POST['pavadzime'];
    /////////////////////////////////////////////////////////////////////////
    if ($C_REP->ERRORS) {
        ?>
<head>
					 <title>Kļūda!</title>
					 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
					</head>
					
					<center>
					<STYLE TYPE="text/css">
					  TD { font-size: 12px; }
					</STYLE>
					</style>
					<body>
						<center><br><br>
						<b><font color=red>Kļūda!</font></b>
						<br><br>
						<?php 
        echo $C_REP->ERRORS;
        ?>
						</center>
						<br><br>
						<input type=button value="Atkārtot" onclick="history.back(-1)">
					</body>
					</html>
			<?php 
        exit;
    }
    //echo $C_REP->GetHTML();
    //exit();
    //create header///
    //header ("Content-type: text/xml");
    //header ("Content-type: file");
    //header ("Content-Disposition: attachment; filename=".$_POST['pavadzime'].".xml");
    if (!$_POST['pavadzime_id']) {
        $_POST['pavadzime_id'] = GetFromPavadzime($_POST['pavadzime'], 'id');
    }
    $pavadz_datums = GetFromPavadzimeID($_POST['pavadzime_id'], 'kad_piegad', 'vikawood_pavadzime');
    if ($pavadz_datums == '0000-00-00') {
        $pavadz_datums = false;
    }
    if (!$pavadz_datums) {
        $pavadz_datums = GetPavadzimeDatumsID($_POST['pavadzime_id']);
        if ($pavadz_datums == '0000-00-00') {
            $pavadz_datums = '';
        }
        $pavadz_datums = str_replace('.', '-', $pavadz_datums);
    }
    if ($pavadz_datums) {
        $pavadz_datums = substr($pavadz_datums, 0, 10);
    }
    if (!$uzmerisanas_datums) {
        $uzmerisanas_datums = GetUzmerisanasDatumsID($_POST['pavadzime_id']);
        if ($uzmerisanas_datums == '0000-00-00') {
            $uzmerisanas_datums = '';
        }
        $uzmerisanas_datums = str_replace('.', '-', $uzmerisanas_datums);
    }
    if ($uzmerisanas_datums) {
        $uzmerisanas_datums = substr($uzmerisanas_datums, 0, 10);
    }
    $arr = $C_REP->GetDataArray();
    $lsk = 5;
    $output = "";
    if ($_POST['grup'] == 1) {
        $output = $output . '<?xml version="1.0" encoding="UTF-8"?>';
        $output = $output . "<Invoice>";
        $output = $output . "\t<EntryDate>" . trim($_POST['datums_head']) . "</EntryDate>";
        $output = $output . "\t<InvoiceNumber>" . $_POST['pavadzime_head'] . "</InvoiceNumber>";
        $output = $output . "\t<InvoiceDate>" . $pavadz_datums . "</InvoiceDate>";
        $output = $output . "\t<ContractNumber>" . $_POST['pieg_lig_num'] . "</ContractNumber>";
        $output = $output . "\t<MeasurerDocNr>" . $_POST['akts_nr_head'] . "</MeasurerDocNr>";
        $output = $output . "\t<Supplier>";
        $output = $output . "\t\t<Name>" . $_POST['pardevejs_head'] . "</Name>";
        $output = $output . "\t\t<RegNr>" . $_POST['pardevejs_regnum'] . "</RegNr>";
        $output = $output . "\t</Supplier>";
        $output = $output . "\t<Reciever>";
        $output = $output . "\t\t<Name>" . $_POST['pircejs_head'] . "</Name>";
        $output = $output . "\t\t<RegNr>" . $_POST['pircejs_regnum'] . "</RegNr>";
        $output = $output . "\t</Reciever>";
        $output = $output . "\t<Carrier>";
        if ($_POST['transport_firm']) {
            $output = $output . "<FirmName>" . $_POST['transport_firm'] . "</FirmName>";
        } else {
            $rAuto = mysql_query("select * from auto where numurs = '" . GetFromPavadzimeID($_POST['pavadzime_id'], 'auto', 'vikawood_pavadzime') . "'");
            if (mysql_num_rows($rAuto) > 0) {
                $mAuto = mysql_fetch_array($rAuto);
                $parvadatajs_id = $mAuto['parvadatajs'];
                $rParvadatajs = mysql_query("select * from parvadatajs where id = {$parvadatajs_id}");
                $mParvadatajs = mysql_fetch_array($rParvadatajs);
                $output = $output . "<FirmName>" . $mParvadatajs['nosaukums'] . "</FirmName>";
            }
        }
        $output = $output . "<TruckNumber>" . trim(GetFromPavadzimeID($_POST['pavadzime_id'], 'auto', 'vikawood_pavadzime')) . "</TruckNumber> ";
        $output = $output . "<Driver>" . GetFromPavadzimeID($_POST['pavadzime_id'], 'soferis', 'vikawood_pavadzime') . "</Driver>";
        $output = $output . "</Carrier>";
        $output = $output . "<Measuring>";
        $output = $output . "\t<MeasuringDate>" . $uzmerisanas_datums . "</MeasuringDate>";
        $output = $output . "\t<OperatorName>VMF Latvia</OperatorName>";
        $output = $output . "\t<MeasureMethod>I</MeasureMethod>";
        $output = $output . "</Measuring>";
        $output = $output . "<AssortmOrigin> ";
        $output = $output . "\t<FSCNumber>" . GetFromPavadzimeID($_POST['pavadzime_id'], 'fsc', 'vikawood_pavadzime') . "</FSCNumber>";
        $output = $output . "\t<SlashCode>" . GetFromPavadzimeID($_POST['pavadzime_id'], 'cirsmas_kods', 'vikawood_pavadzime') . "</SlashCode>";
        $output = $output . "</AssortmOrigin >";
    }
    if ($lsk > 1) {
        for ($j = $lsk - 2; $j >= 0; $j--) {
            $v = $arr[0][$j];
            for ($i = 0; $i < count($arr); $i++) {
                // iekopējam ja tukšs
                if ($arr[$i][$j] == "" && $arr[$i][$j + 1] != "") {
                    $arr[$i][$j] = $v;
                }
                // ja nav tukšs paņem vērtību
                if ($arr[$i][$j] != "") {
                    $v = $arr[$i][$j];
                }
            }
        }
    }
    /// drukājam tabulu
    for ($i = 0; $i < count($arr); $i++) {
        if ($arr[$i][summa]->skaits != 0 && !$arr[$i][-1]) {
            $output = $output . "\n\n<DataRow>\n";
            $output = $output . "<AssortmentGroup>ZB</AssortmentGroup>\n";
            $refused = false;
            $caurm_kods = '';
            for ($j = 0; $j < $lsk; $j++) {
                switch ($arr[-1][$j]) {
                    case 'suga':
                        //$arr[$i][$j]=$LVM_sugas[$arr[$i][$j]]; // pārveidojam uz LVM sugām P:E
                        $output = $output . "<Specie>" . $arr[$i][$j] . "</Specie>\n";
                        break;
                    case 'brakis':
                        if (round($arr[$i][summa]->brakis, 3) > 0 && trim($arr[$i][$j]) == "") {
                            $arr[$i][$j] = "D";
                        }
                        if ($arr[$i][$j] != '') {
                            $refused = true;
                            $output = $output . "<RejectReason>" . $arr[$i][$j] . "</RejectReason>\n";
                        }
                        break;
                    case 'mind_pirms_red':
                        $SG = trim($arr[$i][$j]);
                        if ($SG == '0-79') {
                            $SG = "M";
                        }
                        //echo $SG . '<br />';
                        if ($SG == '120-129' || $SG == '130-139') {
                            $SG = '120-139';
                        }
                        $output = $output . "<SizeGroup>" . $SG . "</SizeGroup>\n";
                        $caurm_kods = trim($arr[$i][$j]);
                        if ($caurm_kods == '120-129' || $caurm_kods == '130-139') {
                            $caurm_kods = '120-139';
                        }
                        break;
                    case 'garums':
                        $a = explode('-', $arr[$i][$j]);
                        $output = $output . "<Length>\n<LowerLimit>{$a['0']}</LowerLimit>\n<UpperLimit>{$a['1']}</UpperLimit>\n</Length>\n";
                        break;
                    case 'cenu_matrica':
                        $output = $output . "<Price>" . $arr[$i][$j] . "</Price>\n";
                    default:
                        //echo "<kaut_kas>".$arr[$i][$j]."</kaut_kas>\n";
                }
            }
            //echo "<td align=right>".round($arr[$i][summa]->bruto,3)."</td><td width=5>";
            $output = $output . "<Assortment>" . get_LVM_asort_kods_no_caurm_kods($caurm_kods) . "</Assortment>";
            $output = $output . "<Overlength>" . round($arr[$i][summa]->virsmers, 3) . "</Overlength>\n";
            $output = $output . "<LengthReduction>" . round($arr[$i][summa]->redukcija_d + $arr[$i][summa]->redukcija_l, 3) . "</LengthReduction>\n";
            if ($refused) {
                $volume = round($arr[$i][summa]->brakis, 3);
            } else {
                $volume = round($arr[$i][summa]->neto, 3);
            }
            $output = $output . "<NetVolume>" . $volume . "</NetVolume>\n";
            $output = $output . "<Count>" . round($arr[$i][summa]->skaits, 3) . "</Count>\n";
            $output = $output . "<NotAgreed>0</NotAgreed>\n";
            $output = $output . "</DataRow>";
        }
    }
    if ($grup == $_POST['grup']) {
        $output = $output . "</Invoice>";
    }
    return $output;
}