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: http://www.suafotoaqui.com.br/suafoto4/index.php?class=PedidoUserList&wm-ueug=%22c34a7666-4bf6-7ae8-81a8-9ff34cb5c2c9%22&wm-fgug=1&__cfduid=d0fbdd93429d043638e5fb43179162d021466861639&PHPSESS...
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

 
  1. <?php
  2. /**
  3. * SaleForm Registration
  4. * @author <your name here>
  5. */
  6. class PedidoUserForm extends TPage
  7. {
  8. protected $form; // form
  9. protected $datagrid;
  10. protected $pageNavigation;
  11. protected $formFields;
  12. protected $loaded;
  13. /**
  14. * Class constructor
  15. * Creates the page and the registration form
  16. */
  17. function __construct()
  18. {
  19. parent::__construct();
  20. // creates the form
  21. $this->form = new TForm('form_Pedido');
  22. $panel_master = new TPanelGroup( 'Pedido' );
  23. $vbox = new TVBox;
  24. $vbox->style = 'width: 100%';
  25. $this->form->add($panel_master);
  26. $panel_master->add($vbox);
  27. $frame_general = new TFrame;
  28. $frame_general->class = 'tframe tframe-custom';
  29. $frame_general->setLegend('Pedido');
  30. $frame_general->style = 'background:whiteSmoke';
  31. $table_general = new TTable;
  32. $table_general->width = '100%';
  33. $frame_general->add($table_general);
  34. $vbox->add( $frame_general );
  35. // master fields
  36. $id = new TEntry('id');
  37. $datap = new TDate('datap');
  38. // o nome do status e total pega de uma funcao no model pedido
  39. $status_id = new TEntry('status_nome');
  40. $total = new TEntry('TransfValor');
  41. $id->setSize(40);
  42. $datap->setSize(100);
  43. $total->setSize(80);
  44. $id->setEditable(false);
  45. $datap->setEditable(false);
  46. $status_id->setEditable(false);
  47. $total->setEditable(false);
  48. // general fields
  49. $table_general->addRowSet( new TLabel('ID'), $id );
  50. $table_general->addRowSet( $label_date = new TLabel('Data '), $datap );
  51. $table_general->addRowSet( new TLabel('Status'), $status_id );
  52. $table_general->addRowSet( new TLabel('Total'), $total );
  53. //criar a datagrid dos itens
  54. $this->datagrid = new TQuickGrid;
  55. //<img src=\"thumbnail.php?thumb=$file\" alt=\"thumb\" />
  56. $this->datagrid->enablePopover('Imagem', "<img src='{imagem}' height='100' >");
  57. $this->datagrid->addQuickColumn('ID', 'produto_id', 'center', '10%');
  58. $this->datagrid->addQuickColumn('Status', 'produto_status_id', 'center', '10%');
  59. $this->datagrid->addQuickColumn('Produto', 'produto_nome', 'left', '30%');
  60. $this->datagrid->addQuickColumn('Tam', 'preco_tam', 'left', '10%');
  61. $this->datagrid->addQuickColumn('Qtd', 'qtd', 'left', '10%');
  62. $pr = $this->datagrid->addQuickColumn('Preco','preco_val', 'right', '10%');
  63. $st = $this->datagrid->addQuickColumn('Subtotal','={qtd} * {preco_val}', 'right','10%');
  64. // creates two datagrid actions
  65. $action1 = new TDataGridAction(array($this, 'onDownload'));
  66. $action1->setLabel('Tamanho Comprado');
  67. $action1->setImage('fa:download');
  68. $action1->setField('produto_id');
  69. $action1->setDisplayCondition( array($this, 'displayDownload') );
  70. // creates two datagrid actions
  71. $action2 = new TDataGridAction(array($this, 'onDownload1200'));
  72. $action2->setLabel('Tamanho 800x1200');
  73. $action2->setImage('fa:download green');
  74. $action2->setField('produto_id');
  75. $action2->setDisplayCondition( array($this, 'displayDownload1200') );
  76. $this->datagrid->addAction($action1);
  77. $this->datagrid->addAction($action2);
  78. $this->datagrid->createModel();
  79. $format_value = function($value) {
  80. if (is_numeric($value)) {
  81. return 'R$ '.number_format($value, 2, ',', '.');
  82. }
  83. return $value;
  84. };
  85. $pr->setTransformer( $format_value );
  86. $st->setTransformer( $format_value );
  87. $this->formFields = array($id,$datap, $status_id, $total);
  88. $this->form->setFields( $this->formFields );
  89. // create the page container
  90. $container = new TVBox;
  91. $container->add($this->form);
  92. $container->add($this->datagrid);
  93. parent::add($container);
  94. }
  95. /**
  96. * Define when the action can be displayed
  97. */
  98. public function displayDownload( $object )
  99. {
  100. if($object->produto_status_id=='4')
  101. {return TRUE;}
  102. return FALSE;
  103. }
  104. /**
  105. * Define when the action can be displayed
  106. */
  107. public function displayDownload1200( $object )
  108. {
  109. if($object->produto_status_id<>'1')
  110. {return TRUE;}
  111. return FALSE;
  112. }
  113. /**
  114. * method onEdit()
  115. * Executed whenever the user clicks at the edit button da datagrid
  116. */
  117. function onEdit($param)
  118. {
  119. try
  120. {
  121. TTransaction::open('ecommerce');
  122. if (isset($param['key']))
  123. {
  124. $key = $param['key'];
  125. $object = new Pedido($key);
  126. $object->datap = TDate::date2br($object->datap);
  127. $sale_items = $object->getPedidoItems();
  128. TSession::setValue('pedido_id',$object->id);
  129. foreach( $sale_items as $item )
  130. {
  131. $obj2 = new StdClass;
  132. $obj2->produto_id = $item->produto_id;
  133. $obj2->produto_status_id = $item->produto_status_id;
  134. $obj2->produto_nome = $item->produto->nome;
  135. $obj2->preco_tam = $item->preco_tam;
  136. $obj2->qtd = $item->qtd;
  137. $obj2->preco_val = $item->preco_val;
  138. $obj2->imagem = $item->produto->imagem;
  139. $this->datagrid->addItem($obj2);
  140. }
  141. $this->form->setData($object); // fill the form
  142. TTransaction::close(); // close transaction
  143. }
  144. }
  145. catch (Exception $e) // in case of exception
  146. {
  147. new TMessage('error', '<b>Error1</b> ' . $e->getMessage());
  148. TTransaction::rollback();
  149. }
  150. }
  151. function onDownload($param)
  152. {
  153. try
  154. {
  155. if (isset($param['produto_id']))
  156. {
  157. $produto_id = $param['produto_id']; // get the parameter $key
  158. $pedido_id = TSession::getValue('pedido_id');
  159. TTransaction::open('ecommerce'); // open a transaction
  160. $items = array();
  161. $pedido = new Pedido($pedido_id); // instantiates the Active Record
  162. $items = $pedido->getPedidoItems();
  163. foreach ($items as $item)
  164. {
  165. if ($item->produto_id == $produto_id)
  166. {
  167. $item->down ++;
  168. $pedido->store();
  169. TPage::openFile($item->photo_path);
  170. }
  171. }
  172. TTransaction::close(); // close the transaction
  173. TApplication::gotoPage('PedidoUserList');
  174. }
  175. }
  176. catch (Exception $e) // in case of exception
  177. {
  178. new TMessage('error', $e->getMessage()); // shows the exception error message
  179. TTransaction::rollback(); // undo all pending operations
  180. }
  181. }
  182. function onDownload1200($param)
  183. {
  184. try
  185. {
  186. if (isset($param['produto_id']))
  187. {
  188. $produto_id = $param['produto_id']; // get the parameter $key
  189. TTransaction::open('ecommerce'); // open a transaction
  190. $object = new Produto($produto_id); // instantiates the Active Record
  191. $pedido_id = TSession::getValue('pedido_id');
  192. $pedido = new Pedido($pedido_id);
  193. $items = $pedido->getPedidoItems();
  194. foreach ($items as $item)
  195. {
  196. if ($item->produto_id == $produto_id)
  197. {
  198. $item->down1200 ++;
  199. $pedido->store();
  200. }
  201. }
  202. TPage::openFile($object->photo_path);
  203. TTransaction::close(); // close the transaction
  204. TApplication::gotoPage('PedidoUserList');
  205. }
  206. }
  207. catch (Exception $e) // in case of exception
  208. {
  209. new TMessage('error', $e->getMessage()); // shows the exception error message
  210. TTransaction::rollback(); // undo all pending operations
  211. }
  212. }
  213. /**
  214. * method onEdit()
  215. * Executed whenever the user clicks at the edit button da datagrid
  216. */
  217. function onReload($param)
  218. {
  219. try
  220. {
  221. TTransaction::open('ecommerce');
  222. if (isset($param['key']))
  223. {
  224. $key = $param['key'];
  225. $object = new Pedido($key);
  226. $object->datap = TDate::date2br($object->datap);
  227. $sale_items = $object->getPedidoItems();
  228. TSession::setValue('pedido_id',$object->id);
  229. foreach( $sale_items as $item )
  230. {
  231. $obj2 = new StdClass;
  232. $obj2->produto_id = $item->produto_id;
  233. $obj2->produto_status_id = $item->produto_status_id;
  234. $obj2->produto_nome = $item->produto->nome;
  235. $obj2->preco_tam = $item->preco_tam;
  236. $obj2->qtd = $item->qtd;
  237. $obj2->preco_val = $item->preco_val;
  238. $obj2->photo_path = $item->photo_path;
  239. $this->datagrid->addItem($obj2);
  240. }
  241. $this->form->setData($object); // fill the form
  242. TTransaction::close(); // close transaction
  243. }
  244. }
  245. catch (Exception $e) // in case of exception
  246. {
  247. new TMessage('error', '<b>Error1</b> ' . $e->getMessage());
  248. TTransaction::rollback();
  249. }
  250. }
  251. /**
  252. * shows the page
  253. */
  254. function show()
  255. {
  256. $this->onReload($param);
  257. parent::show();
  258. }
  259. }
  260. ?>



Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (1)


NR

O servidor está configurado para exibir os erros? Analise o retorno da requisição após clicar no link para download.