@@ -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() | |||
{ |
@@ -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> |
@@ -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() ; | |||
}) ; | |||
} | |||
} | |||
}); |