[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); 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(){ public function pdf(){
$html_inner = ''; $html_inner = '';
$marketplace_type = $this->request->param('MARKETPLACETYPE'); $marketplace_type = $this->request->param('MARKETPLACETYPE');
@ -1138,7 +1169,6 @@ class MarketPlaceAdminPage_Controller extends Page_Controller
//create pdf //create pdf
$file = FileUtils::convertToFileName('preview') . '.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>", $html_outer = sprintf("<html><head><style>%s</style></head><body><div class='container'>%s</div></body></html>",
str_replace("@host", $base, $css),$html_inner); str_replace("@host", $base, $css),$html_inner);

View File

@ -23,7 +23,10 @@ class ConsultantsDirectoryPage extends MarketPlaceDirectoryPage
*/ */
class ConsultantsDirectoryPage_Controller extends MarketPlaceDirectoryPage_Controller { class ConsultantsDirectoryPage_Controller extends MarketPlaceDirectoryPage_Controller {
private static $allowed_actions = array('handleIndex');
static $allowed_actions = array(
'getCurrentOfficesLocationsJson',
);
/** /**
* @var IEntityRepository * @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(){ public function draw(){
Requirements::css("marketplace/code/ui/frontend/css/marketplace.css"); 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"); Requirements::javascript("marketplace/code/ui/frontend/js/consultant.page.js");
$services = $this->consultant->getServicesOffered(); $services = $this->consultant->getServicesOffered();
$unique_services = array(); $unique_services = array();

View File

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

View File

@ -6,127 +6,127 @@
<h1>$Name</h1> <h1>$Name</h1>
</div> </div>
</div> </div>
<% loop Consultant %> <% control Consultant %>
<div class="container marketplace-content"> <div class="container marketplace-content">
<% include MarketPlaceCompany %> <% include MarketPlaceCompany %>
<div class="col-lg-6"> <div class="col-lg-6">
<div class="info-area"> <div class="info-area">
<% if ExpertiseAreas %> <% if ExpertiseAreas %>
<h3 style="color: #{$Company.CompanyColor} !important;">Areas of OpenStack Expertise</h3> <h3 style="color: #{$Company.CompanyColor} !important;">Areas of OpenStack Expertise</h3>
<table> <table>
<tbody> <tbody>
<% loop ExpertiseAreas %> <% control ExpertiseAreas %>
<tr>
<td>$Name</td>
<td>$CodeName</td>
</tr>
<% end_loop %>
</tbody>
</table>
<% end_if %>
<% if Top.Services %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Services Offered</h3>
<ul>
<% loop Top.Services %>
<li>$Type</li>
<% end_loop %>
</ul>
<% end_if %>
<% if PreviousClients %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Select Clients</h3>
<ul>
<% loop PreviousClients %>
<li>$Name</li>
<% end_loop %>
</ul>
<% end_if %>
<% if ConfigurationManagementExpertises %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Configuration Management Expertise</h3>
<ul>
<% loop ConfigurationManagementExpertises %>
<li>$Type</li>
<% end_loop %>
</ul>
<% end_if %>
<% if SpokenLanguages %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Languages</h3>
<ul>
<% loop SpokenLanguages %>
<li>$Name</li>
<% end_loop %>
</ul>
<% end_if %>
<% if Top.Regions %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Regions with local offices</h3>
<ul>
<% loop Top.Regions %>
<li>$Name</li>
<% end_loop %>
</ul>
<% end_if %>
<% if Offices %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Offices</h3>
<script type="text/javascript">
var offices_instance = $Top.CurrentOfficesLocationsJson;
</script>
<div style="width: 300px; height: 200px; position: relative;" id="mini-map" tabindex="0">
</div>
<p>
Click any map pin to see office address
</p>
<% end_if %>
<% if RegionalSupports %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Regions where support is offered</h3>
<table class="regions">
<tbody>
<% loop RegionalSupports %>
<tr> <tr>
<% with Region %>
<td>$Name</td> <td>$Name</td>
<% end_with %> <td>$CodeName</td>
</tr> </tr>
<% end_loop %> <% end_control %>
</tbody> </tbody>
</table> </table>
<% end_if %>
<% if Top.Services %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Services Offered</h3>
<ul>
<% control Top.Services %>
<li>$Type</li>
<% end_control %>
</ul>
<% end_if %>
<% if PreviousClients %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Select Clients</h3>
<ul>
<% control PreviousClients %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if ConfigurationManagementExpertises %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Configuration Management Expertise</h3>
<ul>
<% control ConfigurationManagementExpertises %>
<li>$Type</li>
<% end_control %>
</ul>
<% end_if %>
<% if SpokenLanguages %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Languages</h3>
<ul>
<% control SpokenLanguages %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if Top.Regions %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Regions with local offices</h3>
<ul>
<% control Top.Regions %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if Offices %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Offices</h3>
<script type="text/javascript">
var offices_instance = $Top.CurrentOfficesLocationsJson;
</script>
<div style="width: 300px; height: 200px; position: relative;" id="mini-map" tabindex="0">
</div>
<p>
Click any map pin to see office address
</p>
<% end_if %>
<% if RegionalSupports %>
<hr>
<h3 style="color: #{$Company.CompanyColor} !important;">Regions where support is offered</h3>
<table class="regions">
<tbody>
<% control RegionalSupports %>
<tr>
<% control Region %>
<td>$Name</td>
<% end_control %>
</tr>
<% end_control %>
</tbody>
</table>
<% end_if %>
</div>
</div>
<div class="col-lg-6">
<% if IsPreview %>
<% include MarketPlaceDirectoryPage_Rating_Placeholder %>
<% else %>
<% include MarketPlaceDirectoryPage_Rating %>
<% end_if %> <% end_if %>
<% if Videos %>
<div id="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_control %>
</div>
<% end_if %>
<% if Resources %>
<div id="more-resources">
<h3 style="color: #{$Company.CompanyColor} !important;">More Resources</h3>
<ul>
<% control Resources %>
<li><a href="{$Uri}" style="color: #{$Company.CompanyColor} !important;" class="outbound-link" target="_blank">$Name</a></li>
<% end_control %>
</ul>
</div>
<% end_if %>
</div> </div>
</div> </div>
<div class="col-lg-6">
<% if IsPreview %>
<% include MarketPlaceDirectoryPage_Rating_Placeholder %>
<% else %>
<% include MarketPlaceDirectoryPage_Rating %>
<% end_if %>
<% if Videos %>
<div id="videos">
<% loop 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 %>
</div>
<% end_if %>
<% if Resources %>
<div id="more-resources">
<h3 style="color: #{$Company.CompanyColor} !important;">More Resources</h3>
<ul>
<% loop Resources %>
<li><a href="{$Uri}" style="color: #{$Company.CompanyColor} !important;" class="outbound-link" target="_blank">$Name</a></li>
<% end_loop %>
</ul>
</div>
<% end_if %>
</div> </div>
</div> <% end_control %>
</div>
<% end_loop %>

View File

@ -2,34 +2,111 @@
<h1>$Name</h1> <h1>$Name</h1>
</div> </div>
<% control Consultant %> <% control Consultant %>
<div class="container marketplace-content"> <div class="container marketplace-content">
<table width="540px"> <table width="540px">
<tr> <tr>
<td rowspan="5" valign="top" style="width:140px;padding-right:15px"> <td rowspan="5" valign="top" style="width:140px;padding-right:15px">
$Company.SmallLogoPreview(150) $Company.SmallLogoPreview(150)
<h2 style="color: {$Company.CompanyColorRGB} !important;">About $Company.Name</h2> <h2 style="color: {$Company.CompanyColorRGB} !important;">About $Company.Name</h2>
<p>$Company.Overview</p> <p>$Company.Overview</p>
<hr> <hr>
<div class="pullquote"> <div class="pullquote">
<h2 style="color: {$Company.CompanyColorRGB} !important;">$Company.Name Commitment</h2> <h2 style="color: {$Company.CompanyColorRGB} !important;">$Company.Name Commitment</h2>
<div <% if Company.CommitmentAuthor %>class="commitment"<% end_if %>>$Company.Commitment</div> <div <% if Company.CommitmentAuthor %>class="commitment"<% end_if %>>$Company.Commitment</div>
<% if Company.CommitmentAuthor %> <% if Company.CommitmentAuthor %>
<p class="author">&mdash;$Company.CommitmentAuthor, $Company.Name</p> <p class="author">&mdash;$Company.CommitmentAuthor, $Company.Name</p>
<% end_if %>
</div>
</td>
<td colspan="2" valign="top" style="width:400px;padding-left:15px;">
<div class="info-area">
<h1 style="color: {$Company.CompanyColorRGB} !important;">
$Name
</h1>
<p>$Overview</p>
</div>
</td>
</tr>
<tr>
<td valign="top" style="width:200px;padding-left:15px;">
<div class="info-area">
<% if PreviousClients %>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Select Clients</h3>
<ul>
<% control PreviousClients %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if ConfigurationManagementExpertises %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Configuration Management Expertise</h3>
<ul>
<% control ConfigurationManagementExpertises %>
<li>$Type</li>
<% end_control %>
</ul>
<% end_if %>
<% if SpokenLanguages %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Languages</h3>
<ul>
<% control SpokenLanguages %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if Top.Regions %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Regions with local offices</h3>
<ul>
<% control Top.Regions %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if Offices %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Offices</h3>
<div style="width: 300px; height: 200px; position: relative;" tabindex="0">
<img src="$Top.CurrentOfficesLocationsStaticMapForPDF" />
</div>
<p>
Click any map pin to see office address
</p>
<% end_if %>
<% if RegionalSupports %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Regions where support is offered</h3>
<table class="regions">
<tbody>
<% control RegionalSupports %>
<tr>
<% control Region %>
<td>$Name</td>
<% end_control %>
</tr>
<% end_control %>
</tbody>
</table>
<% end_if %>
</div>
</td>
<td valign="top" style="width:200px;padding-left:15px;padding-right:15px">
<% if ExpertiseAreas %>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Areas of OpenStack Expertise</h3>
<table>
<tbody>
<% control ExpertiseAreas %>
<tr>
<td>$Name</td>
<td>$CodeName</td>
</tr>
<% end_control %>
</tbody>
</table>
<hr>
<% end_if %> <% end_if %>
</div>
</td>
<td colspan="2" valign="top" style="width:400px;padding-left:15px;">
<div class="info-area">
<h1 style="color: {$Company.CompanyColorRGB} !important;">
$Name
</h1>
<p>$Overview</p>
</div>
</td>
</tr>
<tr>
<td valign="top" style="width:200px;padding-left:15px;">
<div class="info-area">
<% if Top.Services %> <% if Top.Services %>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Services Offered</h3> <h3 style="color: #{$Company.CompanyColorRGB} !important;">Services Offered</h3>
<ul> <ul>
@ -37,118 +114,41 @@
<li>$Type</li> <li>$Type</li>
<% end_control %> <% end_control %>
</ul> </ul>
<% end_if %>
<% if PreviousClients %>
<hr> <hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Select Clients</h3>
<ul>
<% control PreviousClients %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if ConfigurationManagementExpertises %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Configuration Management Expertise</h3>
<ul>
<% control ConfigurationManagementExpertises %>
<li>$Type</li>
<% end_control %>
</ul>
<% end_if %>
<% if SpokenLanguages %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Languages</h3>
<ul>
<% control SpokenLanguages %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if Top.Regions %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Regions with local offices</h3>
<ul>
<% control Top.Regions %>
<li>$Name</li>
<% end_control %>
</ul>
<% end_if %>
<% if Offices %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Offices</h3>
<div style="width: 300px; height: 200px; position: relative;" tabindex="0">
<img src="$Top.CurrentDataCenterStaticMapForPDF" />
</div>
<p>
Click any map pin to see office address
</p>
<% end_if %>
<% if RegionalSupports %>
<hr>
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Regions where support is offered</h3>
<table class="regions">
<tbody>
<% control RegionalSupports %>
<tr>
<% control Region %>
<td>$Name</td>
<% end_control %>
</tr>
<% end_control %>
</tbody>
</table>
<% end_if %>
<% end_if %> <% end_if %>
</div> <div id="reviews" style="min-height: 400px;">
</td> <h3 style="color: {$Company.CompanyColorRGB} !important;">Reviews</h3>
<td valign="top" style="width:200px;padding-left:15px;padding-right:15px"> <p>* No Reviews available on preview mode.</p>
<% if ExpertiseAreas %> <!--This script should be places anywhere on a page you want to see rating box-->
<h3 style="color: #{$Company.CompanyColorRGB} !important;">Areas of OpenStack Expertise</h3> <div style='font-size:10px'>Powered by Rating-System.com</div>
<table> <!-- DO NOT REMOVE THE LAST LINE, please contact us first if you need to do it -->
<tbody>
<% control ExpertiseAreas %>
<tr>
<td>$Name</td>
<td>$CodeName</td>
</tr>
<% end_control %>
</tbody>
</table>
<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>
<!--This script should be places anywhere on a page you want to see rating box-->
<div style='font-size:10px'>Powered by Rating-System.com</div>
<!-- DO NOT REMOVE THE LAST LINE, please contact us first if you need to do it -->
</div>
<% if Videos %>
<hr>
<div id="videos">
<% control Videos %>
<h3 style="color: {$Top.Company.CompanyColorRGB} !important;" class="video-title">$Name<span class="video-duration">($FormattedLength)</span></h3>
<a href="//www.youtube.com/embed/{$YouTubeId}"> Video </a>
<% end_control %>
</div>
<% end_if %>
<% if Resources %>
<hr>
<div id="more-resources">
<h3 style="color: {$Company.CompanyColorRGB} !important;">More Resources</h3>
<ul>
<% control Resources %>
<li style="color: {$Company.CompanyColorRGB}>$Name</li>
<% end_control %>
</ul>
</div> </div>
<% end_if %> <% if Videos %>
</td> <hr>
</tr> <div id="videos">
<tr><td></td><td></td></tr> <% control Videos %>
<tr><td></td><td></td></tr> <h3 style="color: {$Top.Company.CompanyColorRGB} !important;" class="video-title">$Name<span class="video-duration">($FormattedLength)</span></h3>
<tr><td></td><td></td></tr> <a href="//www.youtube.com/embed/{$YouTubeId}"> Video </a>
<tr><td></td><td></td></tr> <% end_control %>
</table> </div>
</div> <% end_if %>
<% if Resources %>
<hr>
<div id="more-resources">
<h3 style="color: {$Company.CompanyColorRGB} !important;">More Resources</h3>
<ul>
<% control Resources %>
<li style="color: {$Company.CompanyColorRGB}>$Name</li>
<% end_control %>
</ul>
</div>
<% end_if %>
</td>
</tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
<tr><td></td><td></td></tr>
</table>
</div>
<% end_control %>