Changeman não lista os chamados Prezados, tudo bem? Temos o changeman funcionando certinho e de repente, nao carrega mais os chamados no DataGrid. Temos essa linha: Conseguimos gravar, porém parou de listar os chamados na tela. Alguem poderia nos dar uma ajuda, abaixo codigo completo: ...
EB
Changeman não lista os chamados  
Prezados, tudo bem?

Temos o changeman funcionando certinho e de repente, nao carrega mais os chamados no DataGrid.
Temos essa linha:

 
  1. <?php
  2. $panel->add($this->datagrid);
  3. ?>


Conseguimos gravar, porém parou de listar os chamados na tela.

Alguem poderia nos dar uma ajuda, abaixo codigo completo:
 
  1. <?php
  2. /**
  3. * IssueList Listing
  4. * @author <your name here>
  5. */
  6. class IssueList extends TStandardList
  7. {
  8. protected $form; // registration form
  9. protected $datagrid; // listing
  10. protected $pageNavigation;
  11. protected $loaded;
  12. /**
  13. * Class constructor
  14. * Creates the page, the form and the listing
  15. */
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. parent::setActiveRecord('Issue');
  20. parent::setDatabase('changeman');
  21. parent::setDefaultOrder('id', 'desc');
  22. parent::addFilterField('id_status', '=', 'id_status');
  23. parent::addFilterField('id_project', '=', 'id_project');
  24. parent::addFilterField('id_priority', '=', 'id_priority');
  25. parent::addFilterField('id_category', '=', 'id_category');
  26. parent::addFilterField('title', 'like', 'title');
  27. TTransaction::open('permission');
  28. $user = SystemUser::newFromLogin(TSession::getValue('login'));
  29. $is_admin = $user->checkInGroup( new SystemGroup(1) );
  30. $is_manager = $user->checkInGroup( new SystemGroup(3) );
  31. $is_member = $user->checkInGroup( new SystemGroup(4) );
  32. $is_customer = $user->checkInGroup( new SystemGroup(5) );
  33. TTransaction::close();
  34. var_dump($is_admin);
  35. var_dump($is_manager);
  36. var_dump($is_member);
  37. if ( $is_admin OR $is_manager OR $is_member )
  38. {
  39. parent::addFilterField('id_user', '=', 'id_user');
  40. //var_dump($user);
  41. }
  42. // creates the form
  43. $this->form = new BootstrapFormBuilder('form_search_Issue');
  44. $this->form->setFormTitle( _t('Issues') );
  45. $criteria = new TCriteria;
  46. $criteria->add(new TFilter('active', '=', 'Y'), TExpression::OR_OPERATOR);
  47. $criteria->add(new TFilter('active', 'IS', NULL), TExpression::OR_OPERATOR);
  48. // create the form fields
  49. $filter_status = new TDBCombo('id_status', 'changeman', 'Status', 'id', 'description_translated');
  50. $filter_project = new TDBCombo('id_project', 'changeman', 'Project', 'id', 'description');
  51. $filter_priority = new TDBCombo('id_priority', 'changeman', 'Priority', 'id', 'description_translated');
  52. $filter_category = new TDBCombo('id_category', 'changeman', 'Category', 'id', 'description_translated');
  53. $filter_user = new TDBCombo('id_user', 'permission', 'SystemUser', 'id', 'name', 'name', $criteria);
  54. $filter_title = new TEntry('title');
  55. $filter_user->enableSearch();
  56. $filter_title->setSize('100%');
  57. $filter_status->setSize('100%');
  58. $filter_project->setSize('100%');
  59. $filter_priority->setSize('100%');
  60. $filter_category->setSize('100%');
  61. $filter_user->setSize('100%');
  62. $this->form->addFields( [new TLabel(_t('Status'))], [$filter_status], [new TLabel(_t('Project'))], [$filter_project] );
  63. $this->form->addFields( [new TLabel(_t('Priority'))], [$filter_priority], [new TLabel(_t('Category'))], [$filter_category] );
  64. if ( $is_admin OR $is_manager OR $is_member )
  65. {
  66. $this->form->addFields( [new TLabel(_t('Title'))], [$filter_title], [new TLabel(_t('User'))], [$filter_user]);
  67. }
  68. else
  69. {
  70. $this->form->addFields( [new TLabel(_t('Title'))], [$filter_title]);
  71. }
  72. $btn = $this->form->addAction( _t('Find'), new TAction(array($this, 'onSearch')), 'fa:search' );
  73. $btn->class = 'btn btn-sm btn-primary';
  74. $this->form->addActionLink( _t('New'), new TAction(array('NewIssueForm', 'onEdit')), 'fa:plus-square green' );
  75. $this->form->setData( TSession::getValue('Issue_filter_data') );
  76. // creates a DataGrid
  77. $this->datagrid = new BootstrapDatagridWrapper(new TDataGrid);
  78. $this->datagrid->datatable = 'true';
  79. $this->datagrid->width = '100%';
  80. $this->datagrid->enablePopover(_t('Abstract'), '<table width="500px"><tr><td style="vertical-align:top"><b>'._t('Description').'</b><br>' . '{description}' . '</td><td style="vertical-align:top"><b>'._t('Solution').'</b><br>' . '{solution} </td></tr></table>');
  81. $this->datagrid->setHeight(320);
  82. // creates the datagrid columns
  83. $id = new TDataGridColumn('id', 'ID', 'right', 40);
  84. $id_project = new TDataGridColumn('project_name', _t('Project'), 'left', NULL);
  85. $title = new TDataGridColumn('title', _t('Title'), 'left', NULL);
  86. $id_status = new TDataGridColumn('status_name', _t('Status'), 'left', NULL);
  87. $id_priority = new TDataGridColumn('priority_name', _t('Priority'), 'left', NULL);
  88. $id_category = new TDataGridColumn('category_name', _t('Category'), 'left', NULL);
  89. $register_date = new TDataGridColumn('register_date', _t('Start date'), 'left', NULL);
  90. $id_user = new TDataGridColumn('user_name', _t('User'), 'left', NULL);
  91. $id_status->setTransformer( array($this, 'setStatusColor') );
  92. $id_category->setTransformer( array($this, 'setCatColor') );
  93. $id_priority->setTransformer( array($this, 'setPriColor') );
  94. $id_project->setTransformer( array($this, 'setProjColor') );
  95. // creates the datagrid actions
  96. $order1= new TAction(array($this, 'onReload'));
  97. $order2= new TAction(array($this, 'onReload'));
  98. $order3= new TAction(array($this, 'onReload'));
  99. $order4= new TAction(array($this, 'onReload'));
  100. $order5= new TAction(array($this, 'onReload'));
  101. $order6= new TAction(array($this, 'onReload'));
  102. $order7= new TAction(array($this, 'onReload'));
  103. $order8= new TAction(array($this, 'onReload'));
  104. // define the ordering parameters
  105. $order1->setParameter('order', 'id');
  106. $order2->setParameter('order', 'title');
  107. $order3->setParameter('order', 'id_status');
  108. $order4->setParameter('order', 'id_priority');
  109. $order5->setParameter('order', 'id_category');
  110. $order6->setParameter('order', 'register_date');
  111. // assign the ordering actions
  112. $id->setAction($order1);
  113. $title->setAction($order2);
  114. $id_status->setAction($order3);
  115. $id_priority->setAction($order4);
  116. $id_category->setAction($order5);
  117. $register_date->setAction($order6);
  118. // add the columns to the DataGrid
  119. $this->datagrid->addColumn($id);
  120. $this->datagrid->addColumn($id_project);
  121. $this->datagrid->addColumn($title);
  122. $this->datagrid->addColumn($id_status);
  123. $this->datagrid->addColumn($id_priority);
  124. $this->datagrid->addColumn($id_category);
  125. $this->datagrid->addColumn($register_date);
  126. if ($is_customer)
  127. {
  128. parent::setCriteria( TCriteria::create( ['id_user' => $user->id] ) );
  129. }
  130. if ( $is_admin OR $is_manager )
  131. {
  132. // creates two datagrid actions
  133. $class = 'UpdateIssueForm';
  134. $action1 = new TDataGridAction(array($class, 'onEdit'));
  135. $action1->setLabel(_t('Edit'));
  136. $action1->setImage('fa:pencil-square-o blue fa-lg');
  137. $action1->setField('id');
  138. $action2 = new TDataGridAction(array($this, 'onDelete'));
  139. $action2->setLabel(_t('Delete'));
  140. $action2->setImage('fa:trash-o red fa-lg');
  141. $action2->setField('id');
  142. $this->datagrid->addColumn($id_user);
  143. // add the actions to the datagrid
  144. $this->datagrid->addAction($action1);
  145. $this->datagrid->addAction($action2);
  146. }
  147. else if ($is_member)
  148. {
  149. // creates two datagrid actions
  150. $class = 'UpdateIssueForm';
  151. $action1 = new TDataGridAction(array($class, 'onEdit'));
  152. $action1->setLabel(_t('Edit'));
  153. $action1->setImage('fa:pencil-square-o blue fa-lg');
  154. $action1->setField('id');
  155. $this->datagrid->addColumn($id_user);
  156. // add the actions to the datagrid
  157. $this->datagrid->addAction($action1);
  158. }
  159. // creates two datagrid actions
  160. $class = 'ViewIssueForm';
  161. $action3 = new TDataGridAction(array($class, 'onView'));
  162. $action3->setLabel(_t('View'));
  163. $action3->setImage('fa:search');
  164. $action3->setField('id');
  165. $class = 'NoteForm';
  166. $action4 = new TDataGridAction(array($class, 'onEdit'));
  167. $action4->setLabel(_t('Comment'));
  168. $action4->setImage('fa:plus-square green');
  169. $action4->setField('id');
  170. // add the actions to the datagrid
  171. $this->datagrid->addAction($action3);
  172. $this->datagrid->addAction($action4);
  173. // create the datagrid model
  174. $this->datagrid->createModel();
  175. // creates the page navigation
  176. $this->pageNavigation = new TPageNavigation;
  177. $this->pageNavigation->enableCounters();
  178. $this->pageNavigation->setAction(new TAction(array($this, 'onReload')));
  179. $this->pageNavigation->setWidth($this->datagrid->getWidth());
  180. $panel = new TPanelGroup;
  181. $panel->add($this->datagrid);
  182. $panel->addFooter($this->pageNavigation);
  183. // creates the page structure using a vbox
  184. $container = new TVBox;
  185. $container->style = 'width: 100%';
  186. $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  187. $container->add($this->form);
  188. $container->add($panel);
  189. // add the vbox inside the page
  190. parent::add($container);
  191. }
  192. public function setProjColor($proje, $object, $row)
  193. {
  194. $color = $object->project_color;
  195. if ($color)
  196. {
  197. $div = new TElement('span');
  198. $div->style = "text-shadow:none; font-size:12px; background: $color; border-radius:4px; padding:3px; color: white;";
  199. $div->add($proje);
  200. return $div;
  201. }
  202. else
  203. {
  204. return $proje;
  205. }
  206. }
  207. /**
  208. * Set status color
  209. */
  210. public function setStatusColor($status, $object, $row)
  211. {
  212. $color = $object->status_color;
  213. if ($color)
  214. {
  215. $div = new TElement('span');
  216. $div->style = "text-shadow:none; font-size:12px; background: $color; border-radius:4px; padding:3px; color: white;";
  217. $div->add($status);
  218. return $div;
  219. }
  220. else
  221. {
  222. return $status;
  223. }
  224. }
  225. public function setCatColor($categoria, $object, $row)
  226. {
  227. $color = $object->cat_color;
  228. if ($color)
  229. {
  230. $div = new TElement('span');
  231. $div->style = "text-shadow:none; font-size:12px; background: $color; border-radius:4px; padding:3px; color: white;";
  232. $div->add($categoria);
  233. return $div;
  234. }
  235. else
  236. {
  237. return $categoria;
  238. }
  239. }
  240. public function setPriColor($priori, $object, $row)
  241. {
  242. $color = $object->pri_color;
  243. if ($color)
  244. {
  245. $div = new TElement('span');
  246. $div->style = "text-shadow:none; font-size:12px; background: $color; border-radius:4px; padding:3px; color: white;";
  247. $div->add($priori);
  248. return $div;
  249. }
  250. else
  251. {
  252. return $priori;
  253. }
  254. }
  255. /**
  256. * Delete a record
  257. */
  258. function Delete($param)
  259. {
  260. try
  261. {
  262. TTransaction::open('permission');
  263. $user = SystemUser::newFromLogin(TSession::getValue('login'));
  264. $is_admin = $user->checkInGroup( new SystemGroup(1) );
  265. $is_manager = $user->checkInGroup( new SystemGroup(3) );
  266. TTransaction::close();
  267. // security check
  268. if (!$is_admin AND !$is_manager)
  269. {
  270. throw new Exception(_t('Permission denied'));
  271. }
  272. // get the parameter $key
  273. $key = $param['key'];
  274. // open a transaction with database 'changeman'
  275. TTransaction::open('changeman');
  276. // instantiates object Issue
  277. $object = new Issue($key);
  278. // deletes the object from the database
  279. $object->delete();
  280. // close the transaction
  281. TTransaction::close();
  282. // reload the listing
  283. $this->onReload();
  284. // shows the success message
  285. new TMessage('info', TAdiantiCoreTranslator::translate('Record deleted'));
  286. }
  287. catch (Exception $e) // in case of exception
  288. {
  289. // shows the exception error message
  290. new TMessage('error', $e->getMessage());
  291. // undo all pending operations
  292. TTransaction::rollback();
  293. }
  294. }
  295. function onClear()
  296. {
  297. $this->onSearch();
  298. }
  299. /**
  300. * method show()
  301. * Shows the page
  302. */
  303. public function show()
  304. {
  305. // check if the datagrid is already loaded
  306. if (!$this->loaded)
  307. {
  308. $this->onReload();
  309. }
  310. parent::show();
  311. }
  312. }

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)


EB

Olá pessoal, encontrei o problema, comentei a linha 92, conforme abaixo:

 
  1. <?php
  2. $this->datagrid->enablePopover(_t('Abstract'), '<table width="500px"><tr><td style="vertical-align:top"><b>'._t('Description').'</b><br>' . '{description}' . '</td><td style="vertical-align:top"><b>'._t('Solution').'</b><br>' . '{solution} </td></tr></table>');
  3. ?>


Ficou assim:
 
  1. <?php
  2. //$this->datagrid->enablePopover(_t('Abstract'), '<table width="500px"><tr><td style="vertical-align:top"><b>'._t('Description').'</b><br>' . '{description}' . '</td><td style="vertical-align:top"><b>'._t('Solution').'</b><br>' . '{solution} </td></tr></table>');
  3. ?>


Ainda não sei o motivo, mas vamos ficar sem Popover, o que pra nós não há problemas.
Fica a dica para alguém que esteja passando pelo mesmo problema.

Att.,
Ed

Editado 25/05/2024 (há 1 ano) - Ver alterações