|
- <?php
-
-
-
- use domain\Document\Document\DocumentModule;
- use domain\Document\Invoice\InvoiceModule;
- use domain\Payment\PaymentModule;
- use domain\Producer\Producer\ProducerModule;
- use domain\User\User\UserModule;
- use yii\helpers\Html;
- use yii\widgets\ActiveForm;
-
- $producerModule = ProducerModule::getInstance();
- $documentModule = DocumentModule::getInstance();
- $invoiceModule = InvoiceModule::getInstance();
- $userModule = UserModule::getInstance();
- $paymentManager = PaymentModule::getInstance();
-
- $documentClass = $documentModule->getClass($model);
-
- ?>
-
- <div class="document-form" id="app-document-form" data-class-document="<?= $documentClass ?>"
- data-id-document="<?= ($model->id > 0) ? $model->id : $model->id ?>">
-
- <div class="<?= ($action == 'update') ? 'col-md-6' : '' ?>">
- <div class="panel panel-default">
- <div class="panel-heading">
- Général
- </div>
- <div class="panel-body">
- <?php $form = ActiveForm::begin(); ?>
- <?= Html::hiddenInput('classDocument', $documentClass, ['id' => 'class-document']) ?>
- <?= Html::hiddenInput('typeAction', $action, ['id' => 'type-action']) ?>
- <?php if ($action == 'update'): ?>
- <?= Html::hiddenInput('idDocument', $model->id, ['id' => 'id-document']) ?>
- <?php endif; ?>
- <?= $form->field($model, 'name')->textInput(['v-model' => 'document.name'])->label('Nom du document') ?>
-
- <?php if ($action == 'update'): ?>
- <?= $form->field($model, 'id_user', [
- 'template' => '{label} <div>{input}</div>' . $userModule->getUsername($model->user),
- ])->hiddenInput(); ?>
- <?php else: ?>
- <?= $form->field($model, 'id_user', [
- 'template' => '{label} <a href="' . Yii::$app->urlManager->createUrl(['user/create']) . '" class="btn btn-xs btn-default">Nouvel utilisateur <span class="glyphicon glyphicon-plus"></span></a><div>{input}</div>{hint}',
- ])
- ->dropDownList(
- $userModule->populateUserDropdownList(),
- [
- '@change' => 'changeUser',
- 'v-model' => 'idUser',
- 'class' => 'select2 select2-document-form'
- ]
- ); ?>
- <?php endif; ?>
-
-
- <?= $form->field($model, 'address')->textarea(['rows' => 2, 'v-model' => 'document.address']) ?>
- <?php if ($action == 'update'): ?>
- <?= $form->field($model, 'comment')->textarea(['rows' => 2])->hint('Affiché en bas du document') ?>
- <?php endif; ?>
-
- <?php if ($action == 'create' && $documentClass == 'Invoice'): ?>
- <template v-if="idUser > 0">
-
- <template v-if="deliveryNoteCreateArray && deliveryNoteCreateArray.length > 0">
- <strong>Bons de livraison</strong>
- <table v-if="deliveryNoteCreateArray && deliveryNoteCreateArray.length > 0"
- class="table table-bordered">
- <thead>
- <tr>
- <th>
- <input type="checkbox" class="check-all-checkboxes" data-selector=".checkbox-delivery-note" />
- </th>
- <th>Libellé</th>
- <th v-if="taxRateProducer != 0">Montant (TTC)</th>
- <th v-else>Montant</th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="deliveryNote in deliveryNoteCreateArray">
- <td><input type="checkbox" class="checkbox-delivery-note" name="Invoice[deliveryNotes][]" :value="deliveryNote.id"/></td>
- <td>{{ deliveryNote.name }}</td>
- <td>{{ formatPrice(deliveryNote.total) }}</td>
- </tr>
- </tbody>
- </table>
- <div v-else class="alert alert-warning">Aucun bon de livraison pour cet utilisateur.</div>
- </template>
- <template v-else-if="ordersCreateArray && ordersCreateArray.length > 0">
- <strong>Commandes</strong>
- <table v-if="ordersCreateArray && ordersCreateArray.length > 0"
- class="table table-bordered">
- <thead>
- <tr>
- <th></th>
- <th>Date</th>
- <th v-if="taxRateProducer != 0">Montant (TTC)</th>
- <th v-else>Montant</th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="order in ordersCreateArray">
- <td><input type="checkbox" name="Invoice[ordersOnCreate][]" :value="order.id"/></td>
- <td>{{ order.name }}</td>
- <td>{{ formatPrice(order.amount_with_tax) }}</td>
- </tr>
- </tbody>
- </table>
- <div v-else class="alert alert-warning">Aucune commande pour cet utilisateur.</div>
- </template>
- </template>
- <?php endif; ?>
-
- <div class="form-group">
- <?= Html::submitButton($model->isNewRecord ? 'Ajouter' : 'Modifier', ['class' => 'btn btn-primary']) ?>
- </div>
- <?php ActiveForm::end(); ?>
- </div>
- </div>
- </div>
-
- <?php if ($action == 'update'): ?>
-
- <div class="col-md-6">
- <div id="" class="info-box">
- <span class="info-box-icon bg-green"><i class="fa fa-sticky-note-o"></i></span>
- <div class="info-box-content">
- <span class="info-box-text">
- <?= $typeDocument ?>
- <span v-html="document.html_label"></span>
- <span v-if="document.is_sent" class="label label-success">Envoyé</span>
- </span>
- <span class="info-box-number">{{ document.reference }}</span>
- <span class="info-box-text">Date</span>
- <span class="info-box-number">{{ document.date }}</span>
- </div>
- </div>
- <div id="" class="info-box">
- <span class="info-box-icon bg-yellow"><i class="fa fa-euro"></i></span>
- <div class="info-box-content">
- <span class="info-box-text">
- Total<span v-if="taxRateProducer != 0"> (TTC)</span>
- <?php if( $invoiceModule->isDocumentInvoice($model) && $invoiceModule->isInvoicePaid($model)): ?>
- <span class="label label-success">PAYÉE</span>
- <?php endif; ?>
- </span>
- <span class="info-box-number">{{ formatPrice(total_with_tax) }}</span>
- <p v-if="invoiceUrl">
- <a class="btn btn-sm btn-default" :href="invoiceUrl">
- <span class="glyphicon glyphicon-eye-open"></span> Voir la facture
- </a>
- </p>
- </div>
- </div>
- <div id="" class="info-box">
- <span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span>
- <div class="info-box-content">
- <span class="info-box-text">Commandes</span>
- <?php foreach ($model->orders as $order): ?>
- <?php if ($order->distribution): ?>
- <a class="btn btn-sm btn-default"
- href="<?= Yii::$app->urlManager->createUrl(['distribution/index', 'idOrderUpdate' => $order->id]); ?>">
- <?= date('d/m/Y', strtotime($order->distribution->date)) ?>
- </a>
- <?php endif; ?>
- <?php endforeach; ?>
- </div>
- </div>
- <div id="" class="info-box">
- <span class="info-box-icon bg-blue"><i class="fa fa-download"></i></span>
- <div class="info-box-content">
- <a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/download', 'id' => $model->id]) ?>"
- class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger
- (PDF)</a>
-
- <?php if ($documentClass == 'Invoice' && $producerModule->getConfig('option_export_evoliz')): ?>
- <a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>"
- class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz
- (CSV)</a>
- <?php endif; ?>
- </div>
- </div>
- <div class="info-box">
- <span class="info-box-icon bg-red"><i class="fa fa-flash"></i></span>
- <div class="info-box-content">
-
- <a v-if="document.status == 'draft'"
- href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/validate', 'id' => $model->id, 'backUpdateForm' => 1]) ?>"
- class="btn btn-sm btn-default"><span class="glyphicon glyphicon-ok"></span> Valider le document</a>
-
- <?php if ($documentModule->isStatusValid($model)): ?>
- <a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/regenerate', 'id' => $model->id]) ?>"
- class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer
- (PDF)</a>
- <?php endif; ?>
-
- <?php if (isset($model->user) && strlen($model->user->email) > 0): ?>
- <a v-if="!document.is_sent"
- href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/send', 'id' => $model->id, 'backUpdateForm' => 1]) ?>"
- class="btn btn-sm btn-default"><span class="glyphicon glyphicon-send"></span> Envoyer le
- document</a>
- <?php endif; ?>
- </div>
- </div>
- </div>
- <div class="clr"></div>
-
- <?php if ($action == 'update' && $documentClass == 'DeliveryNote'): ?>
- <?= $this->render('form/_orders'); ?>
- <?php endif; ?>
-
- <?php if ($action == 'update' && $documentClass == 'Invoice'): ?>
-
- <?= $this->render('form/_payment', ['model' => $model, 'payment' => $payment]); ?>
-
- <div v-if="(deliveryNoteUpdateArray && deliveryNoteUpdateArray.length > 0) || (deliveryNoteCreateArray && deliveryNoteCreateArray.length > 0)">
- <div class="panel panel-default">
- <div class="panel-heading">
- Bons de livraison
- </div>
- <div class="panel-body">
- <table v-if="deliveryNoteUpdateArray && deliveryNoteUpdateArray.length > 0"
- class="table table-bordered">
- <thead>
- <tr>
- <th>Libellé</th>
- <th v-if="taxRateProducer != 0">Montant (TTC)</th>
- <th v-else>Montant</th>
- <th v-if="document.status == 'draft'"></th>
- </tr>
- </thead>
- <tbody>
- <tr v-for="deliveryNote in deliveryNoteUpdateArray">
- <td><a :href="deliveryNote.url">{{ deliveryNote.name }}</a></td>
- <td>{{ formatPrice(deliveryNote.total) }}</td>
- <td v-if="document.status == 'draft'"><a class="btn btn-default" href="javascript:void(0);"
- @click="deleteDeliveryNoteFromInvoice"
- :data-id="deliveryNote.id"><span
- class="glyphicon glyphicon-trash"></span></a></td>
- </tr>
- </tbody>
- </table>
- <div v-else class="alert alert-warning">Aucun bon de livraison associé.</div>
-
- <div v-if="document.status == 'draft'" id="delivery-note-add">
- <div class="col-md-8">
- <select class="form-control" v-model="deliveryNoteAddId">
- <option value="0" selected="selected">--</option>
- <option v-for="deliveryNote in deliveryNoteCreateArray" :value="deliveryNote.id">
- {{ deliveryNote.name }}
- </option>
- </select>
- </div>
- <div class="col-md-4">
- <button class="btn btn-primary" value="Ajouter" @click="submitDeliveryNoteAddToInvoice">
- Ajouter
- </button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div v-else>
- <?= $this->render('form/_orders'); ?>
- </div>
- <div class="clr"></div>
- <?php endif; ?>
-
- <div class="panel panel-default" id="block-add-product">
- <div class="panel-heading">
- Ajouter un produit
- </div>
- <div class="panel-body">
- <div class="col-md-6">
- <strong>Produit</strong>
- <select class="form-control" v-model="productAddId"
- @change="changeProductAdd">
- <option value="0" selected="selected">--</option>
- <option v-for="product in productsArray" v-if="product.status >= 0" :value="product.id">
- {{ product.name }}
- </option>
- </select>
- </div>
- <template v-if="productAddId > 0">
- <div class="col-md-3">
- <strong>Prix unitaire</strong>
- <div class="input-group">
- <input type="text" class="form-control input-price"
- v-model="productAddPrice" @change="formatProductAddPrice"/>
- <span class="input-group-addon"><span
- class="glyphicon glyphicon-euro"></span> <span v-if="taxRateProducer != 0">HT</span></span>
- </div>
- </div>
- <div class="col-md-3 total">
- <strong>Quantité</strong>
- <div class="input-group input-group-quantity">
- <span class="input-group-btn">
- <button class="btn btn-default" type="button"
- @click="changeQuantityProductAdd(-1)">-</button>
- </span>
- <input type="text" class="form-control input-quantity"
- v-model="productAddQuantity" @change="formatProductAddQuantity"/>
- <span class="input-group-addon">{{ getProductById(productAddId).wording_unit }}</span>
- <span class="input-group-btn">
- <button class="btn btn-default"
- type="button"
- @click="changeQuantityProductAdd(1)">+</button>
- </span>
- </div>
- <button class="btn btn-primary" value="Ajouter"
- @click="submitProductAdd">Ajouter
- </button>
- <div class="clr"></div>
- </div>
- </template>
- <div class="clr"></div>
- </div>
- </div>
-
- <div class="panel panel-default">
- <div class="panel-heading">
- Produits
- </div>
- <div class="panel-body">
- <div id="block-list-products">
- <table class="table table-bordered" v-if="Object.keys(ordersArray).length > 0">
- <thead>
- <tr>
- <th>Nom</th>
- <th>Prix (unité)</th>
- <th>Quantité</th>
- <th v-if="taxRateProducer != 0">TVA</th>
- <th v-if="taxRateProducer != 0">Total HT</th>
- <th v-else>Total</th>
- <th>Supprimer</th>
- </tr>
- </thead>
- <tbody>
- <template v-for="order in ordersArray">
- <tr v-for="productOrder in order.productOrder">
- <td class="col-md-4">
- <div class="product-name">
- <a :href="productOrder.url_product" target="_blank">
- {{ getProductById(productOrder.id_product).name }}
- </a>
- </div>
- <ul class="product-order-meta">
- <li v-if="order.distribution_date">Commande : <a :href="productOrder.url_order">{{
- order.distribution_date }}</a></li>
- <li>Utilisateur : {{ order.username }}</li>
- <li v-if="order.point_sale_name">Point de vente : {{ order.point_sale_name }}</li>
- </ul>
- </td>
- <td class="col-md-2">
- <template v-if="document.status == 'draft'">
- <div class="input-group input-group-edit-invoice-price">
- <input type="text" class="form-control" :id="'input-product-order-invoice-price-'+productOrder.id" :value="getProductOrderPrice(productOrder)" :data-id-product-order="productOrder.id" @keyup="showProductOrderInvoicePriceButtonApply" />
- <span class="input-group-addon">€</span>
- </div>
- <div class="product-order-invoice-price-button-apply" :id="'product-order-invoice-price-button-apply-'+productOrder.id">
- <button class="btn btn-success" type="button" :data-id-product-order="productOrder.id" @click="updateProductOrderInvoicePrice">
- <span class="glyphicon glyphicon-ok"></span>
- </button>
- </div>
- </template>
- <template v-else>
- {{ formatPrice(getProductOrderPrice(productOrder)) }}
- </template>
- <template
- v-if="document.status == 'draft' && getProductOrderPrice(productOrder) != getBestProductPrice(productOrder.id_product, productOrder.quantity)">
- <i class="different-price fa fa-exclamation-triangle"
- :title="'Prix différent de celui défini au niveau du produit ('+getBestProductPrice(productOrder.id_product, productOrder.quantity)+' €)'"></i>
- </template>
- </td>
- <td class="col-md-2">{{ productOrder.quantity }}</td>
- <td class="col-md-1" v-if="taxRateProducer != 0">
- {{ getProductById(productOrder.id_product).tax_rate * 100 }} %
- </td>
- <td class="col-md-2">
- {{ formatPrice(productOrder.quantity * getProductOrderPrice(productOrder)) }}
- </td>
- <td class="col-md-1">
- <a class="btn btn-default" @click="deleteProductOrder(productOrder.id)">
- <span class="glyphicon glyphicon-trash"></span>
- </a>
- </td>
- </tr>
- </template>
- <template v-if="taxRateProducer != 0">
- <tr>
- <td colspan="4"><strong>Total HT</strong></td>
- <td><strong>{{ formatPrice(total) }} HT</strong></td>
- <td></td>
- </tr>
- <tr>
- <td colspan="4"><strong>Montant TVA</strong></td>
- <td><strong>{{ formatPrice(total_with_tax - total) }}</strong></td>
- <td></td>
- </tr>
- <tr>
- <td colspan="4"><strong>Total TTC</strong></td>
- <td><strong>{{ formatPrice(total_with_tax) }} TTC</strong></td>
- <td></td>
- </tr>
- </template>
- <template v-else>
- <tr>
- <td colspan="3"><strong>Total</strong></td>
- <td><strong>{{ formatPrice(total) }}</strong></td>
- <td></td>
- </tr>
- </template>
- </tbody>
- </table>
- <div v-else class="alert alert-info">
- Aucun produit.
- </div>
- </div>
- </div>
- </div>
- <?php endif; ?>
|