Browse Source

first commit

Jean Roussel 7 years ago
commit
04dc40eb19
100 changed files with 8640 additions and 0 deletions
  1. 5 0
      .gitignore
  2. 9 0
      apps/admin/config/adminConfiguration.class.php
  3. 4 0
      apps/admin/config/app.yml
  4. 4 0
      apps/admin/config/cache.yml
  5. 132 0
      apps/admin/config/factories.yml
  6. 8 0
      apps/admin/config/filters.yml
  7. 564 0
      apps/admin/config/routing.yml
  8. 2 0
      apps/admin/config/security.yml
  9. 109 0
      apps/admin/config/settings.yml
  10. 17 0
      apps/admin/config/view.yml
  11. 13 0
      apps/admin/i18n/fr/messages.xml
  12. 36 0
      apps/admin/lib/myUser.class.php
  13. 56 0
      apps/admin/lib/stats.class.php
  14. 181 0
      apps/admin/modules/cron/actions/actions.class.php
  15. 2 0
      apps/admin/modules/cron/config/security.yml
  16. 11 0
      apps/admin/modules/katao/templates/_relanceEmail.php
  17. 92 0
      apps/admin/modules/katao/templates/_user.php
  18. 350 0
      apps/admin/modules/kataoCart/actions/actions.class.php
  19. 2 0
      apps/admin/modules/kataoCart/config/security.yml
  20. 49 0
      apps/admin/modules/kataoCart/templates/editSuccess.php
  21. 55 0
      apps/admin/modules/kataoCart/templates/generateSuppliersOrdersSuccess.php
  22. 144 0
      apps/admin/modules/kataoCart/templates/indexSuccess.php
  23. 38 0
      apps/admin/modules/kataoCart/templates/showSuccess.php
  24. 32 0
      apps/admin/modules/kataoConfig/actions/actions.class.php
  25. 2 0
      apps/admin/modules/kataoConfig/config/security.yml
  26. 266 0
      apps/admin/modules/kataoConfig/templates/indexSuccess.php
  27. 398 0
      apps/admin/modules/kataoInvoice/actions/actions.class.php
  28. 2 0
      apps/admin/modules/kataoInvoice/config/security.yml
  29. 54 0
      apps/admin/modules/kataoInvoice/templates/deliverSuccess.php
  30. 49 0
      apps/admin/modules/kataoInvoice/templates/editSuccess.php
  31. 115 0
      apps/admin/modules/kataoInvoice/templates/indexSuccess.php
  32. 42 0
      apps/admin/modules/kataoInvoice/templates/showSuccess.php
  33. 46 0
      apps/admin/modules/kataoInvoice/templates/validateSuccess.php
  34. 496 0
      apps/admin/modules/kataoMember/actions/actions.class.php
  35. 3 0
      apps/admin/modules/kataoMember/config/security.yml
  36. 4 0
      apps/admin/modules/kataoMember/templates/__mailingSuccess.php
  37. 100 0
      apps/admin/modules/kataoMember/templates/_pdf.php
  38. 78 0
      apps/admin/modules/kataoMember/templates/adhesionCreateSuccess.php
  39. 77 0
      apps/admin/modules/kataoMember/templates/adhesionEditSuccess.php
  40. 22 0
      apps/admin/modules/kataoMember/templates/adhesionShowAllSuccess.php
  41. 23 0
      apps/admin/modules/kataoMember/templates/changeNextNodeMultipleSuccess.php
  42. 141 0
      apps/admin/modules/kataoMember/templates/editSuccess.php
  43. 92 0
      apps/admin/modules/kataoMember/templates/indexSuccess.php
  44. 120 0
      apps/admin/modules/kataoMember/templates/showSuccess.php
  45. 49 0
      apps/admin/modules/kataoMember/templates/updateGmapCoordinatesSuccess.php
  46. 97 0
      apps/admin/modules/kataoMemberAdhesion/actions/actions.class.php
  47. 39 0
      apps/admin/modules/kataoMemberAdhesion/templates/indexSuccess.php
  48. 445 0
      apps/admin/modules/kataoMemberDeposit/actions/actions.class.php
  49. 33 0
      apps/admin/modules/kataoMemberDeposit/config/security.yml
  50. 51 0
      apps/admin/modules/kataoMemberDeposit/templates/dispatchSolsSuccess.php
  51. 105 0
      apps/admin/modules/kataoMemberDeposit/templates/editSuccess.php
  52. 68 0
      apps/admin/modules/kataoMemberDeposit/templates/indexSuccess.php
  53. 23 0
      apps/admin/modules/kataoMemberDeposit/templates/printChecksSuccess.php
  54. 58 0
      apps/admin/modules/kataoMemberDeposit/templates/showSuccess.php
  55. 48 0
      apps/admin/modules/kataoMemberDeposit/templates/transferSolSuccess.php
  56. 65 0
      apps/admin/modules/kataoMemberGroup/actions/actions.class.php
  57. 26 0
      apps/admin/modules/kataoMemberGroup/templates/editSuccess.php
  58. 26 0
      apps/admin/modules/kataoMemberGroup/templates/indexSuccess.php
  59. 22 0
      apps/admin/modules/kataoMemberGroup/templates/showSuccess.php
  60. 133 0
      apps/admin/modules/kataoNode/actions/actions.class.php
  61. 8 0
      apps/admin/modules/kataoNode/config/security.yml
  62. 42 0
      apps/admin/modules/kataoNode/templates/editSuccess.php
  63. 48 0
      apps/admin/modules/kataoNode/templates/indexSuccess.php
  64. 240 0
      apps/admin/modules/kataoNode/templates/manageProductsByPeriodSuccess.php
  65. 9 0
      apps/admin/modules/kataoNode/templates/manageProductsSuccess.php
  66. 38 0
      apps/admin/modules/kataoNode/templates/showSuccess.php
  67. 282 0
      apps/admin/modules/kataoOrder/actions/actions.class.php
  68. 4 0
      apps/admin/modules/kataoOrder/config/security.yml
  69. 55 0
      apps/admin/modules/kataoOrder/templates/adjustProductSuccess.php
  70. 27 0
      apps/admin/modules/kataoOrder/templates/adjustSuccess.php
  71. 61 0
      apps/admin/modules/kataoOrder/templates/deliverProductSuccess.php
  72. 35 0
      apps/admin/modules/kataoOrder/templates/editSuccess.php
  73. 55 0
      apps/admin/modules/kataoOrder/templates/generateMembersInvoicesSuccess.php
  74. 183 0
      apps/admin/modules/kataoOrder/templates/indexSuccess.php
  75. 11 0
      apps/admin/modules/kataoOrder/templates/receiveNewProductSuccess.php
  76. 32 0
      apps/admin/modules/kataoOrder/templates/receiveSuccess.php
  77. 23 0
      apps/admin/modules/kataoOrder/templates/sendSuccess.php
  78. 34 0
      apps/admin/modules/kataoOrder/templates/showSuccess.php
  79. 36 0
      apps/admin/modules/kataoOrder/templates/simulatedMembersSuccess.php
  80. 150 0
      apps/admin/modules/kataoOrder/templates/simulatedSuccess.php
  81. 464 0
      apps/admin/modules/kataoPeriod/actions/actions.class.php
  82. 2 0
      apps/admin/modules/kataoPeriod/config/security.yml
  83. 286 0
      apps/admin/modules/kataoPeriod/templates/editSuccess.php
  84. 54 0
      apps/admin/modules/kataoPeriod/templates/indexSuccess.php
  85. 46 0
      apps/admin/modules/kataoPeriod/templates/showSuccess.php
  86. 255 0
      apps/admin/modules/kataoProduct/actions/actions.class.php
  87. 3 0
      apps/admin/modules/kataoProduct/config/security.yml
  88. 27 0
      apps/admin/modules/kataoProduct/templates/editPresentationSuccess.php
  89. 238 0
      apps/admin/modules/kataoProduct/templates/editSuccess.php
  90. 80 0
      apps/admin/modules/kataoProduct/templates/indexSuccess.php
  91. 82 0
      apps/admin/modules/kataoProduct/templates/showSuccess.php
  92. 93 0
      apps/admin/modules/kataoProductCategory/actions/actions.class.php
  93. 2 0
      apps/admin/modules/kataoProductCategory/config/security.yml
  94. 42 0
      apps/admin/modules/kataoProductCategory/templates/editSuccess.php
  95. 35 0
      apps/admin/modules/kataoProductCategory/templates/indexSuccess.php
  96. 38 0
      apps/admin/modules/kataoProductCategory/templates/showSuccess.php
  97. 106 0
      apps/admin/modules/kataoProductFamily/actions/actions.class.php
  98. 2 0
      apps/admin/modules/kataoProductFamily/config/security.yml
  99. 35 0
      apps/admin/modules/kataoProductFamily/templates/editSuccess.php
  100. 44 0
      apps/admin/modules/kataoProductFamily/templates/indexSuccess.php

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
+.DS_Store
+cache/*
+log/*
+*.sublime-project
+*.sublime-workspace

+ 9 - 0
apps/admin/config/adminConfiguration.class.php

@@ -0,0 +1,9 @@
+<?php
+
+define('CONST_YES', 1);
+define('CONST_NO', 2);
+
+class adminConfiguration extends sfApplicationConfiguration {
+    public function configure() {
+    }
+}

File diff suppressed because it is too large
+ 4 - 0
apps/admin/config/app.yml


+ 4 - 0
apps/admin/config/cache.yml

@@ -0,0 +1,4 @@
+default:
+  enabled:     off
+  with_layout: false
+  lifetime:    86400

+ 132 - 0
apps/admin/config/factories.yml

@@ -0,0 +1,132 @@
+prod:
+  logger:
+    class:   sfNoLogger
+    param:
+      level:   err
+      loggers: ~
+
+cli:
+  controller:
+    class: sfConsoleController
+  request:
+    class: sfConsoleRequest
+  response:
+    class: sfConsoleResponse
+
+test:
+  storage:
+    class: sfSessionTestStorage
+    param:
+      session_path: %SF_TEST_CACHE_DIR%/sessions
+
+  response:
+    class: sfWebResponse
+    param:
+      send_http_headers: false
+
+all:
+  routing:
+    class: sfPatternRouting
+    param:
+      generate_shortest_url:            true
+      extra_parameters_as_query_string: true
+
+#all:
+#  controller:
+#    class: sfFrontWebController
+#
+#  request:
+#    class: sfWebRequest
+#    param:
+#      logging:           %SF_LOGGING_ENABLED%
+#      path_info_array:   SERVER
+#      path_info_key:     PATH_INFO
+#      relative_url_root: ~
+#      formats:
+#        txt:  text/plain
+#        js:   [application/javascript, application/x-javascript, text/javascript]
+#        css:  text/css
+#        json: [application/json, application/x-json]
+#        xml:  [text/xml, application/xml, application/x-xml]
+#        rdf:  application/rdf+xml
+#        atom: application/atom+xml
+#
+#  response:
+#    class: sfWebResponse
+#    param:
+#      logging:           %SF_LOGGING_ENABLED%
+#      charset:           %SF_CHARSET%
+#      send_http_headers: true
+#
+#  user:
+#    class: myUser
+#    param:
+#      timeout:         1800
+#      logging:         %SF_LOGGING_ENABLED%
+#      use_flash:       true
+#      default_culture: %SF_DEFAULT_CULTURE%
+#
+#  storage:
+#    class: sfSessionStorage
+#    param:
+#      session_name: symfony
+#
+#  view_cache:
+#    class: sfFileCache
+#    param:
+#      automatic_cleaning_factor: 0
+#      cache_dir:                 %SF_TEMPLATE_CACHE_DIR%
+#      lifetime:                  86400
+#      prefix:                    %SF_APP_DIR%/template
+#
+#  i18n:
+#    class: sfI18N
+#    param:
+#      source:               XLIFF
+#      debug:                off
+#      untranslated_prefix:  "[T]"
+#      untranslated_suffix:  "[/T]"
+#      cache:
+#        class: sfFileCache
+#        param:
+#          automatic_cleaning_factor: 0
+#          cache_dir:                 %SF_I18N_CACHE_DIR%
+#          lifetime:                  31556926
+#          prefix:                    %SF_APP_DIR%/i18n
+#
+#  routing:
+#    class: sfPatternRouting
+#    param:
+#      load_configuration:               true
+#      suffix:                           ''
+#      default_module:                   default
+#      default_action:                   index
+#      debug:                            %SF_DEBUG%
+#      logging:                          %SF_LOGGING_ENABLED%
+#      generate_shortest_url:            false
+#      extra_parameters_as_query_string: false
+#      cache:
+#        class: sfFileCache
+#        param:
+#          automatic_cleaning_factor: 0
+#          cache_dir:                 %SF_CONFIG_CACHE_DIR%/routing
+#          lifetime:                  31556926
+#          prefix:                    %SF_APP_DIR%/routing
+#
+#  logger:
+#    class: sfAggregateLogger
+#    param:
+#      level: debug
+#      loggers:
+#        sf_web_debug:
+#          class: sfWebDebugLogger
+#          param:
+#            level: debug
+#            condition:       %SF_WEB_DEBUG%
+#            xdebug_logging:  true
+#            web_debug_class: sfWebDebug
+#        sf_file_debug:
+#          class: sfFileLogger
+#          param:
+#            level: debug
+#            file: %SF_LOG_DIR%/%SF_APP%_%SF_ENVIRONMENT%.log

+ 8 - 0
apps/admin/config/filters.yml

@@ -0,0 +1,8 @@
+rendering: ~
+security:  ~
+
+# insert your own filters here
+
+cache:     ~
+common:    ~
+execution: ~

+ 564 - 0
apps/admin/config/routing.yml

@@ -0,0 +1,564 @@
+# default rules
+homepage:
+  url:   /
+  param: { module: user, action: index }
+login:
+  url:   /login
+  param: { module: user, action: login }
+logout:
+  url:   /logout
+  param: { module: user, action: logout }
+profile:
+  url:   /profil
+  param: { module: user, action: profile }
+profile_update:
+  url:   /profil/modifier
+  param: { module: user, action: profileUpdate }
+profile_gmap:
+  url:   /profil/gmap
+  param: { module: user, action: profileGmap }
+
+# periods
+katao_period:
+  url:   /gestion-des-periodes
+  param: { module: kataoPeriod, action: index }
+katao_period_show:
+  url:   /gestion-des-periodes/voir/:id
+  param: { module: kataoPeriod, action: show }
+katao_period_add:
+  url:   /gestion-des-periodes/ajouter
+  param: { module: kataoPeriod, action: create }
+katao_period_edit:
+  url:   /gestion-des-periodes/modifier/:id
+  param: { module: kataoPeriod, action: edit }
+katao_period_delete:
+  url:   /gestion-des-periodes/supprimer/:id
+  param: { module: kataoPeriod, action: delete }
+katao_period_delete_multiple:
+  url:   /gestion-des-periodes/supprimer-selection
+  param: { module: kataoPeriod, action: deleteMultiple }
+katao_period_filter:
+  url:   /gestion-des-periodes/filtrer
+  param: { module: kataoPeriod, action: filter }
+katao_period_filter_reset:
+  url:   /gestion-des-periodes/filtre/annuler
+  param: { module: kataoPeriod, action: filterReset }
+katao_period_activate:
+  url:   /gestion-des-periodes/activer/:id
+  param: { module: kataoPeriod, action: activate }
+katao_period_export_accounting:
+  url:   /gestion-des-periodes/export-comptable
+  param: { module: kataoPeriod, action: exportAccounting }
+katao_period_copy:
+  url:   /gestion-des-periodes/copier/:id
+  param: { module: kataoPeriod, action: copy }
+
+# nodes
+katao_node:
+  url:   /gestion-des-noeuds
+  param: { module: kataoNode, action: index }
+katao_node_show:
+  url:   /gestion-des-noeuds/voir/:id
+  param: { module: kataoNode, action: show }
+katao_node_add:
+  url:   /gestion-des-noeuds/ajouter
+  param: { module: kataoNode, action: create }
+katao_node_edit:
+  url:   /gestion-des-noeuds/modifier/:id
+  param: { module: kataoNode, action: edit }
+katao_node_delete:
+  url:   /gestion-des-noeuds/supprimer/:id
+  param: { module: kataoNode, action: delete }
+katao_node_delete_multiple:
+  url:   /gestion-des-noeuds/supprimer-selection
+  param: { module: kataoNode, action: deleteMultiple }
+katao_node_manage_products:
+  url:   /gestion-des-noeuds/gerer-les-produits-par-periode/:id
+  param: { module: kataoNode, action: manageProducts }
+katao_node_manage_products_by_period:
+  url:   /gestion-des-noeuds/gerer-les-produits-par-periode/noeud/:node/periode/:period
+  param: { module: kataoNode, action: manageProductsByPeriod }
+
+# members
+katao_member:
+  url:   /gestion-des-adherents
+  param: { module: kataoMember, action: index }
+katao_member_show:
+  url:   /gestion-des-adherents/voir/:id
+  param: { module: kataoMember, action: show }
+katao_member_add:
+  url:   /gestion-des-adherents/ajouter
+  param: { module: kataoMember, action: create }
+katao_member_edit:
+  url:   /gestion-des-adherents/modifier/:id
+  param: { module: kataoMember, action: edit }
+katao_member_delete:
+  url:   /gestion-des-adherents/supprimer/:id
+  param: { module: kataoMember, action: delete }
+katao_member_delete_multiple:
+  url:   /gestion-des-adherents/supprimer-selection
+  param: { module: kataoMember, action: deleteMultiple }
+katao_member_filter:
+  url:   /gestion-des-adherents/filtrer
+  param: { module: kataoMember, action: filter }
+katao_member_filter_reset:
+  url:   /gestion-des-adherents/filtre/annuler
+  param: { module: kataoMember, action: filterReset }
+katao_member_search:
+  url:   /gestion-des-adherents/rechercher
+  param: { module: kataoMember, action: search }
+katao_member_search_reset:
+  url:   /gestion-des-adherents/recherche/annuler
+  param: { module: kataoMember, action: searchReset }
+katao_member_change_next_node_multiple:
+  url:   /gestion-des-adherents/changer-noeud-selection
+  param: { module: kataoMember, action: changeNextNodeMultiple }
+katao_member_send_login:
+  url:   /gestion-des-adherents/envoyer-login/:id
+  param: { module: kataoMember, action: sendLogin }
+katao_member_gmap:
+  url:   /gestion-des-adherents/positionner-sur-carte/:id
+  param: { module: kataoMember, action: updateGmapCoordinates }
+katao_member_export_zyvon:
+  url:   /gestion-des-adherents/exporter/zyvon
+  param: { module: kataoMember, action: exportZyvon }
+
+  # member adhesions
+katao_member_adhesion_create:
+  url: gestion-des-adherents/inscription/:userid
+  param: { module: kataoMember, action: adhesionCreate }
+katao_member_adhesion_edit:
+  url: gestion-des-adherents/edit-adhesion/:userid/:id
+  param: { module: kataoMember, action: adhesionEdit }
+katao_member_adhesion_delete:
+  url: gestion-des-adherents/delete-adhesion/:userid/:id
+  param: { module: kataoMember, action: adhesionDelete }
+katao_member_adhesion_showall:
+  url: gestion-des-adherents/vue-ensemble
+  param: { module: kataoMember, action: adhesionShowAll }
+
+katao_member_print_sol_card:
+  url:   /gestion-des-adherents/imprimer/carte-sol/:id
+  param: { module: kataoMember, action: printSolCard }
+
+katao_member_sent_relance:
+  url: /gestion-des-adherents/relance/:id
+  param: { module: kataoMember, action: sentRelance }
+
+# suppliers
+katao_supplier:
+  url:   /gestion-des-fournisseurs
+  param: { module: kataoSupplier, action: index }
+katao_supplier_show:
+  url:   /gestion-des-fournisseurs/voir/:id
+  param: { module: kataoSupplier, action: show }
+katao_supplier_add:
+  url:   /gestion-des-fournisseurs/ajouter
+  param: { module: kataoSupplier, action: create }
+katao_supplier_edit:
+  url:   /gestion-des-fournisseurs/modifier/:id
+  param: { module: kataoSupplier, action: edit }
+katao_supplier_edit_presentation:
+  url:   /gestion-des-fournisseurs/modifier-presentation/:id
+  param: { module: kataoSupplier, action: editPresentation }
+katao_supplier_delete:
+  url:   /gestion-des-fournisseurs/supprimer/:id
+  param: { module: kataoSupplier, action: delete }
+katao_supplier_delete_multiple:
+  url:   /gestion-des-fournisseurs/supprimer-selection
+  param: { module: kataoSupplier, action: deleteMultiple }
+katao_supplier_filter:
+  url:   /gestion-des-fournisseurs/filtrer
+  param: { module: kataoSupplier, action: filter }
+katao_supplier_filter_reset:
+  url:   /gestion-des-fournisseurs/filtre/annuler
+  param: { module: kataoSupplier, action: filterReset }
+katao_supplier_search:
+  url:   /gestion-des-fournisseurs/rechercher
+  param: { module: kataoSupplier, action: search }
+katao_supplier_search_reset:
+  url:   /gestion-des-fournisseurs/recherche/annuler
+  param: { module: kataoSupplier, action: searchReset }
+katao_supplier_send_login:
+  url:   /gestion-des-fournisseurs/envoyer-login/:id
+  param: { module: kataoSupplier, action: sendLogin }
+katao_supplier_gmap:
+  url:   /gestion-des-fournisseurs/positionner-sur-carte/:id
+  param: { module: kataoSupplier, action: updateGmapCoordinates }
+katao_supplier_export_zyvon:
+  url:   /gestion-des-fournisseurs/exporter/zyvon
+  param: { module: kataoSupplier, action: exportZyvon }
+
+# carts
+katao_cart:
+  url:   /gestion-des-demandes
+  param: { module: kataoCart, action: index }
+katao_cart_show:
+  url:   /gestion-des-demandes/voir/:id
+  param: { module: kataoCart, action: show }
+katao_cart_add:
+  url:   /gestion-des-demandes/ajouter
+  param: { module: kataoCart, action: create }
+katao_cart_edit:
+  url:   /gestion-des-demandes/modifier/:id
+  param: { module: kataoCart, action: edit }
+katao_cart_delete:
+  url:   /gestion-des-demandes/supprimer/:id
+  param: { module: kataoCart, action: delete }
+katao_cart_delete_multiple:
+  url:   /gestion-des-demandes/supprimer-selection
+  param: { module: kataoCart, action: deleteMultiple }
+katao_cart_filter:
+  url:   /gestion-des-demandes/filtrer
+  param: { module: kataoCart, action: filter }
+katao_cart_filter_reset:
+  url:   /gestion-des-demandes/filtre/annuler
+  param: { module: kataoCart, action: filterReset }
+katao_cart_generate_orders:
+  url:   /gestion-des-demandes/generer-commandes-fournisseurs
+  param: { module: kataoCart, action: generateSuppliersOrders }
+katao_cart_pdf:
+  url:   /gestion-des-demandes/exporter/pdf/:id
+  param: { module: kataoCart, action: exportPDF }
+katao_cart_export_pdf_all:
+  url:   /gestion-des-demandes/exporter-pdf/toutes
+  param: { module: kataoCart, action: exportPDFAll }
+katao_cart_export_pdf_selected:
+  url:   /gestion-des-demandes/exporter-pdf/selection
+  param: { module: kataoCart, action: exportPDFSelected }
+katao_cart_validate:
+  url:   /gestion-des-demandes/valider/:id
+  param: { module: kataoCart, action: validate }
+katao_cart_unvalidate:
+  url:   /gestion-des-demandes/devalider/:id
+  param: { module: kataoCart, action: unvalidate }
+
+# products
+katao_product:
+  url:   /gestion-des-produits
+  param: { module: kataoProduct, action: index }
+katao_product_show:
+  url:   /gestion-des-produits/voir/:id
+  param: { module: kataoProduct, action: show }
+katao_product_add:
+  url:   /gestion-des-produits/ajouter
+  param: { module: kataoProduct, action: create }
+katao_product_edit:
+  url:   /gestion-des-produits/modifier/:id
+  param: { module: kataoProduct, action: edit }
+katao_product_edit_presentation:
+  url:   /gestion-des-produits/modifier-presentation/:id
+  param: { module: kataoProduct, action: editPresentation }
+katao_product_delete:
+  url:   /gestion-des-produits/supprimer/:id
+  param: { module: kataoProduct, action: delete }
+katao_product_delete_multiple:
+  url:   /gestion-des-produits/supprimer-selection
+  param: { module: kataoProduct, action: deleteMultiple }
+katao_product_filter:
+  url:   /gestion-des-produits/filtrer
+  param: { module: kataoProduct, action: filter }
+katao_product_filter_reset:
+  url:   /gestion-des-produits/filtre/annuler
+  param: { module: kataoProduct, action: filterReset }
+katao_product_search:
+  url:   /gestion-des-produits/rechercher
+  param: { module: kataoProduct, action: search }
+katao_product_search_reset:
+  url:   /gestion-des-produits/recherche/annuler
+  param: { module: kataoProduct, action: searchReset }
+katao_product_archive_multiple:
+  url:   /gestion-des-produits/archiver-selection
+  param: { module: kataoProduct, action: archiveMultiple }
+katao_product_price_adjust:
+  url:   /gestion-des-produits/ajuster-prix-ht
+  param: { module: kataoProduct, action: adjustPrices }
+
+# product categories
+katao_product_category:
+  url:   /gestion-des-rayons
+  param: { module: kataoProductCategory, action: index }
+katao_product_category_show:
+  url:   /gestion-des-rayons/voir/:id
+  param: { module: kataoProductCategory, action: show }
+katao_product_category_add:
+  url:   /gestion-des-rayons/ajouter
+  param: { module: kataoProductCategory, action: create }
+katao_product_category_edit:
+  url:   /gestion-des-rayons/modifier/:id
+  param: { module: kataoProductCategory, action: edit }
+katao_product_category_delete:
+  url:   /gestion-des-rayons/supprimer/:id
+  param: { module: kataoProductCategory, action: delete }
+katao_product_category_delete_multiple:
+  url:   /gestion-des-rayons/supprimer-selection
+  param: { module: kataoProductCategory, action: deleteMultiple }
+
+# product families
+katao_product_family:
+  url:   /gestion-des-familles
+  param: { module: kataoProductFamily, action: index }
+katao_product_family_show:
+  url:   /gestion-des-familles/voir/:id
+  param: { module: kataoProductFamily, action: show }
+katao_product_family_add:
+  url:   /gestion-des-familles/ajouter
+  param: { module: kataoProductFamily, action: create }
+katao_product_family_edit:
+  url:   /gestion-des-familles/modifier/:id
+  param: { module: kataoProductFamily, action: edit }
+katao_product_family_delete:
+  url:   /gestion-des-familles/supprimer/:id
+  param: { module: kataoProductFamily, action: delete }
+katao_product_family_delete_multiple:
+  url:   /gestion-des-familles/supprimer-selection
+  param: { module: kataoProductFamily, action: deleteMultiple }
+katao_product_family_filter:
+  url:   /gestion-des-familles/filtrer
+  param: { module: kataoProductFamily, action: filter }
+katao_product_family_filter_reset:
+  url:   /gestion-des-familles/filtre/annuler
+  param: { module: kataoProductFamily, action: filterReset }
+
+# orders
+katao_order:
+  url:   /gestion-des-commandes
+  param: { module: kataoOrder, action: index }
+katao_order_simulated:
+  url:   /gestion-des-commandes-simulees
+  param: { module: kataoOrder, action: simulated }
+katao_order_delete_simulated:
+  url:   /gestion-des-commandes-simulees/supprimer
+  param: { module: kataoOrder, action: deleteSimulated }
+katao_order_simulated_members:
+  url:   /gestion-des-commandes-simulees/membres/:id
+  param: { module: kataoOrder, action: simulatedMembers }
+katao_order_show:
+  url:   /gestion-des-commandes/voir/:id
+  param: { module: kataoOrder, action: show }
+katao_order_add:
+  url:   /gestion-des-commandes/ajouter
+  param: { module: kataoOrder, action: create }
+katao_order_edit:
+  url:   /gestion-des-commandes/modifier/:id
+  param: { module: kataoOrder, action: edit }
+katao_order_delete:
+  url:   /gestion-des-commandes/supprimer/:id
+  param: { module: kataoOrder, action: delete }
+katao_order_delete_multiple:
+  url:   /gestion-des-commandes/supprimer-selection
+  param: { module: kataoOrder, action: deleteMultiple }
+katao_order_filter:
+  url:   /gestion-des-commandes/filtrer
+  param: { module: kataoOrder, action: filter }
+katao_order_filter_reset:
+  url:   /gestion-des-commandes/filtre/annuler
+  param: { module: kataoOrder, action: filterReset }
+katao_order_generate_invoices:
+  url:   /gestion-des-commandes/generer-factures-adherents
+  param: { module: kataoOrder, action: generateMembersInvoices }
+katao_order_product_adjust:
+  url:   /gestion-des-commandes/ajuster/produit/:id
+  param: { module: kataoOrder, action: adjustProduct }
+katao_order_product_deliver:
+  url:   /gestion-des-commandes/delivrer/produit/:id
+  param: { module: kataoOrder, action: deliverProduct }
+katao_order_pdf:
+  url:   /gestion-des-commandes/exporter/pdf/:id
+  param: { module: kataoOrder, action: exportPDF }
+katao_order_adjust:
+  url:   /gestion-des-commandes/ajuster/:id
+  param: { module: kataoOrder, action: adjust }
+katao_order_adjust_multiple:
+  url:   /gestion-des-commandes/ajuster-selection
+  param: { module: kataoOrder, action: adjustMultiple }
+katao_order_force_adjustment:
+  url:   /gestion-des-commandes/forcer-ajustement/:id
+  param: { module: kataoOrder, action: forceAdjustment }
+katao_order_send:
+  url:   /gestion-des-commandes/envoyer/:id
+  param: { module: kataoOrder, action: send }
+katao_order_receive:
+  url:   /gestion-des-commandes/receptionner/:id
+  param: { module: kataoOrder, action: receive }
+katao_order_deliver:
+  url:   /gestion-des-commandes/delivrer/:id
+  param: { module: kataoOrder, action: deliver }
+katao_order_export_pdf_all:
+  url:   /gestion-des-commandes/exporter-pdf/toutes
+  param: { module: kataoOrder, action: exportPDFAll }
+katao_order_export_pdf_selected:
+  url:   /gestion-des-commandes/exporter-pdf/selection
+  param: { module: kataoOrder, action: exportPDFSelected }
+katao_order_update_invoice:
+  url:   /gestion-des-commandes/mettre-a-jour-facture-fournisseur/:id
+  param: { module: kataoOrder, action: updateInvoice }
+katao_order_export_invoice:
+  url:   /gestion-des-commandes/exporter/bon-reception/pdf/:id
+  param: { module: kataoOrder, action: exportInvoice }
+katao_order_pay_invoice:
+  url:   /gestion-des-commandes/payer/:id
+  param: { module: kataoOrder, action: payInvoice }
+katao_order_receive_new_product:
+  url:   /gestion-des-commandes/receptionner-nouveau-produit/:id
+  param: { module: kataoOrder, action: receiveNewProduct }
+
+# member invoices
+katao_invoice:
+  url:   /gestion-des-factures-adherents
+  param: { module: kataoInvoice, action: index }
+katao_invoice_show:
+  url:   /gestion-des-factures-adherents/voir/:id
+  param: { module: kataoInvoice, action: show }
+katao_invoice_add:
+  url:   /gestion-des-factures-adherents/ajouter
+  param: { module: kataoInvoice, action: create }
+katao_invoice_edit:
+  url:   /gestion-des-factures-adherents/modifier/:id
+  param: { module: kataoInvoice, action: edit }
+katao_invoice_delete:
+  url:   /gestion-des-factures-adherents/supprimer/:id
+  param: { module: kataoInvoice, action: delete }
+katao_invoice_delete_multiple:
+  url:   /gestion-des-factures-adherents/supprimer-selection
+  param: { module: kataoInvoice, action: deleteMultiple }
+katao_invoice_filter:
+  url:   /gestion-des-factures-adherents/filtrer
+  param: { module: kataoInvoice, action: filter }
+katao_invoice_filter_reset:
+  url:   /gestion-des-factures-adherents/filtre/annuler
+  param: { module: kataoInvoice, action: filterReset }
+katao_invoice_pdf:
+  url:   /gestion-des-factures-adherents/exporter/pdf/:id
+  param: { module: kataoInvoice, action: exportPDF }
+katao_invoice_send:
+  url:   /gestion-des-factures-adherents/envoyer/:id
+  param: { module: kataoInvoice, action: send }
+katao_invoice_send_multiple:
+  url:   /gestion-des-factures-adherents/envoyer-selection
+  param: { module: kataoInvoice, action: sendMultiple }
+katao_invoice_export_pdf_all:
+  url:   /gestion-des-factures-adherents/exporter-pdf/toutes
+  param: { module: kataoInvoice, action: exportPDFAll }
+katao_invoice_export_pdf_selected:
+  url:   /gestion-des-factures-adherents/exporter-pdf/selection
+  param: { module: kataoInvoice, action: exportPDFSelected }
+katao_invoice_deliver:
+  url:   /gestion-des-factures-adherents/delivrer/:id
+  param: { module: kataoInvoice, action: deliver }
+katao_invoice_validate:
+  url:   /gestion-des-factures-adherents/valider
+  param: { module: kataoInvoice, action: validate }
+
+# supplier invoices
+katao_supplier_invoice:
+  url:   /gestion-des-factures-fournisseurs
+  param: { module: kataoSupplierInvoice, action: index }
+katao_supplier_invoice_add:
+  url:   /gestion-des-factures-fournisseurs/ajouter
+  param: { module: kataoSupplierInvoice, action: create }
+katao_supplier_invoice_edit:
+  url:   /gestion-des-factures-fournisseurs/modifier/:id
+  param: { module: kataoSupplierInvoice, action: edit }
+katao_supplier_invoice_delete:
+  url:   /gestion-des-factures-fournisseurs/supprimer/:id
+  param: { module: kataoSupplierInvoice, action: delete }
+katao_supplier_invoice_delete_multiple:
+  url:   /gestion-des-factures-fournisseurs/supprimer-selection
+  param: { module: kataoSupplierInvoice, action: deleteMultiple }
+katao_supplier_invoice_filter:
+  url:   /gestion-des-factures-fournisseurs/filtrer
+  param: { module: kataoSupplierInvoice, action: filter }
+katao_supplier_invoice_filter_reset:
+  url:   /gestion-des-factures-fournisseurs/filtre/annuler
+  param: { module: kataoSupplierInvoice, action: filterReset }
+katao_supplier_invoice_pay:
+  url:   /gestion-des-factures-fournisseurs/payer/:id
+  param: { module: kataoSupplierInvoice, action: pay }
+katao_supplier_invoice_export_pdf:
+  url:   /gestion-des-factures-fournisseurs/exporter/pdf/:id
+  param: { module: kataoSupplierInvoice, action: exportPdf }
+katao_supplier_invoice_export_pdf_all:
+  url:   /gestion-des-factures-fournisseurs/exporter-pdf/toutes
+  param: { module: kataoSupplierInvoice, action: exportPDFAll }
+katao_supplier_invoice_export_pdf_selected:
+  url:   /gestion-des-factures-fournisseurs/exporter-pdf/selection
+  param: { module: kataoSupplierInvoice, action: exportPDFSelected }
+
+# member deposits
+katao_member_deposit:
+  url:   /gestion-des-depots
+  param: { module: kataoMemberDeposit, action: index }
+katao_member_deposit_show:
+  url:   /gestion-des-depots/voir/:id
+  param: { module: kataoMemberDeposit, action: show }
+katao_member_deposit_add:
+  url:   /gestion-des-depots/ajouter
+  param: { module: kataoMemberDeposit, action: create }
+katao_member_deposit_edit:
+  url:   /gestion-des-depots/modifier/:id
+  param: { module: kataoMemberDeposit, action: edit }
+katao_member_deposit_delete:
+  url:   /gestion-des-depots/supprimer/:id
+  param: { module: kataoMemberDeposit, action: delete }
+katao_member_deposit_delete_multiple:
+  url:   /gestion-des-depots/supprimer-selection
+  param: { module: kataoMemberDeposit, action: deleteMultiple }
+katao_member_deposit_filter:
+  url:   /gestion-des-depots/filtrer
+  param: { module: kataoMemberDeposit, action: filter }
+katao_member_deposit_filter_reset:
+  url:   /gestion-des-depots/filtre/annuler
+  param: { module: kataoMemberDeposit, action: filterReset }
+katao_member_deposit_dispatch_sols:
+  url:   /gestion-des-depots/repartir-des-sols
+  param: { module: kataoMemberDeposit, action: dispatchSols }
+katao_member_deposit_dispatch_sols_update:
+  url:   /gestion-des-depots/repartir-des-sols/executer
+  param: { module: kataoMemberDeposit, action: dispatchSolsUpdate }
+katao_member_deposit_print_checks:
+  url:   /gestion-des-depots/imprimer-remise-cheques
+  param: { module: kataoMemberDeposit, action: printChecks }
+katao_member_mailing:
+  url:   /mailing
+  param: { module: mailing, action: index }
+katao_member_mailing_save:
+  url: /mailing/save
+  param: { module: mailing, action: save }
+
+# member groups
+katao_member_group:
+  url:   /gestion-des-utilisateurs
+  param: { module: kataoMemberGroup, action: index }
+katao_member_group_delete:
+  url:   /gestion-des-utilisateurs/supprimer/:id
+  param: { module: kataoMemberGroup, action: delete }
+katao_member_group_create:
+  url:   /gestion-des-utilisateurs/ajouter
+  param: { module: kataoMemberGroup, action: create }
+katao_member_group_edit:
+  url:   /gestion-des-utilisateurs/modifier/:id
+  param: { module: kataoMemberGroup, action: edit }
+
+# config
+katao_config:
+  url:   /configuration
+  param: { module: kataoConfig, action: index }
+
+# cron
+cron_check_outdated_member_deposits:
+  url:   /cron/verifier-depots-provisoires-depasses
+  param: { module: cron, action: checkOutdatedMemberDeposits }
+cron_validate_all_carts_before_order_period:
+  url:   /cron/valider-paniers-avant-periode-commande
+  param: { module: cron, action: validateAllCartsBeforeOrderPeriod }
+cron_disable_all_members:
+  url:   /cron/desactiver-membres-nouvelle-annee
+  param: { module: cron, action: disableAllMembers }
+
+default_index:
+  url:   /:module
+  param: { action: index }
+
+default:
+  url:   /:module/:action/*

+ 2 - 0
apps/admin/config/security.yml

@@ -0,0 +1,2 @@
+default:
+  is_secure: on

+ 109 - 0
apps/admin/config/settings.yml

@@ -0,0 +1,109 @@
+prod:
+  .settings:
+    no_script_name:         off
+    logging_enabled:        off
+
+dev:
+  .settings:
+    error_reporting:        <?php echo (E_ALL | E_STRICT)."\n" ?>
+    web_debug:              on
+    cache:                  off
+    no_script_name:         off
+    etag:                   off
+
+all:
+  rich_text_js_dir:  "js/catalyz/tiny_mce"
+
+  .actions:
+    login_module:           user      # To be called when a non-authenticated user
+    login_action:           login     # Tries to access a secure page
+    secure_module:          user      # To be called when a user doesn't have
+    secure_action:          login     # The credentials required for an action
+
+  .settings:
+    # Form security secret (CSRF protection)
+    csrf_secret:       false     # Unique secret to enable CSRF protection or false to disable
+    i18n:                   on
+    compat_10: on
+
+    # Output escaping settings
+    escaping_strategy:      false            # Determines how variables are made available to templates. Accepted values: on, off.
+    escaping_method:        ESC_SPECIALCHARS # Function or helper used for escaping. Accepted values: ESC_RAW, ESC_ENTITIES, ESC_JS, ESC_JS_NO_ENTITIES, and ESC_SPECIALCHARS.
+
+    # Cache settings
+    lazy_cache_key:         on        # Delays creation of a cache key until after checking whether an action or partial is cacheable
+
+    # Helpers included in all templates by default
+    standard_helpers:       [Partial, Cache, Form, Catalyz, cz, sfThumbnail, wpPersistenceManager]
+    enabled_modules:        [wpFlashMessages, wpPersistenceManager, catalyz]
+
+    # Validation settings, used for error generation by the Validation helper
+    validation_error_prefix:    ' &uarr;&nbsp;'
+    validation_error_suffix:    ' &nbsp;&uarr;'
+    validation_error_class:     form_error
+
+
+#all:
+#  .actions:
+#    error_404_module:       default   # To be called when a 404 error is raised
+#    error_404_action:       error404  # Or when the requested URL doesn't match any route
+#
+#    login_module:           default   # To be called when a non-authenticated user
+#    login_action:           login     # Tries to access a secure page
+#
+#    secure_module:          default   # To be called when a user doesn't have
+#    secure_action:          secure    # The credentials required for an action
+#
+#    module_disabled_module: default   # To be called when a user requests
+#    module_disabled_action: disabled  # A module disabled in the module.yml
+#
+#  .settings:
+#    # Optional features. Deactivating unused features boots performance a bit.
+#    use_database:           on        # Enable database manager. Set to off if you don't use a database.
+#    i18n:                   off       # Enable interface translation. Set to off if your application should not be translated.
+#    check_symfony_version:  off       # Enable check of symfony version for every request. Set to on to have symfony clear the cache automatically when the framework is upgraded. Set to off if you always clear the cache after an upgrade.
+#    compressed:             off       # Enable PHP response compression. Set to on to compress the outgoing HTML via the PHP handler.
+#    check_lock:             off       # Enable the application lock system triggered by the clear-cache and disable tasks. Set to on to have all requests to disabled applications redirected to the $sf_symfony_lib_dir/exception/data/unavailable.php page.
+#
+#    # Routing settings
+#    no_script_name:         off       # Enable the front controller name in generated URLs
+#
+#    # Validation settings, used for error generation by the Validation helper
+#    validation_error_prefix:    ' &darr;&nbsp;'
+#    validation_error_suffix:    ' &nbsp;&darr;'
+#    validation_error_class:     form_error
+#    validation_error_id_prefix: error_for_
+#
+#    # Cache settings
+#    cache:                  off       # Enable the template cache
+#    etag:                   on        # Enable etag handling
+#    lazy_cache_key:         off       # Delays creation of a cache key until after checking whether an action or partial is cacheable (defaults to false for backward compatibility)
+#
+#    # Logging and debugging settings
+#    web_debug:              off       # Enable the web debug toolbar
+#    error_reporting:        <?php echo (E_PARSE | E_COMPILE_ERROR | E_ERROR | E_CORE_ERROR | E_USER_ERROR)."\n" ?> # Determines which events are logged.
+#
+#    # Assets paths
+#    rich_text_js_dir:       js/tiny_mce
+#    admin_web_dir:          /sf/sf_admin
+#    web_debug_web_dir:      /sf/sf_web_debug
+#    calendar_web_dir:       /sf/calendar
+#
+#    # Helpers included in all templates by default
+#    standard_helpers:       [Partial, Cache, Form]
+#
+#    # Activated modules from plugins or from the symfony core
+#    enabled_modules:        [default]
+#
+#    # Charset used for the response
+#    charset:                utf-8
+#
+#    # Miscellaneous
+#    strip_comments:         on         # Remove comments in core framework classes as defined in the core_compile.yml
+#    max_forwards:           5
+#
+#    # Logging
+#    logging_enabled:        on
+#
+#    # i18n
+#    default_culture:        en        # Default user culture

+ 17 - 0
apps/admin/config/view.yml

@@ -0,0 +1,17 @@
+default:
+  http_metas:
+    content-type: text/html
+
+  metas:
+    title:        Katao, faites le choix des Hommes et de la Nature...
+    #description:  symfony project
+    #keywords:     symfony, project
+    language:     fr
+    #robots:       index, follow
+
+  stylesheets:    [main.css, admin.css]
+
+  javascripts:    [prototype.js]
+
+  has_layout:     on
+  layout:         layout

+ 13 - 0
apps/admin/i18n/fr/messages.xml

@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE xliff PUBLIC "-//XLIFF//DTD XLIFF//EN" "http://www.oasis-open.org/committees/xliff/documents/xliff.dtd">
+<xliff version="1.0">
+	<file source-language="EN" target-language="fr" datatype="plaintext" original="messages" date="2009-02-08T19:41:58Z" product-name="messages">
+		<header/>
+		<body>
+			<trans-unit id="">
+				<source>Required.</source>
+				<target>Requis.</target>
+			</trans-unit>
+		</body>
+	</file>
+</xliff>

+ 36 - 0
apps/admin/lib/myUser.class.php

@@ -0,0 +1,36 @@
+<?php
+
+class myUser extends sfBasicSecurityUser {
+    public function signIn($form_values) {
+        $katao_user =/*(KataoUser)*/ KataoUserPeer::getUserByLoginAndPassword($form_values['login'], $form_values['password']);
+        setlocale(LC_TIME, 'fr');
+        $this->setInstance($katao_user);
+        // Credentials and authentication:
+        $this->addCredentials($katao_user->getCredentials());
+        $this->setAuthenticated(true);
+        $this->setCulture('fr');
+    }
+
+    public function signOut() {
+        $this->setAuthenticated(false);
+        $this->clearCredentials();
+        $this->getAttributeHolder()->removeNamespace();
+    }
+
+    public function setInstance(KataoUser $user) {
+        return $this->setAttribute('user', $user);
+    }
+    public function getInstance() {
+        return $this->getAttribute('user', null);
+    }
+
+    public function isJustDelegate() {
+        return !$this->hasCredential('admin') && !$this->hasCredential('seo') && !$this->hasCredential('supplier') && $this->hasCredential('delegate') && !$this->hasCredential('referer');
+    }
+    public function isJustReferer() {
+        return !$this->hasCredential('admin') && !$this->hasCredential('seo') && !$this->hasCredential('supplier') && !$this->hasCredential('delegate') && $this->hasCredential('referer');
+    }
+    public function isJustSupplier() {
+        return !$this->hasCredential('admin') && !$this->hasCredential('seo') && $this->hasCredential('supplier') && !$this->hasCredential('delegate') && !$this->hasCredential('referer');
+    }
+}

+ 56 - 0
apps/admin/lib/stats.class.php

@@ -0,0 +1,56 @@
+<?php
+
+class stats {
+    public static function getMembersCountByNode() {
+        $return = array();
+
+        $criteria = new Criteria();
+        $criteria->addSelectColumn(KataoNodePeer::ID);
+        $criteria->addSelectColumn(KataoNodePeer::CITY);
+        $criteria->addAsColumn('members_count', sprintf('COUNT(DISTINCT(%s))', KataoMemberPeer::ID));
+        $criteria->addJoin(KataoNodePeer::ID, KataoMemberPeer::KATAO_NODE_ID, Criteria::LEFT_JOIN);
+        $criteria->addGroupByColumn(KataoNodePeer::CITY);
+
+        $rs = KataoNodePeer::doSelectRS($criteria);
+        while ($rs->next()) {
+            $return[$rs->getInt(1)] = array('name' => $rs->getString(2), 'members_count' => $rs->getInt(3));
+        }
+
+        return $return;
+    }
+
+    public static function getInvoicesSumByPeriodAndNode() {
+        $return = array();
+
+        $katao_nodes = KataoNodePeer::getAllArray();
+        foreach (KataoPeriodPeer::getAllArray() as $katao_period_id => $katao_period) {
+            foreach ($katao_nodes as $katao_node_id => $katao_node_name) {
+                $return[$katao_period_id]['name'] = $katao_period['name'];
+                $return[$katao_period_id]['status'] = $katao_period['status'];
+                $return[$katao_period_id]['amount'] = 0;
+                $return[$katao_period_id]['nodes_list'][$katao_node_id]['name'] = $katao_node_name;
+                $return[$katao_period_id]['nodes_list'][$katao_node_id]['amount'] = 0;
+            }
+        }
+
+        $criteria = new Criteria();
+        $criteria->addSelectColumn(KataoPeriodPeer::ID);
+        $criteria->addSelectColumn(KataoNodePeer::ID);
+        $criteria->addSelectColumn(KataoNodePeer::CITY);
+        $criteria->addAsColumn('amount', sprintf('SUM(%s * %s)', KataoInvoiceProductPeer::QUANTITY, KataoInvoiceProductPeer::PRODUCT_PRICE_EURO));
+        $criteria->addJoin(KataoInvoicePeer::KATAO_PERIOD_ID, KataoPeriodPeer::ID);
+        $criteria->addJoin(KataoInvoicePeer::KATAO_NODE_ID, KataoNodePeer::ID);
+        $criteria->addJoin(KataoInvoicePeer::ID, KataoInvoiceProductPeer::KATAO_INVOICE_ID);
+        $criteria->addGroupByColumn(KataoPeriodPeer::NAME);
+        $criteria->addGroupByColumn(KataoNodePeer::CITY);
+
+        $rs = KataoInvoiceProductPeer::doSelectRS($criteria);
+        while ($rs->next()) {
+            $return[$rs->getInt(1)]['amount'] += $rs->getFloat(4);
+            $return[$rs->getInt(1)]['nodes_list'][$rs->getInt(2)]['name'] = $rs->getString(3);
+            $return[$rs->getInt(1)]['nodes_list'][$rs->getInt(2)]['amount'] = $rs->getFloat(4);
+        }
+
+        return $return;
+    }
+}

+ 181 - 0
apps/admin/modules/cron/actions/actions.class.php

@@ -0,0 +1,181 @@
+<?php
+
+/**
+ * cron actions.
+ *
+ * @package www.katao.fr
+ * @subpackage cron
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
+ */
+class cronActions extends sfActions {
+    public function preExecute() {
+        parent::preExecute();
+        sfLoader::loadHelpers(array('Tag', 'Url'));
+    }
+
+    public function executeCheckOutdatedMemberDeposits($request) {
+        // retrieve all deposits with pending status and "valid until" date before current time
+        $criteria = new Criteria();
+        $criteria->add(KataoMemberDepositPeer::STATUS, KataoMemberDeposit::STATUS_PENDING);
+        $criteria->add(KataoMemberDepositPeer::VALID_UNTIL, date('Y-m-d H:i:s'), Criteria::LESS_THAN);
+        $katao_member_deposits = KataoMemberDepositPeer::doSelectJoinKataoMember($criteria);
+
+        if (0 < count($katao_member_deposits)) {
+            $mailer = new wpMail();
+            foreach ($katao_member_deposits as/*(KataoMemberDeposit)*/ $katao_member_deposit) {
+                // set deposit status to expired
+                $katao_member_deposit->setStatus(KataoMemberDeposit::STATUS_EXPIRED);
+                $katao_member_deposit->save();
+                // update member current amount to cancel deposit
+                $katao_member =/*(KataoMember)*/ $katao_member_deposit->getKataoMember();
+                if (KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL == $katao_member_deposit->getPaymentMode()) {
+                    $katao_member->setInitialAmount($katao_member->getCurrentAmount() + $katao_member_deposit->getAmount());
+                } else {
+                    $katao_member->setInitialAmount($katao_member->getCurrentAmount() - $katao_member_deposit->getAmount());
+                }
+                $katao_member->save();
+                // send an email to seo to notify him/her
+                if (null != $katao_user = $katao_member->getFirstKataoUser()) {
+                    $katao_member_seo = wpConfig::getInstance()->getKataoMember();
+                    if (null != $katao_user_seo = $katao_member_seo->getFirstKataoUser()) {
+                        try {
+                            $swift_message = new Swift_Message('Votre dépot ne nous est pas parvenu à ce jour', sprintf('%s,
+
+Attention, tu t\'étais engagé(e) le %s a nous envoyer %s
+avant le %s afin d\'honorer le paiement de tes demandes.
+
+Cette date vient d\'arriver à échéance.
+
+Si ton solde %s est inferieur à ta prochaine demande,
+
+ELLE NE SERA PAS PRIS EN COMPTE DANS LES COMMANDES FOURNISSEURS.
+
+Merci de prendre contact rapidement avec %s au %s
+afin de régulariser ta situation
+%s', $katao_member->getFirstName(), $katao_member_deposit->getCreatedAtStr(), $katao_member_deposit->getAmountStr(), CatalyzDate::formatShort($katao_member_deposit->getValidUntil(null)), $katao_member->getCurrentAmountEuroStr(), $katao_member_seo->getFirstName(), $katao_user_seo->getPhone(), Utils::getKataoEmailFooter()));
+                            $mailer->send($swift_message, new Swift_Address($katao_member->getFirstKataoUser()->getEmail(), $katao_member->getFullName()), sfConfig::get('app_mail_from'));
+                            $mailer->send($swift_message, new Swift_Address($katao_user_seo->getEmail(), $katao_user_seo->getFullName()), sfConfig::get('app_mail_from'));
+                        }
+                        catch (Exception $e) {
+                            $mailer->disconnect();
+                        }
+                    }
+                }
+            }
+            $mailer->disconnect();
+        }
+
+        return sfView::HEADER_ONLY;
+    }
+
+    public function executeValidateAllCartsBeforeOrderPeriod($request) {
+        // retrieve active period
+        if (null != $katao_period = KataoPeriodPeer::getActivePeriod()) {
+            // check if we are after the delay before automatic validation
+            if (date('Y-m-d') == date('Y-m-d', strtotime(sprintf('-%d days', wpConfig::getCartValidationDaysNumber()), $katao_period->getOrderEndedAt(null)))) {
+                // retrieve all carts with pending status for current period
+                $criteria = new Criteria();
+                $criteria->addJoin(KataoCartPeer::KATAO_USER_ID, KataoUserPeer::ID);
+                $criteria->add(KataoCartPeer::STATUS, KataoCart::STATUS_IN_PROGRESS);
+                $criteria->add(KataoCartPeer::KATAO_PERIOD_ID, $katao_period->getId());
+                $criteria->add(KataoUserPeer::IS_MEMBER, true);
+                foreach (KataoCartPeer::doSelectJoinKataoUser($criteria) as/*(KataoCart)*/ $katao_cart) {
+                    // set cart status to validated
+                    $katao_cart->setStatus(KataoCart::STATUS_VALIDATED);
+                    $katao_cart->save();
+                    // send an email to member with a link to unvalidate his cart
+                    if (null != $katao_user = $katao_cart->getKataoUser()) {
+                        try {
+                            $mailer = new wpMail();
+                            $mailer->send(new Swift_Message('KATAO : validation automatique de votre panier', sprintf('Bonjour %s,
+
+Votre panier vient d\'être automatiquement validé car la période de commande se termine bientôt.
+
+Cliquez sur le lien ci-dessous pour accèder à votre panier si vous souhaitez y faire des modifications.
+%smon-panier
+
+A bientôt,
+L\'équipe KATAO', $katao_user->getFullName(), $katao_user->getLogin(), $katao_user->getPassword(), sfConfig::get('app_katao_frontend_url'))), new Swift_Address($katao_user->getEmail(), $katao_user->getFullName()), sfConfig::get('app_mail_from'));
+                            $mailer->disconnect();
+                        }
+                        catch (Exception $e) {
+                            $mailer->disconnect();
+                        }
+                    }
+                }
+            }
+        }
+
+        return sfView::HEADER_ONLY;
+    }
+
+    public function executeDisableAllMembers($request) {
+        if ('01-01' == date('m-d')) {
+            $criteria = new Criteria();
+            $criteria->addJoin(KataoUserPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+            $criteria->add(KataoUserPeer::EMAIL, null, Criteria::NOT_EQUAL);
+            $criteria->add(KataoUserPeer::EMAIL, '', Criteria::NOT_EQUAL);
+            $criteria->add(KataoMemberPeer::IS_MEMBER, true);
+            $katao_users = KataoUserPeer::doSelectJoinKataoMember($criteria);
+
+            if (0 < count($katao_users)) {
+                if (null != $katao_member_seo = wpConfig::getInstance()->getKataoMember()) {
+                    $year = date('Y');
+                    $katao_user_seo = $katao_member_seo->getFirstKataoUser();
+
+                    $katao_node_transactions = array();
+                    $katao_node_transactions[0]['members'] = Utils::getKataoMembersCount(false);
+                    $katao_node_transactions[0]['count'] = Utils::getKataoTransactionsCount(false, $year);
+                    $katao_node_transactions[0]['sum'] = Utils::getKataoTransactionsSum(false, $year);
+                    foreach (KataoNodePeer::getAllArray() as $katao_node_id => $katao_node_city) {
+                        $katao_node_transactions[$katao_node_id]['members'] = Utils::getKataoMembersCount($katao_node_id);
+                        $katao_node_transactions[$katao_node_id]['count'] = Utils::getKataoTransactionsCount($katao_node_id, $year);
+                        $katao_node_transactions[$katao_node_id]['sum'] = Utils::getKataoTransactionsSum($katao_node_id, $year);
+                    }
+
+                    $mailer = new wpMail();
+                    foreach ($katao_users as/*(KataoUser)*/ $katao_user) {
+                        $katao_member = $katao_user->getKataoMember();
+                        $katao_node = $katao_member->getKataoNode();
+
+                        try {
+                            $mailer->send(new Swift_Message(sprintf('KATAO : Bonne année %d', $year), sprintf('%s,
+
+Toute l\'équipe de katao te souhaite une bonne et heureuse année %d.
+Que toi et ta famille profitent au mieux de ce nouveau tour de soleil pour réaliser tout ce qui ne nuit pas à autrui et à notre bonne et vielle planète !
+
+A ce titre, dans le respect des hommes et de la nature, dans notre noeud %s nous sommes %d et avons l\'année dernière réalisé %d transactions pour un montant de %s
+
+Sur tout le réseau katao, nous sommes %d et avons l\'année dernière réalisé %d transactions pour un montant de %s
+
+Continuons donc notre marche pour réduire notre empreinte écologique tout en nous faisant plaisr !
+
+Comme chaque année, ton compte vient d\'être désactivé.
+Si tu veux continuer cette année à réaliser tes achats sur notre réseau, il te faut renouveller ton adhésion en faisant un chèque de %s à l\'ordre de "KATAO ASSOCIATION" et l\'envoyer à l\'adresse :
+
+%s
+%s
+
+Pour toute information, prend contact avec %s au %s.
+%s', $katao_member->getFirstName(), $year, $katao_node->getCity(),
+                                        $katao_node_transactions[$katao_node->getId()]['members'], $katao_node_transactions[$katao_node->getId()]['count'], $katao_node_transactions[$katao_node->getId()]['sum'],
+                                        $katao_node_transactions[0]['members'], $katao_node_transactions[0]['count'], $katao_node_transactions[0]['sum'],
+                                        wpConfig::getMemberFeeStr(), $katao_user_seo->getFullName(), $katao_user_seo->getFullAdress(), $katao_member_seo->getFirstName(), $katao_user_seo->getPhone(),
+                                        Utils::getKataoEmailFooter())), new Swift_Address($katao_user->getEmail(), $katao_user->getFullName()), sfConfig::get('app_mail_from'));
+                        }
+                        catch (Exception $e) {
+                            $mailer->disconnect();
+                        }
+
+                        $katao_member->setIsMember(false);
+                        $katao_member->save();
+                    }
+                    $mailer->disconnect();
+                }
+            }
+        }
+
+        return sfView::HEADER_ONLY;
+    }
+}

+ 2 - 0
apps/admin/modules/cron/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  is_secure: off

+ 11 - 0
apps/admin/modules/katao/templates/_relanceEmail.php

@@ -0,0 +1,11 @@
+<p>Cher(e) adhérent(e)</p>
+<p>&nbsp;</p>
+<p>Votre adhésion pour cette nouvelle année civile est arrivée à échance, nous vous prions de la renouveler.</p>
+<p>Vous pouvez vous rendre sur l'espace adhésion du site SOL-Violette :</p>
+<p>Si vous etes soliste : <a href="http://www.sol-violette.info/citoyen/adherer">www.sol-violette.info/citoyen/adherer</a></p>
+<p>Si vous etes prestataire : <a href="http://www.sol-violette.info/prestataire/devenirprestataire">www.sol-violette.info/prestataire/devenirprestataire</a></p>
+<p>&nbsp;</p>
+<p>&nbsp;</p>
+<p>L'Equipe du Sol-violette</p>
+<p><img src="http://www.sol-violette.fr/images/logo.jpg" alt="sol-violette"/></p>
+<p>PS: Si vous avez deja reglé votre adhésion, ne tenez pas compte de ce mail.</p>

+ 92 - 0
apps/admin/modules/katao/templates/_user.php

@@ -0,0 +1,92 @@
+	<?php if ($is_member): ?>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Informations utilisateur</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_email']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_email'] ?>
+		  <?php echo $form['user_email']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_address1']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_address1'] ?>
+		  <?php echo $form['user_address1']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_address2']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_address2'] ?>
+		  <?php echo $form['user_address2']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_zip']->renderLabel() ?> / <?php echo $form['user_city']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_zip'] ?>
+          <?php echo $form['user_city'] ?>
+		  <?php echo $form['user_zip']->renderError() ?>
+		  <?php echo $form['user_city']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_phone']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_phone'] ?>
+		  <?php echo $form['user_phone']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_fax']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_fax'] ?>
+		  <?php echo $form['user_fax']->renderError() ?>
+        </td>
+      </tr>
+	<?php endif ?>
+	<?php if (!$is_member && $sf_user->isJustReferer()): ?>
+      <tr valign="top">
+        <th align="left"><label>Etat</label></th>
+        <td>
+          <?php echo KataoUserPeer::getStatusStr($form['user_status']->getValue()) ?>
+		  <?php echo input_hidden_tag('katao_supplier[user_status]', $form['user_status']->getValue()) ?>
+        </td>
+      </tr>
+    <?php else: ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_status']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_status'] ?>
+		  <?php echo $form['user_status']->renderError() ?>
+        </td>
+      </tr>
+      <?php
+
+		  ?>
+    <?php endif ?>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Accès application</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_login']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_login'] ?>
+		  <?php echo $form['user_login']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['user_password']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['user_password'] ?>
+		  <?php echo $form['user_password']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <td colspan="2">
+          <br /><?php echo $form['update_gmap'] ?><?php echo $form['update_gmap']->renderLabel() ?>
+		  <?php echo $form['update_gmap']->renderError() ?>
+        </td>
+      </tr>

+ 350 - 0
apps/admin/modules/kataoCart/actions/actions.class.php

@@ -0,0 +1,350 @@
+<?php
+
+/**
+ * kataoCart actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoCart
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoCartActions extends wpActions {
+    public function preExecute() {
+        parent::preExecute();
+        sfLoader::loadHelpers(array('Asset'));
+    }
+
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoCartPeer::KATAO_USER_ID, KataoUserPeer::ID);
+        $criteria->addJoin(KataoUserPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+
+        if ($this->getUser()->isJustDelegate()) {
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId());
+        }
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'date')) {
+            case 'no':
+                $criteria->$sort_method(KataoCartPeer::ID);
+                break;
+            case 'status':
+                $criteria->$sort_method(KataoCartPeer::STATUS);
+                break;
+            case 'member':
+                $criteria->$sort_method(KataoMemberPeer::LAST_NAME);
+                $criteria->$sort_method(KataoMemberPeer::FIRST_NAME);
+                break;
+            case 'node':
+                $criteria->$sort_method(KataoCartPeer::KATAO_NODE_ID);
+                break;
+            case 'period':
+                $criteria->$sort_method(KataoCartPeer::KATAO_PERIOD_ID);
+                break;
+            default:
+                $criteria->$sort_method(KataoCartPeer::CREATED_AT);
+        }
+
+        if ('' != $this->filter_status = $this->getUser()->getAttribute('katao_cart_filter_status')) {
+            $criteria->add(KataoCartPeer::STATUS, $this->filter_status);
+        }
+        if ('' != $this->filter_member = $this->getUser()->getAttribute('katao_cart_filter_member')) {
+            $criteria->add(KataoCartPeer::KATAO_USER_ID, $this->filter_member);
+        }
+        if ('' != $this->filter_node = $this->getUser()->getAttribute('katao_cart_filter_node')) {
+            $criteria->add(KataoCartPeer::KATAO_NODE_ID, $this->filter_node);
+        }
+        if ('' != $this->filter_period = $this->getUser()->getAttribute('katao_cart_filter_period', KataoPeriodPeer::getActivePeriod()->getId())) {
+            $criteria->add(KataoCartPeer::KATAO_PERIOD_ID, $this->filter_period);
+        }
+
+        $pager = new sfPropelPager('KataoCart', sfConfig::get('app_pager'));
+        $pager->setPeerMethod('doSelectJoinAll');
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_cartList = $pager->getResults();
+
+        $this->katao_period = KataoPeriodPeer::getActivePeriod();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_cart_filter_status', $request->getParameter('filter_status'));
+        $this->getUser()->setAttribute('katao_cart_filter_member', $request->getParameter('filter_member'));
+        $this->getUser()->setAttribute('katao_cart_filter_node', $request->getParameter('filter_node'));
+        $this->getUser()->setAttribute('katao_cart_filter_period', $request->getParameter('filter_period'));
+        return $this->redirect('kataoCart/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_cart_filter_status', '');
+        $this->getUser()->setAttribute('katao_cart_filter_member', '');
+        $this->getUser()->setAttribute('katao_cart_filter_node', '');
+        $this->getUser()->setAttribute('katao_cart_filter_period', KataoPeriodPeer::getActivePeriod()->getId());
+        return $this->redirect('kataoCart/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_cart = KataoCartPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_cart, 'Demande #' . $request->getParameter('id') . ' inconnue.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoCartForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $this->form = new KataoCartForm(KataoCartPeer::retrieveByPk($request->getParameter('id')));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoCartForm(KataoCartPeer::retrieveByPk($request->getParameter('id')));
+
+        $this->form->bind($request->getParameter('katao_cart'));
+        if ($this->form->isValid()) {
+            $katao_cart = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Demande "' . $katao_cart->getMemberName() . '" sauvée avec succès.');
+            $this->redirect('kataoCart/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_cart = KataoCartPeer::retrieveByPk($request->getParameter('id')), 'Demande #' . $request->getParameter('id') . ' inconnue.');
+
+        $katao_cart->delete();
+
+        wpFlashMessages::addConfirmation('Demande "' . $katao_cart->getMemberName() . '" supprimée avec succès.');
+        $this->redirect('kataoCart/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_cart')) {
+            $criteria = new Criteria();
+            $criteria->add(KataoCartPeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_cart')), Criteria::IN);
+            KataoCartPeer::doDelete($criteria);
+
+            wpPersistenceManager::cleanSelection('katao_cart');
+            wpFlashMessages::addConfirmation('Les demandes sélectionnées ont été supprimées avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une demande.');
+        }
+
+        $this->redirect('kataoCart/index');
+    }
+
+    public function executeGenerateSuppliersOrders($request) {
+        $this->redirectWithErrorUnless($katao_period = KataoPeriodPeer::retrieveByPK((int)$this->getUser()->getAttribute('katao_cart_filter_period', KataoPeriodPeer::getActivePeriod()->getId())), 'Merci de filtrer les demandes sur une période avant de générer les commandes fournisseurs.', 'kataoCart/index');
+        // $this->redirectWithErrorIf(!Utils::between(time(), $katao_period->getOrderEndedAt(null), $katao_period->getFinishAt(null)));
+        $katao_node_ids = array();
+        if ($this->getUser()->isJustDelegate()) {
+            $katao_node_ids[] = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+        } elseif (!$request->isMethod('post')) {
+            $this->katao_node_ids = $katao_period->getKataoNodeIdsForSupplierOrders();
+            return sfView::SUCCESS;
+        } else {
+            $katao_node_ids = $request->getParameter('katao_node_ids', array());
+        }
+
+        $katao_order_count = 0;
+        if (0 < count($katao_node_ids)) {
+            $criteria = new Criteria();
+            $criteria->add(KataoOrderPeer::STATUS, array(KataoOrder::STATUS_GENERATED, KataoOrder::STATUS_ADJUSTED), Criteria::NOT_IN);
+            $criteria->add(KataoOrderPeer::KATAO_PERIOD_ID, $katao_period->getId());
+            $criteria->add(KataoOrderPeer::KATAO_NODE_ID, $katao_node_ids, Criteria::IN);
+            if (0 < KataoOrderPeer::doCount($criteria)) {
+                wpFlashMessages::addError('Impossible de re-générer les commandes pour ces noeuds et cette période car une commande à déjà été envoyée.');
+                return $this->redirect('kataoCart/index');
+            }
+
+            $criteria = new Criteria();
+            $criteria->add(KataoOrderPeer::STATUS, array(KataoOrder::STATUS_GENERATED, KataoOrder::STATUS_ADJUSTED), Criteria::IN);
+            $criteria->add(KataoOrderPeer::KATAO_PERIOD_ID, $katao_period->getId());
+            $criteria->add(KataoOrderPeer::KATAO_NODE_ID, $katao_node_ids, Criteria::IN);
+            if (0 < $katao_order_deleted = KataoOrderPeer::doDelete($criteria)) {
+                wpFlashMessages::addInformation('Certaines commandes fournisseurs ont été re-générées (' . $katao_order_deleted . ' au total).');
+            }
+
+            $products_by_node_and_period_and_supplier = array();
+
+            $criteria = new Criteria();
+            $criteria->add(KataoCartPeer::KATAO_PERIOD_ID, $katao_period->getId());
+            $criteria->add(KataoCartPeer::KATAO_NODE_ID, $katao_node_ids, Criteria::IN);
+
+            $is_simulated = false;
+            foreach (KataoCartPeer::doSelect($criteria) as/*(KataoCart)*/ $katao_cart) {
+                if (KataoCart::STATUS_VALIDATED != $katao_cart->getStatus()) {
+                    $is_simulated = true;
+                }
+                foreach ($katao_cart->getKataoCartProductsJoinKataoProduct() as/*(KataoCartProduct)*/ $katao_cart_product) {
+                    $katao_product = $katao_cart_product->getKataoProduct();
+                    if (!isset($products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['quantity'])) {
+                        $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['quantity'] = 0;
+                    }
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['quantity'] += $katao_cart_product->getQuantity();
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['reference'] = $katao_product->getReference();
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['name'] = $katao_product->getName();
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['price_euro'] = $katao_product->getUnitPriceEuro();
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['margin'] = $katao_product->getMargin();
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['tva_rate'] = $katao_product->getTvaRate();
+                    $products_by_node_and_period_and_supplier[$katao_cart->getKataoNodeId()][$katao_cart->getKataoPeriodId()][$katao_product->getKataoSupplierId()][$katao_product->getId()]['katao_cart_products'][] = $katao_cart_product;
+                }
+            }
+
+            foreach ($products_by_node_and_period_and_supplier as $katao_node_id => $periods) {
+                foreach ($periods as $katao_period_id => $suppliers) {
+                    foreach ($suppliers as $katao_supplier_id => $products) {
+                        if (null != $katao_supplier = KataoSupplierPeer::retrieveByPK($katao_supplier_id)) {
+                            $katao_order = new KataoOrder();
+
+                            $katao_order->setIsSimulated($is_simulated);
+
+                            $katao_order->setKataoSupplierId($katao_supplier_id);
+                            $katao_order->setKataoNodeId($katao_node_id);
+                            $katao_order->setKataoPeriodId($katao_period_id);
+                            $katao_order->setStatus(KataoOrder::STATUS_GENERATED);
+
+                            $katao_order->setSupplierName($katao_supplier->getName());
+                            $katao_order->setSupplierEmail($katao_supplier->getEmail());
+                            $katao_order->setSupplierAddress1($katao_supplier->getAddress1());
+                            $katao_order->setSupplierAddress2($katao_supplier->getAddress2());
+                            $katao_order->setSupplierZip($katao_supplier->getZip());
+                            $katao_order->setSupplierCity($katao_supplier->getCity());
+
+                            $katao_order->setKataoName(wpConfig::getName());
+                            $katao_order->setKataoAddress(wpConfig::getAddress());
+                            $katao_order->setKataoSiretNumber(wpConfig::getSiretNumber());
+                            $katao_order->setKataoRcsNumber(wpConfig::getRCSNumber());
+                            $katao_order->setKataoCapital(wpConfig::getCapital());
+
+                            $katao_order->save();
+
+                            $katao_order_count++;
+
+                            foreach ($products as $katao_product_id => $product_data) {
+                                $katao_order_product = new KataoOrderProduct();
+                                $katao_order_product->setKataoOrder($katao_order);
+                                $katao_order_product->setKataoProductId($katao_product_id);
+                                $katao_order_product->setProductReference($product_data['reference']);
+                                $katao_order_product->setProductName($product_data['name']);
+                                $katao_order_product->setProductPriceEuro($product_data['price_euro']);
+                                $katao_order_product->setProductMargin($product_data['margin']);
+                                $katao_order_product->setProductTvaRate($product_data['tva_rate']);
+                                $katao_order_product->setQuantity($product_data['quantity']);
+                                $katao_order_product->save();
+
+                                foreach ($product_data['katao_cart_products'] as $katao_cart_product) {
+                                    $katao_cart_product->setKataoOrderProduct($katao_order_product);
+                                    $katao_cart_product->setQuantityAdjusted($katao_cart_product->getQuantity());
+                                    $katao_cart_product->setHasBeenAdjusted(true);
+                                    $katao_cart_product->save();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (0 < $katao_order_count) {
+            wpFlashMessages::addConfirmation('Commandes fournisseurs générées avec succès (' . $katao_order_count . ' au total).');
+            if ($is_simulated) {
+                $this->redirect('kataoOrder/simulated');
+            } else {
+                $this->redirect('kataoOrder/index');
+            }
+        }
+
+        wpFlashMessages::addWarning('Aucune commande fournisseur n\'a été générée.');
+        $this->redirect('kataoCart/index');
+    }
+
+    public function executeExportPDF($request) {
+        $this->redirectWithErrorUnless($katao_cart = KataoCartPeer::retrieveByPk($request->getParameter('id')), 'Demande #' . $request->getParameter('id') . ' inconnue.');
+
+        $content = $katao_cart->generatePDF();
+
+        $response = $this->getResponse();
+        $response->setContentType('application/pdf');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="' . $katao_cart->getNumber() . '.pdf"');
+        $response->setHttpHeader('Content-Length', strlen($content));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent($content);
+        return sfView::NONE;
+    }
+
+    public function executeExportPDFAll($request) {
+        $criteria = new Criteria();
+        if ($this->getUser()->isJustDelegate()) {
+            $criteria->addJoin(KataoCartPeer::KATAO_USER_ID, KataoUserPeer::ID);
+            $criteria->addJoin(KataoUserPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId());
+        }
+        $criteria->addAscendingOrderByColumn(KataoCartPeer::ID);
+        return $this->exportCartsToPDF(KataoCartPeer::doSelect($criteria));
+    }
+
+    public function executeExportPDFSelected($request) {
+        if (!wpPersistenceManager::isEmpty('katao_cart')) {
+            $criteria = new Criteria();
+            $criteria->add(KataoCartPeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_cart')), Criteria::IN);
+            $criteria->addAscendingOrderByColumn(KataoCartPeer::ID);
+            return $this->exportCartsToPDF(KataoCartPeer::doSelect($criteria));
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une demande.');
+            $this->redirect('kataoCart/index');
+        }
+    }
+
+    protected function exportCartsToPDF($katao_carts) {
+        $file = tempnam('tmp', 'zip');
+        $archive = new ZipArchive();
+        $archive->open($file, ZipArchive::OVERWRITE);
+
+        foreach ($katao_carts as/*(KataoCart)*/ $katao_cart) {
+            $archive->addFromString($katao_cart->getNumber() . '.pdf', $katao_cart->generatePDF());
+        }
+
+        $archive->close();
+
+        $response = $this->getResponse();
+        $response->setContentType('application/zip');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="KATAO_Demandes_' . date('Y-m-d') . '.zip"');
+        $response->setHttpHeader('Content-Length', filesize($file));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent(file_get_contents($file));
+        return sfView::NONE;
+    }
+
+    public function executeValidate($request) {
+        $this->redirectWithErrorUnless($katao_cart = KataoCartPeer::retrieveByPk($request->getParameter('id')), 'Demande #' . $request->getParameter('id') . ' inconnue.');
+
+        $katao_cart->setStatus(KataoCart::STATUS_VALIDATED);
+        $katao_cart->save();
+
+        wpFlashMessages::addConfirmation('Demande "' . $katao_cart->getNumber() . '" validée avec succès.');
+        $this->redirect('kataoCart/index');
+    }
+
+    public function executeUnvalidate($request) {
+        $this->redirectWithErrorUnless($katao_cart = KataoCartPeer::retrieveByPk($request->getParameter('id')), 'Demande #' . $request->getParameter('id') . ' inconnue.');
+
+        $katao_cart->setStatus(KataoCart::STATUS_IN_PROGRESS);
+        $katao_cart->save();
+
+        wpFlashMessages::addConfirmation('Demande "' . $katao_cart->getNumber() . '" dé-validée avec succès.');
+        $this->redirect('kataoCart/index');
+    }
+}

+ 2 - 0
apps/admin/modules/kataoCart/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  credentials: [[ admin, seo, delegate ]]

+ 49 - 0
apps/admin/modules/kataoCart/templates/editSuccess.php

@@ -0,0 +1,49 @@
+<?php $katao_cart = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_cart->isNew() ? 'Ajout' : 'Modification' ?> d'une demande</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoCart/update'.(!$katao_cart->isNew() ? '?id='.$katao_cart->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoCart/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+	  <tr valign="top">
+        <th align="left"><?php echo $form['katao_user_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_user_id'] ?>
+		  <?php echo $form['katao_user_id']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+        <th align="left"><?php echo $form['katao_node_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_node_id'] ?>
+		  <?php echo $form['katao_node_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_period_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_period_id'] ?>
+		  <?php echo $form['katao_period_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['status']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['status'] ?>
+		  <?php echo $form['status']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 55 - 0
apps/admin/modules/kataoCart/templates/generateSuppliersOrdersSuccess.php

@@ -0,0 +1,55 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Génération des commandes fournisseurs</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoCart/generateSuppliersOrders') ?>" method="post">
+
+<p><i>Sélectioner ci-dessous les noeuds pour lesquels vous souhaitez générer les commandes fournisseurs.<br />Ceux qui sont grisés correspondent aux noeuds où au moins une commande a été générée.</i></p>
+
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Générer" /> ou <a href="<?php echo url_for('kataoCart/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <td><?php echo checkbox_tag('katao_node_all', 1, false, array('onclick' => 'toggleCheckboxes(this.checked);')) ?></td>
+        <td><i><?php echo label_for('katao_node_all', 'Sélectionner tous les noeuds') ?></i></td>
+      </tr>
+      <tr><td colspan="2">&nbsp;</td></tr>
+	<?php foreach ($katao_node_ids as $kata_node_id => $kata_node_data): ?>
+      <tr valign="top">
+        <td><?php echo checkbox_tag('katao_node_ids[]', $kata_node_id, false, array('class' => !empty($kata_node_data['available'])?'checkbox':'', 'onclick' => 'toggleCheckAllCheckbox();', 'disabled' => empty($kata_node_data['available']))) ?></td>
+        <td class="<?php echo empty($kata_node_data['available'])?'not-available':'' ?>"><?php echo label_for('katao_node_ids_' . $kata_node_id, $kata_node_data['city']) ?></td>
+      </tr>
+    <?php endforeach ?>
+    </tbody>
+  </table>
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function toggleCheckboxes(is_checked){
+	var checkboxes = $$('.checkbox');
+	for(var i = 0; i < checkboxes.length; i++){
+		checkboxes[i].checked = is_checked;
+	}
+}
+
+function toggleCheckAllCheckbox(){
+	var	checked_checkboxes = 0;
+	var checkboxes = $$('.checkbox');
+	for(var i = 0; i < checkboxes.length; i++){
+		if (checkboxes[i].checked) {
+			checked_checkboxes++;
+		}
+	}
+	$('katao_node_all').checked = (checked_checkboxes == checkboxes.length);
+}
+
+/* ]]> */
+</script>

+ 144 - 0
apps/admin/modules/kataoCart/templates/indexSuccess.php

@@ -0,0 +1,144 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des demandes adhérents (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_cart_filter') ?>
+			<?php echo select_tag('filter_status', options_for_select(KataoCartPeer::getAllStatuses(), $filter_status, array('include_custom' => '&mdash;&nbsp;Etat&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_member', options_for_select(KataoMemberPeer::getAllUsersGroupedByNode(), $filter_member, array('include_custom' => '&mdash;&nbsp;Adhérent&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_node', options_for_select(KataoNodePeer::getAllArray(), $filter_node, array('include_custom' => '&mdash;&nbsp;Noeud&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_period', options_for_select(KataoPeriodPeer::getAll(), $filter_period, array('include_custom' => '&mdash;&nbsp;Période&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_cart_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_cartList)): ?>
+	<p>Aucune demande.</p>
+<?php else : ?>
+     <?php echo link_to('Supprimer les demandes sélectionnées (' . multiple_action_info_selected('katao_cart') . ')', '@katao_cart_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les demandes sélectionnées ?')) ?>
+     <span class="pdf">Exporter les demandes : </span><?php echo link_to('toutes', '@katao_cart_export_pdf_all') ?> | <?php echo link_to('sélectionnées (' . multiple_action_info_selected('katao_cart') . ')', '@katao_cart_export_pdf_selected') ?>
+  	 <?php echo link_to('Générer les commandes fournisseurs', '@katao_cart_generate_orders', array('class' => 'order')) ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_cart') ?></th>
+	  <th nowrap="nowrap">N&deg; <?php echo sort_links($sf_request, 'no', 'kataoCart/index') ?></th>
+	  <th nowrap="nowrap">Date <?php echo sort_links($sf_request, 'date', 'kataoCart/index') ?></th>
+	  <th nowrap="nowrap">Etat <?php echo sort_links($sf_request, 'status', 'kataoCart/index') ?></th>
+	  <th nowrap="nowrap">Adhérent <?php echo sort_links($sf_request, 'member', 'kataoCart/index') ?></th>
+	  <th nowrap="nowrap">Montant</th>
+	  <th nowrap="nowrap">Noeud <?php echo sort_links($sf_request, 'node', 'kataoCart/index') ?></th>
+	  <th nowrap="nowrap">Période <?php echo sort_links($sf_request, 'period', 'kataoCart/index') ?></th>
+	  <th width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_cartList as/*(KataoCart)*/ $katao_cart): ?>
+		<?php $katao_cart_products = $katao_cart->getKataoCartProductsOrderByProductName() ?>
+    <?php
+
+        $total = 0;
+    $katao_cart_products_data = array();
+    foreach ($katao_cart_products as/*(KataoCartProduct)*/ $katao_cart_product) {
+        $quantity_asked = $katao_cart_product->getQuantity();
+        $quantity_adjusted = $katao_cart_product->gethasBeenAdjusted()?$katao_cart_product->getQuantityAdjusted():CONST_N_A;
+        $quantity_delivered = $katao_cart_product->getKataoOrderProduct()?($katao_cart_product->getKataoOrderProduct()->getHasBeenDelivered()?$katao_cart_product->getQuantityDelivered():CONST_N_A):CONST_N_A;
+
+        $quantity = $quantity_delivered;
+        if (CONST_N_A === $quantity) {
+            $quantity = $quantity_adjusted;
+        }
+        if (CONST_N_A === $quantity) {
+            $quantity = $quantity_asked;
+        }
+
+        $price = $katao_cart_product->getProductPriceWithTaxes();
+        $sub_total = $quantity * $price;
+        $total += $sub_total;
+
+        $katao_cart_products_data[] = array('product_name' => $katao_cart_product->getProductName(),
+            'quantity_asked' => $quantity_asked,
+            'quantity_adjusted' => $quantity_adjusted,
+            'quantity_delivered' => $quantity_delivered,
+            'price' => $price,
+            'sub_total' => $sub_total,
+            );
+    }
+
+    ?>
+
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_cart', $katao_cart->getId()) ?></td>
+		  <td nowrap="nowrap">
+			<a href="javascript://" onclick="toggleDetails('<?php echo $katao_cart->getId() ?>');" title="Détails"><?php echo image_tag('actions/expand.png', array('alt' => 'Détails', 'id' => 'cart-icon-' . $katao_cart->getId(), 'align' => 'bottom')) ?></a>
+			<?php echo $katao_cart->getNumber() ?>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_cart->getCreatedAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_cart->getStatusStr() ?></td>
+		  <td><?php echo $katao_cart->getMemberLink() ?></td>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo Utils::formatCurrencyEuro($total) ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_cart->getNodeLink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_cart->getPeriodLink() ?></td>
+		  <td nowrap="nowrap">
+	<?php if (KataoCart::STATUS_IN_PROGRESS == $katao_cart->getStatus()): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_cart_validate?id=' . $katao_cart->getId(), 'actions/validate.png', array('title' => 'Valider', 'confirm' => 'Êtes-vous sûr de vouloir valider cette demande ?'), array('alt' => 'Valider')) ?>
+	<?php elseif (KataoCart::STATUS_VALIDATED == $katao_cart->getStatus()): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_cart_unvalidate?id=' . $katao_cart->getId(), 'actions/unvalidate.png', array('title' => 'Dé-valider', 'confirm' => 'Êtes-vous sûr de vouloir dé-valider cette demande ?'), array('alt' => 'Dé-valider')) ?>
+	<?php endif ?>
+		<?php echo catalyz_link_to_image_tag('@katao_cart_pdf?id=' . $katao_cart->getId(), 'actions/pdf.png', array('title' => 'Exporter en PDF'), array('alt' => 'Exporter en PDF')) ?>
+	    <?php echo catalyz_link_to_image_tag('@katao_cart_delete?id=' . $katao_cart->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer cette demande ?'), array('alt' => 'Supprimer')) ?>
+	  </td>
+	</tr>
+	<tr valign="top" style="display: none" id="cart-details-<?php echo $katao_cart->getId() ?>">
+	  <td colspan="9">
+	  <?php if(0 == count($katao_cart_products)): ?>
+	  	<p>Aucun produit.</p>
+	  <?php else: ?>
+	  	<table class="admin-sub-list">
+	  	<tr>
+	  		<th>Produit</th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/cart.png', array('alt' => 'Quantité demandée', 'title' => 'Quantité demandée')) ?></th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/adjust.png', array('alt' => 'Quantité commandée', 'title' => 'Quantité commandée')) ?></th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/deliver.png', array('alt' => 'Quantité délivrée', 'title' => 'Quantité délivrée')) ?></th>
+	  		<th nowrap="nowrap" width="1%">P.U. TTC</th>
+	  		<th nowrap="nowrap" width="1%">Total TTC</th>
+		</tr>
+        <?php foreach($katao_cart_products_data as $katao_cart_product_infos): ?>
+		<tr valign="top">
+	  		<td><?php echo $katao_cart_product_infos['product_name'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_cart_product_infos['quantity_asked'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_cart_product_infos['quantity_adjusted'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_cart_product_infos['quantity_delivered'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($katao_cart_product_infos['price']) ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($katao_cart_product_infos['sub_total']) ?></td>
+		</tr>
+		<?php endforeach ?>
+		<tr>
+			<td style="border:none!important">&nbsp;</td>
+			<th colspan="4" nowrap="nowrap" style="text-align:right!important">MONTANT TOTAL TTC</th>
+			<th nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($total) ?></th>
+		</tr>
+		</table>
+	  <?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoCart/index?sort=%s%s', $sf_request->getParameter('sort', 'date'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_cart') ?>
+<?php endif ?>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function toggleDetails( id ){
+	$('cart-details-'+id).toggle();
+	if($('cart-details-'+id).visible()) {
+		$('cart-icon-'+id).src = '<?php echo image_path('actions/collapse.png') ?>';
+	} else {
+		$('cart-icon-'+id).src = '<?php echo image_path('actions/expand.png') ?>';
+	}
+}
+
+/* ]]> */
+</script>

+ 38 - 0
apps/admin/modules/kataoCart/templates/showSuccess.php

@@ -0,0 +1,38 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Demande : <?php echo $katao_cart->getMemberName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_cart->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao user:</th>
+      <td><?php echo $katao_cart->getKataoUserId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao period:</th>
+      <td><?php echo $katao_cart->getKataoPeriodId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Status:</th>
+      <td><?php echo $katao_cart->getStatus() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_cart->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_cart->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoCart/edit?id='.$katao_cart->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoCart/index') ?>">List</a>

+ 32 - 0
apps/admin/modules/kataoConfig/actions/actions.class.php

@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * kataoConfig actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoConfig
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoConfigActions extends wpActions {
+    public function executeIndex() {
+        $this->form = new KataoConfigForm(KataoConfigPeer::retrieveByPK(wpConfig::DEFAULT_ID));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoConfigForm(KataoConfigPeer::retrieveByPK(wpConfig::DEFAULT_ID));
+
+        $this->form->bind($request->getParameter('katao_config'), $request->getFiles('katao_config'));
+        if ($this->form->isValid()) {
+            $katao_config = $this->form->save();
+            wpConfig::setInstance($katao_config);
+
+            wpFlashMessages::addConfirmation('Configuration sauvée avec succès.');
+            $this->redirect('kataoConfig/index');
+        }
+
+        $this->setTemplate('index');
+    }
+}

+ 2 - 0
apps/admin/modules/kataoConfig/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  credentials: [[ admin, seo ]]

+ 266 - 0
apps/admin/modules/kataoConfig/templates/indexSuccess.php

@@ -0,0 +1,266 @@
+<?php $katao_config = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1>Configuration</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoConfig/update') ?>" method="post" enctype="multipart/form-data">
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoConfig/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+	  	<td colspan="2" align="left"><u>Informations SARL</u></td>
+	  </tr>
+	  <tr valign="top">
+        <th align="left"><?php echo $form['katao_member_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_member_id'] ?>
+		  <?php echo $form['katao_member_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['name'] ?>
+		  <?php echo $form['name']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['address']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['address'] ?>
+		  <?php echo $form['address']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['phone']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['phone'] ?>
+		  <?php echo $form['phone']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['email']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['email'] ?>
+		  <?php echo $form['email']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['siret_number']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['siret_number'] ?>
+		  <?php echo $form['siret_number']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['tva_number']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['tva_number'] ?>
+		  <?php echo $form['tva_number']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['rcs_number']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['rcs_number'] ?>
+		  <?php echo $form['rcs_number']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['capital']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['capital'] ?>
+		  <?php echo $form['capital']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Codes comptables</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_prefix_purchase']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_prefix_purchase'] ?>
+		  <?php echo $form['accounting_code_prefix_purchase']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_prefix_sell']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_prefix_sell'] ?>
+		  <?php echo $form['accounting_code_prefix_sell']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_bank']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_bank'] ?>
+		  <?php echo $form['accounting_code_bank']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_bank_sol']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_bank_sol'] ?>
+		  <?php echo $form['accounting_code_bank_sol']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_credit']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_credit'] ?>
+		  <?php echo $form['accounting_code_credit']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_error_adjustment_positive']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_error_adjustment_positive'] ?>
+		  <?php echo $form['accounting_code_error_adjustment_positive']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_error_adjustment_negative']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_error_adjustment_negative'] ?>
+		  <?php echo $form['accounting_code_error_adjustment_negative']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_discount']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_discount'] ?>
+		  <?php echo $form['accounting_code_discount']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_sol_discount']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_sol_discount'] ?>
+		  <?php echo $form['accounting_code_sol_discount']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_fees_shipping']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_fees_shipping'] ?>
+		  <?php echo $form['accounting_code_fees_shipping']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_fees_billing']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_fees_billing'] ?>
+		  <?php echo $form['accounting_code_fees_billing']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Transactions</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['initial_transactions_count']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['initial_transactions_count'] ?>
+		  <?php echo $form['initial_transactions_count']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['initial_transactions_sum']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['initial_transactions_sum'] ?>
+		  <?php echo $form['initial_transactions_sum']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['member_fee']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['member_fee'] ?>
+		  <?php echo $form['member_fee']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Produits</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['default_product_margin']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['default_product_margin'] ?> %
+		  <?php echo $form['default_product_margin']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['default_product_sol_percent']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['default_product_sol_percent'] ?> %
+		  <?php echo $form['default_product_sol_percent']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['default_product_picture']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['default_product_picture'] ?>
+		  <?php echo $form['default_product_picture']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Coordonnés bancaires</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['bank_name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['bank_name'] ?>
+		  <?php echo $form['bank_name']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['bank_account']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['bank_account'] ?>
+		  <?php echo $form['bank_account']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Paramètres</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['additional_currency_name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['additional_currency_name'] ?>
+		  <?php echo $form['additional_currency_name']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['mailing_list_email']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['mailing_list_email'] ?>
+		  <?php echo $form['mailing_list_email']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['cart_validation_days_number']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['cart_validation_days_number'] ?>
+		  <?php echo $form['cart_validation_days_number']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <td colspan="2"><i>Délai avant la validation automatique des paniers à la fin de la période de commande (en jours)</i></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['debug_email']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['debug_email'] ?>
+		  <?php echo $form['debug_email']->renderError() ?>
+
+		  <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 398 - 0
apps/admin/modules/kataoInvoice/actions/actions.class.php

@@ -0,0 +1,398 @@
+<?php
+
+/**
+ * kataoInvoice actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoInvoice
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoInvoiceActions extends wpActions {
+    public function preExecute() {
+        parent::preExecute();
+        sfLoader::loadHelpers(array('Asset', 'Tag', 'Url'));
+    }
+
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoInvoicePeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+
+        if ($this->getUser()->isJustDelegate()) {
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId());
+        }
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'date')) {
+            case 'no':
+                $criteria->$sort_method(KataoInvoicePeer::ID);
+                break;
+            case 'status':
+                $criteria->$sort_method(KataoInvoicePeer::STATUS);
+                break;
+            case 'member':
+                $criteria->$sort_method(KataoInvoicePeer::MEMBER_LAST_NAME);
+                $criteria->$sort_method(KataoInvoicePeer::MEMBER_FIRST_NAME);
+                break;
+            default:
+                $criteria->$sort_method(KataoInvoicePeer::CREATED_AT);
+        }
+
+        if ('' != $this->filter_status = $this->getUser()->getAttribute('katao_invoice_filter_status')) {
+            $criteria->add(KataoInvoicePeer::STATUS, $this->filter_status);
+        }
+        if ('' != $this->filter_member = $this->getUser()->getAttribute('katao_invoice_filter_member')) {
+            $criteria->add(KataoInvoicePeer::KATAO_MEMBER_ID, $this->filter_member);
+        }
+        if ('' != $this->filter_node = $this->getUser()->getAttribute('katao_invoice_filter_node')) {
+            $criteria->add(KataoInvoicePeer::KATAO_NODE_ID, $this->filter_node);
+        }
+        if ('' != $this->filter_period = $this->getUser()->getAttribute('katao_invoice_filter_period', KataoPeriodPeer::getActivePeriod()->getId())) {
+            $criteria->add(KataoInvoicePeer::KATAO_PERIOD_ID, $this->filter_period);
+        }
+
+        $pager = new sfPropelPager('KataoInvoice', sfConfig::get('app_pager'));
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_invoiceList = $pager->getResults();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_invoice_filter_status', $request->getParameter('filter_status'));
+        $this->getUser()->setAttribute('katao_invoice_filter_member', $request->getParameter('filter_member'));
+        $this->getUser()->setAttribute('katao_invoice_filter_node', $request->getParameter('filter_node'));
+        $this->getUser()->setAttribute('katao_invoice_filter_period', $request->getParameter('filter_period'));
+        return $this->redirect('kataoInvoice/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_invoice_filter_status', '');
+        $this->getUser()->setAttribute('katao_invoice_filter_member', '');
+        $this->getUser()->setAttribute('katao_invoice_filter_node', '');
+        $this->getUser()->setAttribute('katao_invoice_filter_period', KataoPeriodPeer::getActivePeriod()->getId());
+        return $this->redirect('kataoInvoice/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_invoice = KataoInvoicePeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_invoice, 'Facture #' . $request->getParameter('id') . ' inconnue.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoInvoiceForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $this->form = new KataoInvoiceForm(KataoInvoicePeer::retrieveByPk($request->getParameter('id')));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoInvoiceForm(KataoInvoicePeer::retrieveByPk($request->getParameter('id')));
+
+        $this->form->bind($request->getParameter('katao_invoice'));
+        if ($this->form->isValid()) {
+            $katao_invoice = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Facture "' . $katao_invoice->getNumber() . '" sauvée avec succès.');
+            $this->redirect('kataoInvoice/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_invoice = KataoInvoicePeer::retrieveByPk($request->getParameter('id')), 'Facture #' . $request->getParameter('id') . ' inconnue.');
+
+        $katao_invoice->delete();
+
+        wpFlashMessages::addConfirmation('Facture "' . $katao_invoice->getNumber() . '" supprimée avec succès.');
+        $this->redirect('kataoInvoice/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_invoice')) {
+            $criteria = new Criteria();
+            $criteria->add(KataoInvoicePeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_invoice')), Criteria::IN);
+            KataoInvoicePeer::doDelete($criteria);
+
+            wpPersistenceManager::cleanSelection('katao_invoice');
+            wpFlashMessages::addConfirmation('Les factures sélectionnées ont été supprimées avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une facture.');
+        }
+
+        $this->redirect('kataoInvoice/index');
+    }
+
+    public function executeExportPDF($request) {
+        $this->redirectWithErrorUnless($katao_invoice = KataoInvoicePeer::retrieveByPk($request->getParameter('id')), 'Facture #' . $request->getParameter('id') . ' inconnue.');
+
+        $content = $katao_invoice->generatePDF();
+
+        $response = $this->getResponse();
+        $response->setContentType('application/pdf');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="' . $katao_invoice->getNumber() . '.pdf"');
+        $response->setHttpHeader('Content-Length', strlen($content));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent($content);
+        return sfView::NONE;
+    }
+
+    public function executeSend($request) {
+        $this->redirectWithErrorUnless($katao_invoice = KataoInvoicePeer::retrieveByPk($request->getParameter('id')), 'Facture #' . $request->getParameter('id') . ' inconnue.');
+
+        $this->sendInvoice($katao_invoice);
+
+        $this->redirect('kataoInvoice/index');
+    }
+
+    public function executeSendMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_invoice')) {
+            foreach (KataoInvoicePeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_invoice'))) as $katao_invoice) {
+                $this->sendInvoice($katao_invoice);
+            }
+
+            wpPersistenceManager::cleanSelection('katao_invoice');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une facture.');
+        }
+
+        $this->redirect('kataoInvoice/index');
+    }
+
+    protected function sendInvoice(KataoInvoice $katao_invoice) {
+        try {
+            if ('' != $katao_invoice->getMemberEmail()) {
+                $content = $katao_invoice->generatePDF();
+
+                $mailer = new wpMail();
+
+                $message = new Swift_Message('Facture Katao');
+                $message->attach(new Swift_Message_Part(sprintf('%s,
+
+Suite à la dernière distribution de la periode %s, tu trouveras ci-joint ta facture.
+
+Tu peux consulter ton compte et tes opérations à cette adresse :
+%smon-profil
+%s', $katao_invoice->getMemberFirstName(), $katao_invoice->getKataoPeriod()->getName(), sfConfig::get('app_katao_frontend_url'), Utils::getKataoEmailFooter())));
+                $message->attach(new Swift_Message_Attachment($content, sprintf('%s.pdf', $katao_invoice->getNumber()), 'application/pdf'));
+
+                $mailer->send($message, new Swift_Address($katao_invoice->getMemberEmail(), sprintf('%s %s', $katao_invoice->getMemberFirstName(), $katao_invoice->getMemberLastName())), sfConfig::get('app_mail_from'));
+                $mailer->disconnect();
+
+                wpFlashMessages::addConfirmation('Facture "' . $katao_invoice->getNumber() . '" envoyée avec succès.');
+            } else {
+                wpFlashMessages::addInformation('Facture "' . $katao_invoice->getNumber() . '" non envoyée car cet adhérent n\'a pas d\'email. Merci de bien vouloir l\'exporter et la lui envoyer ou faxer.');
+            }
+
+            if (KataoInvoice::STATUS_VALIDATED == $katao_invoice->getStatus()) {
+                $katao_invoice->setStatus(KataoInvoice::STATUS_SENT);
+                $katao_invoice->save();
+            }
+        }
+        catch (Exception $e) {
+            $mailer->disconnect();
+            wpFlashMessages::addError('Impossible d\'envoyer la facture ' . $katao_invoice->getNumber() . '.');
+        }
+    }
+
+    public function executeExportPDFAll($request) {
+        $criteria = new Criteria();
+        if ($this->getUser()->isJustDelegate()) {
+            $criteria->addJoin(KataoInvoicePeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId());
+        }
+        $criteria->addAscendingOrderByColumn(KataoInvoicePeer::ID);
+        return $this->exportInvoicesToPDF(KataoInvoicePeer::doSelect($criteria));
+    }
+
+    public function executeExportPDFSelected($request) {
+        if (!wpPersistenceManager::isEmpty('katao_invoice')) {
+            $criteria = new Criteria();
+            $criteria->add(KataoInvoicePeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_invoice')), Criteria::IN);
+            $criteria->addAscendingOrderByColumn(KataoInvoicePeer::ID);
+            return $this->exportInvoicesToPDF(KataoInvoicePeer::doSelect($criteria));
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une facture.');
+            $this->redirect('kataoInvoice/index');
+        }
+    }
+
+    protected function exportInvoicesToPDF($katao_invoices) {
+        $file = tempnam('tmp', 'zip');
+        $archive = new ZipArchive();
+        $archive->open($file, ZipArchive::OVERWRITE);
+
+        foreach ($katao_invoices as/*(KataoInvoice)*/ $katao_invoice) {
+            $archive->addFromString($katao_invoice->getNumber() . '.pdf', $katao_invoice->generatePDF());
+        }
+
+        $archive->close();
+
+        $response = $this->getResponse();
+        $response->setContentType('application/zip');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="KATAO_Factures_Adhérents_' . date('Y-m-d') . '.zip"');
+        $response->setHttpHeader('Content-Length', filesize($file));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent(file_get_contents($file));
+        return sfView::NONE;
+    }
+
+    public function executeDeliver($request) {
+        $this->redirectWithErrorUnless($this->katao_invoice = KataoInvoicePeer::retrieveByPk($request->getParameter('id')), 'Facture #' . $request->getParameter('id') . ' inconnue.');
+
+        if ($request->isMethod('POST')) {
+            foreach ($request->getParameter('quantity') as $katao_invoice_product_id => $quantity) {
+                KataoInvoiceProductPeer::deliverQuantity($katao_invoice_product_id, $quantity);
+            }
+            $this->katao_invoice->setStatus(KataoInvoice::STATUS_DELIVERED);
+            $this->katao_invoice->save();
+
+            $katao_product_id = $request->getParameter('new_product');
+            if ($katao_product_id) {
+                $katao_member = $this->katao_invoice->getKataoMember();
+                $katao_user = $katao_member->getFirstKataoUser();
+                $katao_cart = $katao_user->getCart($this->katao_invoice->getKataoPeriodId(), $this->katao_invoice->getKataoNodeId(), true);
+                $katao_product = KataoProductPeer::retrieveByPK($katao_product_id);
+                $katao_order_product_id = KataoOrderProductPeer::getIdByProductAndPeriodAndNode($katao_product_id, $this->katao_invoice->getKataoPeriodId(), $this->katao_invoice->getKataoNodeId());
+
+                $katao_cart_product = new KataoCartProduct();
+                $katao_cart_product->setKataoCart($katao_cart);
+                $katao_cart_product->setKataoProduct($katao_product);
+                $katao_cart_product->setProductReference($katao_product->getReference());
+                $katao_cart_product->setProductName($katao_product->getName());
+                $katao_cart_product->setProductPriceEuro($katao_product->getUnitPriceEuro());
+                $katao_cart_product->setProductMargin($katao_product->getMargin());
+                $katao_cart_product->setProductTvaRate($katao_product->getTvaRate());
+                $katao_cart_product->setQuantity(0);
+                $katao_cart_product->setQuantityAdjusted(0);
+                $katao_cart_product->setHasBeenAdjusted(true);
+                $katao_cart_product->setQuantityDelivered(1);
+                $katao_cart_product->setKataoOrderProductId($katao_order_product_id);
+                $katao_cart_product->save();
+
+                $katao_invoice_product = new KataoInvoiceProduct();
+                $katao_invoice_product->setKataoInvoice($this->katao_invoice);
+                $katao_invoice_product->setKataoProduct($katao_product);
+                $katao_invoice_product->setKataoCartProduct($katao_cart_product);
+                $katao_invoice_product->setKataoOrderProductId($katao_order_product_id);
+                $katao_invoice_product->setProductReference($katao_product->getReference());
+                $katao_invoice_product->setProductName($katao_product->getName());
+                $katao_invoice_product->setProductPriceEuro($katao_product->getUnitPriceEuro());
+                $katao_invoice_product->setProductMargin($katao_product->getMargin());
+                $katao_invoice_product->setProductTvaRate($katao_product->getTvaRate());
+                $katao_invoice_product->setQuantity(0);
+                $katao_invoice_product->setQuantityDelivered(0);
+                $katao_invoice_product->setSolAmount(0);
+                $katao_invoice_product->save();
+
+                wpFlashMessages::addConfirmation('Produit "' . $katao_product->getName() . '" ajouté à la facture avec succès.');
+                $this->redirect('@katao_invoice_deliver?id=' . $this->katao_invoice->getId());
+            } else {
+                wpFlashMessages::addConfirmation('Facture "' . $this->katao_invoice->getNumber() . '" délivrée avec succès.');
+                $this->redirect('kataoInvoice/index');
+            }
+        }
+    }
+
+    public function executeValidate($request) {
+        $this->redirectWithErrorUnless($this->katao_period = KataoPeriodPeer::retrieveByPK((int)$this->getUser()->getAttribute('katao_invoice_filter_period', KataoPeriodPeer::getActivePeriod()->getId())), 'Merci de filtrer les factures sur une période avant de les valider.', 'kataoInvoice/index');
+
+        if ($request->isMethod('POST')) {
+            $katao_node = KataoNodePeer::retrieveByPK($request->getParameter('node_id'));
+            $this->redirectWithErrorUnless($katao_node, 'Merci de choisir un noeud', '@katao_invoice_validate');
+
+            $criteria_update = new Criteria();
+            $criteria_update->add(KataoInvoicePeer::STATUS, KataoInvoice::STATUS_VALIDATED);
+            $criteria_where = new Criteria();
+            $criteria_where->add(KataoInvoicePeer::KATAO_PERIOD_ID, $this->katao_period->getId());
+            $criteria_where->add(KataoInvoicePeer::KATAO_NODE_ID, $katao_node->getId());
+            $criteria_where->add(KataoInvoicePeer::STATUS, KataoInvoice::STATUS_DELIVERED);
+            BasePeer::doUpdate($criteria_where, $criteria_update, Propel::getConnection());
+
+            wpFlashMessages::addConfirmation('Les factures du noeud "' . $katao_node->getCity() . '" pour la période "' . $this->katao_period->getName() . '" ont été validées avec succès.');
+            $this->redirect('kataoInvoice/index');
+        }
+    }
+
+    public function executeUpdateProductDetails($request) {
+        $katao_period = KataoPeriodPeer::retrieveByPK((int)$this->getUser()->getAttribute('katao_invoice_filter_period', KataoPeriodPeer::getActivePeriod()->getId()));
+        $katao_node = KataoNodePeer::retrieveByPK($request->getParameter('node_id'));
+
+        $return = '<i>Aucune facture à valider.</i>';
+        $suppliers = array();
+        if (!is_null($katao_period) && !is_null($katao_node)) {
+            $criteria = new Criteria();
+            $criteria->add(KataoInvoicePeer::KATAO_PERIOD_ID, $katao_period->getId());
+            $criteria->add(KataoInvoicePeer::KATAO_NODE_ID, $katao_node->getId());
+            $criteria->add(KataoInvoicePeer::STATUS, KataoInvoice::STATUS_DELIVERED, Criteria::NOT_EQUAL);
+            if (0 < KataoInvoicePeer::doCount($criteria)) {
+                $return = '<i>Toutes les factures de ce noeud ne sont pas délivrées.</i>';
+            } else {
+                $criteria = new Criteria();
+                $criteria->addJoin(KataoInvoiceProductPeer::KATAO_INVOICE_ID, KataoInvoicePeer::ID);
+                $criteria->add(KataoInvoicePeer::KATAO_PERIOD_ID, $katao_period->getId());
+                $criteria->add(KataoInvoicePeer::KATAO_NODE_ID, $katao_node->getId());
+                $criteria->add(KataoInvoicePeer::STATUS, KataoInvoice::STATUS_DELIVERED);
+                foreach (KataoInvoiceProductPeer::doSelectJoinAllExceptKataoOrderProduct($criteria) as/*(KataoInvoiceProduct)*/ $katao_invoice_product) {
+                    $return = '<i>Tous les produits ont été distribués en totalité.</i>';
+
+                    $katao_invoice = $katao_invoice_product->getKataoInvoice();
+                    $katao_product = $katao_invoice_product->getKataoProduct();
+
+                    $supplier_name = $katao_product->getKataoSupplier()->getName();
+                    $product_name = $katao_invoice_product->getProductName();
+
+                    $current = $katao_product->getTotalDeliveredQuantity(false, $katao_period->getId(), $katao_node->getId());
+                    $total = $katao_product->getTotalReceivedQuantity($katao_period->getId(), $katao_node->getId());
+                    if ($current != $total) {
+                        $suppliers[$supplier_name][$product_name]['current'] = $current;
+                        $suppliers[$supplier_name][$product_name]['total'] = $total;
+                        $suppliers[$supplier_name][$product_name]['members'][$katao_invoice->getId()] = $katao_invoice->getMemberName();
+                    }
+                }
+            }
+        }
+
+        if (0 < count($suppliers)) {
+            $return = '<table class="admin-sub-list">';
+            foreach ($suppliers as $supplier_name => $products) {
+                $return .= sprintf('<tr><td colspan="4" style="border:none!important;"><div class="content-add02">
+	<div class="heading02"><h2>%s</h2></div>
+</div></td></tr>', $supplier_name);
+                $return .= sprintf('<tr><th>Produit</th><th style="text-align:center!important">%s</th><th style="text-align:center!important"">%s</th><th>Adhérents</th></tr>', image_tag('actions/receive.png', array('alt' => 'Quantité réceptionnée', 'title' => 'Quantité réceptionnée')), image_tag('actions/deliver.png', array('alt' => 'Quantité délivrée', 'title' => 'Quantité délivrée')));
+                foreach ($products as $product_name => $product_data) {
+                    $diff_str = $product_data['current'] - $product_data['total'];
+                    if (0 < $diff_str) {
+                        $diff_str = '+' . $diff_str;
+                    }
+                    $return .= sprintf('<tr valign="top"><td nowrap="nowrap">%s</td><td style="text-align:center!important">%s</td><td style="text-align:center!important">%d (%s)</td>', $product_name, $product_data['total'], $product_data['current'], $diff_str);
+
+                    $members = array();
+                    foreach ($product_data['members'] as $invoice_id => $member_name) {
+                        $members[] = sprintf('<li>%s</li>', link_to($member_name, '@katao_invoice_deliver?id=' . $invoice_id));
+                    }
+                    if (0 < count($members)) {
+                        $return .= sprintf('<td><ul>%s</ul></td>', implode('', $members));
+                    }
+
+                    $return .= '</tr>';
+                }
+            }
+            $return .= '</table>';
+        }
+
+        return $this->renderText($return);
+    }
+}

+ 2 - 0
apps/admin/modules/kataoInvoice/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  credentials: [[ admin, seo, delegate ]]

+ 54 - 0
apps/admin/modules/kataoInvoice/templates/deliverSuccess.php

@@ -0,0 +1,54 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Livraison de la facture "<?php echo $katao_invoice->getNumber() ?>" de l'adhérent "<?php echo $katao_invoice->getMemberName() ?>" pour la période "<?php echo $katao_invoice->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_invoice_deliver?id=' . $katao_invoice->getId()) ?>
+
+<table class="admin-sub-list">
+<tr>
+	<td style="border:none!important">&nbsp;</td>
+	<th colspan="3" style="text-align:center!important">Quantités</th>
+</tr>
+<tr>
+	<th>Produit</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Commandée</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Délivrée</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">EN COURS / TOTAL</th>
+</tr>
+<?php $criteria = new Criteria();
+$criteria->addAscendingOrderByColumn(KataoInvoiceProductPeer::PRODUCT_NAME); ?>
+<?php foreach ($katao_invoice->getKataoInvoiceProductsJoinKataoProduct($criteria) as/*(KataoInvoiceProduct)*/ $katao_invoice_product): ?>
+	<?php $katao_product = $katao_invoice_product->getKataoProduct() ?>
+
+	<?php $quantity = $katao_invoice_product->getQuantityDelivered() ?>
+	<?php $total_delivered_quantity = $katao_product->getTotalDeliveredQuantity($katao_invoice->getId(), $katao_invoice->getKataoPeriodId(), $katao_invoice->getKataoNodeId()) ?>
+<tr>
+ 	<td><?php echo $katao_invoice_product->getProductName() ?></td>
+ 	<td style="text-align:center!important"><?php echo $katao_invoice_product->getQuantity() ?></td>
+ 	<td nowrap="nowrap" style="text-align:center!important">
+ 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value) - 1); updateCurrentDelivered(<?php echo $katao_invoice_product->getId() ?>, <?php echo $total_delivered_quantity ?>);" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_tag('quantity[' . $katao_invoice_product->getId() . ']', $quantity, array('style' => 'width: 20px; text-align: center;', 'class' => 'quantity-delivered', 'onchange' => 'updateCurrentDelivered(' . $katao_invoice_product->getId() . ', ' . $total_delivered_quantity . ');')) ?>
+		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_invoice_product->getId() ?>').value) + 1; updateCurrentDelivered(<?php echo $katao_invoice_product->getId() ?>, <?php echo $total_delivered_quantity ?>);" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+	</td>
+	<td style="text-align:center!important"><span id="current-quantity-<?php echo $katao_invoice_product->getId() ?>"><?php echo $total_delivered_quantity + $quantity ?></span> / <?php echo $katao_product->getTotalReceivedQuantity($katao_invoice->getKataoPeriodId(), $katao_invoice->getKataoNodeId()) ?></td>
+
+</tr>
+<?php endforeach ?>
+<tr>
+	<td colspan="4"><?php echo select_tag('new_product', options_for_select($katao_invoice->getOtherProducts(), false, array('include_custom' => '&mdash;&nbsp;Autre produit&nbsp;&mdash;'))) ?>&nbsp;<?php echo submit_tag('Ajouter') ?></td>
+</tr>
+</table>
+
+<br /><?php echo submit_tag('Délivrer') ?> ou <a href="<?php echo url_for('kataoInvoice/index') ?>">annuler</a>
+
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function updateCurrentDelivered(id, total_delivered_quantity){
+	$('current-quantity-' + id).innerHTML = total_delivered_quantity + parseInt($F('quantity_' + id));
+}
+
+/* ]]> */
+</script>

+ 49 - 0
apps/admin/modules/kataoInvoice/templates/editSuccess.php

@@ -0,0 +1,49 @@
+<?php $katao_invoice = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_invoice->isNew() ? 'Ajout' : 'Modification' ?> d'un facture</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoInvoice/update'.(!$katao_invoice->isNew() ? '?id='.$katao_invoice->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoInvoice/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_user_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_user_id'] ?>
+		  <?php echo $form['katao_user_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_period_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_period_id'] ?>
+		  <?php echo $form['katao_period_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_cart_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_cart_id'] ?>
+		  <?php echo $form['katao_cart_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['status']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['status'] ?>
+		  <?php echo $form['status']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 115 - 0
apps/admin/modules/kataoInvoice/templates/indexSuccess.php

@@ -0,0 +1,115 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des factures adhérents (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_invoice_filter') ?>
+			<?php echo select_tag('filter_status', options_for_select(KataoInvoicePeer::getAllStatuses(), $filter_status, array('include_custom' => '&mdash;&nbsp;Etat&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_member', options_for_select(KataoMemberPeer::getAllGroupedByNode(), $filter_member, array('include_custom' => '&mdash;&nbsp;Adhérent&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_node', options_for_select(KataoNodePeer::getAllArray(), $filter_node, array('include_custom' => '&mdash;&nbsp;Noeud&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_period', options_for_select(KataoPeriodPeer::getAll(), $filter_period, array('include_custom' => '&mdash;&nbsp;Période&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_invoice_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_invoiceList)): ?>
+	<p>Aucune facture.</p>
+<?php else : ?>
+  <?php echo link_to('Valider les factures', '@katao_invoice_validate', array('class' => 'validate')) ?>
+  <?php echo link_to('Supprimer les factures sélectionnées (' . multiple_action_info_selected('katao_invoice') . ')', '@katao_invoice_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les factures sélectionnées ?')) ?>
+  <div style="padding-top:4px">
+  	<span class="pdf">Exporter les factures : </span><?php echo link_to('toutes', '@katao_invoice_export_pdf_all') ?> | <?php echo link_to('sélectionnées (' . multiple_action_info_selected('katao_invoice') . ')', '@katao_invoice_export_pdf_selected') ?>
+  	<?php echo link_to('Envoyer les factures sélectionnées (' . multiple_action_info_selected('katao_invoice') . ')', '@katao_invoice_send_multiple', array('class' => 'send')) ?>
+  </div>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_invoice') ?></th>
+	  <th nowrap="nowrap">N&deg; <?php echo sort_links($sf_request, 'no', 'kataoInvoice/index') ?></th>
+	  <th nowrap="nowrap">Date <?php echo sort_links($sf_request, 'date', 'kataoInvoice/index') ?></th>
+	  <th nowrap="nowrap">Etat <?php echo sort_links($sf_request, 'status', 'kataoInvoice/index') ?></th>
+	  <th nowrap="nowrap">Adhérent <?php echo sort_links($sf_request, 'member', 'kataoInvoice/index') ?></th>
+	  <th nowrap="nowrap">Montant</th>
+	  <th nowrap="nowrap">Noeud <?php echo sort_links($sf_request, 'node', 'kataoInvoice/index') ?></th>
+	  <th nowrap="nowrap">Période <?php echo sort_links($sf_request, 'period', 'kataoInvoice/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_invoiceList as/*(KataoInvoice)*/ $katao_invoice): ?>
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_invoice', $katao_invoice->getId()) ?></td>
+		  <td nowrap="nowrap">
+			<a href="javascript://" onclick="toggleDetails('<?php echo $katao_invoice->getId() ?>');" title="Détails"><?php echo image_tag('actions/expand.png', array('alt' => 'Détails', 'id' => 'invoice-icon-' . $katao_invoice->getId(), 'align' => 'bottom')) ?></a>
+			<?php echo $katao_invoice->getNumber() ?>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_invoice->getCreatedAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_invoice->getStatusStr() ?></td>
+		  <td><?php echo $katao_invoice->getMemberName() ?></td>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_invoice->sumProductsStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_invoice->getNodeLink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_invoice->getPeriodLink() ?></td>
+		  <td nowrap="nowrap">
+	    <?php echo catalyz_link_to_image_tag('@katao_invoice_pdf?id=' . $katao_invoice->getId(), 'actions/pdf.png', array('title' => 'Exporter en PDF'), array('alt' => 'Exporter en PDF')) ?>
+	<?php if (KataoInvoice::STATUS_VALIDATED == $katao_invoice->getStatus()): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_invoice_send?id=' . $katao_invoice->getId(), 'actions/send.png', array('title' => 'Envoyer à l\'adhérent'), array('alt' => 'Envoyer à l\'adhérent')) ?>
+	<?php endif ?>
+	<?php if (in_array($katao_invoice->getStatus(), array(KataoInvoice::STATUS_GENERATED, KataoInvoice::STATUS_DELIVERED))): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_invoice_deliver?id=' . $katao_invoice->getId(), 'actions/deliver.png', array('title' => 'Délivrer'), array('alt' => 'Délivrer')) ?>
+	<?php endif ?>
+	    <?php echo catalyz_link_to_image_tag('@katao_invoice_delete?id=' . $katao_invoice->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer cette facture ?'), array('alt' => 'Supprimer')) ?>
+	  </td>
+	</tr>
+	<tr valign="top" style="display: none" id="invoice-details-<?php echo $katao_invoice->getId() ?>">
+	  <td colspan="9">
+		<table class="admin-sub-list">
+	  	<tr>
+	  		<th>Produit</th>
+	  		<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/adjust.png', array('alt' => 'Quantité commandée', 'title' => 'Quantité commandée')) ?></th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/deliver.png', array('alt' => 'Quantité délivrée', 'title' => 'Quantité délivrée')) ?></th>
+	  		<th nowrap="nowrap" width="1%">Prix TTC</th>
+	  		<th nowrap="nowrap" width="1%">Total</th>
+		</tr>
+		<?php $total = 0 ?>
+		<?php foreach ($katao_invoice->getKataoInvoiceProductsOrderByProduct() as/*(KataoInvoiceProduct)*/ $katao_invoice_product): ?>
+			<?php $quantity = $katao_invoice_product->getQuantity() ?>
+			<?php $quantity_delivered = $katao_invoice_product->getQuantityDelivered() ?>
+			<?php $price = $katao_invoice_product->getProductPriceWithTaxes() ?>
+			<?php $sub_total = $quantity_delivered * $price ?>
+			<?php $total += $sub_total ?>
+		<tr valign="top">
+	  		<td><?php echo $katao_invoice_product->getProductName() ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $quantity ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo (KataoInvoice::STATUS_GENERATED != $katao_invoice->getStatus())?$quantity_delivered:CONST_N_A ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($price) ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($sub_total) ?></td>
+		</tr>
+		<?php endforeach ?>
+		<tr>
+			<td style="border:none!important">&nbsp;</td>
+			<th colspan="3" nowrap="nowrap" style="text-align:right!important">TOTAL :</th>
+			<th nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($total) ?></th>
+		</tr>
+		</table>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoInvoice/index?sort=%s%s', $sf_request->getParameter('sort', 'date'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_invoice') ?>
+<?php endif ?>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function toggleDetails( id ){
+	$('invoice-details-'+id).toggle();
+	if($('invoice-details-'+id).visible()) {
+		$('invoice-icon-'+id).src = '<?php echo image_path('actions/collapse.png') ?>';
+	} else {
+		$('invoice-icon-'+id).src = '<?php echo image_path('actions/expand.png') ?>';
+	}
+}
+
+/* ]]> */
+</script>

+ 42 - 0
apps/admin/modules/kataoInvoice/templates/showSuccess.php

@@ -0,0 +1,42 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Facture : <?php echo $katao_invoice->getMemberName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_invoice->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao user:</th>
+      <td><?php echo $katao_invoice->getKataoUserId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao period:</th>
+      <td><?php echo $katao_invoice->getKataoPeriodId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao cart:</th>
+      <td><?php echo $katao_invoice->getKataoCartId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Status:</th>
+      <td><?php echo $katao_invoice->getStatus() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_invoice->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_invoice->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoInvoice/edit?id='.$katao_invoice->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoInvoice/index') ?>">List</a>

+ 46 - 0
apps/admin/modules/kataoInvoice/templates/validateSuccess.php

@@ -0,0 +1,46 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Validation des factures pour la période "<?php echo $katao_period->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_invoice_validate') ?>
+
+<p><i>Sélectioner ci-dessous le noeud pour lequel vous souhaitez valider les factures adhérents.</i></p>
+
+<table>
+<tr valign="top">
+	<td><?php echo label_for('node_id', 'Noeud') ?></td>
+	<td><?php echo select_tag('node_id', options_for_select(KataoNodePeer::getAllArray(), false, array('include_custom' => '&mdash;&nbsp;choisir&nbsp;&mdash;')), array('onchange' => 'updateProductsDetails(); return true;')) ?></td>
+</tr>
+</table>
+
+<div id="products-details"></div>
+
+<br /><?php echo submit_tag('Valider', array('id' => 'commit', 'disabled' => true)) ?> ou <a href="<?php echo url_for('kataoInvoice/index') ?>">annuler</a>
+
+</form>
+
+<script type="text/javascript">
+
+function updateProductsDetails(){
+	if ($F('node_id')) {
+		new Ajax.Request('<?php echo url_for('kataoInvoice/updateProductDetails') ?>', {
+		 	method: 'get',
+			parameters: {
+				node_id: $F('node_id')
+			},
+			onSuccess: updateProductsDetailsResponse
+		});
+	}
+}
+
+function updateProductsDetailsResponse(xhr){
+	var response = xhr.responseText;
+	$('products-details').innerHTML = response;
+	if ("<i>Aucune facture à valider.</i>" == response || "<i>Toutes les factures de ce noeud ne sont pas délivrées.</i>" == response) {
+		$('commit').disabled = true;
+		return false;
+	}
+	$('commit').disabled = false;
+}
+
+</script>

+ 496 - 0
apps/admin/modules/kataoMember/actions/actions.class.php

@@ -0,0 +1,496 @@
+<?php
+
+/**
+ * kataoMember actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoMember
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoMemberActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoMemberPeer::KATAO_NODE_ID, KataoNodePeer::ID);
+        $criteria->addJoin(KataoMemberPeer::ID, KataoUserPeer::KATAO_MEMBER_ID);
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'name')) {
+            case 'node':
+                $criteria->$sort_method(KataoNodePeer::CITY);
+                break;
+            case 'referer':
+                $criteria->$sort_method(KataoMemberPeer::IS_REFERER);
+                break;
+            case 'delegate':
+                $criteria->$sort_method(KataoMemberPeer::IS_DELEGATE);
+                break;
+            case 'anonymous':
+                $criteria->$sort_method(KataoMemberPeer::IS_ANONYMOUS);
+                break;
+            case 'amount':
+                $criteria->$sort_method(KataoMemberPeer::CURRENT_AMOUNT);
+                break;
+            case 'status':
+                $criteria->$sort_method(KataoUserPeer::STATUS);
+                break;
+            default:
+                $criteria->$sort_method(KataoMemberPeer::LAST_NAME);
+                $criteria->$sort_method(KataoMemberPeer::FIRST_NAME);
+        }
+
+        if ('' != $this->filter_node = $this->getUser()->getAttribute('katao_member_filter_node')) {
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->filter_node);
+        }
+        if ('' != $this->filter_referer = $this->getUser()->getAttribute('katao_member_filter_referer')) {
+            $criteria->add(KataoMemberPeer::IS_REFERER, (CONST_YES == $this->filter_referer)?true:false);
+        }
+        if ('' != $this->filter_delegate = $this->getUser()->getAttribute('katao_member_filter_delegate')) {
+            $criteria->add(KataoMemberPeer::IS_DELEGATE, (CONST_YES == $this->filter_delegate)?true:false);
+        }
+        if ('' != $this->filter_anonymous = $this->getUser()->getAttribute('katao_member_filter_anonymous')) {
+            $criteria->add(KataoMemberPeer::IS_ANONYMOUS, (CONST_YES == $this->filter_anonymous)?true:false);
+        }
+        if ('' != $this->filter_status = $this->getUser()->getAttribute('katao_member_filter_status')) {
+            $criteria->add(KataoUserPeer::STATUS, $this->filter_status);
+        }
+        if ('' != $this->filter_member = $this->getUser()->getAttribute('katao_member_filter_member')) {
+            $criteria->add(KataoMemberPeer::IS_MEMBER, (CONST_YES == $this->filter_member)?true:false);
+        }
+
+        if ('' != $this->search = $this->getUser()->getAttribute('katao_member_search')) {
+            $search_like = sprintf('%%%s%%', $this->search);
+            $criterion = $criteria->getNewCriterion(KataoMemberPeer::FIRST_NAME, $search_like, Criteria::LIKE);
+            $criterion->addOr($criteria->getNewCriterion(KataoMemberPeer::LAST_NAME, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoMemberPeer::ACCOUNTING_CODE, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::EMAIL, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::ADDRESS1, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::ADDRESS2, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::ZIP, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::CITY, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::PHONE, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::FAX, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::LOGIN, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoMemberPeer::CARD_NUMBER_SOL, $search_like, Criteria::LIKE));
+            $criteria->addAnd($criterion);
+        }
+
+        $criteria->setDistinct();
+
+        $pager = new sfPropelPager('KataoMember', sfConfig::get('app_pager'));
+        $pager->setPeerMethod('doSelectJoinKataoNodeRelatedByKataoNodeId');
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_memberList = $pager->getResults();
+
+        $this->is_just_delegate = $this->getUser()->isJustDelegate();
+
+        $this->current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+//        $this->current_user_node_id = $this->getUser()->getAttribute('katao_node_instance')->getId();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_member_filter_node', $request->getParameter('filter_node'));
+        $this->getUser()->setAttribute('katao_member_filter_referer', $request->getParameter('filter_referer'));
+        $this->getUser()->setAttribute('katao_member_filter_delegate', $request->getParameter('filter_delegate'));
+        $this->getUser()->setAttribute('katao_member_filter_anonymous', $request->getParameter('filter_anonymous'));
+        $this->getUser()->setAttribute('katao_member_filter_status', $request->getParameter('filter_status'));
+        $this->getUser()->setAttribute('katao_member_filter_member', $request->getParameter('filter_member'));
+        return $this->redirect('kataoMember/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_member_filter_node', '');
+        $this->getUser()->setAttribute('katao_member_filter_referer', '');
+        $this->getUser()->setAttribute('katao_member_filter_delegate', '');
+        $this->getUser()->setAttribute('katao_member_filter_anonymous', '');
+        $this->getUser()->setAttribute('katao_member_filter_status', '');
+        $this->getUser()->setAttribute('katao_member_filter_member', '');
+        return $this->redirect('kataoMember/index');
+    }
+
+    public function executeSearch($request) {
+        $this->getUser()->setAttribute('katao_member_search', $request->getParameter('search'));
+        return $this->redirect('kataoMember/index');
+    }
+
+    public function executeSearchReset($request) {
+        $this->getUser()->setAttribute('katao_member_search', '');
+        return $this->redirect('kataoMember/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_member, 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+
+	    $katao_user =/*(KataoUser)*/ $this->katao_member->getFirstKataoUser();
+
+		$this->history_euro = $katao_user->getHistoryEuro(true);
+        $this->history_sol = $katao_user->getHistorySol(true);
+
+    	// Historique des adhésions
+        $this->memberid = $request->getParameter('id');
+        $this->userid   = KataoUserPeer::retrieveByKataoMemberId($this->memberid)->getId();
+
+    	$this->list_objet = KataoMemberAdhesionPeer::getAdhesionList($this->userid);
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoMemberForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id'));
+
+        if (!is_null($katao_member)) {
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+            $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $katao_member->getKataoNodeId());
+        }
+
+        $this->form = new KataoMemberForm($katao_member);
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id'));
+
+
+        if (!is_null($katao_member)) {
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+            $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $katao_member->getKataoNodeId());
+        }
+
+        $this->form = new KataoMemberForm($katao_member);
+
+        $this->form->bind($request->getParameter('katao_member'));
+		if ($this->form->isValid()) {
+            $katao_member = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Adhérent "' . $katao_member->getFullName() . '" sauvé avec succès.');
+            $this->redirect('kataoMember/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id')), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+
+        $is_just_delegate = $this->getUser()->isJustDelegate();
+        $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+        $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $katao_member->getKataoNodeId());
+
+        $this->redirectWithErrorIf(!$katao_member->isDeletable());
+
+        $katao_member->delete();
+
+        wpFlashMessages::addConfirmation('Adhérent "' . $katao_member->getFullName() . '" supprimé avec succès.');
+        $this->redirect('kataoMember/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_member')) {
+            foreach (KataoMemberPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_member'))) as/*(KataoMember)*/ $katao_member) {
+                if ($katao_member->isDeletable()) {
+                    $katao_member->delete();
+                }
+            }
+
+            wpPersistenceManager::cleanSelection('katao_member');
+            wpFlashMessages::addConfirmation('Les adhérents sélectionnés ont été supprimés avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un adhérent.');
+        }
+
+        $this->redirect('kataoMember/index');
+    }
+
+    public function executeChangeNextNodeMultiple(sfWebRequest $request) {
+        $this->redirectWithErrorUnless($this->getUser()->isJustDelegate());
+
+        if (!wpPersistenceManager::isEmpty('katao_member')) {
+            if ($request->isMethod('post')) {
+                $criteria_update = new Criteria();
+                $criteria_update->add(KataoMemberPeer::NEXT_KATAO_NODE_ID, $request->getParameter('next_katao_node_id'));
+                $criteria_where = new Criteria();
+                $criteria_where->add(KataoMemberPeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_member')), Criteria::IN);
+                BasePeer::doUpdate($criteria_where, $criteria_update, Propel::getConnection());
+
+                wpPersistenceManager::cleanSelection('katao_member');
+                wpFlashMessages::addConfirmation('Les adhérents sélectionnés ont été changés de noeud avec succès.');
+                $this->redirect('kataoMember/index');
+            }
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un adhérent.');
+            $this->redirect('kataoMember/index');
+        }
+    }
+
+    public function executeSendLogin(sfWebRequest $request) {
+        $this->redirectWithErrorUnless($katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id')), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+        $this->redirectWithErrorUnless($katao_user = $katao_member->getFirstKataoUser(), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+
+        $email = $katao_user->getEmail();
+        if ('' == $email) {
+            wpFlashMessages::addError('L\'adhérent "' . $katao_member->getFullName() . '" n\'a pas d\'adresse email.');
+        } else {
+            try {
+                $mailer = new wpMail();
+                $mailer->send(new Swift_Message('Votre login et votre mot de passe', sprintf('%s,
+
+Tu trouveras ci-joint ton login et ton mot de passe :
+
+Login : %s
+Mot de passe : %s
+%s', $katao_member->getFirstName(), $katao_user->getLogin(), $katao_user->getPassword(), Utils::getKataoEmailFooter())), new Swift_Address($katao_user->getEmail(), $katao_user->getFullName()), sfConfig::get('app_mail_from'));
+                $mailer->disconnect();
+
+                wpFlashMessages::addConfirmation('Les informations de connexion on été envoyées avec succès à l\'adhérent "' . $katao_member->getFullName() . '".');
+            }
+            catch (Exception $e) {
+                $mailer->disconnect();
+                wpFlashMessages::addError('L\'adhérent "' . $katao_member->getFullName() . '" n\'a pas d\'adresse email.');
+            }
+        }
+
+        $this->redirect('kataoMember/index');
+    }
+
+    public function executeUpdateGmapCoordinates($request) {
+        $this->redirectWithErrorUnless($this->katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id')), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+        $this->redirectWithErrorUnless($this->katao_user = $this->katao_member->getFirstKataoUser(), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+
+        if (!is_null($this->katao_member)) {
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+            $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $this->katao_member->getKataoNodeId());
+        }
+
+        if ($request->isMethod('post')) {
+            $this->katao_user->setGmapLat($request->getParameter('gmap_lat'));
+            $this->katao_user->setGmapLng($request->getParameter('gmap_lng'));
+            $this->katao_user->save();
+
+            wpFlashMessages::addConfirmation('L\'adhérent "' . $this->katao_member->getFullName() . '" a été positionné sur la carte avec succès.');
+            $this->redirect('kataoMember/index');
+        }
+    }
+
+    public function executeExportZyvon($request) {
+        $criteria = new Criteria();
+        $criteria->addSelectColumn(KataoMemberPeer::LAST_NAME);
+        $criteria->addSelectColumn(KataoMemberPeer::FIRST_NAME);
+        $criteria->addSelectColumn(KataoUserPeer::EMAIL);
+        $criteria->addJoin(KataoMemberPeer::ID, KataoUserPeer::KATAO_MEMBER_ID);
+        if ($this->getUser()->isJustDelegate()) {
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId());
+        }
+        $criteria->add(KataoUserPeer::EMAIL, '', Criteria::NOT_EQUAL);
+        $criteria->add(KataoUserPeer::EMAIL, null, Criteria::NOT_EQUAL);
+        $criteria->add(KataoUserPeer::STATUS, KataoUser::STATUS_ACTIVE);
+        $criteria->addAscendingOrderByColumn(KataoMemberPeer::LAST_NAME);
+        $criteria->addAscendingOrderByColumn(KataoMemberPeer::FIRST_NAME);
+
+        if ('' != $this->filter_node = $this->getUser()->getAttribute('katao_member_filter_node')) {
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->filter_node);
+        }
+        if ('' != $this->filter_referer = $this->getUser()->getAttribute('katao_member_filter_referer')) {
+            $criteria->add(KataoMemberPeer::IS_REFERER, (CONST_YES == $this->filter_referer)?true:false);
+        }
+        if ('' != $this->filter_delegate = $this->getUser()->getAttribute('katao_member_filter_delegate')) {
+            $criteria->add(KataoMemberPeer::IS_DELEGATE, (CONST_YES == $this->filter_delegate)?true:false);
+        }
+        if ('' != $this->filter_anonymous = $this->getUser()->getAttribute('katao_member_filter_anonymous')) {
+            $criteria->add(KataoMemberPeer::IS_ANONYMOUS, (CONST_YES == $this->filter_anonymous)?true:false);
+        }
+        if ('' != $this->filter_status = $this->getUser()->getAttribute('katao_member_filter_status')) {
+            $criteria->add(KataoUserPeer::STATUS, $this->filter_status);
+        }
+        if ('' != $this->filter_member = $this->getUser()->getAttribute('katao_member_filter_member')) {
+            $criteria->add(KataoUserPeer::IS_MEMBER, (CONST_YES == $this->filter_member)?true:false);
+        }
+
+        if ('' != $this->search = $this->getUser()->getAttribute('katao_member_search')) {
+            $search_like = sprintf('%%%s%%', $this->search);
+            $criterion = $criteria->getNewCriterion(KataoMemberPeer::FIRST_NAME, $search_like, Criteria::LIKE);
+            $criterion->addOr($criteria->getNewCriterion(KataoMemberPeer::LAST_NAME, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoMemberPeer::ACCOUNTING_CODE, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::EMAIL, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::ADDRESS1, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::ADDRESS2, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::ZIP, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::CITY, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::PHONE, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::FAX, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoUserPeer::LOGIN, $search_like, Criteria::LIKE));
+            $criteria->addAnd($criterion);
+        }
+
+        $criteria->setDistinct();
+
+        $rs = KataoMemberPeer::doSelectRS($criteria);
+
+        $content = array();
+        while ($rs->next()) {
+            $content[] = sprintf('"%s %s" <%s>', $rs->getString(1), $rs->getString(2), $rs->getString(3));
+        }
+        $content = implode(';', $content);
+
+        $response = $this->getResponse();
+        $response->setContentType('text/plain');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="Zyvon.txt"');
+        $response->setHttpHeader('Content-Length', strlen($content));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent($content);
+        return sfView::NONE;
+    }
+
+
+	public function executePrintSolCard($request) {
+        $criteria = new Criteria();
+        $criteria->add(KataoUserPeer::KATAO_MEMBER_ID,$request->getParameter('id'));
+        $criteria->addJoin(KataoUserPeer::KATAO_MEMBER_ID,KataoMemberPeer::ID,Criteria::LEFT_JOIN);            $katao_users = KataoUserPeer::doSelectJoinAllExceptKataoSupplier($criteria);
+
+		$katao_user = array();
+        if ( count($katao_users)>0  ) {
+            $katao_user = array_shift($katao_users);
+        }
+
+        $path = solViolette::generatePdf($katao_user,'kataoMember/pdf');
+        $content = file_get_contents($path);
+
+        $response = $this->getResponse();
+        $response->setContentType('application/pdf');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="DemandeCarteSol.pdf"');
+        $response->setHttpHeader('Content-Length', strlen($content));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent($content);
+        return sfView::NONE;
+    }
+
+	public function executeMailing($request){
+		$this->form = new KataomemberMailingForm();
+
+		if($this->form->isValid()){
+
+		}
+	}
+
+	public function executeAdhesionDelete($request)
+	{
+		// gestion-des-adherentes/delete/userid/ahdesionid
+		$this->forward404Unless($adhesion = KataoMemberAdhesionPeer::retrieveByPk($request->getParameter('id')));
+		$this->userid = $request->getParameter('userid');
+
+		$this->memberid = KataoUserPeer::retrieveMemberById($this->userid)->getKataoMemberId();
+
+		$c = new Criteria();
+		$c->add(KataoMemberAdhesionPeer::ID, $request->getParameter('id'));
+		$c->add(KataoMemberAdhesionPeer::KATAO_USER_ID, $this->userid);
+
+		$adhesion = KataoMemberAdhesionPeer::doSelectOne($c);
+		$adhesion->delete();
+
+		wpFlashMessages::addConfirmation('Adhésion du "' . $adhesion->getYear('Y') . '" supprimé avec succès.');
+
+		$this->redirect('@katao_member_show?id='.$this->memberid);
+		//$this->redirect('@katao_member_adhesion/id?='.$this->getParameter('id'));
+	}
+
+	public function executeAdhesionCreate($request){
+		$this->form = new KataoMemberAdhesionForm();
+
+		$this->userid = $request->getParameter('userid');
+        $this->memberid = KataoUserPeer::retrieveMemberById($this->userid)->getId();
+
+        $this->form->setDefault('katao_user_id', $this->userid);
+
+		if($request->isMethod('post'))
+		{
+			$this->form->bind($request->getParameter('form_subscription'));
+
+			if($this->form->isValid())
+			{
+				$save = $this->form->save();
+
+            	wpFlashMessages::addConfirmation('Adhésion ajouté avec succès.');
+				$this->redirect('@katao_member_show?id='.$this->memberid);
+			}
+		}
+
+		$this->setTemplate('adhesionCreate');
+	}
+
+	public function executeAdhesionEdit($request){
+		$adhesion = KataoMemberAdhesionPeer::retrieveByPk($request->getParameter('id'));
+
+		$this->form = new KataoMemberAdhesionForm($adhesion);
+
+		$this->id = $request->getParameter('id');
+		$this->userid = $request->getParameter('userid');
+
+		$this->memberid = KataoUserPeer::retrieveMemberById($this->userid)->getKataoMemberId();
+
+		if($request->isMethod('post'))
+		{
+			$this->form->bind($request->getParameter('form_subscription'));
+
+			if($this->form->isValid())
+			{
+				$adhesion = $this->form->save();
+
+				wpFlashMessages::addConfirmation('Adhésion modifié avec succès.');
+				$this->redirect('@katao_member_show?id='.$this->memberid);
+			}
+		}
+
+		$this->setTemplate('adhesionEdit');
+	}
+
+	public function executeAdhesionShowAll($request){
+		$con = Propel::getConnection();
+		$sql = "SELECT count(*)as cnt,  DATE_FORMAT(year, '%Y') as year, SUM(amount) as amount FROM `katao_member_adhesion` group by  year";
+		$this->adhesion_list = $con->executeQuery($sql);
+	}
+
+	public function executeSentRelance($request) {
+
+		sfLoader::loadHelpers('Partial');
+
+		$this->redirectWithErrorUnless($katao_member = KataoMemberPeer::retrieveByPk($request->getParameter('id')), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+		$this->redirectWithErrorUnless($katao_user = $katao_member->getFirstKataoUser(), 'Adhérent #' . $request->getParameter('id') . ' inconnu.');
+
+		$email = $katao_user->getEmail();
+		if ('' == $email) {
+			wpFlashMessages::addError('L\'adhérent "' . $katao_member->getFullName() . '" n\'a pas d\'adresse email.');
+		} else {
+			try {
+				$mailer = new wpMail();
+				$mailer->send(new Swift_Message('Relance', get_partial('katao/relanceEmail'), 'text/html' ), new Swift_Address($katao_user->getEmail(), $katao_user->getFullName()), sfConfig::get('app_mail_from'));
+				$mailer->disconnect();
+
+				wpFlashMessages::addConfirmation('Relance envoyée avec succès à l\'adhérent "' . $katao_member->getFullName() . '".');
+			}
+			catch (Exception $e) {
+				$mailer->disconnect();
+				wpFlashMessages::addError('L\'adhérent "' . $katao_member->getFullName() . '" n\'a pas d\'adresse email.');
+			}
+		}
+
+
+
+		$this->redirect('@katao_member_show?id='.$request->getParameter('id'));
+	}
+}

+ 3 - 0
apps/admin/modules/kataoMember/config/security.yml

@@ -0,0 +1,3 @@
+default:
+  is_secure: on
+  credentials: [[ admin, seo, delegate ]]

+ 4 - 0
apps/admin/modules/kataoMember/templates/__mailingSuccess.php

@@ -0,0 +1,4 @@
+<?php //$katao_member = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo 'Katao_Mailing' ?></h1></div>
+</div>

+ 100 - 0
apps/admin/modules/kataoMember/templates/_pdf.php

@@ -0,0 +1,100 @@
+<?php $adhesions = sfConfig::get('app_solviolette_adhesion') ?>
+<?php $situations = sfConfig::get('app_solviolette_situation') ?>
+<?php $user = /*(KataoUser)*/ $datas ?>
+<?php $member = /*(KataoMember)*/ $datas->getKataoMember() ?>
+
+<table cellpadding="1" cellspacing="3" border="0" width="100%">
+	<tr>
+		<td width="60%" align="left" valign="middle"><img src="/images/sol_violette.jpg" border="0" height="184" width="205" align="top" /></td>
+		<td width="40%" align="left" valign="bottom">
+			<div><img src="/images/sep.gif" border="0" height="70" width="10"/></div>
+			<div><p><b>Projet Sol-Violette</b><br/>45 rue de chaussas<br/>31200 TOULOUSE</p></div>
+		</td>
+	</tr>
+</table>
+
+<div style="text-align:center">
+	<h1>Demande de carte sol</h1>
+</div>
+
+<table cellpadding="1" cellspacing="3" border="0" width="100%">
+	<tr>
+		<td width="30%"></td>
+		<td></td>
+	</tr>
+	<tr>
+		<td width="30%">Prénom :</td>
+		<?php printf('<td>%s</td>',$member->getFirstName()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Nom :</td>
+		<?php printf('<td>%s</td>',$member->getLastName()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Email :</td>
+		<?php printf('<td>%s</td>',$user->getEmail()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Téléphone :</td>
+		<?php printf('<td>%s</td>',$user->getPhone()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Fax :</td>
+		<?php printf('<td>%s</td>',$user->getFax()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Date de naissance :</td>
+		<?php printf('<td>%s</td>',$member->getUserBirthday()?date('d/m/Y',strtotime($member->getUserBirthday())):'&nbsp;'); ?>
+	</tr>
+	<tr>
+		<td width="30%">Situation :</td>
+		<?php printf('<td>%s</td>',!empty($situations[$member->getUserSituation()])?$situations[$member->getUserSituation()]:'&nbsp;') ?>
+	</tr>
+	<tr>
+		<td width="30%">Adresse :</td>
+		<?php printf('<td>%s<br/>%s</td>',$user->getAddress1(),$user->getAddress2()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Code postal :</td>
+		<?php printf('<td>%s</td>',$user->getZip()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Ville :</td>
+		<?php printf('<td>%s</td>',$user->getCity()) ?>
+	</tr>
+
+	<tr>
+		<td width="30%">Identifiant :</td>
+		<?php printf('<td>%s</td>',$user->getLogin()) ?>
+	</tr>
+
+	<tr>
+		<td width="30%">Nom du parrain :</td>
+		<?php if ($member->getKataoMemberId() != null) {
+			$parrain = /*(KataoMember)*/KataoMemberPeer::retrieveByPk($member->getKataoMemberId());
+			printf('<td>%s</td>', $parrain->getFullName());
+		}
+		else{
+			printf('<td>&nbsp;</td>');
+		}
+		 ?>
+	</tr>
+	<tr>
+		<td width="30%">Numéro de carte :</td>
+		<?php printf('<td>%s</td>',$member->getCardNumberSol()) ?>
+	</tr>
+	<tr>
+		<td width="30%">Type :</td>
+		<?php printf('<td>&nbsp;</td>') ?>
+	</tr>
+</table>
+<p><span style="font-weight: bold;font-size: x-large;">Oui</span>, je souhaite recevoir ma carte SOL personnelle ainsi que mon code PIN.<br/>J'ai bien noté qu'elle est entièrement gratuite et n'entraîne aucune contrepartie de ma part.</p>
+<div><img src="/images/sep.gif" border="0" height="20" width="10"/></div>
+<p style="font-size: x-small;">Conformément à la loi Informatique et Libertés, vous disposez d'un droit d'accès et de rectification quant aux données vous concernant, que vous pouvez exercer librement auprès de SOL: info@sol-reseau.org.</p>
+<div><img src="/images/sep.gif" border="0" height="20" width="10"/></div>
+<table>
+<tr>
+<td width="70%" align="right">Signature :</td>
+<td width="30%">&nbsp;</td>
+</tr>
+</table>

+ 78 - 0
apps/admin/modules/kataoMember/templates/adhesionCreateSuccess.php

@@ -0,0 +1,78 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Ajout d'une adhésion</h1></div>
+</div>
+
+<form action="<?php //echo url_for('@katao_member_adhesion_create?userid='.$userid) ?>" method="post">
+	<?php echo $form->renderGlobalErrors() ?>
+         <?php echo $form['katao_user_id'] ?>
+		  <?php echo $form['katao_user_id']->renderError() ?>
+<table>
+	<tfoot>
+	  <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Ajouter" /> ou <a href="<?php echo url_for('@katao_member_show?id='.$memberid) ?>">annuler</a>
+        </td>
+      </tr>
+	</tfoot>
+	<thead>
+	</thead>
+	<tbody>
+		<?php echo $form->renderGlobalErrors() ?>
+		<tr>
+			<th align="left"><?php echo $form['year']->renderLabel() ?></th>
+			<td><?php echo $form['year'] ?>
+				<?php echo $form['year']->renderError() ?>
+			</td>
+		</tr>
+				<tr>
+			<th align="left"><?php echo $form['amount']->renderLabel() ?></th>
+			<td><?php echo $form['amount'] ?>
+				<?php echo $form['amount']->renderError() ?>
+			</td>
+		</tr>
+		<tr valign="top">
+	  		<td colspan="2" align="left"><br /><u><?php echo $form['type']->renderLabel() ?></u></td>
+	   </tr>
+		<tr>
+			<td><?php echo $form['type'] ?>
+				<?php echo $form['type']->renderError() ?>
+			</td>
+		</tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u><?php echo $form['payment_kind']->renderLabel() ?></u></td>
+	  </tr>
+		<tr>
+			<td><?php echo $form['payment_kind'] ?>
+				<?php echo $form['payment_kind']->renderError() ?>
+			</td>
+		</tr>
+		<tr id="cheque_numero_tr">
+			<th><?php echo $form['check_no']->renderLabel() ?></th>
+			<td>
+				<?php echo $form['check_no'] ?>
+				<?php echo $form['check_no']->renderError() ?>
+			</td>
+		</tr>
+	</tbody>
+</table>
+</form>
+
+<script language="Javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
+<script language="Javascript">
+	$().ready(function(){
+		if($('input[name="form_subscription[payment_kind]"]').val() == '2'){
+			$('#cheque_numero_tr').show();
+		} else {
+			$('#cheque_numero_tr').hide();
+		}
+	});
+
+	$('input[name="form_subscription[payment_kind]"]').change( function () {
+		if( $(this).val() == '2'){
+			$('#cheque_numero_tr').show();
+		} else {
+			$('#cheque_numero_tr').hide();
+		}
+	});
+
+</script>

+ 77 - 0
apps/admin/modules/kataoMember/templates/adhesionEditSuccess.php

@@ -0,0 +1,77 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Modification d'une adhésion</h1></div>
+</div>
+
+<form action="<?php echo url_for('@katao_member_adhesion_edit?id='.$id.'&userid='.$userid) ?>" method="post">
+         <?php echo $form['katao_user_id'] ?>
+		  <?php echo $form['katao_user_id']->renderError() ?>
+		          <?php echo $form['id'] ?>
+		  <?php echo $form['id']->renderError() ?>
+<table>
+	<tfoot>
+	  <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauvegarder" /> ou <a href="<?php echo url_for('@katao_member_show?id='.$memberid) ?>">annuler</a>
+        </td>
+      </tr>
+	</tfoot>
+	<tbody>
+		<?php echo $form->renderGlobalErrors() ?>
+		<tr>
+			<th align="left"><?php echo $form['year']->renderLabel() ?></th>
+			<td><?php echo $form['year'] ?>
+				<?php echo $form['year']->renderError() ?>
+			</td>
+		</tr>
+				<tr>
+			<th align="left"><?php echo $form['amount']->renderLabel() ?></th>
+			<td><?php echo $form['amount'] ?>
+				<?php echo $form['amount']->renderError() ?>
+			</td>
+		</tr>
+		<tr valign="top">
+	  		<td colspan="2" align="left"><br /><u><?php echo $form['type']->renderLabel() ?></u></td>
+	   </tr>
+		<tr>
+			<td><?php echo $form['type'] ?>
+				<?php echo $form['type']->renderError() ?>
+			</td>
+		</tr>
+	  <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u><?php echo $form['payment_kind']->renderLabel() ?></u></td>
+	  </tr>
+		<tr>
+			<td><?php echo $form['payment_kind'] ?>
+				<?php echo $form['payment_kind']->renderError() ?>
+			</td>
+		</tr>
+		<tr id="cheque_numero_tr">
+			<th><?php echo $form['check_no']->renderLabel() ?></th>
+			<td>
+				<?php echo $form['check_no'] ?>
+				<?php echo $form['check_no']->renderError() ?>
+			</td>
+		</tr>
+	</tbody>
+</table>
+</form>
+
+<script language="Javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
+<script language="Javascript">
+	$().ready(function(){
+		if($('input[name="form_subscription[payment_kind]"]').val() == '2'){
+			$('#cheque_numero_tr').show();
+		} else {
+			$('#cheque_numero_tr').hide();
+		}
+	});
+
+	$('input[name="form_subscription[payment_kind]"]').change( function () {
+		if( $(this).val() == '2'){
+			$('#cheque_numero_tr').show();
+		} else {
+			$('#cheque_numero_tr').hide();
+		}
+	});
+
+</script>

+ 22 - 0
apps/admin/modules/kataoMember/templates/adhesionShowAllSuccess.php

@@ -0,0 +1,22 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Vue d'ensemble des adhésions</h1></div>
+</div>
+
+<table class="admin-list"> 
+	<thead>
+		<tr>
+			<th>Année</th>
+			<th>Cotisations</th>
+			<th>Nombre d'adhérents</th>
+		</tr>
+	</thead>
+	<tbody>
+	<?php foreach($adhesion_list as $al): ?>
+		<tr>
+			<td><?php echo $al['year'] ?> </td>
+			<td><?php echo $al['amount'] ?></td>
+			<td><?php echo $al['cnt'] ?></td>
+		</tr>
+	<?php endforeach ?>
+	</tbody>
+</table>

+ 23 - 0
apps/admin/modules/kataoMember/templates/changeNextNodeMultipleSuccess.php

@@ -0,0 +1,23 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Changement de noeud des <?php echo multiple_action_info_selected('katao_member') ?> adhérents sélectionnés</h1></div>
+</div>
+
+<form action="<?php echo url_for('@katao_member_change_next_node_multiple') ?>" method="post">
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMember/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <th align="left"><?php echo label_for('next_katao_node_id', 'Noeud (périodes suivantes)') ?></th>
+        <td>
+          <?php echo select_tag('next_katao_node_id', options_for_select(KataoNodePeer::getAllArray(), false, array('include_custom' => '&mdash;&nbsp;aucun&nbsp;&mdash;'))) ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 141 - 0
apps/admin/modules/kataoMember/templates/editSuccess.php

@@ -0,0 +1,141 @@
+<?php $katao_member = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_member->isNew() ? 'Ajout' : 'Modification' ?> d'un adhérent</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoMember/update'.(!$katao_member->isNew() ? '?id='.$katao_member->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMember/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+  <?php if (!$sf_user->isJustDelegate()): ?>
+	  <tr valign="top">
+        <th align="left">Noeuds : <?php echo $form['katao_node_id']->renderLabel() ?>/<?php echo $form['next_katao_node_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_node_id'] ?>
+          <?php echo $form['next_katao_node_id'] ?>
+		  <?php echo $form['katao_node_id']->renderError() ?>
+		  <?php echo $form['next_katao_node_id']->renderError() ?>
+        </td>
+      </tr>
+  <?php else: ?>
+     <tr valign="top">
+        <th align="left"><label>Noeud</label></th>
+        <td>
+          <?php echo $sf_user->getInstance()->getKataoMember()->getKataoNode()->getCity() ?>
+        </td>
+      </tr>
+  <?php endif ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['first_name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['first_name'] ?>
+		  <?php echo $form['first_name']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['last_name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['last_name'] ?>
+		  <?php echo $form['last_name']->renderError() ?>
+        </td>
+      </tr>
+  <?php if (!$katao_member->isNew()): ?>
+      <tr valign="top">
+        <th align="left"><label>Code comptable (€)</label></th>
+        <td>
+          <?php echo $katao_member->getAccountingCode() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><label>Code comptable (<?php echo wpConfig::getAdditionalCurrencyName() ?>)</label></th>
+        <td>
+          <?php echo $katao_member->getAccountingCodeSol() ?>
+        </td>
+      </tr>
+  <?php endif ?>
+  <?php if (!$sf_user->isJustDelegate()): ?>
+      <tr valign="top">
+        <th align="left"><label>Permissions</label></th>
+        <td>
+          <?php echo $form['is_admin'] ?><?php echo $form['is_admin']->renderLabel() ?>
+		  <?php echo $form['is_admin']->renderError() ?>
+          <?php echo $form['is_referer'] ?><?php echo $form['is_referer']->renderLabel() ?>
+		  <?php echo $form['is_referer']->renderError() ?>
+          <?php echo $form['is_delegate'] ?><?php echo $form['is_delegate']->renderLabel() ?>
+		  <?php echo $form['is_delegate']->renderError() ?>
+        </td>
+      </tr>
+  <?php endif ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['is_anonymous']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['is_anonymous'] ?>
+		  <?php echo $form['is_anonymous']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['is_member']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['is_member'] ?>
+		  <?php echo $form['is_member']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_member_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_member_id'] ?>
+		  <?php echo $form['katao_member_id']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+
+        <?php if ($sf_user->isJustDelegate()): ?>
+          <?php echo input_hidden_tag('katao_member[katao_node_id]', $form['katao_node_id']->getValue()) ?>
+          <?php echo input_hidden_tag('katao_member[next_katao_node_id]', $form['next_katao_node_id']->getValue()) ?>
+          <?php echo input_hidden_tag('katao_member[is_admin]', $form['is_admin']->getValue()) ?>
+          <?php echo input_hidden_tag('katao_member[is_referer]', $form['is_referer']->getValue()) ?>
+          <?php echo input_hidden_tag('katao_member[is_delegate]', $form['is_delegate']->getValue()) ?>
+          <?php echo input_hidden_tag('katao_member[card_number_sol]', $form['card_number_sol']->getValue()) ?>
+        <?php endif ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['initial_amount_euro']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['initial_amount_euro'] ?>
+		  <?php echo $form['initial_amount_euro']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['initial_amount_sol']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['initial_amount_sol'] ?>
+		  <?php echo $form['initial_amount_sol']->renderError() ?>
+        </td>
+      </tr>
+  <?php if (!$sf_user->isJustDelegate()): ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['card_number_sol']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['card_number_sol'] ?>
+		  <?php echo $form['card_number_sol']->renderError() ?>
+        </td>
+      </tr>
+  <?php endif ?>
+  	  <tr valign="top">
+        <th align="left"><?php echo $form['created_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['created_at'] ?>
+		  <?php echo $form['created_at']->renderError() ?>
+        </td>
+      </tr>
+	  <?php include_partial('katao/user', array('form' => $form, 'is_member' => true)) ?>
+    </tbody>
+  </table>
+</form>

+ 92 - 0
apps/admin/modules/kataoMember/templates/indexSuccess.php

@@ -0,0 +1,92 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des adhérents (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter" style="margin-bottom: 0px!important">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_member_filter') ?>
+			<?php echo select_tag('filter_node', options_for_select(KataoNodePeer::getAllArray(), $filter_node, array('include_custom' => '&mdash;&nbsp;Noeud&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_referer', options_for_select(array(CONST_YES => 'Oui', CONST_NO => 'Non'), $filter_referer, array('include_custom' => '&mdash;&nbsp;Référent&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_delegate', options_for_select(array(CONST_YES => 'Oui', CONST_NO => 'Non'), $filter_delegate, array('include_custom' => '&mdash;&nbsp;Délégué&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_anonymous', options_for_select(array(CONST_YES => 'Oui', CONST_NO => 'Non'), $filter_anonymous, array('include_custom' => '&mdash;&nbsp;Anonyme&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_status', options_for_select(KataoUserPeer::getAllStatuses(), $filter_status, array('include_custom' => '&mdash;&nbsp;Etat&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_member', options_for_select(array(CONST_YES => 'Oui', CONST_NO => 'Non'), $filter_member, array('include_custom' => '&mdash;&nbsp;Adhérent&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_member_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_member_search') ?>
+			Rechercher : <?php echo input_tag('search', $search, array('style' => 'width: 250px')) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Rechercher')) ?><div style="float:right"><a href="<?php echo url_for('@katao_member_search_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_memberList)): ?>
+	<p>Aucun adhérent.</p>
+	<p><?php echo link_to('Ajouter un adhérent', '@katao_member_add', array('class' => 'add')) ?></p>
+<?php else : ?>
+  	<?php echo link_to('Ajouter un adhérent', '@katao_member_add', array('class' => 'add')) ?>
+  	<?php echo link_to('Exporter sur Zyvon', '@katao_member_export_zyvon', array('class' => 'zyvon')) ?>
+  <?php if (!$is_just_delegate): ?>
+  	<?php echo link_to('Changer les adhérents sélectionnés (' . multiple_action_info_selected('katao_member') . ') de noeud', '@katao_member_change_next_node_multiple', array('class' => 'change-node')) ?>
+  <?php endif ?>
+  	<?php echo link_to('Supprimer les adhérents sélectionnés (' . multiple_action_info_selected('katao_member') . ')', '@katao_member_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les adhérents sélectionnés ?')) ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_member') ?></th>
+	  <th nowrap="nowrap">Nom <?php echo sort_links($sf_request, 'name', 'kataoMember/index') ?></th>
+	  <th nowrap="nowrap">Noeud <?php echo sort_links($sf_request, 'node', 'kataoMember/index') ?></th>
+	  <th nowrap="nowrap">Réf. <?php echo sort_links($sf_request, 'referer', 'kataoMember/index') ?></th>
+	  <th nowrap="nowrap">Dél. <?php echo sort_links($sf_request, 'delegate', 'kataoMember/index') ?></th>
+	  <th nowrap="nowrap">Anon. <?php echo sort_links($sf_request, 'anonymous', 'kataoMember/index') ?></th>
+	  <th nowrap="nowrap">Solde € / <?php echo wpConfig::getAdditionalCurrencyName() ?></th>
+	  <th nowrap="nowrap">Etat <?php echo sort_links($sf_request, 'status', 'kataoMember/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_memberList as/*(KataoMember)*/ $katao_member): ?>
+		<?php $katao_user = $katao_member->getFirstKataoUser() ?>
+    <tr valign="top" class="line">
+		  <td class="center">
+		<?php if (!$is_just_delegate || $current_user_node_id == $katao_member->getKataoNodeId()): ?>
+		  	<?php echo multiple_action_checkbox_line('katao_member', $katao_member->getId()) ?>
+		<?php endif ?>
+		  </td>
+		  <td>
+		  <?php if ($katao_user->getEmail()): ?>
+		  	<?php echo mail_to($katao_user->getEmail(), $katao_user->getFullName()) ?>
+		  <?php else: ?>
+		    <?php echo $katao_user->getFullName() ?>
+		  <?php endif ?>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_member->getNodeLink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member->getIsRefererStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member->getIsDelegateStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member->getIsAnonymousStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member->getCurrentAmountStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member->getStatusStr() ?></td>
+		  <td nowrap="nowrap">
+			<?php echo catalyz_link_to_image_tag('@katao_member_show?id=' . $katao_member->getId(), 'actions/show.png', array('title' => 'Voir'), array('alt' => 'Voir')) ?>
+		<?php echo catalyz_link_to_image_tag('@katao_member_print_sol_card?id=' . $katao_member->getId(), 'actions/printer_mono.png', array('title' => 'Télécharger le bulletin d\'adhésion SOL'), array('alt' => 'Télécharger le bulletin d\'adhésion SOL')) ?>
+		<?php if (!$is_just_delegate || $current_user_node_id == $katao_member->getKataoNodeId()): ?>
+			<?php echo catalyz_link_to_image_tag('@katao_member_send_login?id=' . $katao_member->getId(), 'actions/send.png', array('title' => 'Envoyer le login'), array('alt' => 'Envoyer le login')) ?>
+			<?php echo catalyz_link_to_image_tag('@katao_member_edit?id=' . $katao_member->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+			<?php echo catalyz_link_to_image_tag('@katao_member_gmap?id=' . $katao_member->getId(), 'actions/gmap.png', array('title' => 'Positionner sur la carte'), array('alt' => 'Positionner sur la carte')) ?>
+			<?php echo catalyz_link_to_image_tag(sprintf('%skatao/login/%s/%s', sfConfig::get('app_katao_frontend_url'), $katao_user->getLogin(), $katao_user->getPassword()), 'actions/login.png', array('title' => 'Se connecter sur la boutique en tant que cet adhérent', 'target' => '_blank'), array('alt' => 'Se connecter sur la boutique en tant que cet adhérent')) ?>
+			<?php if ($katao_member->isDeletable()): ?>
+				<?php echo catalyz_link_to_image_tag('@katao_member_delete?id=' . $katao_member->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer ce adhérent ?'), array('alt' => 'Supprimer')) ?>
+			<?php endif ?>
+		<?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoMember/index?sort=%s%s', $sf_request->getParameter('sort', 'name'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_member') ?>
+<?php endif ?>

+ 120 - 0
apps/admin/modules/kataoMember/templates/showSuccess.php

@@ -0,0 +1,120 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Adhérent : <?php echo $katao_member->getFullName() ?></h1></div>
+</div>
+
+<u>Historique de ses adhésions :</u>
+<a class="send_button_link" href="<?php /*echo url_for('@katao_member_sent_relance?id='.$userid)*/ ?>">Envoyer la relance</a>
+<a class="add_button_link" href="<?php echo url_for('@katao_member_adhesion_create?userid='.$userid) ?>">Ajouter une adhésion</a>
+
+
+<table class="admin-list">
+	<thead>
+		<tr>
+			<th>Année</th>
+			<th>Montant</th>
+			<th>Moyen de paiement</th>
+			<th>Nouvelle adhésion</th>
+			<th>Actions</th>
+		</tr>
+	</thead>
+	<tbody>
+	<?php foreach($list_objet as $obj): ?>
+		<tr>
+			<td>
+				<?php echo $obj->getYear('Y') ?>
+			</td>
+			<td>
+				<?php echo $obj->getAmount()." €" ?>
+			</td>
+			<td>
+				<?php echo KataoMemberAdhesionPeer::$HASH_TABLE['payment_kind'][$obj->getPaymentKind()] ?>
+				<?php
+					if($obj->getPaymentKind() == 2){
+						echo "n° ".$obj->getCheckNo();
+					}
+				?>
+			</td>
+			<td>
+				<?php echo KataoMemberAdhesionPeer::$HASH_TABLE['type'][$obj->getType()] ?>
+			</td>
+			<td>
+				<a href='<?php echo url_for('@katao_member_adhesion_edit?id='.$obj->getId().'&userid='.$userid) ?>'><?php echo image_tag('actions/edit.png') ?></a>
+	   			<?php echo catalyz_link_to_image_tag('@katao_member_adhesion_delete?userid='.$userid.'&id='.$obj->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer cette adhésion ?'), array('alt' => 'Supprimer')) ?>
+			</td>
+		</tr>
+	<?php endforeach ?>
+	</tbody>
+</table>
+<br />
+<u>Historique de ses noeuds :</u>
+<table class="admin-list">
+<tr>
+	<th nowrap="nowrap">Début</th>
+	<th nowrap="nowrap">Fin</th>
+	<th nowrap="nowrap">Noeud</th>
+</tr>
+<?php foreach ($katao_member->getNodesHistory() as $history): ?>
+<tr valign="top">
+	<td nowrap="nowrap"><?php echo $history['begin'] ?></td>
+	<td nowrap="nowrap"><?php echo $history['end'] ?></td>
+	<td nowrap="nowrap"><?php echo $history['node'] ?></td>
+</tr>
+<?php endforeach ?>
+</table>
+
+<br /><u>Liste de ses filleuls :</u>
+
+<?php $filleuls = $katao_member->getKataoMembersRelatedByKataoMemberId() ?>
+<?php if (0 == count($filleuls)): ?>
+	<p><i>Aucun filleul.</i></p>
+<?php else: ?>
+	<ul>
+	<?php foreach ($filleuls as/*(KataoMember)*/ $filleul): ?>
+		<li><?php echo link_to($filleul->getFullName(), '@katao_member_show?id=' . $filleul->getId()) ?></li>
+	<?php endforeach ?>
+	</ul>
+<?php endif ?>
+
+<?php if (0 < count($history_euro)): ?>
+<br /><u>Historique de ses transactions en € :</u>
+<table class="profile-list">
+<tr>
+	<th nowrap="nowrap" width="1%">Date</th>
+	<th>Nature</th>
+	<th nowrap="nowrap" width="1%">Montant</th>
+	<th nowrap="nowrap" width="1%">Solde</th>
+</tr>
+<?php $is_firt = true ?>
+<?php foreach ($history_euro as $history): ?>
+<tr valign="top">
+	<td nowrap="nowrap" width="1%"><?php echo CatalyzDate::formatShort($history['date']) ?></td>
+	<td><?php echo $history['summary'] ?></td>
+	<td nowrap="nowrap" width="1%" style="text-align: right!important"><?php echo ('initial' != $history['type'])?Utils::formatCurrencyEuro($history['amount']):'' ?></td>
+	<td nowrap="nowrap" width="1%" style="text-align: right!important"<?php echo $is_firt?' class="bold"':'' ?>><?php echo Utils::formatCurrencyEuro($history['account']) ?></td>
+</tr>
+	<?php $is_firt = false ?>
+<?php endforeach ?>
+</table>
+<?php endif ?>
+
+<?php if (0 < count($history_sol)): ?>
+<br /><u>Historique de ses transactions en <?php echo wpConfig::getAdditionalCurrencyName() ?> :</u>
+<table class="profile-list">
+<tr>
+	<th nowrap="nowrap" width="1%">Date</th>
+	<th>Nature</th>
+	<th nowrap="nowrap" width="1%">Montant</th>
+	<th nowrap="nowrap" width="1%">Solde</th>
+</tr>
+<?php $is_firt = true ?>
+<?php foreach ($history_sol as $history): ?>
+<tr valign="top">
+	<td nowrap="nowrap" width="1%"><?php echo CatalyzDate::formatShort($history['date']) ?></td>
+	<td><?php echo $history['summary'] ?></td>
+	<td nowrap="nowrap" width="1%" style="text-align: right!important"><?php echo ('initial' != $history['type'])?Utils::formatCurrencySol($history['amount']):'' ?></td>
+	<td nowrap="nowrap" width="1%" style="text-align: right!important"<?php echo $is_firt?' class="bold"':'' ?>><?php echo Utils::formatCurrencySol($history['account']) ?></td>
+</tr>
+	<?php $is_firt = false ?>
+<?php endforeach ?>
+</table>
+<?php endif ?>

+ 49 - 0
apps/admin/modules/kataoMember/templates/updateGmapCoordinatesSuccess.php

@@ -0,0 +1,49 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Positionnement de l'adhérent : <?php echo $katao_member->getFullName() ?></h1></div>
+</div>
+
+<form action="<?php echo url_for('@katao_member_gmap?id=' . $katao_member->getId()) ?>" method="post">
+
+<?php echo input_hidden_tag('gmap_lng', $katao_user->getGmapLng()) ?>
+<?php echo input_hidden_tag('gmap_lat', $katao_user->getGmapLat()) ?>
+
+<p><i>Modifier ci-dessous le positionnement de cet adhérent sur la carte en déplaçant le pion rouge.</i></p>
+
+<input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMember/index') ?>">annuler</a><br /><br />
+
+<script type="text/javascript" src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=<?php echo sfConfig::get('app_gmap') ?>&sensor=true"></script>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+window.onload = function(){
+	if (GBrowserIsCompatible()) {
+        var map = new GMap2($("map_canvas"));
+		map.setCenter(new GLatLng(45, 3), 6);
+        map.setUIToDefault();
+
+        // "tiny" marker icon
+		var icon = new GIcon();
+		icon.image = "http://maps.google.com/mapfiles/ms/micons/red-dot.png";
+		icon.iconSize = new GSize(32, 32);
+		icon.iconAnchor = new GPoint(16, 32);
+
+		var point = new GLatLng(<?php echo $katao_user->getGmapLat() ?>,<?php echo $katao_user->getGmapLng() ?>);
+
+		var markerD = new GMarker(point, {icon:icon, draggable: true});
+		map.addOverlay(markerD);
+		markerD.enableDragging();
+		GEvent.addListener(markerD, "drag", function(){
+			$("gmap_lng").value = markerD.getPoint().lng();
+			$("gmap_lat").value = markerD.getPoint().lat();
+		});
+
+	}
+}
+
+/* ]]> */
+</script>
+
+<div id="map_canvas" style="width: 735px; height: 500px"></div>
+
+</form>

+ 97 - 0
apps/admin/modules/kataoMemberAdhesion/actions/actions.class.php

@@ -0,0 +1,97 @@
+<?php
+
+/**
+ * kataoMemberAdhesion actions.
+ *
+ * @package    www.katao.fr
+ * @subpackage kataoMemberAdhesion
+ * @author     Your name here
+ * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
+ */
+class kataoMemberAdhesionActions extends sfActions
+{
+	/**
+  * Executes index action
+  *
+  * @param sfRequest $request A request object
+  */
+	public function executeAdhesionDelete($request)
+	{
+		// gestion-des-adherentes/delete/userid/ahdesionid
+		$this->forward404Unless($adhesion = KataoMemberAdhesionPeer::retrieveByPk($request->getParameter('id')));
+
+		$c = new Criteria();
+		$c->add(KataoMemberAdhesionPeer::ID, $request->getParameter('id'));
+		$c->add(KataoMemberAdhesionPeer::KATAO_USER_ID, $request->getParameter('userid'));
+
+		$adhesion = KataoMemberAdhesionPeer::doSelectOne($c);
+		$adhesion->delete();
+
+		wpFlashMessages::addConfirmation('Adhésion du "' . $adhesion->getYear('Y') . '" supprimé avec succès.');
+
+		$this->redirect('@katao_member_show?id='.$request->getParameter('userid'));
+		//$this->redirect('@katao_member_adhesion/id?='.$this->getParameter('id'));
+	}
+
+	public function executeAdhesionCreate($request){
+		$this->form = new KataoMemberAdhesionForm();
+
+		$userid = $request->getParameter('userid');
+		$this->form->setDefault('katao_user_id', $userid);
+
+		var_dump($this->form->getValue('katao_user_id'));
+
+		if($request->isMethod('post'))
+		{
+			$this->form->bind($request->getParameter('form_subscription'));
+
+			if($this->form->isValid())
+			{
+				$id = $request->getParameter('id');
+
+				$save = $this->form->save();
+				wpFlashMessages::addConfirmation('Adhésion ajouté avec succès.');
+				$this->redirect('@katao_member_show?id='.$save->getKataoUserId());
+			}
+		}
+
+		$this->setTemplate('adhesionCreate');
+	}
+
+	public function executeAdhesionUpdate($request){
+		$adhesion = KataoMemberAdhesionPeer::retrieveByPk($request->getParameter('id'));
+
+		$this->form = new KataoMemberAdhesionForm($adhesion);
+
+		$this->id = $request->getParameter('id');
+		$this->userid = $request->getParameter('userid');
+
+		$this->form->setDefault('katao_user_id', $request->getParameter('userid'));
+	//	var_dump($this->form->getKatao_user_id());
+
+		if($request->isMethod('post'))
+		{
+			$this->form->bind($request->getParameter('form_subscription'));
+
+			$userid = $request->getParameter('userid');
+
+			if($this->form->isValid())
+			{
+				//$save = $this->form->save();
+				$adhesion = $this->form->save();
+
+				wpFlashMessages::addConfirmation('Adhésion modifié avec succès.');
+				$this->redirect('@katao_member_show?id='.$this->userid);
+			}
+		}
+
+		$this->setTemplate('adhesionUpdate');
+	}
+
+	public function showAllAdhesions($request){
+		$c = new Criteria();
+
+		$sql = "SELECT count(*) as cnt, year, amount, FROM 'katao_member_adhesion' group by year, amount";
+	}
+
+}

+ 39 - 0
apps/admin/modules/kataoMemberAdhesion/templates/indexSuccess.php

@@ -0,0 +1,39 @@
+<?php //$katao_member_group = $form->getObject() ?>
+<div class="content-add01">
+  <div class="heading01"><h1>Adh&eacute;sions</h1></div>
+</div>
+
+<table class="admin-list">
+	<tfoot>
+		<a href="">Ajouter une ann&eacute;e</a>
+	</tfoot>
+	<thead>
+		<th>Année</th>
+		<th>Montant</th>
+		<th>Moyen de paiement</th>
+		<th>Nouvelle adhésion</th>
+		<th>Actions</th>
+	</thead>
+	<tbody>
+	<?php foreach($list_objet as $obj): ?>
+		<tr>
+			<td>
+				<?php $year = getdate($obj->getYear()); echo $year[year]; ?>
+			</td>
+			<td>
+				<?php echo $obj->getAmount()." €" ?>
+			</td>
+			<td>
+				<?php echo KataoMemberAdhesionPeer::$HASH_TABLE['payment_kind'][$obj->getPaymentKind()] ?>
+			</td>
+			<td>
+				<?php echo KataoMemberAdhesionPeer::$HASH_TABLE['type'][$obj->getType()] ?>
+			</td>
+			<td>
+				<a href='<?php echo url_for('@katao_member_adhesion_edit?id='.$obj->getId()) ?>'><?php echo image_tag('actions/edit.png') ?></a>
+				<a href='<?php echo url_for('@katao_member_adhesion_delete?userid='.$userid.'&id='.$obj->getId()) ?>'><?php echo image_tag('actions/delete.png')?> </a>
+			</td>
+		</tr>
+	<?php endforeach ?>
+	</tbody>
+</table>

+ 445 - 0
apps/admin/modules/kataoMemberDeposit/actions/actions.class.php

@@ -0,0 +1,445 @@
+<?php
+
+/**
+ * kataoMemberDeposit actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoMemberDeposit
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoMemberDepositActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoMemberDepositPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+
+        if ($this->getUser()->isJustDelegate()) {
+            $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId());
+        }
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'date')) {
+            case 'member':
+                $criteria->$sort_method(KataoMemberPeer::LAST_NAME);
+                $criteria->$sort_method(KataoMemberPeer::FIRST_NAME);
+                break;
+            case 'amount':
+                $criteria->$sort_method(KataoMemberDepositPeer::AMOUNT);
+                break;
+            case 'status':
+                $criteria->$sort_method(KataoMemberDepositPeer::STATUS);
+                break;
+            case 'payment-mode':
+                $criteria->$sort_method(KataoMemberDepositPeer::PAYMENT_MODE);
+                break;
+            default:
+                $criteria->$sort_method(KataoMemberDepositPeer::VALUED_AT);
+        }
+
+        if ('' != $this->filter_member = $this->getUser()->getAttribute('katao_member_deposit_filter_member')) {
+            $criteria->add(KataoMemberDepositPeer::KATAO_MEMBER_ID, $this->filter_member);
+        }
+        if ('' != $this->filter_currency = $this->getUser()->getAttribute('katao_member_deposit_filter_currency')) {
+            $criteria->add(KataoMemberDepositPeer::CURRENCY, $this->filter_currency);
+        }
+        if ('' != $this->filter_payment_mode = $this->getUser()->getAttribute('katao_member_deposit_filter_payment_mode')) {
+            $criteria->add(KataoMemberDepositPeer::PAYMENT_MODE, $this->filter_payment_mode);
+        }
+        if ('' != $this->filter_status = $this->getUser()->getAttribute('katao_member_deposit_filter_status')) {
+            $criteria->add(KataoMemberDepositPeer::STATUS, $this->filter_status);
+        }
+
+        $pager = new sfPropelPager('KataoMemberDeposit', sfConfig::get('app_pager'));
+        $pager->setPeerMethod('doSelectJoinKataoMember');
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_member_depositList = $pager->getResults();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_member_deposit_filter_member', $request->getParameter('filter_member'));
+        $this->getUser()->setAttribute('katao_member_deposit_filter_currency', $request->getParameter('filter_currency'));
+        $this->getUser()->setAttribute('katao_member_deposit_filter_payment_mode', $request->getParameter('filter_payment_mode'));
+        $this->getUser()->setAttribute('katao_member_deposit_filter_status', $request->getParameter('filter_status'));
+        return $this->redirect('kataoMemberDeposit/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_member_deposit_filter_member', '');
+        $this->getUser()->setAttribute('katao_member_deposit_filter_currency', '');
+        $this->getUser()->setAttribute('katao_member_deposit_filter_payment_mode', '');
+        $this->getUser()->setAttribute('katao_member_deposit_filter_status', '');
+        return $this->redirect('kataoMemberDeposit/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_member_deposit = KataoMemberDepositPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_member_deposit, 'Dépôt #' . $request->getParameter('id') . ' inconnu.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoMemberDepositForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $katao_member_deposit = KataoMemberDepositPeer::retrieveByPk($request->getParameter('id'));
+
+        if (!is_null($katao_member_deposit)) {
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+            $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $katao_member_deposit->getKataoMember()->getKataoNodeId());
+        }
+
+        $this->form = new KataoMemberDepositForm($katao_member_deposit);
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $katao_member_deposit = KataoMemberDepositPeer::retrieveByPk($request->getParameter('id'));
+
+        if (!is_null($katao_member_deposit)) {
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+            $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $katao_member_deposit->getKataoMember()->getKataoNodeId());
+        }
+
+        $this->form = new KataoMemberDepositForm($katao_member_deposit);
+
+        $this->form->bind($request->getParameter('katao_member_deposit'));
+        if ($this->form->isValid()) {
+            $katao_member_deposit = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Dépôt "' . $katao_member_deposit->getMemberName() . '" sauvé avec succès.');
+            $this->redirect('kataoMemberDeposit/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_member_deposit = KataoMemberDepositPeer::retrieveByPk($request->getParameter('id')), 'Dépôt #' . $request->getParameter('id') . ' inconnu.');
+
+        $is_just_delegate = $this->getUser()->isJustDelegate();
+        $current_user_node_id = $this->getUser()->getInstance()->getKataoMember()->getKataoNodeId();
+        $this->redirectWithErrorIf($is_just_delegate && $current_user_node_id != $katao_member_deposit->getKataoMember()->getKataoNodeId());
+
+        $katao_member_deposit->delete();
+
+        wpFlashMessages::addConfirmation('Dépôt "' . $katao_member_deposit->getMemberName() . '" supprimé avec succès.');
+        $this->redirect('kataoMemberDeposit/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_member_deposit')) {
+            $criteria = new Criteria();
+            $criteria->add(KataoMemberDepositPeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_member_deposit')), Criteria::IN);
+            KataoMemberDepositPeer::doDelete($criteria);
+
+            wpPersistenceManager::cleanSelection('katao_member_deposit');
+            wpFlashMessages::addConfirmation('Les dépôts sélectionnés ont été supprimés avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un dépôt.');
+        }
+
+        $this->redirect('kataoMemberDeposit/index');
+    }
+
+    public function executeDispatchSols($request) {
+    }
+
+    public function executeDispatchSolsUpdate($request) {
+        $katao_member_ids = array();
+        if ('member' == $request->getParameter('type') && '' != $request->getParameter('member')) {
+            $katao_member_ids[] = $request->getParameter('member');
+        } elseif (('node' == $request->getParameter('type') && '' != $request->getParameter('node')) || ('all' == $request->getParameter('type'))) {
+            $criteria = new Criteria();
+            $criteria->addSelectColumn(KataoMemberPeer::ID);
+            $criteria->addJoin(KataoMemberPeer::ID, KataoUserPeer::KATAO_MEMBER_ID);
+            if ('all' != $request->getParameter('type')) {
+                $criteria->add(KataoMemberPeer::KATAO_NODE_ID, $request->getParameter('node'));
+            }
+            $criteria->add(KataoMemberPeer::IS_MEMBER, true);
+            $criteria->add(KataoUserPeer::STATUS, KataoUser::STATUS_ACTIVE);
+
+            $rs = KataoMemberPeer::doSelectRS($criteria);
+            while ($rs->next()) {
+                $katao_member_ids[] = $rs->getInt(1);
+            }
+        }
+
+        if (0 < $katao_member_ids_count = count($katao_member_ids)) {
+            if (0 < $amount = floor((int)$request->getParameter('amount') / $katao_member_ids_count)) {
+                foreach ($katao_member_ids as $katao_member_id) {
+                    $katao_member_deposit = new KataoMemberDeposit();
+                    $katao_member_deposit->setKataoMemberId($katao_member_id);
+                    $katao_member_deposit->setAmount($amount);
+                    $katao_member_deposit->setCurrency(KataoMemberDeposit::CURRENCY_SOL);
+                    $katao_member_deposit->setPaymentMode(KataoMemberDeposit::PAYMENT_MODE_OTHER);
+                    $katao_member_deposit->setStatus(KataoMemberDeposit::STATUS_VALIDATED);
+                    $katao_member_deposit->save();
+                }
+                wpFlashMessages::addConfirmation(sprintf('%d %s ont été répartis sur les %d adhérents.', $amount, wpConfig::getAdditionalCurrencyName(), $katao_member_ids_count));
+            } else {
+                wpFlashMessages::addWarning(sprintf('Impossible de répartir %d %s sur %s adhérents.', $request->getParameter('amount'), wpConfig::getAdditionalCurrencyName(), $katao_member_ids_count));
+            }
+        } else {
+            wpFlashMessages::addWarning('Impossible de répartir les ' . wpConfig::getAdditionalCurrencyName() . ' sur aucun adhérent.');
+        }
+
+        return $this->redirect('kataoMemberDeposit/index');
+    }
+
+    public function validateDispatchSolsUpdate() {
+        $return = true;
+
+        if ('' == $this->getRequestParameter('amount')) {
+            $this->getRequest()->setError('amount', 'Merci de saisir un montant');
+            $return = false;
+        }
+        if ('' == $type = $this->getRequestParameter('type')) {
+            $this->getRequest()->setError('type', 'Merci de choisir un type de bénéficiaire(s)');
+            $return = false;
+        }
+        if ('member' == $type && '' == $this->getRequestParameter('member')) {
+            $this->getRequest()->setError('member', 'Merci de sélectionner un adhérent');
+            $return = false;
+        }
+        if ('node' == $type && '' == $this->getRequestParameter('node')) {
+            $this->getRequest()->setError('node', 'Merci de sélectionner un noeud');
+            $return = false;
+        }
+
+        return $return;
+    }
+
+    public function handleErrorDispatchSolsUpdate() {
+        return $this->forward('kataoMemberDeposit', 'dispatchSols');
+    }
+
+    public function executePrintChecks($request) {
+        if (wpPersistenceManager::isEmpty('katao_member_deposit')) {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un dépôt.');
+            return $this->redirect('kataoMemberDeposit/index');
+        }
+
+        $katao_member_deposits = array();
+
+        $criteria = new Criteria();
+        $criteria->add(KataoMemberDepositPeer::ID, array_keys(wpPersistenceManager::getSelectedItems('katao_member_deposit')), Criteria::IN);
+        foreach (KataoMemberDepositPeer::doSelect($criteria) as/*(KataoMemberDeposit)*/ $katao_member_deposit) {
+            if (KataoMemberDeposit::PAYMENT_MODE_CHECK == $katao_member_deposit->getPaymentMode()) {
+                $katao_member_deposits[] = $katao_member_deposit;
+            }
+        }
+
+        if (0 == count($katao_member_deposits)) {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un dépôt sous forme de chèque.');
+            return $this->redirect('kataoMemberDeposit/index');
+        }
+
+        if ($request->isMethod('post')) {
+            $number = $request->getParameter('number');
+
+            $sf_php_excel = new sfPhpExcel();
+
+            $file_name = tempnam(sfConfig::get('sf_upload_dir'), 'excel_');
+
+            $sf_php_excel->setActiveSheetIndex(0);
+
+            $style_header = array(
+                'font' => array(
+                    'bold' => true,
+                    'color' => array('argb' => PHPExcel_Style_Color::COLOR_WHITE),
+                    ),
+                'alignment' => array(
+                    'horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT,
+                    ),
+                'borders' => array(
+                    'top' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    'right' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    'bottom' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    'left' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    ),
+                'fill' => array(
+                    'type' => PHPExcel_Style_Fill::FILL_SOLID,
+                    'startcolor' => array(
+                        'argb' => 'FFA0A0A0',
+                        ),
+                    ),
+                );
+            $style_border = array(
+                'borders' => array(
+                    'top' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    'right' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    'bottom' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    'left' => array(
+                        'style' => PHPExcel_Style_Border::BORDER_THIN,
+                        ),
+                    ),
+                );
+
+            $sf_php_excel->getActiveSheet()->mergeCells('A1:B1');
+            $sf_php_excel->getActiveSheet()->setCellValue('A1', wpConfig::getName());
+
+            $address = explode("\n", str_replace("\r", '', wpConfig::getAddress()));
+            $sf_php_excel->getActiveSheet()->mergeCells('A2:B2');
+            $sf_php_excel->getActiveSheet()->setCellValue('A2', !empty($address[0])?$address[0]:'');
+            $sf_php_excel->getActiveSheet()->mergeCells('A3:B3');
+            $sf_php_excel->getActiveSheet()->setCellValue('A3', !empty($address[1])?$address[1]:'');
+
+            $sf_php_excel->getActiveSheet()->mergeCells('A4:B4');
+            $sf_php_excel->getActiveSheet()->setCellValue('A4', sprintf('Tél : %s - %s', wpConfig::getPhone(), wpConfig::getEmail()));
+
+            $sf_php_excel->getActiveSheet()->setCellValue('C3', 'Date');
+            $sf_php_excel->getActiveSheet()->getStyle('C3')->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('D3', PHPExcel_Shared_Date::PHPToExcel(time()));
+            $sf_php_excel->getActiveSheet()->getStyle('D3')->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_DATE_DDMMYYYY);
+            $sf_php_excel->getActiveSheet()->getStyle('D3')->applyFromArray($style_border);
+            $sf_php_excel->getActiveSheet()->setCellValue('C4', 'Remise N°');
+            $sf_php_excel->getActiveSheet()->getStyle('C4')->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('D4', $number);
+            $sf_php_excel->getActiveSheet()->getStyle('D4')->applyFromArray($style_border);
+            $sf_php_excel->getActiveSheet()->setCellValue('C5', 'Signature');
+            $sf_php_excel->getActiveSheet()->getStyle('C5')->applyFromArray($style_header);
+
+            $sf_php_excel->getActiveSheet()->setCellValue('A10', 'N° CHEQUE');
+            $sf_php_excel->getActiveSheet()->getStyle('A10')->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('B10', 'PERSONNE/SOCIETE QUI VOUS A REMIS LE CHEQUE');
+            $sf_php_excel->getActiveSheet()->getStyle('B10')->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('C10', 'BANQUE');
+            $sf_php_excel->getActiveSheet()->getStyle('C10')->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('D10', 'MONTANT');
+            $sf_php_excel->getActiveSheet()->getStyle('D10')->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->getStyle('D10')->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+
+            $index = 11;
+            foreach ($katao_member_deposits as/*(KataoMemberDeposit)*/ $katao_member_deposit) {
+                // mise à jour du numéro de remise de chèque
+                $katao_member_deposit->setCheckDeposit($number);
+                $katao_member_deposit->save();
+
+                $sf_php_excel->getActiveSheet()->setCellValue('A' . $index, $katao_member_deposit->getCheckNumber());
+                $sf_php_excel->getActiveSheet()->getStyle('A' . $index)->applyFromArray($style_border);
+                $sf_php_excel->getActiveSheet()->getStyle('A' . $index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
+                $sf_php_excel->getActiveSheet()->setCellValue('B' . $index, $katao_member_deposit->getKataoMember()->getFullName());
+                $sf_php_excel->getActiveSheet()->getStyle('B' . $index)->applyFromArray($style_border);
+                $sf_php_excel->getActiveSheet()->setCellValue('C' . $index, $katao_member_deposit->getCheckBank());
+                $sf_php_excel->getActiveSheet()->getStyle('C' . $index)->applyFromArray($style_border);
+                $sf_php_excel->getActiveSheet()->setCellValue('D' . $index, $katao_member_deposit->getAmount());
+                $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->applyFromArray($style_border);
+                $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_NUMBER_00);
+                $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+                $index++;
+            }
+
+            $index++;
+            $sf_php_excel->getActiveSheet()->setCellValue('A' . $index, 'BANQUE');
+            $sf_php_excel->getActiveSheet()->getStyle('A' . $index)->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('B' . $index, 'RIB');
+            $sf_php_excel->getActiveSheet()->getStyle('B' . $index)->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->setCellValue('C' . $index, 'NBR CHEQUES');
+            $sf_php_excel->getActiveSheet()->getStyle('C' . $index)->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->getStyle('C' . $index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+            $sf_php_excel->getActiveSheet()->setCellValue('D' . $index, 'TOTAL');
+            $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->applyFromArray($style_header);
+            $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+
+            $index++;
+            $sf_php_excel->getActiveSheet()->setCellValue('A' . $index, wpConfig::getBankName());
+            $sf_php_excel->getActiveSheet()->getStyle('A' . $index)->applyFromArray($style_border);
+            $sf_php_excel->getActiveSheet()->setCellValue('B' . $index, wpConfig::getBankAccount());
+            $sf_php_excel->getActiveSheet()->getStyle('B' . $index)->applyFromArray($style_border);
+            $sf_php_excel->getActiveSheet()->setCellValue('C' . $index, count($katao_member_deposits));
+            $sf_php_excel->getActiveSheet()->getStyle('C' . $index)->applyFromArray($style_border);
+            $sf_php_excel->getActiveSheet()->setCellValue('D' . $index, '=SUM(D11:D' . (10 + count($katao_member_deposits)) . ')');
+            $sf_php_excel->getActiveSheet()->getCell('D' . $index)->getCalculatedValue();
+            $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
+            $sf_php_excel->getActiveSheet()->getStyle('D' . $index)->applyFromArray($style_border);
+
+            $sf_php_excel->getActiveSheet()->getPageSetup()->setPaperSize(PHPExcel_Worksheet_PageSetup::PAPERSIZE_A4);
+            $sf_php_excel->getActiveSheet()->getColumnDimension('A')->setWidth(15);
+            $sf_php_excel->getActiveSheet()->getColumnDimension('B')->setWidth(41);
+            $sf_php_excel->getActiveSheet()->getColumnDimension('C')->setWidth(12);
+            $sf_php_excel->getActiveSheet()->getColumnDimension('D')->setWidth(10);
+
+            $sf_php_excel->setActiveSheetIndex(0);
+
+            $php_excel_writer = new PHPExcel_Writer_Excel5($sf_php_excel);
+            $php_excel_writer->save($file_name);
+
+            $file_content = file_get_contents($file_name);
+
+            $response = $this->getResponse();
+            $response->setContentType('application/vnd.ms-excel');
+            $response->setHttpHeader('Content-disposition', 'attachment; filename="remise-chèques-' . $number . '.xls"');
+            // $response->setHttpHeader('Content-Length', strlen($file_content));
+            $response->setHttpHeader('Pragma', 'public');
+            $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+            $response->setHttpHeader('Expires', '0');
+            $response->setContent($file_content);
+            return sfView::NONE;
+        }
+    }
+
+    public function executeTransferSol($request) {
+        $this->form = new KataoMemberDepositTransferSolForm();
+    }
+
+    public function executeTransferSolUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoMemberDepositTransferSolForm();
+
+        $parameters = $request->getParameter('katao_member_deposit');
+        $this->form->bind($parameters);
+        if ($this->form->isValid()) {
+            $valued_at = time();
+            if (!empty($parameters['valued_at']) && preg_match('|(\d{2})\/(\d{2})\/(\d{4})|si', $parameters['valued_at'], $matches)) {
+                $valued_at = mktime(12, 0, 0, (int)$matches[2], (int)$matches[1], (int)$matches[3]);
+            }
+
+            $katao_member_deposit = new KataoMemberDeposit();
+            $katao_member_deposit->setKataoMemberId($parameters['katao_member_1_id']);
+            $katao_member_deposit->setAmount(- $parameters['amount']);
+            $katao_member_deposit->setCurrency(KataoMemberDeposit::CURRENCY_SOL);
+            $katao_member_deposit->setPaymentMode(KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL);
+            $katao_member_deposit->setStatus(KataoMemberDeposit::STATUS_VALIDATED);
+            $katao_member_deposit->setValuedAt($valued_at);
+            $katao_member_deposit->save();
+
+            $katao_member_deposit = new KataoMemberDeposit();
+            $katao_member_deposit->setKataoMemberId($parameters['katao_member_2_id']);
+            $katao_member_deposit->setAmount($parameters['amount']);
+            $katao_member_deposit->setCurrency(KataoMemberDeposit::CURRENCY_SOL);
+            $katao_member_deposit->setPaymentMode(KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL);
+            $katao_member_deposit->setStatus(KataoMemberDeposit::STATUS_VALIDATED);
+            $katao_member_deposit->setValuedAt($valued_at);
+            $katao_member_deposit->save();
+
+            wpFlashMessages::addConfirmation('Transfert de ' . wpConfig::getAdditionalCurrencyName() . ' effectué avec succès.');
+            $this->redirect('kataoMemberDeposit/index');
+        }
+
+        $this->setTemplate('transferSol');
+    }
+}

+ 33 - 0
apps/admin/modules/kataoMemberDeposit/config/security.yml

@@ -0,0 +1,33 @@
+create:
+  is_secure: on
+  credentials: admin
+edit:
+  is_secure: on
+  credentials: admin
+update:
+  is_secure: on
+  credentials: admin
+delete:
+  is_secure: on
+  credentials: admin
+deleteMultiple:
+  is_secure: on
+  credentials: admin
+dispatchSols:
+  is_secure: on
+  credentials: admin
+dispatchSolsUpdate:
+  is_secure: on
+  credentials: admin
+printChecks:
+  is_secure: on
+  credentials: admin
+transfer:
+  is_secure: on
+  credentials: [[ admin, delegate ]]
+transferUpdate:
+  is_secure: on
+  credentials: [[ admin, delegate ]]
+default:
+  is_secure: on
+  credentials: [[ admin, seo, delegate ]]

+ 51 - 0
apps/admin/modules/kataoMemberDeposit/templates/dispatchSolsSuccess.php

@@ -0,0 +1,51 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Répartir des <?php echo wpConfig::getAdditionalCurrencyName() ?></h1></div>
+</div>
+
+<?php use_helper('Validation') ?>
+
+<form action="<?php echo url_for('@katao_member_deposit_dispatch_sols_update') ?>" method="post">
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMemberDeposit/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <th align="left"><?php echo label_for('amount', 'Montant') ?></th>
+        <td>
+        	<?php echo input_tag('amount', $sf_request->getParameter('amount')) ?>
+        	<?php echo form_error('amount') ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left" rowspan="3"><label>Bénéficiaire(s)</label></th>
+        <td>
+        	<?php echo radiobutton_tag('type', 'member', 'member' == $sf_request->getParameter('type')) ?>
+        	<?php echo label_for('type_member', 'L\'adhérent : ') ?>
+        	<?php echo select_tag('member', options_for_select(KataoMemberPeer::getAllGroupedByNode(), false, array('include_custom' => '&mdash;&nbsp;choisir&nbsp;&mdash;')), array('onchange' => '$("type_member").checked = true; $("node").value = "";')) ?>
+        	<?php echo form_error('member') ?>
+		</td>
+      </tr>
+      <tr valign="top">
+        <td>
+        	<?php echo radiobutton_tag('type', 'node', 'node' == $sf_request->getParameter('type')) ?>
+        	<?php echo label_for('type_node', 'Tous les adhérents du noeud : ') ?>
+        	<?php echo select_tag('node', options_for_select(KataoNodePeer::getAllArray(), false, array('include_custom' => '&mdash;&nbsp;choisir&nbsp;&mdash;')), array('onchange' => '$("type_node").checked = true; $("member").value = "";')) ?>
+        	<?php echo form_error('node') ?>
+		</td>
+      </tr>
+      <tr valign="top">
+        <td>
+        	<?php echo radiobutton_tag('type', 'all', 'all' == $sf_request->getParameter('type'), array('onclick' => '$("member").value = ""; $("node").value = "";')) ?>
+        	<?php echo label_for('type_all', 'Tous les adhérents du réseau') ?>
+        	<?php echo form_error('all') ?>
+        	<?php echo form_error('type') ?>
+		</td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 105 - 0
apps/admin/modules/kataoMemberDeposit/templates/editSuccess.php

@@ -0,0 +1,105 @@
+<?php $katao_member_deposit = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_member_deposit->isNew() ? 'Ajout' : 'Modification' ?> d'un dépôt</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoMemberDeposit/update' . (!$katao_member_deposit->isNew() ? '?id=' . $katao_member_deposit->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMemberDeposit/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_member_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_member_id'] ?>
+		  <?php echo $form['katao_member_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['amount']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['amount'] ?> <?php echo $form['currency'] ?>
+		  <?php echo $form['amount']->renderError() ?>
+		  <?php echo $form['currency']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['comment']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['comment'] ?>
+		  <?php echo $form['comment']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['payment_mode']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['payment_mode'] ?>
+		  <?php echo $form['payment_mode']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top" id="check_number_row"<?php echo (KataoMemberDeposit::PAYMENT_MODE_CHECK != $katao_member_deposit->getPaymentMode())?' style="display: none"':''?>>
+        <th align="left"><?php echo $form['check_number']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['check_number'] ?>
+		  <?php echo $form['check_number']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top" id="check_bank_row"<?php echo (KataoMemberDeposit::PAYMENT_MODE_CHECK != $katao_member_deposit->getPaymentMode())?' style="display: none"':''?>>
+        <th align="left"><?php echo $form['check_bank']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['check_bank'] ?>
+		  <?php echo $form['check_bank']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['status']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['status'] ?>
+		  <?php echo $form['status']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top" id="valid_until_row"<?php echo (KataoMemberDeposit::STATUS_PENDING != $katao_member_deposit->getStatus())?' style="display: none"':''?>>
+        <th align="left"><?php echo $form['valid_until']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['valid_until'] ?>
+		  <?php echo $form['valid_until']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function togglePaymentModeDetails(){
+	if(<?php echo KataoMemberDeposit::PAYMENT_MODE_CHECK ?> == $('katao_member_deposit_payment_mode').value) {
+		$('check_number_row').show();
+		$('check_bank_row').show();
+	} else {
+		$('check_number_row').hide();
+		$('katao_member_deposit_check_number').value = "";
+		$('check_bank_row').hide();
+		$('katao_member_deposit_check_bank').value = "";
+	}
+}
+
+function toggleStatusDetails(){
+	if(<?php echo KataoMemberDeposit::STATUS_PENDING ?> == $('katao_member_deposit_status').value) {
+		$('valid_until_row').show();
+	} else {
+		$('valid_until_row').hide();
+		$('katao_member_deposit_valid_until').value = "";
+	}
+}
+
+/* ]]> */
+</script>

+ 68 - 0
apps/admin/modules/kataoMemberDeposit/templates/indexSuccess.php

@@ -0,0 +1,68 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des dépôts (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_member_deposit_filter') ?>
+			<?php echo select_tag('filter_member', options_for_select(KataoMemberPeer::getAllGroupedByNode(), $filter_member, array('include_custom' => '&mdash;&nbsp;Adhérent&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_currency', options_for_select(KataoMemberDepositPeer::getAllCurrencies(), $filter_currency, array('include_custom' => '&mdash;&nbsp;Monnaie&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_payment_mode', options_for_select(KataoMemberDepositPeer::getAllPaymentModes(true), $filter_payment_mode, array('include_custom' => '&mdash;&nbsp;Règlement&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_status', options_for_select(KataoMemberDepositPeer::getAllStatuses(), $filter_status, array('include_custom' => '&mdash;&nbsp;Etat&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_member_deposit_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_member_depositList)): ?>
+	<p>Aucun dépôt.</p>
+	  <?php if ($sf_user->hasCredential('admin')): ?>
+	<p>
+		<?php echo link_to('Ajouter un dépôt', '@katao_member_deposit_add', array('class' => 'add')) ?>
+	<?php if (!$sf_user->isJustDelegate()): ?>
+		<?php echo link_to('Répartir des ' . wpConfig::getAdditionalCurrencyName(), '@katao_member_deposit_dispatch_sols', array('class' => 'dispatch')) ?>
+	<?php endif ?>
+	</p>
+	  <?php endif ?>
+<?php else : ?>
+	<?php if ($sf_user->hasCredential('admin')): ?>
+  <?php echo link_to('Ajouter un dépôt', '@katao_member_deposit_add', array('class' => 'add')) ?>
+  <?php if (!$sf_user->isJustDelegate()): ?>
+  	<?php echo link_to('Répartir des ' . wpConfig::getAdditionalCurrencyName(), '@katao_member_deposit_dispatch_sols', array('class' => 'dispatch')) ?>
+  <?php endif ?>
+  <?php echo link_to('Imprimer la remise de chèques (' . multiple_action_info_selected('katao_member_deposit') . ')', '@katao_member_deposit_print_checks', array('class' => 'print')) ?>
+  <?php echo link_to('Supprimer les dépôts sélectionnés (' . multiple_action_info_selected('katao_member_deposit') . ')', '@katao_member_deposit_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les dépôts sélectionnés ?')) ?>
+    <?php endif ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_member_deposit') ?></th>
+	  <th nowrap="nowrap">Date <?php echo sort_links($sf_request, 'date', 'kataoMemberDeposit/index') ?></th>
+	  <th nowrap="nowrap">Adhérent <?php echo sort_links($sf_request, 'member', 'kataoMemberDeposit/index') ?></th>
+	  <th nowrap="nowrap">Montant <?php echo sort_links($sf_request, 'amount', 'kataoMemberDeposit/index') ?></th>
+	  <th nowrap="nowrap">Etat <?php echo sort_links($sf_request, 'status', 'kataoMemberDeposit/index') ?></th>
+	  <th nowrap="nowrap">Règlement <?php echo sort_links($sf_request, 'payment-mode', 'kataoMemberDeposit/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_member_depositList as/*(KataoMemberDeposit)*/ $katao_member_deposit): ?>
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_member_deposit', $katao_member_deposit->getId()) ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member_deposit->getValuedAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member_deposit->getMemberName() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member_deposit->getAmountStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member_deposit->getStatusStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_member_deposit->getPaymentModeStr() ?></td>
+		  <td nowrap="nowrap">
+		  <?php if ($sf_user->hasCredential('admin')): ?>
+		  	<?php if (KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL != $katao_member_deposit->getPaymentMode()): ?>
+	    	<?php echo catalyz_link_to_image_tag('@katao_member_deposit_edit?id=' . $katao_member_deposit->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+	    	<?php endif ?>
+			<?php echo catalyz_link_to_image_tag('@katao_member_deposit_delete?id=' . $katao_member_deposit->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer ce dépôt ?'), array('alt' => 'Supprimer')) ?>
+	  	  <?php endif ?>
+		  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoMemberDeposit/index?sort=%s%s', $sf_request->getParameter('sort', 'date'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_member_deposit') ?>
+<?php endif ?>

+ 23 - 0
apps/admin/modules/kataoMemberDeposit/templates/printChecksSuccess.php

@@ -0,0 +1,23 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Imprimer une remise de chèques</h1></div>
+</div>
+
+<form action="<?php echo url_for('@katao_member_deposit_print_checks') ?>" method="post" onsubmit="if(''==$F('number')){alert('Merci de saisir le N° de remise');$('number').focus();return false;}">
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Imprimer" /> ou <a href="<?php echo url_for('kataoMemberDeposit/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <th align="left"><?php echo label_for('number', 'N° de remise') ?></th>
+        <td>
+        	<?php echo input_tag('number') ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 58 - 0
apps/admin/modules/kataoMemberDeposit/templates/showSuccess.php

@@ -0,0 +1,58 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Dépôt : <?php echo $katao_member_deposit->getMemberName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_member_deposit->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao member:</th>
+      <td><?php echo $katao_member_deposit->getKataoMemberId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Amount:</th>
+      <td><?php echo $katao_member_deposit->getAmount() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Comment:</th>
+      <td><?php echo $katao_member_deposit->getComment() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Payment mode:</th>
+      <td><?php echo $katao_member_deposit->getPaymentMode() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Check number:</th>
+      <td><?php echo $katao_member_deposit->getCheckNumber() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Check bank:</th>
+      <td><?php echo $katao_member_deposit->getCheckBank() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Status:</th>
+      <td><?php echo $katao_member_deposit->getStatus() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Valid until:</th>
+      <td><?php echo $katao_member_deposit->getValidUntil() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_member_deposit->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_member_deposit->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoMemberDeposit/edit?id='.$katao_member_deposit->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoMemberDeposit/index') ?>">List</a>

+ 48 - 0
apps/admin/modules/kataoMemberDeposit/templates/transferSolSuccess.php

@@ -0,0 +1,48 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Transfert en <?php echo wpConfig::getAdditionalCurrencyName() ?></h1></div>
+</div>
+
+<?php use_helper('Validation') ?>
+
+<form action="<?php echo url_for('kataoMemberDeposit/transferSolUpdate') ?>" method="post">
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="8">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMemberDeposit/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['amount']->renderLabel() ?></th>
+        <td>
+        	<?php echo $form['amount'] ?> <?php echo wpConfig::getAdditionalCurrencyName() ?>
+        	<?php echo $form['amount']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_member_1_id']->renderLabel() ?></th>
+        <td>
+        	<?php echo $form['katao_member_1_id'] ?>
+        	<?php echo $form['katao_member_1_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_member_2_id']->renderLabel() ?></th>
+        <td>
+        	<?php echo $form['katao_member_2_id'] ?>
+        	<?php echo $form['katao_member_2_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['valued_at']->renderLabel() ?></th>
+        <td>
+        	<?php echo $form['valued_at'] ?>
+        	<?php echo $form['valued_at']->renderError() ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 65 - 0
apps/admin/modules/kataoMemberGroup/actions/actions.class.php

@@ -0,0 +1,65 @@
+<?php
+
+/**
+ * kataoMemberGroup actions.
+ *
+ * @package    www.katao.fr
+ * @subpackage kataoMemberGroup
+ * @author     Your name here
+ * @version    SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoMemberGroupActions extends sfActions
+{
+  public function executeIndex()
+  {
+    $this->katao_member_groupList = KataoMemberGroupPeer::doSelect(new Criteria());
+  }
+
+  public function executeShow($request)
+  {
+    $this->katao_member_group = KataoMemberGroupPeer::retrieveByPk($request->getParameter('katao_member_group_id'));
+    $this->forward404Unless($this->katao_member_group);
+  }
+
+  public function executeCreate()
+  {
+    $this->form = new KataoMemberGroupForm();
+
+  	$this->setTemplate('edit');
+  }
+
+  public function executeEdit($request)
+  {
+    $this->katao_member_group = KataoMemberGroupPeer::retrieveByPk($request->getParameter('id'));
+    $this->form = new KataoMemberGroupForm(KataoMemberGroupPeer::retrieveByPk($request->getParameter('id')));
+  }
+
+  public function executeUpdate($request)
+  {
+    $this->forward404Unless($request->isMethod('post'));
+
+    $this->form = new KataoMemberGroupForm(KataoMemberGroupPeer::retrieveByPk($request->getParameter('katao_member_group_id')));
+
+    $this->form->bind($request->getParameter('katao_member_group'));
+
+    if ($this->form->isValid())
+    {
+      $katao_member_group = $this->form->save();
+
+      wpFlashMessages::addConfirmation('Groupe "' . $katao_member_group->getKataoMemberGroupName() . '" sauvé avec succès.');
+
+      $this->redirect('kataoMemberGroup/index');
+    }
+
+    $this->setTemplate('edit');
+  }
+
+  public function executeDelete($request)
+  {
+    $this->forward404Unless($katao_member_group = KataoMemberGroupPeer::retrieveByPk($request->getParameter('id')));
+
+    $katao_member_group->delete();
+
+    $this->redirect('kataoMemberGroup/index');
+  }
+}

+ 26 - 0
apps/admin/modules/kataoMemberGroup/templates/editSuccess.php

@@ -0,0 +1,26 @@
+<?php $katao_member_group = $form->getObject() ?>
+<div class="content-add01">
+  <div class="heading01"><h1><?php echo $katao_member_group->isNew() ? 'Ajout' : 'Modification' ?> d'un groupe</h1></div>
+</div>
+
+<?php if ($sf_user->hasFlash('notice')):?>
+  <?php echo $sf_user->getFlash('notice') ?>
+<?php endif; ?>
+
+<form action="<?php echo url_for('kataoMemberGroup/update'.(!$katao_member_group->isNew() ? '?katao_member_group_id='.$katao_member_group->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <?php if (!$katao_member_group->isNew()): ?>
+            &nbsp;
+          <?php endif; ?>
+          <input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoMemberGroup/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form ?>
+    </tbody>
+  </table>
+</form>

+ 26 - 0
apps/admin/modules/kataoMemberGroup/templates/indexSuccess.php

@@ -0,0 +1,26 @@
+<div class="content-add01">
+  <div class="heading01"><h1>Gestion des utilisateurs</h1></div>
+</div>
+
+<p><?php echo link_to('Ajouter un groupe', '@katao_member_group_create', array('class' => 'add')) ?></p>
+<table class="admin-list">
+  <thead>
+    <tr>
+      <th>Nom</th>
+      <th>Action</th>
+    </tr>
+  </thead>
+  <tbody>
+    <?php foreach ($katao_member_groupList as $katao_member_group): ?>
+    <tr>
+      <td><?php echo $katao_member_group->getKataoMemberGroupName() ?></td>
+      <td nowrap="nowrap" width="1%">
+        <?php echo catalyz_link_to_image_tag('@katao_member_group_edit?id='.$katao_member_group->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+        <?php if ($katao_member_group->isDeletable()): ?>
+     		<?php echo catalyz_link_to_image_tag('@katao_member_group_delete?id=' . $katao_member_group->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer ce groupe ?'), array('alt' => 'Supprimer')) ?>
+		<?php endif ?>
+		</td>
+	</tr>
+    <?php endforeach; ?>
+  </tbody>
+</table>

+ 22 - 0
apps/admin/modules/kataoMemberGroup/templates/showSuccess.php

@@ -0,0 +1,22 @@
+<div class="content-add01">
+  <div class="heading01"><h1>Groupe <?php echo $katao_member_group->getKataoMemberGroupName() ?></h1></div>
+</div>
+
+<table class="admin-list">
+  <tbody>
+    <tr>
+      <th>Id:</th>
+      <td><?php echo $katao_member_group->getId() ?></td>
+    </tr>
+    <tr>
+      <th>Nom du groupe:</th>
+      <td><?php echo $katao_member_group->getKataoMemberGroupName() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoMemberGroup/edit?katao_member_group_id='.$katao_member_group->getId()) ?>">modifier</a>
+&nbsp;
+<a href="<?php echo url_for('kataoMemberGroup/index') ?>">annuler</a>

+ 133 - 0
apps/admin/modules/kataoNode/actions/actions.class.php

@@ -0,0 +1,133 @@
+<?php
+
+/**
+ * kataoNode actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoNode
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoNodeActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoNodePeer::RESPONSIBLE, KataoUserPeer::ID);
+        $criteria->addJoin(KataoUserPeer::KATAO_MEMBER_ID, KataoMemberPeer::ID);
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'city')) {
+            case 'delegate':
+                $criteria->$sort_method(KataoMemberPeer::LAST_NAME);
+                $criteria->$sort_method(KataoMemberPeer::FIRST_NAME);
+                break;
+            case 'date':
+                $criteria->$sort_method(KataoNodePeer::BEGIN_AT);
+                break;
+            default:
+                $criteria->$sort_method(KataoNodePeer::CITY);
+        }
+
+        $pager = new sfPropelPager('KataoNode', sfConfig::get('app_pager'));
+        $pager->setPeerMethod('doSelectJoinKataoUser');
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_nodeList = $pager->getResults();
+
+        $this->managed_node_ids = $this->getUser()->getInstance()->getManagedNodeIds();
+    }
+
+    public function executeShow($request) {
+        $this->katao_node = KataoNodePeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_node, 'Noeud #' . $request->getParameter('id') . ' inconnu.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoNodeForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $this->form = new KataoNodeForm(KataoNodePeer::retrieveByPk($request->getParameter('id')));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoNodeForm(KataoNodePeer::retrieveByPk($request->getParameter('id')));
+
+        $this->form->bind($request->getParameter('katao_node'));
+        if ($this->form->isValid()) {
+            $katao_node = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Noeud "' . $katao_node->getCity() . '" sauvé avec succès.');
+            $this->redirect('kataoNode/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_node = KataoNodePeer::retrieveByPk($request->getParameter('id')), 'Noeud #' . $request->getParameter('id') . ' inconnu.');
+        $this->redirectWithErrorIf(!$katao_node->isDeletable() || $katao_node->getIsDefault());
+
+        $katao_node->delete();
+
+        wpFlashMessages::addConfirmation('Noeud "' . $katao_node->getCity() . '" supprimé avec succès.');
+        $this->redirect('kataoNode/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_node')) {
+            foreach (KataoNodePeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_node'))) as/*(KataoNode)*/ $katao_node) {
+                if ($katao_node->isDeletable() && !$katao_node->getIsDefault()) {
+                    $katao_node->delete();
+                }
+            }
+
+            wpPersistenceManager::cleanSelection('katao_node');
+            wpFlashMessages::addConfirmation('Les noeuds sélectionnés ont été supprimés avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un noeud.');
+        }
+
+        $this->redirect('kataoNode/index');
+    }
+
+    public function executeManageProducts($request) {
+        $this->katao_node = KataoNodePeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_node, 'Noeud #' . $request->getParameter('id') . ' inconnu.');
+
+        $managed_node_ids = $this->getUser()->getInstance()->getManagedNodeIds();
+        $this->redirectWithErrorIf(empty($managed_node_ids[$this->katao_node->getId()]));
+    }
+
+    public function executeManageProductsByPeriod($request) {
+        $this->katao_node = KataoNodePeer::retrieveByPk($request->getParameter('node'));
+        $this->redirectWithErrorUnless($this->katao_node, 'Noeud #' . $request->getParameter('node') . ' inconnu.');
+
+        $managed_node_ids = $this->getUser()->getInstance()->getManagedNodeIds();
+        $this->redirectWithErrorIf(empty($managed_node_ids[$this->katao_node->getId()]));
+
+        $this->katao_period = KataoPeriodPeer::retrieveByPk($request->getParameter('period'));
+        $this->redirectWithErrorUnless($this->katao_period, 'Période #' . $request->getParameter('period') . ' inconnue.');
+
+        if ($request->isMethod('post')) {
+            $this->katao_node->updateAvailableProducts($this->katao_period->getId(), !empty($_POST['suppliers_with_all_products'])?$_POST['suppliers_with_all_products']:'', !empty($_POST['products'])?$_POST['products']:array());
+
+            wpFlashMessages::addConfirmation('Gestion des produits pour le noeud "' . $this->katao_node->getCity() . '" et pour la période "' . $this->katao_period->getName() . '" effectuée avec succès.');
+            wpFlashMessages::addWarning('Attention : si vous avez enlevé des produits, merci de bien vouloir prévenir les adhérents qui auraient pu voir ces produits.');
+            return $this->redirect('@katao_node_manage_products?id=' . $this->katao_node->getId());
+        }
+
+        $this->katao_suppliers = KataoSupplierPeer::getAllToSortArray($this->katao_period->getId(), $this->katao_node->getId());
+        $this->products = KataoProductPeer::getSelectedProducts(array_keys($this->katao_suppliers['some_product']), $this->katao_period->getId(), $this->katao_node->getId());
+    }
+
+    public function executeRefreshProducts($request) {
+        return $this->renderText('(' . Utils::array_to_json_string(KataoProductPeer::getSelectedProducts(explode(',', $request->getParameter('suppliers_ids')), $request->getParameter('period'), $request->getParameter('node'))) . ')');
+    }
+}

+ 8 - 0
apps/admin/modules/kataoNode/config/security.yml

@@ -0,0 +1,8 @@
+index:
+  credentials: [[ admin, seo, delegate ]]
+manageProducts:
+  credentials: [[ admin, seo, delegate ]]
+manageProductsByPeriod:
+  credentials: [[ admin, seo, delegate ]]
+all:
+  credentials: [[ admin, seo ]]

+ 42 - 0
apps/admin/modules/kataoNode/templates/editSuccess.php

@@ -0,0 +1,42 @@
+<?php $katao_node = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_node->isNew() ? 'Ajout' : 'Modification' ?> d'un noeud</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoNode/update'.(!$katao_node->isNew() ? '?id='.$katao_node->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoNode/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['city']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['city'] ?>
+		  <?php echo $form['city']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['responsible']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['responsible'] ?>
+		  <?php echo $form['responsible']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['begin_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['begin_at'] ?>
+		  <?php echo $form['begin_at']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 48 - 0
apps/admin/modules/kataoNode/templates/indexSuccess.php

@@ -0,0 +1,48 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des noeuds (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<?php $is_admin_or_seo = $sf_user->hasCredential(array('admin', 'seo'), false) ?>
+
+<?php if (empty($katao_nodeList)): ?>
+	<p>Aucun noeud.</p>
+	<p><?php echo link_to('Ajouter un noeud', '@katao_node_add', array('class' => 'add')) ?></p>
+<?php else : ?>
+  <?php if ($is_admin_or_seo): ?>
+  	<?php echo link_to('Ajouter un noeud', '@katao_node_add', array('class' => 'add')) ?>
+  	<?php echo link_to('Supprimer les noeuds sélectionnés (' . multiple_action_info_selected('katao_node') . ')', '@katao_node_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les noeuds sélectionnés ?')) ?>
+  <?php endif ?>
+  <table class="admin-list">
+    <tr>
+    <?php if ($is_admin_or_seo): ?>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_node') ?></th>
+	<?php endif ?>
+	  <th nowrap="nowrap">Ville <?php echo sort_links($sf_request, 'city', 'kataoNode/index') ?></th>
+	  <th nowrap="nowrap">Délégué <?php echo sort_links($sf_request, 'delegate', 'kataoNode/index') ?></th>
+	  <th nowrap="nowrap">Date de début <?php echo sort_links($sf_request, 'date', 'kataoNode/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_nodeList as/*(KataoNode)*/ $katao_node): ?>
+    <tr valign="top" class="line">
+    	<?php if ($is_admin_or_seo): ?>
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_node', $katao_node->getId()) ?></td>
+		<?php endif ?>
+		  <td nowrap="nowrap"><?php echo $katao_node->getCity() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_node->getResponsibleLink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_node->getBeginAtStr() ?></td>
+		  <td nowrap="nowrap">
+	<?php if (!empty($managed_node_ids[$katao_node->getId()])): ?>
+	    <?php echo catalyz_link_to_image_tag('@katao_node_manage_products?id=' . $katao_node->getId(), 'actions/products.png', array('title' => 'Gérer les produits par période'), array('alt' => 'Gérer les produits par période')) ?>
+	<?php endif ?>
+	<?php if ($is_admin_or_seo): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_node_edit?id=' . $katao_node->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+	    <?php if (!$katao_node->getIsDefault() && $katao_node->isDeletable()): ?>
+	    	<?php echo catalyz_link_to_image_tag('@katao_node_delete?id=' . $katao_node->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer ce noeud ?'), array('alt' => 'Supprimer')) ?>
+	    <?php endif ?>
+	<?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoNode/index?sort=%s%s', $sf_request->getParameter('sort', 'city'), $sf_request->hasParameter('desc')?'&desc=on':''), $is_admin_or_seo?'katao_node':'') ?>
+<?php endif ?>

+ 240 - 0
apps/admin/modules/kataoNode/templates/manageProductsByPeriodSuccess.php

@@ -0,0 +1,240 @@
+<?php use_javascript('dd/coordinates.js') ?>
+<?php use_javascript('dd/drag.js') ?>
+<?php use_javascript('dd/dragdrop.js') ?>
+<?php use_stylesheet('dd/lists.css') ?>
+
+<div class="content-add01">
+	<div class="heading01"><h1>Gestions des produits : noeud <?php echo $katao_node->getCity() ?>, période <?php echo $katao_period->getName() ?></h1></div>
+</div>
+
+<?php echo form_tag('@katao_node_manage_products_by_period?node=' . $katao_node->getId() . '&period=' . $katao_period->getId()) ?>
+
+<p>
+	Faites glisser les fournisseurs disponibles dans les listes suivantes :
+	<ul>
+		<li><u>Tous les produits</u> si vous souhaitez activer tous les produits</li>
+		<li><u>Certains produits</u> si vous ne souhaitez activer que certains produits</li>
+	</ul>
+</p>
+
+<?php echo input_hidden_tag('node', $katao_node->getId()) ?>
+<?php echo input_hidden_tag('period', $katao_period->getId()) ?>
+<?php echo input_hidden_tag('suppliers_with_all_products', '') ?>
+
+<table cellpadding="0" border="0">
+<tr valign="top">
+	<td rowspan="3">
+		<div class="section-title-filter4"><b>Fournisseurs :</b></div>
+		<div class="section-container-filter4">
+			<ul id="left_col" class="sortable boxy" style="min-height: 250px">
+			<?php foreach ($katao_suppliers['not_select'] as $id => $name): ?>
+				<li id="supplier-<?php echo $id ?>" onmouseup="refreshProducts(this)"><?php echo $name ?></li>
+			<?php endforeach ?>
+			</ul>
+		</div>
+	</td>
+	<td>&nbsp;&nbsp;</td>
+	<td>
+		<table cellpadding="0" border="0">
+		<tr valign="top">
+			<td>
+				<div class="section-title-filter4"><b>Tous les produits :</b></div>
+				<div class="section-container-filter4">
+					<ul id="middle_col" class="sortable boxy boxy-large" style="min-height: 150px">
+					<?php foreach ($katao_suppliers['all_product'] as $id => $name): ?>
+						<li id="all-products-<?php echo $id ?>" onmouseup="refreshProducts(this)"><?php echo $name ?></li>
+					<?php endforeach ?>
+					</ul>
+				</div>
+			</td>
+		</tr>
+		<tr><td>&nbsp;</td></tr>
+		<tr valign="top">
+			<td>
+				<div class="section-title-filter4"><b>Certains produits :</b> <em>(choisir dans la liste ci-dessous)</em></div>
+				<div class="section-container-filter4">
+					<ul id="right_col" class="sortable boxy boxy-large" style="min-height: 150px">
+					<?php foreach ($katao_suppliers['some_product'] as $id => $name): ?>
+						<li id="products-<?php echo $id ?>" onmouseup="refreshProducts(this)"><?php echo $name ?></li>
+					<?php endforeach ?>
+					</ul>
+				</div>
+			</td>
+		</tr>
+		<tr valign="top">
+			<td>
+				<b>Produits sélectionnés :</b>
+			</td>
+		</tr>
+		<tr valign="top">
+			<td id="dynamic_product">
+				<?php echo select_tag('products', options_for_select($products['list'], $products['selected']), array('multiple' => 'multiple', 'style' => 'width:365px;')) ?>
+			</td>
+		</tr>
+		</table>
+	</td>
+</tr>
+</table>
+
+<br />
+<?php echo submit_tag('Sauver', array('onclick' => 'getSort();')) ?> ou <a href="<?php echo url_for('@katao_node_manage_products?id=' . $katao_node->getId()) ?>">annuler</a>
+
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+all_supplier = new Array();
+<?php foreach($katao_suppliers['all'] as $name) : ?>
+all_supplier.push('<?php echo str_replace('\'', '\\\'', $name) ?>');
+<?php endforeach ?>
+
+function in_array(needle, haystack, argStrict) {
+    // http://kevin.vanzonneveld.net
+
+    var key = '', strict = !!argStrict;
+
+    if (strict) {
+        for (key in haystack) {
+            if (haystack[key] === needle) {
+                return true;
+            }
+        }
+    } else {
+        for (key in haystack) {
+            if (haystack[key] == needle) {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
+window.onload = function() {
+	list = document.getElementById("left_col");
+	DragDrop.makeListContainer( list, 'g1' );
+	list.onDragOver = function() { this.style["background"] = "#eff3fc"; };
+	list.onDragOut = function() {this.style["background"] = "none"; };
+
+	list = document.getElementById("middle_col");
+	DragDrop.makeListContainer( list, 'g1' );
+	list.onDragOver = function() { this.style["background"] = "#eff3fc"; };
+	list.onDragOut = function() {this.style["background"] = "none"; };
+
+	list = document.getElementById("right_col");
+	DragDrop.makeListContainer( list, 'g1' );
+	list.onDragOver = function() { this.style["background"] = "#eff3fc"; };
+	list.onDragOut = function() {this.style["background"] = "none"; };
+};
+
+function getSort() {
+	$("suppliers_with_all_products").value = DragDrop.serData('g1', null);
+}
+
+function showValue() {
+	suppliers_with_all_products = document.getElementById("suppliers_with_all_products");
+	alert(suppliers_with_all_products.value);
+}
+
+function refreshProducts(element){
+	var parent = element.parentNode; //right_col
+	var supplier_id = element.id;
+	var childs = parent.childNodes;
+	var period_id = $('period');
+	var node_id = $('node');
+	var params = new Array();
+	if (parent.id == 'right_col') {
+		for(var i = 0; i < childs.length; i++){
+			if ('LI' == childs[i].nodeName) {
+				var supplier_id = childs[i].id;
+				supplier_id = supplier_id.substr(13, supplier_id.length - 13);
+				params.push(supplier_id);
+			}
+		}
+		var tidyParams = params.join(',');
+		var url = '<?php echo url_for('kataoNode/refreshProducts') ?>';
+		var myAjax = new Ajax.Request(
+		    url,
+		    {
+		      method: 'get',
+			  parameters: {
+			  			 suppliers_ids:tidyParams,
+						 period:period_id.value,
+						 node:node_id.value
+			  },
+
+		      onSuccess: manageResponse
+		    });
+	}
+	if (parent.id == 'middle_col' || parent.id == 'left_col') {
+		var right_col = $('right_col');
+		var childs_right_col = right_col.childNodes;
+		for(var i = 0; i < childs_right_col.length; i++){
+			if ('LI' == childs_right_col[i].nodeName) {
+				var supplier_id = childs_right_col[i].id;
+				supplier_id = supplier_id.substr(9, supplier_id.length - 9);
+				params.push(supplier_id)
+			}
+		}
+		var tidyParams = params.join(',');
+		var url = '<?php echo url_for('kataoNode/refreshProducts') ?>';
+		var myAjax = new Ajax.Request(
+		    url,
+		    {
+		      method: 'get',
+			  parameters: {
+			  			 suppliers_ids:tidyParams,
+						 period:period_id.value,
+						 node:node_id.value
+			  },
+
+		      onSuccess: manageResponse
+		    });
+	}
+}
+
+function manageResponse(xhr){
+	var products = xhr.responseText.evalJSON();
+	var mySelect = '<select name="products[]" id="products" multiple="multiple" style="width:365px;">';
+	var optSelect = new Array();
+	products.selected.each(
+	    function (result)
+	    {
+			optSelect = Object.values(result);
+		});
+	products.list.each(
+        function (supplier)
+        {
+			//console.log(products.selected);
+            for(var i = 0; i < all_supplier.length; i++){
+				var product_list = eval('supplier["' + all_supplier[i] + '"]');
+				if (product_list != undefined) {
+				    mySelect += '<optgroup label="'+all_supplier[i]+'">';
+					product_list.each(
+					function (opt_list)
+        			{
+						var opt_names = Object.values(opt_list);
+						var opt_ids = Object.keys(opt_list);
+						for(var i = 0; i < opt_ids.length; i++){
+							// mySelect += '<option value="'+opt_ids[i]+'">'+opt_names[i]+'</option>';
+							if (in_array(opt_ids[i],optSelect)) {
+								mySelect += '<option value="'+opt_ids[i]+'" selected="selected">'+opt_names[i]+'</option>';
+							}else{
+								mySelect += '<option value="'+opt_ids[i]+'">'+opt_names[i]+'</option>';
+							}
+						}
+					});
+					mySelect += '</optgroup>';
+				}
+			}
+        });
+	mySelect += '</select>';
+	$('dynamic_product').update();
+	$('dynamic_product').innerHTML
+	$('dynamic_product').update(mySelect);
+	$('dynamic_product').innerHTML
+}
+
+/* ]]> */
+</script>

+ 9 - 0
apps/admin/modules/kataoNode/templates/manageProductsSuccess.php

@@ -0,0 +1,9 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Gestions des produits : noeud <?php echo $katao_node->getCity() ?></h1></div>
+</div>
+
+<ul>
+<?php foreach (KataoPeriodPeer::getAllActiveWithoutCart($katao_node->getId()) as $katao_period_id => $katao_period_name): ?>
+	<li><?php echo link_to($katao_period_name, '@katao_node_manage_products_by_period?node=' . $katao_node->getId() . '&period=' . $katao_period_id) ?></li>
+<?php endforeach ?>
+</ul>

+ 38 - 0
apps/admin/modules/kataoNode/templates/showSuccess.php

@@ -0,0 +1,38 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Noeud : <?php echo $katao_node->getCity() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_node->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>City:</th>
+      <td><?php echo $katao_node->getCity() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Responsible:</th>
+      <td><?php echo $katao_node->getResponsible() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>BEgin at:</th>
+      <td><?php echo $katao_node->getBeginAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_node->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_node->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoNode/edit?id='.$katao_node->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoNode/index') ?>">List</a>

File diff suppressed because it is too large
+ 282 - 0
apps/admin/modules/kataoOrder/actions/actions.class.php


+ 4 - 0
apps/admin/modules/kataoOrder/config/security.yml

@@ -0,0 +1,4 @@
+exportPDF:
+  credentials: [[ admin, seo, delegate, supplier ]]
+all:
+  credentials: [[ admin, seo, delegate ]]

+ 55 - 0
apps/admin/modules/kataoOrder/templates/adjustProductSuccess.php

@@ -0,0 +1,55 @@
+<?php $katao_order = $katao_order_product->getKataoOrder() ?>
+<div class="content-add01">
+	<div class="heading01"><h1>Ajustement de la commande "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_order_product_adjust?id=' . $katao_order_product->getId()) ?>
+
+<?php $katao_product = $katao_order_product->getKataoProduct() ?>
+<h3><?php echo $katao_order_product->getProductName() ?></h3>
+
+<table class="admin-sub-list">
+<tr>
+	<td style="border:none!important">Commande : <?php echo $katao_product->getOrderDetails($katao_order_product->getKataoOrder()->getKataoPeriodId(), $katao_order_product->getKataoOrder()->getKataoNodeId(), true) ?></td>
+	<th colspan="2" style="text-align:center!important">Quantités</th>
+</tr>
+<tr>
+	<th>Adhérent</th>
+	<th nowrap="nowrap" width="1%">Commandée</th>
+	<th nowrap="nowrap" width="1%">Ajustée</th>
+</tr>
+<?php foreach ($katao_order_product->getKataoCartProductsJoinKataoCart() as/*(KataoCartProduct)*/ $katao_cart_product): ?>
+	<?php $katao_member = $katao_cart_product->getKataoCart()->getMember() ?>
+<tr>
+ 	<td>
+ 		<?php echo catalyz_link_to_image_tag('@katao_cart_pdf?id=' . $katao_cart_product->getKataoCartId(), 'actions/pdf.png', array('title' => 'Exporter la demande correspondante en PDF'), array('alt' => 'Exporter la demande correspondante en PDF', 'align' => 'top')) ?>
+		<?php echo $katao_member->getFullName() ?>
+ 	</td>
+ 	<td><?php echo $katao_cart_product->getQuantity() ?></td>
+ 	<td nowrap="nowrap">
+ 	<?php if (!$view_mode_only): ?>
+ 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_tag('quantity[' . $katao_cart_product->getId() . ']', $katao_cart_product->getQuantityAdjusted(), array('style' => 'width: 20px; text-align: center;')) ?>
+		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+	<?php else: ?>
+		<?php echo $katao_cart_product->getQuantityAdjusted() ?>
+	<?php endif ?>
+	</td>
+</tr>
+<?php endforeach ?>
+<?php if (!$view_mode_only): ?>
+<tr>
+ 	<td><?php echo select_tag('new_user_id', options_for_select($katao_order_product->getMembersWithoutProduct(), false, array('include_custom' => '&mdash;&nbsp;Ajouter une commande à un adhérent&nbsp;&mdash;'))) ?></td>
+ 	<td>-</td>
+ 	<td nowrap="nowrap">
+ 		<a href="javascript://" onclick="document.getElementById('quantity_0').value = Math.max(0, parseInt(document.getElementById('quantity_0').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_tag('quantity[0]', '0', array('style' => 'width: 20px; text-align: center;')) ?>
+		<a href="javascript://" onclick="document.getElementById('quantity_0').value = parseInt(document.getElementById('quantity_0').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+	</td>
+</tr>
+<?php endif ?>
+</table>
+
+<br /><?php if (!$view_mode_only): ?><?php echo submit_tag('Ajuster') ?> ou <?php endif ?><a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+
+</form>

+ 27 - 0
apps/admin/modules/kataoOrder/templates/adjustSuccess.php

@@ -0,0 +1,27 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Ajustement de la commande "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_order_adjust?id=' . $katao_order->getId()) ?>
+
+<?php foreach($katao_order->getKataoOrderProductsJoinKataoProduct() as/*(KataoOrderProduct)*/ $katao_order_product): ?>
+	<?php $katao_product = $katao_order_product->getKataoProduct() ?>
+	<h2><?php echo $katao_order_product->getProductName() ?> - <?php echo $katao_product->getOrderDetails($katao_order->getKataoPeriodId(), $katao_order->getKataoNodeId(), true) ?></h2>
+	<ul>
+	<?php foreach ($katao_order_product->getKataoCartProductsJoinKataoCart() as/*(KataoCartProduct)*/ $katao_cart_product): ?>
+		<?php $katao_member = $katao_cart_product->getKataoCart()->getMember() ?>
+		<li>
+			<?php echo $katao_member->getFullName() ?>
+			<?php echo input_tag('quantity[' . $katao_product->getId() . '][' . $katao_cart_product->getId() . ']', $katao_cart_product->getQuantityAdjusted(), array('style' => 'width: 20px; text-align: center;')) ?>
+		</li>
+	<?php endforeach ?>
+		<li>
+			<?php echo select_tag('new_user_id', options_for_select($katao_order_product->getMembersWithoutProduct(), false, array('include_custom' => '&mdash;&nbsp;Ajouter une commande à un adhérent&nbsp;&mdash;'))) ?>
+			<?php echo input_tag('quantity[' . $katao_product->getId() . '][0]', '', array('style' => 'width: 20px; text-align: center;')) ?>
+		</li>
+	</ul>
+<?php endforeach ?>
+
+<?php echo submit_tag('Ajuster') ?> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+
+</form>

+ 61 - 0
apps/admin/modules/kataoOrder/templates/deliverProductSuccess.php

@@ -0,0 +1,61 @@
+<?php $katao_order = $katao_order_product->getKataoOrder() ?>
+<div class="content-add01">
+	<div class="heading01"><h1>Livraison de la commande "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_order_product_deliver?id=' . $katao_order_product->getId()) ?>
+
+<h3><?php echo $katao_order_product->getProductName() ?> (quantité réceptionnée: <?php echo $katao_order_product->getQuantityReceived() ?>)</h3>
+
+<table class="admin-sub-list">
+<tr>
+	<td style="border:none!important">&nbsp;</td>
+	<th colspan="3" style="text-align:center!important">Quantités</th>
+</tr>
+<tr>
+	<th>Adhérent</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Commandée</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Ajustée</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Délivrée</th>
+</tr>
+<?php $total_delivered = 0 ?>
+<?php foreach ($katao_order_product->getKataoCartProductsJoinKataoCart() as/*(KataoCartProduct)*/ $katao_cart_product): ?>
+	<?php $katao_member = $katao_cart_product->getKataoCart()->getMember() ?>
+	<?php $quantity = $katao_order_product->getHasBeenDelivered()?$katao_cart_product->getQuantityDelivered():$katao_cart_product->getQuantityAdjusted() ?>
+	<?php $total_delivered += $quantity ?>
+<tr>
+ 	<td><?php echo $katao_member->getFullName() ?></td>
+ 	<td style="text-align:center!important"><?php echo $katao_cart_product->getQuantity() ?></td>
+ 	<td style="text-align:center!important"><?php echo $katao_cart_product->getQuantityAdjusted() ?></td>
+ 	<td nowrap="nowrap" style="text-align:center!important">
+ 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) - 1); updateTotalDelivered();" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_tag('quantity[' . $katao_cart_product->getId() . ']', $quantity, array('style' => 'width: 20px; text-align: center;', 'class' => 'quantity-delivered', 'onchange' => 'updateTotalDelivered();')) ?>
+		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_cart_product->getId() ?>').value) + 1; updateTotalDelivered();" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+	</td>
+</tr>
+<?php endforeach ?>
+<tr>
+	<td style="border:none!important">&nbsp;</td>
+	<th colspan="2" style="text-align:right!important">Total <?php echo image_tag('actions/deliver.png', array('alt' => 'Quantité délivrée', 'title' => 'Quantité délivrée', 'align' => 'top')) ?> / <?php echo image_tag('actions/receive.png', array('alt' => 'Quantité réceptionnée', 'title' => 'Quantité réceptionnée', 'align' => 'top')) ?></th>
+	<th style="text-align:center!important"><span id="total-delivered"><?php echo $total_delivered ?></span> / <?php echo $katao_order_product->getQuantityReceived() ?></th>
+</tr>
+</table>
+
+<br /><?php echo submit_tag('Délivrer', array('onclick' => 'if(parseInt($("total-delivered").innerHTML)!=' . $katao_order_product->getQuantityReceived() . '){alert("La somme des quantités par adhérent ne correspond pas à la quantité réceptionnée");return false;}')) ?> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function updateTotalDelivered(){
+	var total_delivered = 0;
+	var delivered_quantities = $$('.quantity-delivered');
+	for(var i = 0; i < delivered_quantities.length; i++){
+		total_delivered += parseInt(delivered_quantities[i].value);
+	}
+	$('total-delivered').innerHTML = total_delivered;
+}
+
+/* ]]> */
+</script>

+ 35 - 0
apps/admin/modules/kataoOrder/templates/editSuccess.php

@@ -0,0 +1,35 @@
+<?php $katao_order = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_order->isNew() ? 'Ajout' : 'Modification' ?> d'un commande</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoOrder/update'.(!$katao_order->isNew() ? '?id='.$katao_order->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_supplier_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_supplier_id'] ?>
+		  <?php echo $form['katao_supplier_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['status']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['status'] ?>
+		  <?php echo $form['status']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 55 - 0
apps/admin/modules/kataoOrder/templates/generateMembersInvoicesSuccess.php

@@ -0,0 +1,55 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Génération des factures adhérents pour la période <u><?php echo $katao_period->getName() ?></u></h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoOrder/generateMembersInvoices') ?>" method="post">
+
+<p><i>Sélectioner ci-dessous les noeuds pour lesquels vous souhaitez générer les factures adhérents.<br />Ceux qui sont grisés correspondent aux noeuds où au moins une facture a été générée.</i></p>
+
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Générer" /> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <td><?php echo checkbox_tag('katao_node_all', 1, false, array('onclick' => 'toggleCheckboxes(this.checked);')) ?></td>
+        <td><i><?php echo label_for('katao_node_all', 'Sélectionner tous les noeuds') ?></i></td>
+      </tr>
+      <tr><td colspan="2">&nbsp;</td></tr>
+	<?php foreach ($katao_node_ids as $kata_node_id => $kata_node_data): ?>
+      <tr valign="top">
+        <td><?php echo checkbox_tag('katao_node_ids[]', $kata_node_id, false, array('class' => !empty($kata_node_data['available'])?'checkbox':'', 'onclick' => 'toggleCheckAllCheckbox();', 'disabled' => empty($kata_node_data['available']))) ?></td>
+        <td class="<?php echo empty($kata_node_data['available'])?'not-available':'' ?>"><?php echo label_for('katao_node_ids_' . $kata_node_id, $kata_node_data['city']) ?></td>
+      </tr>
+    <?php endforeach ?>
+    </tbody>
+  </table>
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function toggleCheckboxes(is_checked){
+	var checkboxes = $$('.checkbox');
+	for(var i = 0; i < checkboxes.length; i++){
+		checkboxes[i].checked = is_checked;
+	}
+}
+
+function toggleCheckAllCheckbox(){
+	var	checked_checkboxes = 0;
+	var checkboxes = $$('.checkbox');
+	for(var i = 0; i < checkboxes.length; i++){
+		if (checkboxes[i].checked) {
+			checked_checkboxes++;
+		}
+	}
+	$('katao_node_all').checked = (checked_checkboxes == checkboxes.length);
+}
+
+/* ]]> */
+</script>

+ 183 - 0
apps/admin/modules/kataoOrder/templates/indexSuccess.php

@@ -0,0 +1,183 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des commandes fournisseurs (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_order_filter') ?>
+			<?php echo select_tag('filter_status', options_for_select(KataoOrderPeer::getAllStatuses(), $filter_status, array('include_custom' => '&mdash;&nbsp;Etat&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_supplier', options_for_select(KataoSupplierPeer::getAllSimple(), $filter_supplier, array('include_custom' => '&mdash;&nbsp;Fournisseur&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_node', options_for_select(KataoNodePeer::getAllArray(), $filter_node, array('include_custom' => '&mdash;&nbsp;Noeud&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_period', options_for_select(KataoPeriodPeer::getAll(), $filter_period, array('include_custom' => '&mdash;&nbsp;Période&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_order_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_orderList)): ?>
+	<p>Aucune commande.</p>
+<?php else : ?>
+  <?php use_helper('Javascript') ?>
+
+  <?php echo link_to('Marquer les commandes sélectionnées (' . multiple_action_info_selected('katao_order') . ') comme ajustées', '@katao_order_adjust_multiple', array('class' => 'adjust', 'confirm' => 'Êtes-vous sûr de vouloir marquer les commandes sélectionnées comme ajustées ?')) ?>
+  <?php echo link_to('Générer les factures adhérents', '@katao_order_generate_invoices', array('class' => 'invoice')) ?>
+  <div style="padding-top:4px">
+  	<span class="pdf">Exporter les commandes : </span><?php echo link_to('toutes', '@katao_order_export_pdf_all') ?> | <?php echo link_to('sélectionnées (' . multiple_action_info_selected('katao_order') . ')', '@katao_order_export_pdf_selected') ?>
+  	<?php echo link_to('Supprimer les commandes sélectionnées (' . multiple_action_info_selected('katao_order') . ')', '@katao_order_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les commandes sélectionnées ?')) ?>
+  </div>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_order') ?></th>
+	  <th nowrap="nowrap">N&deg; <?php echo sort_links($sf_request, 'no', 'kataoOrder/index') ?></th>
+	  <th nowrap="nowrap">Date <?php echo sort_links($sf_request, 'date', 'kataoOrder/index') ?></th>
+	  <th nowrap="nowrap">Etat <?php echo sort_links($sf_request, 'status', 'kataoOrder/index') ?></th>
+	  <th nowrap="nowrap">Fournisseur <?php echo sort_links($sf_request, 'supplier', 'kataoOrder/index') ?></th>
+	  <th nowrap="nowrap">Montant / Min.</th>
+	  <th nowrap="nowrap">Noeud <?php echo sort_links($sf_request, 'node', 'kataoOrder/index') ?></th>
+	  <th nowrap="nowrap">Période <?php echo sort_links($sf_request, 'period', 'kataoOrder/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_orderList as/*(KataoOrder)*/ $katao_order): ?>
+
+	<?php
+		$criteria = new Criteria();
+		$criteria->addAscendingOrderByColumn(KataoOrderProductPeer::PRODUCT_NAME);
+		$katao_order_products = $katao_order->getKataoOrderProductsJoinKataoProduct($criteria);
+
+    $total = 0;
+    $katao_order_products_data = array();
+    foreach ($katao_order_products as/*(KataoOrderProduct)*/ $katao_order_product) {
+        $katao_product = $katao_order_product->getKataoProduct();
+
+        $quantity_adjusted = $katao_order_product->getQuantity();
+        $quantity_received = $katao_order_product->getHasBeenReceived()?$katao_order_product->getQuantityReceived():CONST_N_A;
+        $quantity_delivered = $katao_order_product->getHasBeenDelivered()?$katao_order_product->getQuantityDelivered():CONST_N_A;
+
+        $quantity = $quantity_delivered;
+        if (CONST_N_A === $quantity) {
+            $quantity = $quantity_received;
+        }
+        if (CONST_N_A === $quantity) {
+            $quantity = $quantity_adjusted;
+        }
+
+        $price = round($katao_order_product->getProductPriceEuro() * (1 + $katao_order_product->getProductTvaRate()), 2);
+        $sub_total = $quantity * $price;
+        $total += $sub_total;
+
+        $katao_order_products_data[] = array('id' => $katao_order_product->getId(),
+            'product_name' => $katao_order_product->getProductName(),
+            'quantity_adjusted' => $quantity_adjusted,
+            'quantity_received' => $quantity_received,
+            'quantity_delivered' => $quantity_delivered,
+            'price' => $price,
+            'sub_total' => $sub_total,
+            'last_incomplete_package' => $katao_product->getLastIncompletePackageQuantity($katao_order->getKataoPeriodId(), $katao_order->getKataoNodeId(), true),
+            'order_details' => $katao_product->getOrderDetails($katao_order->getKataoPeriodId(), $katao_order->getKataoNodeId(), true),
+            );
+    }
+
+    ?>
+
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_order', $katao_order->getId()) ?></td>
+		  <td nowrap="nowrap">
+			<a href="javascript://" onclick="toggleDetails('<?php echo $katao_order->getId() ?>');" title="Détails"><?php echo image_tag('actions/expand.png', array('alt' => 'Détails', 'id' => 'order-icon-' . $katao_order->getId(), 'align' => 'bottom')) ?></a>
+		    <?php echo $katao_order->getNumber() ?>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getCreatedAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getStatusStr() ?></td>
+		  <td><?php echo $katao_order->getSupplierName() ?></td>
+		  <td nowrap="nowrap" style="text-align:right!important">
+		  	<?php echo Utils::formatCurrencyEuro($total) ?> / <?php echo Utils::formatCurrencyEuro($katao_order->getKataoSupplier()->getOrderMinAmount()) ?>
+		  	<?php $order_min_amount = $katao_order->getKataoSupplier()->getOrderMinAmount() ?>
+		  	<?php $is_adjustable = $total >= $order_min_amount ?>
+			<span id="order-status-red-<?php echo $katao_order->getId() ?>" style="display: <?php echo $is_adjustable?'none':'inline' ?>"><?php echo image_tag('actions/bullet_red.png', array('alt' => 'Montant minimum NON atteint et/ou colisage NON complet', 'title' => 'Montant minimum NON atteint et/ou colisage NON complet', 'align' => 'top')) ?></span>
+		  	<span id="order-status-green-<?php echo $katao_order->getId() ?>" style="display: <?php echo $is_adjustable?'inline':'none' ?>"><?php echo image_tag('actions/bullet_green.png', array('alt' => 'Montant minimum atteint et colisage complet', 'title' => 'Montant minimum atteint et colisage complet', 'align' => 'top')) ?></span>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getNodeLink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getPeriodLink() ?></td>
+		  <td nowrap="nowrap">
+	      <?php if (KataoOrder::STATUS_GENERATED == $katao_order->getStatus()): ?>
+		    <span id="order-link-adjust-<?php echo $katao_order->getId() ?>" style="display: <?php echo $is_adjustable?'inline':'none' ?>"><?php echo catalyz_link_to_image_tag('@katao_order_adjust?id=' . $katao_order->getId(), 'actions/adjust.png', array('title' => 'Marquer comme ajustée', 'confirm' => 'Êtes-vous sûr de vouloir marquer cette commande comme ajustée ?'), array('alt' => 'Marquer comme ajustée')) ?></span>
+		    <?php if (!$sf_user->isJustDelegate()): ?>
+		    <?php echo catalyz_link_to_image_tag('@katao_order_force_adjustment?id=' . $katao_order->getId(), 'actions/force.png', array('title' => 'Forcer l\'ajustement', 'confirm' => 'Êtes-vous sûr de vouloir forcer l\'ajustement de cette commande ?\nATTENTION : il se peut que le colisage des produits ne soit pas complet\net que le montant minimum de la commande ne soit pas atteint.'), array('alt' => 'Forcer l\'ajustement')) ?>
+		    <?php endif ?>
+		  <?php else: ?>
+		    <?php echo catalyz_link_to_image_tag('@katao_order_pdf?id=' . $katao_order->getId(), 'actions/pdf.png', array('title' => 'Exporter en PDF'), array('alt' => 'Exporter en PDF')) ?>
+		  <?php endif ?>
+		  <?php if (KataoOrder::STATUS_ADJUSTED == $katao_order->getStatus()): ?>
+		    <?php echo catalyz_link_to_image_tag('@katao_order_send?id=' . $katao_order->getId(), 'actions/send.png', array('title' => 'Envoyer au fournisseur', 'confirm' => 'Êtes-vous sûr de vouloir envoyer la commande au fournisseur ?'), array('alt' => 'Envoyer au fournisseur')) ?>
+		  <?php elseif (KataoOrder::STATUS_SENT == $katao_order->getStatus()): ?>
+		  	<?php echo catalyz_link_to_image_tag('@katao_order_receive?id=' . $katao_order->getId(), 'actions/receive.png', array('title' => 'Marquer comme réceptionnée'), array('alt' => 'Marquer comme réceptionnée')) ?>
+		  <?php elseif (KataoOrder::STATUS_RECEIVED == $katao_order->getStatus() && $katao_order->checkIfAllProductsHaveBeenDelivered()): ?>
+		  	<?php echo catalyz_link_to_image_tag('@katao_order_deliver?id=' . $katao_order->getId(), 'actions/deliver.png', array('title' => 'Marquer comme délivrée', 'confirm' => 'Êtes-vous sûr de vouloir marquer cette commande comme délivrée ?'), array('alt' => 'Marquer comme délivrée')) ?>
+		  <?php endif ?>
+			<?php echo catalyz_link_to_image_tag('@katao_order_delete?id=' . $katao_order->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer cette commande ?'), array('alt' => 'Supprimer')) ?>
+	  </td>
+	</tr>
+	<tr valign="top" style="display: none" id="order-details-<?php echo $katao_order->getId() ?>">
+	  <td colspan="9">
+	    <table class="admin-sub-list">
+	  	<tr>
+	  		<th>Produit</th>
+			<th nowrap="nowrap" width="1%">Colisage</th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/adjust.png', array('alt' => 'Quantité commandée', 'title' => 'Quantité commandée')) ?></th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/receive.png', array('alt' => 'Quantité réceptionnée', 'title' => 'Quantité réceptionnée')) ?></th>
+			<th nowrap="nowrap" width="1%"><?php echo image_tag('actions/deliver.png', array('alt' => 'Quantité délivrée', 'title' => 'Quantité délivrée')) ?></th>
+	  		<th nowrap="nowrap" width="1%">Prix TTC</th>
+	  		<th nowrap="nowrap" width="1%">Total</th>
+		</tr>
+		<?php foreach ($katao_order_products_data as $katao_order_product_infos): ?>
+		<tr valign="top">
+	  		<td>
+	  			<?php echo $katao_order_product_infos['product_name'] ?>
+	  			<?php echo catalyz_link_to_image_tag('@katao_order_product_adjust?id=' . $katao_order_product_infos['id'], 'actions/adjust.png', array('title' => 'Ajuster'), array('alt' => 'Ajuster', 'align' => 'top')) ?>
+			<?php if (!empty($katao_order_product_infos['last_incomplete_package'])): ?>
+				<?php echo javascript_tag('$("order-status-red-' . $katao_order->getId() . '").style.display = "inline"; $("order-status-green-' . $katao_order->getId() . '").style.display = "none"; $("order-link-adjust-' . $katao_order->getId() . '").style.display = "none";') ?>
+			<?php endif ?>
+	  		</td>
+	  		<td nowrap="nowrap"><?php echo $katao_order_product_infos['order_details'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_order_product_infos['quantity_adjusted'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_order_product_infos['quantity_received'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_order_product_infos['quantity_delivered'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo Utils::formatCurrencyEuro($katao_order_product_infos['price']) ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo Utils::formatCurrencyEuro($katao_order_product_infos['sub_total']) ?></td>
+		</tr>
+		<?php endforeach ?>
+		<tr>
+			<td colspan="2" style="border:none!important">
+			<?php if (KataoOrder::STATUS_SENT == $katao_order->getStatus()): ?>
+	  			<?php echo link_to('Ajouter un nouveau produit à cette commande', '@katao_order_receive_new_product?id=' . $katao_order->getId(), array('class' => 'add')) ?>
+		  	<?php endif ?>
+			</td>
+			<th colspan="4" nowrap="nowrap" style="text-align:right!important">MONTANT TOTAL TTC</th>
+			<th nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($total) ?></th>
+		</tr>
+		</table>
+	  <?php if ('' != $katao_order->getDeliveryAddress()): ?>
+		<p><u>Adresse de livraison</u> : <?php echo str_replace("\n", ' - ', $katao_order->getDeliveryAddress()) ?></p>
+	  <?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoOrder/index?sort=%s%s', $sf_request->getParameter('sort', 'supplier'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_order') ?>
+<?php endif ?>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function toggleDetails( id ){
+	$('order-details-'+id).toggle();
+	if($('order-details-'+id).visible()) {
+		$('order-icon-'+id).src = '<?php echo image_path('actions/collapse.png') ?>';
+	} else {
+		$('order-icon-'+id).src = '<?php echo image_path('actions/expand.png') ?>';
+	}
+}
+
+/* ]]> */
+</script>

+ 11 - 0
apps/admin/modules/kataoOrder/templates/receiveNewProductSuccess.php

@@ -0,0 +1,11 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Ajout d'un produit à la commande "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_order_receive_new_product?id=' . $katao_order->getId()) ?>
+
+<?php echo select_tag('product', options_for_select($katao_order->getOtherProducts())) ?>
+
+<br /><br /><?php echo submit_tag('Ajouter') ?> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+
+</form>

+ 32 - 0
apps/admin/modules/kataoOrder/templates/receiveSuccess.php

@@ -0,0 +1,32 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Réception de la commande "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_order_receive?id=' . $katao_order->getId()) ?>
+
+<table class="admin-sub-list">
+<tr>
+	<td style="border:none!important">&nbsp;</td>
+	<th colspan="3" style="text-align:center!important">Quantités</th>
+</tr>
+<tr>
+	<th>Produit</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Commandée</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Réceptionnée</th>
+</tr>
+<?php foreach ($katao_order->getKataoOrderProducts() as/*(KataoOrderProduct)*/ $katao_order_product): ?>
+<tr>
+ 	<td><?php echo $katao_order_product->getProductName() ?></td>
+ 	<td style="text-align:center!important"><?php echo $katao_order_product->getQuantity() ?></td>
+ 	<td nowrap="nowrap" style="text-align:center!important">
+ 		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value = Math.max(0, parseInt(document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value) - 1)" title="Diminuer la quantité"><?php echo image_tag('minus.png', array('alt' => 'Diminuer la quantité', 'align' => 'top')) ?></a>
+		<?php echo input_tag('quantity[' . $katao_order_product->getId() . ']', $katao_order_product->getHasBeenReceived()?$katao_order_product->getQuantityReceived():$katao_order_product->getQuantity(), array('style' => 'width: 20px; text-align: center;')) ?>
+		<a href="javascript://" onclick="document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value = parseInt(document.getElementById('quantity_<?php echo $katao_order_product->getId() ?>').value) + 1" title="Augmenter la quantité"><?php echo image_tag('plus.png', array('alt' => 'Augmenter la quantité', 'align' => 'top')) ?></a>
+	</td>
+</tr>
+<?php endforeach ?>
+</table>
+
+<br /><?php echo submit_tag('Réceptionner') ?> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+
+</form>

+ 23 - 0
apps/admin/modules/kataoOrder/templates/sendSuccess.php

@@ -0,0 +1,23 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Envoi de la commande "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<?php echo form_tag('@katao_order_send?id=' . $katao_order->getId()) ?>
+
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><?php echo submit_tag('Envoyer') ?> ou <?php echo submit_tag('Marquer comme envoyée', array('name' => 'do_not_send')) ?> ou <a href="<?php echo url_for('kataoOrder/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <td><?php echo label_for('delivery_address', 'Adresse de livraison') ?></td>
+		<td><?php echo textarea_tag('delivery_address', $delivery_address) ?></td>
+      </tr>
+    </tbody>
+  </table>
+
+</form>

+ 34 - 0
apps/admin/modules/kataoOrder/templates/showSuccess.php

@@ -0,0 +1,34 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Commande : <?php echo $katao_order->getSupplierName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_order->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao supplier:</th>
+      <td><?php echo $katao_order->getKataoSupplierId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Status:</th>
+      <td><?php echo $katao_order->getStatus() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_order->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_order->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoOrder/edit?id='.$katao_order->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoOrder/index') ?>">List</a>

+ 36 - 0
apps/admin/modules/kataoOrder/templates/simulatedMembersSuccess.php

@@ -0,0 +1,36 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des membres du produit "<?php echo $katao_product->getName() ?>" de la commande simulée "<?php echo $katao_order->getNumber() ?>" du fournisseur "<?php echo $katao_order->getSupplierName() ?>" pour la période "<?php echo $katao_order->getKataoPeriod()->getName() ?>"</h1></div>
+</div>
+
+<table class="admin-sub-list">
+<tr>
+	<td style="border:none!important">&nbsp;</td>
+	<th colspan="2" style="text-align:center!important">Quantités</th>
+</tr>
+<tr>
+	<th>Adhérent</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Commandée</th>
+	<th nowrap="nowrap" width="1%" style="text-align:center!important">Ajustée</th>
+</tr>
+<?php $total = 0 ?>
+<?php $total_adjusted = 0 ?>
+<?php foreach ($katao_order_product->getKataoCartProductsJoinKataoCart() as/*(KataoCartProduct)*/ $katao_cart_product): ?>
+	<?php $katao_cart = $katao_cart_product->getKataoCart() ?>
+	<?php $katao_member = $katao_cart->getMember() ?>
+	<?php $total += $katao_cart_product->getQuantity() ?>
+	<?php $total_adjusted += $katao_cart_product->getQuantityAdjusted() ?>
+<tr>
+ 	<td>
+ 		<?php echo $katao_member->getFullName() ?>
+ 		<?php echo catalyz_link_to_image_tag('@katao_cart_pdf?id=' . $katao_cart->getId(), 'actions/pdf.png', array('title' => 'Exporter en PDF'), array('alt' => 'Exporter en PDF')) ?>
+ 	</td>
+ 	<td style="text-align:center!important"><?php echo $katao_cart_product->getQuantity() ?></td>
+ 	<td style="text-align:center!important"><?php echo $katao_cart_product->getQuantityAdjusted() ?></td>
+</tr>
+<?php endforeach ?>
+<tr>
+	<th style="text-align:right!important">TOTAL :</th>
+	<th style="text-align:center!important"><?php echo $total ?></th>
+	<th style="text-align:center!important"><?php echo $total_adjusted ?></th>
+</tr>
+</table>

+ 150 - 0
apps/admin/modules/kataoOrder/templates/simulatedSuccess.php

@@ -0,0 +1,150 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des commandes simulées (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<?php if (empty($katao_orderList)): ?>
+	<p>Aucune commande simulée.</p>
+<?php else : ?>
+  <?php echo link_to('Supprimer toutes les commandes simulées', '@katao_order_delete_simulated', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer toutes les commandes simulées ?')) ?>
+
+  <br /><br /><?php echo checkbox_tag('toggle_complete', 1, false, array('onclick' => 'toggleCompleteOrders();')) ?><?php echo label_for('toggle_complete', 'Afficher uniquement les commandes incomplètes') ?>
+
+  <?php use_helper('Javascript') ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap">N&deg;</th>
+	  <th nowrap="nowrap">Date</th>
+	  <th nowrap="nowrap">Fournisseur</th>
+	  <th nowrap="nowrap">Montant / Min.</th>
+	  <th nowrap="nowrap">Noeud</th>
+	  <th nowrap="nowrap">Période</th>
+	</tr>
+	<?php $total_total = 0 ?>
+	<?php foreach ($katao_orderList as/*(KataoOrder)*/ $katao_order): ?>
+
+	<?php
+        $katao_order_products = $katao_order->getKataoOrderProductsJoinKataoProduct();
+
+    $total = 0;
+    $katao_order_products_data = array();
+    foreach ($katao_order_products as/*(KataoOrderProduct)*/ $katao_order_product) {
+        $katao_product = $katao_order_product->getKataoProduct();
+
+        $quantity = $katao_order_product->getQuantity();
+
+        $price = round($katao_order_product->getProductPriceEuro() * (1 + $katao_order_product->getProductTvaRate()), 2);
+        $sub_total = $quantity * $price;
+        $total += $sub_total;
+        $total_total += $sub_total;
+
+        $katao_order_products_data[] = array('id' => $katao_order_product->getId(),
+            'product_name' => $katao_order_product->getProductName(),
+            'quantity' => $quantity,
+            'price' => $price,
+            'sub_total' => $sub_total,
+            'last_incomplete_package' => $katao_product->getLastIncompletePackageQuantity($katao_order->getKataoPeriodId(), $katao_order->getKataoNodeId(), true),
+            'order_details' => $katao_product->getOrderDetails($katao_order->getKataoPeriodId(), $katao_order->getKataoNodeId(), true),
+            );
+    }
+
+    ?>
+
+    <tr valign="top" id="tr-<?php echo $katao_order->getId() ?>" class="line complete incomplete">
+		  <td nowrap="nowrap">
+			<a href="javascript://" onclick="toggleDetails('<?php echo $katao_order->getId() ?>');" title="Détails"><?php echo image_tag('actions/expand.png', array('alt' => 'Détails', 'id' => 'order-icon-' . $katao_order->getId(), 'align' => 'bottom')) ?></a>
+		    <?php echo $katao_order->getNumber() ?>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getCreatedAtStr() ?></td>
+		  <td><?php echo $katao_order->getSupplierName() ?></td>
+		  <td nowrap="nowrap" style="text-align:right!important">
+		  	<?php echo Utils::formatCurrencyEuro($total) ?> / <?php echo Utils::formatCurrencyEuro($katao_order->getKataoSupplier()->getOrderMinAmount()) ?>
+		  	<?php $order_min_amount = $katao_order->getKataoSupplier()->getOrderMinAmount() ?>
+		  	<?php $is_adjustable = $total >= $order_min_amount ?>
+		  	<?php if (!$is_adjustable): ?>
+		  		<?php echo javascript_tag('$("tr-' . $katao_order->getId() . '").removeClassName("complete");') ?>
+		  	<?php endif ?>
+			<span id="order-status-red-<?php echo $katao_order->getId() ?>" style="display: <?php echo $is_adjustable?'none':'inline' ?>"><?php echo image_tag('actions/bullet_red.png', array('alt' => 'Montant minimum NON atteint et/ou colisage NON complet', 'title' => 'Montant minimum NON atteint et/ou colisage NON complet', 'align' => 'top')) ?></span>
+		  	<span id="order-status-green-<?php echo $katao_order->getId() ?>" style="display: <?php echo $is_adjustable?'inline':'none' ?>"><?php echo image_tag('actions/bullet_green.png', array('alt' => 'Montant minimum atteint et colisage complet', 'title' => 'Montant minimum atteint et colisage complet', 'align' => 'top')) ?></span>
+		  </td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getNodeLink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_order->getPeriodLink() ?></td>
+	</tr>
+	<tr valign="top" style="display: none" id="order-details-<?php echo $katao_order->getId() ?>">
+	  <td colspan="9">
+	    <table class="admin-sub-list">
+	  	<tr>
+	  		<th>Produit</th>
+			<th nowrap="nowrap" width="1%">Colisage</th>
+			<th nowrap="nowrap" width="1%">Quantité</th>
+	  		<th nowrap="nowrap" width="1%">Prix TTC</th>
+	  		<th nowrap="nowrap" width="1%">Total</th>
+		</tr>
+		<?php foreach ($katao_order_products_data as $katao_order_product_infos): ?>
+		<tr valign="top" class="sub-line <?php echo !empty($katao_order_product_infos['last_incomplete_package'])?'incomplete':'complete' ?>">
+	  		<td>
+	  			<?php echo $katao_order_product_infos['product_name'] ?>
+	  			<?php echo link_to(image_tag('actions/users.png', array('alt' => 'Voir la liste des adhérents', 'align' => 'top')), '@katao_order_simulated_members?id=' . $katao_order_product_infos['id'], array('title' => 'Voir la liste des adhérents')) ?>
+			<?php if (!empty($katao_order_product_infos['last_incomplete_package'])): ?>
+				<?php echo javascript_tag('$("tr-' . $katao_order->getId() . '").removeClassName("complete"); $("order-status-red-' . $katao_order->getId() . '").style.display = "inline"; $("order-status-green-' . $katao_order->getId() . '").style.display = "none";') ?>
+			<?php endif ?>
+	  		</td>
+	  		<td nowrap="nowrap"><?php echo $katao_order_product_infos['order_details'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_order_product_infos['quantity'] ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo Utils::formatCurrencyEuro($katao_order_product_infos['price']) ?></td>
+	  		<td nowrap="nowrap" style="text-align:right!important"><?php echo Utils::formatCurrencyEuro($katao_order_product_infos['sub_total']) ?></td>
+		</tr>
+		<?php endforeach ?>
+		<tr>
+			<td colspan="2" style="border:none!important">&nbsp;</td>
+			<th colspan="2" nowrap="nowrap" style="text-align:right!important">TOTAL TTC</th>
+			<th nowrap="nowrap" style="text-align:right!important"><?php echo utils::formatCurrencyEuro($total) ?></th>
+		</tr>
+		</table>
+	  <?php if ('' != $katao_order->getDeliveryAddress()): ?>
+		<p><u>Adresse de livraison</u> : <?php echo str_replace("\n", ' - ', $katao_order->getDeliveryAddress()) ?></p>
+	  <?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+    <tr>
+	  <td colspan="3" style="border:none!important">&nbsp;</td>
+	  <th nowrap="nowrap" style="text-align:right!important"> <?php echo Utils::formatCurrencyEuro($total_total) ?></th>
+	  <td colspan="2" style="border:none!important">&nbsp;</td>
+	</tr>
+  </table>
+<?php endif ?>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function toggleDetails( id ){
+	$('order-details-'+id).toggle();
+	if($('order-details-'+id).visible()) {
+		$('order-icon-'+id).src = '<?php echo image_path('actions/collapse.png') ?>';
+	} else {
+		$('order-icon-'+id).src = '<?php echo image_path('actions/expand.png') ?>';
+	}
+}
+
+
+function toggleCompleteOrders(){
+	var orders = $$('.line');
+	for(var i = 0; i < orders.length; i++){
+		orders[i].show();
+	}
+
+	var products = $$('.sub-line');
+	for(var i = 0; i < products.length; i++){
+		products[i].show();
+	}
+
+	if ($('toggle_complete').checked) {
+		var complete_lines = $$('.complete');
+		for(var i = 0; i < complete_lines.length; i++){
+			complete_lines[i].hide();
+		}
+	}
+}
+
+/* ]]> */
+</script>

+ 464 - 0
apps/admin/modules/kataoPeriod/actions/actions.class.php

@@ -0,0 +1,464 @@
+<?php
+
+/**
+ * kataoPeriod actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoPeriod
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoPeriodActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'name')) {
+            case 'begin':
+                $criteria->$sort_method(KataoPeriodPeer::BEGIN_AT);
+                break;
+            case 'end':
+                $criteria->$sort_method(KataoPeriodPeer::FINISH_AT);
+                break;
+            case 'order':
+                $criteria->$sort_method(KataoPeriodPeer::ORDER_ENDED_AT);
+                break;
+            case 'active':
+                $criteria->$sort_method(KataoPeriodPeer::IS_ACTIVE);
+                break;
+            default:
+                $criteria->$sort_method(KataoPeriodPeer::NAME);
+        }
+
+        if ('' != $this->filter_status = $this->getUser()->getAttribute('katao_period_status')) {
+            $criteria->add(KataoPeriodPeer::STATUS, $this->filter_status);
+        }
+
+        $pager = new sfPropelPager('KataoPeriod', sfConfig::get('app_pager'));
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_periodList = $pager->getResults();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_period_status', $request->getParameter('filter_status'));
+        return $this->redirect('kataoPeriod/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_period_status', '');
+        return $this->redirect('kataoPeriod/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_period = KataoPeriodPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_period, 'Période #' . $request->getParameter('id') . ' inconnue.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoPeriodForm();
+
+        $this->katao_suppliers = KataoSupplierPeer::getAllToSortArray();
+        $this->products = KataoProductPeer::getSelectedProducts(array_keys($this->katao_suppliers['some_product']));
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $this->form = new KataoPeriodForm(KataoPeriodPeer::retrieveByPk($request->getParameter('id')));
+
+        $this->katao_suppliers = KataoSupplierPeer::getAllToSortArray($request->getParameter('id'));
+        $this->products = KataoProductPeer::getSelectedProducts(array_keys($this->katao_suppliers['some_product']), $request->getParameter('id'));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoPeriodForm(KataoPeriodPeer::retrieveByPk($request->getParameter('id')));
+
+        $this->form->bind($request->getParameter('katao_period'));
+        if ($this->form->isValid()) {
+            $katao_period = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Période "' . $katao_period->getName() . '" sauvée avec succès.');
+            $this->redirect('kataoPeriod/index');
+        }
+
+        $this->katao_suppliers = KataoSupplierPeer::getAllToSortArray($request->getParameter('id'));
+        $this->products = KataoProductPeer::getSelectedProducts(array_keys($this->katao_suppliers['some_product']), $request->getParameter('id'));
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_period = KataoPeriodPeer::retrieveByPk($request->getParameter('id')), 'Période #' . $request->getParameter('id') . ' inconnue.');
+        $this->redirectWithErrorIf(!$katao_period->isDeletable());
+
+        $katao_period->delete();
+
+        wpFlashMessages::addConfirmation('Période "' . $katao_period->getName() . '" supprimée avec succès.');
+        $this->redirect('kataoPeriod/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_period')) {
+            foreach (KataoPeriodPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_period'))) as/*(KataoPeriod)*/ $katao_period) {
+                if ($katao_period->isDeletable()) {
+                    $katao_period->delete();
+                }
+            }
+
+            wpPersistenceManager::cleanSelection('katao_period');
+            wpFlashMessages::addConfirmation('Les périodes sélectionnées ont été supprimées avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une période.');
+        }
+
+        $this->redirect('kataoPeriod/index');
+    }
+
+    public function executeRefreshProducts($request) {
+        return $this->renderText('(' . Utils::array_to_json_string(KataoProductPeer::getSelectedProducts(explode(',', $request->getParameter('suppliers_ids')), $request->getParameter('id'))) . ')');
+    }
+
+    public function executeActivate($request) {
+        $this->redirectWithErrorUnless($katao_period = KataoPeriodPeer::retrieveByPk($request->getParameter('id')), 'Période #' . $request->getParameter('id') . ' inconnue.');
+
+        $katao_period->activate();
+
+        wpFlashMessages::addConfirmation('Période "' . $katao_period->getName() . '" activée avec succès.');
+        $this->redirect('kataoPeriod/index');
+    }
+
+    public function executeExportAccounting($request) {
+        $katao_periods = KataoPeriodPeer::getAllWithDates();
+        $export_date_from = date('Y-m-d 00:00:00', Utils::getDateFromInput($request->getParameter('date_from')));
+        $export_date_to = date('Y-m-d 23:59:59', Utils::getDateFromInput($request->getParameter('date_to')));
+
+        $content = array();
+
+        /* Liste des dépôts validés de la période en question */
+        $criteria = new Criteria();
+        $criteria->add(KataoMemberDepositPeer::PAYMENT_MODE, KataoMemberDeposit::PAYMENT_MODE_TRANSFER_SOL, Criteria::NOT_EQUAL);
+        $criteria->add(KataoMemberDepositPeer::STATUS, KataoMemberDeposit::STATUS_VALIDATED);
+        $criterion = $criteria->getNewCriterion(KataoMemberDepositPeer::VALUED_AT, $export_date_from, Criteria::GREATER_EQUAL);
+        $criterion->addAnd($criteria->getNewCriterion(KataoMemberDepositPeer::VALUED_AT, $export_date_to, Criteria::LESS_EQUAL));
+        $criteria->addAnd($criterion);
+        $criteria->addAscendingOrderByColumn(KataoMemberDepositPeer::VALUED_AT);
+        foreach (KataoMemberDepositPeer::doSelectJoinKataoMember($criteria) as/*(KataoMemberDeposit)*/ $katao_member_deposit) {
+            $katao_period_id = KataoPeriodPeer::getIdFromRangeDate($katao_member_deposit->getValuedAt('Y-m-d'), $katao_periods);
+            $katao_member = $katao_member_deposit->getKataoMember();
+
+            $date_ecriture = $katao_member_deposit->getValuedAt('Ymd');
+            $date_echeance = $katao_member_deposit->getValuedAt('Ymd');
+            $num_piece = sprintf('DE%04d', $katao_member_deposit->getId());
+            if (KataoMemberDeposit::PAYMENT_MODE_CHECK == $katao_member_deposit->getPaymentMode()) {
+                $libelle_ecriture = sprintf('%s%s%s - %s', $katao_member_deposit->getCheckDeposit()?sprintf('%s-', $katao_member_deposit->getCheckDeposit()):'', $katao_member_deposit->getCheckBank(), $katao_member_deposit->getCheckNumber(), $katao_member->getLastName());
+            } else {
+                $libelle_ecriture = sprintf('%s - %s', $katao_member_deposit->getPaymentModeStr(), $katao_member->getLastName());
+            }
+            $num_pointage = '';
+            $code_analytique_budgetaire = '';
+            $libelle_compte = $katao_member->getFullName();
+
+            if (KataoMemberDeposit::CURRENCY_SOL == $katao_member_deposit->getCurrency()) {
+                $journal = 'SO';
+                $num_mouvement = $katao_period_id . '4';
+                $montant = $katao_member_deposit->getAmount() / CONST_EURO_TO_SOL;
+
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeSolDiscount(), $libelle_ecriture, $montant, (KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL != $katao_member_deposit->getPaymentMode())?'D':'C', $num_pointage, $code_analytique_budgetaire, 'REMISE SOL');
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $katao_member->getAccountingCodeSol(), $libelle_ecriture, $montant, (KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL != $katao_member_deposit->getPaymentMode())?'C':'D', $num_pointage, $code_analytique_budgetaire, $libelle_compte . '-' . wpConfig::getAdditionalCurrencyName());
+            } else {
+                $journal = 'BQ';
+                $num_mouvement = $katao_period_id . '3';
+                $montant = $katao_member_deposit->getAmount();
+
+                $num_compte = (KataoMemberDeposit::PAYMENT_MODE_CREDIT == $katao_member_deposit->getPaymentMode())?wpConfig::getAccountingCodeCredit():wpConfig::getAccountingCodeBank();
+
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $num_compte, $libelle_ecriture, $montant, (KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL != $katao_member_deposit->getPaymentMode())?'D':'C', $num_pointage, $code_analytique_budgetaire, 'CAISSE D\'EPARGNE');
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $katao_member->getAccountingCode(), $libelle_ecriture, $montant, (KataoMemberDeposit::PAYMENT_MODE_WITHDRAWAL != $katao_member_deposit->getPaymentMode())?'C':'D', $num_pointage, $code_analytique_budgetaire, $libelle_compte);
+            }
+        }
+
+        /* Liste des factures fournisseurs de la période */
+        $criteria = new Criteria();
+        $criterion = $criteria->getNewCriterion(KataoSupplierInvoicePeer::INVOICE_DATE, $export_date_from, Criteria::GREATER_EQUAL);
+        $criterion->addAnd($criteria->getNewCriterion(KataoSupplierInvoicePeer::INVOICE_DATE, $export_date_to, Criteria::LESS_EQUAL));
+        $criteria->addAnd($criterion);
+        $criteria->addAscendingOrderByColumn(KataoSupplierInvoicePeer::INVOICE_DATE);
+        foreach (KataoSupplierInvoicePeer::doSelectJoinAll($criteria) as/*(KataoSupplierInvoice)*/ $katao_supplier_invoice) {
+            $katao_period = $katao_supplier_invoice->getKataoPeriod();
+            $katao_supplier = $katao_supplier_invoice->getKataoSupplier();
+
+            $journal = 'HA';
+            $num_mouvement = $katao_period->getId() . '2';
+            $date_ecriture = $katao_supplier_invoice->getInvoiceDate('Ymd');
+            $date_echeance = $katao_supplier_invoice->getDueDate('Ymd');
+            $num_piece = $katao_supplier_invoice->getReference();
+            $libelle_ecriture = $katao_period->getName();
+            $num_pointage = '';
+            $code_analytique_budgetaire = '';
+            $libelle_compte = '';
+
+            $total_sol = $katao_supplier_invoice->getPaymentAmountSol() / CONST_EURO_TO_SOL;
+            // enlever la valeur en sol du montant total en €
+            $total_euro = $katao_supplier_invoice->getTotalHT() + $katao_supplier_invoice->getTotalTva() - $total_sol;
+
+            $total_credit = $total_euro;
+            // pour vérifier que total débit = total crédit sans les sols
+            $total_debit = - $total_sol;
+
+            $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $katao_supplier->getAccountingCode(), $libelle_ecriture, $total_euro, 'C', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName());
+            if ($total_sol) {
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $katao_supplier->getAccountingCodeSol(), $libelle_ecriture, $total_sol, 'C', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName() . '-' . wpConfig::getAdditionalCurrencyName());
+            }
+
+            $line_by_accounting_code = array();
+            foreach ($katao_supplier_invoice->getKataoSupplierInvoiceProductsJoinKataoProduct() as/*(KataoSupplierInvoiceProduct)*/ $katao_supplier_invoice_product) {
+                $katao_product = $katao_supplier_invoice_product->getKataoProduct();
+                if (!isset($line_by_accounting_code[$katao_product->getAccountingCodePurchase()]['amount'])) {
+                    $line_by_accounting_code[$katao_product->getAccountingCodePurchase()]['amount'] = 0;
+                }
+                $line_by_accounting_code[$katao_product->getAccountingCodePurchase()]['amount'] += $katao_supplier_invoice_product->getProductPriceTotal();
+                $line_by_accounting_code[$katao_product->getAccountingCodePurchase()]['category'] = sprintf('Ach : %s', $katao_product->getKataoProductFamily()->getKataoProductCategory()->getName());
+            }
+            foreach ($line_by_accounting_code as $accounting_code => $data) {
+                if (!empty($data['amount'])) {
+                    $total_debit += $data['amount'];
+                    $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $accounting_code, $libelle_ecriture, $data['amount'], 'D', $num_pointage, $code_analytique_budgetaire, $data['category']);
+                }
+            }
+
+            $discount = $katao_supplier_invoice->getTaux0DiscountHt() + $katao_supplier_invoice->getTaux1DiscountHt() + $katao_supplier_invoice->getTaux2DiscountHt();
+
+            $tva_rates = array('0.196' => 1, '0.055' => 2, '0' => 0);
+            $tva_5_5 = $katao_supplier_invoice->getTaux2Amount();
+            $tva_19_6 = $katao_supplier_invoice->getTaux1Amount();
+            if ($katao_supplier_invoice->getFeesBillingTva() && !empty($tva_rates[(string)$katao_supplier_invoice->getFeesBillingRate()])) {
+                switch ($tva_rates[(string)$katao_supplier_invoice->getFeesBillingRate()]) {
+                    case 1:
+                        $tva_19_6 += $katao_supplier_invoice->getFeesBillingTva();
+                        break;
+                    case 2:
+                        $tva_5_5 += $katao_supplier_invoice->getFeesBillingTva();
+                        break;
+                }
+            }
+            if ($katao_supplier_invoice->getFeesShippingTva() && !empty($tva_rates[(string)$katao_supplier_invoice->getFeesShippingRate()])) {
+                switch ($tva_rates[(string)$katao_supplier_invoice->getFeesShippingRate()]) {
+                    case 1:
+                        $tva_19_6 += $katao_supplier_invoice->getFeesShippingTva();
+                        break;
+                    case 2:
+                        $tva_5_5 += $katao_supplier_invoice->getFeesShippingTva();
+                        break;
+                }
+            }
+
+            if ($tva_19_6) {
+                $total_debit += $tva_19_6;
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, '445664', $libelle_ecriture, $tva_19_6, 'D', $num_pointage, $code_analytique_budgetaire, 'TVA 19.6%');
+            }
+            if ($tva_5_5) {
+                $total_debit += $tva_5_5;
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, '445662', $libelle_ecriture, $tva_5_5, 'D', $num_pointage, $code_analytique_budgetaire, 'TVA 5.5%');
+            }
+            if ($katao_supplier_invoice->getFeesBillingHt()) {
+                $total_debit += $katao_supplier_invoice->getFeesBillingHt();
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeFeesBilling(), sprintf('FRSDEFACT-%s', $katao_supplier->getName()), $katao_supplier_invoice->getFeesBillingHt(), 'D', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName());
+            }
+
+            if ($katao_supplier_invoice->getFeesShippingHt()) {
+                $total_debit += $katao_supplier_invoice->getFeesShippingHt();
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeFeesShipping(), sprintf('FRSDEPORT-%s', $katao_supplier->getName()), $katao_supplier_invoice->getFeesShippingHt(), 'D', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName());
+            }
+            if ($discount) {
+                $total_credit += $discount;
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeDiscount(), sprintf('REMISE-%s', $katao_supplier->getName()), $discount, 'C', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName());
+            }
+
+            if (round(abs($total_debit - $total_credit), 2)) {
+                if ($total_debit > $total_credit) {
+                    $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeErrorAdjustmentPositive(), $libelle_ecriture, $total_debit - $total_credit, 'C', $num_pointage, $code_analytique_budgetaire, 'Ecart de conversion');
+                } elseif ($total_debit < $total_credit) {
+                    $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeErrorAdjustmentNegative(), $libelle_ecriture, $total_credit - $total_debit, 'D', $num_pointage, $code_analytique_budgetaire, 'Ecart de conversion');
+                }
+            }
+        }
+
+        /* Liste des factures fournisseurs payées de la période */
+        $criteria = new Criteria();
+        $criterion = $criteria->getNewCriterion(KataoSupplierInvoicePeer::PAYMENT_DATE, $export_date_from, Criteria::GREATER_EQUAL);
+        $criterion->addAnd($criteria->getNewCriterion(KataoSupplierInvoicePeer::PAYMENT_DATE, $export_date_to, Criteria::LESS_EQUAL));
+        $criteria->addAnd($criterion);
+        $criteria->addAscendingOrderByColumn(KataoSupplierInvoicePeer::INVOICE_DATE);
+        foreach (KataoSupplierInvoicePeer::doSelectJoinAll($criteria) as/*(KataoSupplierInvoice)*/ $katao_supplier_invoice) {
+            $katao_period = $katao_supplier_invoice->getKataoPeriod();
+            $katao_supplier = $katao_supplier_invoice->getKataoSupplier();
+
+            $num_mouvement = $katao_period->getId() . '5';
+            $date_ecriture = $katao_supplier_invoice->getPaymentDate('Ymd');
+            $date_echeance = $katao_supplier_invoice->getPaymentDate('Ymd');
+            $num_piece = $katao_supplier_invoice->getReference();
+            $libelle_ecriture = sprintf('%s - %s', (KataoMemberDeposit::PAYMENT_MODE_CHECK == $katao_supplier_invoice->getPaymentMode())?$katao_supplier_invoice->getPaymentDetails():$katao_supplier_invoice->getPaymentModeStr(), $katao_supplier->getName());
+            $num_pointage = '';
+            $code_analytique_budgetaire = '';
+            $libelle_compte = '';
+
+            $total_sol = $katao_supplier_invoice->getPaymentAmountSol() / CONST_EURO_TO_SOL;
+            $total_euro = $katao_supplier_invoice->getTotalHT() + $katao_supplier_invoice->getTotalTva();
+
+            $this->addAccountingLine($num_mouvement, 'BQ', $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeBank(), $libelle_ecriture, $total_euro, 'C', $num_pointage, $code_analytique_budgetaire, 'CAISSE D\'EPARGNE');
+            if ($total_sol) {
+                $this->addAccountingLine($num_mouvement, 'BQ', $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeBankSol(), $libelle_ecriture, $total_sol, 'C', $num_pointage, $code_analytique_budgetaire, 'COMPTE SOL');
+            }
+            $this->addAccountingLine($num_mouvement, 'BQ', $date_ecriture, $date_echeance, $num_piece, $katao_supplier->getAccountingCode(), $libelle_ecriture, $total_euro, 'D', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName());
+            if ($total_sol) {
+                $this->addAccountingLine($num_mouvement, 'BQ', $date_ecriture, $date_echeance, $num_piece, $katao_supplier->getAccountingCodeSol(), $libelle_ecriture, $total_sol, 'D', $num_pointage, $code_analytique_budgetaire, $katao_supplier->getName() . '-' . wpConfig::getAdditionalCurrencyName());
+            }
+        }
+
+        /* Liste des factures adhérents envoyées de la période */
+        $criteria = new Criteria();
+        $criterion = $criteria->getNewCriterion(KataoInvoicePeer::CREATED_AT, $export_date_from, Criteria::GREATER_EQUAL);
+        $criterion->addAnd($criteria->getNewCriterion(KataoInvoicePeer::CREATED_AT, $export_date_to, Criteria::LESS_EQUAL));
+        $criteria->addAnd($criterion);
+        $criteria->add(KataoInvoicePeer::STATUS, KataoInvoice::STATUS_SENT);
+        $criteria->addAscendingOrderByColumn(KataoInvoicePeer::CREATED_AT);
+        foreach (KataoInvoicePeer::doSelectJoinAllExceptKataoCart($criteria) as/*(KataoInvoice)*/ $katao_invoice) {
+            $katao_period = $katao_invoice->getKataoPeriod();
+            $katao_member = $katao_invoice->getKataoMember();
+
+            $journal = 'VT';
+            $num_mouvement = $katao_period->getId() . '1';
+            $date_ecriture = $katao_invoice->getCreatedAt('Ymd');
+            $date_echeance = $katao_invoice->getCreatedAt('Ymd');
+            $num_piece = $katao_invoice->getNumber();
+            $libelle_ecriture = sprintf('%s - %s', $katao_period->getName(), $katao_invoice->getKataoNode()->getCity());
+            $num_pointage = '';
+            $code_analytique_budgetaire = '';
+            $libelle_compte = '';
+
+            $total_by_tva_rate = array('0.196' => 0, '0.055' => 0, '0' => 0);
+
+            $total_debit = $katao_invoice->sumProducts();
+            $total_debit_sol = $katao_invoice->getSolAmount() / CONST_EURO_TO_SOL;
+            $total_debit_euro = $total_debit - $total_debit_sol;
+
+            $total_credit = 0;
+
+            $libelle_compte = $katao_member->getFullName();
+            $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $katao_member->getAccountingCode(), $libelle_ecriture, $total_debit_euro, 'D', $num_pointage, $code_analytique_budgetaire, $libelle_compte);
+            if ($total_debit_sol) {
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $katao_member->getAccountingCodeSol(), $libelle_ecriture, $total_debit_sol, 'D', $num_pointage, $code_analytique_budgetaire, $libelle_compte . '-' . wpConfig::getAdditionalCurrencyName());
+            }
+            $libelle_compte = '';
+
+            $amounts_by_accounting_code_and_tva = array();
+            $line_by_accounting_code = array();
+            foreach ($katao_invoice->getKataoInvoiceProductsJoinKataoProduct() as/*(KataoInvoiceProduct)*/ $katao_invoice_product) {
+                $katao_product = $katao_invoice_product->getKataoProduct();
+
+                $famille = $katao_product->getAccountingCodeSell();
+                $tva = (string)$katao_invoice_product->getProductTvaRate();
+
+                $amounts_by_accounting_code_and_tva[$famille]['name'] = $katao_product->getKataoProductFamily()->getKataoProductCategory()->getName();
+                if (!isset($amounts_by_accounting_code_and_tva[$famille]['values'][$tva]['ttc'])) {
+                    $amounts_by_accounting_code_and_tva[$famille]['values'][$tva]['ttc'] = 0;
+                }
+                $amounts_by_accounting_code_and_tva[$famille]['values'][$tva]['ttc'] += round($katao_invoice_product->getQuantityDelivered() * round($katao_invoice_product->getProductPriceWithTaxes(), 2), 2);
+
+                $amount = $katao_invoice_product->getQuantityDelivered() * $katao_invoice_product->getProductPriceWithoutTaxes();
+            }
+
+            $total_by_tva_rate = array();
+            foreach ($amounts_by_accounting_code_and_tva as $amount_accounting_code => $amount_accounting_code_tvas) {
+                foreach ($amount_accounting_code_tvas['values'] as $amount_tva => $amount_tva_values) {
+                    if (!isset($amount_tva_values['ttc'])) {
+                        $amount_tva_values['ttc'] = 0;
+                        $amounts_by_accounting_code_and_tva[$amount_accounting_code]['values'][$amount_tva]['ttc'] = 0;
+                    }
+                    $value = round($amount_tva_values['ttc'] / (1 + (float)$amount_tva), 2);
+                    $amounts_by_accounting_code_and_tva[$amount_accounting_code]['values'][$amount_tva]['ht'] = $value;
+
+                    if (!isset($total_by_tva_rate[$amount_tva])) {
+                        $total_by_tva_rate[$amount_tva] = 0;
+                    }
+                    $total_by_tva_rate[$amount_tva] += max(0, $amounts_by_accounting_code_and_tva[$amount_accounting_code]['values'][$amount_tva]['ttc'] - $amounts_by_accounting_code_and_tva[$amount_accounting_code]['values'][$amount_tva]['ht']);
+                }
+            }
+
+            foreach ($amounts_by_accounting_code_and_tva as $amount_accounting_code => $amount_accounting_code_tvas) {
+                $amount = 0;
+                foreach ($amount_accounting_code_tvas['values'] as $amount_tva => $amount_tva_values) {
+                    $amount += $amount_tva_values['ht'];
+                }
+                $total_credit += round($amount, 2);
+
+                $line_by_accounting_code[$amount_accounting_code]['amount'] = $amount;
+                $line_by_accounting_code[$amount_accounting_code]['category'] = sprintf('Vts : %s', $amount_accounting_code_tvas['name']);
+            }
+
+            foreach ($line_by_accounting_code as $accounting_code => $data) {
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $accounting_code, $libelle_ecriture, $data['amount'], 'C', $num_pointage, $code_analytique_budgetaire, $data['category']);
+            }
+
+            if (!empty($total_by_tva_rate['0.196'])) {
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, '445714', $libelle_ecriture, $total_by_tva_rate['0.196'], 'C', $num_pointage, $code_analytique_budgetaire, 'TVA 19.6%');
+                $total_credit += round($total_by_tva_rate['0.196'], 2);
+            }
+            if (!empty($total_by_tva_rate['0.055'])) {
+                $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, '445712', $libelle_ecriture, $total_by_tva_rate['0.055'], 'C', $num_pointage, $code_analytique_budgetaire, 'TVA 5.5%');
+                $total_credit += round($total_by_tva_rate['0.055'], 2);
+            }
+
+            if (round(abs($total_debit - $total_credit), 2)) {
+                if ($total_debit > $total_credit) {
+                    $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeErrorAdjustmentPositive(), $libelle_ecriture, $total_debit - $total_credit, 'C', $num_pointage, $code_analytique_budgetaire, 'Ecart de conversion');
+                } elseif ($total_debit < $total_credit) {
+                    $this->addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, wpConfig::getAccountingCodeErrorAdjustmentNegative(), $libelle_ecriture, $total_credit - $total_debit, 'D', $num_pointage, $code_analytique_budgetaire, 'Ecart de conversion');
+                }
+            }
+        }
+
+        $content = implode("\n", $this->accounting_lines);
+
+        $response = $this->getResponse();
+        $response->setContentType('application/octet-stream');
+        $response->setHttpHeader('Content-disposition', 'attachment; filename="XIMPORT.TXT"');
+        $response->setHttpHeader('Content-Length', strlen($content));
+        $response->setHttpHeader('Pragma', 'public');
+        $response->setHttpHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
+        $response->setHttpHeader('Expires', '0');
+        $response->setContent($content);
+        return sfView::NONE;
+    }
+
+    protected $accounting_lines = array();
+    protected function addAccountingLine($num_mouvement, $journal, $date_ecriture, $date_echeance, $num_piece, $num_compte, $libelle_ecriture, $montant, $sens_operation, $num_pointage, $code_analytique_budgetaire, $libelle_compte) {
+        $libelle_ecriture = Utils::removeAccents(utf8_decode($libelle_ecriture));
+        $libelle_compte = Utils::removeAccents(utf8_decode($libelle_compte));
+
+        $this->accounting_lines[] = sprintf('%s%s%s%s%s%s%s%s%s%s%s%s02003', Utils::completeWithSpaces($num_mouvement, 5, true), $journal,
+            $date_ecriture, $date_echeance,
+            Utils::completeWithSpaces($num_piece, 12), Utils::completeWithSpaces($num_compte, 11),
+            Utils::completeWithSpaces($libelle_ecriture, 25), Utils::completeWithSpaces(sprintf('%0.2f', $montant), 13, true), $sens_operation,
+            Utils::completeWithSpaces($num_pointage, 12), Utils::completeWithSpaces('', 6),
+            Utils::completeWithSpaces($libelle_compte, 34));
+    }
+
+    public function executeCopy($request) {
+        $this->redirectWithErrorUnless($katao_period = KataoPeriodPeer::retrieveByPk($request->getParameter('id')), 'Période #' . $request->getParameter('id') . ' inconnue.');
+
+        if ($katao_period_id = $katao_period->makePeriodCopy()) {
+            wpFlashMessages::addConfirmation('Période "' . $katao_period->getName() . '" copiée avec succès.');
+            $this->redirect('kataoPeriod/edit?id=' . $katao_period_id);
+        }
+
+        wpFlashMessages::addError('Impossible de copier la période "' . $katao_period->getName() . '".');
+        $this->redirect('kataoPeriod/index');
+    }
+}

+ 2 - 0
apps/admin/modules/kataoPeriod/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  credentials: [[ admin, seo ]]

+ 286 - 0
apps/admin/modules/kataoPeriod/templates/editSuccess.php

@@ -0,0 +1,286 @@
+<?php use_javascript('dd/coordinates.js') ?>
+<?php use_javascript('dd/drag.js') ?>
+<?php use_javascript('dd/dragdrop.js') ?>
+<?php use_stylesheet('dd/lists.css') ?>
+
+<?php $katao_period = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_period->isNew() ? 'Ajout' : 'Modification' ?> d'une période</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoPeriod/update' . (!$katao_period->isNew() ? '?id=' . $katao_period->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><?php echo submit_tag('Sauver', array('onclick' => 'getSort();')) ?> ou <a href="<?php echo url_for('kataoPeriod/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['name'] ?>
+		  <?php echo $form['name']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['begin_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['begin_at'] ?>
+		  <?php echo $form['begin_at']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['order_ended_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['order_ended_at'] ?> <i>(inclus)</i>
+		  <?php echo $form['order_ended_at']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['finish_at']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['finish_at'] ?> <i>(inclus)</i>
+		  <?php echo $form['finish_at']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+
+<br />
+<div class="content-add01">
+	<div class="heading01"><h1>Choix des fournisseurs/produits disponibles</h1></div>
+</div>
+
+<p>
+	Faites glisser les fournisseurs disponibles dans les listes suivantes :
+	<ul>
+		<li><u>Tous les produits</u> si vous souhaitez activer tous les produits</li>
+		<li><u>Certains produits</u> si vous ne souhaitez activer que certains produits</li>
+	</ul>
+</p>
+
+<?php echo input_hidden_tag('id', $katao_period->getId()) ?>
+<?php echo input_hidden_tag('suppliers_with_all_products', '') ?>
+
+<table cellpadding="0" border="0">
+<tr valign="top">
+	<td rowspan="3">
+		<div class="section-title-filter4"><b>Fournisseurs :</b></div>
+		<div class="section-container-filter4">
+			<ul id="left_col" class="sortable boxy" style="min-height: 250px">
+			<?php foreach ($katao_suppliers['not_select'] as $id => $name): ?>
+				<li id="supplier-<?php echo $id ?>" onmouseup="refreshProducts(this)"><?php echo $name ?></li>
+			<?php endforeach ?>
+			</ul>
+		</div>
+	</td>
+	<td>&nbsp;&nbsp;</td>
+	<td>
+		<table cellpadding="0" border="0">
+		<tr valign="top">
+			<td>
+				<div class="section-title-filter4"><b>Tous les produits :</b></div>
+				<div class="section-container-filter4">
+					<ul id="middle_col" class="sortable boxy boxy-large" style="min-height: 150px">
+					<?php foreach ($katao_suppliers['all_product'] as $id => $name): ?>
+						<li id="all-products-<?php echo $id ?>" onmouseup="refreshProducts(this)"><?php echo $name ?></li>
+					<?php endforeach ?>
+					</ul>
+				</div>
+			</td>
+		</tr>
+		<tr><td>&nbsp;</td></tr>
+		<tr valign="top">
+			<td>
+				<div class="section-title-filter4"><b>Certains produits :</b> <em>(choisir dans la liste ci-dessous)</em></div>
+				<div class="section-container-filter4">
+					<ul id="right_col" class="sortable boxy boxy-large" style="min-height: 150px">
+					<?php foreach ($katao_suppliers['some_product'] as $id => $name): ?>
+						<li id="products-<?php echo $id ?>" onmouseup="refreshProducts(this)"><?php echo $name ?></li>
+					<?php endforeach ?>
+					</ul>
+				</div>
+			</td>
+		</tr>
+		<tr valign="top">
+			<td>
+				<b>Produits sélectionnés :</b>
+			</td>
+		</tr>
+		<tr valign="top">
+			<td id="dynamic_product">
+				<?php echo select_tag('products', options_for_select($products['list'], $products['selected']), array('multiple' => 'multiple', 'style' => 'width:365px;')) ?>
+			</td>
+		</tr>
+		</table>
+	</td>
+</tr>
+</table>
+
+<br />
+<?php echo submit_tag('Sauver', array('onclick' => 'getSort();')) ?> ou <a href="<?php echo url_for('kataoPeriod/index') ?>">annuler</a>
+
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+all_supplier = new Array();
+<?php if(!empty($katao_suppliers['all']) && is_array($katao_suppliers['all']) && 0 < count($katao_suppliers['all'])) : ?>
+<?php foreach($katao_suppliers['all'] as $name) : ?>
+all_supplier.push('<?php echo $name ?>');
+<?php endforeach ?>
+<?php endif ?>
+
+function in_array(needle, haystack, argStrict) {
+    // http://kevin.vanzonneveld.net
+
+    var key = '', strict = !!argStrict;
+
+    if (strict) {
+        for (key in haystack) {
+            if (haystack[key] === needle) {
+                return true;
+            }
+        }
+    } else {
+        for (key in haystack) {
+            if (haystack[key] == needle) {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
+window.onload = function() {
+	list = document.getElementById("left_col");
+	DragDrop.makeListContainer( list, 'g1' );
+	list.onDragOver = function() { this.style["background"] = "#eff3fc"; };
+	list.onDragOut = function() {this.style["background"] = "none"; };
+
+	list = document.getElementById("middle_col");
+	DragDrop.makeListContainer( list, 'g1' );
+	list.onDragOver = function() { this.style["background"] = "#eff3fc"; };
+	list.onDragOut = function() {this.style["background"] = "none"; };
+
+	list = document.getElementById("right_col");
+	DragDrop.makeListContainer( list, 'g1' );
+	list.onDragOver = function() { this.style["background"] = "#eff3fc"; };
+	list.onDragOut = function() {this.style["background"] = "none"; };
+};
+
+function getSort() {
+	$("suppliers_with_all_products").value = DragDrop.serData('g1', null);
+}
+
+function showValue() {
+	suppliers_with_all_products = document.getElementById("suppliers_with_all_products");
+	alert(suppliers_with_all_products.value);
+}
+
+function refreshProducts(element){
+	var parent = element.parentNode; //right_col
+	var supplier_id = element.id;
+	var childs = parent.childNodes;
+	var period_id = $('id');
+	var params = new Array();
+	if (parent.id == 'right_col') {
+		for(var i = 0; i < childs.length; i++){
+			if ('LI' == childs[i].nodeName) {
+				var supplier_id = childs[i].id;
+				supplier_id = supplier_id.substr(13, supplier_id.length - 13);
+				params.push(supplier_id);
+			}
+		}
+		var tidyParams = params.join(',');
+		var url = '<?php echo url_for('kataoPeriod/refreshProducts') ?>';
+		var myAjax = new Ajax.Request(
+		    url,
+		    {
+		      method: 'get',
+			  parameters: {
+			  			 suppliers_ids:tidyParams,
+						 id:period_id.value
+			  },
+
+			  onSuccess: manageResponse
+		    });
+	}
+	if (parent.id == 'middle_col' || parent.id == 'left_col') {
+		var right_col = $('right_col');
+		var childs_right_col = right_col.childNodes;
+		for(var i = 0; i < childs_right_col.length; i++){
+			if ('LI' == childs_right_col[i].nodeName) {
+				var supplier_id = childs_right_col[i].id;
+				supplier_id = supplier_id.substr(9, supplier_id.length - 9);
+				params.push(supplier_id)
+			}
+		}
+		var tidyParams = params.join(',');
+		var url = '<?php echo url_for('kataoPeriod/refreshProducts') ?>';
+		var myAjax = new Ajax.Request(
+		    url,
+		    {
+		      method: 'get',
+			  parameters: {
+			  			 suppliers_ids:tidyParams,
+						 id:period_id.value
+			  },
+
+			  onSuccess: manageResponse
+		    });
+	}
+}
+
+function manageResponse(xhr){
+	var products = xhr.responseText.evalJSON();
+	var mySelect = '<select name="products[]" id="products" multiple="multiple" style="width:365px;">';
+	var optSelect = new Array();
+	products.selected.each(
+	    function (result)
+	    {
+			optSelect = Object.values(result);
+		});
+	products.list.each(
+        function (supplier)
+        {
+			//console.log(products.selected);
+            for(var i = 0; i < all_supplier.length; i++){
+				var product_list = eval('supplier["' + all_supplier[i] + '"]');
+				if (product_list != undefined) {
+				    mySelect += '<optgroup label="'+all_supplier[i]+'">';
+					product_list.each(
+					function (opt_list)
+        			{
+						var opt_names = Object.values(opt_list);
+						var opt_ids = Object.keys(opt_list);
+						for(var i = 0; i < opt_ids.length; i++){
+							// mySelect += '<option value="'+opt_ids[i]+'">'+opt_names[i]+'</option>';
+							if (in_array(opt_ids[i],optSelect)) {
+								mySelect += '<option value="'+opt_ids[i]+'" selected="selected">'+opt_names[i]+'</option>';
+							}else{
+								mySelect += '<option value="'+opt_ids[i]+'">'+opt_names[i]+'</option>';
+							}
+						}
+					});
+					mySelect += '</optgroup>';
+				}
+			}
+        });
+	mySelect += '</select>';
+	$('dynamic_product').update();
+	$('dynamic_product').innerHTML
+	$('dynamic_product').update(mySelect);
+	$('dynamic_product').innerHTML
+}
+
+/* ]]> */
+</script>

+ 54 - 0
apps/admin/modules/kataoPeriod/templates/indexSuccess.php

@@ -0,0 +1,54 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des périodes (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_period_filter') ?>
+			<?php echo select_tag('filter_status', options_for_select(KataoPeriodPeer::getAllStatuses(), $filter_status, array('include_custom' => '&mdash;&nbsp;Etat&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_period_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_periodList)): ?>
+	<p>Aucune période.</p>
+	<p><?php echo link_to('Ajouter une période', '@katao_period_add', array('class' => 'add')) ?></p>
+<?php else : ?>
+  <?php echo link_to('Ajouter une période', '@katao_period_add', array('class' => 'add')) ?>
+  <?php echo link_to('Supprimer les périodes sélectionnées (' . multiple_action_info_selected('katao_period') . ')', '@katao_period_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les périodes sélectionnées ?')) ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_period') ?></th>
+	  <th nowrap="nowrap">Nom <?php echo sort_links($sf_request, 'name', 'kataoPeriod/index') ?></th>
+	  <th nowrap="nowrap">Début <?php echo sort_links($sf_request, 'begin', 'kataoPeriod/index') ?></th>
+	  <th nowrap="nowrap">Fin <?php echo sort_links($sf_request, 'end', 'kataoPeriod/index') ?></th>
+	  <th nowrap="nowrap">Fin demandes <?php echo sort_links($sf_request, 'order', 'kataoPeriod/index') ?></th>
+	  <th nowrap="nowrap">Etat <?php echo sort_links($sf_request, 'active', 'kataoPeriod/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_periodList as/*(KataoPeriod)*/ $katao_period): ?>
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_period', $katao_period->getId()) ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_period->getName() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_period->getBeginAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_period->getFinishAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_period->getOrderEndedAtStr() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_period->getStatusStr() ?></td>
+		  <td nowrap="nowrap">
+	<?php if (KataoPeriod::STATUS_DRAFT == $katao_period->getStatus()): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_period_activate?id=' . $katao_period->getId(), 'actions/activate.png', array('title' => 'Activer', 'confirm' => 'Êtes-vous sûr de vouloir activer cette période ?'), array('alt' => 'Activer')) ?>
+	<?php endif ?>
+	    <?php echo catalyz_link_to_image_tag('@katao_period_edit?id=' . $katao_period->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+	    <?php echo catalyz_link_to_image_tag('@katao_period_copy?id=' . $katao_period->getId(), 'actions/copy.png', array('title' => 'Copier'), array('alt' => 'Copier')) ?>
+	<?php if ($katao_period->isDeletable()): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_period_delete?id=' . $katao_period->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer cette période ?'), array('alt' => 'Supprimer')) ?>
+	<?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoPeriod/index?sort=%s%s', $sf_request->getParameter('sort', 'name'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_period') ?>
+<?php endif ?>

+ 46 - 0
apps/admin/modules/kataoPeriod/templates/showSuccess.php

@@ -0,0 +1,46 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Période : <?php echo $katao_period->getName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_period->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Name:</th>
+      <td><?php echo $katao_period->getName() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Begin at:</th>
+      <td><?php echo $katao_period->getBeginAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Finish at:</th>
+      <td><?php echo $katao_period->getFinishAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Order ended at:</th>
+      <td><?php echo $katao_period->getOrderEndedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Status:</th>
+      <td><?php echo $katao_period->getStatus() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_period->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_period->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoPeriod/edit?id='.$katao_period->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoPeriod/index') ?>">List</a>

+ 255 - 0
apps/admin/modules/kataoProduct/actions/actions.class.php

@@ -0,0 +1,255 @@
+<?php
+
+/**
+ * kataoProduct actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoProduct
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoProductActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoProductPeer::KATAO_SUPPLIER_ID, KataoSupplierPeer::ID);
+        $criteria->addJoin(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, KataoProductFamilyPeer::ID);
+        $criteria->addJoin(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, KataoProductCategoryPeer::ID);
+
+        $sf_user = $this->getUser();
+        if ($sf_user->isJustSupplier()) {
+            $criteria->add(KataoProductPeer::KATAO_SUPPLIER_ID, $sf_user->getInstance()->getKataoSupplierId());
+        } elseif ($sf_user->isJustReferer()) {
+            $criteria->add(KataoSupplierPeer::REFERER_ID, $sf_user->getInstance()->getKataoMemberId());
+        }
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'name')) {
+            case 'price':
+                $criteria->$sort_method(KataoProductPeer::UNIT_PRICE_EURO);
+                break;
+            case 'category':
+                $criteria->$sort_method(KataoProductCategoryPeer::NAME);
+                break;
+            case 'family':
+                $criteria->$sort_method(KataoProductFamilyPeer::NAME);
+                break;
+            case 'supplier':
+                $criteria->$sort_method(KataoSupplierPeer::NAME);
+                break;
+            default:
+                $criteria->$sort_method(KataoProductPeer::NAME);
+        }
+
+        if ('' != $this->filter_supplier = $this->getUser()->getAttribute('katao_product_filter_supplier')) {
+            $criteria->add(KataoProductPeer::KATAO_SUPPLIER_ID, $this->filter_supplier);
+        }
+        if ('' != $this->filter_product_category = $this->getUser()->getAttribute('katao_product_filter_product_category')) {
+            $criteria->add(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, $this->filter_product_category);
+        }
+        if ('' != $this->filter_product_family = $this->getUser()->getAttribute('katao_product_filter_product_family')) {
+            $criteria->add(KataoProductPeer::KATAO_PRODUCT_FAMILY_ID, $this->filter_product_family);
+        }
+        if ('' != $this->filter_product_archived = $this->getUser()->getAttribute('katao_product_filter_archived')) {
+            $criteria->add(KataoProductPeer::IS_ARCHIVED, (CONST_YES == $this->filter_product_archived)?true:false);
+        }
+
+        if ('' != $this->search = $this->getUser()->getAttribute('katao_product_search')) {
+            $search_like = sprintf('%%%s%%', $this->search);
+            $criterion = $criteria->getNewCriterion(KataoProductPeer::REFERENCE, $search_like, Criteria::LIKE);
+            $criterion->addOr($criteria->getNewCriterion(KataoProductPeer::NAME, $search_like, Criteria::LIKE));
+            $criterion->addOr($criteria->getNewCriterion(KataoProductPeer::DESCRIPTION, $search_like, Criteria::LIKE));
+            $criteria->addAnd($criterion);
+        }
+
+        $pager = new sfPropelPager('KataoProduct', sfConfig::get('app_pager'));
+        $pager->setPeerMethod('doSelectJoinAll');
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_productList = $pager->getResults();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_product_filter_supplier', $request->getParameter('filter_supplier'));
+        $this->getUser()->setAttribute('katao_product_filter_product_category', $request->getParameter('filter_product_category'));
+        $this->getUser()->setAttribute('katao_product_filter_product_family', $request->getParameter('filter_product_family'));
+        $this->getUser()->setAttribute('katao_product_filter_archived', $request->getParameter('filter_product_archived'));
+        return $this->redirect('kataoProduct/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_product_filter_supplier', '');
+        $this->getUser()->setAttribute('katao_product_filter_product_category', '');
+        $this->getUser()->setAttribute('katao_product_filter_product_family', '');
+        $this->getUser()->setAttribute('katao_product_filter_archived', '');
+        return $this->redirect('kataoProduct/index');
+    }
+
+    public function executeSearch($request) {
+        $this->getUser()->setAttribute('katao_product_search', $request->getParameter('search'));
+        return $this->redirect('kataoProduct/index');
+    }
+
+    public function executeSearchReset($request) {
+        $this->getUser()->setAttribute('katao_product_search', '');
+        return $this->redirect('kataoProduct/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_product = KataoProductPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_product, 'Produit #' . $request->getParameter('id') . ' inconnu.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoProductForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $katao_product = KataoProductPeer::retrieveByPk($request->getParameter('id'));
+
+        if (!is_null($katao_product)) {
+            $is_just_supplier = $this->getUser()->isJustSupplier();
+            $is_just_referer = $this->getUser()->isJustReferer();
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $local_node_suppliers = $is_just_delegate?KataoSupplierPeer::getAllLocalToNode($this->getUser()->getInstance()->getKataoMember()->getKataoNodeId()):array();
+            $this->redirectWithErrorIf($is_just_supplier && $this->getUser()->getInstance()->getKataoSupplierId() != $katao_product->getKataoSupplierId());
+            $this->redirectWithErrorIf($is_just_referer && $this->getUser()->getInstance()->getKataoMemberId() != $katao_product->getKataoSupplier()->getRefererId());
+            $this->redirectWithErrorIf($is_just_delegate && empty($local_node_suppliers[$katao_product->getKataoSupplierId()]));
+        }
+
+        $this->form = new KataoProductForm($katao_product);
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $katao_product = KataoProductPeer::retrieveByPk($request->getParameter('id'));
+
+        if (!is_null($katao_product)) {
+            $is_just_supplier = $this->getUser()->isJustSupplier();
+            $is_just_referer = $this->getUser()->isJustReferer();
+            $is_just_delegate = $this->getUser()->isJustDelegate();
+            $local_node_suppliers = $is_just_delegate?KataoSupplierPeer::getAllLocalToNode($this->getUser()->getInstance()->getKataoMember()->getKataoNodeId()):array();
+            $this->redirectWithErrorIf($is_just_supplier && $this->getUser()->getInstance()->getKataoSupplierId() != $katao_product->getKataoSupplierId());
+            $this->redirectWithErrorIf($is_just_referer && $this->getUser()->getInstance()->getKataoMemberId() != $katao_product->getKataoSupplier()->getRefererId());
+            $this->redirectWithErrorIf($is_just_delegate && empty($local_node_suppliers[$katao_product->getKataoSupplierId()]));
+        }
+
+        $this->form = new KataoProductForm($katao_product);
+
+        $this->form->bind($request->getParameter('katao_product'), $request->getFiles('katao_product'));
+        if ($this->form->isValid()) {
+            $katao_product = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Produit "' . $katao_product->getName() . '" sauvé avec succès.');
+            $this->redirect('kataoProduct/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEditPresentation($request) {
+        $this->katao_product = KataoProductPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_product, 'Produit #' . $request->getParameter('id') . ' inconnu.');
+
+        $is_just_supplier = $this->getUser()->isJustSupplier();
+        $is_just_referer = $this->getUser()->isJustReferer();
+        $is_just_delegate = $this->getUser()->isJustDelegate();
+        $local_node_suppliers = $is_just_delegate?KataoSupplierPeer::getAllLocalToNode($this->getUser()->getInstance()->getKataoMember()->getKataoNodeId()):array();
+        $this->redirectWithErrorIf($is_just_supplier && $this->getUser()->getInstance()->getKataoSupplierId() != $this->katao_product->getKataoSupplierId());
+        $this->redirectWithErrorIf($is_just_referer && $this->getUser()->getInstance()->getKataoMemberId() != $this->katao_product->getKataoSupplier()->getRefererId());
+        $this->redirectWithErrorIf($is_just_delegate && empty($local_node_suppliers[$this->katao_product->getKataoSupplierId()]));
+
+        if ($request->isMethod('post')) {
+            $this->katao_product->setDescription($request->getParameter('description'));
+            $this->katao_product->save();
+
+            wpFlashMessages::addConfirmation('Présentation du produit "' . $this->katao_product->getName() . '" sauvée avec succès.');
+            $this->redirect('kataoProduct/index');
+        }
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_product = KataoProductPeer::retrieveByPk($request->getParameter('id')));
+
+        $is_just_supplier = $this->getUser()->isJustSupplier();
+        $is_just_referer = $this->getUser()->isJustReferer();
+        $is_just_delegate = $this->getUser()->isJustDelegate();
+        $local_node_suppliers = $is_just_delegate?KataoSupplierPeer::getAllLocalToNode($this->getUser()->getInstance()->getKataoMember()->getKataoNodeId()):array();
+        $this->redirectWithErrorIf($is_just_supplier && $this->getUser()->getInstance()->getKataoSupplierId() != $katao_product->getKataoSupplierId());
+        $this->redirectWithErrorIf($is_just_referer && $this->getUser()->getInstance()->getKataoMemberId() != $katao_product->getKataoSupplier()->getRefererId());
+        $this->redirectWithErrorIf($is_just_delegate && empty($local_node_suppliers[$katao_product->getKataoSupplierId()]));
+
+        $this->redirectWithErrorIf(!$katao_product->isDeletable());
+
+        $katao_product->delete();
+
+        wpFlashMessages::addConfirmation('Produit "' . $katao_product->getName() . '" supprimé avec succès.');
+        $this->redirect('kataoProduct/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_product')) {
+            foreach (KataoProductPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_product'))) as/*(KataoProduct)*/ $katao_product) {
+                if ($katao_product->isDeletable()) {
+                    $katao_product->delete();
+                }
+            }
+
+            wpPersistenceManager::cleanSelection('katao_product');
+            wpFlashMessages::addConfirmation('Les produits sélectionnés ont été supprimés avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un produit.');
+        }
+
+        $this->redirect('kataoProduct/index');
+    }
+
+    public function executeArchiveMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_product')) {
+            $done = 0;
+            foreach (KataoProductPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_product'))) as/*(KataoProduct)*/ $katao_product) {
+                if (!$katao_product->getIsArchived()) {
+                    $katao_product->setIsArchived(true);
+                    $katao_product->save();
+                    $done++;
+                }
+            }
+
+            if (0 < $done) {
+                wpFlashMessages::addConfirmation($done . ' produits sélectionnés sur ' . wpPersistenceManager::getSelectedItemCount('katao_product') . ' ont été archivés avec succès.');
+            } else {
+                wpFlashMessages::addWarning('Aucun produit sélectionné n\'a été archivé.');
+            }
+            wpPersistenceManager::cleanSelection('katao_product');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un produit.');
+        }
+
+        $this->redirect('kataoProduct/index');
+    }
+
+    public function executeAdjustPrices($request) {
+        $count = 0;
+        foreach (KataoProductPeer::getAll() as/*(KataoProduct)*/ $katao_product) {
+            $price_ht_1 = round($katao_product->getUnitPriceEuro(), 3);
+            $price_ht_2 = round($katao_product->getUnitPriceEuroCalculated(), 3);
+            if ($price_ht_1 != $price_ht_2) {
+                $katao_product->setUnitPriceEuro($price_ht_2);
+                $katao_product->save();
+                $count++;
+            }
+        }
+        if (0 < $count) {
+            wpFlashMessages::addConfirmation('Les prix HT de ces ' . $count . ' produits ont été ajustés automatiquement avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Aucun prix HT n\'a été ajusté automatiquement.');
+        }
+
+        $this->redirect('@homepage');
+    }
+}

+ 3 - 0
apps/admin/modules/kataoProduct/config/security.yml

@@ -0,0 +1,3 @@
+default:
+  is_secure: on
+  credentials: [[ admin, seo, supplier, delegate, referer ]]

+ 27 - 0
apps/admin/modules/kataoProduct/templates/editPresentationSuccess.php

@@ -0,0 +1,27 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Présentation du produit : <?php echo $katao_product->getName() ?></h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoProduct/editPresentation') ?>" method="post">
+
+<?php echo input_hidden_tag('id', $katao_product->getId()) ?>
+
+<p><i>Modifier ci-dessous la présentation de ce produit qui sera affichée sur sa page de détail du site.</i></p>
+
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoProduct/index') ?>">annuler</a> ou <a href="<?php echo url_for('@katao_product_edit?id=' . $katao_product->getId()) ?>">modifier sa fiche</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <tr valign="top">
+        <td>
+          <?php echo textarea_tag('description', $katao_product->getDescription(), array('rich' => true, 'size' => '65x10', 'style' => 'width: 385px; height: 385px', 'tinymce_options' => sfConfig::get('app_tiny_mce_options'), 'id' => 'description')) ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 238 - 0
apps/admin/modules/kataoProduct/templates/editSuccess.php

@@ -0,0 +1,238 @@
+<?php $katao_product = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_product->isNew() ? 'Ajout' : 'Modification' ?> d'un produit</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoProduct/update' . (!$katao_product->isNew() ? '?id=' . $katao_product->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" onclick="if(checkPrices()){computeMaxSolAmount();return true;}else{return false;}" /> ou <a href="<?php echo url_for('kataoProduct/index') ?>">annuler</a><?php if (!$katao_product->isNew()): ?> ou <a href="<?php echo url_for('@katao_product_edit_presentation?id=' . $katao_product->getId()) ?>">modifier sa présentation</a><?php endif ?>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+	  	<td colspan="2" align="left"><u>Produit</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['name'] ?>
+		  <?php echo $form['name']->renderError() ?>
+        </td>
+      </tr>
+	  <tr valign="top">
+        <th align="left"><?php echo $form['reference']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['reference'] ?>
+		  <?php echo $form['reference']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_product_family_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_product_family_id'] ?>
+		  <?php echo $form['katao_product_family_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['picture']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['picture'] ?>
+		  <?php echo $form['picture']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Fournisseur</u></td>
+	  </tr>
+	<?php if (!$sf_user->isJustSupplier()): ?>
+	  <tr valign="top">
+        <th align="left"><?php echo $form['katao_supplier_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_supplier_id'] ?>
+		  <?php echo $form['katao_supplier_id']->renderError() ?>
+        </td>
+      </tr>
+	<?php endif ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['min_order_number']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['min_order_number'] ?>
+		  <?php echo $form['min_order_number']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['delivery_delay']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['delivery_delay'] ?> jours
+		  <?php echo $form['delivery_delay']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['is_archived']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['is_archived'] ?>
+		  <?php echo $form['is_archived']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+
+    <?php if ($sf_user->isJustSupplier()): ?>
+    	  <?php echo input_hidden_tag('katao_product[katao_supplier_id]', $sf_user->getInstance()->getKataoSupplierId()) ?>
+    	  <?php echo input_hidden_tag('katao_product[margin]', $form['margin']->getValue()) ?>
+    	  <?php echo input_hidden_tag('katao_product[tva_rate]', $form['tva_rate']->getValue()) ?>
+    <?php endif ?>
+        </td>
+      </tr>
+      <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Tarification</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['unit_price_euro']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['unit_price_euro'] ?> €
+      <?php if (!$sf_user->isJustSupplier()): ?>
+		  &nbsp;<a href="javascript://" onclick="computeUnitPriceWithTaxes();" title="Calculer le prix de vente TTC"><?php echo image_tag('actions/calculator.png', array('alt' => 'Calculer le prix de vente TTC', 'align' => 'top')) ?></a>
+	  <?php endif ?>
+		  <?php echo $form['unit_price_euro']->renderError() ?>
+        </td>
+      </tr>
+  <?php if (!$sf_user->isJustSupplier()): ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['margin']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['margin'] ?> %
+      <?php if (!$sf_user->isJustSupplier()): ?>
+		  &nbsp;<a href="javascript://" onclick="computeMargin();" title="Calculer la marge"><?php echo image_tag('actions/calculator.png', array('alt' => 'Calculer la marge', 'align' => 'top')) ?></a>
+	  <?php endif ?>
+		  <?php echo $form['margin']->renderError() ?>
+        </td>
+      </tr>
+  <?php endif ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['tva_rate']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['tva_rate'] ?>
+		  <?php echo $form['tva_rate']->renderError() ?>
+        </td>
+      </tr>
+  <?php if (!$sf_user->isJustSupplier()): ?>
+      <tr valign="top">
+        <th align="left"><label>Prix de vente TTC</label></th>
+        <td>
+          <?php echo input_tag('sell_price', '', array('style' => 'width: 54px')) ?> €
+          &nbsp;<a href="javascript://" onclick="computeUnitPriceWithoutTaxes();" title="Calculer le prix d'achat HT"><?php echo image_tag('actions/calculator.png', array('alt' => 'Calculer le prix d\'achat HT', 'align' => 'top')) ?></a>
+        </td>
+      </tr>
+  <?php endif ?>
+      <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Monnaie complémentaire</u></td>
+	  </tr>
+  <?php if (!$sf_user->isJustSupplier()): ?>
+      <tr valign="top">
+        <th align="left"><label>Pourcentage</label></th>
+        <td>
+          <?php echo input_tag('sol_percent', '', array('style' => 'width: 54px')) ?> %
+        </td>
+      </tr>
+  <?php endif ?>
+	  <tr valign="top">
+        <th align="left"><?php echo $form['max_sol_amount']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['max_sol_amount'] ?> <?php echo wpConfig::getAdditionalCurrencyName() ?>
+        <?php if (!$sf_user->isJustSupplier()): ?>
+		  &nbsp;<a href="javascript://" onclick="computeMaxSolAmount();" title="Calculer le montant maxi de la monnaie complémentaire"><?php echo image_tag('actions/calculator.png', array('alt' => 'Calculer le montant maxi de la monnaie complémentaire', 'align' => 'top')) ?></a>
+		<?php endif ?>
+		  <?php echo $form['max_sol_amount']->renderError() ?>
+        </td>
+      </tr>
+  <?php if (!$sf_user->isJustSupplier()): ?>
+      <tr valign="top">
+	  	<td colspan="2" align="left"><br /><u>Codes comptables</u></td>
+	  </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_purchase']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_purchase'] ?>
+		  <?php echo $form['accounting_code_purchase']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_sell']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_sell'] ?>
+		  <?php echo $form['accounting_code_sell']->renderError() ?>
+        </td>
+      </tr>
+      <tr><td colspan="2"><i>Laisser vide pour utiliser celui du rayon</i></td></tr>
+  <?php endif ?>
+    </tbody>
+  </table>
+</form>
+
+<script type="text/javascript" language="JavaScript">
+/* <![CDATA[ */
+
+function checkPrices(){
+	var price_ht_displayed = parseFloat($F('katao_product_unit_price_euro'));
+	var price_ht_calculated = round3decimals(parseFloat($F('sell_price')) / (1+parseFloat($F('katao_product_margin'))/100) / (1+parseFloat($F('katao_product_tva_rate'))));
+	if (price_ht_displayed != price_ht_calculated) {
+		alert('ATTENTION : Le prix d\'achat HT ('+price_ht_displayed+' €) ne correspond pas à celui calculé ('+price_ht_calculated+' €).\n\nMerci de bien vouloir le modifier ou le calculer en cliquant sur la calculette\nà côté du champ "Prix de vente TTC".\n');
+		return false;
+	}
+	return true;
+}
+
+function computeUnitPriceWithTaxes(){
+	$('sell_price').value = round2decimals(parseFloat($F('katao_product_unit_price_euro')) * (1+parseFloat($F('katao_product_margin'))/100) * (1+parseFloat($F('katao_product_tva_rate'))));
+}
+
+function computeUnitPriceWithoutTaxes(){
+	$('katao_product_unit_price_euro').value = round3decimals(parseFloat($F('sell_price')) / (1+parseFloat($F('katao_product_margin'))/100) / (1+parseFloat($F('katao_product_tva_rate'))));
+}
+
+function computeMaxSolAmount(){
+	if (!$F('sol_percent')) {
+		$('sol_percent').value = 0;
+	}
+	if (!$F('sell_price')) {
+		computeUnitPriceWithTaxes();
+	}
+	$('katao_product_max_sol_amount').value = Math.floor(10 * parseFloat($F('sell_price')) * parseFloat($F('sol_percent')) / 100);
+}
+
+function computeSolPercent(){
+	$('sol_percent').value = Math.round(100 * parseFloat($F('katao_product_max_sol_amount')) / parseFloat($F('sell_price')) / 10);
+}
+
+function computeMargin(){
+	$('katao_product_margin').value = Math.round(100 * parseFloat($F('sell_price')) / (parseFloat($F('katao_product_unit_price_euro')) * (parseFloat($F('katao_product_tva_rate')) + 1)) - 100);
+}
+
+function round2decimals(value){
+	return Math.round(value*100)/100;
+}
+
+function round3decimals(value){
+	return Math.round(value*1000)/1000;
+}
+
+var margin = parseFloat($F('katao_product_margin'));
+if (1 >= margin) {
+	margin = 100 * margin;
+}
+$('katao_product_margin').value = margin;
+<?php if (!$sf_user->isJustSupplier()): ?>
+<?php if ($katao_product->isNew() && !$sf_request->isMethod('post')): ?>
+$('sell_price').value = '';
+$('sol_percent').value = <?php echo wpConfig::getDefaultProductSolPercent() ?>
+<?php else: ?>
+computeUnitPriceWithTaxes();
+computeSolPercent();
+<?php endif ?>
+<?php endif ?>
+
+/* ]]> */
+</script>

+ 80 - 0
apps/admin/modules/kataoProduct/templates/indexSuccess.php

@@ -0,0 +1,80 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des produits (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter" style="margin-bottom: 0px!important">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_product_filter') ?>
+			<?php echo select_tag('filter_supplier', options_for_select(KataoSupplierPeer::getAllSimple(), $filter_supplier, array('include_custom' => '&mdash;&nbsp;Fournisseur&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_product_category', options_for_select(KataoProductCategoryPeer::getAllSimple(), $filter_product_category, array('include_custom' => '&mdash;&nbsp;Rayon&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_product_family', options_for_select(KataoProductFamilyPeer::getAllGroupedByCategory(), $filter_product_family, array('include_custom' => '&mdash;&nbsp;Famille&nbsp;&mdash;'))) ?>
+			<?php echo image_tag('separator02.gif', array('alt' => '')) ?>&nbsp;<?php echo select_tag('filter_product_archived', options_for_select(array(CONST_YES => 'Oui', CONST_NO => 'Non'), $filter_product_archived, array('include_custom' => '&mdash;&nbsp;Archivé&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_product_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_product_search') ?>
+			Rechercher : <?php echo input_tag('search', $search, array('style' => 'width: 250px')) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Rechercher')) ?><div style="float:right"><a href="<?php echo url_for('@katao_product_search_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_productList)): ?>
+	<p>Aucun produit.</p>
+	<p><?php echo link_to('Ajouter un produit', '@katao_product_add', array('class' => 'add')) ?></p>
+<?php else : ?>
+  <?php echo link_to('Ajouter un produit', '@katao_product_add', array('class' => 'add')) ?>
+  <?php echo link_to('Archiver les produits sélectionnés (' . multiple_action_info_selected('katao_product') . ')', '@katao_product_archive_multiple', array('class' => 'archive', 'confirm' => 'Êtes-vous sûr de vouloir archiver les produits sélectionnés ?')) ?>
+  <?php echo link_to('Supprimer les produits sélectionnés (' . multiple_action_info_selected('katao_product') . ')', '@katao_product_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les produits sélectionnés ?')) ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_product') ?></th>
+	  <th nowrap="nowrap">Nom <?php echo sort_links($sf_request, 'name', 'kataoProduct/index') ?></th>
+	  <th nowrap="nowrap">HT <?php echo sort_links($sf_request, 'price', 'kataoProduct/index') ?></th>
+	<?php if (!$sf_user->isJustSupplier()): ?>
+	  <th nowrap="nowrap">Marge</th>
+	<?php endif ?>
+	  <th nowrap="nowrap">TVA</th>
+	<?php if (!$sf_user->isJustSupplier()): ?>
+	  <th nowrap="nowrap">TTC</th>
+	<?php endif ?>
+	  <th nowrap="nowrap"><?php echo wpConfig::getAdditionalCurrencyName() ?></th>
+	  <th nowrap="nowrap">Rayon / Famille <?php echo sort_links($sf_request, 'category', 'kataoProduct/index') ?></th>
+	  <th nowrap="nowrap">Fournisseur <?php echo sort_links($sf_request, 'supplier', 'kataoProduct/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_productList as/*(KataoProduct)*/ $katao_product): ?>
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_product', $katao_product->getId()) ?></td>
+		  <td><?php echo $katao_product->getName() ?></td>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_product->getUnitPriceEuroStr() ?></td>
+		<?php if (!$sf_user->isJustSupplier()): ?>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_product->getMarginStr() ?></td>
+		<?php endif ?>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_product->getTvaRateStr() ?></td>
+		<?php if (!$sf_user->isJustSupplier()): ?>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_product->getTotalPriceWithTaxesStr() ?></td>
+		<?php endif ?>
+		  <td nowrap="nowrap" style="text-align:right!important"><?php echo $katao_product->getMaxSolAmount() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product->getCategoryLink() ?> / <?php echo $katao_product->getFamilylink() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product->getSupplierName() ?></td>
+		  <td nowrap="nowrap">
+	    <?php echo catalyz_link_to_image_tag('@katao_product_edit?id=' . $katao_product->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+	    <?php echo catalyz_link_to_image_tag('@katao_product_edit_presentation?id=' . $katao_product->getId(), 'actions/presentation.png', array('title' => 'Modifier la présentation'), array('alt' => 'Modifier la présentation')) ?>
+	    <?php if ($katao_product->isDeletable()): ?>
+			<?php echo catalyz_link_to_image_tag('@katao_product_delete?id=' . $katao_product->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer ce produit ?'), array('alt' => 'Supprimer')) ?>
+		<?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoProduct/index?sort=%s%s', $sf_request->getParameter('sort', 'name'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_product') ?>
+<?php endif ?>

+ 82 - 0
apps/admin/modules/kataoProduct/templates/showSuccess.php

@@ -0,0 +1,82 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Produit : <?php echo $katao_product->getName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_product->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Reference:</th>
+      <td><?php echo $katao_product->getReference() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Name:</th>
+      <td><?php echo $katao_product->getName() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Url identifier:</th>
+      <td><?php echo $katao_product->getUrlIdentifier() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Description:</th>
+      <td><?php echo $katao_product->getDescription() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao product family:</th>
+      <td><?php echo $katao_product->getKataoProductFamilyId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Katao supplier:</th>
+      <td><?php echo $katao_product->getKataoSupplierId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Unit price sol:</th>
+      <td><?php echo $katao_product->getUnitPriceSol() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Unit price euro:</th>
+      <td><?php echo $katao_product->getUnitPriceEuro() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Tva rate:</th>
+      <td><?php echo $katao_product->getTvaRate() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Min order number:</th>
+      <td><?php echo $katao_product->getMinOrderNumber() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Margin:</th>
+      <td><?php echo $katao_product->getMargin() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Picture:</th>
+      <td><?php echo $katao_product->getPicture() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Delivery delay:</th>
+      <td><?php echo $katao_product->getDeliveryDelay() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Is archived:</th>
+      <td><?php echo $katao_product->getIsArchived() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_product->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_product->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoProduct/edit?id='.$katao_product->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoProduct/index') ?>">List</a>

+ 93 - 0
apps/admin/modules/kataoProductCategory/actions/actions.class.php

@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * kataoProductCategory actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoProductCategory
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoProductCategoryActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'order')) {
+            case 'name':
+                $criteria->$sort_method(KataoProductCategoryPeer::NAME);
+                break;
+            case 'accounting-code':
+                $criteria->$sort_method(KataoProductCategoryPeer::ACCOUNTING_CODE_SUFFIX);
+                break;
+            default:
+                $criteria->$sort_method(KataoProductCategoryPeer::SORT_ORDER);
+        }
+
+        $pager = new sfPropelPager('KataoProductCategory', sfConfig::get('app_pager'));
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_product_categoryList = $pager->getResults();
+    }
+
+    public function executeShow($request) {
+        $this->katao_product_category = KataoProductCategoryPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_product_category, 'Rayon #' . $request->getParameter('id') . ' inconnu.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoProductCategoryForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $this->form = new KataoProductCategoryForm(KataoProductCategoryPeer::retrieveByPk($request->getParameter('id')));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoProductCategoryForm(KataoProductCategoryPeer::retrieveByPk($request->getParameter('id')));
+
+        $this->form->bind($request->getParameter('katao_product_category'));
+        if ($this->form->isValid()) {
+            $katao_product_category = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Rayon "' . $katao_product_category->getName() . '" sauvé avec succès.');
+            $this->redirect('kataoProductCategory/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_product_category = KataoProductCategoryPeer::retrieveByPk($request->getParameter('id')), 'Rayon #' . $request->getParameter('id') . ' inconnu.');
+        $this->redirectWithErrorIf(!$katao_product_category->isDeletable());
+
+        $katao_product_category->delete();
+
+        wpFlashMessages::addConfirmation('Rayon "' . $katao_product_category->getName() . '" supprimé avec succès.');
+        $this->redirect('kataoProductCategory/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_product_category')) {
+            foreach (KataoProductCategoryPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_product_category'))) as/*(KataoProductCategory)*/ $katao_product_category) {
+                if ($katao_product_category->isDeletable()) {
+                    $katao_product_category->delete();
+                }
+            }
+
+            wpPersistenceManager::cleanSelection('katao_product_category');
+            wpFlashMessages::addConfirmation('Les rayons sélectionnés ont été supprimés avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins un rayon.');
+        }
+
+        $this->redirect('kataoProductCategory/index');
+    }
+}

+ 2 - 0
apps/admin/modules/kataoProductCategory/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  credentials: [[ admin, seo ]]

+ 42 - 0
apps/admin/modules/kataoProductCategory/templates/editSuccess.php

@@ -0,0 +1,42 @@
+<?php $katao_product_category = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_product_category->isNew() ? 'Ajout' : 'Modification' ?> d'un rayon</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoProductCategory/update'.(!$katao_product_category->isNew() ? '?id='.$katao_product_category->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoProductCategory/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['name'] ?>
+		  <?php echo $form['name']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['accounting_code_suffix']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['accounting_code_suffix'] ?>
+		  <?php echo $form['accounting_code_suffix']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['sort_order']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['sort_order'] ?>
+		  <?php echo $form['sort_order']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 35 - 0
apps/admin/modules/kataoProductCategory/templates/indexSuccess.php

@@ -0,0 +1,35 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des rayons (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<?php if (empty($katao_product_categoryList)): ?>
+	<p>Aucun rayon.</p>
+	<p><?php echo link_to('Ajouter un rayon', '@katao_product_category_add', array('class' => 'add')) ?></p>
+<?php else : ?>
+  <?php echo link_to('Ajouter un rayon', '@katao_product_category_add', array('class' => 'add')) ?>
+  <?php echo link_to('Supprimer les rayons sélectionnés (' . multiple_action_info_selected('katao_product_category') . ')', '@katao_product_category_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les rayons sélectionnés ?')) ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_product_category') ?></th>
+	  <th nowrap="nowrap">Nom <?php echo sort_links($sf_request, 'name', 'kataoProductCategory/index') ?></th>
+	  <th nowrap="nowrap">Code comptable <?php echo sort_links($sf_request, 'accounting-code', 'kataoProductCategory/index') ?></th>
+	  <th nowrap="nowrap">Ordre <?php echo sort_links($sf_request, 'order', 'kataoProductCategory/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_product_categoryList as/*(KataoProductCategory)*/ $katao_product_category): ?>
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_product_category', $katao_product_category->getId()) ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product_category->getName() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product_category->getAccountingCodeSuffix() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product_category->getSortOrder() ?></td>
+		  <td nowrap="nowrap">
+	    <?php echo catalyz_link_to_image_tag('@katao_product_category_edit?id=' . $katao_product_category->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+	    <?php if ($katao_product_category->isDeletable()): ?>
+			<?php echo catalyz_link_to_image_tag('@katao_product_category_delete?id=' . $katao_product_category->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer ce rayon ?'), array('alt' => 'Supprimer')) ?>
+		<?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoProductCategory/index?sort=%s%s', $sf_request->getParameter('sort', 'order'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_product_category') ?>
+<?php endif ?>

+ 38 - 0
apps/admin/modules/kataoProductCategory/templates/showSuccess.php

@@ -0,0 +1,38 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Rayon : <?php echo $katao_product_category->getName() ?></h1></div>
+</div>
+
+<table>
+  <tbody>
+    <tr valign="top">
+      <th>Id:</th>
+      <td><?php echo $katao_product_category->getId() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Name:</th>
+      <td><?php echo $katao_product_category->getName() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Url identifier:</th>
+      <td><?php echo $katao_product_category->getUrlIdentifier() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Sort order:</th>
+      <td><?php echo $katao_product_category->getSortOrder() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Created at:</th>
+      <td><?php echo $katao_product_category->getCreatedAt() ?></td>
+    </tr>
+    <tr valign="top">
+      <th>Updated at:</th>
+      <td><?php echo $katao_product_category->getUpdatedAt() ?></td>
+    </tr>
+  </tbody>
+</table>
+
+<hr />
+
+<a href="<?php echo url_for('kataoProductCategory/edit?id='.$katao_product_category->getId()) ?>">Edit</a>
+&nbsp;
+<a href="<?php echo url_for('kataoProductCategory/index') ?>">List</a>

+ 106 - 0
apps/admin/modules/kataoProductFamily/actions/actions.class.php

@@ -0,0 +1,106 @@
+<?php
+
+/**
+ * kataoProductFamily actions.
+ *
+ * @package www.katao.fr
+ * @subpackage kataoProductFamily
+ * @author Your name here
+ * @version SVN: $Id: actions.class.php 8507 2008-04-17 17:32:20Z fabien $
+ */
+class kataoProductFamilyActions extends wpActions {
+    public function executeIndex() {
+        $criteria = new Criteria();
+        $criteria->addJoin(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, KataoProductCategoryPeer::ID);
+
+        $sort_method = $this->getCriteriaSortMethod();
+        switch ($this->sort = $this->getRequestParameter('sort', 'name')) {
+            case 'category':
+                $criteria->$sort_method(KataoProductCategoryPeer::NAME);
+                break;
+            default:
+                $criteria->$sort_method(KataoProductFamilyPeer::NAME);
+        }
+
+        if ('' != $this->filter_product_category = $this->getUser()->getAttribute('katao_product_family_filter_product_category')) {
+            $criteria->add(KataoProductFamilyPeer::KATAO_PRODUCT_CATEGORY_ID, $this->filter_product_category);
+        }
+
+        $pager = new sfPropelPager('KataoProductFamily', sfConfig::get('app_pager'));
+        $pager->setPeerMethod('doSelectJoinKataoProductCategory');
+        $pager->setCriteria($criteria);
+        $pager->setPage($this->getRequestParameter('page', 1));
+        $pager->init();
+        $this->pager = $pager;
+
+        $this->katao_product_familyList = $pager->getResults();
+    }
+
+    public function executeFilter($request) {
+        $this->getUser()->setAttribute('katao_product_family_filter_product_category', $request->getParameter('filter_product_category'));
+        return $this->redirect('kataoProductFamily/index');
+    }
+
+    public function executeFilterReset($request) {
+        $this->getUser()->setAttribute('katao_product_family_filter_product_category', '');
+        return $this->redirect('kataoProductFamily/index');
+    }
+
+    public function executeShow($request) {
+        $this->katao_product_family = KataoProductFamilyPeer::retrieveByPk($request->getParameter('id'));
+        $this->redirectWithErrorUnless($this->katao_product_family, 'Famille #' . $request->getParameter('id') . ' inconnue.');
+    }
+
+    public function executeCreate() {
+        $this->form = new KataoProductFamilyForm();
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeEdit($request) {
+        $this->form = new KataoProductFamilyForm(KataoProductFamilyPeer::retrieveByPk($request->getParameter('id')));
+    }
+
+    public function executeUpdate($request) {
+        $this->redirectWithErrorUnless($request->isMethod('post'));
+
+        $this->form = new KataoProductFamilyForm(KataoProductFamilyPeer::retrieveByPk($request->getParameter('id')));
+
+        $this->form->bind($request->getParameter('katao_product_family'));
+        if ($this->form->isValid()) {
+            $katao_product_family = $this->form->save();
+
+            wpFlashMessages::addConfirmation('Famille "' . $katao_product_family->getName() . '" sauvée avec succès.');
+            $this->redirect('kataoProductFamily/index');
+        }
+
+        $this->setTemplate('edit');
+    }
+
+    public function executeDelete($request) {
+        $this->redirectWithErrorUnless($katao_product_family = KataoProductFamilyPeer::retrieveByPk($request->getParameter('id')), 'Famille #' . $request->getParameter('id') . ' inconnue.');
+        $this->redirectWithErrorIf(!$katao_product_family->isDeletable());
+
+        $katao_product_family->delete();
+
+        wpFlashMessages::addConfirmation('Famille "' . $katao_product_family->getName() . '" supprimée avec succès.');
+        $this->redirect('kataoProductFamily/index');
+    }
+
+    public function executeDeleteMultiple($request) {
+        if (!wpPersistenceManager::isEmpty('katao_product_family')) {
+            foreach (KataoProductFamilyPeer::retrieveByPKs(array_keys(wpPersistenceManager::getSelectedItems('katao_product_family'))) as/*(KataoProductFamily)*/ $katao_product_family) {
+                if ($katao_product_family->isDeletable()) {
+                    $katao_product_family->delete();
+                }
+            }
+
+            wpPersistenceManager::cleanSelection('katao_product_family');
+            wpFlashMessages::addConfirmation('Les familles sélectionnées ont été supprimées avec succès.');
+        } else {
+            wpFlashMessages::addWarning('Merci de sélectionner au moins une famille.');
+        }
+
+        $this->redirect('kataoProductFamily/index');
+    }
+}

+ 2 - 0
apps/admin/modules/kataoProductFamily/config/security.yml

@@ -0,0 +1,2 @@
+all:
+  credentials: [[ admin, seo ]]

+ 35 - 0
apps/admin/modules/kataoProductFamily/templates/editSuccess.php

@@ -0,0 +1,35 @@
+<?php $katao_product_family = $form->getObject() ?>
+<div class="content-add01">
+	<div class="heading01"><h1><?php echo $katao_product_family->isNew() ? 'Ajout' : 'Modification' ?> d'une famille</h1></div>
+</div>
+
+<form action="<?php echo url_for('kataoProductFamily/update'.(!$katao_product_family->isNew() ? '?id='.$katao_product_family->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
+  <table>
+    <tfoot>
+      <tr>
+        <td colspan="2">
+          <br /><input type="submit" value="Sauver" /> ou <a href="<?php echo url_for('kataoProductFamily/index') ?>">annuler</a>
+        </td>
+      </tr>
+    </tfoot>
+    <tbody>
+      <?php echo $form->renderGlobalErrors() ?>
+      <tr valign="top">
+        <th align="left"><?php echo $form['katao_product_category_id']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['katao_product_category_id'] ?>
+		  <?php echo $form['katao_product_category_id']->renderError() ?>
+        </td>
+      </tr>
+      <tr valign="top">
+        <th align="left"><?php echo $form['name']->renderLabel() ?></th>
+        <td>
+          <?php echo $form['name'] ?>
+		  <?php echo $form['name']->renderError() ?>
+
+        <?php echo $form['id'] ?>
+        </td>
+      </tr>
+    </tbody>
+  </table>
+</form>

+ 44 - 0
apps/admin/modules/kataoProductFamily/templates/indexSuccess.php

@@ -0,0 +1,44 @@
+<div class="content-add01">
+	<div class="heading01"><h1>Liste des familles (<?php echo $pager->getNbResults() ?>)</h1></div>
+</div>
+
+<div class="filter">
+	<div class="filter-left">&nbsp;</div>
+	<div class="filter-middle">
+		<?php echo form_tag('@katao_product_family_filter') ?>
+			<?php echo select_tag('filter_product_category', options_for_select(KataoProductCategoryPeer::getAllSimple(), $filter_product_category, array('include_custom' => '&mdash;&nbsp;Rayon&nbsp;&mdash;'))) ?>
+			<?php echo submit_tag('', array('class' => 'btn-search', 'title' => 'Filtrer')) ?><div style="float:right"><a href="<?php echo url_for('@katao_product_family_filter_reset') ?>">[annuler]</a></div>
+		</form>
+	</div>
+	<div class="filter-right">&nbsp;</div>
+</div>
+
+<?php if (empty($katao_product_familyList)): ?>
+	<p>Aucune famille.</p>
+	<p><?php echo link_to('Ajouter une famille', '@katao_product_family_add', array('class' => 'add')) ?></p>
+<?php else : ?>
+  <?php echo link_to('Ajouter une famille', '@katao_product_family_add', array('class' => 'add')) ?>
+  <?php echo link_to('Supprimer les familles sélectionnées (' . multiple_action_info_selected('katao_product_family') . ')', '@katao_product_family_delete_multiple', array('class' => 'delete', 'confirm' => 'Êtes-vous sûr de vouloir supprimer les familles sélectionnées ?')) ?>
+  <table class="admin-list">
+    <tr>
+	  <th nowrap="nowrap" width="1%"><?php echo multiple_action_checkbox_all('katao_product_family') ?></th>
+	  <th nowrap="nowrap">Nom <?php echo sort_links($sf_request, 'name', 'kataoProductFamily/index') ?></th>
+	  <th nowrap="nowrap">Rayon <?php echo sort_links($sf_request, 'category', 'kataoProductFamily/index') ?></th>
+	  <th nowrap="nowrap" width="1%">Actions</th>
+	</tr>
+	<?php foreach ($katao_product_familyList as/*(KataoProductFamily)*/ $katao_product_family): ?>
+    <tr valign="top" class="line">
+		  <td class="center"><?php echo multiple_action_checkbox_line('katao_product_family', $katao_product_family->getId()) ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product_family->getName() ?></td>
+		  <td nowrap="nowrap"><?php echo $katao_product_family->getKataoProductCategoryLink() ?></td>
+		  <td nowrap="nowrap">
+	    <?php echo catalyz_link_to_image_tag('@katao_product_family_edit?id=' . $katao_product_family->getId(), 'actions/edit.png', array('title' => 'Modifier'), array('alt' => 'Modifier')) ?>
+	<?php if ($katao_product_family->isDeletable()): ?>
+		<?php echo catalyz_link_to_image_tag('@katao_product_family_delete?id=' . $katao_product_family->getId(), 'actions/delete.png', array('title' => 'Supprimer', 'confirm' => 'Êtes-vous sûr de vouloir supprimer cette famille ?'), array('alt' => 'Supprimer')) ?>
+	<?php endif ?>
+	  </td>
+	</tr>
+  <?php endforeach ?>
+  </table>
+  <?php echo pager($pager, sprintf('kataoProductFamily/index?sort=%s%s', $sf_request->getParameter('sort', 'name'), $sf_request->hasParameter('desc')?'&desc=on':''), 'katao_product_family') ?>
+<?php endif ?>

Some files were not shown because too many files changed in this diff