Browse Source

Modification d'un document : supprimer un productOrder #166

refactoring
Guillaume Bourgeois 5 years ago
parent
commit
2e628a163b
3 changed files with 33 additions and 2 deletions
  1. +20
    -0
      backend/controllers/DocumentController.php
  2. +4
    -2
      backend/views/document/_form.php
  3. +9
    -0
      backend/web/js/vuejs/document-form.js

+ 20
- 0
backend/controllers/DocumentController.php View File

@@ -246,6 +246,26 @@ class DocumentController extends BackendController
'return' => 'error'
] ;
}

public function actionAjaxDeleteProductOrder($idProductOrder)
{
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

$productOrder = ProductOrder::searchOne([
'id' => $idProductOrder
]) ;

if($productOrder) {
$productOrder->delete() ;
return [
'return' => 'success'
] ;
}

return [
'return' => 'error'
] ;
}
protected function getClass()
{

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

@@ -193,8 +193,10 @@ use common\models\Producer;
<td>{{ formatPrice(productOrder.quantity *
productOrder.price) }}
</td>
<td><a class="btn btn-default"><span
class="glyphicon glyphicon-trash"></span></a>
<td>
<a class="btn btn-default" @click="deleteProductOrder(productOrder.id)">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
</template>

+ 9
- 0
backend/web/js/vuejs/document-form.js View File

@@ -123,6 +123,15 @@ var app = new Vue({
app.init() ;
alert('Produit ajouté') ;
}) ;
},
deleteProductOrder: function(idProductOrder) {
var app = this ;
axios.get(UrlManager.getBaseUrlAbsolute()+"document/ajax-delete-product-order",{params: {
idProductOrder: idProductOrder
}})
.then(function(response) {
app.init() ;
}) ;
}
}
});

Loading…
Cancel
Save