Legosp Forum
Shop-Script "Legosp" => Общие вопросы => Тема начата: rom1 от Ноября 15, 2012, 04:52:24 pm
-
Делаю под себя форму ПД4 за основу взяв print_tov.php и соответствующий шаблон.
Всё легко и отлично, кроме формирования суммы заказа (итоговой).
Как я понял в товарном чеке выводится список всех товаров, их количество, всё это суммируется и получается итоговая сумма.
В моей ПД4 мне выводить товары не нужно, соответственно я этот расчет не могу получить.
Как мне вытащить итоговую сумму заказа в этом случае?
-
под какую версию?
зы/ все же: пд4 или принт_тов? с чего ваяете?
-
502
-
ну а такой "изврат" ::) :
[spoiler]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ТОВАРНЫЙ ЧЕК</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<link rel="stylesheet" href="printforms/printforms.css" type="text/css" />
<script type="text/javascript">
var lang_strings = {
'edit_link':'Корректировка перед печатью',
'field_title':'Двойной клик для редактирования',
'save_link':'OK'
}
var page_url = 'form_id=340';
</script>
<script type="text/javascript" src="printforms/inline_edit_printform.js"></script>
</head>
<body onLoad="Printform.init('inline_edit');">
<form action="" class="noprint">
<input id="print_button" type="button" value="Печать" alt="Печать" title="Печать" onClick="window.print();return false;"/>
</form>
<table cellpadding="0" cellspacing="5" border="0" width="640" align="center">
<tr>
<td align="right" width="70" valign="top"><strong>Поставщик:</strong></td>
<td align="left">
{$smarty.const.COMPANY_NAME}<BR>
{$smarty.const.COMPANY_ADDRESS}<BR>
Тел. {$smarty.const.COMPANY_PHONE}<BR>
р/счет №{$smarty.const.COMPANY_RS}<br>
в {$smarty.const.COMPANY_BANK}<br>
кор/счет: {$smarty.const.COMPANY_BANK_KOR}<br>
БИК: {$smarty.const.COMPANY_BANK_BIK}
</td>
</tr>
<tr>
<td align="right" width="70" valign="top"><strong>Плательщик:</strong></td>
<td align="left">
{$cust_name}<br>
{$cust_adress}<br>
Телефон: {$cust_numbert}
</td>
</tr>
<tr align="center">
<td colspan="2">
<BR><BR><font size="+1"><strong>ТОВАРНЫЙ ЧЕК №{$ord_num} от {$ord_date|date_format:"%d.%m.%Y"}г</strong></font><BR><BR><BR>
</td>
</tr>
</table>
{foreach item=val from=$mmm}
{if (!strstr($val.name, $smarty.const.ADMIN_SHIPPING))} {assign var=free_shipping value=1} {else} {assign var=free_shipping value=0}{/if}
{if ((strpos($val.name, $smarty.const.ADMIN_SHIPPING) === false) && (strpos($val.name, $smarty.const.ADMIN_FAST_ORDER) === false))}
{assign var="val.Price" value=$val.Price*$disc.val/100}
{/if}
{assign var="totalsum" value=$val.Price*$val.Quantity+$totalsum}
{assign var="totalq" value=$val.Quantity+$totalq}
{/foreach}
<table cellpadding="5" cellspacing="0" border="0" width="620" align="center">
{if $disc.val>0}
{math assign="discont" equation="x*y/100" x=$totalsum y=$disc.val format="%1.2f"}
{math assign="totalsum" equation="x-y" x=$totalsum y=$discont format="%1.2f"}
<tr>
<td width="460" align="right"><strong>Скидка:</strong></td>
<td width="80" align="center"><strong>{$disc.val}%</strong></td>
<td width="80" align="center"><strong>{$discont}</strong></td>
</tr>
{/if}
<tr>
<td width="460" align="left"><strong>ИТОГО:</strong></td>
<td width="80" align="center"></td>
<td width="80" align="center"><strong>{math equation=$totalsum format="%1.2f"}</strong></td>
</tr>
<tr>
<td colspan="3"><strong>Итого прописью:</strong> <u>{num2str inn=$totalsum}</u></td>
</tr>
</table>
<table cellpadding="5" cellspacing="0" border="0" width="580" align="center" style="margin-top:60px;">
<tr>
<td align="left" width="50%">Выдал: _____________________________</td>
<td align="right" width="50%">Получил: _____________________________</td>
</tr>
</table>
</body>
</html>
[/spoiler]
-
Т.е. по сути мне нужно вставить в мой шаблон это:
[spoiler]{foreach item=val from=$mmm}
{if (!strstr($val.name, $smarty.const.ADMIN_SHIPPING))} {assign var=free_shipping value=1} {else} {assign var=free_shipping value=0}{/if}
{if ((strpos($val.name, $smarty.const.ADMIN_SHIPPING) === false) && (strpos($val.name, $smarty.const.ADMIN_FAST_ORDER) === false))}
{assign var="val.Price" value=$val.Price*$disc.val/100}
{/if}
{assign var="totalsum" value=$val.Price*$val.Quantity+$totalsum}
{assign var="totalq" value=$val.Quantity+$totalq}
{/foreach}
[/spoiler]
И использовать $totalsum ?
Сейчас попробуем )
-
но это, как я писал постом выше, изврат конечно.
-
Работает. Спасибо.
А чем плоха такая реализация? Какие минусы?
-
лишнее в коде. скидка будет тут учитываться?
-
Пока скидок нет. )
Но, наверное, было бы неплохо.