diff --git a/library/Actions.php b/library/Actions.php index 022a388..679a835 100644 --- a/library/Actions.php +++ b/library/Actions.php @@ -130,6 +130,7 @@ class Actions { try { $crawler = $this->account->getClient()->request('GET', self::ADD_URL); + $this->addPageDebug('add-form', $crawler); $form = $crawler->selectButton('Valider')->form(); $path = $deal->getPath(); if (empty($path)) { @@ -207,11 +208,15 @@ class Actions ]; $crawler = $this->account->getClient()->request('POST', self::DELETE_URL, $fields); $this->addPageDebug('delete', $crawler); - // confirmation - $form = $crawler->selectButton('Valider')->form(); - $crawler = $this->account->getClient()->submit($form, ['delete_reason' => '1']); - $this->addPageDebug('delete-validation', $crawler); - // TODO return if it's the validation page or not + // check s'il y a un bouton "Valider", s'il y en a pas c'est que la demande a déjà été faite + $node = $crawler->filterXPath('//input[@value="Valider"]'); + if ($node->count() == 1) { + // confirmation + $form = $crawler->selectButton('Valider')->form(); + $crawler = $this->account->getClient()->submit($form, ['delete_reason' => '1']); + // TODO return if it's the validation page or not + $this->addPageDebug('delete-validation', $crawler); + } return true; } } \ No newline at end of file