Files
crm.twinpol.com/modules/EcmPaymentStates/test.php
2025-05-12 15:44:39 +00:00

151 lines
6.2 KiB
PHP
Executable File

<?php
$g=$_GET;
?>
<form action="index.php" method="get" name="Search">
<input type="hidden" name="action" value="index" />
<input type="hidden" name="not_matched" value="0" />
<input type="hidden" name="module" value="EcmPaymentStates" />
<script language="javascript">
var OPT=new Array();
OPT['dec_len']=2;
OPT['sep_1000']=".";
OPT['dec_sep']=",";
function formatNumber(number,add) {
if(!number) number = 0;
number = parseFloat(number);
var tmp = number.toFixed(OPT['dec_len']);
var s1 = tmp.substring(0,tmp.length-1-OPT['dec_len']);
var s2 = tmp.substring(tmp.length-OPT['dec_len'],tmp.length);
var tmp = '';
for(var i=s1.length;i>0;i-=3) {
tmp = ((i<=3)?"":OPT['sep_1000'])+s1.substring(i-3,i)+tmp;
}
s1 = tmp;
return (s1+OPT['dec_sep']+s2).toString()+((add)?add:'');
}
function unformatNumber(ufn,add) {
if(add) {
var match = /add/g;
ufn = ufn.replace(match,'');
}
var match = /Err/g;
ufn = ufn.replace(match,'');
if(!ufn) return parseFloat(0);
var pos = ufn.indexOf(OPT['dec_sep']);
var s1='', s2='';
if(pos==-1) { s1 = ufn; s2 = ''; }
else { s1 = ufn.substring(0,pos); s2 = ufn.substring(pos+1,ufn.length); }
var pos = -1;
while((pos = s1.indexOf(OPT['sep_1000'])) != -1)
s1 = s1.substring(0,pos)+s1.substring(pos+1,s1.length);
return parseFloat(s1+"."+s2);
}
function addValue(obj,value,inp){
if(obj.checked==true)inp.innerHTML=formatNumber(parseFloat(unformatNumber(inp.innerHTML))+parseFloat(value));
else inp.innerHTML=formatNumber(parseFloat(unformatNumber(inp.innerHTML))-parseFloat(value));
}
function addValuePayments(obj,value,inp){
var cb=document.getElementById("paymentsList").getElementsByTagName("input");
for(var i=0;i<cb.length;i++){
if(cb[i].type=="checkbox"){
cb[i].checked=false;
}
}
obj.checked=true;
inp.innerHTML=formatNumber(parseFloat(value));
}
</script>
<?php
echo '<table cellspacing="0" cellpadding="0" border="0">';
echo '<tr>';
echo '<td class="listViewThS1" width="10">&nbsp;</td><td class="listViewThS1" width="20">&nbsp;</td><td class="listViewThS1" width="100">Register Date</td><td class="listViewThS1" width="190">Name</td><td class="listViewThS1" width="100">Total</td>';
echo '<td class="listViewThS1" width="10">&nbsp;</td><td class="listViewThS1" width="20">&nbsp;</td><td class="listViewThS1" width="100">Payment Date</td><td class="listViewThS1" width="190">Name</td><td class="listViewThS1" width="100">Value</td>';
echo '</tr>';
echo '<tr valign="top"><td colspan="5"><div style="height:400px;overflow:auto">';
echo '<table cellspacing="0" cellpadding="0" border="0">';
$w=$GLOBALS['db']->query("select p.id,p.document_no,p.paid,p.register_date,p.payment_date,p.total from ecmpayments_ecminvoiceouts as p where p.deleted='0' and p.account_id='134' order by p.register_date desc,p.document_no desc");
// inner join ecmpayments_ecminvoiceouts as p on p.ecminvoiceout_id=e.id
echo mysql_error();
while($r=$GLOBALS['db']->fetchByAssoc($w)){
//if($r['type']!='correct'){
if($r['paid']==0)$paid="&nbsp;";
else $paid="*";
$exp=explode("-",$r['register_date']);
//if($paid=="&nbsp;" && mktime()>mktime(0,0,0,$exp[1],$exp[2],$exp[0])+30*24*3600)$arr+=$r['total'];
echo '<tr><td class="oddListRowS1" width="10"><input type="checkbox" name="check1[]" value="'.$r['id'].'" onclick="addValue(this,'.$r['total'].',document.getElementById(\'total_wn\'));"></td><td class="oddListRowS1" width="10">'.$paid.'</td><td class="oddListRowS1" width="100">'.$r['register_date'].'</td><td class="oddListRowS1" width="220">'.$r['document_no'].'</td><td class="oddListRowS1" width="80">'.$r['total'].'</td></tr>';
//}
$total_wn+=$r['total'];
}
echo '</table></div>';
echo '</td><td colspan="5"><div style="height:400px;overflow:auto">';
echo '<table cellspacing="0" cellpadding="0" border="0">';
$w=$GLOBALS['db']->query("select payment_date,id,description,value,paid from ecmpayments where paid!='18' and deleted='0' and parent_id='134' order by payment_date desc,description desc");
while($r=$GLOBALS['db']->fetchByAssoc($w)){
if($r['paid'])$paid="*";
else $paid="&nbsp;";
echo '<tr><td class="oddListRowS1" width="10"><input type="checkbox" name="check2[]" value="'.$r['id'].'" onclick="addValue(this,'.$r['value'].',document.getElementById(\'total_ma\'));"></td><td class="oddListRowS1" width="10">'.$paid.'</td><td class="oddListRowS1" width="100">'.$r['payment_date'].'</td><td class="oddListRowS1" width="220"><a href="index.php?module=EcmPayments&action=DetailView&record='.$r['id'].'">'.$r['description'].'</a></td><td class="oddListRowS1" width="80">'.$r['value'].'</td></tr>';
$total_ma+=$r['value'];
}
echo '</table></div>';
echo '</td></tr></table>';
?>
<table width="943">
<tr>
<td colspan="2" style="font-size: 18px;text-align:center">
<table cellspacing="3" cellpadding="3" border="0" width="100%" style="font-size: 20px; border: 1px solid #cccccc;">
<tr style="font-weight: bold; background: #e6e6e6;">
<td style="text-align: center;">
Summary WN
</td>
<td style="text-align: center;">
Summary
</td>
<td style="text-align: center;">
Summary MA
</td>
</tr>
<tr>
<td style="text-align: center;">
<?php
//$total_wn-=4635096.97;
echo number_format(($total_wn),2,",",".");
?>
</td>
<td style="text-align: center;">
<?php
echo number_format(($total_ma-$total_wn),2,",",".");
?>
</td>
<td style="text-align: center;">
<?php
echo number_format(($total_ma),2,",",".");
?>
</td>
</tr>
<tr style="font-weight: bold; background: #e6e6e6;">
<td style="text-align: center;">&nbsp;
</td>
<td style="text-align: center;">
Actual arrear
</td>
<td style="text-align: center;">&nbsp;
</td>
</tr>
<tr>
<td style="text-align: center;" id="total_wn">0,00
</td>
<td style="text-align: center;">
<?php
echo ($arr);
?>
</td>
<td style="text-align: center;" id="total_ma">0,00
</td>
</tr>
</table><br />
<input type="submit" class="button" value="Match" onclick="document.Search.action.value='Match';" name="match" />&nbsp;
<input type="submit" class="button" value="Show not matched" onclick="document.Search.action.value='index';document.Search.not_matched.value='1';" name="notmatched" />
<input type="submit" class="button" value="Show all" onclick="document.Search.action.value='index';document.Search.not_matched.value='0';" name="matchednotmatched" />
</form>