From: vincent@cubedesigners.com Date: Wed, 1 Mar 2017 11:13:02 +0000 (+0000) Subject: cleanup tools | wip #1181 @0:20 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f1e2f295e066712976e1663e51d83c87ad09ca3a;p=cubeextranet.git cleanup tools | wip #1181 @0:20 --- diff --git a/inc/commons/class.common.tools.php b/inc/commons/class.common.tools.php index 215a8df45..00133fb7e 100644 --- a/inc/commons/class.common.tools.php +++ b/inc/commons/class.common.tools.php @@ -24,6 +24,8 @@ class commonTools { public static function des() { global $core; + commonDroits::min(2); + $ue = array_diff(cubeCountry::getUECountries(), array('FR')); $countries = "'" . implode("','", $ue) . "'"; @@ -197,7 +199,7 @@ class commonTools { $url = $_GET['u']; $hash = sha1($url); - $onlyplayer = isset($_GET['onlyplayer']) && $onlyplayer; + $onlyplayer = isset($_GET['onlyplayer']); if (!$onlyplayer) { $web = '/tube/' . $hash . '/'; @@ -321,134 +323,6 @@ class commonTools { return $res; } - public static function exportClients($args) { - global $core; - - $types = array('Cubedesigners' => 'cube', 'Tous les contacts (Clients de revendeurs inclus)' => 'all'); - $typeexp = array('Entreprises' => 'entreprises', 'Utilisateurs' => 'users'); - - $res = commonPage::barre(); - $res .= commonPage::tMain(); - $res .= commonPage::bh(); - $res .= '
'; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
' . __('Exporter la base clients') . '
' . __('Type de client') . '' . form::combo('type', $types) . '
' . $core->typo->BoutonOK(__('Exporter')) . '
'; - $res .= '
'; - $res .= ''; - $res .= commonPage::bf(); - $res .= commonPage::bMain(); - return $res; - } - - public static function exportClientsXLS($args) { - global $core; - - $sql = 'SELECT * FROM entreprises_ws'; - if ($_POST['type'] == 'cube') { - $sql .= " WHERE revendeur = 'Cubedesigners'"; - } - - $r = $core->con->select($sql); - $entreprises = array(); - $rows = $r->rows(); - foreach ($rows as $r) { - - $entreprises[$r['entreprise_id']] = $r; - $entreprises[$r['entreprise_id']]['utilisateurs'] = array(); - } - - $r = $core->con->select('SELECT * FROM utilisateurs_entreprise WHERE entreprise IN(' . implode(',', array_keys($entreprises)) . ')'); - $rows = $r->rows(); - foreach ($rows as $r) { - $entreprises[$r['entreprise']]['utilisateurs'][$r['utilisateur_id']] = $r; - } - - $xls = new PHPExcel(); - $s1 = $xls->getActiveSheet(); - $s1->setTitle('Entreprises'); - self::exportClientsXLSEntreprises($s1, $entreprises); - - $s2 = $xls->createSheet(); - $s2->setTitle('Utilisateurs'); - self::exportClientsXLSUsers($s2, $entreprises); - - ob_end_clean(); - files::$mimeType['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; - cubeHTTP::forceDownload('clients.xlsx', false); - - $xls->setActiveSheetIndex(0); - $writer = new PHPExcel_Writer_Excel2007($xls); - $writer->save('php://output'); - exit; - } - - /** - * - * @param PHPExcel_Worksheet $s - * @param type $e - */ - public static function exportClientsXLSEntreprises(&$s, $e) { - $j = 2; - $w = 3; - foreach ($e as $id => $datas) { - $mainAddress = self::_address($datas['nom'], $datas['adresse'], $datas['code_postal'], $datas['ville'], $datas['pays']); - $otherAddress = array(); - foreach ($datas['utilisateurs'] as $u) { - $a = self::_address($datas['nom'], $u['adresse'], $u['code_postal'], $u['ville'], $u['pays']); - if ($a != $mainAddress && !in_array($a, $otherAddress)) { - $otherAddress[] = $a; - } - } - - $s->getCellByColumnAndRow(0, $j)->setValue($id); - $s->getCellByColumnAndRow(1, $j)->setValue($datas['nom']); - $s->getCellByColumnAndRow(2, $j)->setValue($mainAddress); - $i = 3; - foreach ($otherAddress as $o) { - $s->getCellByColumnAndRow($i, $j)->setValue($o); - $i++; - } - $j++; - $w = max($w, $i); - } - - $h = $j; - - $s->getCellByColumnAndRow(0, 1)->setValue('#'); - $s->getCellByColumnAndRow(1, 1)->setValue('Raison sociale'); - $s->getCellByColumnAndRow(2, 1)->setValue('Adresse principale'); - $s->getCellByColumnAndRow(3, 1)->setValue('Autres adresses'); - - for ($i = 0; $i <= $w; $i++) { - for ($j = 0; $j <= $h; $j++) { - $style = $s->getStyleByColumnAndRow($i, $j); - $style->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER)->setWrapText(true); - } - if ($i == 0) { - $s->getColumnDimensionByColumn($i)->setAutoSize(); - } elseif ($i == 1) { - $s->getColumnDimensionByColumn($i)->setWidth(20); - } else { - $s->getColumnDimensionByColumn($i)->setWidth(30); - } - } - } - - protected static function _address($nom, $adresse, $code_postal, $ville, $pays) { - return trim(trim($nom) . "\r\n" . trim($adresse) . "\r\n" . trim($code_postal . " " . $ville) . "\r\n" . cubeCountry::getCountryName($pays, 'fr_FR')); - } - - /** - * - * @param PHPExcel_Worksheet $s - * @param type $e - */ - public static function exportClientsXLSUsers(&$s, $e) { - - } public static function favicon($args) { global $core; @@ -709,11 +583,6 @@ class commonTools { exit; } - public static function css() { - - } - - public static function csr() { commonDroits::min(1); global $core;