Sfoglia il codice sorgente

Modification d'un document : supprimer un productOrder #166

refactoring
parent
commit
2e628a163b
3 ha cambiato i file con 33 aggiunte e 2 eliminazioni
  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 Vedi 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 Vedi 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 Vedi 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…
Annulla
Salva