File: /www/exchange2/exchange/classes/Display/DTrade.php
<?php
include_once('admin/classes/Display/DBase.php');
class Display_DTrade extends DBase
{
function getInvestorFloor($trade){
$i =1;
$output = '
<tr class="grays_bg1" style="padding:0; margin:0;">
<td valign="top" align="left" colspan="13" style="padding:0; margin:0;background:none;"><script>
var iterate = '.(count($trade)).';
function addin(str){
for(i=1; i<=iterate;i++){
var id = "#trade_"+i;
var drop = "#search_id_"+i;
if(str == i){
$(id).removeClass("clsTradeBook");
showMnu("search_id_"+i, this);
//$(id).addClass("nodisplay");
}else{
$(id).addClass("clsTradeBook");
//$(id).removeClass("nodisplay");
$(drop).hide();
}
}
}
//sorting function for Trade
i=0;
myWindow="undefined";
function openWin(str,height,flg)
{
if(myWindow !="undefined"){
myWindow.close();
}
if(flg == "1"){
str +="&flg=buy";
}
myWindow=window.open("index.php?do=tradewindow&trade_id="+str+"","mywin","width=750,height="+height+"");
myWindow.focus();
}
function openBuyWin(str,height){
var r=confirm("Click OK to Buy Out this Trade, otherwise click Cancel")
if (r==true)
{
$.post(
"?do=bid",
{inv_id: str,
buy: 2 },
function(responseText){
if(responseText !=3){
//alert("Buy Out Successful");
}else{
alert("Buy Out Unsuccessful");
}
},
"html"
);
}else{
return false;
}
}
function openBuyWindow(){
//alert(document.trade_floor.["inv_all[]"].length);
var a=new Array();
a=document.getElementsByName("inv_all[]");
//alert("Length:"+a.length);
var p=0;
var output = "";
for(i=0;i<a.length;i++){
if(a[i].checked == true){
output += a[i].value+",";
p=1;
}
}
if (p==0){
alert("please select at least one check box");
return false;
}else{
myWindow=window.open("index.php?do=buyoutwindow&inv_id="+output+"","mywin","width=820,height=600,scrollbars=yes");
//alert(output);
}
}
function jumptoCart(str){
$.post(
"?do=jumpcart",
{id: str},
function(responseText){
//window.close();
},
"html"
);
}
function all_set(){
$( function() {
$("INPUT[name=\'inv_all[]\']").attr(\'checked\', $(\'#select_all\').is(\':checked\'));
});
}
</script>';
$output .=' <ul style="height: 35px; background:#C0C0C0;">
<li style="width: 83px; padding: 0px 7px; border-right: 4px solid #FFF;"><b>Debtor</b></li>
<!--<li style="width: 50px; padding: 0px 7px;"><b>Nc/Nd</b></li>-->
<!--<li style="border-right: 4px solid #FFF; padding: 0px 10px; width: 66px;"><b>R/C</b>\'000</li>-->
<li style=" padding: 0 29px 0 5px; width: 79px;"><b>Tdr/Bkr</b></li>
<!--<li style=" padding: 0 1px; width: 68px;"><b>R/C</b>\'000</li>-->
<li style=" width: 50px; padding: 0px 1px;"><b>Tm S&T</b></li>
<li style="padding: 0 7px 0 12px; text-align: left;width: 54px;"><b>Value</b></li>
<li style=" padding: 0 10px; width: 36px;"><b>Date</b></li>
<li style="border-left: 4px solid #FFFFFF;padding: 0 4px;text-align: center;width: 55px;"><b>Offer</b></li>
<li style="width: 67px; padding: 0px 10px; border-left: 4px solid #FFF; text-align: center;"><b>Paid</b></li>
<li style="padding: 0pt 3px; width: 31px; text-align: center;"><b>Yield</b></li>
<li style="width: 45px; border-left: 4px solid #FFF; padding: 0px 5px 0 6px; text-align: center;"><b>D/Os</b></li>
<li style="width: 100px; padding: 0px;text-align: center; "><b>Status</b></li></td></tr>';
foreach($trade as $tradefloor){
$trader_id = str_replace("-","",$tradefloor['doj'])."000";
$trader_id = $trader_id + $tradefloor['user_id'];
if($i%2 == 0){
$bg_class = "row2";
}else{
$bg_class = "row1";
}
if($tradefloor['sales_type'] !="0"){
$bid_query=new Bin_Query();
$bid_sql = "SELECT * FROM invoice_bidding_history where invoice_id = '".$tradefloor['invoice_id']."'";
$bid_query->executeQuery($bid_sql);
$history = $bid_query->records;
if(count($history) ==0){
$style="color:#000000;"; //black
}else{
$bid_query1=new Bin_Query();
$bid_sql1 = "SELECT * FROM invoice_bidding_history where invoice_id = '".$tradefloor['invoice_id']."' && user_id ='".$_SESSION['user']['userid']."'";
$bid_query1->executeQuery($bid_sql1);
$history1 = $bid_query1->records;
if(count($history1) ==0){
$style="color:#3F48CC;"; // blue
}else{
$bid_query=new Bin_Query();
if($tradefloor['sales_type'] =="1"){
$bid_sql = "SELECT * FROM invoice_bidding where invoice_id = '".$tradefloor['invoice_id']."' order by min_advance DESC limit 1";
}else{
$bid_sql = "SELECT * FROM invoice_bidding where invoice_id = '".$tradefloor['invoice_id']."' order by max_thirty_reserve ASC limit 1";
}
$bid_query->executeQuery($bid_sql);
$history = $bid_query->records[0];
if($_SESSION['user']['userid'] != $history['user_id']){
$style="color:#3F48CC;"; //red
}else{
if($tradefloor['invoice_status'] == 2){
$style="color:#22B14B;"; //green
}else{
$style="color:#22B14C;"; //green
}
}
}
}
if($tradefloor['sales_type'] =="1"){
$bid_query=new Bin_Query();
$bid_sql = "SELECT min_advance , max_thirty_reserve FROM invoice_bidding where invoice_id = '".$tradefloor['invoice_id']."' order by min_advance DESC limit 1";
$bid_query->executeQuery($bid_sql);
$history = $bid_query->records[0];
if(count($history) ==0){
$history['min_advance'] = $tradefloor['min_advance'];
$history['max_thirty_reserve'] = $tradefloor['max_thirty_day_reserve'];
}
$history['max_thirty_reserve'] =' ';
/*$annualYield = ((($tradefloor['face_value'] - 7 - 50)/$history['min_advance'])-1) *
(360 / ( $tradefloor['exp_days'] - ($tradefloor['days'] + 3)));
$yield = number_format(abs($annualYield),3,'.','');
if($tradefloor['buy_out'] == 1) {
$buy_annualYield = ((($tradefloor['face_value'] - 7 - 50)/$history['buy_min_advance'])-1) *
(360 / ( $tradefloor['exp_days'] - ($tradefloor['days'] + 3)));
$buy_yield = number_format(abs($buy_annualYield),3,'.','');
}*/
if($history['min_advance'] >= 1000000 ){
$history['min_advance'] = $history['min_advance'] / 1000000;
$history['min_advance'] = $tradefloor['currency_code'].number_format($history['min_advance'], 1, '.', ',')."M";
}else{
$history['min_advance'] = $tradefloor['currency_code'].number_format(round($history['min_advance']));
}
if($tradefloor['min_advance'] >= 1000000 ){
$tradefloor['min_advance'] = $tradefloor['min_advance'] / 1000000;
$tradefloor['min_advance'] = $tradefloor['currency_code'].number_format($tradefloor['min_advance'], 1, '.', ',')."M";
}else{
$tradefloor['min_advance'] = $tradefloor['currency_code'].number_format(round($tradefloor['min_advance']));
}
}else{
$bid_query=new Bin_Query();
$bid_sql = "SELECT min_advance , max_thirty_reserve FROM invoice_bidding where invoice_id = '".$tradefloor['invoice_id']."' order by max_thirty_reserve ASC limit 1";
$bid_query->executeQuery($bid_sql);
$history = $bid_query->records[0];
if(count($history) ==0){
$history['min_advance'] = $tradefloor['min_advance'];
$history['max_thirty_reserve'] = $tradefloor['max_thirty_day_reserve'];
}
$history['min_advance'] =' ';
/*$annualYield = ((((($tradefloor['face_value'] - 7)/$history['max_thirty_reserve'])-1)* 360)/180);
$yield = number_format(abs($annualYield),'3','.','');
if($tradefloor['buy_out'] == 1) {
$buy_annualYield = ((((($tradefloor['face_value'] - 7)/$tradefloor['buy_max_thirty_day_reserve'])-1) * 360)
/180);
$buy_yield = number_format(abs($buy_annualYield),'3','.','');
}*/
$non_face_value = $tradefloor['face_value'];
$non_purchase_price = $non_face_value / (1+((180/360) * ( ($tradefloor['max_thirty_day_reserve']/100) * 12)));
$non_result1 = $non_face_value - 7;
//echo $q63 = $face_value/(1+((180/360) * ($max_thirty_day_reserve *12)));
$non_result2 = $non_result1 / $non_purchase_price;
$non_result3 = $non_result2 - 1;
$non_result4 = $non_result3 * 360;
/*$non_days_sql = "select DATEDIFF( DATE_ADD(expected_date,INTERVAL 1 DAY), DATE(DATE_ADD(NOW(),INTERVAL 3 DAY)) )AS days from invoice_master where invoice_id = '".$tradefloor['invoice_id']."' ";*/
$non_days_sql = "select DATEDIFF(expected_date, DATE(NOW()) )AS days from invoice_master where invoice_id = '".$tradefloor['invoice_id']."' ";
$non_query=new Bin_Query();
$non_query->executeQuery($non_days_sql);
$non_days = $non_query->records;
$non_diff_days = $non_days[0]['days'] -2;
$non_result5 = $non_diff_days;
$non_result6 = $non_result4 / $non_result5;
$non_yield = abs($non_result6) * 100;
$non_yield = number_format(($non_yield), 3, '.', '')."%";
$buy_non_face_value = $tradefloor['face_value'];
$buy_non_purchase_price = $buy_non_face_value / (1+((180/360) * ( ($tradefloor['buy_max_thirty_day_reserve']/100) * 12)));
$buy_non_result1 = $buy_non_face_value - 7;
//echo $q63 = $face_value/(1+((180/360) * ($max_thirty_day_reserve *12)));
$buy_non_result2 = $buy_non_result1 / $buy_non_purchase_price;
$buy_non_result3 = $buy_non_result2 - 1;
$buy_non_result4 = $buy_non_result3 * 360;
/*$buy_non_days_sql = "select DATEDIFF( DATE_ADD(expected_date,INTERVAL 1 DAY), DATE(DATE_ADD(NOW(),INTERVAL 3 DAY)) )AS days from invoice_master where invoice_id = '".$tradefloor['invoice_id']."' ";*/
$buy_non_days_sql = "select DATEDIFF( expected_date, DATE(NOW()) )AS days from invoice_master where invoice_id = '".$tradefloor['invoice_id']."' ";
$buy_non_query=new Bin_Query();
$buy_non_query->executeQuery($buy_non_days_sql);
$buy_non_days = $buy_non_query->records;
$buy_non_diff_days = $buy_non_days[0]['days'] - 2;
$buy_non_result5 = $buy_non_diff_days;
$buy_non_result6 = $buy_non_result4 / $buy_non_result5;
$buy_non_yield = abs($buy_non_result6) * 100;
$buy_non_yield = number_format(($buy_non_yield), 3, '.', '')."%";
$history['max_thirty_reserve'] = number_format(($history['max_thirty_reserve']), 3, '.', '');
$tradefloor['max_thirty_day_reserve'] = number_format(($tradefloor['max_thirty_day_reserve']), 3, '.', '')."%";
$tradefloor['buy_max_thirty_day_reserve'] = number_format(($tradefloor['buy_max_thirty_day_reserve']), 3, '.', '')."%";
}
}//else{}
$face_value = $tradefloor['currency_code'].number_format($tradefloor['face_value'], 2, '.', ',');
$face_value1 = $tradefloor['face_value'];
if($face_value1 >= 1000000 ){
$face_value1 = $face_value1 / 1000000;
$face_value1 = $tradefloor['currency_code'].number_format($face_value1, 1, '.', ',')."M";
}else{
$face_value1 = $tradefloor['currency_code'].number_format(round($tradefloor['face_value']));
}
$debtor_limit = $tradefloor['debtor_limit'];
if($debtor_limit >= 1000000){
$debtor_limit = $debtor_limit / 1000000;
$debtor_limit = number_format($debtor_limit, 2, '.', ',')."M";
}else{
$debtor_limit = number_format($tradefloor['debtor_limit']);
}
$tooltip = $tradefloor['debtor_name'].", Average Risk: ".$tradefloor['debtor_risk']." & Credit Limit: ".$debtor_limit." ";
if($tradefloor['debtor_limit'] >= 1000){
$debtor_limit = number_format($tradefloor['debtor_limit']/1000);
}else{
$debtor_limit = $tradefloor['debtor_limit']/1000;
if($debtor_limit != "0")
$debtor_limit = number_format($debtor_limit,1,".",",");
else
$debtor_limit = 0;
}
$output .='
<tr>
<td align="left" valign="top" colspan="14">';
if($i ==1){
$output .='
<div id="trade_'.$i.'" ondblclick="addin('.$i.');" style="position:relative;">
';
$display = "none";
}else{
$output .='
<div id="trade_'.$i.'" class="clsTradeBook" ondblclick="addin('.$i.');" style="position:relative;">';
$display = "none";
}
/*$limits = $tradefloor['limits'];
if($limits >= 1000000){
$limits = $limits / 1000000;
$limits = number_format($limits, 2, '.', ',')."M";
}else{
$limits = number_format($tradefloor['limits']);
}*/
if($tradefloor['limits'] >= 1000){
$limits = number_format($tradefloor['limits']/1000);
}else{
$limits = $tradefloor['limits']/1000;
if($limits != "0")
$limits = number_format($limits,1,".",",");
else
$limits = 0;
}
$risk_query=new Bin_Query();
$risk_sql = "SELECT risk_credit_id, provider1_credit_limit, provider1_risk_score,provider2_credit_limit, provider2_risk_score FROM risk_credit where debtor_id = '".$tradefloor['debtor_master_id']."' limit 1";
$risk_query->executeQuery($risk_sql);
$risk = $risk_query->records;
if($risk[0]['provider1_risk_score'] >= 1000){
$risk[0]['provider1_risk_score'] = number_format($risk[0]['provider1_risk_score'] /1000);
}else{
$risk[0]['provider1_risk_score'] = $risk[0]['provider1_risk_score']/1000;
if($risk[0]['provider1_risk_score'] != "0")
$risk[0]['provider1_risk_score'] = number_format($risk[0]['provider1_risk_score'],1,".",",");
else
$risk[0]['provider1_risk_score'] = 0;
}
if($risk[0]['provider2_risk_score'] >= 1000){
$risk[0]['provider2_risk_score'] = number_format($risk[0]['provider2_risk_score'] /1000);
}else{
$risk[0]['provider2_risk_score'] = $risk[0]['provider2_risk_score']/1000;
if($risk[0]['provider2_risk_score'] != "0")
$risk[0]['provider2_risk_score'] = number_format($risk[0]['provider2_risk_score'],1,".",",");
else
$risk[0]['provider2_risk_score'] = 0;
}
$risk_org_query=new Bin_Query();
$risk_org_sql = "SELECT risk_credit_id, provider1_credit_limit, provider1_risk_score,provider2_credit_limit, provider2_risk_score FROM risk_credit where organisation_id = '".$tradefloor['organisation_id']."' limit 1";
$risk_org_query->executeQuery($risk_org_sql);
$risk_org = $risk_org_query->records;
if($risk_org[0]['provider1_risk_score'] >= 1000){
$risk_org[0]['provider1_risk_score'] = number_format($risk_org[0]['provider1_risk_score'] /1000);
}else{
$risk_org[0]['provider1_risk_score'] = $risk_org[0]['provider1_risk_score']/1000;
if($risk_org[0]['provider1_risk_score'] != "0")
$risk_org[0]['provider1_risk_score'] = number_format($risk_org[0]['provider1_risk_score'],1,".",",");
else
$risk_org[0]['provider1_risk_score'] = 0;
}
if($risk_org[0]['provider2_risk_score'] >= 1000){
$risk_org[0]['provider2_risk_score'] = number_format($risk_org[0]['provider2_risk_score'] /1000);
}else{
$risk_org[0]['provider2_risk_score'] = $risk_org[0]['provider2_risk_score']/1000;
if($risk_org[0]['provider2_risk_score'] != "0")
$risk_org[0]['provider2_risk_score'] = number_format($risk_org[0]['provider2_risk_score'],1,".",",");
else
$risk_org[0]['provider2_risk_score'] = 0;
}
$pro_query=new Bin_Query();
$pro_sql = "SELECT provider1_document_path, provider2_document_path FROM risk_credit_document where risk_credit_id = '".$risk[0]['risk_credit_id']."' order by risk_credit_document_id DESC limit 1";
$pro_query->executeQuery($pro_sql);
$pro = $pro_query->records;
$pro_org_query=new Bin_Query();
$pro_org_sql = "SELECT provider1_document_path, provider2_document_path FROM risk_credit_document where risk_credit_id = '".$risk_org[0]['risk_credit_id']."' order by risk_credit_document_id DESC limit 1";
$pro_org_query->executeQuery($pro_org_sql);
$pro_org = $pro_org_query->records;
//Annual collection days calculation
// (((((facevalue-bank cahnrges - debx fees)/purchase price)-1)* 360) / Annual collection days )
//Yield Calculation
// ((Purchase price * Annual Yield * Assumed Collection days )/ 360)
/* if($tradefloor['invoice_id'] == 9){
}*/
$output .='<span style="position: absolute; height: 27px; z-index: 999; left: -3px; bottom:0px; top:1px;width: 970px; display:none;" id="blink_'.$tradefloor['invoice_id'].'"></span>';
$output .='
<div class="cat_middle '.$bg_class.'"> <span ondblclick="" class="categrey_u">
<ul style="display:block; height:30px;" class="td_floor">
<li style="float: left; width: 97px; margin:0px;" class="tool-tip"> <a href="javascript:void(0);" title="'.$tooltip.'"><img alt="#" src="../images/i_bttn.png"></a> <span ><b class="black">'.substr($tradefloor['debtor_name'],0,8).'...</b></span></li>
<!--<li style="float: left; width: 30px; margin:0 0 0 5px;">'.$tradefloor['d_nace_group_id'].' </li>
<li style="float: left; width: 27px; text-align:right; margin:0 10px 0 0 ">'.$tradefloor['d_nace_id'].'</li>-->
<!--<li style="float: left; width: 25px; margin:0; ">'.$tradefloor['debtor_risk'].'</li>
<li style="float: left; width: 42px; margin:0 10px 0 0 ; text-align:right;">'.$debtor_limit.'</li>-->
<li style="float: left; padding: 0 10px 0 6px; width: 88px; border-left:4px solid #FFF; text-align:left;">'.$trader_id.'</li>
<!--<li style="float: left; margin:0 0 0 10px; width: 23px;"> '.$tradefloor['risks'].'</li>
<li style="float: left; width: 45px; margin:0px; text-align:right;">'.$limits.'</li>-->
<li style="float: left;margin: 0 0 0 9px;width: 21px; text-align:right;">'.$tradefloor['payment_terms'].'</li><li style="float: left; margin: 0 2px 0 5px;width: 10px;">S</li><li style="float: left;margin: 0 0 0 5px;width: 10px;"><b>';
/*if( $tradefloor['buy_out'] ==1)
$output .= ' Y ';
else
$output .= ' N ';*/
if($tradefloor['sales_type'] =="1"){
$output .='O';
}else if($tradefloor['sales_type'] =="2"){
$output .='M';
}else{
$output .='P';
}
$output .='</b></li>
<li style="float: left; width: 65px; margin:0 2px 0 0; text-align:right;"><span class="black"><b>'.$face_value1.'</b></span></li>
<li style="float: left; width: 50px; margin: 0 5px; text-align:center;">';
$expected_date = explode("-",$tradefloor['expected_date']);
$output .=$expected_date[2]."/".$expected_date[1]."/".substr($expected_date[0],2,4);
$output .='</li>
';
if($tradefloor['sales_type'] !=1)
$align="text-align:right;";
else
$align ="text-align:left;";
if($tradefloor['sales_type'] =='1'){
$output .='
<li style="float: left; border-left: 4px solid #FFFFFF; margin: 0 5px 0 1px;text-align: right;width: 58px;">'.$tradefloor['min_advance'].'</li>
<li style="border-left: 4px solid #FFFFFF; float: left;padding: 0 2px 0 2px; width: 70px; text-align:right;"> <span class="black" id="min_'.$tradefloor['invoice_id'].'" style="display:none;" ><b style="'.$style.'" id="cnt_min_'.$tradefloor['invoice_id'].'">'.$history['min_advance'].'</b></span></li>
<li style="width:50px; position:relative;float: left;border-right: 4px solid #FFFFFF;"> <span class="black" id="max_'.$tradefloor['invoice_id'].'" ><b id="cnt_max_'.$tradefloor['invoice_id'].'">'.number_format($tradefloor['yield'],'3','.',',').'</b></span></li>
';
}else{
if($tradefloor['sales_type'] =='3'){
$return = $tradefloor['face_value'] -7 - 50 ;
$val_return = $tradefloor['currency_code'].number_format($return);
}else{
$val_return =' ';
}
/*$output .='
<li style="float: left; border-left: 4px solid #FFFFFF; margin: 0 5px 0 1px; text-align: right;width: 58px;">'.$tradefloor['max_thirty_day_reserve'].' </li>
<li style=" border-left: 4px solid #FFFFFF; position:relative; border-right: 4px solid #FFFFFF; float: left;padding: 0 2px 0 2px; width: 120px; '.$align.'"><span class="black" id="min_'.$tradefloor['invoice_id'].'"><b style="'.$style.'" >'.$val_return.'</b></span> <span class="black" id="max_'.$tradefloor['invoice_id'].'"><b style="'.$style.'" >'.$history['max_thirty_reserve'].'</b></span></li>
';*/
$output .='
<li style="float: left; border-left: 4px solid #FFFFFF; margin: 0 5px 0 1px;text-align: right;width: 58px;">'.$tradefloor['max_thirty_day_reserve'].'</li>
<li style="border-left: 4px solid #FFFFFF; float: left;padding: 0 2px 0 2px; width: 70px; text-align:right;"> <span class="black" id="min_'.$tradefloor['invoice_id'].'" style="" style="display:none;"><b style="'.$style.'" id="cnt_min_'.$tradefloor['invoice_id'].'">'.$val_return.'</b></span></li>
<li style="width:50px; position:relative;float: left;border-right: 4px solid #FFFFFF;text-align:right;"> <span class="black" id="max_'.$tradefloor['invoice_id'].'" ><b id="cnt_max_'.$tradefloor['invoice_id'].'">'.number_format($tradefloor['yield'],'3','.',',').'</b></span></li>
';
}
$hidden_style = str_replace("color:#",'',$style);
$hidden_style = trim(str_replace(";",'',$hidden_style));
$output .='
<li style="float: left; margin: 0 1px 0 3px; text-align:right;
width:51px;"> </li>
<li style="float:left; width:100px; margin:0 0 0 2px;"> <span style="display:none;" id="style_'.$tradefloor['invoice_id'].'">'.$hidden_style.'</span></li>
</ul>
<script>
</script>
</span> </div>
<div class="categ">
<ul id="search_id_'.$i.'" style="display: '.$display.';" class="trd_detail">
<li>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tbody>
<tr>
<td align="left" width="26%" valign="top" style="line-height: 20px; padding-left: 15px;"><b class="black"> Debtors Details</b><br>
Name : '.self::substr($tradefloor['debtor_name'],22).'<br>
NACEC : '.$tradefloor['d_nace_group_id'].'<br>
NACED : '.$tradefloor['d_nace_id'].' <br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">';
if($risk[0]['provider1_credit_limit'] != '0' && $risk[0]['provider1_risk_score'] != '0' && $risk[0]['provider1_credit_limit'] != '' && $risk[0]['provider1_risk_score'] != ''){
$output .=' <tr>
<td>Experian Risk Value :</td>
<td><span style="float:right;margin: 0 23px 0 0; display:block;">'.$risk[0]['provider1_credit_limit'].'%</span></td>
</tr>
<tr>
<td>Experian Credit Limit :</td>
<td><span style="float:right;margin: 0 35px 0 0; display:block;">'.$tradefloor['currency_code'].$risk[0]['provider1_risk_score'].'</span></td>
</tr>';
}
if($risk[0]['provider2_credit_limit'] != '0' && $risk[0]['provider2_risk_score'] != '0' && $risk[0]['provider2_credit_limit'] != '' && $risk[0]['provider2_risk_score'] != ''){
$output .=' <tr>
<td>Creditsafe Risk Report :</td>
<td><span style="float:right;margin: 0 23px 0 0; display:block;">'.$risk[0]['provider2_credit_limit'].'%</span></td>
</tr>
<tr>
<td>Creditsafe Credit Limit :</td>
<td><span style="float:right;margin: 0 35px 0 0; display:block;">'.$tradefloor['currency_code'].$risk[0]['provider2_risk_score'].'</span></td>
</tr>';
}
$output .='</table><br>
<br>
<br>
';
if($pro[0]['provider1_document_path'] !='' || $pro[0]['provider2_document_path'] !=''){
$output .='<p><a href="index.php?do=reportcart&id='.$tradefloor['invoice_id'].'&p_id=8" target="_blank" style="padding:2px 5px 3px 5px;" class="buy_repo">Buy Report</a></p><br>';
}
$output .='</td>
<td align="left" width="24%" valign="top" style="line-height: 20px;"><b class="black">Trader Details</b><br>
Reference Code : '.$trader_id.'<br>
NACEC : '.$tradefloor['t_nace_group_id'].'<br>
NACED : '.$tradefloor['t_nace_id'].' <br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">';
if($risk_org[0]['provider1_credit_limit'] != '0' && $risk_org[0]['provider1_risk_score'] != '0' && $risk_org[0]['provider1_credit_limit'] != '' && $risk_org[0]['provider1_risk_score'] != ''){
$output .=' <tr>
<td>Experian Risk Value :</td>
<td><span style="float:right;margin: 0 23px 0 0; display:block;">'.$risk_org[0]['provider1_credit_limit'].'%</span></td>
</tr>
<tr>
<td>Experian Credit Limit :</td>
<td><span style="float:right;margin: 0 35px 0 0; display:block;">'.$tradefloor['currency_code'].$risk_org[0]['provider1_risk_score'].'</span></td>
</tr>';
}
if($risk_org[0]['provider2_credit_limit'] != '0' && $risk_org[0]['provider2_risk_score'] != '0' && $risk_org[0]['provider2_credit_limit'] != '' && $risk_org[0]['provider2_risk_score'] != ''){
$output .=' <tr>
<td>Creditsafe Risk Report :</td>
<td><span style="float:right;margin: 0 23px 0 0; display:block;">'.$risk_org[0]['provider2_credit_limit'].'%</span></td>
</tr>
<tr>
<td>Creditsafe Credit Limit :</td>
<td><span style="float:right;margin: 0 35px 0 0; display:block;">'.$tradefloor['currency_code'].$risk_org[0]['provider2_risk_score'].'</span></td>
</tr>';
}
$output .='</table><br>
<br>
';
if($pro_org[0]['provider1_document_path'] !='' || $pro_org[0]['provider2_document_path'] !=''){
$output .='<p><a href="index.php?do=reportcart&id='.$tradefloor['invoice_id'].'&p_id=9" target="_blank" style="padding:2px 5px 3px 5px;" class="buy_repo">Buy Report</a></p><br>';
}
$output .='</td>
<td align="left" width="32%" valign="top" style="line-height: 18px;">
Face Value : '.$face_value.'<br>
Sales Type: <b class="black">'.$tradefloor['type_name'].'</b> <br>
';
if($tradefloor['sales_type'] !="1"){
$return = $tradefloor['face_value'] -7;
$val_return = number_format($return, 2, '.', ',');//number_format($deci_value[0]).substr($deci_value[1], 0,4);
//if($tradefloor['bid_yield'] == "0"){
$yield = number_format($tradefloor['yield'],'3','.',',');
/*}else{
$yield = number_format($tradefloor['bid_yield'],'3','.',',');
}*/
$output .='
Percentage Offered: '.$tradefloor['max_thirty_day_reserve'].' <br>
Value Returned: '.$tradefloor['currency_code'].number_format($tradefloor['return'],'2','.',',').' <br>
Yield: '.$yield.'% <br>';
if($tradefloor['sales_type'] == 3){
$output .='Non-Performance Yield: '.$non_yield.'<br>';
}
if($tradefloor['buy_out'] == 1) {
$output .='<b class="black"> Buy Out Details</b><br>
Percentage Offered: '.$tradefloor['buy_max_thirty_day_reserve'].'<br>
Yield: <b>'.number_format($tradefloor['buy_yield'],'3','.','').'%</b> ';
if($tradefloor['sales_type'] == 3){
$output .='<br>Non-Performance Yield: '.$buy_non_yield;
}
}
}else{
$return = $tradefloor['face_value'] -7 - 50 ;
$val_return = number_format($return, 2, '.', ',');//number_format($deci_value[0]).substr($deci_value[1], 0,4);
//if($tradefloor['bid_yield'] == "0"){
$yield = number_format($tradefloor['yield'],'3','.',',');
/*}else{
$yield = number_format($tradefloor['bid_yield'],'3','.',',');
}*/
$output .='Price Offered: '.$tradefloor['min_advance'].' <br>
Value Returned: '.$tradefloor['currency_code'].number_format($tradefloor['return'],'2','.',',').' <br>
Yield: '.$yield.' % <br>';
$checked='';
if($tradefloor['debx'] =='1'){
$checked = 'checked="true"';
}
$output .='<p style="font-size:11px;margin: 5px 0;">
<input type="checkbox" id="debx" name="debx" value="1" '.$checked.' readonly="readonly">
Use CE <a style="color:#0033FF; font-size:11px; text-decoration:underline;" href="#">Debt Collection Service</a> for this invoice
</p>';
if($tradefloor['buy_out'] == 1) {
$output .='<b class="black"> Buy Out Details</b><br>
Price Offered: '.$tradefloor['currency_code'].number_format(round($tradefloor['buy_min_advance'])).' <br>
Yield: <b>'.number_format($tradefloor['buy_yield'],'3','.','').'%</b> ';
}
}
$output .='';
/* if($_SESSION['user']['usertype'] == 1 || $_SESSION['user']['usertype'] == 2) {
if($tradefloor['buy_out'] == 1) {
$output .='
<input type="text" class="buy_tr1" value="Buy" name="" onclick=\'return openBuyWin("'.$tradefloor['invoice_id'].'",'.$height.');\'>
';
}
}<td align="left" width="18%" valign="top" style="line-height: 18px;">
Trade is Open : '.$tradefloor['c_days'].'D:'.$tradefloor['c_hours'].'H:'.$tradefloor['c_minutes'].'M <br>
Payment Terms : '.$tradefloor['payment_terms'].' Days<br>
Expected By :'.$tradefloor['expected_date'].'<br>
';
$days = $tradefloor['exp_days'];
$week = str_replace(".00","",number_format(($days / 7), 2, '.', ''));
$months = str_replace(".00","",number_format(($days / 30), 2, '.', ''));
$quaters = str_replace(".00","",number_format(($days / 90), 2, '.', ''));
$output .='
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td aign="left" style="padding-left:0px;">Settled Time:</td>
<td align="right">'.$days.'</td>
<td align="left">Days</td>
</tr>
<tr>
<td align="right"></td>
<td align="right">'.$week.'</td>
<td align="left">Weeks</td>
</tr>
<tr>
<td align="right"></td>
<td align="right">'.$quaters.'</td>
<td align="left">Quarters</td>
</tr>
</table>
<br>
<p align="center">Time Remaining:</p>
<div id="countdown_dashboard_'.$tradefloor['invoice_id'].'" class="countdwn" style="font-size:11px; width:130px;"> '.$tradefloor['days'].'D:'.$tradefloor['hours'].'H:'.$tradefloor['minutes'].'M </div>
';
$output.='</td>*/
$output .='</td></tr>
</tbody>
</table>
</li>
</ul>
</div></div>
</td>
</tr>';
$i++;
}
return $output.'<style> .ClsFloor li, .ClsFloor li span , .ClsFloor li span b { font-size:11px !important; } .grays_bg1 li { float:left; line-height:35px; } .clsTradeBook .blinks{ height:31px !important; }</style>';
}
}
?>