Приветствую. Сделал массовую печать в PDF из списка для кастомных модулей, также решил сделать это для печати счетов. Внес изменения по инструкции Bulk Print to pdf custom module . Но для модуля AOS_Invoices не выгружается вся информация в шаблон PDF при выгрузке из списка.
В теме Invoice Print as pdf from list view указано, что это не сложно, нужно просто в папку custom/modules/AOS_PDF_Templates добавить formLetterPdf.php.
Got this working as i wanted, Actually was a lot simpler than I thought
By creating a custom formLetterPdf.php I can now mass print invoices from the list view with all relationship data B)
Я это сделал, после чего создал entry_point. custom/Extension/application/Ext/EntryPointRegistry/formLetter.php:
$_REQUEST[‘current_post’] содержит с id записей, которые надо печатать ИЛИ $_REQUEST[‘uid’] содержит список через запятую id записей, которые надо печатать
Такое впечатление, что номера id не соответствуют модулю.
Я обычно вывожу информацию в лог. В данном случае значение уровень легирования должно быть равно fatal
Посмотрите метод parse_template_bean в файле modules/AOS_PDF_Templates/templateParser.php именно он заменяет имя поля на данные. Он не берет данные из связанных объектов. Возможно, вместо formLetterPdf.php за основу стоит взять generatePdf.php, там уже присутствует анализ связанного модуля AOS_Line_Item_Groups.
Складывается впечатление, что не line items подключено не в formLetterPdf.php, а ранее - например в view.list.php или AOS_InvoicesListViewSmarty.php:
/custom/modules/AOS_Invoices/views/view.list.php (с <?php в начале):
require_once('include/MVC/View/views/view.list.php');
require_once('modules/AOS_Invoices/AOS_InvoicesListViewSmarty.php');
class AOS_InvoicesViewList extends ViewList
{
/**
* @see ViewList::preDisplay()
*/
public function preDisplay()
{
require_once('modules/AOS_PDF_Templates/formLetter.php');
formLetter::LVPopupHtml('AOS_Invoices');
parent::preDisplay();
$this->lv = new ContactsListViewSmarty();
}
}
/custom/modules/AOS_Invoices/AOS_InvoicesListViewSmarty.php (с <?php в начале):
require_once('include/ListView/ListViewSmarty.php');
require_once('modules/AOS_PDF_Templates/formLetter.php');
class AOS_InvoicesListViewSmarty extends ListViewSmarty
{
public function __construct()
{
parent::__construct();
$this->targetList = true;
}
/**
* @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
*/
public function AOS_InvoicesListViewSmarty()
{
$deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
if (isset($GLOBALS['log'])) {
$GLOBALS['log']->deprecated($deprecatedMessage);
} else {
trigger_error($deprecatedMessage, E_USER_DEPRECATED);
}
self::__construct();
}
/**
*
* @param file $file Template file to use
* @param array $data from ListViewData
* @param string $htmlVar the corresponding html public in xtpl per row
* @return bool|void
*/
public function process($file, $data, $htmlVar)
{
$configurator = new Configurator();
if ($configurator->isConfirmOptInEnabled()) {
$this->actionsMenuExtraItems[] = $this->buildSendConfirmOptInEmailToPersonAndCompany();
}
$ret = parent::process($file, $data, $htmlVar);
if (!ACLController::checkAccess($this->seed->module_dir, 'export', true) || !$this->export) {
$this->ss->assign('exportLink', $this->buildExportLink());
}
return $ret;
}
public function buildExportLink($id = 'export_link')
{
global $app_strings;
global $sugar_config;
$script = "";
if (ACLController::checkAccess($this->seed->module_dir, 'export', true)) {
if ($this->export) {
$script = parent::buildExportLink($id);
}
}
$script .= "<a href='javascript:void(0)' id='map_listview_top' " .
" onclick=\"return sListView.send_form(true, 'jjwg_Maps', " .
"'index.php?entryPoint=jjwg_Maps&display_module={$_REQUEST['module']}', " .
"'{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_MAP']}</a>";
return formLetter::LVSmarty().$script;
}
}
Нет. Все делает formLetterPdf.php и templateParser.php, получая на входе название модуля и список его id, для которых надо собрать pdf файлы на основе соответствующего шаблона. В view.list.php формируется только экранная форма вывода.
templateParser.php не учитывает связи модуля с другими модулями. templateParser.php будет нормально работать только если в шаблоне pdf используются только поля текущего модуля. generatePdf.php как раз учитывает связь именно с модулем AOS_Line_Item_Groups.