Browse Source

[Backend] Producteurs admin : ajouter champs commentaire #1166

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
ee34f7ce56
5 changed files with 75 additions and 30 deletions
  1. +1
    -0
      backend/views/producer-admin/_form.php
  2. +42
    -26
      backend/views/producer-admin/index.php
  3. +4
    -2
      common/logic/Producer/Producer/Model/Producer.php
  4. +2
    -2
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  5. +26
    -0
      console/migrations/m230825_091434_add_column_producer_admin_comment.php

+ 1
- 0
backend/views/producer-admin/_form.php View File

@@ -54,6 +54,7 @@ use common\logic\Producer\Producer\Model\Producer;
<?= $form->field($model, 'latitude') ?>
<?= $form->field($model, 'longitude') ?>
<?= $form->field($model, 'code')->label('Code d\'accès') ?>
<?= $form->field($model, 'admin_comment')->textarea(['rows' => 7]) ?>

<h3>Facturation</h3>
<?= $form->field($model, 'option_billing_type')

+ 42
- 26
backend/views/producer-admin/index.php View File

@@ -157,47 +157,63 @@ $this->addButton(['label' => 'Nouveau producteur <span class="glyphicon glyphico
}
],*/
[
'attribute' => 'À facturer / chiffre d\'affaire',
'label' => 'À facturer / chiffre d\'affaire',
'label' => 'Facturation',
'format' => 'raw',
'value' => function($producer) use ($producerManager) {

$str = '';
if($producerManager->isBillingFrequencyMonthly($producer)) {
$str .= $producerManager->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1);
}
elseif($producerManager->isBillingFrequencyQuarterly($producer)) {
$str .= $producerManager->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3);
}
elseif($producerManager->isBillingFrequencyBiannual($producer)) {
$str .= $producerManager->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6);
}
$str .= '<ul style="margin: 0px;padding-left: 15px;">';

$isBillingFrequencyMonthly = $producerManager->isBillingFrequencyMonthly($producer);
$summaryMonthly = $producerManager->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1);
$isBillingFrequencyQuaterly = $producerManager->isBillingFrequencyQuarterly($producer);
$summaryQuaterly = $producerManager->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3);
$isBillingFrequencyBiannual = $producerManager->isBillingFrequencyBiannual($producer);
$summaryBiannual = $producerManager->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6);

if(($isBillingFrequencyMonthly && $summaryMonthly)
|| ($isBillingFrequencyQuaterly && $summaryQuaterly)
|| ($isBillingFrequencyBiannual && $summaryBiannual)) {

if($producer->option_billing_reduction && strlen($str)) {
$str .= '<br /><u>Avec réduction</u> : ';
if($producer->option_billing_reduction_percentage) {
$str .= ' '.$producer->option_billing_reduction_percentage.'&nbsp;%';
$str .= '<li>';
if ($isBillingFrequencyMonthly && $summaryMonthly) {
$str .= $summaryMonthly;
} elseif ($isBillingFrequencyQuaterly && $summaryQuaterly) {
$str .= $summaryQuaterly;
} elseif ($isBillingFrequencyBiannual && $summaryBiannual) {
$str .= $summaryBiannual;
}

if ($producer->option_billing_reduction && strlen($str)) {
$str .= '<br /><u>Avec réduction</u> : ';
if ($producer->option_billing_reduction_percentage) {
$str .= ' ' . $producer->option_billing_reduction_percentage . '&nbsp;%';
}
}
$str .= '</li>';

$str .= '<li>Facturation '.strtolower(Producer::$billingFrequencyArray[$producer->option_billing_frequency]).'</li>';
}

if($producer->option_billing_permanent_transfer) {
$str .= '<li>Virement permanent : <strong>'.Price::format($producer->option_billing_permanent_transfer_amount).'</strong></li>';
}

$str .= '</ul>';

return $str;
}
],
[
'attribute' => 'Facturation',
'label' => 'Détails facturation',
'attribute' => 'admin_comment',
'label' => 'Commentaire',
'format' => 'raw',
'value' => function($model) {
$str = '<ul style="margin: 0px;padding-left: 15px;">';
$str .= '<li>'.Producer::$billingFrequencyArray[$model->option_billing_frequency].'</li>';

if($model->option_billing_permanent_transfer) {
$str .= '<li>Virement permanent : <strong>'.Price::format($model->option_billing_permanent_transfer_amount).'</strong></li>';
'value' => function($producer) {
if($producer->admin_comment) {
return $producer->admin_comment;
}

$str .= '</ul>';

return $str;
return '';
}
],
[

+ 4
- 2
common/logic/Producer/Producer/Model/Producer.php View File

@@ -220,7 +220,8 @@ class Producer extends ActiveRecordCommon
'option_csv_separator',
'option_point_sale_wording',
'option_testimony',
'contact_email'
'contact_email',
'admin_comment',
],
'string'
],
@@ -411,7 +412,8 @@ class Producer extends ActiveRecordCommon
'longitude' => 'Longitude',
'option_testimony' => 'Témoignage',
'option_time_saved' => 'Temps gagné / semaine',
'contact_email' => 'Email de contact'
'contact_email' => 'Email de contact',
'admin_comment' => 'Commentaire'
];
}


+ 2
- 2
common/logic/Producer/Producer/Repository/ProducerRepository.php View File

@@ -193,7 +193,7 @@ class ProducerRepository extends AbstractRepository
if ($isBold) $text .= '<strong>';
$text .= $this->producerPriceRangeRepository->getAmountToBeBilledByTurnover($turnover, true);
if ($isBold) $text .= '</strong>';
$text .= ' / ' . Price::format($turnover, 0);
$text .= ' (' . Price::format($turnover, 0). ' CA)';
$text .= '<br />';

$sumInvoicePrice += $this->producerPriceRangeRepository->getAmountToBeBilledByTurnover($turnover, false);
@@ -205,7 +205,7 @@ class ProducerRepository extends AbstractRepository
}
}

if($numberOfMonths > 1) {
if($numberOfMonths > 1 && $sumInvoicePrice > 0) {
$text .= '<br />Total : <strong>'.Price::format($sumInvoicePrice, 0).'</strong>';
}


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

@@ -0,0 +1,26 @@
<?php

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

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

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

Loading…
Cancel
Save