actions.class.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * kataoProductFamily actions.
  4. *
  5. * @package www.katao.fr
  6. * @subpackage kataoProductFamily
  7. * @author Your name here
  8. * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
  9. */
  10. class kataoProductFamilyActions extends wpActions {
  11. public function executeIndex() {
  12. $criteria = new Criteria();
  13. $criteria->addJoin(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, KataoProductCategoryPeer::ID);
  14. $sort_method = $this->getCriteriaSortMethod();
  15. switch ($this->sort = $this->getRequestParameter('sort', 'name')) {
  16. case 'category':
  17. $criteria->$sort_method(KataoProductCategoryPeer::NAME);
  18. break;
  19. default:
  20. $criteria->$sort_method(KataoProductFamilyPeer::NAME);
  21. }
  22. if ('' != $this->filter_product_category = $this->getUser()->getAttribute('katao_product_family_filter_product_category')) {
  23. $criteria->add(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, $this->filter_product_category);
  24. }
  25. $pager = new sfPropelPager('KataoProductFamily', sfConfig::get('app_pager'));
  26. $pager->setPeerMethod('doSelectJoinKataoProductCategory');
  27. $pager->setCriteria($criteria);
  28. $pager->setPage($this->getRequestParameter('page', 1));
  29. $pager->init();
  30. $this->pager = $pager;
  31. $this->katao_product_familyList = $pager->getResults();
  32. }
  33. public function executeFilter($request) {
  34. $this->getUser()->setAttribute('katao_product_family_filter_product_category', $request->getParameter('filter_product_category'));
  35. return $this->redirect('kataoProductFamily/index');
  36. }
  37. public function executeFilterReset($request) {
  38. $this->getUser()->setAttribute('katao_product_family_filter_product_category', '');
  39. return $this->redirect('kataoProductFamily/index');
  40. }
  41. public function executeShow($request) {
  42. $this->katao_product_family = KataoProductFamilyPeer::retrieveByPk($request->getParameter('id'));
  43. $this->redirectWithErrorUnless($this->katao_product_family, 'Famille #' . $request->getParameter('id') . ' inconnue.');
  44. }
  45. public function executeCreate() {
  46. $this->form = new KataoProductFamilyForm();
  47. $this->setTemplate('edit');
  48. }
  49. public function executeEdit($request) {
  50. $this->form = new KataoProductFamilyForm(KataoProductFamilyPeer::retrieveByPk($request->getParameter('id')));
  51. }
  52. public function executeUpdate($request) {
  53. $this->redirectWithErrorUnless($request->isMethod('post'));
  54. $this->form = new KataoProductFamilyForm(KataoProductFamilyPeer::retrieveByPk($request->getParameter('id')));
  55. $this->form->bind($request->getParameter('katao_product_family'));
  56. if ($this->form->isValid()) {
  57. $katao_product_family = $this->form->save();
  58. wpFlashMessages::addConfirmation('Famille "' . $katao_product_family->getName() . '" sauvée avec succès.');
  59. $this->redirect('kataoProductFamily/index');
  60. }
  61. $this->setTemplate('edit');
  62. }
  63. public function executeDelete($request) {
  64. $this->redirectWithErrorUnless($katao_product_family = KataoProductFamilyPeer::retrieveByPk($request->getParameter('id')), 'Famille #' . $request->getParameter('id') . ' inconnue.');
  65. $this->redirectWithErrorIf(!$katao_product_family->isDeletable());
  66. $katao_product_family->delete();
  67. wpFlashMessages::addConfirmation('Famille "' . $katao_product_family->getName() . '" supprimée avec succès.');
  68. $this->redirect('kataoProductFamily/index');
  69. }
  70. public function executeDeleteMultiple($request) {
  71. if (!wpPersistenceManager::isEmpty('katao_product_family')) {
  72. foreach (KataoProductFamilyPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_product_family'))) as/*(KataoProductFamily)*/ $katao_product_family) {
  73. if ($katao_product_family->isDeletable()) {
  74. $katao_product_family->delete();
  75. }
  76. }
  77. wpPersistenceManager::cleanSelection('katao_product_family');
  78. wpFlashMessages::addConfirmation('Les familles sélectionnées ont été supprimées avec succès.');
  79. } else {
  80. wpFlashMessages::addWarning('Merci de sélectionner au moins une famille.');
  81. }
  82. $this->redirect('kataoProductFamily/index');
  83. }
  84. }