]> _ Git - cubeextranet.git/commitdiff
wip #2438 @1.5
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 18 Dec 2018 17:46:36 +0000 (17:46 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 18 Dec 2018 17:46:36 +0000 (17:46 +0000)
inc/commons/class.common.ajax.php
inc/commons/class.common.core.php
inc/commons/class.common.tools.php
inc/ws/Util/class.ws.links.php

index 2aacaae29d6c83acfae097f3145dd4c1e69ae89d..af147addc5e2e92deba950d2b0ac7b6d6fe2120f 100644 (file)
@@ -472,5 +472,49 @@ Mot de passe : $password";
                $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;
+       }
 }
index 7b2ba635b1fa2044775f447d89669cde3ae8e5af..5ccaf0cabb6fee6773765579d788b6b70dfe8cea 100644 (file)
@@ -525,6 +525,12 @@ class commonCore extends cubeCore
                $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
index eae96d4847f4c79b6f2b663d64ca93abf76a5d1a..914a1667e5321e198a6bb2c5c4f5d9b3b7703f97 100644 (file)
@@ -1141,6 +1141,28 @@ class commonTools
                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']));
index 6e58b2fd5e2a2d96c61f0d2f08f3175b38f29584..c16e6a65f9a342ccf6ca072b8c72c084ee453045 100644 (file)
@@ -35,8 +35,6 @@ class wsLinks
                        'group' => __('Groupe'),
                );
 
-               new PHPExcel();
-
                /* $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_memcache;
                  $cacheSettings = array('memcacheServer' => 'localhost',
                  'memcachePort' => 11211,