$mail->send($transport);
}
+ public static function importWSReferences($args, &$x)
+ {
+ global $core;
+
+ $e = explode('.', $_FILES['file']['name']);
+ $ext = array_pop($e);
+ new PHPExcel();
+ $reader = new PHPExcel_Reader_Excel2007();
+ $phpexcel = $reader->load($_FILES['file']['tmp_name']);
+ $sheet = $phpexcel->getSheet(0);
+ $maxRow = $sheet->getHighestRow(0);
+ for ($i = 0; $i < $maxRow; $i++) {
+
+ $ref = trim($sheet->getCellByColumnAndRow(0, $i));
+ $url = trim($sheet->getCellByColumnAndRow(1, $i)->getOldCalculatedValue());
+ if ($url == '' || $ref == '') {
+ continue;
+ }
+
+ $c = $core->con->openCursor('wsref');
+ $c->type = $_POST['type'];
+ $c->ref = self::_formatWsReferenceRef($ref, $_POST['type']);
+ $c->url = self::_formatWsReferenceUrl($url, $_POST['type']);
+ try {
+ $c->insert();
+ } catch (Exception $e) {
+ $c->update("WHERE ref='" . $core->con->escape($ref) . "' AND type='" . $core->con->escape($_POST['type']) . "'");
+ }
+ }
+ }
+
+ public static function _formatWsReferenceRef($ref, $type)
+ {
+ if ($type == '10doigts') {
+ if (stripos($ref, 'ic') === 0) {
+ return 'C' . substr($ref, 2);
+ }
+ }
+ return $ref;
+ }
+ public static function _formatWsReferenceUrl($url, $type)
+ {
+ return $url;
+ }
}
$db->bulle->nom('varchar', 128, false);\r
$db->bulle->catalogue('varchar', 128, false);\r
\r
+ // WS Ref\r
+\r
+ $db->wsref->type('varchar', 32, false);\r
+ $db->wsref->ref('varchar', 32, false);\r
+ $db->wsref->url('varchar', 512, false);\r
+ $db->wsref->primary('pk_wsref', 'type', 'ref');\r
\r
// Table google search api\r
$db->google_search_api->request('varchar', 256, false);\r
return $res;
}
+ public static function importWSReferences()
+ {
+ commonDroits::min(5);
+ global $core;
+ $res = commonPage::barre();
+ $res .= commonPage::tMain();
+ $res .= commonPage::bh();
+ $res .= '<form action="importWSReferences" method="post" enctype="multipart/form-data">';
+ $res .= '<table class="liste">';
+ $res .= '<tr><th colspan="2"><strong>' . __('Importer un fichier de références') . '</strong></th></tr>';
+ $res .= '<tr><td>' . __("Fichier XLSX") . '<br>(colonne A : référence, colonne B : URL)</td><td><input type="file" name="file" accept=".xlsx" /></td></tr>';
+ $res .= '<tr><td>' . __("Type") . '</td><td><select name="type"><option>10doigts</option></select></td></tr>';
+ $res .= '<tr><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Importer les références')) . '</a></td></td>';
+ $res .= '</table>';
+ $res .= '</form>';
+ $res .= commonPage::bf();
+
+ $res .= commonPage::bMain();
+ return $res;
+ }
+
+
public static function makeSNCFCodes()
{
$list = explode("\n", file_get_contents($_FILES['file']['tmp_name']));
'group' => __('Groupe'),
);
- new PHPExcel();
-
/* $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;
$cacheSettings = array('memcacheServer' => 'localhost',
'memcachePort' => 11211,