@@ -39,16 +39,21 @@ termes. | |||
namespace backend\models; | |||
use common\helpers\GlobalParam; | |||
use common\helpers\Mailjet; | |||
use common\logic\Distribution\Distribution\Model\Distribution; | |||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use Yii; | |||
use yii\base\Model; | |||
use common\helpers\Price ; | |||
use yii\helpers\Html; | |||
/** | |||
* ContactForm is the model behind the contact form. | |||
*/ | |||
class MailForm extends Model | |||
{ | |||
public $id_distribution ; | |||
public $subject; | |||
public $message; | |||
@@ -87,6 +92,9 @@ class MailForm extends Model | |||
*/ | |||
public function sendEmail($usersArray, $fromProducer = true) | |||
{ | |||
$productManager = ProductManager::getInstance(); | |||
$producerManager = ProducerManager::getInstance(); | |||
$mj = new \Mailjet\Client( | |||
Mailjet::getApiKey('public'), | |||
Mailjet::getApiKey('private'), | |||
@@ -105,7 +113,7 @@ class MailForm extends Model | |||
' ; | |||
$messageAutoHtml = '<br /><br />' ; | |||
$distribution = DistributionModel::searchOne(['id' => $this->id_distribution]) ; | |||
$distribution = Distribution::searchOne(['id' => $this->id_distribution]) ; | |||
if($distribution) { | |||
@@ -143,7 +151,7 @@ Produits disponibles : | |||
} | |||
if($product->price) { | |||
$productDescription .= ' / '.Price::format($product->getPriceWithTax()) ; | |||
$productDescription .= ' ('. Product::strUnit($product->unit, 'wording_unit').')' ; | |||
$productDescription .= ' ('. $productManager->strUnit($product->unit, 'wording_unit').')' ; | |||
} | |||
$messageAutoText .= '- '.$productDescription.' | |||
@@ -158,7 +166,7 @@ Produits disponibles : | |||
if($fromProducer) { | |||
$producer = GlobalParam::getCurrentProducer() ; | |||
$fromEmail = $producer->getEmailOpendistrib() ; | |||
$fromEmail = $producerManager->getEmailOpendistrib($producer) ; | |||
$fromName = $producer->name ; | |||
} | |||
else { | |||
@@ -206,5 +214,4 @@ Produits disponibles : | |||
return $response ; | |||
} | |||
} |
@@ -36,6 +36,14 @@ | |||
* termes. | |||
*/ | |||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | |||
use yii\grid\GridView; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\Order\Order\Model\Order; | |||
use yii\helpers\Html; | |||
use yii\helpers\ArrayHelper; | |||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | |||
$this->setTitle('Bons de livraison'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
$this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon glyphicon-plus"></span>', 'url' => ['distribution/index', 'message_generate_bl' => 1], 'class' => 'btn btn-primary']); | |||
@@ -43,107 +51,111 @@ $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon gl | |||
?> | |||
<div class="delivery-note-index"> | |||
<?php if(DeliveryNote::searchCount()): ?> | |||
<?= GridView::widget([ | |||
'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
[ | |||
'attribute' => 'status', | |||
'label' => 'Statut', | |||
'filter' => [ | |||
'draft' => 'Brouillon', | |||
'valid' => 'Valide', | |||
], | |||
'format' => 'raw', | |||
'value' => function($model) { | |||
return $model->getHtmlLabel() ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'reference', | |||
'value' => function($model) { | |||
if(strlen($model->reference) > 0) { | |||
return $model->reference ; | |||
} | |||
return '' ; | |||
} | |||
], | |||
'name', | |||
[ | |||
'attribute' => 'date_distribution', | |||
'header' => 'Jour de distribution', | |||
'filter' => \yii\jui\DatePicker::widget([ | |||
'language' => 'fr', | |||
'dateFormat' => 'dd/MM/yyyy', | |||
'model' => $searchModel, | |||
'attribute' => 'date_distribution', | |||
'options' => ['class' => 'form-control'] | |||
]), | |||
'value' => function($model) { | |||
$distribution = $model->getDistribution() ; | |||
if($distribution) { | |||
return date('d/m/Y',strtotime($distribution->date)) ; | |||
} | |||
return '' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_point_sale', | |||
'header' => 'Point de vente', | |||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array'=>true]), 'id', 'name'), | |||
'format' => 'html', | |||
'value' => function($model) { | |||
$pointSale = $model->getPointSale() ; | |||
if($pointSale) { | |||
return Html::encode($pointSale->name); | |||
} | |||
return '' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function($deliveryNote) { | |||
return $deliveryNote->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||
} | |||
], | |||
[ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{validate} {update} {delete} {send} {download}', | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'send' => function($url, $model) { | |||
return ((isset($model->user) && strlen($model->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||
'title' => 'Envoyer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
'download' => function($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'validate' => function ($url, $model) { | |||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'title' => 'Valider', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
'update' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'delete' => function ($url, $model) { | |||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
} | |||
], | |||
], | |||
], | |||
]); ?> | |||
<?php else: ?> | |||
<div class="alert alert-info">Aucun bon de livraison enregistré</div> | |||
<?php endif; ?> | |||
<?php if (DeliveryNote::searchCount()): ?> | |||
<?= GridView::widget([ | |||
'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
[ | |||
'attribute' => 'status', | |||
'label' => 'Statut', | |||
'filter' => [ | |||
'draft' => 'Brouillon', | |||
'valid' => 'Valide', | |||
], | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||
return $deliveryNoteManager->getHtmlLabel($model); | |||
} | |||
], | |||
[ | |||
'attribute' => 'reference', | |||
'value' => function ($model) { | |||
if (strlen($model->reference) > 0) { | |||
return $model->reference; | |||
} | |||
return ''; | |||
} | |||
], | |||
'name', | |||
[ | |||
'attribute' => 'date_distribution', | |||
'header' => 'Jour de distribution', | |||
'filter' => \yii\jui\DatePicker::widget([ | |||
'language' => 'fr', | |||
'dateFormat' => 'dd/MM/yyyy', | |||
'model' => $searchModel, | |||
'attribute' => 'date_distribution', | |||
'options' => ['class' => 'form-control'] | |||
]), | |||
'value' => function ($model) { | |||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||
$distribution = $deliveryNoteManager->getDistribution($model); | |||
if ($distribution) { | |||
return date('d/m/Y', strtotime($distribution->date)); | |||
} | |||
return ''; | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_point_sale', | |||
'header' => 'Point de vente', | |||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'), | |||
'format' => 'html', | |||
'value' => function ($model) { | |||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||
$pointSale = $deliveryNoteManager->getPointSale($model); | |||
if ($pointSale) { | |||
return Html::encode($pointSale->name); | |||
} | |||
return ''; | |||
} | |||
], | |||
[ | |||
'attribute' => 'amount', | |||
'header' => 'Montant', | |||
'value' => function ($deliveryNote) { | |||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||
return $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true); | |||
} | |||
], | |||
[ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{validate} {update} {delete} {send} {download}', | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'send' => function ($url, $model) { | |||
return ((isset($model->user) && strlen($model->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||
'title' => 'Envoyer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
'download' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'validate' => function ($url, $model) { | |||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||
'title' => 'Valider', 'class' => 'btn btn-default' | |||
]) : ''); | |||
}, | |||
'update' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'delete' => function ($url, $model) { | |||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||
]) : ''); | |||
} | |||
], | |||
], | |||
], | |||
]); ?> | |||
<?php else: ?> | |||
<div class="alert alert-info">Aucun bon de livraison enregistré</div> | |||
<?php endif; ?> | |||
</div> |
@@ -41,6 +41,8 @@ use yii\widgets\ActiveForm; | |||
\backend\assets\VuejsDocumentFormAsset::register($this); | |||
$producerManager = $this->getProducerManager(); | |||
?> | |||
<div class="document-form" id="app-document-form" data-class-document="<?= $model->getClass() ?>" | |||
@@ -211,7 +213,7 @@ use yii\widgets\ActiveForm; | |||
class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a> | |||
<?php endif; ?> | |||
<?php if ($model->getClass() == 'Invoice' && Producer::getConfig('option_export_evoliz')): ?> | |||
<?php if ($model->getClass() == 'Invoice' && $producerManager->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> |
@@ -1,8 +1,10 @@ | |||
<?php | |||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && Producer::getConfig('document_display_prices_delivery_note')); | |||
$displayProductDescription = Producer::getConfig('document_display_product_description'); | |||
$documentPriceDecimals = (int) Producer::getConfig('option_document_price_decimals'); | |||
$producerManager = $this->getProducerManager(); | |||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && $producerManager->getConfig('document_display_prices_delivery_note')); | |||
$displayProductDescription = $producerManager->getConfig('document_display_product_description'); | |||
$documentPriceDecimals = (int) $producerManager->getConfig('option_document_price_decimals'); | |||
?> | |||
@@ -39,6 +39,11 @@ | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\logic\Producer\Producer\Model\Producer; | |||
use common\logic\User\User\Wrapper\UserManager; | |||
$producerManager = $this->getProducerManager(); | |||
$userManager = $this->getUserManager(); | |||
?> | |||
@@ -54,12 +59,12 @@ use yii\helpers\ArrayHelper; | |||
<?= $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( User::populateDropdownList(), ['class' => 'select2']) | |||
->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']) | |||
->hint('Utilisé lors de la facturation'); ?> | |||
<?php | |||
$addHintCredit = ''; | |||
if (!ProducerModel::getConfig('credit')): | |||
if (!$producerManager->getConfig('credit')): | |||
$addHintCredit = '<br /><strong>Attention, le système de Crédit est désactivé au niveau des ' . Html::a('paramètres globaux', ['producer/update']) . '.</strong>'; | |||
endif; | |||
@@ -71,11 +76,11 @@ use yii\helpers\ArrayHelper; | |||
<?= $form->field($model, 'credit_functioning') | |||
->dropDownList([ | |||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[ProducerModel::getConfig('credit_functioning')] . ')', | |||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_OPTIONAL], | |||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_MANDATORY], | |||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[ProducerModel::CREDIT_FUNCTIONING_USER], | |||
], [])->hint(ProducerModel::HINT_CREDIT_FUNCTIONING); ?> | |||
'' => 'Paramètres globaux (' . Producer::$creditFunctioningArray[$producerManager->getConfig('credit_functioning')] . ')', | |||
Producer::CREDIT_FUNCTIONING_OPTIONAL => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_OPTIONAL], | |||
Producer::CREDIT_FUNCTIONING_MANDATORY => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_MANDATORY], | |||
Producer::CREDIT_FUNCTIONING_USER => Producer::$creditFunctioningArray[Producer::CREDIT_FUNCTIONING_USER], | |||
], [])->hint(Producer::HINT_CREDIT_FUNCTIONING); ?> | |||
<?php /*$form->field($model, 'product_price_percent') | |||
->dropDownList( ProductPrice::percentValues(), [])->hint('Pourcentage appliqué aux prix de chaque produit dans ce point de vente.');*/ ?> | |||
@@ -122,8 +127,8 @@ use yii\helpers\ArrayHelper; | |||
<div id="users"> | |||
<?= Html::activeCheckboxList($model, 'users', ArrayHelper::map($users, 'user_id', function ($model_user, $defaultValue) use ($model) { | |||
return Html::encode( User::getUsernameFromArray($model_user)) . '<br />' | |||
$userManager = UserManager::getInstance(); | |||
return Html::encode($userManager->getUsernameFromArray($model_user)) . '<br />' | |||
. Html::activeTextInput( | |||
$model, | |||
'users_comment[' . $model_user['user_id'] . ']', |
@@ -4,6 +4,11 @@ use yii\helpers\Html; | |||
use yii\bootstrap\ActiveForm; | |||
use yii\helpers\ArrayHelper; | |||
use common\helpers\GlobalParam; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
$productCategoryManager = $this->getProductCategoryManager(); | |||
$taxRateManager = $this->getTaxRateManager(); | |||
?> | |||
@@ -19,12 +24,12 @@ use common\helpers\GlobalParam; | |||
<?= $form->field($model, 'active')->radioList([1 => 'Oui', 0 => 'Non']) ?> | |||
<?= $form->field($model, 'name')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'reference')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'id_product_category')->dropDownList( ProductCategory::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_product_category')->dropDownList($productCategoryManager->populateProductCategoriesDropdownList()); ?> | |||
<?= $form->field($model, 'description')->textInput(['maxlength' => 255]) ?> | |||
<?= $form->field($model, 'recipe')->textarea()->label('Description longue') ?> | |||
<?= $form->field($model, 'unit') | |||
->dropDownList(ArrayHelper::map( Product::$unitsArray, 'unit', 'wording')) | |||
->dropDownList(ArrayHelper::map(Product::$unitsArray, 'unit', 'wording')) | |||
->label('Unité (pièce, poids ou volume)'); ?> | |||
@@ -34,10 +39,10 @@ use common\helpers\GlobalParam; | |||
$producer = \common\helpers\GlobalParam::getCurrentProducer(); | |||
$taxRateDefault = $producer->taxRate; | |||
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) { | |||
$taxRateNamesArray = array_merge(array(0 => 'Tva par défaut'), ArrayHelper::map($taxRateManager->findTaxRates(), 'id', function ($model) { | |||
return $model->name; | |||
})); | |||
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map(TaxRate::find()->all(), 'id', function ($model) { | |||
$taxRateValuesArray = array_merge(array(0 => $taxRateDefault->value), ArrayHelper::map($taxRateManager->findTaxRates(), 'id', function ($model) { | |||
return $model->value; | |||
})); | |||
foreach ($taxRateValuesArray as $key => $taxRateValue) { |
@@ -1,3 +1,12 @@ | |||
<?php | |||
use common\helpers\Price; | |||
$productManager = $this->getProductManager(); | |||
?> | |||
<div class="alert alert-warning"> | |||
Prix de base : <strong><?= Price::format($model->getPrice()); ?> HT</strong> / <strong><?= Price::format($model->getPriceWithTax()); ?> TTC</strong><br /> | |||
Prix de base : <strong><?= Price::format($productManager->getPrice($model)); ?> HT</strong> / <strong><?= Price::format($productManager->getPriceWithTax($model)); ?> TTC</strong><br /> | |||
</div> |
@@ -4,16 +4,19 @@ use yii\helpers\Html; | |||
use yii\bootstrap\ActiveForm; | |||
use common\helpers\GlobalParam; | |||
$userManager = $this->getUserManager(); | |||
$userGroupManager = $this->getUserGroupManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
$productManager = $this->getProductManager(); | |||
?> | |||
<div class="product-form"> | |||
<?= | |||
$this->render('_base_price', [ | |||
'model' => $modelProduct, | |||
]) ; | |||
?> | |||
<?php $form = ActiveForm::begin([ | |||
@@ -21,10 +24,10 @@ use common\helpers\GlobalParam; | |||
'options' => ['enctype' => 'multipart/form-data'] | |||
]); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList( User::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_user_group')->dropDownList( UserGroup::populateDropdownList()); ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(PointSale::populateDropdownList()); ?> | |||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList()); ?> | |||
<?= $form->field($model, 'id_user_group')->dropDownList($userGroupManager->populateUserGroupDropdownList()); ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList($pointSaleManager->populatePointSaleDropdownList()); ?> | |||
<?= $form->field($model, 'from_quantity')->label('À partir de la quantité ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording').')'); ?> | |||
<?php | |||
$producer = GlobalParam::getCurrentProducer(); | |||
@@ -38,13 +41,13 @@ use common\helpers\GlobalParam; | |||
'template' => ' | |||
<div class="row"> | |||
<div class="col-xs-6"> | |||
<label for="product-price" class="control-label without-tax">Prix ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||
<label for="product-price" class="control-label without-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') HT</label> | |||
<div class="input-group"> | |||
{input} <span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | |||
</div> | |||
</div> | |||
<div class="col-xs-6"> | |||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. Product::strUnit( Product::getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||
<label for="productprice-price-with-tax" class="control-label with-tax">Prix ('. $productManager->strUnit($productManager->getRefUnit($modelProduct->unit), 'wording_unit').') TTC</label> | |||
<div class="input-group"> | |||
<input type="text" id="productprice-price-with-tax" class="form-control" name="" value="" data-tax-rate-value="'.$taxRateValue.'"> | |||
<span class="input-group-addon"><span class="glyphicon glyphicon-euro"></span></span> | |||
@@ -59,5 +62,4 @@ use common\helpers\GlobalParam; | |||
</div> | |||
<?php ActiveForm::end(); ?> | |||
</div> |
@@ -1,7 +1,5 @@ | |||
<?php | |||
use common\helpers\Price ; | |||
/** | |||
* Copyright distrib (2018) | |||
* | |||
@@ -38,214 +36,131 @@ use common\helpers\Price ; | |||
* termes. | |||
*/ | |||
$this->setTitle('Liste des prix ('.Html::encode($model->name).')'); | |||
use yii\helpers\Html; | |||
use common\helpers\Price; | |||
use yii\grid\GridView; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
$productManager = $this->getProductManager(); | |||
$this->setTitle('Liste des prix (' . Html::encode($model->name) . ')'); | |||
$this->addBreadcrumb(['label' => 'Produits', 'url' => ['index']]); | |||
$this->addBreadcrumb(['label' => $model->name, 'url' => ['update', 'id' => $model->id]]); | |||
$this->addBreadcrumb('Modifier'); | |||
//$this->addButton(['label' => 'Nouveau prix <span class="glyphicon glyphicon-plus"></span>', 'url' => ['product/prices-create', 'idProduct' => $model->id ], 'class' => 'btn btn-primary']); | |||
?> | |||
<?= | |||
$this->render('../_nav', [ | |||
'model' => $model, | |||
'action' => $action, | |||
]) ; | |||
$this->render('../_nav', [ | |||
'model' => $model, | |||
'action' => $action, | |||
]); | |||
?> | |||
<div class="col-md-12"> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title"> | |||
Prix spécifiques à ce produit | |||
<a href="<?= Yii::$app->urlManager->createUrl(['product/prices-create', 'idProduct' => $model->id ]) ?>" class="btn btn-default btn-xs"> | |||
Nouveau prix | |||
<span class="glyphicon glyphicon-plus"></span> | |||
</a> | |||
</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<?php | |||
echo GridView::widget([ | |||
//'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
[ | |||
'attribute' => 'id_user', | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if($model->user) { | |||
return $model->user->getUsername() ; | |||
} | |||
return '<span class="label label-success">Tous</span>' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_user_group', | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if($model->userGroup) { | |||
return $model->userGroup->name ; | |||
} | |||
return '<span class="label label-success">Tous</span>' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_point_sale', | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if($model->pointSale) { | |||
return $model->pointSale->name ; | |||
} | |||
return '<span class="label label-success">Tous</span>' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'from_quantity', | |||
'value' => function ($productPrice) { | |||
if($productPrice->from_quantity) { | |||
return $productPrice->from_quantity.' '. Product::strUnit( Product::getRefUnit($productPrice->product->unit), 'wording'); | |||
} | |||
return '' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'price', | |||
'value' => function ($productPrice) { | |||
return Price::numberTwoDecimals($productPrice->price).' €' ; | |||
} | |||
], | |||
[ | |||
'attribute' => 'price', | |||
'header' => 'Prix (TTC)', | |||
'value' => function ($productPrice) use ($model) { | |||
return Price::numberTwoDecimals(Price::getPriceWithTax($productPrice->price, $model->taxRate->value)).' €' ; | |||
} | |||
], | |||
[ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{update} {delete}', | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'update' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['product/prices-update', 'id' => $model->id], [ | |||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'delete' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['product/prices-delete', 'id' => $model->id], [ | |||
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' | |||
]); | |||
} | |||
], | |||
], | |||
], | |||
]); | |||
?> | |||
</div> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title"> | |||
Prix spécifiques à ce produit | |||
<a href="<?= Yii::$app->urlManager->createUrl(['product/prices-create', 'idProduct' => $model->id]) ?>" | |||
class="btn btn-default btn-xs"> | |||
Nouveau prix | |||
<span class="glyphicon glyphicon-plus"></span> | |||
</a> | |||
</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<?php | |||
<!-- | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Pourcentage global / Utilisateurs</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Utilisateur</th> | |||
<th>Pourcentage</th> | |||
<th>Prix (HT)</th> | |||
<th>Prix (TTC)</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php if($userProducerWithProductPercent && count($userProducerWithProductPercent) > 0): ?> | |||
<?php foreach($userProducerWithProductPercent as $userProducer): ?> | |||
<?php if($userProducer->user): ?> | |||
<tr> | |||
<td><?= $userProducer->user->getUsername() ?></td> | |||
<td><?= $userProducer->product_price_percent ?> %</td> | |||
<td><?= Price::format($model->getPrice(['user_producer' => $userProducer])) ?></td> | |||
<td><?= Price::format($model->getPriceWithTax(['user_producer' => $userProducer])) ?></td> | |||
</tr> | |||
<?php endif; ?> | |||
<?php endforeach; ?> | |||
<?php else: ?> | |||
<tr><td colspan="4">Aucun résultat</td></tr> | |||
<?php endif; ?> | |||
</tbody> | |||
</table> | |||
</div> | |||
</div> | |||
echo GridView::widget([ | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
[ | |||
'attribute' => 'id_user', | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if ($model->user) { | |||
return $model->user->getUsername(); | |||
} | |||
return '<span class="label label-success">Tous</span>'; | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_user_group', | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if ($model->userGroup) { | |||
return $model->userGroup->name; | |||
} | |||
return '<span class="label label-success">Tous</span>'; | |||
} | |||
], | |||
[ | |||
'attribute' => 'id_point_sale', | |||
'format' => 'raw', | |||
'value' => function ($model) { | |||
if ($model->pointSale) { | |||
return $model->pointSale->name; | |||
} | |||
return '<span class="label label-success">Tous</span>'; | |||
} | |||
], | |||
[ | |||
'attribute' => 'from_quantity', | |||
'value' => function ($productPrice) { | |||
$productManager = ProductManager::getInstance(); | |||
if ($productPrice->from_quantity) { | |||
return $productPrice->from_quantity . ' ' . $productManager->strUnit($productManager->getRefUnit($productPrice->product->unit), 'wording'); | |||
} | |||
return ''; | |||
} | |||
], | |||
[ | |||
'attribute' => 'price', | |||
'value' => function ($productPrice) { | |||
return Price::numberTwoDecimals($productPrice->price) . ' €'; | |||
} | |||
], | |||
[ | |||
'attribute' => 'price', | |||
'header' => 'Prix (TTC)', | |||
'value' => function ($productPrice) use ($model) { | |||
return Price::numberTwoDecimals(Price::getPriceWithTax($productPrice->price, $model->taxRate->value)) . ' €'; | |||
} | |||
], | |||
[ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{update} {delete}', | |||
'headerOptions' => ['class' => 'column-actions'], | |||
'contentOptions' => ['class' => 'column-actions'], | |||
'buttons' => [ | |||
'update' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', ['product/prices-update', 'id' => $model->id], [ | |||
'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' | |||
]); | |||
}, | |||
'delete' => function ($url, $model) { | |||
return Html::a('<span class="glyphicon glyphicon-trash"></span>', ['product/prices-delete', 'id' => $model->id], [ | |||
'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' | |||
]); | |||
} | |||
], | |||
], | |||
], | |||
]); | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Pourcentage global / Points de vente</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<table class="table table-bordered"> | |||
<thead> | |||
<tr> | |||
<th>Point de vente</th> | |||
<th>Pourcentage</th> | |||
<th>Prix (HT)</th> | |||
<th>Prix (TTC)</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<?php if($pointSaleWithProductPercent && count($pointSaleWithProductPercent) > 0): ?> | |||
<?php foreach($pointSaleWithProductPercent as $pointSale): ?> | |||
<tr> | |||
<td><?= Html::encode($pointSale->name) ?></td> | |||
<td><?= $pointSale->product_price_percent ?> %</td> | |||
<td><?= Price::format($model->getPrice(['point_sale' => $pointSale])) ?></td> | |||
<td><?= Price::format($model->getPriceWithTax(['point_sale' => $pointSale])) ?></td> | |||
</tr> | |||
<?php endforeach; ?> | |||
<?php else: ?> | |||
<tr><td colspan="4">Aucun résultat</td></tr> | |||
<?php endif; ?> | |||
</tbody> | |||
</table> | |||
</div> | |||
?> | |||
</div> | |||
--> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Rappel du prix de base</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<p>Prix de base : <strong><?= Price::format($model->getPrice()); ?> HT</strong> / <strong><?= Price::format($model->getPriceWithTax()); ?> TTC</strong><br /></p> | |||
</div> | |||
</div> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Rappel du prix de base</h3> | |||
</div> | |||
</div> | |||
<!-- | |||
<div class="col-md-4"> | |||
<div class="panel panel-default"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title">Priorités de résolution</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<p>Le prix d'un produit se déduit dans un ordre précis de résolution, le voici : </p> | |||
<ul> | |||
<li>Les prix spécifiques définis au niveau du produit</li> | |||
<li>Les pourcentages globaux définis au niveau des utilisateurs et points de vente</li> | |||
<li>Le prix de base défini au niveau du produit</li> | |||
</ul> | |||
<p>À chaque étape de résolution, on vérifie si le contexte courant (utilisateur / point de vente) correspond à un prix. | |||
Si c'est le cas, on l'utilise, sinon on passe à l'étape suivante jusqu'à arriver au prix de base | |||
défini dans "Général". | |||
</p> | |||
</div> | |||
<div class="panel-body"> | |||
<p>Prix de base : <strong><?= Price::format($productManager->getPrice($model)); ?> HT</strong> / | |||
<strong><?= Price::format($productManager->getPriceWithTax($model)); ?> TTC</strong><br/></p> | |||
</div> | |||
</div> | |||
--> | |||
</div> | |||
</div> |
@@ -39,12 +39,13 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
use yii\helpers\ArrayHelper ; | |||
use common\models\ User ; | |||
use common\models\PointSale ; | |||
use common\helpers\GlobalParam ; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
\backend\assets\VuejsSubscriptionFormAsset::register($this); | |||
$userManager = $this->getUserManager(); | |||
$pointSaleManager = $this->getPointSaleManager(); | |||
?> | |||
<div class="subscription-form" id="app-subscription-form"> | |||
@@ -53,7 +54,7 @@ use common\helpers\GlobalParam ; | |||
<?= $form->field($model, 'id')->hiddenInput() ?> | |||
<?php endif; ?> | |||
<div class="col-md-5" id="bloc-select-user"> | |||
<?= $form->field($model, 'id_user')->dropDownList( User::populateDropdownList(), ['class' => 'select2']); ?> | |||
<?= $form->field($model, 'id_user')->dropDownList($userManager->populateUserDropdownList(), ['class' => 'select2']); ?> | |||
</div> | |||
<div class="col-md-1" id="or-user"> | |||
<span>OU</span> | |||
@@ -64,7 +65,7 @@ use common\helpers\GlobalParam ; | |||
<div class="clr"></div> | |||
<?= $form->field($model, 'id_producer')->hiddenInput() ?> | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map(PointSale::searchAll(), 'id', function($model, $defaultValue) { | |||
<?= $form->field($model, 'id_point_sale')->dropDownList(ArrayHelper::map($pointSaleManager->findPointSales(), 'id', function($model, $defaultValue) { | |||
return $model['name']; | |||
}), ['prompt' => '--','class' => 'form-control user-id']) ?> | |||
<?= $form->field($model, 'date_begin') ?> |
@@ -38,9 +38,12 @@ termes. | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\Product ; | |||
use common\helpers\GlobalParam ; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\Product\Product\Wrapper\ProductManager; | |||
use yii\helpers\ArrayHelper; | |||
use common\logic\Product\Product\Model\Product; | |||
$this->setTitle('Abonnements') ; | |||
$this->addBreadcrumb($this->getTitle()) ; | |||
@@ -48,8 +51,6 @@ $this->addButton(['label' => 'Nouvel abonnement <span class="glyphicon glyphicon | |||
$subscriptionsArray = Subscription::searchAll() ; | |||
?> | |||
<div class="subscription-index"> | |||
@@ -78,11 +79,12 @@ $subscriptionsArray = Subscription::searchAll() ; | |||
'label' => 'Produits', | |||
'format' => 'raw', | |||
'value' => function($model) { | |||
$productManager = ProductManager::getInstance(); | |||
$html = '' ; | |||
foreach($model->productSubscription as $productSubscription) | |||
{ | |||
if(isset($productSubscription->product)) { | |||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. Product::strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||
$html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. $productManager->strUnit($productSubscription->product->unit, 'wording_short').')<br />' ; | |||
} | |||
else { | |||
$html .= 'Produit non défini<br />' ; |
@@ -38,8 +38,10 @@ | |||
use yii\helpers\Html; | |||
use yii\grid\GridView; | |||
use common\models\ User; | |||
use common\models\Order; | |||
use common\logic\User\User\Wrapper\UserManager; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
use common\logic\User\User\Model\User; | |||
$this->setTitle('Utilisateurs'); | |||
$this->addBreadcrumb($this->getTitle()); | |||
@@ -67,14 +69,16 @@ $this->render('_menu', [ | |||
'attribute' => 'username', | |||
'label' => 'Nom', | |||
'value' => function ($model) { | |||
return User::getUsernameFromArray($model); | |||
$userManager = UserManager::getInstance(); | |||
return $userManager->getUsername($model); | |||
} | |||
], | |||
[ | |||
'attribute' => 'type', | |||
'label' => 'Type', | |||
'value' => function ($model) { | |||
$typeArray = User::getTypeChoicesArray(); | |||
$userManager = UserManager::getInstance(); | |||
$typeArray = $userManager->getTypeChoicesArray(); | |||
if(isset($typeArray[$model['type']])) { | |||
return $typeArray[$model['type']]; | |||
} | |||
@@ -128,7 +132,6 @@ $this->render('_menu', [ | |||
'attribute' => 'credit', | |||
'format' => 'raw', | |||
'value' => function ($model) use ($producer) { | |||
$userProducer = UserProducer::searchOne([ | |||
'id_user' => $model->id | |||
]); |
@@ -15,7 +15,6 @@ class BusinessLogic | |||
$this->getTaxRateContainer(), | |||
$this->getUserUserGroupContainer(), | |||
$this->getUserGroupContainer(), | |||
$this->getDocumentContainer(), | |||
$this->getCreditHistoryContainer(), | |||
$this->getProducerPriceRangeContainer(), | |||
$this->getUserProducerContainer(), | |||
@@ -29,6 +28,10 @@ class BusinessLogic | |||
$this->getProductPriceContainer(), | |||
$this->getProductSubscriptionContainer(), | |||
$this->getUserPointSaleContainer(), | |||
$this->getQuotationContainer(), | |||
$this->getInvoiceContainer(), | |||
$this->getDeliveryNoteContainer(), | |||
$this->getDocumentContainer(), | |||
$this->getPointSaleContainer(), | |||
$this->getSubscriptionContainer(), | |||
$this->getProductContainer(), | |||
@@ -74,6 +77,6 @@ class BusinessLogic | |||
} | |||
} | |||
throw new ErrorException('Service '.$serviceClass.' introuvable dans le container.'); | |||
throw new ErrorException('Service '.$serviceClass.' introuvable dans les containers.'); | |||
} | |||
} |
@@ -10,10 +10,13 @@ use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributio | |||
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionManager; | |||
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionContainer; | |||
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionManager; | |||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteContainer; | |||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | |||
use common\logic\Document\Document\Wrapper\DocumentContainer; | |||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||
use common\logic\Document\Invoice\Wrapper\InvoiceContainer; | |||
use common\logic\Document\Invoice\Wrapper\InvoiceManager; | |||
use common\logic\Document\Quotation\Wrapper\QuotationContainer; | |||
use common\logic\Document\Invoice\Wrapper\QuotationManager; | |||
use common\logic\Order\Order\Wrapper\OrderContainer; | |||
use common\logic\Order\Order\Wrapper\OrderManager; | |||
@@ -214,6 +217,21 @@ trait BusinessLogicTrait | |||
return DocumentContainer::getInstance(); | |||
} | |||
public function getDeliveryNoteContainer(): DeliveryNoteContainer | |||
{ | |||
return DeliveryNoteContainer::getInstance(); | |||
} | |||
public function getInvoiceContainer(): InvoiceContainer | |||
{ | |||
return InvoiceContainer::getInstance(); | |||
} | |||
public function getQuotationContainer(): QuotationContainer | |||
{ | |||
return QuotationContainer::getInstance(); | |||
} | |||
public function getUserGroupContainer(): UserGroupContainer | |||
{ | |||
return UserGroupContainer::getInstance(); |
@@ -38,10 +38,11 @@ termes. | |||
namespace common\forms; | |||
use common\logic\Product\Product\Model\Product; | |||
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; | |||
use common\logic\Subscription\Subscription\Model\Subscription; | |||
use Yii; | |||
use yii\base\Model; | |||
use common\models\Subscription; | |||
use common\models\SubscriptionProduct; | |||
/** | |||
* Login form |
@@ -3,6 +3,7 @@ | |||
namespace common\logic\Config\TaxRate\Repository; | |||
use common\logic\AbstractRepository; | |||
use common\logic\Config\TaxRate\Model\TaxRate; | |||
class TaxRateRepository extends AbstractRepository | |||
{ |
@@ -22,7 +22,7 @@ class DeliveryNoteContainer extends AbstractContainer | |||
]; | |||
} | |||
public function getFactory(): DeliveryNoteBuilder | |||
public function getBuilder(): DeliveryNoteBuilder | |||
{ | |||
return DeliveryNoteBuilder::getInstance(); | |||
} |
@@ -7,11 +7,19 @@ use common\logic\AbstractService; | |||
use common\logic\Document\Document\Model\Document; | |||
use common\logic\Document\Document\Model\DocumentInterface; | |||
use common\logic\Order\Order\Model\Order; | |||
use common\logic\Order\ProductOrder\Service\ProductOrderSolver; | |||
use common\logic\PointSale\PointSale\Model\PointSale; | |||
use common\logic\SolverInterface; | |||
class DocumentSolver extends AbstractService implements SolverInterface | |||
{ | |||
protected ProductOrderSolver $productOrderSolver; | |||
public function loadDependencies(): void | |||
{ | |||
$this->productOrderSolver = $this->loadService(ProductOrderSolver::class); | |||
} | |||
public function getAmount(DocumentInterface $document, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||
{ | |||
return $this->_getAmountGeneric($document, $type, false, $format); | |||
@@ -29,7 +37,7 @@ class DocumentSolver extends AbstractService implements SolverInterface | |||
foreach($this->getProductsOrders($document) as $productOrderArray) { | |||
foreach($productOrderArray as $productOrder) { | |||
$priceLine = $productOrder->getPriceByTypeTotal($type) * $productOrder->quantity; | |||
$priceLine = $this->productOrderSolver->getPriceByTypeTotal($productOrder, $type) * $productOrder->quantity; | |||
$amount += $priceLine; | |||
$totalVat += Price::getVat($priceLine, $productOrder->taxRate->value, $document->tax_calculation_method); | |||
} |
@@ -1,6 +1,6 @@ | |||
<?php | |||
namespace common\logic\Document\Invoice\Wrapper; | |||
namespace common\logic\Document\Quotation\Wrapper; | |||
use common\logic\AbstractContainer; | |||
use common\logic\Document\Document\Service\DocumentSolver; |
@@ -21,7 +21,7 @@ class ProductPointSaleBuilder extends AbstractBuilder | |||
$productPointSale = $this->instanciateProductPointSale(); | |||
$productPointSale->populateProduct($product); | |||
$productPointSale->populatePointSale($pointSale); | |||
$productPointSale->availability = $available; | |||
$productPointSale->available = $available; | |||
$this->saveCreate($productPointSale); | |||
@@ -53,16 +53,16 @@ class UserRepository extends AbstractRepository | |||
return $this->queryUsersBy()->all(); | |||
} | |||
public static function populateUserDropdownList() | |||
public function populateUserDropdownList() | |||
{ | |||
$usersArray = | |||
$usersArray = $this->findUsers(); | |||
$usersArrayDropdown = ['' => '--']; | |||
foreach ($usersArray as $user) { | |||
$usersArrayDropdown[$user['user_id']] = User::getUsernameFromArray($user, true); | |||
$usersArrayDropdown[$user['user_id']] = $this->userSolver->getUsernameFromArray($user, true); | |||
} | |||
return $usersArrayDropdown;; | |||
return $usersArrayDropdown; | |||
} | |||
/** |