Browse Source

Modification d'un document : supprimer un productOrder #166

refactoring
Guillaume Bourgeois 4 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

'return' => 'error' '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() protected function getClass()
{ {

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

<td>{{ formatPrice(productOrder.quantity * <td>{{ formatPrice(productOrder.quantity *
productOrder.price) }} productOrder.price) }}
</td> </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> </td>
</tr> </tr>
</template> </template>

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

app.init() ; app.init() ;
alert('Produit ajouté') ; 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