|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- <?php
-
- /**
- * Copyright Souke (2018)
- *
- * contact@souke.fr
- *
- * Ce logiciel est un programme informatique servant à aider les producteurs
- * à distribuer leur production en circuits courts.
- *
- * Ce logiciel est régi par la licence CeCILL soumise au droit français et
- * respectant les principes de diffusion des logiciels libres. Vous pouvez
- * utiliser, modifier et/ou redistribuer ce programme sous les conditions
- * de la licence CeCILL telle que diffusée par le CEA, le CNRS et l'INRIA
- * sur le site "http://www.cecill.info".
- *
- * En contrepartie de l'accessibilité au code source et des droits de copie,
- * de modification et de redistribution accordés par cette licence, il n'est
- * offert aux utilisateurs qu'une garantie limitée. Pour les mêmes raisons,
- * seule une responsabilité restreinte pèse sur l'auteur du programme, le
- * titulaire des droits patrimoniaux et les concédants successifs.
- *
- * A cet égard l'attention de l'utilisateur est attirée sur les risques
- * associés au chargement, à l'utilisation, à la modification et/ou au
- * développement et à la reproduction du logiciel par l'utilisateur étant
- * donné sa spécificité de logiciel libre, qui peut le rendre complexe à
- * manipuler et qui le réserve donc à des développeurs et des professionnels
- * avertis possédant des connaissances informatiques approfondies. Les
- * utilisateurs sont donc invités à charger et tester l'adéquation du
- * logiciel à leurs besoins dans des conditions permettant d'assurer la
- * sécurité de leurs systèmes et ou de leurs données et, plus généralement,
- * à l'utiliser et l'exploiter dans les mêmes conditions de sécurité.
- *
- * Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
- * pris connaissance de la licence CeCILL, et que vous en avez accepté les
- * termes.
- */
-
- 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')->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 v-if="document.status == 'draft' || !document.is_sent" 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; ?>
|