<?php 
$ss = new Sugar_Smarty ();
global $mod_strings;
$ss -> assign( "MOD", $mod_strings );
$Calendar_daFormat = str_replace("d","%d",str_replace("m","%m",str_replace("Y","%Y",$GLOBALS['timedate']->get_date_format())));
$ss -> assign("dateFormat", $Calendar_daFormat);

if ($_REQUEST['process'] == '1') {

$date_from = $_REQUEST['date_from'];
$ss->assign('date_from', $date_from);
$date_to = $_REQUEST['date_to'];
$ss->assign('date_to', $date_to);
$parent_id = $_REQUEST['account_id'];
$ss->assign('contractorId', $parent_id);
$parent_name = $_REQUEST['account_name'];
$ss->assign('contractorName', $_REQUEST['account_name']);

$date_from = substr($date_from, 6,4).'-'.substr($date_from, 3,2).'-'.substr($date_from, 0,2);
$date_to = substr($date_to, 6,4).'-'.substr($date_to, 3,2).'-'.substr($date_to, 0,2);


$db = $GLOBALS['db'];
$res = $db->query("SELECT id, document_no, register_date, total_netto FROM ecminvoiceouts WHERE 
        (register_date BETWEEN '$date_from' AND '$date_to') AND deleted='0' AND canceled='0'
        AND parent_id='$parent_id' AND type='normal' order by register_date");
$invoices = array();
while ($row = $db->fetchByAssoc($res)) {
    $invoices[] = $row;
}
$ss->assign('PROCESS', '1');
$ss->assign('INVOICES', $invoices);
} 

echo $ss->display ( 'modules/EcmInvoiceOuts/tpls/multiDiscountCorrectInvoice.tpl' );
?>