Price
if ( $ZAAUID > 0 )
{
$curr = strtoupper(substr($SCURR,4));
$ex_query = " SELECT rateyen , rategbp , rateeur , rateyenfixedstk from exrate WHERE exdate <= NOW() ORDER by exdate desc LIMIT 1 ";
$ex_result = pg_query($db,$ex_query);
$ex_line = pg_fetch_array($ex_result, null, PGSQL_ASSOC);
$rateyen = ($ex_line['rateyenfixedstk']/100) ;
$rateyenfixedstk = ($ex_line['rateyenfixedstk']/100) ;
$rategbp = ($ex_line['rategbp']/10000) + 0.0170;
$rateeur = ($ex_line['rateeur']/10000) + 0.0200;
if($curr=='YEN')
$rateyen15 = ($ex_line['rateyenfixedstk']/100);
else
$rateyen15 = ($ex_line['rateyen']/100) ;
if( $line[showsw] == 0 )
print 'Not Set Yet';
else
{
if ( $ZAAAGENTDEF != "FOB" && $ZAAAGENTDEF != "STOCKMSC" && $ZAAAGENTDEF != "STOCKMOL" && $ZAAAGENTDEF != "STOCKHOEGH" && ( $line['place'] == "DB" || $line['place'] == "TG" || $line['place'] == "SG" ) )
{
$agentdef = "STOCKUNIT";
}
else
{
$agentdef = $ZAAAGENTDEF;
}
$sSQL = " SELECT * FROM freight WHERE fplace='$line[place]' AND shipcountry='$ZAACOUNTRY' AND shipportname='$ZAAPORTNAME' AND agentname='$agentdef'";
$result2 = pg_query($db,$sSQL);
if ( $line2 = pg_fetch_array($result2, null, PGSQL_ASSOC) )
{
$baseunder = $line2['baseunder'];
$baseover = $line2['baseover'];
$baf = $line2['baf'];
$ea_freight = $line2['ea_freight'] + $line2['ea_add_freight'];
$frprice_type = $line2['frprice_type'];
}
pg_free_result($result2);
$freight = 0;
if( $SCURR == 'rateyen')
{
if($line['ivcurr'] == 'JPY' && $line['ivsellprice'])
$line['fobpriceyen'] = $line['ivsellprice'];
elseif($line['ivcurr'] == 'USD' && $line['ivsellprice'])
$line['fobpriceyen'] = $line['ivsellprice'] * $rateyenfixedstk ;
elseif($line['fobpriceyen'] == 0 )
$line['fobpriceyen'] = $line['fobpriced'] * $rateyenfixedstk ;
$fobpriced = ($line['fobpriceyen'] + $cpfixedamountup) ;
$fobpriceyen = $fobpriced;
}
else
{
$ex_rate_adj = getExRateAdjust($line['biddingprice'] ,$line['place1'] == 'ZA' ? 'auction' : 'stock' , $exrate_slabs);
$rate_yen_adj = $rateyen15 + $ex_rate_adj;
if($line['ivcurr'] == 'JPY' && $line['ivsellprice'])
$fobpriced = $line['ivsellprice']/$rate_yen_adj;
elseif($line['ivcurr'] == 'USD' && $line['ivsellprice'])
$fobpriced = $line['ivsellprice'];
else
$fobpriced = ($line['fobpriceyen'] + $cpfixedamountup)/$rate_yen_adj;
$fobpriceyen = $fobpriced * $rateyen15;
}
$priceup_percent = getPriceUP($fobpriceyen , $ZAAUPTYPE , $ZAAPRICEUP , $ZAAPRICESLABS);
if($line['ivsellprice'] && $line['ivcurr'])
{
if ( $priceup_percent != 0 )
{
$fobpriced = round(($fobpriced * 100 / (100 + $priceup_percent)));
}
}
if ( $priceup_percent != 0 )
{
$fobpriced = round(((100 + $priceup_percent) * $fobpriced) / 5000) * 50;
}
$fobpriced2 = $fobpriced;
if ( $ZAADISCOUNTTYPE == 1 && $ZAAPERCENTDISCOUNT > 0 )
{
$fobpriced2 = round(((100 - $ZAAPERCENTDISCOUNT) * $fobpriced) / 5000) * 50;
}
if ( $ZAADISCOUNTTYPE == 2 && $ZAAPERUNITDISCOUNT > 0 )
{
$fobpriced2 = $fobpriced - $ZAAPERUNITDISCOUNT;
}
$m3 = $line['carwidth'] /1000.0;
$m3 *= $line['carlength'] /1000.0;
$m3 *= $line['carheight'] /1000.0;
if ( $agentdef == "STOCKMSC")
{
if ( $line['place'] == "DB" || $line['place'] == "TG" || $line['place'] == "SG" )
{
if ( $line['bodytype'] == 1)
{
$freight = $baseunder/100.0 + $baf/100.0;
}
else
{
$freight = $baseover/100.0 + $baf/100.0;
}
}
else
{
if ( $m3 >= 20.0 )
{
$freight = $baseover/100.0 + $baf/100.0;
}
elseif ( $m3 > 0 )
{
$freight = $baseunder/100.0 + $baf/100.0;
}
}
}
elseif ( $agentdef == "STOCKUNIT" || $agentdef == 'TOYOFUJI' )
{
if ( $m3 >= 20.0 )
$freight = ($baseover/100.0 ) ;
else
$freight = ($baseunder/100.0 ) ;
}
elseif ( $agentdef != "FOB" )
{
if($line['place1'] == "ED" || $line['place1'] == "EA" )
{
$freight = $ea_freight;
}
elseif ( $m3 > 0.0 && ($baseunder > 0 || $baseover > 0 ))
{
if ( $m3 >= 20.0 )
$freight = ($baseover/100.0 ) * $m3 + $baf/100.0 ;
else
$freight = ($baseunder/100.0 ) * $m3 + $baf/100.0 ;
}
}
$freight = round($freight/10.0) * 10;
if($frprice_type == 1)
{
$freight = $freight / $rateyenfixedstk;
}
if( $SCURR == 'rateyen')
$fobpriced = $fobpriced / $rateyen;
if ( !($ZAAWITHOUTPRICE == 1) && $line['deletedate'] == null )
{
if ( $freight > 0 )
{
echo "C&F ";//"(USD) : ";
$car_price = $fobpriced + $freight ;
if ( $fobpriced2 < $fobpriced )
{
$car_price = $fobpriced2 + $freight ;
}
}
else
{
echo "FOB ";//(USD) :";
$car_price = $fobpriced ;
if ( $fobpriced2 < $fobpriced )
{
$car_price = $fobpriced2 ;
}
}
}
}
}
?> |
$sSQL_price = " SELECT estsale , acsoldprice FROM soldreport WHERE soldcarid = '".$line['carid']."' ";
$result_price = pg_query($db,$sSQL_price) or die(pg_last_error());
$line_price = pg_fetch_array($result_price, null, PGSQL_ASSOC);
if($line_price[estsale] > 0)
$car_price = " PKR ".number_format($line_price[estsale])." ";
elseif($line_price[pkr_price] > 0)
$car_price = " PKR ".number_format($line[pkr_price])." ";
print $car_price;
?>
|