LJ
problema com download de arquivo, localhost funciona, nao funcio
Estou tendo um proble,ma com um comportamento diferente entre localhost e no servidor,
Fiz uma rotina de download e no servidor não faz o download e não envio nenhum destes parametros abaixo
servidor:
www.suafotoaqui.com.br/suafoto4/index.php?class=PedidoUserList&w
Fiz uma rotina de download e no servidor não faz o download e não envio nenhum destes parametros abaixo
servidor:
www.suafotoaqui.com.br/suafoto4/index.php?class=PedidoUserList&w
- <?php
- /**
- * SaleForm Registration
- * @author <your name here>
- */
- class PedidoUserForm extends TPage
- {
- protected $form; // form
- protected $datagrid;
- protected $pageNavigation;
- protected $formFields;
- protected $loaded;
- /**
- * Class constructor
- * Creates the page and the registration form
- */
- function __construct()
- {
- parent::__construct();
- // creates the form
- $this->form = new TForm('form_Pedido');
- $panel_master = new TPanelGroup( 'Pedido' );
- $vbox = new TVBox;
- $vbox->style = 'width: 100%';
- $this->form->add($panel_master);
- $panel_master->add($vbox);
- $frame_general = new TFrame;
- $frame_general->class = 'tframe tframe-custom';
- $frame_general->setLegend('Pedido');
- $frame_general->style = 'background:whiteSmoke';
- $table_general = new TTable;
- $table_general->width = '100%';
- $frame_general->add($table_general);
- $vbox->add( $frame_general );
- // master fields
- $id = new TEntry('id');
- $datap = new TDate('datap');
- // o nome do status e total pega de uma funcao no model pedido
- $status_id = new TEntry('status_nome');
- $total = new TEntry('TransfValor');
- $id->setSize(40);
- $datap->setSize(100);
- $total->setSize(80);
- $id->setEditable(false);
- $datap->setEditable(false);
- $status_id->setEditable(false);
- $total->setEditable(false);
- // general fields
- $table_general->addRowSet( new TLabel('ID'), $id );
- $table_general->addRowSet( $label_date = new TLabel('Data '), $datap );
- $table_general->addRowSet( new TLabel('Status'), $status_id );
- $table_general->addRowSet( new TLabel('Total'), $total );
- //criar a datagrid dos itens
- $this->datagrid = new TQuickGrid;
- //<img src=\"thumbnail.php?thumb=$file\" alt=\"thumb\" />
- $this->datagrid->enablePopover('Imagem', "<img src='{imagem}' height='100' >");
- $this->datagrid->addQuickColumn('ID', 'produto_id', 'center', '10%');
- $this->datagrid->addQuickColumn('Status', 'produto_status_id', 'center', '10%');
- $this->datagrid->addQuickColumn('Produto', 'produto_nome', 'left', '30%');
- $this->datagrid->addQuickColumn('Tam', 'preco_tam', 'left', '10%');
- $this->datagrid->addQuickColumn('Qtd', 'qtd', 'left', '10%');
- $pr = $this->datagrid->addQuickColumn('Preco','preco_val', 'right', '10%');
- $st = $this->datagrid->addQuickColumn('Subtotal','={qtd} * {preco_val}', 'right','10%');
- // creates two datagrid actions
- $action1 = new TDataGridAction(array($this, 'onDownload'));
- $action1->setLabel('Tamanho Comprado');
- $action1->setImage('fa:download');
- $action1->setField('produto_id');
- $action1->setDisplayCondition( array($this, 'displayDownload') );
- // creates two datagrid actions
- $action2 = new TDataGridAction(array($this, 'onDownload1200'));
- $action2->setLabel('Tamanho 800x1200');
- $action2->setImage('fa:download green');
- $action2->setField('produto_id');
- $action2->setDisplayCondition( array($this, 'displayDownload1200') );
- $this->datagrid->addAction($action1);
- $this->datagrid->addAction($action2);
- $this->datagrid->createModel();
- $format_value = function($value) {
- if (is_numeric($value)) {
- return 'R$ '.number_format($value, 2, ',', '.');
- }
- return $value;
- };
- $pr->setTransformer( $format_value );
- $st->setTransformer( $format_value );
- $this->formFields = array($id,$datap, $status_id, $total);
- $this->form->setFields( $this->formFields );
- // create the page container
- $container = new TVBox;
- $container->add($this->form);
- $container->add($this->datagrid);
- parent::add($container);
- }
- /**
- * Define when the action can be displayed
- */
- public function displayDownload( $object )
- {
- if($object->produto_status_id=='4')
- {return TRUE;}
- return FALSE;
- }
- /**
- * Define when the action can be displayed
- */
- public function displayDownload1200( $object )
- {
- if($object->produto_status_id<>'1')
- {return TRUE;}
- return FALSE;
- }
- /**
- * method onEdit()
- * Executed whenever the user clicks at the edit button da datagrid
- */
- function onEdit($param)
- {
- try
- {
- TTransaction::open('ecommerce');
- if (isset($param['key']))
- {
- $key = $param['key'];
- $object = new Pedido($key);
- $object->datap = TDate::date2br($object->datap);
- $sale_items = $object->getPedidoItems();
- TSession::setValue('pedido_id',$object->id);
- foreach( $sale_items as $item )
- {
- $obj2 = new StdClass;
- $obj2->produto_id = $item->produto_id;
- $obj2->produto_status_id = $item->produto_status_id;
- $obj2->produto_nome = $item->produto->nome;
- $obj2->preco_tam = $item->preco_tam;
- $obj2->qtd = $item->qtd;
- $obj2->preco_val = $item->preco_val;
- $obj2->imagem = $item->produto->imagem;
- $this->datagrid->addItem($obj2);
- }
- $this->form->setData($object); // fill the form
- TTransaction::close(); // close transaction
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', '<b>Error1</b> ' . $e->getMessage());
- TTransaction::rollback();
- }
- }
- function onDownload($param)
- {
- try
- {
- if (isset($param['produto_id']))
- {
- $produto_id = $param['produto_id']; // get the parameter $key
- $pedido_id = TSession::getValue('pedido_id');
- TTransaction::open('ecommerce'); // open a transaction
- $items = array();
- $pedido = new Pedido($pedido_id); // instantiates the Active Record
- $items = $pedido->getPedidoItems();
- foreach ($items as $item)
- {
- if ($item->produto_id == $produto_id)
- {
- $item->down ++;
- $pedido->store();
- TPage::openFile($item->photo_path);
- }
- }
- TTransaction::close(); // close the transaction
- TApplication::gotoPage('PedidoUserList');
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- function onDownload1200($param)
- {
- try
- {
- if (isset($param['produto_id']))
- {
- $produto_id = $param['produto_id']; // get the parameter $key
- TTransaction::open('ecommerce'); // open a transaction
- $object = new Produto($produto_id); // instantiates the Active Record
- $pedido_id = TSession::getValue('pedido_id');
- $pedido = new Pedido($pedido_id);
- $items = $pedido->getPedidoItems();
- foreach ($items as $item)
- {
- if ($item->produto_id == $produto_id)
- {
- $item->down1200 ++;
- $pedido->store();
- }
- }
- TPage::openFile($object->photo_path);
- TTransaction::close(); // close the transaction
- TApplication::gotoPage('PedidoUserList');
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', $e->getMessage()); // shows the exception error message
- TTransaction::rollback(); // undo all pending operations
- }
- }
- /**
- * method onEdit()
- * Executed whenever the user clicks at the edit button da datagrid
- */
- function onReload($param)
- {
- try
- {
- TTransaction::open('ecommerce');
- if (isset($param['key']))
- {
- $key = $param['key'];
- $object = new Pedido($key);
- $object->datap = TDate::date2br($object->datap);
- $sale_items = $object->getPedidoItems();
- TSession::setValue('pedido_id',$object->id);
- foreach( $sale_items as $item )
- {
- $obj2 = new StdClass;
- $obj2->produto_id = $item->produto_id;
- $obj2->produto_status_id = $item->produto_status_id;
- $obj2->produto_nome = $item->produto->nome;
- $obj2->preco_tam = $item->preco_tam;
- $obj2->qtd = $item->qtd;
- $obj2->preco_val = $item->preco_val;
- $obj2->photo_path = $item->photo_path;
- $this->datagrid->addItem($obj2);
- }
- $this->form->setData($object); // fill the form
- TTransaction::close(); // close transaction
- }
- }
- catch (Exception $e) // in case of exception
- {
- new TMessage('error', '<b>Error1</b> ' . $e->getMessage());
- TTransaction::rollback();
- }
- }
- /**
- * shows the page
- */
- function show()
- {
- $this->onReload($param);
- parent::show();
- }
- }
- ?>
O servidor está configurado para exibir os erros? Analise o retorno da requisição após clicar no link para download.