$maxRow = $sheet->getHighestRow(0);
+ $updated = 0;
for ($i = 1; $i <= $maxRow; $i++) {
$ref = trim($sheet->getCellByColumnAndRow(0, $i));
$url = trim($sheet->getCellByColumnAndRow(1, $i)->getOldCalculatedValue());
$fref = self::_formatWsReferenceRef($ref, $_POST['type']);
$furl = self::_formatWsReferenceUrl($url, $_POST['type']);
- $delete = "DELETE FROM wsref WHERE ref='" . $core->con->escape($fref) . "' AND type='" . $core->con->escape($_POST['type']) . "'";
- $core->con->execute($delete);
+ try {
+ $delete = "DELETE FROM wsref WHERE ref='" . $core->con->escape($fref) . "' AND type='" . $core->con->escape($_POST['type']) . "'";
+ $core->con->execute($delete);
+ } catch (Exception $e) {
+ }
- $c = $core->con->openCursor('wsref');
- $c->type = $_POST['type'];
- $c->ref = $fref;
- $c->url = $furl;
- $c->insert();
+ try {
+ $c = $core->con->openCursor('wsref');
+ $c->type = $_POST['type'];
+ $c->ref = $fref;
+ $c->url = $furl;
+ $c->insert();
+ $updated++;
+ } catch (Exception $e) {
+
+ }
}
+ $x->addAlert(sprintf(__('%d liens insérés ou mis à jour'), $updated));
}
public static function _formatWsReferenceRef($ref, $type)