cancel an order
This commit is contained in:
parent
4d0b220a11
commit
e4a93b775a
@ -5,4 +5,5 @@ namespace OCA\Gestion\Constants;
|
||||
abstract class OrderStatusConstant
|
||||
{
|
||||
const ORDERED_KEY = "ORDERED";
|
||||
const CANCELED_KEY = "CANCELED";
|
||||
}
|
||||
@ -119,4 +119,12 @@ class OrderBdd {
|
||||
$order = $this->getOrderByCalendarUuid($calendarUuid);
|
||||
return $order['id'];
|
||||
}
|
||||
|
||||
public function updateOrderStatus($orderId,$statusKey){
|
||||
$sql= "UPDATE ".$this->orderTablePrefix."orders as orders
|
||||
SET orders.fk_order_status_key = ?
|
||||
WHERE orders.id = ?";
|
||||
|
||||
$this->execSQLNoData($sql,[$statusKey,$orderId]);
|
||||
}
|
||||
}
|
||||
@ -27,6 +27,7 @@ declare(strict_types=1);
|
||||
namespace OCA\Gestion\Service;
|
||||
|
||||
use OCA\Gestion\Constants\DevisMentionConstant;
|
||||
use OCA\Gestion\Constants\OrderStatusConstant;
|
||||
use OCA\Gestion\Constants\ThanatoTypeConstant;
|
||||
use OCA\Gestion\Db\Bdd;
|
||||
use OCA\Gestion\Db\OrderBdd;
|
||||
@ -249,11 +250,24 @@ class GestionService {
|
||||
}
|
||||
|
||||
public function HandleCalendarObjectMovedToTrash(string $vCalendarString){
|
||||
$thanato = $this->GetThanatoFromVCalendarString($vCalendarString);
|
||||
if($thanato == null){
|
||||
return;
|
||||
}
|
||||
$calendarUuid = $this->GetCalendarUuidFromVCalendarString($vCalendarString);
|
||||
$thanatoIsSubcontractor = $thanato["fk_thanato_type_key"] === ThanatoTypeConstant::THANATO_TYPE_SUBCONTRACTOR;
|
||||
if($thanatoIsSubcontractor){
|
||||
$order = $this->orderBdd->getOrderByCalendarUuid($calendarUuid);
|
||||
if($order != null){
|
||||
$this->orderBdd->updateOrderStatus($order['id'],OrderStatusConstant::CANCELED_KEY);
|
||||
}
|
||||
}
|
||||
else{
|
||||
$devis = $this->gestionBdd->getDevisByCalendarUuid($calendarUuid);
|
||||
if($devis != null){
|
||||
$this->gestionBdd->updateDevisMentionToCanceled($devis['id']);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user