|
| 1 | +<?php |
| 2 | + |
| 3 | +/* This file is part of Jeedom. |
| 4 | + * |
| 5 | + * Jeedom is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU General Public License as published by |
| 7 | + * the Free Software Foundation, either version 3 of the License, or |
| 8 | + * (at your option) any later version. |
| 9 | + * |
| 10 | + * Jeedom is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. |
| 17 | + */ |
| 18 | + |
| 19 | +try { |
| 20 | + require_once dirname(__FILE__) . '/../../../../core/php/core.inc.php'; |
| 21 | + include_file('core', 'authentification', 'php'); |
| 22 | + |
| 23 | + if (!isConnect('admin')) { |
| 24 | + throw new Exception(__('401 - Accès non autorisé', __FILE__)); |
| 25 | + } |
| 26 | + |
| 27 | + ajax::init(); |
| 28 | + |
| 29 | + if (init('action') == 'ethGetData') { |
| 30 | + |
| 31 | + |
| 32 | + $date = array( |
| 33 | + 'start' => init('dateStart'), |
| 34 | + 'end' => init('dateEnd'), |
| 35 | + ); |
| 36 | + |
| 37 | + if ($date['start'] == '') { |
| 38 | + $date['start'] = date('Y-m-d', strtotime('-1 months ' . date('Y-m-d'))); |
| 39 | + } |
| 40 | + if ($date['end'] == '') { |
| 41 | + $date['end'] = date('Y-m-d', strtotime('+1 days ' . date('Y-m-d'))); |
| 42 | + } |
| 43 | + |
| 44 | + |
| 45 | + $ethalsurveillance = ethalsurveillance::byId(init('eqid')); |
| 46 | + |
| 47 | + if (!is_object($ethalsurveillance)) { |
| 48 | + throw new Exception(__('Equipement ethalsurveillance introuvable : ', __FILE__) . init('eqid')); |
| 49 | + } |
| 50 | + |
| 51 | + if ($ethalsurveillance->getIsEnable() == 1 && $ethalsurveillance->getEqType_name() == 'ethalsurveillance') { |
| 52 | + $return['eq'] = array('eqName' => $ethalsurveillance->getName(), 'ethCumulData' => array($ethalsurveillance->ethCumulData($date['start'], $date['end']))); |
| 53 | + } |
| 54 | + |
| 55 | + //echo $return; |
| 56 | + |
| 57 | + ajax::success($return); |
| 58 | + } |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + throw new Exception(__('Aucune méthode correspondante à : ', __FILE__) . init('action')); |
| 63 | + /* * *********Catch exeption*************** */ |
| 64 | +} catch (Exception $e) { |
| 65 | + ajax::error(displayExeption($e), $e->getCode()); |
| 66 | +} |
| 67 | +?> |
0 commit comments