KataoConfigForm.class.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * KataoConfig form.
  4. *
  5. * @package form
  6. * @subpackage katao_config
  7. * @version SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
  8. */
  9. class KataoConfigForm extends BaseKataoConfigForm {
  10. public function configure() {
  11. $this->widgetSchema['katao_member_id'] = new sfWidgetFormSelect(array('choices' => KataoMemberPeer::getAllGroupedByNode()), array('style' => 'width:250px'));
  12. $this->widgetSchema['siret_number'] = new sfWidgetFormInput(array(), array('maxlength' => 14));
  13. $this->widgetSchema['tva_number'] = new sfWidgetFormInput(array(), array('maxlength' => 13));
  14. $this->widgetSchema['default_product_picture'] = new wpWidgetFormInputFile(array(), array('file_src' => $this->getObject()->getDefaultProductPicture()));
  15. $this->validatorSchema['default_product_picture'] = new sfValidatorFile(array('required' => false));
  16. $this->widgetSchema['name'] = new sfWidgetFormInput(array(), array('style' => 'width:250px'));
  17. $this->widgetSchema['address'] = new sfWidgetFormTextarea(array(), array('style' => 'width:250px; height:50px'));
  18. $this->widgetSchema['phone'] = new sfWidgetFormInput(array(), array('style' => 'width:250px'));
  19. $this->widgetSchema['email'] = new sfWidgetFormInput(array(), array('style' => 'width:250px'));
  20. $this->widgetSchema['default_product_margin'] = new sfWidgetFormInput(array(), array('style' => 'width:25px'));
  21. $this->widgetSchema['default_product_sol_percent'] = new sfWidgetFormInput(array(), array('style' => 'width:25px'));
  22. $this->widgetSchema['cart_validation_days_number'] = new sfWidgetFormInput(array(), array('style' => 'width:25px'));
  23. $this->widgetSchema['initial_transactions_count'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  24. $this->widgetSchema['initial_transactions_sum'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  25. $this->widgetSchema['member_fee'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  26. $this->widgetSchema['accounting_code_prefix_purchase'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  27. $this->widgetSchema['accounting_code_prefix_sell'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  28. $this->widgetSchema['accounting_code_bank'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  29. $this->widgetSchema['accounting_code_bank_sol'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  30. $this->widgetSchema['accounting_code_credit'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  31. $this->widgetSchema['accounting_code_error_adjustment_positive'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  32. $this->widgetSchema['accounting_code_error_adjustment_negative'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  33. $this->widgetSchema['accounting_code_discount'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  34. $this->widgetSchema['accounting_code_sol_discount'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  35. $this->widgetSchema['accounting_code_fees_shipping'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  36. $this->widgetSchema['accounting_code_fees_billing'] = new sfWidgetFormInput(array(), array('style' => 'width:70px'));
  37. $this->widgetSchema['debug_email'] = new sfWidgetFormInput(array(), array('style' => 'width:250px'));
  38. $this->widgetSchema->setLabels(array(
  39. 'katao_member_id' => 'Gérant',
  40. 'name' => 'Nom',
  41. 'address' => 'Adresse',
  42. 'phone' => 'Téléphone',
  43. 'email' => 'Email',
  44. 'siret_number' => 'N° SIRET',
  45. 'tva_number' => 'N° TVA',
  46. 'rcs_number' => 'N° RCS',
  47. 'capital' => 'Capital',
  48. 'initial_transactions_count' => 'Nombre initial',
  49. 'initial_transactions_sum' => 'Volume initial',
  50. 'cart_validation_days_number' => 'Délai validation paniers',
  51. 'mailing_list_email' => 'Email newsletter',
  52. 'accounting_code_prefix_purchase' => 'Achat (préfixe)',
  53. 'accounting_code_prefix_sell' => 'Vente (préfixe)',
  54. 'accounting_code_bank' => 'Banque (€)',
  55. 'accounting_code_bank_sol' => 'Banque (' . wpConfig::getAdditionalCurrencyName() . ')',
  56. 'accounting_code_credit' => 'Avoir (€)',
  57. 'accounting_code_error_adjustment_positive' => 'Ecart d\'ajustement (faveur)',
  58. 'accounting_code_error_adjustment_negative' => 'Ecart d\'ajustement (défaveur)',
  59. 'accounting_code_discount' => 'Remise (€)',
  60. 'accounting_code_sol_discount' => 'Remise (' . wpConfig::getAdditionalCurrencyName() . ')',
  61. 'accounting_code_fees_shipping' => 'Frais de port',
  62. 'accounting_code_fees_billing' => 'Frais de facturation',
  63. 'default_product_picture' => 'Photo par défaut',
  64. 'default_product_margin' => 'Marge par défaut',
  65. 'default_product_sol_percent' => 'Part de ' . wpConfig::getAdditionalCurrencyName() . ' par défaut',
  66. 'member_fee' => 'Cotisation annuelle adhérents',
  67. 'additional_currency_name' => 'Nom monnaie complémentaire',
  68. 'debug_email' => 'Email de redirection',
  69. 'bank_name' => 'Nom de la banque',
  70. 'bank_account' => 'N° de compte',
  71. ));
  72. }
  73. public function doSave($con = null) {
  74. $file = $this->getValue('default_product_picture');
  75. if ($file && is_object($file)) {
  76. if (is_file(sfConfig::get('sf_web_dir') . $this->getObject()->getDefaultProductPicture())) {
  77. unlink(sfConfig::get('sf_web_dir') . $this->getObject()->getDefaultProductPicture());
  78. }
  79. $filename = sha1($file->getOriginalName()) . $file->getExtension($file->getOriginalExtension());
  80. $file->save(sfConfig::get('sf_upload_dir') . '/repository/produits/' . $filename);
  81. } elseif (!empty($_REQUEST['RemovePicture'])) {
  82. if (is_file(sfConfig::get('sf_web_dir') . $this->getObject()->getDefaultProductPicture())) {
  83. unlink(sfConfig::get('sf_web_dir') . $this->getObject()->getDefaultProductPicture());
  84. }
  85. $this->getObject()->setDefaultProductPicture(null);
  86. }
  87. return parent::doSave($con);
  88. }
  89. public function updateObject($values = null) {
  90. $default_product_picture = $this->getObject()->getDefaultProductPicture();
  91. $object = parent::updateObject($values);
  92. $file = $this->getValue('default_product_picture');
  93. if ($file && is_object($file)) {
  94. $object->setDefaultProductPicture(str_replace(sfConfig::get('sf_web_dir'), '', $object->getDefaultProductPicture()));
  95. } else {
  96. $object->setDefaultProductPicture($default_product_picture);
  97. }
  98. return $object;
  99. }
  100. }