Created
May 12, 2016 15:38
-
-
Save betobaz/fd482ce43b0984fb446bf45a80daf361 to your computer and use it in GitHub Desktop.
SugarCRM::Custom PDF add variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); | |
/* | |
* Your installation or use of this SugarCRM file is subject to the applicable | |
* terms available at | |
* http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/. | |
* If you do not agree to all of the applicable terms or do not have the | |
* authority to bind the entity as an authorized representative, then do not | |
* install or use this SugarCRM file. | |
* | |
* Copyright (C) SugarCRM Inc. All rights reserved. | |
*/ | |
require_once('custom/include/Sugarpdf/sugarpdf/sugarpdf.pdfmanager.php'); | |
class QuotesSugarpdfPdfmanager extends SugarpdfPdfmanager{ | |
public function preDisplay() | |
{ | |
parent::preDisplay(); | |
global $timedate, $current_user; | |
$this->SetAutoPageBreak(TRUE, 35); | |
$this->setPrintHeader(true); | |
$this->setPrintFooter(true); // always print page number at least | |
$fecha_cotizacion_c_formateado = ""; | |
if($this->bean->fecha_cotizacion_c){ | |
$fecha_cotizacion_c_date = $timedate->fromUserDate($this->bean->fecha_cotizacion_c, false, $current_user); | |
$mes = $fecha_cotizacion_c_date->format('n'); | |
$GLOBALS['log']->fatal('SugarpdfPdfmanager::mes: ' . $mes); | |
$mes = $app_list_strings['dom_cal_month_long'][$mes]; | |
$dia = $fecha_cotizacion_c_date->format('d'); | |
$anio = $fecha_cotizacion_c_date->format('Y'); | |
$fecha_cotizacion_c_formateado = "León Guanajuato; $dia de $mes de $anio"; | |
} | |
$GLOBALS['log']->fatal('SugarpdfPdfmanager::fecha_cotizacion_c_formateado: ' . $fecha_cotizacion_c_formateado); | |
$this->ss->assign('fecha_cotizacion_c_formateado', $fecha_cotizacion_c_formateado); | |
$this->bean->load_relationship('product_bundles'); | |
$product_bundles = $this->bean->product_bundles->getBeans(); | |
$this->ss->assign('productos_servicio_table', $this->getProductosServicioTable($product_bundles)); | |
} | |
private function getProductosServicioTable(&$product_bundles){ | |
$table = ""; | |
if(count($product_bundles) > 1){ | |
$table = <<<HTML | |
<table border><tbody> | |
<tr> | |
<td width="400" >Equipo</td> | |
<td width="200" >Serie</td> | |
<td width="200" >Parte</td> | |
<td width="200" >MRE</td> | |
</tr> | |
HTML; | |
foreach($product_bundles as $product_bundle){ | |
if($product_bundle->product_id_c){ | |
$product = BeanFactory::getBean('Products', $product_bundle->product_id_c); | |
$product_bundle->product__name = $product->name; | |
$product_bundle->product__serial_number = $product->serial_number; | |
$product_bundle->product__mft_part_num = $product->mft_part_num; | |
$product_bundle->product__emr_c = $product->emr_c; | |
$table .= <<<HTML | |
<tr> | |
<td width="400" >$product->name</td> | |
<td width="200" >$product->serial_number</td> | |
<td width="200" >$product->mft_part_num</td> | |
<td width="200" >$product->emr_c</td> | |
</tr> | |
HTML; | |
} | |
} | |
$table .= "</tbody></table>"; | |
} | |
else{ | |
$product_bundle = array_shift(array_slice($product_bundles,0, 1)); | |
$product = BeanFactory::getBean('Products', $product_bundle->product_id_c); | |
$table = <<<HTML | |
<table> | |
<tr> | |
<td>{$product->name}</td> | |
</tr> | |
<tr> | |
<td>Serie: <b>{$product->serial_number}</b> Parte: <b>{$product->mft_part_num}</b> EMR:<b>{$product->emr_c}</b></td> | |
</tr> | |
<tr> | |
<td>Fecha de último servicio: <b>{$product->f_ultimo_servicio_c}</b> Horas de trabajo:<b>{$product->horas_totales_c}</b></td> | |
</tr> | |
</table> | |
HTML; | |
} | |
return $table; | |
} | |
/*private function _initSmartyInstance(){ | |
if ( !($this->ss instanceof Sugar_Smarty) ) { | |
$this->ss = new Sugar_Smarty(); | |
// TODO: Remove after MAR-1064 is merged. | |
// Enable enhanced security for user-provided templates. This | |
// includes disabling the {php} Smarty tag. | |
$this->ss->security = true; | |
$this->ss->assign('MOD', $GLOBALS['mod_strings']); | |
$this->ss->assign('APP', $GLOBALS['app_strings']); | |
} | |
}*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment