static function updateDetailForPerfdata($perfdata, $perfdatas_id)
 {
     $a_lines = array();
     $a_perfdata = PluginMonitoringPerfdata::splitPerfdata($perfdata);
     $i = 1;
     foreach ($a_perfdata as $data) {
         $data = trim($data, ", ");
         $a_a_perfdata = explode("=", $data);
         $a_a_perfdata[0] = trim($a_a_perfdata[0], "'");
         if (!isset($a_a_perfdata[1])) {
             return;
         }
         //$a_a_perfdata[1] = trim($a_a_perfdata[1], ";");
         $a_lines[$i] = array('name' => $a_a_perfdata[0]);
         $a_perfdata_final = explode(";", $a_a_perfdata[1]);
         $num = 1;
         foreach ($a_perfdata_final as $nb_val => $val) {
             if ($val == '') {
                 if ($nb_val < count($a_perfdata_final) - 1) {
                     $a_lines[$i]['values'][$num] = '';
                 }
             } else {
                 $a_lines[$i]['values'][$num] = '';
             }
             $num++;
         }
         $i++;
     }
     // Add/update perfdatadetails in DB
     $pmPerfdataDetail = new PluginMonitoringPerfdataDetail();
     $a_perfdatadetails = $pmPerfdataDetail->find("`plugin_monitoring_perfdatas_id`='" . $perfdatas_id . "'", "position");
     foreach ($a_perfdatadetails as $data) {
         $find = 0;
         foreach ($a_lines as $key => $a_line) {
             if ($a_line['name'] == $data['name'] && $data['position'] == $key && !$find) {
                 $find = 1;
                 $countfind = count($a_line['values']);
                 $input = array();
                 $input['id'] = $data['id'];
                 $input['dsname_num'] = $countfind;
                 for ($i = 1; $i <= $countfind; $i++) {
                     if ($data['dsname' . $i] == '') {
                         $input['dsname' . $i] = 'value' . $data['position'] . '.' . $i;
                     }
                 }
                 for ($i = $countfind + 1; $i < 9; $i++) {
                     $input['dsname' . $i] = '';
                 }
                 $pmPerfdataDetail->update($input);
                 unset($a_lines[$key]);
             }
         }
         if (!$find) {
             $pmPerfdataDetail->delete($data);
         }
     }
     foreach ($a_lines as $position => $data) {
         $input = array();
         $input['name'] = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data['name']));
         $input['plugin_monitoring_perfdatas_id'] = $perfdatas_id;
         $input['position'] = $position;
         $input['dsname_num'] = count($data['values']);
         for ($i = 1; $i <= $input['dsname_num']; $i++) {
             $input['dsname' . $i] = 'value' . $position . '.' . $i;
         }
         $pmPerfdataDetail->add($input);
     }
 }
  ------------------------------------------------------------------------

  @package   Plugin Monitoring for GLPI
  @author    David Durieux
  @co-author
  @comment
  @copyright Copyright (c) 2011-2014 Plugin Monitoring for GLPI team
  @license   AGPL License 3.0 or (at your option) any later version
             http://www.gnu.org/licenses/agpl-3.0-standalone.html
  @link      https://forge.indepnet.net/projects/monitoring/
  @since     2013

  ------------------------------------------------------------------------
*/
include "../../../inc/includes.php";
Session::checkRight("plugin_monitoring_perfdata", READ);
$pmPerfdataDetail = new PluginMonitoringPerfdataDetail();
if (isset($_POST["update"])) {
    foreach ($_POST as $name => $value) {
        if (strstr($name, 'dsnameincr') && $value == 'on') {
            $_POST[$name] = 1;
        }
    }
    for ($i = 1; $i <= 15; $i++) {
        if (!isset($_POST['dsnameincr' . $i])) {
            $_POST['dsnameincr' . $i] = 0;
        }
    }
    $pmPerfdataDetail->update($_POST);
    Html::back();
}