/** * Выставяем счет оплаты по безналу * * @param string $type - тип платежа (тут всегда bank) * @param array $data * @return \xajaxResponse */ function quickPaymentBillinvoiceBank($type, $data) { $objResponse =& new xajaxResponse(); $uid = get_uid(false); if ($uid <= 0) { return $objResponse; } $form = new BillInvoiceForm(); if (!$form->isValid($data)) { $params = addslashes(urldecode(http_build_query($form->getAllMessages('<br/>')))); $objResponse->script("\n var qp = window.quick_ext_payment_factory.getQuickPayment('billinvoice');\n if(qp) qp.showElementsError('{$params}');\n "); return $objResponse; } $sum = $form->getValue('sum'); try { $doc = new DocGenBill(); $file = $doc->generateBankInvoice($uid, @$_SESSION['login'], $sum); } catch (Exception $e) { $objResponse->script("\n var qp = quick_ext_payment_factory.getQuickPayment('billinvoice');\n if(qp) qp.show_error('{$e->getMessage()} Попробуйте еще раз.');\n "); return $objResponse; } $link = WDCPREFIX . '/' . $file->path . $file->name; $objResponse->script(" \n \n var template = \$('bill_invoice_template').get('html');\n if(template) {\n template = template.replace('{link}','{$link}');\n template = template.replace('{name}','{$file->original_name}'); \n template = template.replace('{num}','{$doc->getField('id')}'); \n \$('bill_invoice_create').addClass('b-layout_hide'); \n \$('bill_invoice_remove').set('html', template).removeClass('b-layout_hide'); \n }\n \n var qp = quick_ext_payment_factory.getQuickPayment('billinvoice');\n if(qp) qp.close_popup();\n "); return $objResponse; }