Browse Source

first commit

Jean Roussel 5 years ago
commit
04dc40eb19
100 changed files with 9297 additions and 0 deletions
  1. 5 0
      .gitignore
  2. 9 0
      apps/admin/config/adminConfiguration.class.php
  3. 376 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. 611 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. 0 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
+ 376 - 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>