Преглед изворни кода

[backend] Documents : gestion de l'affichage du détail des commandes dans les exports PDF

refactoring
Guillaume пре 4 година
родитељ
комит
91290f4994
8 измењених фајлова са 134 додато и 47 уклоњено
  1. +22
    -0
      backend/views/document/_download_product_line.php
  2. +33
    -23
      backend/views/document/download.php
  3. +8
    -0
      backend/views/producer/update.php
  4. +25
    -20
      backend/web/css/document/download.css
  5. +5
    -1
      backend/web/sass/document/download.scss
  6. +17
    -1
      common/models/Document.php
  7. +4
    -2
      common/models/Producer.php
  8. +20
    -0
      console/migrations/m200225_153956_document_display_orders.php

+ 22
- 0
backend/views/document/_download_product_line.php Прегледај датотеку

@@ -0,0 +1,22 @@
<tr class="<?php if(isset($displayOrders) && $displayOrders): ?>order<?php endif; ?>">
<td class="align-left">
<?= Html::encode($productOrder->product->name) ?>
<?php if($productOrder->unit == 'piece' && isset($productOrder->product->weight) && $productOrder->product->weight): ?>
<span class="weight"> / <?= $productOrder->product->weight ?> g</span>
<?php endif; ?>
<?php if(strlen($productOrder->product->description)): ?>
<br /><small><?= Html::encode($productOrder->product->description) ?></small>
<?php endif; ?>
</td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<td class="align-center"><?= Price::format($productOrder->getPrice()) ?></td>
<?php endif; ?>
<td class="align-center"><?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?></td>
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td>
<?php endif; ?>
<td class="align-center"><?= Price::format($productOrder->getPrice() * $productOrder->quantity) ?></td>
<?php endif; ?>
</tr>

+ 33
- 23
backend/views/document/download.php Прегледај датотеку

@@ -61,32 +61,42 @@
</tr>
</thead>
<tbody>
<?php foreach($document->getProductsOrders() as $product): ?>
<?php foreach($product as $productOrder): ?>
<tr>
<td class="align-left">
<?= Html::encode($productOrder->product->name) ?>
<?php if($productOrder->unit == 'piece' && isset($productOrder->product->weight) && $productOrder->product->weight): ?>
<span class="weight"> / <?= $productOrder->product->weight ?> g</span>
<?php endif; ?>
<?php if(strlen($productOrder->product->description)): ?>
<br /><small><?= Html::encode($productOrder->product->description) ?></small>
<?php if($document->isDisplayOrders()): ?>
<?php foreach($document->orders as $order): ?>
<tr>
<td>
<strong><?= Html::encode($order->getUsername()) ; ?></strong>
le <?= date('d/m/Y', strtotime($order->date)) ?>
</td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<td class="align-center"></td>
<?php endif; ?>
</td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<td class="align-center"><?= Price::format($productOrder->getPrice()) ?></td>
<?php endif; ?>
<td class="align-center"><?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?></td>
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td>
<td></td>
<td></td>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<td class="align-center"></td>
<?php endif; ?>
<td class="align-center"></td>
<?php endif; ?>
<td class="align-center"><?= Price::format($productOrder->getPrice() * $productOrder->quantity) ?></td>
<?php endif; ?>
</tr>
</tr>
<?php foreach($order->productOrder as $productOrder): ?>
<?= $this->render('_download_product_line', [
'productOrder' => $productOrder,
'displayOrders' => true,
]) ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($document->getProductsOrders() as $product): ?>
<?php foreach($product as $productOrder): ?>
<?= $this->render('_download_product_line', [
'productOrder' => $productOrder,
]) ?>
<?php endforeach; ?>
<?php endforeach; ?>
<?php endif; ?>
<?php if(Yii::$app->controller->getClass() != 'DeliveryNote'): ?>
<?php if(GlobalParam::getCurrentProducer()->taxRate->value != 0): ?>
<tr>

+ 8
- 0
backend/views/producer/update.php Прегледај датотеку

@@ -308,6 +308,14 @@ $this->addBreadcrumb($this->getTitle()) ;
<?= $form->field($model, 'document_invoice_first_reference') ; ?>
<?= $form->field($model, 'document_delivery_note_prefix') ; ?>
<?= $form->field($model, 'document_delivery_note_first_reference') ; ?>
<?= $form->field($model, 'document_display_orders_invoice')->dropDownList([
0 => 'Non',
1 => 'Oui'
]) ; ?>
<?= $form->field($model, 'document_display_orders_delivery_note')->dropDownList([
0 => 'Non',
1 => 'Oui'
]) ; ?>
<?= $form->field($model, 'document_infos_bottom')
->textarea(['rows' => 15]) ?>
<?= $form->field($model, 'document_infos_quotation')

+ 25
- 20
backend/web/css/document/download.css Прегледај датотеку

@@ -1,52 +1,57 @@
/* line 5, ../../sass/document/download.scss */
body {
padding-bottom: 200px;
}

/* line 9, ../../sass/document/download.scss */
.document-download {
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/* line 10, ../../sass/document/download.scss */
/* line 14, ../../sass/document/download.scss */
.document-download #block-addresses .producer {
text-align: left;
margin-bottom: 20px;
}
/* line 15, ../../sass/document/download.scss */
/* line 19, ../../sass/document/download.scss */
.document-download #block-addresses .producer .logo {
margin-bottom: 20px;
}
/* line 23, ../../sass/document/download.scss */
/* line 27, ../../sass/document/download.scss */
.document-download #block-addresses .user {
text-align: right;
}
/* line 28, ../../sass/document/download.scss */
/* line 32, ../../sass/document/download.scss */
.document-download #block-infos-document {
padding-top: 30px;
}
/* line 31, ../../sass/document/download.scss */
/* line 35, ../../sass/document/download.scss */
.document-download #block-infos-document .date {
padding-bottom: 10px;
}
/* line 34, ../../sass/document/download.scss */
/* line 38, ../../sass/document/download.scss */
.document-download #block-infos-document .reference {
padding-bottom: 10px;
font-size: 15px;
font-weight: bold;
}
/* line 39, ../../sass/document/download.scss */
/* line 43, ../../sass/document/download.scss */
.document-download #block-infos-document .reference .block-is-draft {
border: solid 2px black;
padding: 10px;
text-transform: uppercase;
}
/* line 50, ../../sass/document/download.scss */
/* line 54, ../../sass/document/download.scss */
.document-download #block-no-product {
font-weight: bold;
border: solid 2px black;
text-transform: uppercase;
padding: 10px;
}
/* line 57, ../../sass/document/download.scss */
/* line 61, ../../sass/document/download.scss */
.document-download #block-products {
padding-top: 20px;
}
/* line 60, ../../sass/document/download.scss */
/* line 64, ../../sass/document/download.scss */
.document-download #block-products table {
width: 100%;
padding: 0px;
@@ -55,51 +60,51 @@
border-right: solid 1px #c0c0c0;
border-collapse: collapse;
}
/* line 68, ../../sass/document/download.scss */
/* line 72, ../../sass/document/download.scss */
.document-download #block-products table td, .document-download #block-products table th {
padding: 5px;
border-top: solid 1px #c0c0c0;
border-left: solid 1px #c0c0c0;
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/* line 74, ../../sass/document/download.scss */
/* line 78, ../../sass/document/download.scss */
.document-download #block-products table td.align-left, .document-download #block-products table th.align-left {
text-align: left;
}
/* line 77, ../../sass/document/download.scss */
/* line 81, ../../sass/document/download.scss */
.document-download #block-products table td.align-center, .document-download #block-products table th.align-center {
text-align: center;
}
/* line 80, ../../sass/document/download.scss */
/* line 84, ../../sass/document/download.scss */
.document-download #block-products table td.align-right, .document-download #block-products table th.align-right {
text-align: right;
}
/* line 87, ../../sass/document/download.scss */
/* line 91, ../../sass/document/download.scss */
.document-download .block-infos {
margin-top: 20px;
padding: 10px;
border: solid 1px #c0c0c0;
}
/* line 92, ../../sass/document/download.scss */
/* line 96, ../../sass/document/download.scss */
.document-download .block-infos strong {
font-size: 12px;
}

/* line 98, ../../sass/document/download.scss */
/* line 102, ../../sass/document/download.scss */
#footer {
font-family: "Source Sans Pro", "Helvetica Neue", Helvetica, Arial, sans-serif;
text-align: center;
padding-top: 20px;
padding-top: 10px;
border-top: solid 1px gray;
}
/* line 104, ../../sass/document/download.scss */
/* line 108, ../../sass/document/download.scss */
#footer .infos-bottom {
padding-bottom: 20px;
margin-bottom: 40px;
font-size: 12px;
line-height: 18px;
}
/* line 110, ../../sass/document/download.scss */
/* line 114, ../../sass/document/download.scss */
#footer .reference-document {
font-weight: bold;
}

+ 5
- 1
backend/web/sass/document/download.scss Прегледај датотеку

@@ -2,6 +2,10 @@
$font-family: 'Source Sans Pro','Helvetica Neue',Helvetica,Arial,sans-serif ;
$border-color: #c0c0c0 ;

body {
padding-bottom: 200px ;
}

.document-download {
font-family: $font-family ;

@@ -98,7 +102,7 @@ $border-color: #c0c0c0 ;
#footer {
font-family: $font-family ;
text-align: center ;
padding-top: 20px ;
padding-top: 10px ;
border-top: solid 1px gray ;

.infos-bottom {

+ 17
- 1
common/models/Document.php Прегледај датотеку

@@ -98,7 +98,8 @@ class Document extends ActiveRecordCommon

return $this->hasMany(Order::className(), [$fieldIdDocument => 'id'])
->with($defaultOptionsSearch['with'])
->joinWith($defaultOptionsSearch['join_with']);
->joinWith($defaultOptionsSearch['join_with'])
->orderBy('user.lastname ASC, user.name ASC, comment_point_sale ASC');
}


@@ -240,6 +241,11 @@ class Document extends ActiveRecordCommon
}
$contentFooter .= '</div>';

$marginBottom = 10 ;
if(strlen(Producer::getConfig('document_infos_bottom')) > 0) {
$marginBottom = 40 ;
}

$pdf = new Pdf([
'mode' => Pdf::MODE_UTF8,
'format' => Pdf::FORMAT_A4,
@@ -248,6 +254,7 @@ class Document extends ActiveRecordCommon
'content' => $content,
'filename' => $this->getFilename(),
'cssFile' => Yii::getAlias('@webroot/css/document/download.css'),
'marginBottom' => $marginBottom,
'methods' => [
'SetHTMLFooter' => $contentFooter
]
@@ -353,6 +360,15 @@ class Document extends ActiveRecordCommon
return $productsOrdersArray;
}

public function isDisplayOrders()
{
$displayOrders = ($this->getClass() == 'Invoice') ?
Producer::getConfig('document_display_orders_invoice') :
Producer::getConfig('document_display_orders_delivery_note') ;

return $displayOrders ;
}

public function getFilename()
{
return Yii::getAlias('@app/web/pdf/'.$this->getType().'-' . $this->reference. '.pdf') ;

+ 4
- 2
common/models/Producer.php Прегледај датотеку

@@ -128,7 +128,7 @@ class Producer extends ActiveRecordCommon
}],
[['description', 'mentions', 'gcs', 'order_infos', 'slug', 'secret_key_payplug', 'background_color_logo', 'option_behavior_cancel_order', 'tiller_provider_token', 'tiller_restaurant_token', 'status',
'document_infos_bottom', 'document_infos_quotation', 'document_infos_invoice', 'document_infos_delivery_note', 'address'], 'string'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller'], 'boolean'],
[['negative_balance', 'credit', 'active', 'online_payment', 'user_manage_subscription', 'option_allow_user_gift', 'use_credit_checked_default', 'tiller', 'document_display_orders_invoice', 'document_display_orders_delivery_note'], 'boolean'],
[['name', 'siret', 'logo', 'photo', 'postcode', 'city', 'code', 'type', 'credit_functioning', 'option_behavior_cancel_order', 'document_quotation_prefix', 'document_quotation_first_reference', 'document_invoice_prefix', 'document_invoice_first_reference', 'document_delivery_note_prefix', 'document_delivery_note_first_reference'], 'string', 'max' => 255],
[['free_price', 'credit_limit_reminder', 'credit_limit'], 'double'],
['free_price', 'compare', 'compareValue' => 0, 'operator' => '>=', 'type' => 'number', 'message' => 'Prix libre doit être supérieur ou égal à 0'],
@@ -201,7 +201,9 @@ class Producer extends ActiveRecordCommon
'document_infos_quotation' => 'Informations affichées en bas des devis',
'document_infos_invoice' => 'Informations affichées en bas des factures',
'document_infos_delivery_note' => 'Informations affichées en bas des bons de livraison',
'address' => 'Adresse'
'address' => 'Adresse',
'document_display_orders_invoice' => 'Afficher le détail des commandes dans les factures',
'document_display_orders_delivery_note' => 'Afficher le détail des commandes dans les bons de commande',
];
}


+ 20
- 0
console/migrations/m200225_153956_document_display_orders.php Прегледај датотеку

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

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

class m200225_153956_document_display_orders extends Migration
{
public function safeUp()
{
$this->addColumn('producer', 'document_display_orders_invoice', Schema::TYPE_BOOLEAN ) ;
$this->addColumn('producer', 'document_display_orders_delivery_note', Schema::TYPE_BOOLEAN ) ;
}

public function safeDown()
{
$this->dropColumn('producer', 'document_display_orders_invoice') ;
$this->dropColumn('producer', 'document_display_orders_delivery_note') ;
}

}

Loading…
Откажи
Сачувај