From 4f12d3da3b3d645f612b75d5160029c306973dbc Mon Sep 17 00:00:00 2001 From: Clement Desmidt Date: Mon, 12 Sep 2016 16:41:57 +0200 Subject: [PATCH] Ajoute tous les champs du formulaire --- library/Account.php | 47 +++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/library/Account.php b/library/Account.php index 70ffaac..93d558f 100644 --- a/library/Account.php +++ b/library/Account.php @@ -103,28 +103,29 @@ class Account file_put_contents(sprintf('%s/add.html', $log_folder), $crawler->html()); $form = $crawler->selectButton('Valider')->form(); $image0 = fopen(sprintf('%s/%s/image0.jpg', DEALS_DIR, $deal->getId()), 'r'); - $fields = [ - 'check_type_diff' => 0, - 'company_ad' => 0, - // TODO what are those ? - 'location_p' => sprintf('%s %s', $this->config->city, $this->config->postal_code), - 'zipcode' => $this->config->postal_code, - 'city' => $this->config->city, - 'region' => $this->config->region, - 'dpt_code' => $this->config->department, - 'address' => $this->config->address, - 'name' => $this->config->name, - 'email' => $this->config->login, - 'phone' => $this->config->phone, - 'category' => $deal->getCategory(), - 'type' => $deal->getType(), - 'subject' => $deal->getSubject(), - 'body' => $deal->getBody(), - 'price' => $deal->getPrice(), - 'image0' => $image0, - 'no_salesmen' => 1, - 'phone_hidden' => 0, - ]; + $fields = $form->getPhpValues(); + $fields = array_merge( + $fields, + [ + 'location_p' => sprintf('%s %s', $this->config->city, $this->config->postal_code), + 'zipcode' => $this->config->postal_code, + 'city' => $this->config->city, + 'region' => $this->config->region, + 'dpt_code' => $this->config->department, + 'address' => $this->config->address, + 'name' => $this->config->name, + 'email' => $this->config->login, + 'phone' => $this->config->phone, + 'category' => $deal->getCategory(), + 'type' => $deal->getType(), + 'subject' => $deal->getSubject(), + 'body' => $deal->getBody(), + 'price' => $deal->getPrice(), + 'image0' => $image0, + 'no_salesmen' => 1, + 'phone_hidden' => 0, + ] + ); array_walk($fields, function (&$item, $key) { $item = [ 'name' => $key, @@ -145,4 +146,4 @@ class Account echo $e->getTraceAsString(); } } -} \ No newline at end of file +}