[spalenque] - #6968 *pdfs bug

Conflicts:

	marketplace/code/ui/frontend/ConsultantsDirectoryPage.php
	marketplace/templates/Layout/ConsultantsDirectoryPage_consultant.ss
This commit is contained in:
santipalenque 2014-10-27 20:24:05 -03:00 committed by Sebastian Marcet
parent b70162348b
commit 1fb147c59a
7 changed files with 333 additions and 259 deletions

View File

@ -1077,6 +1077,37 @@ class MarketPlaceAdminPage_Controller extends Page_Controller
return CloudViewModel::getEnabledPricingSchemas($cloud);
}
public function getCurrentOfficesLocationsJson()
{
$instance_id = intval($this->request->param('ID'));
$query = new QueryObject();
$query->addAddCondition(QueryCriteria::equal('ID', $instance_id));
$consultant = $this->consultant_repository->getBy($query);
if (!$consultant) throw new NotFoundEntityException('', '');
return ConsultantViewModel::getOfficesLocationsJson($consultant);
}
public function getCurrentOfficesLocationsStaticMapForPDF()
{
$static_map_url = "http://maps.googleapis.com/maps/api/staticmap?zoom=2&size=300x200&maptype=roadmap";
$instance_id = intval($this->request->param('ID'));
$query = new QueryObject();
$query->addAddCondition(QueryCriteria::equal('ID', $instance_id));
$consultant = $this->consultant_repository->getBy($query);
if (!$consultant) throw new NotFoundEntityException('', '');
$locations = json_decode(ConsultantViewModel::getOfficesLocationsJson($consultant));
foreach ($locations as $loc) {
$static_map_url .= "&markers=".$loc->lat.",".$loc->lng;
}
return $static_map_url;
}
public function pdf(){
$html_inner = '';
$marketplace_type = $this->request->param('MARKETPLACETYPE');
@ -1138,7 +1169,6 @@ class MarketPlaceAdminPage_Controller extends Page_Controller
//create pdf
$file = FileUtils::convertToFileName('preview') . '.pdf';
//$html_inner = $this->customise(array('BASEURL' => Director::protocolAndHost()))->renderWith("UserStoryPDF");
$html_outer = sprintf("<html><head><style>%s</style></head><body><div class='container'>%s</div></body></html>",
str_replace("@host", $base, $css),$html_inner);

View File

@ -23,7 +23,10 @@ class ConsultantsDirectoryPage extends MarketPlaceDirectoryPage
*/
class ConsultantsDirectoryPage_Controller extends MarketPlaceDirectoryPage_Controller {
private static $allowed_actions = array('handleIndex');
static $allowed_actions = array(
'getCurrentOfficesLocationsJson',
);
/**
* @var IEntityRepository
*/

View File

@ -0,0 +1,35 @@
<?php
/**
* Class ConsultantViewModel
*/
final class ConsultantViewModel {
public static function getOfficesLocationsJson(IConsultant $consultant){
$res = array();
$color = strtoupper(dechex(rand(0,10000000)));
$office_index = 1;
foreach($consultant->getOffices() as $office){
$data_office = array();
$data_office['color'] = is_null($consultant->getCompany()->Color)?$color:$consultant->getCompany()->Color;
$address = $office->getAddress();
$data_office['address'] = '';
if(!empty($address))
$data_office['address'] = trim($address.' '.$office->getAddress1());
$state = $office->getState();
if(!empty($state)){
$data_office['address'] .= ', '.$state;
}
$data_office['address'] .=((empty($data_office['address']))?'': ', ').$office->getCity();
$data_office['address'] .= ', '.$office->getCountry();
$data_office['lat'] = $office->getLat();
$data_office['lng'] = $office->getLng();
$data_office['owner'] = $consultant->getName();
$data_office['name'] = sprintf('Office #%s',$office_index);
++$office_index;
array_push($res,$data_office);
}
return json_encode($res);
}
}

View File

@ -22,6 +22,12 @@ final class ConsultantSapphireRender {
public function draw(){
Requirements::css("marketplace/code/ui/frontend/css/marketplace.css");
Requirements::javascript(Director::protocol() . "maps.googleapis.com/maps/api/js?sensor=false");
Requirements::javascript("marketplace/code/ui/admin/js/utils.js");
Requirements::javascript("marketplace/code/ui/frontend/js/markerclusterer.js");
Requirements::javascript("marketplace/code/ui/frontend/js/oms.min.js");
Requirements::javascript("marketplace/code/ui/frontend/js/infobubble-compiled.js");
Requirements::javascript("marketplace/code/ui/frontend/js/google.maps.jquery.js");
Requirements::javascript("marketplace/code/ui/frontend/js/consultant.page.js");
$services = $this->consultant->getServicesOffered();
$unique_services = array();

View File

@ -73,7 +73,7 @@
<% end_control %>
</p>
<div style="width: 300px; height: 200px; position: relative;" tabindex="0">
<img src="$Top.getCurrentOfficesStaticMapForPDF" />
<img src="$Top.CurrentDataCenterStaticMapForPDF" />
</div>
<p>Click any location to see availability zones and API endpoints</p>
<% end_if %>

View File

@ -6,7 +6,7 @@
<h1>$Name</h1>
</div>
</div>
<% loop Consultant %>
<% control Consultant %>
<div class="container marketplace-content">
<% include MarketPlaceCompany %>
<div class="col-lg-6">
@ -15,12 +15,12 @@
<h3 style="color: #{$Company.CompanyColor} !important;">Areas of OpenStack Expertise</h3>
<table>
<tbody>
<% loop ExpertiseAreas %>
<% control ExpertiseAreas %>
<tr>
<td>$Name</td>
<td>$CodeName</td>
</tr>
<% end_loop %>
<% end_control %>
</tbody>
</table>
<% end_if %>
@ -28,45 +28,45 @@
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Services Offered</h3>
<ul>
<% loop Top.Services %>
<% control Top.Services %>
<li>$Type</li>
<% end_loop %>
<% end_control %>
</ul>
<% end_if %>
<% if PreviousClients %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Select Clients</h3>
<ul>
<% loop PreviousClients %>
<% control PreviousClients %>
<li>$Name</li>
<% end_loop %>
<% end_control %>
</ul>
<% end_if %>
<% if ConfigurationManagementExpertises %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Configuration Management Expertise</h3>
<ul>
<% loop ConfigurationManagementExpertises %>
<% control ConfigurationManagementExpertises %>
<li>$Type</li>
<% end_loop %>
<% end_control %>
</ul>
<% end_if %>
<% if SpokenLanguages %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Languages</h3>
<ul>
<% loop SpokenLanguages %>
<% control SpokenLanguages %>
<li>$Name</li>
<% end_loop %>
<% end_control %>
</ul>
<% end_if %>
<% if Top.Regions %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Regions with local offices</h3>
<ul>
<% loop Top.Regions %>
<% control Top.Regions %>
<li>$Name</li>
<% end_loop %>
<% end_control %>
</ul>
<% end_if %>
<% if Offices %>
@ -86,13 +86,13 @@
<h3 style="color: #{$Company.CompanyColor} !important;">Regions where support is offered</h3>
<table class="regions">
<tbody>
<% loop RegionalSupports %>
<% control RegionalSupports %>
<tr>
<% with Region %>
<% control Region %>
<td>$Name</td>
<% end_with %>
<% end_control %>
</tr>
<% end_loop %>
<% end_control %>
</tbody>
</table>
<% end_if %>
@ -106,12 +106,12 @@
<% end_if %>
<% if Videos %>
<div id="videos">
<% loop Videos %>
<% control Videos %>
<h3 style="color: #{$Top.Company.CompanyColor} !important;" class="video-title">$Name<span class="video-duration">($FormattedLength)</span></h3>
<iframe frameborder="0" width="250" height="200" allowfullscreen=""
src="//www.youtube.com/embed/{$YouTubeId}?rel=0&amp;showinfo=0&amp;modestbranding=1&amp;controls=2">
</iframe>
<% end_loop %>
<% end_control %>
</div>
<% end_if %>
@ -119,9 +119,9 @@
<div id="more-resources">
<h3 style="color: #{$Company.CompanyColor} !important;">More Resources</h3>
<ul>
<% loop Resources %>
<% control Resources %>
<li><a href="{$Uri}" style="color: #{$Company.CompanyColor} !important;" class="outbound-link" target="_blank">$Name</a></li>
<% end_loop %>
<% end_control %>
</ul>
</div>
<% end_if %>
@ -129,4 +129,4 @@
</div>
</div>
</div>
<% end_loop %>
<% end_control %>

View File

@ -30,16 +30,7 @@
<tr>
<td valign="top" style="width:200px;padding-left:15px;">
<div class="info-area">
<% if Top.Services %>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Services Offered</h3>
<ul>
<% control Top.Services %>
<li>$Type</li>
<% end_control %>
</ul>
<% end_if %>
<% if PreviousClients %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Select Clients</h3>
<ul>
<% control PreviousClients %>
@ -78,7 +69,7 @@
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Offices</h3>
<div style="width: 300px; height: 200px; position: relative;" tabindex="0">
<img src="$Top.CurrentDataCenterStaticMapForPDF" />
<img src="$Top.CurrentOfficesLocationsStaticMapForPDF" />
</div>
<p>
Click any map pin to see office address
@ -99,7 +90,6 @@
</tbody>
</table>
<% end_if %>
<% end_if %>
</div>
</td>
<td valign="top" style="width:200px;padding-left:15px;padding-right:15px">
@ -117,6 +107,15 @@
</table>
<hr>
<% end_if %>
<% if Top.Services %>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Services Offered</h3>
<ul>
<% control Top.Services %>
<li>$Type</li>
<% end_control %>
</ul>
<hr>
<% end_if %>
<div id="reviews" style="min-height: 400px;">
<h3 style="color: {$Company.CompanyColorRGB} !important;">Reviews</h3>
<p>* No Reviews available on preview mode.</p>
@ -152,3 +151,4 @@
<tr><td></td><td></td></tr>
</table>
</div>
<% end_control %>