Skip to content

Instantly share code, notes, and snippets.

@fayqLs
Created October 10, 2024 07:54
Show Gist options
  • Save fayqLs/ede017eb49b5c49715ea72fc9a4695f9 to your computer and use it in GitHub Desktop.
Save fayqLs/ede017eb49b5c49715ea72fc9a4695f9 to your computer and use it in GitHub Desktop.
ADICIONAR ITENS EM LOTE NO DETAILFORM
<?php
# VendaForm
public function onAddDetailVendaItemVenda($param = null)
{
try
{
$data = (object) $param;
if (empty($data->venda_item_venda__row__id))
{
$data = $this->form->getData();
}
}
}
# ProdutoSimpleList
public function SelecionarItens($param = null)
{
try
{
$selecionados = TSession::getValue(__CLASS__.'builder_datagrid_check');
if ($selecionados)
{
TTransaction::open(self::$database);
$itens = array();
foreach ($selecionados as $id)
{
$produto = Produto::find($id);
if ($produto)
{
$itens[] = array(
'venda_item_venda_produto' => $produto->nome,
'venda_item_venda_preco' => $produto->preco,
'venda_item_venda__row__id' => 'b'.uniqid(),
'venda_item_venda_id' => ''
);
}
}
TTransaction::close();
if ($itens)
{
TApplication::loadPage('VendaForm', 'onAddVendaItens',array(
'itens' => $itens,
'static' => 1
));
}
TScript::create("Template.closeRightPanel();");
}
}
catch (Exception $e)
{
new TMessage('error', $e->getMessage());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment