} | } | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
$usersAccessArray = $this->getUserManager()->findUsersByProducer($producer->id); | |||||
$usersAccessArray = $this->getUserManager()->findUsersByProducer($producer); | |||||
return $this->render('index', [ | return $this->render('index', [ | ||||
'usersArray' => $usersArray, | 'usersArray' => $usersArray, |
public function actionDownload($id) | public function actionDownload($id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
return $document->downloadPdf(); | |||||
return $documentManager->downloadPdf($document); | |||||
} | } | ||||
public function actionRegenerate($id) | public function actionRegenerate($id) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
$document->downloadPdf(true); | |||||
$documentManager->downloadPdf($document, true); | |||||
$this->setFlash('success', 'Le document PDF a bien été regénéré.'); | $this->setFlash('success', 'Le document PDF a bien été regénéré.'); | ||||
return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]); | return $this->redirect([$this->getControllerUrl() . '/update', 'id' => $id]); | ||||
public function actionSend(int $id, $backUpdateForm = false) | public function actionSend(int $id, $backUpdateForm = false) | ||||
{ | { | ||||
$documentManager = $this->getDocumentManager(); | |||||
$document = $this->findModel($id); | $document = $this->findModel($id); | ||||
if ($document->send()) { | |||||
if ($documentManager->send($document)) { | |||||
$document->is_sent = true; | $document->is_sent = true; | ||||
$document->save(); | $document->save(); | ||||
if ($user) { | if ($user) { | ||||
$document = null; | $document = null; | ||||
if ($documentManager->isValidClass($classDocument)) { | if ($documentManager->isValidClass($classDocument)) { | ||||
$document = $classDocument::searchOne([ | |||||
'id' => $idDocument, | |||||
'id_user' => $idUser | |||||
]); | |||||
$document = $this->findModel($idDocument, $classDocument); | |||||
} | } | ||||
if ($document && $document->id_user == $user->id) { | if ($document && $document->id_user == $user->id) { | ||||
$classDocument = $this->getClass(); | $classDocument = $this->getClass(); | ||||
if ($id > 0 && $documentManager->isValidClass($classDocument)) { | if ($id > 0 && $documentManager->isValidClass($classDocument)) { | ||||
$document = $classDocument::searchOne([ | |||||
'id' => $id | |||||
]); | |||||
$document = $this->findModel($id); | |||||
if ($document) { | if ($document) { | ||||
$documentManager->changeStatus($document,Document::STATUS_VALID); | $documentManager->changeStatus($document,Document::STATUS_VALID); | ||||
$pointSaleManager = $this->getPointSaleManager(); | $pointSaleManager = $this->getPointSaleManager(); | ||||
if ($idDocument > 0 && $documentManager->isValidClass($classDocument)) { | if ($idDocument > 0 && $documentManager->isValidClass($classDocument)) { | ||||
$document = $classDocument::searchOne([ | |||||
'id' => $idDocument | |||||
]); | |||||
$document = $this->findModel($idDocument, $classDocument); | |||||
if ($document) { | if ($document) { | ||||
$ordersArray = []; | $ordersArray = []; | ||||
$productsArray = $productManager->findProducts(); | $productsArray = $productManager->findProducts(); | ||||
foreach ($document->orders as $order) { | foreach ($document->orders as $order) { | ||||
$orderManager->init($order); | |||||
$orderManager->initOrder($order); | |||||
$productsOrderArray = []; | $productsOrderArray = []; | ||||
foreach ($order->productOrder as $productOrder) { | foreach ($order->productOrder as $productOrder) { | ||||
$ordersArray[$order->id] = array_merge( | $ordersArray[$order->id] = array_merge( | ||||
$order->getAttributes(), | $order->getAttributes(), | ||||
[ | [ | ||||
'username' => $order->getUsername(), | |||||
'username' => $orderManager->getOrderUsername($order), | |||||
'distribution_date' => isset($order->distribution) ? date( | 'distribution_date' => isset($order->distribution) ? date( | ||||
'd/m/Y', | 'd/m/Y', | ||||
strtotime( | strtotime( | ||||
$productManager = $this->getProductManager(); | $productManager = $this->getProductManager(); | ||||
if ($documentManager->isValidClass($classDocument)) { | if ($documentManager->isValidClass($classDocument)) { | ||||
$document = $classDocument::searchOne([ | |||||
'id' => $idDocument | |||||
]); | |||||
$document = $this->findModel($idDocument, $classDocument); | |||||
$product = $productManager->findOneProductById($idProduct); | $product = $productManager->findOneProductById($idProduct); | ||||
if ($document && $product) { | if ($document && $product) { | ||||
* @return Document | * @return Document | ||||
* @throws NotFoundHttpException si le modèle n'est pas trouvé | * @throws NotFoundHttpException si le modèle n'est pas trouvé | ||||
*/ | */ | ||||
protected function findModel($id) | |||||
protected function findModel($idDocument, $classDocument = null) | |||||
{ | { | ||||
$class = $this->getClass(); | |||||
$model = $class::searchOne([ | |||||
'id' => $id | |||||
]); | |||||
$documentManager = $this->getDocumentManager(); | |||||
$model = $documentManager->findOneDocumentByIdAndClass($idDocument, $classDocument ?? $this->getClass()); | |||||
if ($model) { | if ($model) { | ||||
return $model; | return $model; |
*/ | */ | ||||
public function actionUpdate() | public function actionUpdate() | ||||
{ | { | ||||
$producerManager = $this->getProducerManager(); | |||||
$request = Yii::$app->request; | $request = Yii::$app->request; | ||||
$model = $this->findModel(GlobalParam::getCurrentProducerId()); | $model = $this->findModel(GlobalParam::getCurrentProducerId()); | ||||
$logoFilenameOld = $model->logo; | $logoFilenameOld = $model->logo; | ||||
$model->save(); | $model->save(); | ||||
} | } | ||||
$model->savePrivateKeyApiStripe(); | |||||
$model->savePrivateKeyEndpointStripe(); | |||||
$producerManager->savePrivateKeyApiStripe($model); | |||||
$producerManager->savePrivateKeyEndpointStripe($model); | |||||
$model->option_stripe_private_key = ''; | $model->option_stripe_private_key = ''; | ||||
$model->option_stripe_endpoint_secret = ''; | $model->option_stripe_endpoint_secret = ''; |
namespace backend\controllers; | namespace backend\controllers; | ||||
use common\logic\Config\TaxRate\TaxRate; | |||||
use common\logic\Config\TaxRate\Model\TaxRate; | |||||
use Yii; | use Yii; | ||||
use yii\web\NotFoundHttpException; | use yii\web\NotFoundHttpException; | ||||
use yii\filters\VerbFilter; | use yii\filters\VerbFilter; |
use common\logic\PointSale\PointSale\Model\PointSale; | use common\logic\PointSale\PointSale\Model\PointSale; | ||||
use common\logic\PointSale\UserPointSale\Model\UserPointSale; | use common\logic\PointSale\UserPointSale\Model\UserPointSale; | ||||
use common\logic\User\CreditHistory\Model\CreditHistory; | use common\logic\User\CreditHistory\Model\CreditHistory; | ||||
use common\logic\User\User\Model\User; | |||||
use common\logic\User\User\Model\UserSearch; | use common\logic\User\User\Model\UserSearch; | ||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
use common\logic\User\UserUserGroup\Model\UserUserGroup; | use common\logic\User\UserUserGroup\Model\UserUserGroup; | ||||
use yii\base\UserException; | use yii\base\UserException; | ||||
use yii\debug\models\search\User; | |||||
use yii\filters\AccessControl; | use yii\filters\AccessControl; | ||||
use yii\filters\VerbFilter; | use yii\filters\VerbFilter; | ||||
use \Yii; | use \Yii; | ||||
$newPassword = Yii::$app->request->post('submit_new_password'); | $newPassword = Yii::$app->request->post('submit_new_password'); | ||||
if ($newPassword) { | if ($newPassword) { | ||||
$password = Password::generate(); | $password = Password::generate(); | ||||
$model->setPassword($password); | |||||
$userManager->setPassword($model, $password); | |||||
$model->save(); | $model->save(); | ||||
$producer = $this->getProducerCurrent(); | $producer = $this->getProducerCurrent(); | ||||
*/ | */ | ||||
public function actionDelete(int $id) | public function actionDelete(int $id) | ||||
{ | { | ||||
$userManager = $this->getUserManager(); | |||||
$userProducerManager = $this->getUserProducerManager(); | $userProducerManager = $this->getUserProducerManager(); | ||||
$userProducer = $userProducerManager->findOneUserProducer($userProducer); | |||||
$user = $userManager->findOneUserById($id); | |||||
$producer = $this->getProducerCurrent(); | |||||
$userProducer = $userProducerManager->findOneUserProducer($user, $producer); | |||||
if ($userProducer) { | if ($userProducer) { | ||||
$userProducer->active = 0; | $userProducer->active = 0; | ||||
])->all(); | ])->all(); | ||||
$usersArray = []; | $usersArray = []; | ||||
foreach ($users as $user) { | |||||
if (isset($user['email']) && strlen($user['email'])) | |||||
foreach ($users as $key => $user) { | |||||
if (isset($user['email']) && strlen($user['email']) > 0) { | |||||
$usersArray[] = $user['email']; | $usersArray[] = $user['email']; | ||||
} | |||||
else { | |||||
unset($users[$key]); | |||||
} | |||||
} | } | ||||
$pointsSaleArray = PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->all(); | $pointsSaleArray = PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->all(); | ||||
if (isset($bodyResponseSendMail['Messages'])) { | if (isset($bodyResponseSendMail['Messages'])) { | ||||
foreach ($bodyResponseSendMail['Messages'] as $message) { | foreach ($bodyResponseSendMail['Messages'] as $message) { | ||||
if ($message['Status'] != 'success') { | if ($message['Status'] != 'success') { | ||||
$emailsErrorArray[] = $message['To']['Email']; | |||||
$emailsErrorArray[] = $message['Errors'][0]['ErrorMessage']; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
$messageError = 'Un problème est survenu lors de l\'envoi de votre email.'; | $messageError = 'Un problème est survenu lors de l\'envoi de votre email.'; | ||||
if (count($emailsErrorArray) > 0) { | if (count($emailsErrorArray) > 0) { | ||||
$messageError .= '<br />Problème détecté sur les adresses suivantes : ' . implode(',', $emailsErrorArray); | |||||
$messageError .= '<br />Problème détecté : ' . implode(',', $emailsErrorArray); | |||||
} | } | ||||
$this->setFlash('error', $messageError); | $this->setFlash('error', $messageError); | ||||
} | } |
namespace backend\models; | namespace backend\models; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\User\User\Model\User; | |||||
use yii\base\Model; | use yii\base\Model; | ||||
/** | /** | ||||
*/ | */ | ||||
class AccessUserProducerForm extends Model | class AccessUserProducerForm extends Model | ||||
{ | { | ||||
public $id_user ; | public $id_user ; | ||||
/** | /** |
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\helpers\Mailjet; | use common\helpers\Mailjet; | ||||
use common\logic\Producer\Producer\Wrapper\ProducerManager; | |||||
use common\logic\User\CreditHistory\Model\CreditHistory; | |||||
use common\logic\User\CreditHistory\Wrapper\CreditHistoryManager; | |||||
use common\logic\User\User\Model\User; | |||||
use common\logic\User\User\Wrapper\UserManager; | |||||
use common\logic\User\UserProducer\Model\UserProducer; | |||||
use Yii; | use Yii; | ||||
use yii\base\Model; | use yii\base\Model; | ||||
*/ | */ | ||||
public function save() | public function save() | ||||
{ | { | ||||
$creditHistoryManager = $this->getCreditHistoryManager(); | |||||
$userManager = UserManager::getInstance(); | |||||
$creditHistoryManager = CreditHistoryManager::getInstance(); | |||||
$producerManager = ProducerManager::getInstance(); | |||||
if ($this->validate()) { | if ($this->validate()) { | ||||
$creditHistory = new CreditHistory; | |||||
$creditHistory = new CreditHistory(); | |||||
$creditHistory->id_user = $this->id_user; | $creditHistory->id_user = $this->id_user; | ||||
$creditHistory->id_user_action = Yii::$app->user->identity->id; | $creditHistory->id_user_action = Yii::$app->user->identity->id; | ||||
$creditHistory->id_producer = GlobalParam::getCurrentProducerId() ; | $creditHistory->id_producer = GlobalParam::getCurrentProducerId() ; | ||||
$creditHistory->amount = $this->amount ; | $creditHistory->amount = $this->amount ; | ||||
$creditHistory->mean_payment = $this->mean_payment ; | $creditHistory->mean_payment = $this->mean_payment ; | ||||
$creditHistoryManager->save($creditHistory); | |||||
$creditHistoryManager->saveCreate($creditHistory); | |||||
// on prévient l'utilisateur que son compte vient d'être crédité | // on prévient l'utilisateur que son compte vient d'être crédité | ||||
if($this->send_mail) { | if($this->send_mail) { | ||||
]); | ]); | ||||
$paramsEmail = [ | $paramsEmail = [ | ||||
'from_email' => $producer->getEmailOpendistrib(), | |||||
'from_email' => $producerManager->getEmailOpendistrib($producer), | |||||
'from_name' => $producer->name, | 'from_name' => $producer->name, | ||||
'to_email' => $user->email, | 'to_email' => $user->email, | ||||
'to_name' => $user->getUsername(), | |||||
'to_name' => $userManager->getUsername($user), | |||||
'subject' => '['.$producer->name.'] Mouvement de crédit', | 'subject' => '['.$producer->name.'] Mouvement de crédit', | ||||
'content_view_text' => '@common/mail/creditUser-text.php', | 'content_view_text' => '@common/mail/creditUser-text.php', | ||||
'content_view_html' => '@common/mail/creditUser-html.php', | 'content_view_html' => '@common/mail/creditUser-html.php', |
$productDescription .= ' / '.$product->description ; | $productDescription .= ' / '.$product->description ; | ||||
} | } | ||||
if($product->price) { | if($product->price) { | ||||
$productDescription .= ' / '.Price::format($product->getPriceWithTax()) ; | |||||
$productDescription .= ' / '.Price::format($productManager->getPriceWithTax($product)) ; | |||||
$productDescription .= ' ('. $productManager->strUnit($product->unit, 'wording_unit').')' ; | $productDescription .= ' ('. $productManager->strUnit($product->unit, 'wording_unit').')' ; | ||||
} | } | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use yii\helpers\ArrayHelper ; | use yii\helpers\ArrayHelper ; | ||||
$userManager = $this->getUserManager(); | |||||
$this->setTitle('Accès') ; | $this->setTitle('Accès') ; | ||||
?> | ?> | ||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?php $form = ActiveForm::begin(); ?> | <?php $form = ActiveForm::begin(); ?> | ||||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( User::populateDropdownList(), ['class' => 'select2'])->label(''); ?> | |||||
<?= $form->field($modelAccessUserProducerForm, 'id_user')->dropDownList( $userManager->populateUserDropdownList(), ['class' => 'select2'])->label(''); ?> | |||||
<?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | <?= Html::submitButton('Ajouter', ['class' => 'btn btn-success']) ?> | ||||
<?php ActiveForm::end(); ?> | <?php ActiveForm::end(); ?> | ||||
</div> | </div> |
use yii\helpers\ArrayHelper; | use yii\helpers\ArrayHelper; | ||||
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager; | ||||
$deliveryNoteManager = $this->getDeliveryNoteManager(); | |||||
$this->setTitle('Bons de livraison'); | $this->setTitle('Bons de livraison'); | ||||
$this->addBreadcrumb($this->getTitle()); | $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']); | $this->addButton(['label' => 'Nouveau bon de livraison <span class="glyphicon glyphicon-plus"></span>', 'url' => ['distribution/index', 'message_generate_bl' => 1], 'class' => 'btn btn-primary']); | ||||
'valid' => 'Valide', | 'valid' => 'Valide', | ||||
], | ], | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
'value' => function ($model) use ($deliveryNoteManager) { | |||||
return $deliveryNoteManager->getHtmlLabel($model); | return $deliveryNoteManager->getHtmlLabel($model); | ||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'reference', | 'attribute' => 'reference', | ||||
'value' => function ($model) { | 'value' => function ($model) { | ||||
if (strlen($model->reference) > 0) { | |||||
return $model->reference; | |||||
} | |||||
return ''; | |||||
return (strlen($model->reference) > 0) ? $model->reference : ''; | |||||
} | } | ||||
], | ], | ||||
'name', | 'name', | ||||
'attribute' => 'date_distribution', | 'attribute' => 'date_distribution', | ||||
'options' => ['class' => 'form-control'] | 'options' => ['class' => 'form-control'] | ||||
]), | ]), | ||||
'value' => function ($model) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
'value' => function ($model) use ($deliveryNoteManager) { | |||||
$distribution = $deliveryNoteManager->getDistribution($model); | $distribution = $deliveryNoteManager->getDistribution($model); | ||||
if ($distribution) { | |||||
return date('d/m/Y', strtotime($distribution->date)); | |||||
} | |||||
return ''; | |||||
return $distribution ? date('d/m/Y', strtotime($distribution->date)) : ''; | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'header' => 'Point de vente', | 'header' => 'Point de vente', | ||||
'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'), | 'filter' => ArrayHelper::map(PointSale::searchAll([], ['as_array' => true]), 'id', 'name'), | ||||
'format' => 'html', | 'format' => 'html', | ||||
'value' => function ($model) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
'value' => function ($model) use ($deliveryNoteManager) { | |||||
$pointSale = $deliveryNoteManager->getPointSale($model); | $pointSale = $deliveryNoteManager->getPointSale($model); | ||||
if ($pointSale) { | |||||
return Html::encode($pointSale->name); | |||||
} | |||||
return ''; | |||||
return $pointSale ? Html::encode($pointSale->name) : ''; | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'attribute' => 'amount', | 'attribute' => 'amount', | ||||
'header' => 'Montant', | 'header' => 'Montant', | ||||
'value' => function ($deliveryNote) { | |||||
$deliveryNoteManager = DeliveryNoteManager::getInstance(); | |||||
'value' => function ($deliveryNote) use ($deliveryNoteManager) { | |||||
return $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true); | return $deliveryNoteManager->getAmountWithTax($deliveryNote, Order::INVOICE_AMOUNT_TOTAL, true); | ||||
} | } | ||||
], | ], | ||||
'headerOptions' => ['class' => 'column-actions'], | 'headerOptions' => ['class' => 'column-actions'], | ||||
'contentOptions' => ['class' => 'column-actions'], | 'contentOptions' => ['class' => 'column-actions'], | ||||
'buttons' => [ | 'buttons' => [ | ||||
'send' => function ($url, $model) { | |||||
return ((isset($model->user) && strlen($model->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||||
'send' => function ($url, $deliveryNote) use ($deliveryNoteManager) { | |||||
return ((isset($deliveryNote->user) && strlen($deliveryNote->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||||
'title' => 'Envoyer', 'class' => 'btn btn-default' | 'title' => 'Envoyer', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
}, | }, | ||||
'download' => function ($url, $model) { | |||||
'download' => function ($url, $deliveryNote) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | ||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | 'title' => 'Télécharger', 'class' => 'btn btn-default' | ||||
]); | ]); | ||||
}, | }, | ||||
'validate' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'validate' => function ($url, $deliveryNote) use ($deliveryNoteManager) { | |||||
return ($deliveryNoteManager->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'title' => 'Valider', 'class' => 'btn btn-default' | 'title' => 'Valider', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
}, | }, | ||||
'update' => function ($url, $model) { | |||||
'update' => function ($url, $deliveryNote) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | ||||
'title' => 'Modifier', 'class' => 'btn btn-default' | 'title' => 'Modifier', 'class' => 'btn btn-default' | ||||
]); | ]); | ||||
}, | }, | ||||
'delete' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'delete' => function ($url, $deliveryNote) use ($deliveryNoteManager) { | |||||
return ($deliveryNoteManager->isStatusDraft($deliveryNote) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => 'Supprimer', 'class' => 'btn btn-default' | 'title' => 'Supprimer', 'class' => 'btn btn-default' | ||||
]) : ''); | ]) : ''); | ||||
} | } |
<?php | |||||
use common\helpers\Price; | |||||
use common\logic\Product\Product\Model\Product; | |||||
use yii\helpers\Html; | |||||
$documentManager = $this->getDocumentManager(); | |||||
$productManager = $this->getProductManager(); | |||||
?> | |||||
<tr class="<?php if(isset($displayOrders) && $displayOrders): ?>order<?php endif; ?>"> | <tr class="<?php if(isset($displayOrders) && $displayOrders): ?>order<?php endif; ?>"> | ||||
<td class="align-left"> | <td class="align-left"> | ||||
<?php if($productOrder->product): ?> | <?php if($productOrder->product): ?> | ||||
<?php | <?php | ||||
$price = $productOrder->getPrice() ; | $price = $productOrder->getPrice() ; | ||||
if($document->isInvoicePrice() && $productOrder->getInvoicePrice()) { | |||||
if($documentManager->isInvoicePrice($document) && $productOrder->getInvoicePrice()) { | |||||
$price = $productOrder->getInvoicePrice() ; | $price = $productOrder->getInvoicePrice() ; | ||||
} | } | ||||
?> | ?> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | <?= $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'] ?> | ||||
</td> | </td> | ||||
<td class="align-center"><?= Product::strUnit($productOrder->unit, 'wording') ?></td> | |||||
<td class="align-center"><?= $productManager->strUnit($productOrder->unit, 'wording') ?></td> | |||||
<?php if($displayPrices): ?> | <?php if($displayPrices): ?> | ||||
<?php if($producer->taxRate->value != 0): ?> | <?php if($producer->taxRate->value != 0): ?> | ||||
<td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> | <td class="align-center"><?= $productOrder->taxRate->value * 100 ?> %</td> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?php if($document->getClass() == ''): ?> | |||||
<?php if($documentManager->getClass($document) == ''): ?> | |||||
<?= Price::format($price * $productOrder->quantity) ?> | <?= Price::format($price * $productOrder->quantity) ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= Price::format($price * $productOrder->quantity) ?> | <?= Price::format($price * $productOrder->quantity) ?> |
\backend\assets\VuejsDocumentFormAsset::register($this); | \backend\assets\VuejsDocumentFormAsset::register($this); | ||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$documentManager = $this->getDocumentManager(); | |||||
$userManager = $this->getUserManager(); | |||||
$documentClass = $documentManager->getClass($model); | |||||
?> | ?> | ||||
<div class="document-form" id="app-document-form" data-class-document="<?= $model->getClass() ?>" | |||||
<div class="document-form" id="app-document-form" data-class-document="<?= $documentClass ?>" | |||||
data-id-document="<?= ($model->id > 0) ? $model->id : $model->id ?>"> | data-id-document="<?= ($model->id > 0) ? $model->id : $model->id ?>"> | ||||
<div class="<?= ($action == 'update') ? 'col-md-6' : '' ?>"> | <div class="<?= ($action == 'update') ? 'col-md-6' : '' ?>"> | ||||
</div> | </div> | ||||
<div class="panel-body"> | <div class="panel-body"> | ||||
<?php $form = ActiveForm::begin(); ?> | <?php $form = ActiveForm::begin(); ?> | ||||
<?= Html::hiddenInput('classDocument', $model->getClass(), ['id' => 'class-document']) ?> | |||||
<?= Html::hiddenInput('classDocument', $documentClass, ['id' => 'class-document']) ?> | |||||
<?= Html::hiddenInput('typeAction', $action, ['id' => 'type-action']) ?> | <?= Html::hiddenInput('typeAction', $action, ['id' => 'type-action']) ?> | ||||
<?php if ($action == 'update'): ?> | <?php if ($action == 'update'): ?> | ||||
<?= Html::hiddenInput('idDocument', $model->id, ['id' => 'id-document']) ?> | <?= Html::hiddenInput('idDocument', $model->id, ['id' => 'id-document']) ?> | ||||
<?php if ($action == 'update'): ?> | <?php if ($action == 'update'): ?> | ||||
<?= $form->field($model, 'id_user', [ | <?= $form->field($model, 'id_user', [ | ||||
'template' => '{label} <div>{input}</div>' . $model->user->getUsername(), | |||||
'template' => '{label} <div>{input}</div>' . $userManager->getUsername($model->user), | |||||
])->hiddenInput(); ?> | ])->hiddenInput(); ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= $form->field($model, 'id_user', [ | <?= $form->field($model, 'id_user', [ | ||||
<?= $form->field($model, 'comment')->textarea(['rows' => 2])->hint('Affiché en bas du document') ?> | <?= $form->field($model, 'comment')->textarea(['rows' => 2])->hint('Affiché en bas du document') ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if ($action == 'create' && $model->getClass() == 'Invoice'): ?> | |||||
<?php if ($action == 'create' && $documentClass == 'Invoice'): ?> | |||||
<template v-if="idUser > 0"> | <template v-if="idUser > 0"> | ||||
<strong>Bons de livraison</strong> | <strong>Bons de livraison</strong> | ||||
<table v-if="deliveryNoteCreateArray && deliveryNoteCreateArray.length > 0" class="table table-bordered"> | <table v-if="deliveryNoteCreateArray && deliveryNoteCreateArray.length > 0" class="table table-bordered"> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<?php if ($action == 'update' && $model->getClass() == 'Invoice'): ?> | |||||
<?php if ($action == 'update' && $documentClass == 'Invoice'): ?> | |||||
<div class="panel panel-default"> | <div class="panel panel-default"> | ||||
<div class="panel-heading"> | <div class="panel-heading"> | ||||
Bons de livraison | Bons de livraison | ||||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/download', 'id' => $model->id]) ?>" | <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> | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-download-alt"></span> Télécharger (PDF)</a> | ||||
<?php if($model->isStatusValid()): ?> | |||||
<?php if($documentManager->isStatusValid($model)): ?> | |||||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/regenerate', 'id' => $model->id]) ?>" | <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> | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-repeat"></span> Regénérer (PDF)</a> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if ($model->getClass() == 'Invoice' && $producerManager->getConfig('option_export_evoliz')): ?> | |||||
<?php if ($documentClass == 'Invoice' && $producerManager->getConfig('option_export_evoliz')): ?> | |||||
<a href="<?= Yii::$app->urlManager->createUrl([Yii::$app->controller->getControllerUrl() . '/export-csv-evoliz', 'id' => $model->id]) ?>" | <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 | class="btn btn-sm btn-default"><span class="glyphicon glyphicon-save-file"></span> Export Evoliz | ||||
(CSV)</a> | (CSV)</a> |
<?php | <?php | ||||
use yii\helpers\Html; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use common\helpers\Price; | |||||
$producerManager = $this->getProducerManager(); | $producerManager = $this->getProducerManager(); | ||||
$userManager = $this->getUserManager(); | |||||
$documentManager = $this->getDocumentManager(); | |||||
$orderManager = $this->getOrderManager(); | |||||
$displayPrices = Yii::$app->controller->getClass() != 'DeliveryNote' || (Yii::$app->controller->getClass() == 'DeliveryNote' && $producerManager->getConfig('document_display_prices_delivery_note')); | $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'); | $displayProductDescription = $producerManager->getConfig('document_display_product_description'); | ||||
<div class="producer"> | <div class="producer"> | ||||
<?php if (strlen($producer->logo)) : ?> | <?php if (strlen($producer->logo)) : ?> | ||||
<div class="logo"> | <div class="logo"> | ||||
<img style="max-height: 80px;" src="<?= $producer->getUrlLogo() ?>"/> | |||||
<img style="max-height: 80px;" src="<?= $producerManager->getUrlLogo($producer) ?>"/> | |||||
</div> | </div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div class="address"><?= $producer->getFullAddress(true); ?></div> | |||||
<div class="address"><?= $producerManager->getFullAddress($producer, true); ?></div> | |||||
</div> | </div> | ||||
<div class="user"> | <div class="user"> | ||||
<?php if ($document->address && strlen($document->address) > 0): ?> | <?php if ($document->address && strlen($document->address) > 0): ?> | ||||
<?= nl2br($document->address) ?> | <?= nl2br($document->address) ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?= $document->user->getFullAddress(true); ?> | |||||
<?= $userManager->getFullAddress($document->user, true); ?> | |||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="reference"> | <div class="reference"> | ||||
<?php if (strlen($document->reference)) : ?> | <?php if (strlen($document->reference)) : ?> | ||||
<?= $document->getType(); ?> N°<?= $document->reference; ?> | |||||
<?= $documentManager->getType($document); ?> N°<?= $document->reference; ?> | |||||
<?php else: ?> | <?php else: ?> | ||||
<div class="block-is-draft"><?= $document->getType(); ?> non | <div class="block-is-draft"><?= $document->getType(); ?> non | ||||
validé<?= ($document->getType() == 'Facture') ? 'e' : '' ?></div> | validé<?= ($document->getType() == 'Facture') ? 'e' : '' ?></div> | ||||
</thead> | </thead> | ||||
<tbody> | <tbody> | ||||
<?php if ($document->isDisplayOrders()): ?> | |||||
<?php if ($producerManager->isDocumentDisplayOrders($document)): ?> | |||||
<?php foreach ($document->orders as $order): ?> | <?php foreach ($document->orders as $order): ?> | ||||
<tr> | <tr> | ||||
<td> | <td> | ||||
<strong><?= Html::encode($order->getUsername()); ?></strong> | |||||
<strong><?= Html::encode($orderManager->getOrderUsername($order)); ?></strong> | |||||
<?php if ($order->distribution): ?> | <?php if ($order->distribution): ?> | ||||
le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | le <?= date('d/m/Y', strtotime($order->distribution->date)) ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endforeach; ?> | <?php endforeach; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php if ($displayPrices): ?> | <?php if ($displayPrices): ?> | ||||
<?php $typeAmount = $document->isInvoicePrice() ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?> | |||||
<?php $typeAmount = $documentManager->isInvoicePrice($document) ? Order::INVOICE_AMOUNT_TOTAL : Order::AMOUNT_TOTAL; ?> | |||||
<?php if ($producer->taxRate->value != 0): ?> | <?php if ($producer->taxRate->value != 0): ?> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"><strong>Total HT</strong></td> | <td class="align-right" colspan="5"><strong>Total HT</strong></td> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= Price::format($document->getAmount($typeAmount)); ?> | |||||
<?= Price::format($documentManager->getAmount($document, $typeAmount)); ?> | |||||
</td> | </td> | ||||
</tr> | </tr> | ||||
<?php | <?php | ||||
$taxRateArray = $this->getTaxRateManager()->findTaxRatesAsArray(); | $taxRateArray = $this->getTaxRateManager()->findTaxRatesAsArray(); | ||||
foreach ($document->getTotalVatArray($typeAmount) as $idTaxRate => $totalVat): ?> | |||||
foreach ($documentManager->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?> | |||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"> | <td class="align-right" colspan="5"> | ||||
<strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | <strong>TVA <?= $taxRateArray[$idTaxRate]->value * 100 ?> %</strong></td> | ||||
<!--<tr> | <!--<tr> | ||||
<td class="align-right" colspan="5"><strong>TVA</strong></td> | <td class="align-right" colspan="5"><strong>TVA</strong></td> | ||||
<td class="align-center"> | <td class="align-center"> | ||||
<?= Price::format($document->getAmountWithTax($typeAmount) - $document->getAmount($typeAmount)) ?> | |||||
<?= Price::format($documentManager->getAmountWithTax($document, $typeAmount) - $documentManager->getAmount($document, $typeAmount)) ?> | |||||
</td> | </td> | ||||
</tr>--> | </tr>--> | ||||
<tr> | <tr> | ||||
<td class="align-right" colspan="5"><strong>Total TTC</strong></td> | <td class="align-right" colspan="5"><strong>Total TTC</strong></td> | ||||
<td class="align-center"><?= Price::format($document->getAmountWithTax($typeAmount)) ?></td> | |||||
<td class="align-center"><?= Price::format($documentManager->getAmountWithTax($document, $typeAmount)) ?></td> | |||||
</tr> | </tr> | ||||
<?php else: ?> | <?php else: ?> | ||||
<tr> | <tr> | ||||
<strong>Total</strong><br/> | <strong>Total</strong><br/> | ||||
TVA non applicable | TVA non applicable | ||||
</td> | </td> | ||||
<td class="align-center"><?= Price::format($document->getAmount($typeAmount)) ?></td> | |||||
<td class="align-center"><?= Price::format($documentManager->getAmount($document, $typeAmount)) ?></td> | |||||
</tr> | </tr> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
</div> | </div> | ||||
<?php | <?php | ||||
$fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($document->getClass())); ?> | |||||
$fieldProducerDocumentInfo = 'document_infos_' . str_replace('deliverynote', 'delivery_note', strtolower($documentManager->getClass($document))); ?> | |||||
<?php if (strlen($producer->$fieldProducerDocumentInfo)): ?> | <?php if (strlen($producer->$fieldProducerDocumentInfo)): ?> | ||||
<div class="block-infos"> | <div class="block-infos"> | ||||
<strong>Informations</strong><br/> | <strong>Informations</strong><br/> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\helpers\Url; | use common\helpers\Url; | ||||
use common\logic\Document\Invoice\Model\Invoice; | |||||
use common\logic\Order\Order\Model\Order; | |||||
$producerManager = $this->getProducerManager(); | |||||
$invoiceManager = $this->getInvoiceManager(); | |||||
$userManager = $this->getUserManager(); | |||||
$this->setTitle('Factures'); | $this->setTitle('Factures'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
<div class="invoice-index"> | <div class="invoice-index"> | ||||
<?php if(Invoice::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' => 'username', | |||||
'header' => 'Utilisateur', | |||||
'value' => function($model) { | |||||
return $model->user->getUsername() ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'date', | |||||
'header' => 'Date', | |||||
'value' => function($model) { | |||||
return date('d/m/Y',strtotime($model->date)) ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'amount', | |||||
'header' => 'Montant', | |||||
'value' => function($invoice) { | |||||
return $invoice->getAmountWithTax(Order::INVOICE_AMOUNT_TOTAL, true) ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'is_sent', | |||||
'header' => 'Envoyé', | |||||
'format' => 'raw', | |||||
'value' => function($model) { | |||||
if($model->is_sent) { | |||||
return '<span class="label label-success">Oui</span>'; | |||||
} | |||||
else { | |||||
return '<span class="label label-danger">Non</span>'; | |||||
} | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{validate} {update} {delete} {send} {download} {export-csv-evoliz}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'validate' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'title' => 'Valider', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'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' | |||||
]); | |||||
}, | |||||
'export-csv-evoliz' => function($url, $model) { | |||||
if(ProducerModel::getConfig('option_export_evoliz')) { | |||||
return Html::a('<span class="glyphicon glyphicon-save-file"></span> Evoliz', $url, [ | |||||
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default' | |||||
]); | |||||
} | |||||
<?php if (Invoice::searchCount()): ?> | |||||
<?= GridView::widget([ | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'status', | |||||
'label' => 'Statut', | |||||
'filter' => [ | |||||
'draft' => 'Brouillon', | |||||
'valid' => 'Valide', | |||||
], | |||||
'format' => 'raw', | |||||
'value' => function ($invoice) use ($invoiceManager) { | |||||
return $invoiceManager->getHtmlLabel($invoice); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'reference', | |||||
'value' => function ($invoice) { | |||||
return (strlen($invoice->reference) > 0) ? $invoice->reference : ''; | |||||
} | |||||
], | |||||
'name', | |||||
[ | |||||
'attribute' => 'username', | |||||
'header' => 'Utilisateur', | |||||
'value' => function ($invoice) use ($userManager) { | |||||
return $userManager->getUsername($invoice->user); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'date', | |||||
'header' => 'Date', | |||||
'value' => function ($invoice) { | |||||
return date('d/m/Y', strtotime($invoice->date)); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'amount', | |||||
'header' => 'Montant', | |||||
'value' => function ($invoice) use ($invoiceManager) { | |||||
return $invoiceManager->getAmountWithTax($invoice, Order::INVOICE_AMOUNT_TOTAL, true); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'is_sent', | |||||
'header' => 'Envoyé', | |||||
'format' => 'raw', | |||||
'value' => function ($model) { | |||||
if ($model->is_sent) { | |||||
return '<span class="label label-success">Oui</span>'; | |||||
} else { | |||||
return '<span class="label label-danger">Non</span>'; | |||||
} | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{validate} {update} {delete} {send} {download} {export-csv-evoliz}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'validate' => function ($url, $invoice) use ($invoiceManager) { | |||||
return ($invoiceManager->isStatusDraft($invoice) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'title' => 'Valider', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'send' => function ($url, $invoice) { | |||||
return ((isset($invoice->user) && strlen($invoice->user->email) > 0) ? Html::a('<span class="glyphicon glyphicon-send"></span>', $url, [ | |||||
'title' => 'Envoyer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'download' => function ($url, $invoice) { | |||||
return Html::a('<span class="glyphicon glyphicon-download-alt"></span>', $url, [ | |||||
'title' => 'Télécharger', 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'export-csv-evoliz' => function ($url, $invoice) use ($producerManager) { | |||||
if ($producerManager->getConfig('option_export_evoliz')) { | |||||
return Html::a('<span class="glyphicon glyphicon-save-file"></span> Evoliz', $url, [ | |||||
'title' => 'Export CSV Evoliz', 'class' => 'btn btn-default' | |||||
]); | |||||
} | |||||
return ''; | |||||
}, | |||||
'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">Aucune facture enregistrée</div> | |||||
<?php endif; ?> | |||||
return ''; | |||||
}, | |||||
'update' => function ($url, $invoice) { | |||||
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||||
]); | |||||
}, | |||||
'delete' => function ($url, $invoice) use ($invoiceManager) { | |||||
return ($invoiceManager->isStatusDraft($invoice) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); ?> | |||||
<?php else: ?> | |||||
<div class="alert alert-info">Aucune facture enregistrée</div> | |||||
<?php endif; ?> | |||||
</div> | </div> |
<?php | |||||
/** | |||||
* Copyright distrib (2018) | |||||
* | |||||
* contact@opendistrib.net | |||||
* | |||||
* 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 yii\helpers\Html; | |||||
use yii\bootstrap\Nav; | |||||
use yii\bootstrap\NavBar; | |||||
use yii\widgets\Breadcrumbs; | |||||
use yii\widgets\ActiveForm; | |||||
use yii\helpers\ArrayHelper; | |||||
use common\helpers\Url; | |||||
use common\helpers\GlobalParam; | |||||
/* @var $this \yii\web\View */ | |||||
/* @var $content string */ | |||||
\common\assets\CommonAsset::register($this); | |||||
\backend\assets\AppAsset::register($this); | |||||
$producer = null; | |||||
if (!Yii::$app->user->isGuest) { | |||||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | |||||
} | |||||
?> | |||||
<?php $this->beginPage() ?> | |||||
<!DOCTYPE html> | |||||
<html lang="<?= Yii::$app->language ?>"> | |||||
<head> | |||||
<meta charset="<?= Yii::$app->charset ?>"> | |||||
<meta name="viewport" content="width=device-width, initial-scale=1"> | |||||
<meta name="baseurl" content="<?= Yii::$app->urlManagerBackend->baseUrl; ?>"> | |||||
<meta name="baseurl-absolute" | |||||
content="<?= Yii::$app->urlManagerBackend->getHostInfo() . Yii::$app->urlManagerBackend->baseUrl; ?>"> | |||||
<link rel="icon" type="image/png" href="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/favicon3.png"/> | |||||
<?= Html::csrfMetaTags() ?> | |||||
<title><?= Html::encode($this->title) ?> - distrib</title> | |||||
<?php $this->head() ?> | |||||
</head> | |||||
<body> | |||||
<?php $this->beginBody() ?> | |||||
<div class="wrap"> | |||||
<?php | |||||
NavBar::begin([ | |||||
'brandLabel' => '<img class="logo" src="' . Yii::$app->urlManager->getBaseUrl() . '/img/laboulange3.png" />', | |||||
'brandUrl' => Yii::$app->homeUrl, | |||||
'innerContainerOptions' => ['class' => 'container-fluid'], | |||||
'options' => [ | |||||
'class' => 'navbar-inverse navbar-fixed-top nav-header', | |||||
], | |||||
]); | |||||
$menuItems = [ | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-home"></span> Tableau de bord', | |||||
'url' => ['/site/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-calendar"></span> Commandes', | |||||
'url' => ['/order/index'], | |||||
'visible' => !Yii::$app->user->isGuest, | |||||
'items' => [ | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-calendar"></span> Toutes les commandes', | |||||
'url' => ['/order/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-repeat"></span> Abonnements', | |||||
'url' => ['/subscription/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
] | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-grain"></span> Produits', | |||||
'url' => ['/product/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-map-marker"></span> Points de vente', | |||||
'url' => ['/point-sale/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-user"></span> Clients', | |||||
'url' => ['/user/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-plus"></span>', | |||||
'url' => ['/producer/update'], | |||||
'visible' => !Yii::$app->user->isGuest, | |||||
'items' => [ | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-cog"></span> Paramètres', | |||||
'url' => ['/producer/update'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-bullhorn"></span> Communiquer', | |||||
'url' => ['/communicate/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-euro"></span> Mon abonnement', | |||||
'url' => ['/producer/billing'], | |||||
'visible' => !Yii::$app->user->isGuest, | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-stats"></span> Statistiques', | |||||
'url' => ['/stats/index'], | |||||
'visible' => !Yii::$app->user->isGuest, | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-stats"></span> Statistiques produits', | |||||
'url' => ['/stats/products'], | |||||
'visible' => !Yii::$app->user->isGuest, | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-wrench"></span> Développement', | |||||
'url' => ['/development/index'], | |||||
'visible' => !Yii::$app->user->isGuest | |||||
], | |||||
], | |||||
] | |||||
]; | |||||
if (Yii::$app->user->isGuest) { | |||||
$menuItems[] = ['label' => 'Connexion', 'url' => ['/site/login']]; | |||||
} else { | |||||
if (Yii::$app->user->identity->status == User::STATUS_ADMIN) { | |||||
$menuItems[] = [ | |||||
'label' => '<span class="glyphicon glyphicon-asterisk"></span>', | |||||
'url' => '#', | |||||
'items' => [ | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-th-list"></span> Producteurs', | |||||
'url' => ['producer-admin/index'], | |||||
'visible' => !Yii::$app->user->isGuest, | |||||
], | |||||
[ | |||||
'label' => '<span class="glyphicon glyphicon-euro"></span> Facturation', | |||||
'url' => ['producer-admin/billing'], | |||||
'visible' => false, | |||||
], | |||||
] | |||||
]; | |||||
} | |||||
$menuItems[] = [ | |||||
'label' => '<span class="glyphicon glyphicon-off"></span>', | |||||
'url' => ['/site/logout'], | |||||
'linkOptions' => ['data-method' => 'post', 'title' => 'Déconnexion'] | |||||
]; | |||||
$menuItems[] = [ | |||||
'label' => '<span class="retour-site">Retour sur le site</span>', | |||||
'url' => Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]), | |||||
]; | |||||
} | |||||
echo Nav::widget([ | |||||
'options' => ['class' => 'navbar-nav navbar-right'], | |||||
'items' => $menuItems, | |||||
'encodeLabels' => false | |||||
]); | |||||
NavBar::end(); | |||||
?> | |||||
<div class="container-fluid container-body"> | |||||
<?php if (YII_ENV == 'dev' || YII_ENV == 'demo'): ?> | |||||
<div id="env-dev"><?php if (YII_ENV == 'dev'): ?>Dév.<?php elseif (YII_ENV == 'demo'): ?>Démo<?php endif; ?></div> | |||||
<?php endif; ?> | |||||
<?php if (!Yii::$app->user->isGuest): ?> | |||||
<div class="name-producer"> | |||||
<?php if ( User::getCurrentStatus() == User::STATUS_PRODUCER): ?> | |||||
<span><?= Html::encode(Yii::$app->user->identity->getNameProducer()); ?></span> | |||||
<?php elseif ( User::getCurrentStatus() == User::STATUS_ADMIN): ?> | |||||
<?php $form = ActiveForm::begin(['id' => 'select-producer']); ?> | |||||
<?= | |||||
Html::dropDownList('select_producer', GlobalParam::getCurrentProducerId(), ArrayHelper::map(ProducerModel::find()->orderBy('name ASC')->all(), 'id', function ($model, $defaultValue) { | |||||
return $model->name; | |||||
})); | |||||
?> | |||||
<?php ActiveForm::end(); ?> | |||||
<?php endif; ?> | |||||
<?php | |||||
$producer = Producer::findOne(GlobalParam::getCurrentProducerId()); | |||||
if (!$producer->active): | |||||
?> | |||||
<span class="label label-danger" data-toggle="tooltip" data-placement="bottom" | |||||
data-original-title="Activez votre établissement quand vous le souhaitez afin de la rendre visible à vos clients."> | |||||
<?= Html::a('Hors-ligne', ['producer/update']); ?> | |||||
</span> | |||||
<?php endif; ?> | |||||
<div class="clr"></div> | |||||
</div> | |||||
<?php endif; ?> | |||||
<?php if (YII_ENV == 'demo'): ?> | |||||
<div id="block-demo"> | |||||
<div class="container-fluid"> | |||||
<span class="glyphicon glyphicon-eye-open"></span> <strong>Espace de démonstration</strong> : | |||||
Testez la plateforme sans avoir à vous inscrire. Les données sont réinitialisées quotidiennement | |||||
• <?= Html::a('Retour', Url::env('prod', 'frontend')) ?> | |||||
</div> | |||||
</div> | |||||
<?php endif; ?> | |||||
<?= | |||||
Breadcrumbs::widget([ | |||||
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [], | |||||
]) | |||||
?> | |||||
<?= $content ?> | |||||
</div> | |||||
</div> | |||||
<div id="alerts-fixed"></div> | |||||
<footer class="footer"> | |||||
<div class="container-fluid"> | |||||
<p class="pull-left"> | |||||
<a href="<?php echo Url::frontend('site/contact'); ?>">Contact</a> • | |||||
<a href="<?php echo Url::frontend('site/mentions'); ?>">Mentions légales</a> • | |||||
<a href="<?php echo Url::frontend('site/cgv'); ?>">CGS</a> | |||||
<a id="code-source" href="https://framagit.org/guillaume-bourgeois/laboiteapain">Code source <img | |||||
src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-framagit.png" | |||||
alt="Hébergé par Framasoft"/> <img | |||||
src="<?php echo Yii::$app->urlManager->getBaseUrl(); ?>/img/logo-gitlab.png" | |||||
alt="Propulsé par Gitlab"/></a> | |||||
</p> | |||||
<p class="pull-right"><?= Yii::powered() ?></p> | |||||
</div> | |||||
</footer> | |||||
<?php $this->endBody() ?> | |||||
<!-- analytics --> | |||||
<script> | |||||
(function (i, s, o, g, r, a, m) { | |||||
i['GoogleAnalyticsObject'] = r; | |||||
i[r] = i[r] || function () { | |||||
(i[r].q = i[r].q || []).push(arguments) | |||||
}, i[r].l = 1 * new Date(); | |||||
a = s.createElement(o), | |||||
m = s.getElementsByTagName(o)[0]; | |||||
a.async = 1; | |||||
a.src = g; | |||||
m.parentNode.insertBefore(a, m) | |||||
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga'); | |||||
ga('create', 'UA-86917043-1', 'auto'); | |||||
ga('send', 'pageview'); | |||||
</script> | |||||
</body> | |||||
</html> | |||||
<?php $this->endPage() ?> |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
?> | ?> | ||||
<h3>Facturation</h3> | <h3>Facturation</h3> | ||||
<?= $form->field($model, 'option_billing_type') | <?= $form->field($model, 'option_billing_type') | ||||
->dropDownList(ProducerModel::getBillingTypePopulateDropdown()); ?> | |||||
->dropDownList(Producer::getBillingTypePopulateDropdown()); ?> | |||||
<?= $form->field($model, 'option_billing_frequency') | <?= $form->field($model, 'option_billing_frequency') | ||||
->dropDownList(ProducerModel::getBillingFrequencyPopulateDropdown()); ?> | |||||
->dropDownList(Producer::getBillingFrequencyPopulateDropdown()); ?> | |||||
<?= $form->field($model, 'option_billing_reduction') | <?= $form->field($model, 'option_billing_reduction') | ||||
->dropDownList([ | ->dropDownList([ | ||||
0 => 'Non', | 0 => 'Non', |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use common\logic\User\User\Model\User; | |||||
use common\logic\Producer\Producer\Model\Producer; | |||||
use common\helpers\Price; | |||||
$producerManager = $this->getProducerManager(); | |||||
$this->setTitle('Producteurs') ; | $this->setTitle('Producteurs') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
'attribute' => 'À facturer / chiffre d\'affaire', | 'attribute' => 'À facturer / chiffre d\'affaire', | ||||
'label' => 'À facturer / chiffre d\'affaire', | 'label' => 'À facturer / chiffre d\'affaire', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | |||||
'value' => function($producer) use ($producerManager) { | |||||
$str = ''; | $str = ''; | ||||
if($model->isBillingFrequencyMonthly()) { | |||||
$str .= $model->getSummaryAmountsToBeBilled('Mois dernier', 1); | |||||
if($producerManager->isBillingFrequencyMonthly($producer)) { | |||||
$str .= $producerManager->getSummaryAmountsToBeBilled($producer, 'Mois dernier', 1); | |||||
} | } | ||||
elseif($model->isBillingFrequencyQuarterly()) { | |||||
$str .= $model->getSummaryAmountsToBeBilled('3 derniers mois', 3); | |||||
elseif($producerManager->isBillingFrequencyQuarterly($producer)) { | |||||
$str .= $producerManager->getSummaryAmountsToBeBilled($producer, '3 derniers mois', 3); | |||||
} | } | ||||
elseif($model->isBillingFrequencyBiannual()) { | |||||
$str .= $model->getSummaryAmountsToBeBilled('6 derniers mois', 6); | |||||
elseif($producerManager->isBillingFrequencyBiannual($producer)) { | |||||
$str .= $producerManager->getSummaryAmountsToBeBilled($producer, '6 derniers mois', 6); | |||||
} | } | ||||
if($model->option_billing_reduction && strlen($str)) { | |||||
if($producer->option_billing_reduction && strlen($str)) { | |||||
$str .= '<br /><u>Avec réduction</u> : '; | $str .= '<br /><u>Avec réduction</u> : '; | ||||
if($model->option_billing_reduction_percentage) { | |||||
$str .= ' '.$model->option_billing_reduction_percentage.' %'; | |||||
if($producer->option_billing_reduction_percentage) { | |||||
$str .= ' '.$producer->option_billing_reduction_percentage.' %'; | |||||
} | } | ||||
} | } | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
$str = '<ul style="margin: 0px;padding-left: 15px;">'; | $str = '<ul style="margin: 0px;padding-left: 15px;">'; | ||||
$str .= '<li>'.ProducerModel::$billingFrequencyArray[$model->option_billing_frequency].'</li>'; | |||||
$str .= '<li>'.Producer::$billingFrequencyArray[$model->option_billing_frequency].'</li>'; | |||||
if($model->option_billing_permanent_transfer) { | if($model->option_billing_permanent_transfer) { | ||||
$str .= '<li>Virement permanent : <strong>'.Price::format($model->option_billing_permanent_transfer_amount, 0).'</strong></li>'; | $str .= '<li>Virement permanent : <strong>'.Price::format($model->option_billing_permanent_transfer_amount, 0).'</strong></li>'; |
termes. | termes. | ||||
*/ | */ | ||||
$producerManager = $this->getProducerManager(); | |||||
$producerPriceRangeManager = $this->getProducerPriceRangeManager(); | |||||
$this->setTitle('Tarifs') ; | $this->setTitle('Tarifs') ; | ||||
$this->addBreadcrumb($this->getTitle()) ; | $this->addBreadcrumb($this->getTitle()) ; | ||||
<?php | <?php | ||||
if($producer->isBillingTypeFreePrice()) { | |||||
if($producerManager->isBillingTypeFreePrice($producer)) { | |||||
echo '<div class="alert alert-info">'; | echo '<div class="alert alert-info">'; | ||||
echo "Vous bénéficiez actuellement d'un abonnement à prix libre dont voici le montant : <strong>".$producer->getFreePrice()."</strong>"; | echo "Vous bénéficiez actuellement d'un abonnement à prix libre dont voici le montant : <strong>".$producer->getFreePrice()."</strong>"; | ||||
echo '</div>'; | echo '</div>'; | ||||
} | } | ||||
elseif($producer->isBillingTypeClassic()) { | |||||
elseif($producerManager->isBillingTypeClassic($producer)) { | |||||
$month = date('Y-m', strtotime('-1 month')); | $month = date('Y-m', strtotime('-1 month')); | ||||
$turnover = $producer->getTurnover($month); | |||||
$amountBilledLastMonth = $producer->getAmountToBeBilledByTurnover($turnover); | |||||
$turnover = $producerManager->getTurnover($producer, $month); | |||||
$amountBilledLastMonth = $producerPriceRangeManager->getAmountToBeBilledByTurnover($turnover); | |||||
if($amountBilledLastMonth) { | if($amountBilledLastMonth) { | ||||
echo '<div class="alert alert-info">'; | echo '<div class="alert alert-info">'; | ||||
echo "À titre d'information, voici le tarif retenu pour le mois dernier (".strftime('%B', strtotime('-1 month')).") : <strong>".$producer->getAmountToBeBilledByMonth($month, true)."</strong>"; | |||||
echo "À titre d'information, voici le tarif retenu pour le mois dernier (".strftime('%B', strtotime('-1 month')).") : <strong>".$producerManager->getAmountToBeBilledByMonth($producer, $month, true)."</strong>"; | |||||
echo "<br />Le chiffre d'affaire pris en compte pour ce calcul est : <strong>".Price::format($turnover)." HT</strong>"; | echo "<br />Le chiffre d'affaire pris en compte pour ce calcul est : <strong>".Price::format($turnover)." HT</strong>"; | ||||
echo '<br /><a href="'.Yii::$app->urlManager->createUrl(['stats/index']).'">Voir l\'évolution de mon chiffre d\'affaire</a>'; | echo '<br /><a href="'.Yii::$app->urlManager->createUrl(['stats/index']).'">Voir l\'évolution de mon chiffre d\'affaire</a>'; | ||||
echo '</div>'; | echo '</div>'; |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
use common\logic\Config\TaxRate\Model\TaxRate; | |||||
use common\logic\Document\Document\Model\Document; | |||||
use yii\helpers\ArrayHelper; | |||||
\backend\assets\VuejsProducerUpdateAsset::register($this); | |||||
$userManager = $this->getUserManager(); | |||||
\backend\assets\VuejsProducerUpdateAsset::register($this); | |||||
$this->setTitle('Paramètres'); | $this->setTitle('Paramètres'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
<script> | <script> | ||||
var appInitValues = { | var appInitValues = { | ||||
isAdmin: <?= (int) User::isCurrentAdmin() ?> | |||||
isAdmin: <?= (int) $userManager->isCurrentAdmin() ?> | |||||
}; | }; | ||||
</script> | </script> | ||||
<?= $form->field($model, 'credit_functioning') | <?= $form->field($model, 'credit_functioning') | ||||
->dropDownList([ | ->dropDownList([ | ||||
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); ?> | |||||
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); ?> | |||||
<?= $form->field($model, 'use_credit_checked_default') | <?= $form->field($model, 'use_credit_checked_default') | ||||
->dropDownList([ | ->dropDownList([ | ||||
1 => 'Oui', | 1 => 'Oui', | ||||
], []); ?> | ], []); ?> | ||||
<?= $form->field($model, 'option_online_payment_minimum_amount') | <?= $form->field($model, 'option_online_payment_minimum_amount') | ||||
->hint('Valeur par défaut si non défini : '.ProducerModel::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT.' €') | |||||
->hint('Valeur par défaut si non défini : '.Producer::ONLINE_PAYMENT_MINIMUM_AMOUNT_DEFAULT.' €') | |||||
->textInput(); ?> | ->textInput(); ?> | ||||
<?= $form->field($model, 'option_stripe_mode_test')->dropDownList([ | <?= $form->field($model, 'option_stripe_mode_test')->dropDownList([ | ||||
0 => 'Non', | 0 => 'Non', |
* termes. | * termes. | ||||
*/ | */ | ||||
use common\logic\Document\Quotation\Model\Quotation; | |||||
use yii\grid\GridView; | |||||
use common\logic\Order\Order\Model\Order; | |||||
use yii\helpers\Html; | |||||
$quotationManager = $this->getQuotationManager(); | |||||
$userManager = $this->getUserManager(); | |||||
$this->setTitle('Devis'); | $this->setTitle('Devis'); | ||||
$this->addBreadcrumb($this->getTitle()); | $this->addBreadcrumb($this->getTitle()); | ||||
$this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plus"></span>', 'url' => 'quotation/create', 'class' => 'btn btn-primary']); | $this->addButton(['label' => 'Nouveau devis <span class="glyphicon glyphicon-plus"></span>', 'url' => 'quotation/create', 'class' => 'btn btn-primary']); | ||||
?> | ?> | ||||
<div class="quotation-index"> | <div class="quotation-index"> | ||||
<?php if(Quotation::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' => 'id_user', | |||||
'header' => 'Utilisateur', | |||||
'value' => function($model) { | |||||
return $model->user->getUsername() ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'date', | |||||
'header' => 'Date', | |||||
'value' => function($model) { | |||||
return date('d/m/Y',strtotime($model->date)) ; | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'amount', | |||||
'header' => 'Montant', | |||||
'value' => function($invoice) { | |||||
return $invoice->getAmountWithTax(Order::AMOUNT_TOTAL, true) ; | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{transform} {validate} {update} {delete} {send} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'transform' => function ($url, $model) { | |||||
return ($model->isStatusValid() ? Html::a('<span class="glyphicon glyphicon-check"></span>', $url, [ | |||||
'title' => 'Transformer en facture', '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' | |||||
]) : ''); | |||||
}, | |||||
'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' | |||||
]); | |||||
}, | |||||
'update' => function ($url, $model) { | |||||
return ($model->isStatusDraft() ? 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 devis enregistré</div> | |||||
<?php endif; ?> | |||||
<?php if (Quotation::searchCount()): ?> | |||||
<?= GridView::widget([ | |||||
'filterModel' => $searchModel, | |||||
'dataProvider' => $dataProvider, | |||||
'columns' => [ | |||||
[ | |||||
'attribute' => 'status', | |||||
'label' => 'Statut', | |||||
'filter' => [ | |||||
'draft' => 'Brouillon', | |||||
'valid' => 'Valide', | |||||
], | |||||
'format' => 'raw', | |||||
'value' => function ($quotation) use ($quotationManager) { | |||||
return $quotationManager->getHtmlLabel($quotation); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'reference', | |||||
'value' => function ($model) { | |||||
return (strlen($model->reference) > 0) ? $model->reference : ''; | |||||
} | |||||
], | |||||
'name', | |||||
[ | |||||
'attribute' => 'id_user', | |||||
'header' => 'Utilisateur', | |||||
'value' => function ($quotation) use ($userManager) { | |||||
return $userManager->getUsername($quotation->user); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'date', | |||||
'header' => 'Date', | |||||
'value' => function ($quotation) { | |||||
return date('d/m/Y', strtotime($quotation->date)); | |||||
} | |||||
], | |||||
[ | |||||
'attribute' => 'amount', | |||||
'header' => 'Montant', | |||||
'value' => function ($quotation) use ($quotationManager) { | |||||
return $quotationManager->getAmountWithTax($quotation, Order::AMOUNT_TOTAL, true); | |||||
} | |||||
], | |||||
[ | |||||
'class' => 'yii\grid\ActionColumn', | |||||
'template' => '{transform} {validate} {update} {delete} {send} {download}', | |||||
'headerOptions' => ['class' => 'column-actions'], | |||||
'contentOptions' => ['class' => 'column-actions'], | |||||
'buttons' => [ | |||||
'transform' => function ($url, $quotation) use ($quotationManager) { | |||||
return ($quotationManager->isStatusValid($quotation) ? Html::a('<span class="glyphicon glyphicon-check"></span>', $url, [ | |||||
'title' => 'Transformer en facture', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'validate' => function ($url, $quotation) use ($quotationManager) { | |||||
return ($quotationManager->isStatusValid($quotation) ? Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [ | |||||
'title' => 'Valider', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'send' => function ($url, $quotation) { | |||||
return ((isset($quotation->user) && strlen($quotation->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' | |||||
]); | |||||
}, | |||||
'update' => function ($url, $quotation) use ($quotationManager) { | |||||
return ($quotationManager->isStatusDraft($quotation) ? Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [ | |||||
'title' => 'Modifier', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
}, | |||||
'delete' => function ($url, $quotation) use ($quotationManager) { | |||||
return ($quotationManager->isStatusDraft($quotation) ? Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [ | |||||
'title' => 'Supprimer', 'class' => 'btn btn-default' | |||||
]) : ''); | |||||
} | |||||
], | |||||
], | |||||
], | |||||
]); ?> | |||||
<?php else: ?> | |||||
<div class="alert alert-info">Aucun devis enregistré</div> | |||||
<?php endif; ?> | |||||
</div> | </div> |
'format' => 'raw', | 'format' => 'raw', | ||||
'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'), | 'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => GlobalParam::getCurrentProducerId()])->asArray()->all(), 'id', 'name'), | ||||
'value' => function($model) { | 'value' => function($model) { | ||||
return Html::encode($model->pointSale->name) ; | |||||
if($model->pointSale) { | |||||
return Html::encode($model->pointSale->name) ; | |||||
} | |||||
return ''; | |||||
} | } | ||||
], | ], | ||||
[ | [ |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\models\ProductPrice ; | |||||
use yii\helpers\ArrayHelper; | |||||
\backend\assets\VuejsUserFormAsset::register($this); | \backend\assets\VuejsUserFormAsset::register($this); | ||||
$userManager = $this->getUserManager(); | |||||
$producerManager = $this->getProducerManager(); | |||||
?> | ?> | ||||
<div class="user-form" id="app-user-form"> | <div class="user-form" id="app-user-form"> | ||||
]); ?> | ]); ?> | ||||
<?= $form->field($model, 'type') | <?= $form->field($model, 'type') | ||||
->dropDownList( User::getTypeChoicesArray(), [ | |||||
->dropDownList( $userManager->getTypeChoicesArray(), [ | |||||
'v-model' => 'type' | 'v-model' => 'type' | ||||
]) ; ?> | ]) ; ?> | ||||
<?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?> | <?= $form->field($model, 'name_legal_person', ['options' => ['v-show' => "type == 'legal-person'"]])->textInput() ?> | ||||
<?= $form->field($model, 'email')->textInput() ?> | <?= $form->field($model, 'email')->textInput() ?> | ||||
<?= $form->field($model, 'address')->textarea() ?> | <?= $form->field($model, 'address')->textarea() ?> | ||||
<?php if(ProducerModel::getConfig('option_export_evoliz')): ?> | |||||
<?php if($producerManager->getConfig('option_export_evoliz')): ?> | |||||
<?= $form->field($model, 'evoliz_code')->textInput() ?> | <?= $form->field($model, 'evoliz_code')->textInput() ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use yii\widgets\ActiveForm; | use yii\widgets\ActiveForm; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\User\CreditHistory\Model\CreditHistory; | |||||
use common\helpers\MeanPayment; | |||||
$creditHistoryManager = $this->getCreditHistoryManager(); | $creditHistoryManager = $this->getCreditHistoryManager(); | ||||
$producerManager = $this->getProducerManager(); | |||||
$userManager = $this->getUserManager(); | |||||
$this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | $this->setTitle('Créditer <small>'.Html::encode($user->lastname.' '.$user->name).'</small>', 'Créditer '.Html::encode($user->lastname.' '.$user->name)) ; | ||||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ; | $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ; | ||||
<div class="user-credit"> | <div class="user-credit"> | ||||
<?php | <?php | ||||
$producer = Producer::searchOne([ | |||||
'id' => GlobalParam::getCurrentProducerId() | |||||
]); | |||||
$producer = $producerManager->findOneProducerById(GlobalParam::getCurrentProducerId()); | |||||
if(!$producer->credit) | if(!$producer->credit) | ||||
{ | { | ||||
</div> | </div> | ||||
<div class="col-md-8"> | <div class="col-md-8"> | ||||
<h2>Historique <span class="the-credit"><?= number_format($user->getCredit($producer->id), 2); ?> €</span></h2> | |||||
<h2>Historique <span class="the-credit"><?= number_format($userManager->getCredit($user, $producer), 2); ?> €</span></h2> | |||||
<table class="table table-bordered"> | <table class="table table-bordered"> | ||||
<thead> | <thead> | ||||
<tr> | <tr> |
*/ | */ | ||||
use yii\grid\GridView; | use yii\grid\GridView; | ||||
use yii\helpers\Html; | |||||
$this->setTitle('Commandes <small>' . Html::encode($user->getUsername()) . '</small>', 'Commandes de ' . Html::encode($user->getUsername())); | |||||
$userManager = $this->getUserManager(); | |||||
$orderManager = $this->getOrderManager(); | |||||
$this->setTitle('Commandes <small>' . Html::encode($userManager->getUsername($user)) . '</small>', 'Commandes de ' . Html::encode($userManager->getUsername($user))); | |||||
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | $this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]); | ||||
$this->addBreadcrumb(['label' => Html::encode($user->lastname . ' ' . $user->name)]); | $this->addBreadcrumb(['label' => Html::encode($user->lastname . ' ' . $user->name)]); | ||||
$this->addBreadcrumb('Commandes'); | $this->addBreadcrumb('Commandes'); | ||||
[ | [ | ||||
'attribute' => 'distribution.date', | 'attribute' => 'distribution.date', | ||||
'label' => 'Date de livraison', | 'label' => 'Date de livraison', | ||||
'value' => function ($model) { | |||||
return date('d/m/Y',strtotime($model->distribution->date)); | |||||
'value' => function ($user) { | |||||
return date('d/m/Y',strtotime($user->distribution->date)); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Historique', | 'label' => 'Historique', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) { | |||||
return $model->getStrHistory(); | |||||
'value' => function ($order) use ($orderManager) { | |||||
return $orderManager->getHistorySummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Résumé', | 'label' => 'Résumé', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) { | |||||
return $model->getCartSummary(); | |||||
'value' => function ($order) use ($orderManager) { | |||||
return $orderManager->getCartSummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Point de vente', | 'label' => 'Point de vente', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) { | |||||
return $model->getPointSaleSummary(); | |||||
'value' => function ($order) use ($orderManager) { | |||||
return $orderManager->getPointSaleSummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ | ||||
'label' => 'Montant', | 'label' => 'Montant', | ||||
'format' => 'raw', | 'format' => 'raw', | ||||
'value' => function ($model) { | |||||
$model->init(); | |||||
return $model->getAmountSummary(); | |||||
'value' => function ($order) use ($orderManager) { | |||||
$orderManager->initOrder($order); | |||||
return $orderManager->getAmountSummary($order); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
use common\logic\Document\Invoice\Wrapper\InvoiceContainer; | use common\logic\Document\Invoice\Wrapper\InvoiceContainer; | ||||
use common\logic\Document\Invoice\Wrapper\InvoiceManager; | use common\logic\Document\Invoice\Wrapper\InvoiceManager; | ||||
use common\logic\Document\Quotation\Wrapper\QuotationContainer; | use common\logic\Document\Quotation\Wrapper\QuotationContainer; | ||||
use common\logic\Document\Invoice\Wrapper\QuotationManager; | |||||
use common\logic\Document\Quotation\Wrapper\QuotationManager; | |||||
use common\logic\Order\Order\Wrapper\OrderContainer; | use common\logic\Order\Order\Wrapper\OrderContainer; | ||||
use common\logic\Order\Order\Wrapper\OrderManager; | use common\logic\Order\Order\Wrapper\OrderManager; | ||||
use common\logic\Order\OrderStatusHistory\Wrapper\OrderStatusHistoryContainer; | use common\logic\Order\OrderStatusHistory\Wrapper\OrderStatusHistoryContainer; |
// isAvailable | // isAvailable | ||||
public function isDistributionAvailable(Distribution $distribution): bool | public function isDistributionAvailable(Distribution $distribution): bool | ||||
{ | { | ||||
$dateToday = date('Y-m-d'); | |||||
$producer = $distribution->producer; | $producer = $distribution->producer; | ||||
$dateDistribution = $distribution->date; | $dateDistribution = $distribution->date; | ||||
$dayDistribution = strtolower(date('l', strtotime($dateDistribution))); | $dayDistribution = strtolower(date('l', strtotime($dateDistribution))); | ||||
*/ | */ | ||||
public function filterDistributionsByDateDelay(array $distributionsArray): array | public function filterDistributionsByDateDelay(array $distributionsArray): array | ||||
{ | { | ||||
$producer = GlobalParam::getCurrentProducer(); | |||||
$dateToday = date('Y-m-d'); | |||||
foreach ($distributionsArray as $keyDistribution => $distribution) { | foreach ($distributionsArray as $keyDistribution => $distribution) { | ||||
if(!$this->isDistributionAvailable($distribution)) { | if(!$this->isDistributionAvailable($distribution)) { | ||||
unset($distributionsArray[$keyDistribution]); | unset($distributionsArray[$keyDistribution]); |
use common\logic\AbstractContainer; | use common\logic\AbstractContainer; | ||||
use common\logic\Document\DeliveryNote\Model\DeliveryNote; | use common\logic\Document\DeliveryNote\Model\DeliveryNote; | ||||
use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository; | |||||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder; | ||||
use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver; | use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver; | ||||
public function getServices(): array | public function getServices(): array | ||||
{ | { | ||||
return [ | return [ | ||||
DeliveryNoteBuilder::class, | |||||
DeliveryNoteSolver::class, | DeliveryNoteSolver::class, | ||||
DeliveryNoteRepository::class, | |||||
DeliveryNoteBuilder::class, | |||||
]; | ]; | ||||
} | } | ||||
public function getBuilder(): DeliveryNoteBuilder | |||||
public function getSolver(): DeliveryNoteSolver | |||||
{ | { | ||||
return DeliveryNoteBuilder::getInstance(); | |||||
return DeliveryNoteSolver::getInstance(); | |||||
} | } | ||||
public function getSolver(): DeliveryNoteSolver | |||||
public function getRepository(): DeliveryNoteRepository | |||||
{ | { | ||||
return DeliveryNoteSolver::getInstance(); | |||||
return DeliveryNoteRepository::getInstance(); | |||||
} | |||||
public function getBuilder(): DeliveryNoteBuilder | |||||
{ | |||||
return DeliveryNoteBuilder::getInstance(); | |||||
} | } | ||||
} | } |
<?php | |||||
namespace common\logic\Document\Document\Repository; | |||||
use common\logic\AbstractRepository; | |||||
use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository; | |||||
use common\logic\Document\Invoice\Repository\InvoiceRepository; | |||||
use common\logic\Document\Quotation\Repository\QuotationRepository; | |||||
class DocumentRepository extends AbstractRepository | |||||
{ | |||||
protected DeliveryNoteRepository $deliveryNoteRepository; | |||||
protected InvoiceRepository $invoiceRepository; | |||||
protected QuotationRepository $quotationRepository; | |||||
public function loadDependencies(): void | |||||
{ | |||||
$this->deliveryNoteRepository = $this->loadService(DeliveryNoteRepository::class); | |||||
$this->invoiceRepository = $this->loadService(InvoiceRepository::class); | |||||
$this->quotationRepository = $this->loadService(QuotationRepository::class); | |||||
} | |||||
public function getDefaultOptionsSearch(): array | |||||
{ | |||||
return []; | |||||
} | |||||
public function findOneDocumentByIdAndClass($idDocument, $classDocument) | |||||
{ | |||||
$model = null; | |||||
if($classDocument == 'DeliveryNote') { | |||||
$model = $this->deliveryNoteRepository->findOneDeliveryNoteById($idDocument); | |||||
} | |||||
elseif($classDocument == 'Quotation') { | |||||
$model = $this->quotationRepository->findOneQuotationById($idDocument); | |||||
} | |||||
elseif($classDocument == 'Invoice') { | |||||
$model = $this->invoiceRepository->findOneInvoiceById($idDocument); | |||||
} | |||||
return $model; | |||||
} | |||||
} |
use common\logic\AbstractBuilder; | use common\logic\AbstractBuilder; | ||||
use common\logic\Document\Document\Model\Document; | use common\logic\Document\Document\Model\Document; | ||||
use common\logic\Document\Document\Model\DocumentInterface; | use common\logic\Document\Document\Model\DocumentInterface; | ||||
use common\logic\Document\Document\Repository\DocumentRepository; | |||||
use common\logic\Producer\Producer\Repository\ProducerRepository; | use common\logic\Producer\Producer\Repository\ProducerRepository; | ||||
class DocumentBuilder extends AbstractBuilder | class DocumentBuilder extends AbstractBuilder | ||||
{ | { | ||||
protected DocumentSolver $documentSolver; | protected DocumentSolver $documentSolver; | ||||
protected DocumentRepository $documentRepository; | |||||
protected ProducerRepository $producerRepository; | protected ProducerRepository $producerRepository; | ||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
$this->documentSolver = $this->loadService(DocumentSolver::class); | $this->documentSolver = $this->loadService(DocumentSolver::class); | ||||
$this->documentRepository = $this->loadService(DocumentRepository::class); | |||||
$this->producerRepository = $this->loadService(ProducerRepository::class); | $this->producerRepository = $this->loadService(ProducerRepository::class); | ||||
} | } | ||||
public function generateReference(DocumentInterface $document): void | public function generateReference(DocumentInterface $document): void | ||||
{ | { | ||||
$class = $this->documentSolver->getClass($document); | $class = $this->documentSolver->getClass($document); | ||||
$classComplete = $this->documentSolver->getClass($document, true); | |||||
$classLower = strtolower($class); | $classLower = strtolower($class); | ||||
if ($classLower == 'deliverynote') { | if ($classLower == 'deliverynote') { | ||||
$classLower = 'delivery_note'; | $classLower = 'delivery_note'; | ||||
} | } | ||||
$prefix = $this->producerRepository->getConfig('document_' . $classLower . '_prefix'); | $prefix = $this->producerRepository->getConfig('document_' . $classLower . '_prefix'); | ||||
$oneDocumentExist = $class::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']); | |||||
$oneDocumentExist = $classComplete::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']); | |||||
if ($oneDocumentExist) { | if ($oneDocumentExist) { | ||||
$referenceDocument = $oneDocumentExist->reference; | $referenceDocument = $oneDocumentExist->reference; |
} | } | ||||
$totalVatArray[$idTaxRate] += Price::getVat( | $totalVatArray[$idTaxRate] += Price::getVat( | ||||
$productOrder->getPriceByTypeTotal($typeTotal) * $productOrder->quantity, | |||||
$this->productOrderSolver->getPriceByTypeTotal($productOrder, $typeTotal) * $productOrder->quantity, | |||||
$productOrder->taxRate->value, | $productOrder->taxRate->value, | ||||
$document->tax_calculation_method | $document->tax_calculation_method | ||||
); | ); | ||||
return null; | return null; | ||||
} | } | ||||
public function getClass(DocumentInterface $document): string | |||||
public function getClass(DocumentInterface $document, bool $pathComplete = false): string | |||||
{ | { | ||||
return str_replace('common\models\\', '', get_class($document)); | |||||
$classDocument = get_class($document); | |||||
if(!$pathComplete) { | |||||
return str_replace( | |||||
[ | |||||
'common\logic\Document\DeliveryNote\Model\\', | |||||
'common\logic\Document\Invoice\Model\\', | |||||
'common\logic\Document\Quotation\Model\\'], | |||||
'', | |||||
$classDocument); | |||||
} | |||||
return $classDocument; | |||||
} | } | ||||
public function getType(DocumentInterface $document): string | public function getType(DocumentInterface $document): string | ||||
public function getFilename(DocumentInterface $document): string | public function getFilename(DocumentInterface $document): string | ||||
{ | { | ||||
$filename = $document->getType() . '-'; | |||||
$filename = $this->getType($document) . '-'; | |||||
if($this->isStatusValid($document)) { | if($this->isStatusValid($document)) { | ||||
$filename .= $document->reference; | $filename .= $document->reference; |
$this->producerRepository = $this->loadService(ProducerRepository::class); | $this->producerRepository = $this->loadService(ProducerRepository::class); | ||||
} | } | ||||
public function generatePdf(DocumentInterface $document, string $destination): string | |||||
public function generatePdf(DocumentInterface $document, string $destination): ?string | |||||
{ | { | ||||
$producer = $document->producer; | $producer = $document->producer; | ||||
$content = \Yii::$app->controller->renderPartial('/document/download', [ | $content = \Yii::$app->controller->renderPartial('/document/download', [ | ||||
'producer' => $producer, | 'producer' => $producer, | ||||
'document' => $this | |||||
'document' => $document | |||||
]); | ]); | ||||
$contentFooter = '<div id="footer">'; | $contentFooter = '<div id="footer">'; | ||||
if ($this->documentSolver->isStatusValid($document) || $this->documentSolver->isStatusDraft($document)) { | if ($this->documentSolver->isStatusValid($document) || $this->documentSolver->isStatusDraft($document)) { | ||||
$contentFooter .= '<div class="reference-document">'; | $contentFooter .= '<div class="reference-document">'; | ||||
if ($this->documentSolver->isStatusValid($document)) { | if ($this->documentSolver->isStatusValid($document)) { | ||||
$contentFooter .= $this->getType() . ' N°' . $document->reference; | |||||
$contentFooter .= $this->documentSolver->getType($document) . ' N°' . $document->reference; | |||||
} | } | ||||
if ($this->documentSolver->isStatusDraft($document)) { | if ($this->documentSolver->isStatusDraft($document)) { | ||||
$contentFooter .= $document->getType() . ' non validé'; | |||||
if ($document->getType() == 'Facture') { | |||||
$contentFooter .= $this->documentSolver->getType($document) . ' non validé'; | |||||
if ($this->documentSolver->getType($document) == 'Facture') { | |||||
$contentFooter .= 'e'; | $contentFooter .= 'e'; | ||||
} | } | ||||
} | } | ||||
if (isset($document->user) && strlen($document->user->email) > 0) { | if (isset($document->user) && strlen($document->user->email) > 0) { | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$subjectEmail = $document->getType(); | |||||
$subjectEmail = $this->documentSolver->getType($document); | |||||
if ($this->documentSolver->isStatusValid($document)) { | if ($this->documentSolver->isStatusValid($document)) { | ||||
$subjectEmail .= ' N°' . $document->reference; | $subjectEmail .= ' N°' . $document->reference; | ||||
} | } | ||||
'html' => 'sendDocument-html', | 'html' => 'sendDocument-html', | ||||
'text' => 'sendDocument-text' | 'text' => 'sendDocument-text' | ||||
], [ | ], [ | ||||
'document' => $this, | |||||
'document' => $document | |||||
]) | ]) | ||||
->setTo($document->user->email) | ->setTo($document->user->email) | ||||
->setFrom([$producer->getEmailOpendistrib() => $producer->name]) | |||||
->setFrom([$this->producerSolver->getEmailOpendistrib($producer) => $producer->name]) | |||||
->setSubject('[' . $producer->name . '] ' . $subjectEmail); | ->setSubject('[' . $producer->name . '] ' . $subjectEmail); | ||||
$this->generatePdf($document, Pdf::DEST_FILE); | $this->generatePdf($document, Pdf::DEST_FILE); |
use common\logic\AbstractContainer; | use common\logic\AbstractContainer; | ||||
use common\logic\Document\Document\Model\Document; | use common\logic\Document\Document\Model\Document; | ||||
use common\logic\Document\Document\Repository\DocumentRepository; | |||||
use common\logic\Document\Document\Service\DocumentBuilder; | use common\logic\Document\Document\Service\DocumentBuilder; | ||||
use common\logic\Document\Document\Service\DocumentSolver; | use common\logic\Document\Document\Service\DocumentSolver; | ||||
use common\logic\Document\Document\Service\DocumentUtils; | use common\logic\Document\Document\Service\DocumentUtils; | ||||
{ | { | ||||
return [ | return [ | ||||
DocumentSolver::class, | DocumentSolver::class, | ||||
DocumentRepository::class, | |||||
DocumentBuilder::class, | DocumentBuilder::class, | ||||
DocumentUtils::class, | DocumentUtils::class, | ||||
]; | ]; | ||||
return DocumentSolver::getInstance(); | return DocumentSolver::getInstance(); | ||||
} | } | ||||
public function getRepository(): DocumentRepository | |||||
{ | |||||
return DocumentRepository::getInstance(); | |||||
} | |||||
public function getBuilder(): DocumentBuilder | public function getBuilder(): DocumentBuilder | ||||
{ | { | ||||
return DocumentBuilder::getInstance(); | return DocumentBuilder::getInstance(); |
{ | { | ||||
return [ | return [ | ||||
DocumentSolver::class, | DocumentSolver::class, | ||||
InvoiceRepository::class, | |||||
InvoiceBuilder::class, | InvoiceBuilder::class, | ||||
]; | ]; | ||||
} | } |
namespace common\logic\Document\Quotation\Model; | namespace common\logic\Document\Quotation\Model; | ||||
use common\helpers\GlobalParam; | use common\helpers\GlobalParam; | ||||
use common\logic\PointSale\PointSale\Repository\QuotationRepository; | |||||
use common\logic\Document\Quotation\Repository\QuotationRepository; | |||||
use yii\data\ActiveDataProvider; | use yii\data\ActiveDataProvider; | ||||
class QuotationSearch extends Quotation | class QuotationSearch extends Quotation |
<?php | <?php | ||||
namespace common\logic\PointSale\PointSale\Repository; | |||||
namespace common\logic\Document\Quotation\Repository; | |||||
use common\logic\AbstractRepository; | use common\logic\AbstractRepository; | ||||
use common\logic\Document\Quotation\Repository\QuotationRepositoryQuery; | |||||
use common\logic\Document\Quotation\Model\Quotation; | |||||
class QuotationRepository extends AbstractRepository | class QuotationRepository extends AbstractRepository | ||||
{ | { | ||||
'attribute_id_producer' => 'quotation.id_producer' | 'attribute_id_producer' => 'quotation.id_producer' | ||||
]; | ]; | ||||
} | } | ||||
public function findOneQuotationById(int $id): ?Quotation | |||||
{ | |||||
return Quotation::searchOne(['id' => $id]); | |||||
} | |||||
} | } |
use common\logic\AbstractContainer; | use common\logic\AbstractContainer; | ||||
use common\logic\Document\Document\Service\DocumentSolver; | use common\logic\Document\Document\Service\DocumentSolver; | ||||
use common\logic\Document\Quotation\Model\Quotation; | use common\logic\Document\Quotation\Model\Quotation; | ||||
use common\logic\Document\Quotation\Repository\QuotationRepository; | |||||
use common\logic\Document\Quotation\Service\QuotationBuilder; | use common\logic\Document\Quotation\Service\QuotationBuilder; | ||||
use common\logic\PointSale\PointSale\Repository\QuotationRepository; | |||||
class QuotationContainer extends AbstractContainer | class QuotationContainer extends AbstractContainer | ||||
{ | { | ||||
public function getServices(): array | public function getServices(): array | ||||
{ | { | ||||
return [ | return [ | ||||
DocumentSolver::class, | |||||
QuotationRepository::class, | |||||
QuotationBuilder::class, | QuotationBuilder::class, | ||||
]; | ]; | ||||
} | } |
<?php | <?php | ||||
namespace common\logic\Document\Invoice\Wrapper; | |||||
namespace common\logic\Document\Quotation\Wrapper; | |||||
use common\logic\Document\Document\Wrapper\DocumentManager; | use common\logic\Document\Document\Wrapper\DocumentManager; | ||||
use common\logic\Document\Quotation\Repository\QuotationRepository; | |||||
use common\logic\Document\Quotation\Service\QuotationBuilder; | use common\logic\Document\Quotation\Service\QuotationBuilder; | ||||
use common\logic\PointSale\PointSale\Repository\QuotationRepository; | |||||
/** | /** | ||||
* @mixin QuotationRepository | * @mixin QuotationRepository |
use common\logic\Producer\Producer\Model\Producer; | use common\logic\Producer\Producer\Model\Producer; | ||||
use common\logic\Producer\Producer\Repository\ProducerRepository; | use common\logic\Producer\Producer\Repository\ProducerRepository; | ||||
use common\logic\Product\Product\Model\Product; | use common\logic\Product\Product\Model\Product; | ||||
use common\logic\Product\Product\Service\ProductSolver; | |||||
use common\logic\User\User\Model\User; | use common\logic\User\User\Model\User; | ||||
use common\logic\User\UserProducer\Model\UserProducer; | use common\logic\User\UserProducer\Model\UserProducer; | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
protected ProducerRepository $producerRepository; | protected ProducerRepository $producerRepository; | ||||
protected OrderSolver $orderSolver; | protected OrderSolver $orderSolver; | ||||
protected ProductDistributionRepository $productDistributionRepository; | protected ProductDistributionRepository $productDistributionRepository; | ||||
protected ProductSolver $productSolver; | |||||
public function loadDependencies(): void | public function loadDependencies(): void | ||||
{ | { | ||||
$this->producerRepository = $this->loadService(ProducerRepository::class); | $this->producerRepository = $this->loadService(ProducerRepository::class); | ||||
$this->orderSolver = $this->loadService(OrderSolver::class); | $this->orderSolver = $this->loadService(OrderSolver::class); | ||||
$this->productDistributionRepository = $this->loadService(ProductDistributionRepository::class); | $this->productDistributionRepository = $this->loadService(ProductDistributionRepository::class); | ||||
$this->productSolver = $this->loadService(ProductSolver::class); | |||||
} | } | ||||
public function getDefaultOptionsSearch(): array | public function getDefaultOptionsSearch(): array | ||||
$count = count($order->productOrder); | $count = count($order->productOrder); | ||||
foreach ($order->productOrder as $p) { | foreach ($order->productOrder as $p) { | ||||
if (isset($p->product)) { | if (isset($p->product)) { | ||||
$html .= Html::encode($p->product->name) . ' (' . $p->quantity . ' ' . Product::strUnit( | |||||
$html .= Html::encode($p->product->name) . ' (' . $p->quantity . ' ' . $this->productSolver->strUnit( | |||||
$p->unit, | $p->unit, | ||||
'wording_short', | 'wording_short', | ||||
true | true |
$theOrder = $this->orderRepository->findOneOrderById($order->id); | $theOrder = $this->orderRepository->findOneOrderById($order->id); | ||||
// remboursement de la commande | // remboursement de la commande | ||||
if ($theOrder->id_user && $theOrder->getAmount(Order::AMOUNT_PAID) && $configCredit) { | |||||
if ($theOrder->id_user && $this->orderSolver->getOrderAmount($theOrder, Order::AMOUNT_PAID) && $configCredit) { | |||||
$this->creditHistoryBuilder->createCreditHistory( | $this->creditHistoryBuilder->createCreditHistory( | ||||
CreditHistory::TYPE_REFUND, | CreditHistory::TYPE_REFUND, | ||||
$theOrder->getAmount(Order::AMOUNT_PAID), | |||||
$this->orderSolver->getAmount($theOrder, Order::AMOUNT_PAID), | |||||
$theOrder->distribution->producer, | $theOrder->distribution->producer, | ||||
$theOrder->user, | $theOrder->user, | ||||
GlobalParam::getCurrentUser() | GlobalParam::getCurrentUser() | ||||
$order->auto_payment = 1; | $order->auto_payment = 1; | ||||
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { | } elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { | ||||
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user, $order->producer); | |||||
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user, $subscription->producer); | |||||
if ($userProducer) { | if ($userProducer) { | ||||
$order->auto_payment = $userProducer->credit_active; | $order->auto_payment = $userProducer->credit_active; |
* Retourne le montant de la commande (total, payé, restant, ou en surplus). | * Retourne le montant de la commande (total, payé, restant, ou en surplus). | ||||
*/ | */ | ||||
// getAmount | // getAmount | ||||
public function getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false): float | |||||
public function getOrderAmount(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||||
{ | { | ||||
$amount = $order->amount; | $amount = $order->amount; | ||||
if ($type == Order::INVOICE_AMOUNT_TOTAL && $order->invoice_amount) { | if ($type == Order::INVOICE_AMOUNT_TOTAL && $order->invoice_amount) { | ||||
} | } | ||||
// getAmountWithTax | // getAmountWithTax | ||||
public function getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false): float | |||||
public function getOrderAmountWithTax(Order $order, string $type = Order::AMOUNT_TOTAL, bool $format = false) | |||||
{ | { | ||||
$amount = $order->amount + $this->getOrderTotalVat($order, $type); | $amount = $order->amount + $this->getOrderTotalVat($order, $type); | ||||
if ($type == Order::INVOICE_AMOUNT_TOTAL && $order->invoice_amount) { | if ($type == Order::INVOICE_AMOUNT_TOTAL && $order->invoice_amount) { |
); | ); | ||||
} | } | ||||
public function savePrivateKeyEndpointStripe(Producer $producer): bool | |||||
public function savePrivateKeyEndpointStripe(Producer $producer): void | |||||
{ | { | ||||
$this->savePrivateKeyStripe( | $this->savePrivateKeyStripe( | ||||
$this->producerSolver->getFilenamePrivateKeyEndpointStripe($producer), | $this->producerSolver->getFilenamePrivateKeyEndpointStripe($producer), |
return $this->queryProducerPriceRanges()->all(); | return $this->queryProducerPriceRanges()->all(); | ||||
} | } | ||||
public function getAmountToBeBilledByTurnover(float $turnover, $format = false) | |||||
public function getAmountToBeBilledByTurnover(float $turnover = null, $format = false) | |||||
{ | { | ||||
$amountToBeBilled = 0; | $amountToBeBilled = 0; | ||||
$producerPriceRangeArray = $this->findProducerPriceRanges(); | $producerPriceRangeArray = $this->findProducerPriceRanges(); |
$user = $creditHistory->getUserObject(); | $user = $creditHistory->getUserObject(); | ||||
if ($user) { | if ($user) { | ||||
$str .= '<br />Client : ' . Html::encode($user->getName() . ' CreditHistorySolver.php' . $user->getLastname()); | |||||
$str .= '<br />Client : ' . Html::encode($user->getName() . ' ' . $user->getLastname()); | |||||
} | } | ||||
$userAction = $creditHistory->getUserActionObject(); | $userAction = $creditHistory->getUserActionObject(); | ||||
if ($userAction) { | if ($userAction) { | ||||
$str .= '<br />Action : ' . Html::encode($userAction->getName() . ' CreditHistorySolver.php' . $userAction->getLastname()); | |||||
$str .= '<br />Action : ' . Html::encode($userAction->getName() . ' ' . $userAction->getLastname()); | |||||
} | } | ||||
return $str; | return $str; | ||||
$userAction = $creditHistory->getUserActionObject(); | $userAction = $creditHistory->getUserActionObject(); | ||||
if ($userAction) { | if ($userAction) { | ||||
return $userAction->getName() . ' CreditHistorySolver.php' . $userAction->getlastname(); | |||||
return $userAction->getName() . ' ' . $userAction->getlastname(); | |||||
} else { | } else { | ||||
return 'Système'; | return 'Système'; | ||||
} | } |
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\helpers\Price; | use common\helpers\Price; | ||||
use common\logic\User\CreditHistory\CreditHistory; | |||||
use common\logic\User\CreditHistory\Model\CreditHistory; | |||||
?> | ?> | ||||
*/ | */ | ||||
use common\helpers\Price ; | use common\helpers\Price ; | ||||
use common\models\CreditHistorique; | |||||
use common\logic\User\CreditHistory\Model\CreditHistory; | |||||
?> | ?> | ||||
Bonjour <?= $user->name; ?>,</p> | Bonjour <?= $user->name; ?>,</p> |
*/ | */ | ||||
use yii\helpers\Html; | use yii\helpers\Html; | ||||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||||
$documentManager = DocumentManager::getInstance(); | |||||
?> | ?> | ||||
<p>Bonjour <?= Html::encode($document->user->name); ?>,</p> | <p>Bonjour <?= Html::encode($document->user->name); ?>,</p> | ||||
<p>Veuillez trouver en pièce jointe votre <?= strtolower($document->getType()) ?> <?php if($document->isStatusValid()): ?>N°<?= $document->reference ?><?php endif; ?>.</p> | |||||
<p>Veuillez trouver en pièce jointe votre <?= strtolower($documentManager->getType($document)) ?> <?php if($documentManager->isStatusValid($document)): ?>N°<?= $document->reference ?><?php endif; ?>.</p> | |||||
<p>À bientôt.</p> | <p>À bientôt.</p> |
termes. | termes. | ||||
*/ | */ | ||||
use common\logic\Document\Document\Wrapper\DocumentManager; | |||||
$documentManager = DocumentManager::getInstance(); | |||||
?> | ?> | ||||
Bonjour <?= $document->user->name ?>, | Bonjour <?= $document->user->name ?>, | ||||
Veuillez trouver en pièce jointe votre <?= strtolower($document->getType()) ?> <?php if($document->isStatusValid()): ?>N°<?= $document->reference ?><?php endif; ?>. | |||||
Veuillez trouver en pièce jointe votre <?= strtolower($documentManager->getType($document)) ?> <?php if($documentManager->isStatusValid($document)): ?>N°<?= $document->reference ?><?php endif; ?>. | |||||
À bientôt. | À bientôt. |
use yii\db\Migration; | use yii\db\Migration; | ||||
use yii\db\mysql\Schema; | use yii\db\mysql\Schema; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
class m190206_135142_ajout_champs_gestion_credit_avancee extends Migration { | class m190206_135142_ajout_champs_gestion_credit_avancee extends Migration { | ||||
public function up() { | public function up() { | ||||
$this->addColumn('producer', 'credit_functioning', Schema::TYPE_STRING.' DEFAULT \''.ProducerModel::CREDIT_FUNCTIONING_OPTIONAL.'\'') ; | |||||
$this->addColumn('producer', 'credit_functioning', Schema::TYPE_STRING.' DEFAULT \''.Producer::CREDIT_FUNCTIONING_OPTIONAL.'\'') ; | |||||
$this->addColumn('point_sale', 'credit_functioning', Schema::TYPE_STRING) ; | $this->addColumn('point_sale', 'credit_functioning', Schema::TYPE_STRING) ; | ||||
} | } | ||||
use yii\db\Migration; | use yii\db\Migration; | ||||
use yii\db\Schema; | use yii\db\Schema; | ||||
use common\logic\Producer\Producer\Model\Producer; | |||||
class m210326_104759_add_option_order_entry_point extends Migration | class m210326_104759_add_option_order_entry_point extends Migration | ||||
{ | { | ||||
public function safeUp() | public function safeUp() | ||||
{ | { | ||||
$this->addColumn('producer', 'option_order_entry_point', Schema::TYPE_STRING.' DEFAULT \''.ProducerModel::ORDER_ENTRY_POINT_DATE.'\''); | |||||
$this->addColumn('producer', 'option_order_entry_point', Schema::TYPE_STRING.' DEFAULT \''.Producer::ORDER_ENTRY_POINT_DATE.'\''); | |||||
} | } | ||||
public function safeDown() | public function safeDown() |