public static function des() {
global $core;
+ commonDroits::min(2);
+
$ue = array_diff(cubeCountry::getUECountries(), array('FR'));
$countries = "'" . implode("','", $ue) . "'";
$url = $_GET['u'];
$hash = sha1($url);
- $onlyplayer = isset($_GET['onlyplayer']) && $onlyplayer;
+ $onlyplayer = isset($_GET['onlyplayer']);
if (!$onlyplayer) {
$web = '/tube/' . $hash . '/';
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 .= '<form action="' . SITE_PATH . 'tools / exportClientsXLS" method="post" class="notajax">';
- $res .= '<table class="liste">';
- $res .= '<tr><th colspan="3"><strong>' . __('Exporter la base clients') . '</strong></th></tr>';
- $res .= '<tr><td>' . __('Type de client') . '</td><td>' . form::combo('type', $types) . '</td></td>';
- $res .= '<tr class="odd"><td class="right" colspan="2"><a href="#" class="submit">' . $core->typo->BoutonOK(__('Exporter')) . '</a></td></td>';
- $res .= '</table>';
- $res .= '</form>';
- $res .= '</div>';
- $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;
exit;
}
- public static function css() {
-
- }
-
-
public static function csr() {
commonDroits::min(1);
global $core;