$requiredUserLevel = array(1); $cfgProgDir = './phpSecurePages/'; include($cfgProgDir . "secure.php"); include "setup.php"; include "lib.php"; include "lib_api.php"; $msg= "Book Trade"; $msgtype= "main"; //** to autofill a previous trade $unitid= $_GET['tradeid']; //******** LOAD PREVIOUS CLIENT LISTING ******************** if ($_POST['submit']=="Load Previous" && isset($_POST['submit'])){ $unitid= $_POST['pastlisting']; } //******** Insert OR Update Data ******************** if ($_POST['submit']=="Delete" && isset($_POST['submit'])) { $query = "delete from UnitAddr where"; if($superadmn==1){ $query .= " ID="; $query .= "'".$ID."' and "; } $query .= " PtyID='".$_POST['oldid']."'"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); if(!$result){ $msg= "Error - ".$unitid." not deleted. Adminstrator Rights only."; $msgtype= "error"; }else{ $msg= "Trade ".$unitid." Deleted"; $msgtype= "ok"; } } if ($_POST['submit']=="Save"){ $flag=1; $errorcounter=1; //--- Update Existing Record --- if($_POST['oldid'] !=NULL){ $query22="Select PriceID from ListSeller where "; $query22.=" SellerID="."'".$_POST['comment']."'"; $result22 = mysql_query($query22) or die (mysql_error(). " : ".mysql_errno()); $row22=mysql_fetch_object($result22); $query = "update UnitAddr set"; $query .= " Address="; $query .= "'".$_POST['address']."'"; $query .= ", Postal="; $query .= "'".$_POST['postal']."'"; $query .= ", Development="; $query .= "'".$_POST['development']."'"; $query .= ", Tenor="; $query .= "'".$_POST['tenor']."'"; $query .= ", Top="; $query .= "'".$_POST['top']."'"; $query .= ", Type="; $query .= "'".$_POST['type']."'"; $query .= ", Area="; $query .= "'".$_POST['area']."'"; $query .= ", NoOfRoom="; $query .= "'".$_POST['noofroom']."'"; $query .= ", Floor="; $query .= "'".$_POST['floor']."'"; $query .= ", Price="; $query .= "'".$row22->PriceID."'"; $query .= ", Comment="; $query .= "'".$_POST['comment']."'"; $query .= ", DateExpiry="; $query .= "'".$_POST['dateexpiry']."'"; //$query .= ", DatePosted="; //$query .= "'".$today."'"; //$query .= ", Grouping="; //$query .= "'".$_POST['group']."' "; $query .= " where "; if($superadmn!=9 && $superadmn!=1){ $query .= " ID="; $query .= "'".$ID."' and "; } $query .= " PtyID="; $query .= "'".$_POST['oldid']."'"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); if(!$result){ $msg= "Error - ".$_POST['oldid']." not updated. Settlements and Adminstrator Rights only."; $msgtype= "error"; }else{ //update table UnitNo $query = "update UnitNo set"; $query .= " UnitFloor="; $query .= "'".$_POST['unitfloor']."'"; $query .= ", UnitNo="; $query .= "'".$_POST['unitno']."'"; $query .= ", UnitCode="; $query .= "'".$_POST['unitcode']."'"; $query .= ", UnitPrice="; $query .= "'".$_POST['pricefull']."'"; $query .= ", UnitBuiltup="; $query .= "'".$_POST['areafull']."'"; $query .= ", UnitLand="; $query .= "'".$_POST['unitland']."'"; $query .= ", UnitSeller="; $query .= "'".$_POST['unitseller']."'"; $query .= ", UnitContact="; $query .= "'".$_POST['unitcontact']."'"; $query .= ", UnitNotes="; $query .= "'".$_POST['unitnotes']."'"; $query .= " where PtyID="; $query .= "'".$_POST['oldid']."'"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); $msg= "Success - Trade ".$_POST['oldid']." updated."; $msgtype= "ok"; } }else{ //--- Add New Record --- $count=0; if($_POST['development']!=NULL && $_POST['comment']!=NULL && $_POST['floor']!=NULL ){ $query13="Select PriceID, Denom from ListSeller where "; $query13.=" SellerID='".$_POST['comment']."'"; $result13 = mysql_query($query13) or die (mysql_error(). " : ".mysql_errno()); $row13=mysql_fetch_object($result13); $tradetime=$todaytime; $query = "insert into UnitAddr"; $query .= "(PtyID, Address, Postal, Development, Tenor, Top, Type, Area, NoOfRoom, Floor, Price, Comment, DatePosted, DateExpiry, ID) "; $query .= "values (NULL, "; $query .= "'".$_POST['address']."'"; $query .= ", "."'".$_POST['postal']."'"; $query .= ", "."'".$_POST['development']."'"; $query .= ", "."'".$_POST['tenor']."'"; $query .= ", "."'".$_POST['top']."'"; $query .= ", "."'".$_POST['type']."'"; $query .= ", "."'".$_POST['area']."'"; $query .= ", "."'".$_POST['noofroom']."'"; $query .= ", "."'".$_POST['floor']."'"; $query .= ", "."'".$row13->PriceID."'"; $query .= ", "."'".$_POST['comment']."'"; $query .= ", "."'".$tradetime."'"; $query .= ", "."'".$_POST['dateexpiry']."'"; $query .= ", "."'".$ID."'"; //-- Grouping field removed //$query .= ", "."'".$_POST['group']."'"; $query .= " )"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); if(!$result){ $msg= "Error - ".$_POST['address']." trade booked but details not saved. Contact Settlements immediately."; $msgtype= "error"; }else{ $tempid=mysql_insert_id(); //-- calculating EAM spread if($_POST['unitland']!=NULL)$spdamount=$_POST['unitland']; else $spdamount=$_POST['unitno']; $query = "insert into UnitNo"; $query .= "(PtyID, UnitFloor, UnitNo, UnitCode, UnitPrice, UnitBuiltup, UnitLand, UnitSeller, UnitContact, UnitNotes)"; $query .= "values ('".$tempid."'"; $query .= ", "."'".$_POST['unitfloor']."'"; $query .= ", "."'".$_POST['unitno']."'"; $query .= ", "."'".$_POST['unitcode']."'"; $query .= ", "."'".$_POST['pricefull']."'"; $query .= ", "."'".$_POST['areafull']."'"; $query .= ", "."'".$spdamount."'"; $query .= ", "."'".$_POST['unitseller']."'"; $query .= ", "."'".$_POST['unitcontact']."'"; $query .= ", "."'".$_POST['unitnotes']."'"; $query .= " )"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); $msg= "Success - Trade Booked"; $msgtype= "ok"; //--- CREATE CORRESPONDING CASH LINE --- $notifybookcash=0; if($_POST['area']=='1' || $_POST['area']=='2'){ //-- Bonds=1 EQUITY=2 //-- select CASH type if($row13->Denom == 'USD'){ if($row13->PriceID=='3')$actype=3; //FUND elseif($row13->PriceID=='2' || $row13->PriceID=='7')$actype=1; //EAM elseif($row13->PriceID=='4'|| $row13->PriceID=='6')$actype=2; //AMC elseif($row13->PriceID=='5')$actype=4; //BANK else $actype=3; $query66="Select * from Development where "; $query66.=" DvID='".$actype."'"; $result66=mysql_query($query66) or die (mysql_error(). " : ".mysql_errno()); $row66=mysql_fetch_object($result66); }else{ $query66="Select * from Development where "; $query66.=" Address Like'%CASH%' and Address Like '%".$row13->Denom."%'"; $result66=mysql_query($query66) or die (mysql_error(). " : ".mysql_errno()); $row66=mysql_fetch_object($result66); } $query = "insert into UnitAddr"; $query .= "(PtyID, Address, Postal, Development, Tenor, Top, Type, Area, NoOfRoom, Floor, Price, Comment, DatePosted, DateExpiry, ID) "; $query .= "values (NULL, "; $query .= "'".$row66->Address."'"; $query .= ", "."'".$row66->Postal."'"; $query .= ", "."'".$row66->Development."'"; $query .= ", "."'".$row66->Tenor."'"; $query .= ", "."'".$row66->Top."'"; $query .= ", "."'".$row66->Type."'"; $query .= ", "."'".$row66->Area."'"; $query .= ", "."'".$row66->Room."'"; $query .= ", "."'".$_POST['floor']."'"; $query .= ", "."'".$row13->PriceID."'"; $query .= ", "."'".$_POST['comment']."'"; $query .= ", "."'".$tradetime."'"; $query .= ", "."'".$_POST['dateexpiry']."'"; $query .= ", "."'5'"; //settlements officer ID $query .= " )"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); $tempid1=mysql_insert_id(); $query77="Select * from ListPostal where "; $query77.=" PosID='".$_POST['postal']."'"; $result77=mysql_query($query77) or die (mysql_error(). " : ".mysql_errno()); $row77=mysql_fetch_object($result77); if($row77->Name != $row13->Denom){ //-- to calculate bond cost if($_POST['area']=='1')$pamt= changeBaseFX($_POST['unitcode'] * $_POST['unitno'] / 100, $row77->Name ,$row13->Denom); //-- calculate equity costing elseif($_POST['area']=='2') $pamt= changeBaseFX($_POST['unitcode'] * $_POST['unitno'], $row77->Name , $row13->Denom); else $pamt=999.99; $oriamt=$_POST['unitcode'] * $_POST['unitno']; //print "INSIDE FX CON - pamt=".$pamt." - orignal=".$oriamt." basefx=".$row13->Denom." oldfx=".$row77->Name." "; }else{ //-- to calculate bond cost if($_POST['area']=='1')$pamt= $_POST['unitcode'] * $_POST['unitno'] / 100; //-- calculate equity costing elseif($_POST['area']=='2') $pamt= $_POST['unitcode'] * $_POST['unitno']; else $pamt=999.99; } $query = "insert into UnitNo"; $query .= "(PtyID, UnitFloor, UnitNo, UnitCode, UnitPrice, UnitLand, UnitNotes)"; $query .= "values ('".$tempid1."'"; if($_POST['unitfloor']=='Long') $query .= ", "."'Short'"; else $query .= ", "."'Long'"; $query .= ", "."'100'"; $query .= ", "."'".$pamt."'"; $query .= ", "."'Open'"; $query .= ", "."'100'"; $query .= ", "."'AA Settle ID ".$tempid."'"; $query .= " )"; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); }else{ $msg= "Error - Cash Adjustment not made. Contact Settlements."; $msgtype= "error"; $notifybookcash=1; } //-- email on trade booked $query=" Select distinct ListDevelopment.Name as Name, Development.Address as Address, ListArea.Name as Class from ListDevelopment, Development, ListArea where Development.Area=ListArea.AreaID and Development.DvID=ListDevelopment.DevID and ListDevelopment.DevID='".$_POST['development']."' "; $result = mysql_query($query) or die (mysql_error(). " : ".mysql_errno()); $row=mysql_fetch_object($result); $queryc=" Select distinct Name from ListFloor where FlrID='".$_POST['floor']."' "; $resultc = mysql_query($queryc) or die (mysql_error(). " : ".mysql_errno()); $rowc=mysql_fetch_object($resultc); $query3=" Select ListSeller.Name as Account, ListPrice.Name as FType from ListSeller, ListPrice where ListSeller.PriceID=ListPrice.PriceID and SellerID='".$_POST['comment']."' "; $result3 = mysql_query($query3) or die (mysql_error(). " : ".mysql_errno()); $row3=mysql_fetch_object($result3); $message="Trader : ".$superadmnname."\n\n"; $message.="Portfolio : ".$row3->Account." (".$row3->FType.")\n\n"; $message.="Instrument : ".$row->Address."\n\n"; $message.="Identifier : ".$row->Name."\n\n"; $message.="Asset Class : ".$row->Class."\n\n"; $message.="Trade Price : ".$_POST['unitno']."\n\n"; $message.="Trade Size : ".$_POST['unitfloor']." ".$_POST['unitcode']."\n\n"; $message.="Settlement Date : ".$_POST['dateexpiry']."\n\n"; $message.="Counter-Party : ".$rowc->Name."\n\n"; if($_POST['areafull']!=NULL)$message.=">> NOTE : ".$_POST['areafull']." << \n\n"; if($notifybookcash!=0)$message.=">> CASH ADJUSTMENT REQUIRED <<\n\n"; if($notifybookcash!=0) $subject="GXP Booked (FYA) : ".$row3->Account." - $tradetime"; else $subject="GXP Booked : ".$row3->Account." - $tradetime "; mail("wei@kredenscapital.com", $subject, $message, "From: GXP ".$superadmnname." <".$superadmnemail.">"); mail("settlements@kredenscapital.com", $subject, $message, "From: GXP ".$superadmnname." <".$superadmnemail.">"); } }else{ $msg= "Error - Trade booking failed. Contact Settlements Officer"; $msgtype= "error"; } } } //******** end of insert data ******************** //******** end of insert data ******************** print"
";
if($msgtype=='main')
print "$msg"; elseif($msgtype=='error') print "$msg"; else print "$msg"; print " |