From: vincent@cubedesigners.com Date: Mon, 7 Feb 2022 16:18:13 +0000 (+0000) Subject: wip #4871 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d92caa433af30874f943bb51121600ed9f69901e;p=cubeextranet.git wip #4871 @1.5 --- diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index ee0ca3a28..9bcfc90e9 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -740,6 +740,7 @@ class wsMaintenance public static function kadreoDevis8524147851() { global $core; + wsDroits::admin(true); $xls = new PHPExcel(); @@ -824,8 +825,8 @@ class wsMaintenance $batch[] = array_merge($e[$user['entreprise']], array('email' => $user['email'], 'LOCALE' => $user['lang'], 'FNAME' => $user['prenom'], 'LNAME' => $user['nom'])); } - $api = new CubeIT_Services_Mailchimp('2b255293f3595181dd7d079d29dc6b99-us14'); - $res = $api->batchSubscribe('8ff710b78e', $batch); +// $api = new CubeIT_Services_Mailchimp('2b255293f3595181dd7d079d29dc6b99-us14'); +// $res = $api->batchSubscribe('8ff710b78e', $batch); echo '
OK
'; } diff --git a/inc/ws/Util/class.ws.util.php b/inc/ws/Util/class.ws.util.php index e89aa300d..0b41286d9 100644 --- a/inc/ws/Util/class.ws.util.php +++ b/inc/ws/Util/class.ws.util.php @@ -56,9 +56,9 @@ class wsUtil } if ($assoc) { - $worksheets[$title] = self::_assocSheet($worksheet->toArray(null, true, true)); + $worksheets[$title] = self::_assocSheet(self::worksheetToArray($worksheet)); } else { - $worksheets[$title] = $worksheet->toArray(null, true, true); + $worksheets[$title] = self::worksheetToArray($worksheet); } } file_put_contents($cacheFile, json_encode($worksheets)); @@ -67,6 +67,32 @@ class wsUtil return $worksheets; } + /** + * @param $worksheet PHPExcel_Worksheet + * @return array + */ + public static function worksheetToArray($worksheet) + { + $w = $worksheet->toArray(null, true, true); + $res = []; + foreach ($w as $line) { + $empty = true; + foreach ($line as $k => $v) { + if (null === $v || $v === '') { + $v = ''; + } else { + $empty = false; + } + $line[$k] = $v; + } + if ($empty) { + continue; + } + $res[] = $line; + } + return $res; + } + public static function excelToArrayKeyVal($excelFile, $reader = 'Excel2007') { $worksheets = self::excelToArray($excelFile, false, $reader);