diff -crB htdocs.orig/modules/balanceadd.php htdocs/modules/balanceadd.php
*** htdocs.orig/modules/balanceadd.php	2009-08-26 12:12:10.000000000 +0200
--- htdocs/modules/balanceadd.php	2009-08-26 14:18:38.000000000 +0200
***************
*** 121,126 ****
--- 121,133 ----
  		$LMS->AddBalance($addbalance);
  }
  
+ if ($payment_id = $_POST['marks']) {
+ 	foreach ($payment_id as $id) {
+ 		$DB->Execute('UPDATE cashimport SET closed = 1 WHERE id = ?',
+ 			array($id));
+ 	}
+ }
+ 
  header('Location: ?'.$SESSION->get('backto'));
  
  ?>
diff -crB htdocs.orig/modules/cashimport.php htdocs/modules/cashimport.php
*** htdocs.orig/modules/cashimport.php	2009-08-26 12:12:10.000000000 +0200
--- htdocs/modules/cashimport.php	2009-08-26 14:50:16.000000000 +0200
***************
*** 198,207 ****
--- 198,224 ----
  	}
  }
  
+ if($importlist_payments = $DB->GetAll('SELECT i.*, c.name
+ 	FROM cashimport i
+ 	LEFT JOIN cashsources c ON (i.sourceid = c.id)
+ 	WHERE i.closed = 0 AND i.value < 0
+ 	ORDER BY i.id'))
+ {
+ 	$listdata_payments['total'] = sizeof($importlist_payments);
+ 
+ 	foreach($importlist_payments as $idx => $row)
+         {
+ 		$divisions_payments[0]['list'][] = $row;
+                 unset($importlist_payments[$idx]);
+         }
+ }
+ 
  $SESSION->save('backto', $_SERVER['QUERY_STRING']);
  
  $SMARTY->assign('divisions', $divisions);
+ $SMARTY->assign('divisions_payments', $divisions_payments);
  $SMARTY->assign('listdata', isset($listdata) ? $listdata : NULL);
+ $SMARTY->assign('listdata_payments', isset($listdata_payments) ? $listdata_payments : NULL);
  $SMARTY->assign('error', $error);
  $SMARTY->assign('customerlist', $LMS->GetCustomerNames());
  $SMARTY->assign('sourcelist', $DB->GetAll('SELECT id, name FROM cashsources ORDER BY name'));
diff -crB htdocs.orig/templates/cashimport.html htdocs/templates/cashimport.html
*** htdocs.orig/templates/cashimport.html	2009-08-26 12:12:10.000000000 +0200
--- htdocs/templates/cashimport.html	2009-08-26 14:50:03.000000000 +0200
***************
*** 34,42 ****
  //-->
  </SCRIPT>
  {/literal}
! <P><FORM NAME="cashimport" ACTION="?m=cashimport" METHOD="post">
! <INPUT type="submit" class="hiddenbtn">
  <TABLE WIDTH="100%" CELLPADDING="3">
  	<TR CLASS="DARK">
  		<TD CLASS="fleftu" WIDTH="1%">
  			{t}ID:{/t}
--- 34,43 ----
  //-->
  </SCRIPT>
  {/literal}
! <P>
  <TABLE WIDTH="100%" CELLPADDING="3">
+ <FORM NAME="cashimport" ACTION="?m=cashimport" METHOD="post">
+ <INPUT type="submit" class="hiddenbtn">
  	<TR CLASS="DARK">
  		<TD CLASS="fleftu" WIDTH="1%">
  			{t}ID:{/t}
***************
*** 66,72 ****
  		    <IMG src="img/division.gif" alt=""> <B>{$division.name}</B>
  		</TD>
  		<TD colspan="3" class="frightu" align="right">
! 		    <A href="?m=cashimport&action=csv&division={$division.id}">{t}Download (CSV){/t} <IMG src="img/save.gif" alt="">
  		</TD>
  	</TR>
  		{cycle values="light,lucid" print=false}
--- 67,73 ----
  		    <IMG src="img/division.gif" alt=""> <B>{$division.name}</B>
  		</TD>
  		<TD colspan="3" class="frightu" align="right">
! 		    <A href="?m=cashimport&action=csv&division={$division.id}">{t}Download (CSV){/t} <IMG src="img/save.gif" alt=""></A>
  		</TD>
  	</TR>
  		{cycle values="light,lucid" print=false}
***************
*** 118,124 ****
  			<A HREF="javascript:CheckAll2();">{t}Check All{/t}</A>
  		</TD>
  		<TD CLASS="fbt" COLSPAN="2" ALIGN="center" nowrap>
! 		    <A href="?m=cashimport&action=txt">{t}Download all (TXT){/t} <IMG src="img/save.gif" alt="">
  		</TD>
  		<TD CLASS="frightu" COLSPAN="2" align="right" nowrap>
  			<A HREF="javascript:Delete();">{t}Delete{/t} <IMG src="img/delete.gif" ALT=""></A>
--- 119,125 ----
  			<A HREF="javascript:CheckAll2();">{t}Check All{/t}</A>
  		</TD>
  		<TD CLASS="fbt" COLSPAN="2" ALIGN="center" nowrap>
! 		    <A href="?m=cashimport&action=txt">{t}Download all (TXT){/t} <IMG src="img/save.gif" alt=""></A>
  		</TD>
  		<TD CLASS="frightu" COLSPAN="2" align="right" nowrap>
  			<A HREF="javascript:Delete();">{t}Delete{/t} <IMG src="img/delete.gif" ALT=""></A>
***************
*** 126,133 ****
  			<A HREF="javascript:document.cashimport.submit();">{t}<!do>Import{/t} <IMG src="img/save.gif" ALT=""></A>
  		</TD>
  	</TR>
! </TABLE>
! </FORM></P>
  {if $error.lines}
  <P><TABLE width="100%" CELLPADDING="3">
  	<TR class="DARK">
--- 127,187 ----
  			<A HREF="javascript:document.cashimport.submit();">{t}<!do>Import{/t} <IMG src="img/save.gif" ALT=""></A>
  		</TD>
  	</TR>
! </FORM>
! 	{foreach from=$divisions_payments item=division_payments}{if $division_payments.list}
! 	<TR class="DARK">
! 		<TD colspan="4" class="fleftu">
! 			<IMG src="img/division.gif" alt=""> <B>{t}Payments List{/t}</B>
! 	        </TD>
! 		<TD colspan="3" class="frightu" align="right">
! 			<A href="?m=cashimport&action=csv&payments=1">{t}Download (CSV){/t} <IMG src="img/save.gif" alt=""></A>
! 		</TD>
! 	</TR>
! 		{cycle values="light,lucid" print=false}
! 	        {foreach from=$division_payments.list item=item}
! <FORM NAME="addbalance{$item.id|string_format:"%04d"}" METHOD="POST" ACTION="?m=balanceadd">	
! 	<TR class="{cycle}">
! 		<TD CLASS="fleft">
! 			{$item.id|string_format:"%04d"}
! 		</TD>
! 		<TD NOWRAP>
! 		        {$item.date|date_format:"%Y/%m/%d"}
! 		</TD>
! 		<TD NOWRAP ALIGN="RIGHT">
! 		        <B>{$item.value|money_format}</B>
! 		</TD>
! 		<TD ALIGN="LEFT">
!                         {if $item.customer}{$item.customer}
! 			{elseif $item.customerid}
! 				{assign var=cust value=$item.customerid}
! 				{$customerlist.$cust.customername}
! 			{/if}
! 		</TD>
! 		<TD ALIGN="LEFT">
! 		        {$item.description}
! 		</TD>
! 		<TD ALIGN="RIGHT" CLASS="fright" COLSPAN="2" NOWRAP>
! 			<INPUT type="submit" class="hiddenbtn">
! 			<INPUT TYPE="HIDDEN" NAME="m" VALUE="balanceadd">
! 			<INPUT TYPE="HIDDEN" NAME="marks[{$item.id}]" VALUE="{$item.id}">
! 			<INPUT TYPE="HIDDEN" NAME="addbalance[value]" VALUE="{math equation="x*-1" x=$item.value}">
! 			<INPUT TYPE="HIDDEN" NAME="addbalance[comment]" VALUE="{$item.description} / {$item.customer}">
! 			<A HREF="javascript:document.addbalance{$item.id|string_format:"%04d"}.submit();" onClick="document.addbalance{$item.id|string_format:"%04d"}.action='?m=cashimport&action=delete'"><IMG src="img/delete.gif" alt="[ {t}Delete{/t} ]" title="[ {t}Delete{/t} ]"></A>
! 			<A HREF="javascript:document.addbalance{$item.id|string_format:"%04d"}.submit();"><IMG src="img/pay.gif" alt="[ {t}Account payment{/t} ]" title="[ {t}Account payment{/t} ]"></A>
! 		</TD>
! 	</TR>
! </FORM>
! 		{/foreach}
! 	{/if}{/foreach}
! <TR CLASS="dark">
!                 <TD CLASS="fleftu" COLSPAN="3" nowrap>
! 		</TD>
! 		<TD CLASS="fbt" COLSPAN="2" ALIGN="center" nowrap>
! 		</TD>
! 		<TD CLASS="frightu" COLSPAN="2" align="right" nowrap>
! 		</TD>
! </TR>
! </P>
  {if $error.lines}
  <P><TABLE width="100%" CELLPADDING="3">
  	<TR class="DARK">
