Browse Source

[Administration] Paramètres > paiement en ligne : montant minimum éditable dans les paramètres #159

refactoring
Guillaume Bourgeois 2 years ago
parent
commit
5c24bf4ad5
5 changed files with 47 additions and 4 deletions
  1. +3
    -0
      backend/views/producer/update.php
  2. +16
    -2
      common/models/Producer.php
  3. +26
    -0
      console/migrations/m221115_085843_producer_add_option_online_payment_minimum_amount.php
  4. +1
    -1
      producer/models/CreditForm.php
  5. +1
    -1
      producer/views/credit/add.php

+ 3
- 0
backend/views/producer/update.php View File

0 => 'Non', 0 => 'Non',
1 => 'Oui', 1 => 'Oui',
], []); ?> ], []); ?>
<?= $form->field($model, 'option_online_payment_minimum_amount')
->hint('Valeur par défaut si non défini : '.Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT.' €')
->textInput(); ?>
<?= $form->field($model, 'option_stripe_mode_test')->dropDownList([ <?= $form->field($model, 'option_stripe_mode_test')->dropDownList([
0 => 'Non', 0 => 'Non',
1 => 'Oui' 1 => 'Oui'

+ 16
- 2
common/models/Producer.php View File



var $secret_key_payplug; var $secret_key_payplug;


const ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT = 25;

/** /**
* @inheritdoc * @inheritdoc
*/ */
'order_deadline_sunday', 'order_deadline_sunday',
'id_tax_rate_default', 'id_tax_rate_default',
'document_quotation_duration', 'document_quotation_duration',
'option_dashboard_number_distributions'
'option_dashboard_number_distributions',
'option_online_payment_minimum_amount'
], ],
'integer' 'integer'
], ],
'option_export_evoliz' => 'Activer l\'export vers Evoliz', 'option_export_evoliz' => 'Activer l\'export vers Evoliz',
'latest_version_opendistrib' => 'Dernière version d\'Opendistrib', 'latest_version_opendistrib' => 'Dernière version d\'Opendistrib',
'option_csv_separator' => 'Séparateur de colonnes (CSV)', 'option_csv_separator' => 'Séparateur de colonnes (CSV)',
'option_display_message_new_opendistrib_version' => 'Afficher les messages de mise à jour du logiciel Opendistrib'
'option_display_message_new_opendistrib_version' => 'Afficher les messages de mise à jour du logiciel Opendistrib',
'option_online_payment_minimum_amount' => 'Paiement en ligne : montant minimum'
]; ];
} }


$this->latest_version_opendistrib = array_values($versionsArray)[0]; $this->latest_version_opendistrib = array_values($versionsArray)[0];
$this->save(); $this->save();
} }

public function getOnlinePaymentMinimumAmount()
{
$onlinePaymentMinimumAmount = self::getConfig('option_online_payment_minimum_amount');
if(!$onlinePaymentMinimumAmount) {
$onlinePaymentMinimumAmount = self::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT;
}

return $onlinePaymentMinimumAmount;
}
} }

+ 26
- 0
console/migrations/m221115_085843_producer_add_option_online_payment_minimum_amount.php View File

<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m221115_085843_producer_add_option_online_payment_minimum_amount
*/
class m221115_085843_producer_add_option_online_payment_minimum_amount extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('producer', 'option_online_payment_minimum_amount', Schema::TYPE_INTEGER);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('producer', 'option_online_payment_minimum_amount');
}
}

+ 1
- 1
producer/models/CreditForm.php View File

{ {
return [ return [
[['amount'], 'required'], [['amount'], 'required'],
[['amount'], 'double', 'min' => 25],
[['amount'], 'double', 'min' => Producer::getOnlinePaymentMinimumAmount()],
]; ];
} }



+ 1
- 1
producer/views/credit/add.php View File

'template' => '{label}<div class="input-group input-group-lg">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}', 'template' => '{label}<div class="input-group input-group-lg">{input}<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span></div>{hint}',
]) ])
->label('Quel montant souhaitez-vous créditer ?') ->label('Quel montant souhaitez-vous créditer ?')
->hint('Montant minimum : 25 €'); ?>
->hint('Montant minimum : '.Producer::getOnlinePaymentMinimumAmount().' €'); ?>


<div class="form-group"> <div class="form-group">
<?= Html::submitButton('<span class="glyphicon glyphicon-lock"></span> Payer', ['class' => 'btn btn-primary'] <?= Html::submitButton('<span class="glyphicon glyphicon-lock"></span> Payer', ['class' => 'btn btn-primary']

Loading…
Cancel
Save