<script type="text/javascript" src="modules/EcmReports/javascript/SendSMS.js"></script>
<link rel="stylesheet" type="text/css" href="modules/EcmReports/css/SearchTable.css"/>
<script src="include/jQuery/tablesorter/jquery.tablesorter.min.js"></script>
<link class="theme" rel="stylesheet" href="include/jQuery/tablesorter/themes/blue/style.css">
<style>
{literal}
.hidden{
	display:none !important;
}
.show{
	
}
{/literal}
</style>
<h1>Raport wysłanych SMS'ów</h1>

<form action="index.php" method="get" name="ReportSalesByProduct">
	<input type="hidden" name="module" value="EcmReports" />
	<input type="hidden" name="action" value="SendSMS"/>
	<input type="hidden" name="parentTab" value="Raporty" />
	<table style="width:100%" class="edit view" id="SearchTable">
		<tbody>
			<tr>
				<td>
					Data od:
					<input id="date_from" name="date_from" type="text" maxlength="10" size="11" title="{$MOD.LBL_DATE_FROM}" value="{$date_from_value}">
					<img id="date_from_trigger" src="themes/default/images/jscalendar.gif">
				</td>
				<td rowspan='2'>
					<p>
					Numer telefonu:
					<input id="number" name="number" type="text" maxlength="10" size="11" title="{$MOD.LBL_DATE_FROM}" value="{$number}">
					</p><br>
					<p>
					{$MOD.LBL_CONTRACTOR}:
					<input type="hidden" id="account_id" name="account_id" value="{$ACCOUNT_ID}">
					<input type="text" id="account_name" name="account_name" value="{$ACCOUNT_NAME}">
					<button 
						type="button"  
						id="selectAccount"
						value="{$APP.LBL_ADD_BUTTON}"
						title="{$MOD.TIP_CHOOSE_ACCOUNT}">
						<img src="{sugar_getimagepath file="id-ff-select.png"}">
					</button>
					<button 
						type="button"  
						id="clearAccount"
						value="{$MOD.LBL_CLEAR}"
						title="{$MOD.LBL_CLEAR}">
						<img src="{sugar_getimagepath file='id-ff-clear.png'}">
					</button>
					</p>
				</td>
				<td rowspan='2'>
				Ukryj puste:
				<input type="checkbox" name="empty" value="1" {if $empty==1}checked{/if}>
					</td>
			</tr>
			<tr>
			<td>	Data do 
					<input id="date_to" name="date_to" type="text" maxlength="10" size="11" title="{$MOD.LBL_DATE_TO}" value="{$date_to_value}">
					<img id="date_to_trigger" src="themes/default/images/jscalendar.gif">
				</td>
			</tr>
		</tbody>
	</table>
	<input class="button" name="submit" value="Wykonaj" type="submit">
	<input class="button" name="clear" value="{$MOD.LBL_CLEAR}" type="button" onclick="location.href='index.php?module=EcmReports&action=SendSMS';">
	{if $executed==1}
	{if $data!=null}
	<input class="button" name="show" id="show" value="Pokaż transakcje" type="button" onclick="showHide();">
		<input id="status" value="0" type="hidden" >
	{/if}
	{/if}
	
</form>

{if $executed==1}
<table id="myTable" class="tablesorter">
		<thead>
		<tr>
		<th class='sortby' style="width:1%">L.p</th>
		<th class='sortby' style="width:40%">Kontrahent</th>
		<th class='sortby' style="width:5%">Numer</th>
		<th class='sortby' style="width:34%">Treść</th>
		<th class='sortby' style="width:5%">Kwota</th>
		<th class='sortby' style="width:5%">Data</th>

		</tr>
		</thead>
		<tbody>
		{if $data!=null}
		
			{foreach from=$data item=item key=item_name}
			<tr>
				<td>{$item.no}</td>
				<td><img src="modules/EcmSales/images/add_position.gif" onclick="showPosition('{$item.id}');">&nbsp;{$item.parent_name}</td>
				<td>{if $item.number!=''}<b>{$item.number}</b>{else}&nbsp;{/if}</td>
				<td>{$item.description}</td>
				<td style="text-align:right;"><b>{$item.total|number_format:2:",":"."}</b></td>
				<td>{$item.send_date|date_format:"%d.%m.%Y %H:%M:%S"}</td>
			</tr>
			{if $item.records|@count>0}
			<tr class="hidden" id="tr_{$item.id}">
			<td class="" id="td1_{$item.id}" colspan="2"></td>
			<td class="" id="td2_{$item.id}" colspan="4">
			<table id="myTable2" class="tablesorter">
		<thead>
		<tr>
		<th class='sortby' style="width:1%">L.p</th>
		<th class='sortby' style="width:70%">Transakcja</th>
		<th class='sortby' style="width:15%">Kwota</th>
		<th class='sortby' style="width:14%">Termin płatności</th>

		</tr>
		</thead>
			<tbody>
				{foreach from=$item.records item=item2 key=item_name2}
				<tr>
					<td>{$item2.no}</td>
					<td>{$item2.name}</td>
					<td style="text-align:right;"><b>{$item2.total|number_format:2:",":"."}</b></td>
					<td>{$item2.payment_date|date_format:"%d.%m.%Y"}</td>
				</tr>
				{/foreach}
				</tbody>
				</table>
				</td>
				</tr>
			{/if}
			{/foreach}
			
			{else}
			<tr>
				<td style="width:100%;text-align:center;" colspan="6"><b>Brak danych do wyświetlenia</b></td>
			</tr>
			{/if}
			</tbody>
	</table>
{/if}