So, One of my companies developers wrote this. Not me. Alright, it was me.
How can improve this puke?
$return = array();
$i=0;
foreach ( $prospects AS $key => $p ) {
$name = htmlentities(str_replace("'", "", $p->name));
$name = "<a href=\"/LAND/prospect/" . $p->id . "\" class=\"btn btn-md btn-success btn-block\" ><span class='fa fa-globe' style='padding-right:10px;'></span>".$name."</a>";
$deleteButton = (\Yii::$app->user->can('LAND:DeleteLand')) ?
"<a onclick=\"$('a.deleteClick').attr('href','/LAND/prospect/".$p->id."/delete');\" href=\"#\"
data-id='".$p->id."'
data-object='prospect'
data-toggle=\"modal\"
data-target=\"#confirm-delete\"
class=\"tooltiplink deleteBtn \"
data-original-title=\"Delete\"><span class=\"fa fa-trash-o tool\" style=\"color:red\"></span></a>" : '';
$schoolName = ($p->schoolDistrict) ? "<p><strong>School District:</strong> " . htmlentities($p->schoolDistrict->name) . "</p>": '';
$division = ($p->division) ? "<p><strong>Division:</strong> " . htmlentities($p->division->code) . "</p>": '';
$askingPrice = ($p->askingPrice) ? "<p><strong>Asking: </strong>" . htmlentities(Common::money($p->askingPrice)) . "</p>" : '';
$offerPrice = ($p->offerPrice) ? "<p><strong>Offer: </strong>" . htmlentities(Common::money($p->offerPrice)) . "</p>" : '';
if ($p->homeSites && $p->acreage) {
$homeSites = "<p><strong>" . htmlentities($p->homeSites) . "</strong> projected home sites";
$homeSites .= ($p->acreage && $p->acreage != 0) ? " on <strong>" . htmlentities($p->acreage) . "</strong> acres." : ".";
$homeSites .= "</p>";
} elseif ($p->homeSites && !$p->acreage) {
$homeSites = $homeSites = "<p><strong>" . htmlentities($p->homeSites) . "</strong> projected home sites.</p>";
} elseif ($p->acreage && !$p->homeSites) {
$homeSites = "<p><strong>" . $p->acreage . "</strong> acres.</p>";
} else {
$homeSites = "";
}
$dealProbability = ($p->dealProbability) ? "<p><strong>Probability: </strong>" . htmlentities($p->dealProbability) . "</p>" : '';
$dealStructure = ($p->dealStructure) ? "<p><strong>Deal Structure: </strong>" . htmlentities($p->dealStructure) . "</p>" : '';
$status = htmlentities($p->status);
//$status = "<span class='col-xs-6 pull-left' style='padding-left:0px; text-align:right;'>".htmlentities($p->status)."</span>";
$Owner = "<p><strong>Assigned To</strong> " . htmlentities($p->staff->person->nameFirst . " " . $p->staff->person->nameLast) . "</p>";
$html=<<<HTML
<div id="content" style="min-height:200px;min-width:300px;">
<h5 id="secondHeading" class="col-xs-12 " style="color:#AC0723; min-height:100%; min-width:100%; padding:0px; margin:10px 0px 0px 0px;">{$name} </h5>
<h5 id="thirdHeading" class="col-xs-12" style="color:#AC0723; min-height:100%; min-width:100%; padding:0px; margin:0px 0px 10px 0px; text-align:center;">{$status} {$deleteButton}</h5>
<div id="bodyContent">
{$schoolName}
{$division}
{$askingPrice}{$offerPrice}
{$homeSites}
{$dealProbability}
{$dealStructure}
{$Owner}
</div>
</div>
HTML;
$html = str_replace(array("\r", "\n"), '',$html);
$array['p'] = $p->attributes;
$array['landDeal'] = (isset($p->landDeal)) ? "<a href='/LAND/deal/".$p->landDeal->id."'
class='tooltiplink-deal'
data-original-title='Deal: " .$p->landDeal->name."'>
<span class='fa fa-code-fork'></span></a>" : '';
$array['name'] = $p->name;
$array['schoolName'] = ($p->schoolDistrict) ? substr(str_ireplace("High School", "HS", $p->schoolDistrict->name), 0, 10) : '';
$array['division'] = (isset($p->division)) ? $p->division->code : '';
$array['sites'] = ($p->homeSites) ? $p->homeSites : '0';
$array['acreage'] = ($p->acreage) ? $p->acreage : '0';
$array['offer'] = Common::money($p->offerPrice);
$array['staffName'] = substr($p->staff->person->nameFirst, 0, 1) . $p->staff->person->nameLast;
$array['dealProb'] = ($p['dealProbability'] == '') ? '0%' : $p['dealProbability']."%";
$array['rowLink'] = (\Yii::$app->user->can('LAND:DeleteLand')) ?
"<a href='#'
data-id='$p->id'
data-object='prospect'
data-toggle='modal'
data-target='#confirm-delete'
class='tooltiplink deleteBtn'
data-original-title='Delete'>
<span class='fa fa-trash-o tool' style='color:red'></span></a>" : '';
$array['html'] = $html;
$return[] = $array;
}