/** * Выставяем счет оплаты по безналу * * @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; }
function getFileUrl($file) { if (!$file) { return 0; } return WDCPREFIX . '/' . $file->path . $file->name; } try { if (!$login) { throw new Exception('No login param'); } if (!$sum) { throw new Exception('No sum param'); } $userObj = new users(); $userObj->GetUser($login); if ($userObj->uid <= 0) { throw new Exception("Not find user with login: {$login}"); } $doc = new DocGenBill(); $results['generateBankInvoice'] = getFileUrl($doc->generateBankInvoice($userObj->uid, $login, $sum)); } catch (\Exception $e) { $message = $e->getMessage(); $results['Error Message'] = iconv('cp1251', 'utf-8', $message); } //------------------------------------------------------------------------------ array_walk($results, function (&$value, $key) { $value = sprintf('%s = %s' . PHP_EOL, $key, $value); }); print_r(implode('', $results)); exit;
/** * Сченерировать счет-фактуру. * * @param type $nums * @param type $dates */ public function addFactura($nums, $dates) { require_once ABS_PATH . '/classes/DocGen/DocGenBill.php'; if ($nums) { foreach ($nums as $user_id => $invoices) { foreach ($invoices as $invoice_id => $num) { try { $date = @$dates[$user_id][$invoice_id]; $doc = new DocGenBill(); $doc->generateFactura($invoice_id, $num, $date); } catch (Exception $e) { continue; } } } } }