Browse Source

Merge branch 'feature/devis_bl_factures' of https://framagit.org/guillaume-bourgeois/distrib into feature/devis_bl_factures

dev
Fab 4 years ago
parent
commit
a6d64c9e6f
9 changed files with 91 additions and 24 deletions
  1. +2
    -1
      backend/assets/VuejsDocumentFormAsset.php
  2. +36
    -12
      backend/controllers/DocumentController.php
  3. +15
    -2
      backend/views/document/_form.php
  4. +3
    -2
      backend/views/document/create.php
  5. +3
    -2
      backend/views/document/update.php
  6. +3
    -3
      backend/views/invoice/index.php
  7. +24
    -2
      backend/web/js/vuejs/document-form.js
  8. +5
    -0
      common/models/Document.php
  9. +0
    -0
      producer/web/assets/.gitignore

+ 2
- 1
backend/assets/VuejsDocumentFormAsset.php View File

public $css = []; public $css = [];
public $js = []; public $js = [];
public $depends = [ public $depends = [
'common\assets\CommonAsset'
'common\assets\CommonAsset',
'backend\assets\AppAsset',
]; ];
public function __construct() public function __construct()

+ 36
- 12
backend/controllers/DocumentController.php View File

return $this->render('/document/create', [ return $this->render('/document/create', [
'title' => $this->getTitle('Ajouter'), 'title' => $this->getTitle('Ajouter'),
'documentType' => $this->getDocumentType(),
'typeDocument' => $this->getDocumentType(),
'model' => $model, 'model' => $model,
]); ]);
} }
*/ */
public function actionUpdate($id) public function actionUpdate($id)
{ {
$request = Yii::$app->request;

$model = $this->findModel($id) ; $model = $this->findModel($id) ;
$class = $this->getClass();
$model = $class::searchOne([
'id' => $id
]) ;


if ($model->load(Yii::$app->request->post()) && $model->save()) {
if ($model && $model->load(Yii::$app->request->post()) && $model->save()) {


Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('update', $model)); Yii::$app->getSession()->setFlash('success', $this->getFlashMessage('update', $model));
return $this->redirect(['index']);
} else {
return $this->render('update', [
'title' => $this->getTitle('Modifier'),
'documentType' => $this->getDocumentType(),
'model' => $model,
]);
} }
return $this->render('/document/update', [
'title' => $this->getTitle('Modifier'),
'typeDocument' => $this->getDocumentType(),
'model' => $model,
]);
} }


public function actionAddressUser($idUser)
public function actionAjaxAddressUser($idUser)
{ {
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
return ['return' => 'error'] ; return ['return' => 'error'] ;
} }
public function actionAjaxInit($idDocument, $classDocument)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
if($idDocument > 0 && Document::isValidClass($classDocument)) {
$document = $classDocument::searchOne([
'id' => $idDocument
]) ;
if($document) {
return [
'return' => 'success',
'address' => $document->address,
'idUser' => $document->user->id
] ;
}
}
return ['return' => 'error'] ;
}
protected function getClass() protected function getClass()
{ {
$class = get_class($this); $class = get_class($this);

+ 15
- 2
backend/views/document/_form.php View File



?> ?>


<div class="document-form" id="app-document-form">
<div class="document-form" id="app-document-form" data-class-document="<?= $model->getClass() ?>" data-id-document="<?= ($model->id > 0) ? $model->id : $model->id ?>">


<div class="col-md-12">
<div class="<?php if($action == 'create') : ?>col-md-12<?php else : ?>col-md-4<?php endif; ?>">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
Informations Informations
</div> </div>
</div> </div>
</div> </div>
<?php if($action == 'update'): ?>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">
Produits
</div>
<div class="panel-body">
</div>
</div>
</div>
<?php endif; ?>
</div> </div>

+ 3
- 2
backend/views/document/create.php View File

use yii\helpers\Html; use yii\helpers\Html;


$this->setTitle($title) ; $this->setTitle($title) ;
$this->addBreadcrumb(['label' => $documentType.'s', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => $typeDocument.'s', 'url' => ['index']]) ;
$this->addBreadcrumb('Ajouter') ; $this->addBreadcrumb('Ajouter') ;


?> ?>


<div class="document-create"> <div class="document-create">
<?= $this->render('_form', [ <?= $this->render('_form', [
'action' => 'create',
'model' => $model, 'model' => $model,
'documentType' => $documentType
'typeDocument' => $typeDocument,
]) ?> ]) ?>
</div> </div>

+ 3
- 2
backend/views/document/update.php View File





$this->setTitle($title) ; $this->setTitle($title) ;
$this->addBreadcrumb(['label' => $documentType.'s', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => $typeDocument.'s', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => $model->name, 'url' => ['update', 'id' => $model->id]]) ; $this->addBreadcrumb(['label' => $model->name, 'url' => ['update', 'id' => $model->id]]) ;
$this->addBreadcrumb('Modifier') ; $this->addBreadcrumb('Modifier') ;




<div class="product-update"> <div class="product-update">
<?= $this->render('_form', [ <?= $this->render('_form', [
'action' => 'update',
'model' => $model, 'model' => $model,
'documentType' => $documentType
'typeDocument' => $typeDocument,
]) ?> ]) ?>
</div> </div>

+ 3
- 3
backend/views/invoice/index.php View File

'value' => function($invoice) { 'value' => function($invoice) {
return $invoice->getAmount(Order::AMOUNT_TOTAL, true) ; return $invoice->getAmount(Order::AMOUNT_TOTAL, true) ;
} }
]
/*[
],
[
'class' => 'yii\grid\ActionColumn', 'class' => 'yii\grid\ActionColumn',
'template' => '{update} {delete}', 'template' => '{update} {delete}',
'headerOptions' => ['class' => 'column-actions'], 'headerOptions' => ['class' => 'column-actions'],
]); ]);
} }
], ],
],*/
],
], ],
]); ?> ]); ?>
</div> </div>

+ 24
- 2
backend/web/js/vuejs/document-form.js View File

var app = new Vue({ var app = new Vue({
el: '#app-document-form', el: '#app-document-form',
data: { data: {
idDocument: 0,
typeDocument: '',
idUser: '', idUser: '',
address : '' address : ''
}, },
mounted: function() {
this.init() ;
},
methods: { methods: {
init: function() {
var idDocument = $('#app-document-form').attr('data-id-document') ;
var classDocument = $('#app-document-form').attr('data-class-document') ;
if(idDocument) {
var app = this ;
axios.get(UrlManager.getBaseUrlAbsolute()+"document/ajax-init",{params: {
idDocument: idDocument,
classDocument: classDocument
}})
.then(function(response) {
if(response.data.return == 'success') {
app.address = response.data.address ;
app.idUser = response.data.idUser ;
}
}) ;
}
},
changeUser: function(event) { changeUser: function(event) {
var app = this ; var app = this ;
axios.get(UrlManager.getBaseUrlAbsolute()+"document/address-user",{params: {
axios.get(UrlManager.getBaseUrlAbsolute()+"document/ajax-address-user",{params: {
idUser: app.idUser idUser: app.idUser
}}) }})
.then(function(response) { .then(function(response) {
console.log(response.data) ;
if(response.data.return == 'success') { if(response.data.return == 'success') {
app.address = response.data.address ; app.address = response.data.address ;
} }

+ 5
- 0
common/models/Document.php View File

} }
} }
} }
public function isValidClass($typeDocument)
{
return in_array($typeDocument, ['Invoice', 'DeliveryNote', 'Quotation']) ;
}
} }

+ 0
- 0
producer/web/assets/.gitignore View File


Loading…
Cancel
Save